:root {
  --paper: #f3f0e8; --paper-2: #e9e4d8; --card: #fbfaf6; --ink: #161512; --ink-2: #4a4740; --muted: #8a857a;
  --line: #d8d2c3; --signal: #e0432a; --signal-ink: #fff; --ok: #2f7d4f; --err: #b3261e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
code, pre { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; gap: 14px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font: 600 20px/1 var(--serif); letter-spacing: -.01em; }
.brand .mark { width: 26px; height: 26px; color: var(--signal); }
.topnav { margin-left: auto; display: flex; gap: 18px; font-size: 14px; }
.topnav a { text-decoration: none; color: var(--ink-2); }
.topnav a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.deck-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.deck-title .sep { color: var(--muted); }
.deck-title input { all: unset; font: 500 16px/1.3 var(--sans); padding: 4px 6px; border-radius: 4px; min-width: 120px; width: 100%; max-width: 520px; }
.deck-title input:hover, .deck-title input:focus { background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }

main.narrow { max-width: 640px; margin: 56px auto; padding: 0 22px; }
main.wide { max-width: 1240px; margin: 40px auto; padding: 0 22px; }
.display { font: 400 48px/1.05 var(--serif); letter-spacing: -.02em; margin: 0 0 14px; }
h2 { font: 600 18px/1.3 var(--sans); margin: 0 0 8px; }
.lede { font-size: 18px; color: var(--ink-2); margin: 0 0 24px; }
.hint { color: var(--muted); font-size: 13px; }
.ok { color: var(--ok); } .err { color: var(--err); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; } .row.end { justify-content: flex-end; }
.stack { display: grid; gap: 14px; }
.grow { flex: 1; }

label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, textarea, select { font: 15px/1.4 var(--sans); color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; width: 100%; }
textarea { font-family: var(--mono); font-size: 13px; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--ink); }
.btn { appearance: none; display: inline-flex; align-items: center; gap: 8px; font: 500 14px/1 var(--sans); padding: 10px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: #000; }
.btn.danger { color: var(--err); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.btn[aria-pressed="true"] { background: var(--signal); color: var(--signal-ink); border-color: var(--signal); }
.btn[aria-pressed="true"] .dot { background: #fff; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 22px; margin: 22px 0; }
.cmd { background: var(--ink); color: #efe9da; padding: 14px 16px; border-radius: 8px; overflow-x: auto; position: relative; margin: 10px 0; }
.cmd code { font-size: 13px; line-height: 1.6; white-space: pre; }
.cmd .copy { position: absolute; top: 8px; right: 8px; font: 12px var(--sans); background: #333; color: #ddd; border: 0; border-radius: 4px; padding: 4px 8px; cursor: pointer; }
.code-big { font: 600 34px/1 var(--mono); letter-spacing: .08em; margin: 20px 0; }
.msg { min-height: 1.5em; margin: 0; }

.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; margin-top: 22px; }
.deck-card { display: block; text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.deck-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .35); }
.deck-card .thumb { aspect-ratio: 16/9; background: var(--paper-2) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font: 400 22px/1.1 var(--serif); padding: 16px; text-align: center; position: relative; overflow: hidden; }
.deck-card .thumb.ex iframe { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; border: 0; transform-origin: 0 0; pointer-events: none; }
.deck-card .meta { padding: 12px 14px; display: grid; gap: 2px; }
.deck-card .meta b { font-weight: 600; }
.deck-card .meta span { font-size: 13px; color: var(--muted); }
.badge { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; margin-left: 6px; }

.dlg { border: 1px solid var(--line); border-radius: 12px; padding: 24px; background: var(--card); color: var(--ink); width: min(440px, 92vw); }
.dlg::backdrop { background: rgba(20, 18, 14, .45); }
.wide-dlg { width: min(1000px, 94vw); max-height: 88vh; }

/* ------------------------------------------------------------- studio */
.studio-page { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.studio { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: 0; }
.stage-wrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.status { font-size: 13px; color: var(--muted); }
.stage { flex: 1; display: grid; place-items: center; padding: 22px; min-height: 0; background: var(--paper-2); container-type: size; }
.stage iframe { width: min(100cqw, 100cqh * 16 / 9); height: auto; aspect-ratio: 16/9; border: 0; border-radius: 6px; background: #000; box-shadow: 0 18px 40px -24px rgba(0, 0, 0, .5); }
.side { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--card); }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tabs button { all: unset; cursor: pointer; padding: 12px 10px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--signal); }
.panel { flex: 1; overflow: auto; padding: 16px; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; }
.panel h3:first-child { margin-top: 0; }

.slide-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.slide-item { display: grid; grid-template-columns: 22px 112px 1fr; grid-template-areas: 'num th t' 'num th acts'; column-gap: 10px; row-gap: 2px; align-items: center; padding: 6px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; background: var(--card); }
.slide-item:hover { border-color: var(--line); }
.slide-item.current { border-color: var(--ink); }
.slide-item.dragging { opacity: .4; }
.slide-item.drop-before { box-shadow: 0 -3px 0 var(--signal); }
.slide-item.drop-after { box-shadow: 0 3px 0 var(--signal); }
.slide-item .num { grid-area: num;  font: 600 12px var(--mono); color: var(--muted); text-align: right; }
.slide-item .th { grid-area: th; display: block;  aspect-ratio: 16/9; border-radius: 4px; background: var(--paper-2) center/cover; overflow: hidden; }
.slide-item .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slide-item .t { grid-area: t; align-self: end;  font-size: 13px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.slide-item .acts { grid-area: acts; align-self: start; margin-left: -6px; display: flex; gap: 4px; opacity: 0; }
.slide-item:hover .acts, .slide-item:focus-within .acts { opacity: 1; }
.slide-item .acts button { all: unset; cursor: pointer; font-size: 12px; color: var(--ink-2); padding: 2px 6px; border-radius: 4px; }
.slide-item .acts button:hover { background: var(--paper-2); }
.slide-item.hidden .th, .slide-item.hidden .t { opacity: .4; }
.slide-item.hidden .t::after { content: " · hidden"; color: var(--muted); }
.drag { cursor: grab; color: var(--muted); font-size: 14px; text-align: center; }

.hist { list-style: none; padding: 0; margin: 0; }
.hist li { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.hist .who { font-size: 13px; }
.hist .who b { font-weight: 600; }
.hist .when { font-size: 12px; color: var(--muted); }
.hist .label { display: inline-block; background: var(--signal); color: #fff; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.hist .src { font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .05em; padding: 1px 5px; border-radius: 3px; background: var(--paper-2); color: var(--ink-2); }
.hist .files { font: 12px var(--mono); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.hist .group { font-size: 12px; color: var(--muted); padding: 4px 0 4px 10px; border-left: 2px solid var(--line); }
.diff { font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; background: var(--paper); border-radius: 6px; padding: 8px; max-height: 60vh; overflow: auto; }
.diff .a { background: #dff0e2; } .diff .r { background: #f8dcd8; } .diff .s { color: var(--muted); font-style: italic; }
.diff-body h4 { font: 600 13px var(--mono); margin: 14px 0 6px; }

.notes-edit { width: 100%; min-height: 260px; font: 15px/1.5 var(--sans); }
.kv { display: grid; gap: 10px; }
.share-url { font: 13px var(--mono); word-break: break-all; background: var(--paper); padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line); }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); font-size: 14px; }
.switch input { width: auto; }
.member { display: flex; justify-content: space-between; align-items: center; font-size: 14px; padding: 6px 0; }

.empty-deck { display: grid; place-items: center; min-height: 100vh; padding: 30px; text-align: left; background: var(--paper); }
.empty-deck > div { max-width: 560px; }

table.cmds { border-collapse: collapse; width: 100%; font-size: 14px; }
table.cmds td { border-top: 1px solid var(--line); padding: 8px 10px 8px 0; vertical-align: top; }
.prose h2 { margin-top: 32px; }
.settings .card { margin: 18px 0; }
.tok { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------------- presenter & remote (dark) */
body.dark { --paper: #121212; --paper-2: #1c1c1c; --card: #1a1a1a; --ink: #f1ede4; --ink-2: #bdb7aa; --muted: #8a857a; --line: #2e2e2e; color-scheme: dark; background: #0e0e0e; }
body.dark .btn.primary { background: var(--signal); border-color: var(--signal); color: #fff; }
.presenter { height: 100vh; display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr); gap: 18px; padding: 18px; }
.presenter .frame { position: relative; aspect-ratio: 16/9; width: 100%; background: #000; border-radius: 6px; overflow: hidden; }
.presenter iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pv-main { display: grid; align-content: center; }
.pv-side { display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.pv-next .frame { opacity: .9; }
.pv-next .end { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); display: block; margin-bottom: 4px; }
.pv-clock { display: flex; gap: 26px; align-items: end; }
.pv-clock b { font: 500 34px/1 var(--mono); }
.pv-clock .btn { margin-left: auto; }
.pv-pos { font-size: 15px; color: var(--ink-2); }
.pv-pos b { font-family: var(--mono); color: var(--ink); }
.pv-notes { flex: 1; overflow: auto; font-size: 22px; line-height: 1.45; white-space: pre-wrap; background: var(--card); border-radius: 8px; padding: 16px 18px; }
.pv-ctl { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.pv-ctl .btn { justify-content: center; padding: 16px; font-size: 16px; }

.remote-page { height: 100dvh; overflow: hidden; }
.remote { height: 100dvh; display: grid; grid-template-rows: auto auto 1fr auto auto auto; gap: 10px; padding: max(14px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom)); }
.rm-top { display: flex; justify-content: space-between; font: 500 18px var(--mono); color: var(--ink-2); }
.rm-title { font: 400 26px/1.15 var(--serif); }
.rm-notes { overflow: auto; font-size: 19px; line-height: 1.45; white-space: pre-wrap; color: var(--ink); background: var(--card); border-radius: 10px; padding: 12px 14px; }
.rm-notes:empty::before { content: "No notes on this slide."; color: var(--muted); }
.rm-ctl { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; height: 26vh; min-height: 130px; }
.rm-ctl button { border: 0; border-radius: 14px; font-size: 56px; color: #fff; background: #2a2a2a; touch-action: manipulation; }
.rm-ctl #next { background: var(--signal); }
.rm-ctl button:active { transform: scale(.98); filter: brightness(1.15); }
.rm-bottom { display: flex; gap: 10px; justify-content: space-between; }

@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .studio-page { height: auto; overflow: auto; }
  .stage { padding: 10px; container-type: inline-size; }
  .stage iframe { width: 100%; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .presenter { grid-template-columns: 1fr; height: auto; }
  .display { font-size: 36px; }
  .topnav { gap: 12px; font-size: 13px; }
  .topnav a[href="/setup"], .topnav a[href="/examples"] { display: none; }
  .deck-title { min-width: 0; flex: 1; }
  .deck-title input { min-width: 0; width: 100%; }
  .brand span { display: none; }
  .toolbar { flex-wrap: wrap; }
}
