:root {
  color-scheme: light;
  --bg: #eef3f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --muted-strong: #475569;
  --line: #d9e2ec;
  --line-strong: #c4d0dd;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #e6f5f3;
  --accent: #2563eb;
  --danger: #b42318;
  --ok: #0f766e;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(238, 243, 247, 0.96) 280px),
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.10), transparent 320px),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 650;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

button:hover:not(:disabled) {
  border-color: #94a3b8;
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.20);
}

button.primary:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  max-width: 1540px;
  margin: 0 auto;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.hero-copy {
  min-width: 0;
  max-width: 820px;
}

.eyebrow {
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.hero h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0;
}

.hero p {
  margin: 10px 0 0;
  color: var(--muted-strong);
  line-height: 1.65;
  max-width: 760px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(190px, 1.05fr) repeat(3, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.file-picker input,
.switch-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.action-card,
.switch-card {
  position: relative;
  min-width: 0;
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.action-card:hover,
.switch-card:hover {
  border-color: #94a3b8;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.action-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 22px;
  font-weight: 800;
}

.action-card strong,
.switch-card strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  margin-bottom: 4px;
}

.action-card em,
.switch-card em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
}

.switch-ui {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.15s ease;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
  transition: transform 0.15s ease;
}

.switch-card input:checked + .switch-ui {
  background: var(--primary);
}

.switch-card input:checked + .switch-ui::after {
  transform: translateX(18px);
}

.metrics {
  display: grid;
  grid-template-columns: 132px 132px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card,
.message {
  min-height: 62px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  padding: 10px 14px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  margin-bottom: 4px;
}

.metric-card strong {
  font-size: 24px;
  line-height: 1;
}

.message {
  color: var(--muted-strong);
  font-size: 14px;
  line-height: 1.5;
}

.message.error {
  color: var(--danger);
  background: #fff7f7;
  border-color: #fecaca;
}

.message.ok {
  color: var(--ok);
  background: #f0fdfa;
  border-color: #99f6e4;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.panel-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

textarea {
  width: 100%;
  min-height: 57vh;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--text);
  padding: 14px;
  outline: none;
  line-height: 1.58;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.035);
}

textarea::placeholder {
  color: #94a3b8;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13), inset 0 1px 2px rgba(15, 23, 42, 0.035);
  background: #fff;
}

#outputText {
  background: #f8fafc;
}

@media (max-width: 1120px) {
  .control-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics {
    grid-template-columns: 132px 132px minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 14px;
  }

  .hero {
    align-items: stretch;
    flex-direction: column;
  }

  .hero h1 {
    font-size: 28px;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .control-strip,
  .layout,
  .metrics {
    grid-template-columns: 1fr;
  }

  .metric-card,
  .message {
    min-height: 54px;
  }

  textarea {
    min-height: 44vh;
  }
}

@media (max-width: 520px) {
  button {
    width: 100%;
  }

  .hero-actions {
    width: 100%;
  }

  .action-card,
  .switch-card {
    min-height: 70px;
  }
}
