:root {
  --bg: #efe6d8;
  --glow-a: #ffe1b5;
  --glow-b: #ffd2c8;
  --ink: #1c1915;
  --muted: #5e574e;
  --card: #fffdf8;
  --line: #e3d9cb;
  --field: #fff;
  --accent: #c4321f;
  --accent-ink: #fffaf6;
  --ring: #1c1915;
  --pill: #efe8dc;
  --pill-ink: #3f3a34;
  --ok: #1e4d32;
  --ok-bg: #e5f2e6;
  --warn: #8a2b1b;
  --warn-bg: #f8e4dc;
  --shadow: 0 16px 40px rgb(40 24 12 / 0.08);
  --track: #e6ddd0;
  --fill: #c4321f;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12110f;
    --glow-a: #3a241c;
    --glow-b: #2c2618;
    --ink: #f6f1e8;
    --muted: #c4b8a8;
    --card: #1c1a17;
    --line: #3a342e;
    --field: #141311;
    --accent: #ff5a45;
    --accent-ink: #1c1915;
    --ring: #f6f1e8;
    --pill: #2a2622;
    --pill-ink: #f6f1e8;
    --ok: #b7e0c4;
    --ok-bg: #1a3326;
    --warn: #ffb4a4;
    --warn-bg: #3a221c;
    --shadow: 0 16px 40px rgb(0 0 0 / 0.35);
    --track: #3a342e;
    --fill: #ff5a45;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #12110f;
  --glow-a: #3a241c;
  --glow-b: #2c2618;
  --ink: #f6f1e8;
  --muted: #c4b8a8;
  --card: #1c1a17;
  --line: #3a342e;
  --field: #141311;
  --accent: #ff5a45;
  --accent-ink: #1c1915;
  --ring: #f6f1e8;
  --pill: #2a2622;
  --pill-ink: #f6f1e8;
  --ok: #b7e0c4;
  --ok-bg: #1a3326;
  --warn: #ffb4a4;
  --warn-bg: #3a221c;
  --shadow: 0 16px 40px rgb(0 0 0 / 0.35);
  --track: #3a342e;
  --fill: #ff5a45;
  color-scheme: dark;
}

:root[data-theme="light"] {
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1000px 420px at 0% -10%, var(--glow-a), transparent 55%),
    radial-gradient(800px 380px at 100% 0%, var(--glow-b), transparent 50%),
    var(--bg);
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus { outline: none; }

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

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

.skip:focus { top: 12px; }

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 20px 32px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand h1 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 700;
}

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

.mark { width: 32px; height: 32px; flex: none; }

.lede {
  margin: 10px 0 18px;
  max-width: 62ch;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  align-items: start;
}

.work, .stage { min-width: 0; }

.composer, .library {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.composer { padding: 16px; }

.url-row, .meta-row {
  display: grid;
  gap: 12px;
}

.url-row { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }

.meta-row { grid-template-columns: 1fr 1fr; margin-top: 12px; }

.field { display: grid; gap: 6px; min-width: 0; }

label { font-size: 13px; font-weight: 650; }

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

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

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

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

.btn.ghost { background: transparent; }

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

.shutter { padding-inline: 18px; }

.text-btn {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 44px;
}

.quiet { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

.banner {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--pill);
  color: var(--pill-ink);
}

.banner.bad {
  background: var(--warn-bg);
  color: var(--warn);
}

.library { margin-top: 16px; padding: 14px; }

.library-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
}

.library-head h2 { margin: 0; font-size: 18px; }

.library-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.library-tools input { width: 140px; min-height: 44px; }

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

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

.snap-row {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--field);
}

.snap-row[aria-current="true"] { border-color: var(--accent); }

.row-code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-weight: 700;
}

.row-meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; color: var(--muted); font-size: 13px; }

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin: 8px 0 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--pill);
  color: var(--pill-ink);
  font-size: 12px;
  font-weight: 650;
}

.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--warn-bg); color: var(--warn); }
.pill.never { background: var(--pill); color: var(--pill-ink); }

.polaroid {
  background: #fbf6ee;
  color: #1c1915;
  border-radius: 8px 8px 18px 18px;
  padding: 14px 14px 18px;
  box-shadow: 0 18px 40px rgb(28 20 12 / 0.16);
}

.polaroid .kicker { color: #6b635a; }

.kicker {
  margin: 0 0 6px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.qr {
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  max-width: 240px;
  margin: 0 auto;
}

.ghost-lens {
  width: 72px;
  height: 72px;
  margin: 4px auto 12px;
  border-radius: 50%;
  border: 4px solid #1c1915;
  background:
    radial-gradient(circle at 50% 50%, #ff5a45 0 42%, #1c1915 43% 56%, #fbf6ee 57% 100%);
}

.qr svg { width: 100%; height: auto; display: block; }

.caption {
  margin: 12px 0 0;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.host { margin: 4px 0 0; color: #5e574e; }

.url {
  margin: 8px 0 0;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.url.share {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.polaroid .quiet { color: #5e574e; }

.polaroid .btn {
  background: transparent;
  color: #1c1915;
  border-color: #d9d0c3;
}

.polaroid .btn.primary {
  background: #c4321f;
  border-color: #c4321f;
  color: #fffaf6;
}

.polaroid .btn.danger { color: #8a2b1b; border-color: #e7c7bc; }

.polaroid .pill.ok { background: #e5f2e6; color: #1e4d32; }
.polaroid .pill.bad { background: #f8e4dc; color: #8a2b1b; }
.polaroid .pill.never { background: #efe8dc; color: #3f3a34; }

.polaroid .banner { background: #efe8dc; color: #3f3a34; }

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

.stats { margin-top: 16px; padding-top: 12px; border-top: 1px solid #e6ddd0; }

.stats h2 { margin: 0; font-size: 15px; }

.stats ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: #3f3a34; }

.bar {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 24px;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  font-size: 13px;
}

.track {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: #e6ddd0;
  overflow: hidden;
}

.track span {
  display: block;
  height: 100%;
  background: #c4321f;
  border-radius: inherit;
}

.status {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 24px);
}

dialog::backdrop { background: rgb(16 12 8 / 0.64); }

.leave {
  width: min(440px, 100%);
  margin: 0;
  padding: 20px;
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.leave h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.25; }

.leave .actions { margin-top: 16px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .stage { order: 2; }
}

@media (max-width: 640px) {
  .shell { padding: 16px 16px 28px; }
  .brand h1 { font-size: 28px; }
  .url-row, .meta-row { grid-template-columns: 1fr; }
  .shutter { width: 100%; }
  .library-tools input { width: 100%; }
  .caption { font-size: 24px; }
}

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