/* SSS: the design system in design.md. Every colour is a light/dark token pair;
   host and guest pages follow the system, the display is always dark. */

:root {
  --canvas: #f7f5f1; --surface: #ffffff; --surface-raised: #ffffff; --surface-sunken: #efebe4;
  --border: #e2ddd4; --border-strong: #8c877e;
  --text: #1b1a18; --text-secondary: #4a4741; --text-tertiary: #615d56;
  --accent: #9a5b00; --accent-hover: #7f4b00; --accent-subtle: #fbefd9; --on-accent: #ffffff;
  --danger: #b42318; --success: #2f6b3a;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --canvas: #0e0d0c; --surface: #181715; --surface-raised: #22201d; --surface-sunken: #0a0908;
    --border: #2c2a26; --border-strong: #6e6a63;
    --text: #f2efe9; --text-secondary: #c9c4bb; --text-tertiary: #a39e95;
    --accent: #f2b33d; --accent-hover: #f6c565; --accent-subtle: #2e2310; --on-accent: #1a1206;
    --danger: #ff8a7a; --success: #8fd19e;
  }
}
:root.dark {
  --canvas: #0e0d0c; --surface: #181715; --surface-raised: #22201d; --surface-sunken: #0a0908;
  --border: #2c2a26; --border-strong: #6e6a63;
  --text: #f2efe9; --text-secondary: #c9c4bb; --text-tertiary: #a39e95;
  --accent: #f2b33d; --accent-hover: #f6c565; --accent-subtle: #2e2310; --on-accent: #1a1206;
  --danger: #ff8a7a; --success: #8fd19e;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--text); font: 400 16px/1.45 var(--sans); }
h1, h2, p { margin: 0; }
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* type */
.title { font-size: 22px; font-weight: 600; line-height: 1.25; }
.subtitle { font-size: 16px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.caption { font-size: 12px; font-weight: 500; line-height: 1.35; }
.mono, code { font-family: var(--mono); }
.secondary { color: var(--text-secondary); }
.hint { color: var(--text-tertiary); font-size: 14px; }
.error { color: var(--danger); }
.error:empty { display: none; }
.tag { border: 1px solid var(--border-strong); color: var(--text-secondary); border-radius: 999px; padding: 1px 8px; }
.link { color: var(--text); text-underline-offset: 3px; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.link.quiet { color: var(--text-tertiary); }
.link.danger { color: var(--danger); }

/* buttons */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 10px; border: 1px solid transparent; font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease); white-space: nowrap; }
.button.primary { background: var(--accent); color: var(--on-accent); }
.button.primary:hover { background: var(--accent-hover); }
.button.secondary { background: transparent; border-color: var(--border-strong); color: var(--text); }
.button.secondary:hover { background: var(--surface-sunken); }
.button.destructive { background: transparent; color: var(--danger); padding: 0; height: auto; }
.button.danger-fill { background: var(--danger); color: var(--canvas); }
.button.big { height: 48px; width: 100%; }
.button.huge { height: 56px; width: 100%; font-size: 18px; }
.icon-button { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; border: 0;
  background: transparent; cursor: pointer; color: var(--text-secondary); }
.icon-button:hover { background: var(--surface-sunken); }
.icon-button.danger:hover { color: var(--danger); }

/* fields */
.field { display: grid; gap: 4px; }
.field > span:first-child { font-size: 14px; font-weight: 500; }
input:not([type]), input[type=text], input[type=email], input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]) {
  height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); width: 100%; font-size: 16px; }
input::placeholder { color: var(--text-tertiary); }
input[aria-invalid=true] { border-color: var(--danger); }
.slug-input { font-size: 20px; height: 56px; text-transform: lowercase; }
input.code { font-size: 22px; letter-spacing: 6px; }
.stack { display: grid; gap: 12px; }

/* host frame */
.top { display: flex; align-items: center; gap: 24px; max-width: 960px; margin: 0 auto; padding: 16px; }
.brand { font-weight: 700; letter-spacing: 0.04em; text-decoration: none; font-size: 18px; }
.top nav { display: flex; gap: 16px; }
.top nav a { text-decoration: none; color: var(--text-secondary); }
.top nav a[aria-current=page] { color: var(--text); font-weight: 600; }
.col { max-width: 960px; margin: 0 auto; padding: 8px 16px 48px; display: grid; gap: 24px; }
.heading { display: flex; align-items: center; gap: 12px; }

.new-room { display: flex; gap: 8px; }
.new-room .field { flex: 1; }
.empty { color: var(--text-secondary); max-width: 560px; }
.room-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.room-list li a { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; padding: 14px 4px;
  border-bottom: 1px solid var(--border); text-decoration: none; }
.room-list li a:hover { background: var(--surface-sunken); }
.room-list .name { font-weight: 600; flex: 1 1 200px; }

