:root {
  color-scheme: light;
  --paper: #f5f4f0;
  --sheet: #fff;
  --ink: #181a19;
  --muted: #525751;
  --rule: #d4d7d0;
  --accent: #1c583e;
  --on-accent: white;
  --tint: #e1f0e6;
  font: 100%/1.55 Inter, ui-sans-serif, system-ui, sans-serif;
}

[data-tool="csv"] {
  --paper: #f2f3fa;
  --accent: #37328c;
  --tint: #eae7ff;
}
[data-tool="utm"] {
  --paper: #faf3ee;
  --accent: #9b3a24;
  --tint: #f8e5dc;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
a { color: var(--accent); text-underline-offset: 0.2em; }
[hidden] { display: none !important; }
header, main, footer { width: min(100% - 2.5rem, 69rem); margin-inline: auto; }
header { display: flex; justify-content: space-between; gap: 1rem; align-items: center; border-bottom: 1px solid var(--rule); min-height: 4.5rem; }
.wordmark { color: var(--ink); text-decoration: none; font-size: 1.15rem; font-weight: 800; letter-spacing: -0.035em; }
header span { color: var(--muted); font-size: .875rem; text-align: right; }
.hero { padding: clamp(2rem, 5vw, 4.5rem) 0 2.1rem; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2.2rem, 6vw, 4.7rem); line-height: 0.99; letter-spacing: -.065em; max-width: 15ch; }
.hero p { margin-top: 1rem; max-width: 54ch; font-size: clamp(1rem, 2vw, 1.2rem); color: var(--muted); }
.shell { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; }
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: 1rem; padding: clamp(1rem, 3vw, 1.5rem); min-width: 0; }
.panel h2 { font-size: 1.35rem; letter-spacing: -.035em; }
.panel p { color: var(--muted); margin-top: .55rem; }
.field { display: grid; gap: .45rem; margin-top: .85rem; }
label { font-weight: 680; font-size: .94rem; }
input, textarea, select, button, .file { min-height: 2.65rem; font: inherit; color: inherit; }
textarea, input:not([type="file"]), select { width: 100%; outline-offset: 2px; border: 1px solid var(--rule); border-radius: .55rem; background: #fbfbfa; padding: .55rem .7rem; }
textarea { padding: .8rem; font: .9rem/1.55 ui-monospace, monospace; min-height: 11rem; resize: vertical; tab-size: 4; }
textarea::placeholder { color: #626662; }
button, .file { padding: .55rem .9rem; border: 1px solid var(--rule); border-radius: .55rem; background: var(--sheet); font-weight: 690; cursor: pointer; }
button:hover, .file:hover { background: var(--tint); }
button:disabled { opacity: .52; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover { filter: brightness(1.14); }
.file { display: inline-flex; align-items: center; }
.file input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.file:focus-within, :where(a, input, button, select, textarea):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.controls { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; margin-top: .9rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
#status { min-height: 1.25rem; margin: .85rem 0 .25rem; font-size: .95rem; color: var(--accent); }
#status[data-error="true"] { color: #922616; }
#output { margin-top: 1rem; }
.table-wrap { overflow: auto; max-height: 26rem; margin-top: .85rem; border: 1px solid var(--rule); border-radius: .55rem; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; text-align: left; }
th, td { padding: .65rem; vertical-align: top; border-bottom: 1px solid var(--rule); }
td { min-width: 5ch; max-width: 35ch; overflow-wrap: anywhere; white-space: pre-wrap; }
th { position: sticky; top: 0; background: var(--tint); }
.guide { padding: 1.1rem 0; max-width: 66ch; }
.guide:first-of-type { margin-top: 1.05rem; }
.guide:last-child { margin-bottom: 1.8rem; }
.guide h2 { font-size: 1.45rem; letter-spacing: -.04em; }
.guide p { margin-top: .65rem; color: var(--muted); }
footer { border-top: 1px solid var(--rule); padding: 1rem 0 2rem; color: var(--muted); font-size: .875rem; }

@media (max-width: 47rem) {
  .shell { grid-template-columns: 1fr; }
  header, main, footer { width: min(100% - 1.5rem, 69rem); }
}
@media (max-width: 28rem) {
  .pair { grid-template-columns: 1fr; gap: 0; }
}
