:root {
  --bg: #f0fdfa;
  --ink: #134e4a;
  --muted: #475569;
  --card: #ffffff;
  --line: #6e8f8c;
  --soft: #ccfbf1;
  --primary: #0d9488;
  --on-primary: #000000;
  --accent: #ea580c;
  --on-accent: #000000;
  --danger: #dc2626;
  --on-danger: #ffffff;
  --danger-fill: #dc2626;
  --danger-soft: #fef2f2;
  --focus: #0d9488;
  --qr-bg: #ffffff;
  --move: 160ms;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #042f2e;
    --ink: #f0fdfa;
    --muted: #cbd5e1;
    --card: #0c3f3c;
    --line: #5c9a93;
    --soft: #134e4a;
    --primary: #2dd4bf;
    --on-primary: #042f2e;
    --accent: #ea580c;
    --on-accent: #000000;
    --danger: #fecaca;
    --on-danger: #ffffff;
    --danger-fill: #dc2626;
    --danger-soft: #3f1d1d;
    --focus: #5eead4;
    --qr-bg: #ffffff;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  border-top: 4px solid var(--primary);
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Plus Jakarta Sans", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
h1, h2, h3, p { margin: 0; }
h1, h2, .tag { text-wrap: balance; }
h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.3; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button, a, .qr-hit { touch-action: manipulation; }
button, a.btn, .qr-hit { cursor: pointer; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: absolute;
  left: 12px;
  top: 12px;
  transform: translateY(-160%);
  background: var(--primary);
  color: var(--on-primary);
  padding: 8px 12px;
  border-radius: 999px;
  z-index: 5;
  text-decoration: none;
  font-weight: 600;
}
.skip:focus { transform: none; }
.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 24px calc(48px + env(safe-area-inset-bottom));
}
header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 16px;
  row-gap: 8px;
  margin-bottom: 24px;
}
.logo {
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 2.5rem);
  letter-spacing: -0.045em;
  text-decoration: none;
  line-height: 1;
  color: inherit;
}
.logo span { box-shadow: inset 0 -0.22em 0 var(--accent); }
.tag { grid-column: 1 / -1; color: var(--muted); max-width: 42ch; }
.stat {
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.banner, .status { min-height: 1.5em; margin: 8px 0; }
.banner {
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 12px;
  color: var(--danger);
  background: var(--danger-soft);
}
.status.bad, .note.bad { color: var(--danger); }
.boot { display: none; margin: 0 0 16px; color: var(--muted); }
html.opening .boot { display: block; }
html.opening #desk, html.opening footer { display: none; }
#form, .hero, .empty, .gate, .row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}
#form { padding: 20px; }
.url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label label"
    "input button"
    "error error";
  gap: 8px 12px;
  align-items: center;
}
.url-row label { grid-area: label; display: block; }
.url-row input { grid-area: input; }
.url-row .btn { grid-area: button; min-width: 7.5rem; }
.url-row .field-error { grid-area: error; }
.fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}
label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
  min-width: 0;
}
.req { color: var(--accent); margin-left: 2px; }
.hint, .field-error { font-weight: 400; font-size: 0.875rem; line-height: 1.4; }
.hint { color: var(--muted); }
.field-error { color: var(--danger); }
label:has(.field-error:not([hidden])) .hint { display: none; }
::placeholder { color: var(--muted); opacity: 1; }
input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  transition: border-color var(--move) ease, background-color var(--move) ease;
}
input[aria-invalid="true"] {
  border-color: var(--danger);
  background: var(--danger-soft);
}
input[aria-invalid="true"]:focus-visible { outline-color: var(--danger); }
.form-errors {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 12px;
  color: var(--danger);
  background: var(--danger-soft);
}
.form-errors p { font-weight: 700; }
.form-errors ul { margin: 8px 0 0; padding-left: 1.2em; }
.form-errors a { color: inherit; }
.form-errors:focus { outline: 3px solid var(--danger); outline-offset: 3px; }
.btn {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background-color var(--move) ease, border-color var(--move) ease, color var(--move) ease, opacity var(--move) ease;
}
.btn.accent { background: var(--accent); color: var(--on-accent); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--danger-fill); color: var(--on-danger); border-color: transparent; }
.btn:hover { background: #14b8a6; }
.btn.accent:hover { background: #f97316; }
.btn.ghost:hover { background: var(--soft); color: var(--ink); }
.btn.danger:hover { background: #b91c1c; color: var(--on-danger); }
.btn:active { opacity: 0.88; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 8px 24px;
  padding: 20px;
  margin: 8px 0 16px;
  animation: rise 180ms ease;
}
.eyebrow {
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.slug {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
#hero-name { margin-top: 4px; overflow-wrap: anywhere; }
#leave-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.dest, .leave-url, .row .sub {
  overflow-wrap: anywhere;
  min-width: 0;
}
.dest, .leave-url {
  margin-top: 8px;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.9375rem;
  line-height: 1.45;
}
.cutline { margin-top: 12px; font-variant-numeric: tabular-nums; }
.cutbar {
  height: 8px;
  margin-top: 8px;
  border-radius: 99px;
  background: var(--soft);
  overflow: hidden;
}
.cutbar span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.meta, .note { color: var(--muted); margin-top: 8px; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.analytics { grid-column: 1 / -1; margin-top: 8px; min-height: 48px; }
.chart-cap {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.bars {
  display: flex;
  align-items: end;
  gap: 6px;
  height: 64px;
  border-bottom: 1px solid var(--line);
}
.bar { flex: 1; background: var(--primary); border-radius: 4px 4px 0 0; min-width: 0; }
.bar[data-zero="1"] { height: 2px; background: var(--line); }
.meters { display: grid; gap: 8px; margin-top: 12px; }
.meter-row {
  display: grid;
  grid-template-columns: minmax(4.5rem, 7.5rem) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 0.9375rem;
}
.meter { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--primary); }
.meter-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.qr-col { display: grid; align-content: start; justify-items: center; gap: 8px; }
.qr-col .note { margin-top: 0; text-align: center; max-width: 148px; }
.qr-hit { padding: 0; border: 0; background: transparent; border-radius: 12px; }
.qr-frame, #qr-big { background: var(--qr-bg); border-radius: 12px; padding: 8px; border: 1px solid var(--line); }
.qr-frame { width: 148px; height: 148px; }
.qr-frame svg, #qr-big svg { display: block; width: 100%; height: auto; }
#qr-big { width: min(360px, 100%); }
.lib-head { margin: 8px 0 12px; }
.empty {
  padding: 20px;
  display: grid;
  gap: 12px;
  justify-items: start;
}
.empty-lead { display: flex; gap: 12px; align-items: flex-start; }
.empty-mark { color: var(--primary); flex: none; margin-top: 3px; }
.empty-dot { fill: var(--accent); }
.empty p { max-width: 48ch; }
.list { display: grid; gap: 12px; }
.row {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
}
.row.active { border-color: var(--primary); }
.row .slugline {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.0625rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.row .sub { color: var(--muted); }
.row .acts { grid-column: 1 / -1; margin-top: 8px; }
.badge {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 0.9375rem;
  font-weight: 600;
}
.gate { padding: 24px; }
.leave-url {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}
#leave > .acts { margin-top: 16px; }
footer {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: grid;
  gap: 16px;
}
footer p { max-width: 68ch; }
dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  padding: 24px;
  width: min(440px, calc(100% - 24px));
}
dialog[open] { animation: rise 160ms ease; }
dialog::backdrop { background: rgba(4, 47, 46, 0.72); }
dialog .btn { margin-top: 16px; }
::selection { background: #99f6e4; color: #134e4a; }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 720px) {
  .wrap { padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); }
  header { margin-bottom: 16px; }
  #form { padding: 16px; }
  .fields { gap: 12px; margin-top: 12px; }
  input, .btn { min-height: 44px; }
  .empty { padding: 16px; }
  .lib-head { margin: 4px 0 8px; }
  .url-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "label"
      "input"
      "button"
      "error";
  }
  .url-row .btn { width: 100%; }
  .fields { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .analytics { grid-column: auto; }
  .qr-col { justify-items: start; }
  .qr-col .note { text-align: left; }
}
@media (max-width: 360px) {
  header { grid-template-columns: minmax(0, 1fr); }
  .stat { justify-self: start; max-width: 100%; white-space: normal; }
}
@media (prefers-color-scheme: dark) {
  ::selection { background: #115e59; color: #f0fdfa; }
  .btn:hover { background: #5eead4; color: #042f2e; }
  .btn.accent:hover { background: #f97316; color: #000000; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
