:root {
  color-scheme: light;
  --bg: #f3eee6;
  --bg-2: #e7e0d4;
  --ink: #1c1612;
  --muted: #5e554c;
  --line: #d9d0c3;
  --card: #fffdf8;
  --accent: #c2411a;
  --accent-ink: #fff8f4;
  --glow: #ffd8c4;
  --danger: #9d1c2b;
  --shadow: 0 16px 40px rgba(70, 42, 18, 0.08);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #12100e;
    --bg-2: #221c17;
    --ink: #f6f0e6;
    --muted: #c4b8a8;
    --line: #3c342c;
    --card: #1c1814;
    --accent: #ff7a4d;
    --accent-ink: #1a0c08;
    --glow: #3a2018;
    --danger: #ff9aa6;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  background:
    radial-gradient(900px 420px at 8% -10%, var(--glow), transparent 55%),
    var(--bg);
}

.wrap {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 22px 20px 64px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--card);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 5;
}

.skip:focus { top: 12px; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}

.brand { display: flex; gap: 14px; align-items: center; }

.mark { width: 44px; height: 44px; color: var(--ink); flex: none; }

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 2.2rem;
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.brand p, .foot p { margin: 4px 0 0; color: var(--muted); }

.pill {
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

h2 {
  margin: 18px 0 10px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.card, .link, dialog {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.composer { padding: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

label, .file {
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

label span { font-weight: 500; letter-spacing: 0; text-transform: none; }

input[type="text"] {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.3 var(--sans);
}

input::placeholder { color: color-mix(in srgb, var(--muted) 65%, transparent); }

.compose-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
}

[hidden] { display: none !important; }

button, .primary, .file {
  font: inherit;
  cursor: pointer;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 0.55rem 0.95rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

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

button:focus-visible, a:focus-visible, input:focus-visible, .file:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.error { min-height: 1.2em; margin: 10px 0 0; color: var(--danger); }

.error:empty { margin: 0; }

.pulse { margin-top: 18px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 82%, transparent);
}

.stat b {
  display: block;
  font-family: var(--serif);
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.stat b.num { font-size: 1.8rem; line-height: 1; }

.stat b.host { font-family: var(--sans); font-size: 1rem; font-weight: 650; }

.caption {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat span { color: var(--muted); font-size: 0.82rem; }

.bars {
  display: flex;
  align-items: end;
  gap: 8px;
  height: 64px;
  margin-top: 8px;
}

.bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: center;
  gap: 4px;
  height: 100%;
  min-width: 0;
}

.bar i {
  display: block;
  width: 100%;
  max-width: 36px;
  border-radius: 6px 6px 2px 2px;
  background: var(--accent);
  min-height: 4px;
}

.bar i.zero { background: var(--line); }

.bar em {
  font-style: normal;
  font-size: 0.68rem;
  color: var(--muted);
}

.list { display: flex; flex-direction: column; gap: 10px; }

.link { padding: 14px 14px 14px 16px; position: relative; }

.link::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.link-top, .actions, .dialog-actions, .tools, .foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.link-top { justify-content: space-between; align-items: baseline; }

.link h3 { margin: 0; font-size: 1.05rem; font-weight: 650; overflow-wrap: anywhere; }

.code {
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  flex: none;
}

.url, .dest {
  margin: 6px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.meta { margin: 6px 0 10px; font-variant-numeric: tabular-nums; }

.empty {
  padding: 28px 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
}

.empty p { margin: 0; }
.empty p + p { margin-top: 6px; }

.foot {
  justify-content: space-between;
  align-items: end;
  margin-top: 28px;
  gap: 16px;
}

.foot p { max-width: 46ch; margin: 0; }

.file { position: relative; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 1rem; color: var(--ink); }

.file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 22px;
  color: var(--ink);
}

dialog::backdrop { background: rgba(18, 12, 8, 0.62); }

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

dialog h2 { margin: 0 0 8px; font-size: 1.45rem; letter-spacing: 0; text-transform: none; color: var(--ink); font-family: var(--serif); font-weight: 560; }

.leave-name { margin: 0; font-weight: 650; }

.dest {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--bg-2);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 10px;
}

.fine { color: var(--muted); margin: 10px 0; }

.dialog-actions { margin-top: 8px; }

.qr-slot {
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 12px;
  padding: 10px;
}

.qr-slot svg { width: min(240px, 100%); height: auto; }

#qr-close { margin-top: 12px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  max-width: calc(100vw - 32px);
}

#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  .wrap { padding: 18px 16px 80px; }
  h1 { font-size: 2rem; }
  .top, .foot, .compose-row { display: flex; flex-direction: column; align-items: stretch; }
  .pill { align-self: flex-start; }
  .compose-row button, .dialog-actions .primary, .dialog-actions .ghost, .dialog-actions a, #qr-close { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:last-child { grid-column: 1 / -1; }
  .stat b.host { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
