:root {
  color-scheme: light;
  --bg: #f3ecdf;
  --surface: #fffaf3;
  --text: #1d1814;
  --muted: #5c5146;
  --line: #e0d3c2;
  --brass: #8a4b12;
  --brass-soft: #f4e2cc;
  --ember: #c2410c;
  --ember-ink: #fff8f4;
  --good: #1f6b45;
  --danger: #9f2d2d;
  --shadow: 0 18px 40px rgba(70, 42, 14, 0.08);
  --plate: #fffdf9;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: system-ui, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #12100e;
    --surface: #1d1915;
    --text: #f6f0e6;
    --muted: #c4b6a4;
    --line: #3c342c;
    --brass: #f0b56a;
    --brass-soft: #3a2c1e;
    --ember: #e4884d;
    --ember-ink: #1a100c;
    --good: #9ed6b4;
    --danger: #f0a8a0;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    --plate: #16130f;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 0% -10%, color-mix(in srgb, var(--ember) 22%, transparent), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, color-mix(in srgb, var(--brass) 18%, transparent), transparent 50%),
    var(--bg);
}

body, button, input { font: inherit; }

button, input { color: inherit; }

/* Ignore clicks until the module has bound its listeners. */
body:not(.ready) button,
body:not(.ready) input,
body:not(.ready) a.home { pointer-events: none; }

button {
  cursor: pointer;
  border-radius: 10px;
  min-height: 40px;
  padding: 8px 14px;
}

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

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

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

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

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

.top, main, footer {
  width: min(920px, calc(100% - 32px));
  margin-inline: auto;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  padding: 28px 0 8px;
}

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

.brand img { border-radius: 10px; }

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

h1, h2 { font-family: var(--serif); font-weight: 600; }

h1 { margin: 0; font-size: 2rem; line-height: 1; letter-spacing: -0.02em; }

h2 { margin: 0; font-size: 1.45rem; }

.stats {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

main { display: grid; gap: 22px; padding-bottom: 28px; }

.composer, .bench {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.composer {
  padding: 18px;
  display: grid;
  gap: 14px;
  border-left: 4px solid var(--ember);
}

.field { display: grid; gap: 6px; }

label { font-size: 0.92rem; font-weight: 650; }

label span { color: var(--muted); font-weight: 500; }

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

input[aria-invalid="true"] { border-color: var(--danger); }

.hot { color: var(--brass); font-weight: 700; }

.split { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }

.form-actions { display: flex; justify-content: flex-end; }

.error { margin: 0; color: var(--danger); }

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

.bench { padding: 16px 16px 8px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.toolbar h2 { margin-right: auto; }

.toolbar input { width: min(240px, 100%); min-height: 40px; }

.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.empty {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 28px 18px;
  text-align: center;
  margin-bottom: 12px;
}

.empty p { margin: 0 auto 8px; max-width: 42ch; color: var(--muted); }

.empty-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  color: var(--text);
}

.empty button, a.home { margin-top: 8px; }

a.home {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

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

.stamp {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--plate);
}

.code-plate {
  display: grid;
  place-items: center;
  min-height: 76px;
  padding: 8px;
  border-radius: 12px;
  background: var(--brass-soft);
  color: var(--brass);
  border: 1px dashed color-mix(in srgb, var(--brass) 55%, var(--line));
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  overflow-wrap: anywhere;
}

.stamp-body { min-width: 0; display: grid; gap: 4px; align-content: start; }

.stamp-label { font-weight: 700; }

.stamp-url {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta { margin: 0; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.actions button { min-height: 36px; padding: 6px 10px; font-size: 0.92rem; }

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

footer {
  padding: 4px 0 36px;
  color: var(--muted);
  font-size: 0.9rem;
}

footer p { margin: 0; }

dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(18, 14, 10, 0.62); }

dialog form { display: grid; gap: 12px; margin: 0; }

#leave-title { overflow-wrap: anywhere; font-size: 1.35rem; line-height: 1.25; }

.leave-url {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  overflow-wrap: anywhere;
  max-height: 7rem;
  overflow: auto;
}

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

#qr-svg { width: min(240px, 70vw); height: auto; }

.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 5;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100% - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
}

.toast[hidden] { display: none; }
.toast:not([hidden]) { display: flex; }

.toast button {
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  min-height: 36px;
}

.noscript {
  width: min(920px, calc(100% - 32px));
  margin: 12px auto;
}

@media (max-width: 640px) {
  .top { align-items: start; flex-direction: column; padding-top: 20px; }
  h1 { font-size: 1.7rem; }
  .split, .stamp { grid-template-columns: 1fr; }
  .form-actions button, .toolbar input { width: 100%; }
  .code-plate { min-height: 52px; }
  .toast { left: 12px; right: 12px; top: auto; bottom: 12px; max-width: none; }
}

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