:root {
  --bg: #e4eef0;
  --glow: rgba(12, 110, 104, 0.16);
  --ink: #102028;
  --muted: #4c6270;
  --card: #f7fbfb;
  --line: #c5d5dc;
  --accent: #0c6e68;
  --accent-ink: #f4fffd;
  --warn: #9a3412;
  --warn-bg: #fff6f0;
  --good: #0f6b45;
  --shadow: 0 10px 30px rgba(16, 32, 40, 0.06);
  --sans: "Segoe UI", "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1418;
    --glow: rgba(62, 207, 184, 0.14);
    --ink: #e7eef2;
    --muted: #a9bdc8;
    --card: #152026;
    --line: #2c4250;
    --accent: #3ecfb8;
    --accent-ink: #04221e;
    --warn: #f0a070;
    --warn-bg: #2a1b14;
    --good: #8ee0b8;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

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

.shell {
  width: min(1040px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2.5rem;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  z-index: 5;
}

.skip:focus { top: 0.75rem; }

.mast { margin-bottom: 1.25rem; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.mark {
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  color: var(--accent);
}

.mark rect { fill: currentColor; }

.mark path {
  fill: none;
  stroke: var(--accent-ink);
  stroke-width: 2.2;
  stroke-linecap: round;
}

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

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 700;
}

h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 680;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.15rem 1.15rem 1.2rem;
  box-shadow: var(--shadow);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  margin: 0;
}

.stats p {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
}

.stats b {
  display: block;
  font-size: 1.6rem;
  line-height: 1.1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

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

.field { margin-bottom: 0.85rem; }

label {
  display: block;
  font-size: 0.88rem;
  font-weight: 650;
  margin-bottom: 0.35rem;
}

.opt {
  font-weight: 500;
  color: var(--muted);
}

input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--mono);
}

.actions, .copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.actions { margin-top: 0.2rem; }

button, .primary, .ghost {
  min-height: 44px;
  padding: 0.5rem 0.95rem;
  border-radius: 10px;
  font: 650 0.95rem/1 var(--sans);
  cursor: pointer;
}

button { color: inherit; }

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid transparent;
  text-decoration: none;
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.primary:hover { filter: brightness(1.08); }

.ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }

button:disabled { opacity: 0.55; cursor: not-allowed; }

:focus { outline: none; }

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

.hint, .fine, .empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.hint { margin: 0.75rem 0 0; }

.fine { margin: 0.85rem 0 0; }

.error {
  margin: 0.7rem 0 0;
  color: var(--warn);
  font-weight: 650;
}

.error:empty { display: none; }

.result { margin: 0; }

.result-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.9rem;
}

#result-title { overflow-wrap: anywhere; }

.qr-hit {
  width: 6.5rem;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #102028;
  display: grid;
  gap: 0.2rem;
  justify-items: center;
  flex: none;
}

.qr-hit svg { width: 5.4rem; height: 5.4rem; display: block; }

.qr-caption { font: 600 0.68rem/1.2 var(--sans); color: #3d5160; }

.copy-row { margin-bottom: 0.75rem; align-items: stretch; }

.field-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 650;
  margin: 0 0 0.35rem;
}

.url-out {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font: 14px/1.45 var(--mono);
  overflow-wrap: anywhere;
}

.copy-row button { flex: none; align-self: center; }

.library { margin: 0; }

.library-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.library-head .hint { margin: 0; }

.list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 0.85rem 0.95rem;
  display: grid;
  gap: 0.55rem;
}

.item-title {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.item-url {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.item-meta {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.item-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.item-actions button {
  min-height: 40px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.warn {
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
}

.leave-label {
  display: inline-block;
  margin: 0.8rem 0 0;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  color: var(--warn);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.leave-host {
  margin: 0.45rem 0 0;
  font-size: clamp(1.55rem, 4vw, 2.35rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
  font-weight: 750;
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

.leave-host:empty, .leave-url:empty { display: none; }

.leave-url {
  margin: 0.55rem 0 0;
  font-family: var(--mono);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

#leave .actions { margin-top: 1rem; }

.col { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }

@media (min-width: 900px) {
  .desk {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 1rem;
    align-items: start;
  }
}

html[data-route="go"] body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

html[data-route="go"] .shell {
  width: min(720px, calc(100% - 2rem));
  margin: auto;
}

html[data-route="desk"] #leave { display: none; }

html[data-route="go"] .lede,
html[data-route="go"] .desk { display: none; }

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  padding: 1.1rem;
  width: min(22rem, calc(100% - 2rem));
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(8, 14, 18, 0.55); }

#qr-slot {
  margin: 0.8rem 0;
  background: #fff;
  border-radius: 12px;
  padding: 0.6rem;
}

#qr-slot svg { width: 100%; height: auto; display: block; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  display: flex;
  gap: 0.75rem;
  align-items: center;
  background: var(--ink);
  color: var(--bg);
  padding: 0.55rem 0.7rem 0.55rem 0.95rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 6;
  max-width: calc(100% - 2rem);
}

.toast button {
  min-height: 36px;
  background: transparent;
  color: inherit;
  border: 1px solid color-mix(in srgb, var(--bg) 40%, transparent);
}

.noscript {
  width: min(960px, calc(100% - 2rem));
  margin: 1rem auto;
  padding: 0.8rem 1rem;
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 12px;
}

@media (max-width: 640px) {
  .shell { width: min(960px, calc(100% - 1.25rem)); padding-top: 1.1rem; }
  .stats { gap: 0.45rem; }
  .stats p { padding: 0.65rem 0.55rem; }
  .stats b { font-size: 1.3rem; }
  .stats span { font-size: 0.72rem; }
  .copy-row { flex-direction: column; align-items: stretch; }
  .copy-row button, .actions > button, .actions > .primary { width: 100%; }
  .result-top { flex-direction: column-reverse; }
  .qr-hit { width: 100%; grid-template-columns: 5.4rem 1fr; justify-items: start; align-items: center; }
  .library-head { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
}

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