:root {
    --bg: #eef2f0;
    --surface: #ffffff;
    --surface-2: #f4f7f5;
    --ink: #17211d;
    --ink-muted: #56655d;
    --ink-faint: #8a988f;
    --accent: #146356;
    --accent-strong: #0d4b41;
    --accent-soft: #dcece6;
    --line: #d7e0da;
    --code-bg: #10201c;
    --code-text: #d6f3e8;
    --code-key: #7fd8bd;
    --code-muted: #6c8f83;
    --warn-bg: #fbe9e1;
    --warn-ink: #8a3d1e;
    --shadow: 0 1px 2px rgba(18, 40, 33, 0.06), 0 8px 24px -12px rgba(18, 40, 33, 0.18);
    --radius: 10px;
    color-scheme: light;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #0f1614;
      --surface: #16201d;
      --surface-2: #1b2622;
      --ink: #e8f0ec;
      --ink-muted: #9db1a8;
      --ink-faint: #62786f;
      --accent: #5bbaa2;
      --accent-strong: #7fd0ba;
      --accent-soft: #1c2f29;
      --line: #283730;
      --code-bg: #0a1412;
      --code-text: #cdeee1;
      --code-key: #8fe3c6;
      --code-muted: #567368;
      --warn-bg: #2e2119;
      --warn-ink: #e8a67c;
      --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
      color-scheme: dark;
    }
  }
  :root[data-theme="dark"] {
    --bg: #0f1614;
    --surface: #16201d;
    --surface-2: #1b2622;
    --ink: #e8f0ec;
    --ink-muted: #9db1a8;
    --ink-faint: #62786f;
    --accent: #5bbaa2;
    --accent-strong: #7fd0ba;
    --accent-soft: #1c2f29;
    --line: #283730;
    --code-bg: #0a1412;
    --code-text: #cdeee1;
    --code-key: #8fe3c6;
    --code-muted: #567368;
    --warn-bg: #2e2119;
    --warn-ink: #e8a67c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    padding: 32px 20px 80px;
  }
  .wrap { max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

  header.top { display: flex; flex-direction: column; gap: 8px; padding: 4px 2px 4px; }
  header.top .eyebrow {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 600;
  }
  header.top h1 {
    font-size: 26px;
    font-weight: 700;
    margin: 0;
    text-wrap: balance;
    letter-spacing: -0.01em;
  }
  header.top p {
    margin: 0;
    color: var(--ink-muted);
    max-width: 62ch;
    font-size: 14.5px;
  }

  .card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .step-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
  }
  .step-num {
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 6px;
    padding: 3px 8px;
    flex-shrink: 0;
  }
  .step-head h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
  }
  .step-sub { color: var(--ink-muted); font-size: 13.5px; margin: -8px 0 0; }

  .dropzone {
    border: 1.5px dashed var(--line);
    border-radius: var(--radius);
    padding: 28px 16px;
    text-align: center;
    color: var(--ink-muted);
    font-size: 13.5px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    background: var(--surface-2);
  }
  .dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
  .dropzone strong { color: var(--ink); font-weight: 600; }
  .dropzone input { display: none; }
  .file-chip {
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-family: "IBM Plex Mono", monospace;
    background: var(--accent-soft);
    color: var(--accent-strong);
    border-radius: 7px;
    padding: 7px 11px;
    width: fit-content;
  }
  .file-chip.show { display: flex; }
  .file-chip button {
    border: none; background: none; color: inherit; cursor: pointer;
    font-family: inherit; font-size: 13px; text-decoration: underline; padding: 0;
  }

  .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  @media (max-width: 560px) { .row-2 { grid-template-columns: 1fr; } }
  label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-muted); }
  label.field span.name { font-weight: 500; color: var(--ink); }
  select, input[type="number"] {
    font-family: inherit;
    font-size: 13.5px;
    padding: 8px 10px;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
  }
  select:focus, input:focus, button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
  }

  .mapping-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 18px;
  }
  @media (max-width: 640px) { .mapping-grid { grid-template-columns: 1fr; } }
  .map-item { display: flex; flex-direction: column; gap: 5px; }
  .map-item .lab { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
  .map-item .opt { font-weight: 400; color: var(--ink-faint); font-size: 11.5px; }

  .preview-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
  table.preview { border-collapse: collapse; width: 100%; font-size: 12.5px; white-space: nowrap; }
  table.preview th, table.preview td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
  }
  table.preview th {
    background: var(--surface-2);
    color: var(--ink-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    position: sticky; top: 0;
  }
  table.preview td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: "IBM Plex Mono", monospace; }
  table.preview tr:last-child td { border-bottom: none; }
  .count-note { font-size: 12.5px; color: var(--ink-muted); }
  .count-note strong { color: var(--ink); }

  button.primary {
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 11px 18px;
    cursor: pointer;
    transition: background 0.15s ease;
    width: fit-content;
  }
  button.primary:hover { background: var(--accent-strong); }
  button.primary:disabled { background: var(--ink-faint); cursor: not-allowed; }

  .code-panel {
    background: var(--code-bg);
    border-radius: 9px;
    overflow: hidden;
  }
  .code-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .code-toolbar span {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11.5px;
    color: var(--code-muted);
    letter-spacing: 0.02em;
  }
  button.copy {
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    font-weight: 500;
    background: rgba(255,255,255,0.08);
    color: var(--code-text);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    padding: 5px 11px;
    cursor: pointer;
  }
  button.copy:hover { background: rgba(255,255,255,0.16); }
  pre.script-out {
    margin: 0;
    padding: 16px;
    max-height: 340px;
    overflow: auto;
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--code-text);
    white-space: pre;
  }
  pre.script-out .k { color: var(--code-key); }

  ol.howto {
    margin: 0;
    padding-left: 20px;
    font-size: 13.5px;
    color: var(--ink-muted);
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  ol.howto b { color: var(--ink); }
  ol.howto code {
    font-family: "IBM Plex Mono", monospace;
    background: var(--accent-soft);
    color: var(--accent-strong);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
  }

  .warn-box {
    background: var(--warn-bg);
    color: var(--warn-ink);
    font-size: 12.5px;
    border-radius: 8px;
    padding: 10px 12px;
    display: none;
  }
  .warn-box.show { display: block; }

  .empty-state { color: var(--ink-faint); font-size: 13.5px; text-align: center; padding: 20px 0; }

  footer.foot {
    text-align: center;
    color: var(--ink-faint);
    font-size: 12px;
    padding-top: 8px;
  }
