:root {
  color-scheme: light;
  --bg: #f3efe6;
  --bg-raise: #fffdf8;
  --ink: #1a1714;
  --muted: #5e574e;
  --line: #e4dcd0;
  --accent: #0f6e56;
  --accent-ink: #f4fff9;
  --danger: #9f1239;
  --danger-bg: #fff1f2;
  --warn: #92400e;
  --warn-bg: #fffbeb;
  --shadow: 0 1px 0 rgba(26, 23, 20, 0.04), 0 18px 50px rgba(26, 23, 20, 0.06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101210;
    --bg-raise: #1a1d1a;
    --ink: #f4f0e6;
    --muted: #b7b1a6;
    --line: #2e342e;
    --accent: #7ddec8;
    --accent-ink: #06231c;
    --danger: #fda4af;
    --danger-bg: #3f1219;
    --warn: #fcd34d;
    --warn-bg: #3a2a0a;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 320px at 8% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--bg-raise);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 20;
}

.skip:focus { top: 12px; }

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.bar {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #10211c;
  color: #7ddec8;
}

nav { display: flex; gap: 4px; }

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
}

nav a[aria-current="page"] {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}

main {
  flex: 1;
  width: min(980px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 18px 16px 28px;
}

footer p { margin: 0; }

.kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  letter-spacing: -0.03em;
  line-height: 1.12;
}

.lede {
  margin: 12px 0 0;
  max-width: 38rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.card {
  margin-top: 18px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.stats .card { margin-top: 0; }

label, .label {
  display: block;
  font-size: 0.92rem;
  font-weight: 650;
  margin-bottom: 6px;
}

.hint { font-weight: 450; color: var(--muted); }

input, select {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.actions, .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  font: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 650;
}

.btn.danger { color: var(--danger); }

.btn.file { position: relative; overflow: hidden; }

.btn.file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  min-height: 100%;
}

.error, .warn, .note {
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 14px;
  font-size: 0.95rem;
}

.error { background: var(--danger-bg); color: var(--danger); }
.warn { background: var(--warn-bg); color: var(--warn); }
.note { color: var(--muted); padding: 0; }

.result {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.qr {
  width: 180px;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  border: 1px solid var(--line);
}

.mono, .urlbox {
  overflow-wrap: break-word;
}

.mono {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--accent);
  margin: 6px 0 0;
}

.share-line {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
  white-space: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
}

.sub {
  margin: 6px 0 0;
  color: var(--muted);
  overflow-wrap: break-word;
}

.row .grow { display: grid; gap: 2px; }
.row .sub { margin: 0; }

.list { list-style: none; margin: 8px 0 0; padding: 0; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  min-height: 44px;
}

.row:first-child { border-top: 0; }

.row .grow { min-width: 0; flex: 1; }

.slug { font-weight: 650; }
.result .slug {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.badge {
  flex: none;
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 3px 8px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--muted);
}

.badge.warn { background: var(--warn-bg); color: var(--warn); padding: 3px 8px; margin: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.stat p, .panel h2 { margin: 0; }

.big {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 3.4rem;
  letter-spacing: -0.04em;
  line-height: 1;
}

.bars { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }

h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 650;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: capitalize;
}

.track {
  height: 8px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  overflow: hidden;
}

.fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  width: 0;
}

.chart {
  margin-top: 14px;
  height: 120px;
  display: flex;
  align-items: end;
  gap: 6px;
  border-bottom: 1px solid var(--line);
}

.chart i {
  display: block;
  flex: 1;
  background: color-mix(in srgb, var(--accent) 80%, var(--ink));
  border-radius: 6px 6px 2px 2px;
  min-height: 0;
}

.chart i.off {
  background: color-mix(in srgb, var(--ink) 28%, transparent);
  min-height: 6px;
  max-height: 6px;
}

.chart-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 6px;
}

.table-wrap { overflow-x: auto; margin-top: 8px; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }

th, td { text-align: left; padding: 8px 10px 8px 0; white-space: nowrap; }

th { color: var(--muted); font-weight: 550; font-size: 0.78rem; }

td.ref { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }

.urlbox {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.88rem;
}

.empty {
  text-align: center;
  padding: 36px 12px;
  color: var(--muted);
}

.head-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 800px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .result { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .btn.primary { width: 100%; }
  .head-row { flex-direction: column; align-items: stretch; }
  main { padding-top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