/* room page */
.room-top { display: grid; grid-template-columns: 1fr 200px; gap: 24px; align-items: start; }
.preview { display: grid; gap: 12px; justify-items: start; }
.preview iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; background: #0e0d0c; pointer-events: none; }
.share { display: grid; gap: 8px; justify-items: start; }
.share .slug { font-size: 16px; }
.add .uploader > label.button { justify-self: start; }
.qr-box { background: #fff; border-radius: 6px; line-height: 0; width: 100%; }
.qr-box svg { width: 100%; height: auto; }
@media (max-width: 720px) { .room-top { grid-template-columns: 1fr; } .share { grid-template-columns: 120px 1fr; } }

.grid { list-style: none; margin: 0; padding: 8px; display: grid; gap: 8px; background: var(--surface-sunken); border-radius: 10px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.grid li { display: grid; gap: 4px; position: relative; }
.grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--border); }
.grid .meta { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.grid .meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid form { position: absolute; top: 4px; right: 4px; }
.grid form .icon-button { background: var(--surface-raised); }
.grid-section { display: grid; gap: 12px; }
.guest-grid { grid-template-columns: repeat(3, 1fr); padding: 4px; gap: 4px; }
.guest-grid:empty { display: none; }

.settings { display: grid; }
.rows-form { display: grid; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0;
  border-bottom: 1px solid var(--border); min-height: 56px; margin: 0; }
fieldset.row { border: 0; border-bottom: 1px solid var(--border); padding: 12px 0; }
fieldset.row legend { float: left; padding: 0; }
.row > span:first-child, .row > legend { font-weight: 500; }
.row input:not([type=checkbox]):not([type=radio]):not([type=range]) { max-width: 360px; }
.row.end { justify-content: flex-end; }
.row.block { display: grid; justify-content: stretch; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; margin-left: auto; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span { display: block; padding: 6px 12px; font-size: 14px; }
.segmented label + label span { border-left: 1px solid var(--border); }
.segmented input:checked + span { background: var(--accent-subtle); color: var(--text); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.range { display: inline-flex; align-items: center; gap: 12px; }
.range input { accent-color: var(--accent); width: 200px; }
.range output { min-width: 4ch; text-align: right; }
.toggle { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--border-strong); position: relative;
  cursor: pointer; transition: background-color 150ms var(--ease); margin: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); transition: transform 150ms var(--ease); }
.toggle:checked { background: var(--accent); }
.toggle:checked::after { transform: translateX(18px); }
.danger-zone summary { list-style: none; cursor: pointer; }
.danger-zone summary::-webkit-details-marker { display: none; }
.danger-zone[open] { display: grid; justify-content: stretch; }
.danger-zone form { display: grid; gap: 12px; justify-items: start; padding-top: 8px; }
.plain { list-style: none; padding: 0; margin: 0; }
.line { display: flex; gap: 12px; align-items: baseline; padding: 6px 0; }
.line form { margin-left: auto; }
.version { padding-top: 24px; }

/* guest pages */
.narrow { max-width: 480px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 16px 48px; display: grid; gap: 16px; }
.message { padding-top: 15vh; justify-items: start; }
.join { padding-top: 12vh; }
.foot { padding-top: 24px; }
.alt { padding-top: 8px; border-top: 1px solid var(--border); }
.alt .button { width: 100%; }
.uploader { display: grid; gap: 12px; }
#state p { padding: 12px 0; }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rows:empty { display: none; }
.file { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 8px;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.file.done { background: var(--accent-subtle); }
.file img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--surface-sunken); }
.file .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .size { color: var(--text-secondary); }
.file .state { font-size: 14px; display: grid; justify-items: end; gap: 4px; text-align: right; }
.file .bar { width: 72px; height: 4px; background: var(--border); border-radius: 999px; overflow: hidden; }
.file .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 150ms linear; }
.file .ok { color: var(--success); display: inline-flex; gap: 4px; align-items: center; }
.file .dup { color: var(--text-secondary); }
.file .fail { color: var(--danger); }
.file .retry { font-size: 14px; }
@media (min-width: 0) { .guest .button.huge { min-height: 56px; } }

/* display: a stage, always dark */
.display { background: #0e0d0c; overflow: hidden; height: 100vh; height: 100dvh; cursor: default; }
.display.idle, .display.idle * { cursor: none; }
.stage { position: fixed; inset: 0; }
.slide { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0;
  transition: opacity 600ms ease-in-out; }
.slide.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .slide { transition: none; } }

.live-dot { position: absolute; top: 3vh; right: 3vh; width: 10px; height: 10px; border-radius: 999px; background: var(--text-tertiary); }
.live-dot.live { background: var(--accent); }

.join-card { position: absolute; right: 3vh; bottom: 3vh; max-width: 40vw; background: var(--surface-raised); border-radius: 16px;
  padding: 2.4vh; display: grid; gap: 1.6vh; justify-items: center; box-shadow: 0 8px 32px rgba(0,0,0,0.5); text-align: center; }
.join-card .call { font-size: max(22px, 3vh); font-weight: 500; line-height: 1.2; color: var(--text); }
.join-card .call strong { font-weight: 600; white-space: nowrap; }
.join-card .qr-box { width: 22vh; min-width: 140px; border-radius: 6px; }
.join-card .slug { font-size: max(28px, 4vh); font-weight: 600; line-height: 1.1; color: var(--text); overflow-wrap: normal; }
.join-card.big { right: 50%; bottom: 50%; transform: translate(50%, 50%); }
.join-card.big .qr-box { width: 38vh; }
.empty-note { position: absolute; left: 0; right: 0; bottom: 6vh; text-align: center; color: var(--text-secondary); font-size: max(22px, 3vh); }

.controls { position: absolute; left: 50%; bottom: 3vh; transform: translateX(-50%); display: flex; gap: 8px; padding: 8px;
  background: var(--surface-raised); border-radius: 16px; opacity: 0; pointer-events: none; transition: opacity 150ms var(--ease); }
.display.awake .controls { opacity: 1; pointer-events: auto; }
.controls button { width: 48px; height: 48px; border-radius: 999px; border: 0; background: transparent; color: var(--text);
  display: grid; place-items: center; cursor: pointer; }
.controls button:hover { background: var(--surface-sunken); }
.controls .i-play { display: none; }
.display.paused .controls .i-play { display: block; }
.display.paused .controls .i-pause { display: none; }

.display.preview .controls, .display.preview .join-card:not(.big), .display.preview .live-dot { display: none; }
.row.block > .button { justify-self: start; }
