:root {
  --mist: #EEF1EE;
  --paper: #FFFFFF;
  --lake: #24474F;
  --lake-deep: #14252A;
  --shore: #5E7F7A;
  --ink: #1C2A2E;
  --line: #D3DCD8;
  --ochre: #B98A3E;
  --ochre-soft: #F3E6CC;
  --danger: #A3412F;
  --warm-white: #F7F3EA;
  --sans: "Atkinson Hyperlegible", system-ui, sans-serif;
  --serif: "Literata", Georgia, serif;
  --r-sm: 6px;
  --r-lg: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--mist); color: var(--ink);
  font: 400 18px/1.55 var(--sans);
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ochre); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .75em; }
.muted { color: var(--shore); }
.small { font-size: .9rem; }

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: .6em 1.2em; border-radius: var(--r-sm);
  border: 2px solid var(--lake); background: var(--lake); color: #fff;
  font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #1b3940; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.quiet { background: transparent; color: var(--lake); }
.btn.quiet:hover { background: #E2E9E6; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.voice { background: var(--ochre); border-color: var(--ochre); }
.btn.small { min-height: 38px; padding: .3em .8em; font-size: .9rem; }
.linkish { background: none; border: 0; padding: 0; color: var(--lake); text-decoration: underline; cursor: pointer; font-weight: 700; }
label.field { display: block; margin-bottom: 1rem; }
label.field > span { display: block; font-weight: 700; margin-bottom: .3rem; }
label.field > small { display: block; color: var(--shore); margin-top: .25rem; font-size: .88rem; }
input[type=text], input[type=email], input[type=number], input[type=time], select, textarea {
  width: 100%; min-height: 48px; padding: .55em .75em; border: 2px solid var(--line);
  border-radius: var(--r-sm); background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--lake); outline: none; }
.check { display: flex; gap: .6rem; align-items: center; margin-bottom: .9rem; }
.check input { width: 22px; height: 22px; accent-color: var(--lake); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.error { color: var(--danger); font-weight: 700; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: .7rem; color: inherit; text-decoration: none; }
.brand svg { width: 40px; height: 40px; flex: none; }
.wordmark { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; letter-spacing: .01em; }

/* ---------- Sign in ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.auth-art {
  background: var(--lake); color: var(--warm-white); padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-art .lakeline { position: absolute; left: 0; right: 0; top: 54%; border-top: 1px solid rgba(247,243,234,.35); }
.auth-art blockquote { margin: 0; font-family: var(--serif); font-size: clamp(1.6rem, 3vw, 2.4rem); line-height: 1.25; max-width: 18ch; position: relative; }
.auth-art blockquote.reflect { transform: scaleY(-1); opacity: .16; filter: blur(1.5px); margin-top: .2rem; }
.auth-art .brand { color: var(--warm-white); }
.auth-main { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(16px, 6vw, 80px); }
.auth-main form { max-width: 420px; }
.auth-main h1 { margin-bottom: .5rem; }
.auth-main .lede { color: var(--shore); max-width: 36ch; margin-bottom: 1.6rem; }
.auth-foot { margin-top: 2rem; max-width: 420px; border-top: 1px solid var(--line); padding-top: 1rem; }
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 24px 16px; min-height: 0; }
  .auth-art blockquote { font-size: 1.4rem; margin-top: 1.5rem; }
  .auth-art .lakeline, .auth-art blockquote.reflect { display: none; }
  .auth-main { padding: 28px 16px 48px; }
}

/* ---------- App shell ---------- */
.topbar { background: var(--lake); color: #fff; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 1rem; }
.topbar .brand { color: #fff; }
.topbar .spacer { flex: 1; }
.topbar select { width: auto; min-height: 40px; background: #1b3940; color: #fff; border-color: #3f6870; }
.topbar .linkish { color: #fff; font-weight: 400; }
.circle-head { max-width: 1120px; margin: 0 auto; padding: 28px 16px 0; }
.circle-head h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); }
.tabs { max-width: 1120px; margin: 18px auto 0; padding: 0 16px; display: flex; gap: .25rem; border-bottom: 2px solid var(--line); overflow-x: auto; }
.tab { background: none; border: 0; padding: .7em 1em; font-weight: 700; color: var(--shore); border-bottom: 3px solid transparent; margin-bottom: -2px; cursor: pointer; white-space: nowrap; }
.tab[aria-selected=true] { color: var(--lake); border-bottom-color: var(--lake); }
main.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 80px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.panel { background: var(--paper); border-radius: var(--r-lg); padding: 24px; border: 1px solid var(--line); margin-bottom: 1.25rem; }
.narrow { max-width: 640px; }

/* ---------- Photo prints ---------- */
.prints { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 28px 22px; }
.print { margin: 0; background: #fff; padding: 10px 10px 14px; box-shadow: 0 1px 0 var(--line), 0 6px 18px -10px rgba(20,37,42,.35); border-radius: 3px; }
.print .ph { aspect-ratio: 4/3; background: #DDE4E1; overflow: hidden; }
.print .ph img { width: 100%; height: 100%; object-fit: cover; }
.print figcaption { padding: 10px 2px 0; }
.print .who { font-family: var(--serif); font-size: 1.12rem; font-weight: 600; line-height: 1.25; }
.print .what { font-family: var(--serif); font-style: italic; color: #3c4b4f; line-height: 1.35; margin-top: .15rem; }
.print .where { color: var(--shore); font-size: .88rem; margin-top: .3rem; }
.print .acts { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-top: .7rem; }
.print.is-hidden .ph { opacity: .35; }
.tag { display: inline-flex; align-items: center; gap: .3em; font-size: .82rem; font-weight: 700; padding: .15em .55em; border-radius: 99px; background: var(--ochre-soft); color: #6d4f1c; }
.tag.grey { background: #E2E9E6; color: var(--shore); }
.empty { text-align: left; padding: 40px 24px; border: 2px dashed var(--line); border-radius: var(--r-lg); max-width: 640px; }
.empty h2 { margin-bottom: .5rem; }

/* ---------- Lists ---------- */
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; gap: 1rem; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 180px; }
.list .name { font-weight: 700; }

/* ---------- Pairing code ---------- */
.code-box { background: var(--lake); color: var(--warm-white); border-radius: var(--r-lg); padding: 24px; margin-bottom: 1.25rem; }
.code-box .code { font-family: var(--serif); font-size: clamp(2.6rem, 9vw, 4rem); letter-spacing: .18em; font-weight: 600; margin: .2rem 0 .6rem; }
.code-box ol { margin: 0 0 1rem; padding-left: 1.3em; }
.code-box .btn.quiet { color: var(--warm-white); border-color: var(--warm-white); }

/* ---------- Editor dialog ---------- */
dialog.editor { width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 24px); border: 0; border-radius: var(--r-lg); padding: 0; }
dialog.editor::backdrop { background: rgba(20,37,42,.6); }
.editor form { padding: 24px; }
.editor .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.editor .preview { background: #DDE4E1; border-radius: var(--r-sm); min-height: 180px; display: grid; place-items: center; margin-bottom: 1rem; overflow: hidden; }
.editor .preview img { max-height: 320px; width: auto; }
.picker { display: grid; place-items: center; gap: .5rem; padding: 32px 16px; text-align: center; width: 100%; cursor: pointer; }
.voicebox { border: 2px solid var(--ochre-soft); background: #FBF6EC; border-radius: var(--r-sm); padding: 14px; margin-bottom: 1.2rem; }
.voicebox h3 { margin-bottom: .2rem; }
.voicebox audio { width: 100%; margin: .5rem 0; }
.recdot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.editor .foot { display: flex; justify-content: flex-end; gap: .75rem; border-top: 1px solid var(--line); padding-top: 1rem; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7em 1.2em; border-radius: var(--r-sm); font-weight: 700; z-index: 50; opacity: 0; pointer-events: none; transition: opacity .25s; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }
#toast.bad { background: var(--danger); }

/* ================= DISPLAY (TV / iPad / phone) ================= */
body.display-mode { background: var(--lake-deep); color: var(--warm-white); overflow: hidden; }
.d-center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 16px; gap: 1.2rem; }
.d-center h1 { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 400; }
.d-center p { font-size: clamp(1.1rem, 2.2vw, 1.5rem); color: #C9D6D2; max-width: 30ch; }
.d-code { font-family: var(--serif); font-size: clamp(2.4rem, 8vw, 4.5rem); letter-spacing: .3em; text-align: center; width: min(520px, 100%); background: transparent; color: var(--warm-white); border: 0; border-bottom: 3px solid #6A8C86; padding: .1em 0 .1em .3em; }
.d-code:focus { outline: none; border-bottom-color: #E3B866; }
.d-btn { font-size: clamp(1.2rem, 2.5vw, 1.6rem); padding: .7em 2em; border-radius: 99px; border: 0; background: var(--warm-white); color: var(--lake-deep); font-weight: 700; cursor: pointer; }
.d-err { color: #F0B8A8; font-size: 1.2rem; min-height: 1.5em; }
.d-start { position: fixed; inset: 0; cursor: pointer; }

.stage { position: fixed; inset: 0; cursor: pointer; user-select: none; -webkit-user-select: none; }
.stage .bg { position: absolute; inset: -60px; background-size: cover; background-position: center; filter: blur(46px) brightness(.45) saturate(.9); transition: opacity 2.2s ease; }
.stage img.slide { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 2.2s ease; }
.stage img.slide.on { opacity: 1; }
.stage .shade { position: absolute; left: 0; right: 0; bottom: 0; height: 46%; background: linear-gradient(to top, rgba(10,20,23,.88), rgba(10,20,23,0)); pointer-events: none; }
.stage .cap { position: absolute; left: 5vw; right: 5vw; bottom: 5vh; transition: opacity 1.4s ease; text-shadow: 0 2px 12px rgba(0,0,0,.5); }
.stage .cap.off { opacity: 0; }
.stage .people { font-family: var(--serif); font-weight: 600; font-size: clamp(2rem, 5.2vw, 5rem); line-height: 1.1; }
.stage .text { font-family: var(--serif); font-size: clamp(1.3rem, 2.9vw, 2.7rem); line-height: 1.3; margin-top: .3em; max-width: 34ch; }
.stage .meta { font-size: clamp(1rem, 1.8vw, 1.6rem); color: #C9D6D2; margin-top: .5em; }
.stage .clock { position: absolute; top: 4vh; right: 4vw; text-align: right; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.stage .clock .day { font-family: var(--serif); font-size: clamp(1.2rem, 2.4vw, 2.2rem); }
.stage .clock .time { font-size: clamp(1rem, 1.8vw, 1.6rem); color: #C9D6D2; }
.stage .voice-on { position: absolute; top: 4vh; left: 4vw; display: flex; gap: 5px; align-items: flex-end; height: 26px; opacity: 0; transition: opacity .6s; }
.stage .voice-on.on { opacity: .85; }
.stage .voice-on i { width: 5px; background: #E3B866; border-radius: 3px; animation: bars 1s ease-in-out infinite; }
.stage .voice-on i:nth-child(2) { animation-delay: .2s; } .stage .voice-on i:nth-child(3) { animation-delay: .4s; }
@keyframes bars { 0%,100% { height: 8px; } 50% { height: 26px; } }
.night { position: fixed; inset: 0; background: #0B1517; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .6rem; color: #9FB3AE; }
.night .big { font-family: var(--serif); font-size: clamp(2rem, 6vw, 4.5rem); color: #C9D6D2; }
.night .t { font-size: clamp(1.4rem, 3vw, 2.4rem); }
.corner { position: fixed; top: 0; left: 0; width: 90px; height: 90px; background: transparent; border: 0; z-index: 5; }
.d-menu { position: fixed; inset: 0; background: rgba(11,21,23,.92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; z-index: 10; }
.d-menu .d-btn.ghost { background: transparent; color: var(--warm-white); border: 2px solid var(--warm-white); }

@media (prefers-reduced-motion: reduce) {
  .stage img.slide, .stage .bg, .stage .cap { transition-duration: .01s; }
  .recdot, .stage .voice-on i { animation: none; }
}

/* Sign out: always visible as a clear button, even on small phones */
.topbar #signout { border: 1.5px solid rgba(255,255,255,.7); border-radius: 6px; padding: 6px 12px; text-decoration: none; font-weight: 700; white-space: nowrap; flex: none; min-height: 40px; }
.topbar .brand { min-width: 0; }
@media (max-width: 420px) { .topbar .wordmark { font-size: 1rem; } .topbar-inner { gap: .6rem; } }

/* Front page: new visitor call to action */
.newhere { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--ochre-soft); border: 1px solid #E6CF9F; border-radius: var(--r-lg); padding: 16px 18px; margin: 0 0 1.75rem; max-width: 520px; }
.newhere .btn { white-space: nowrap; }
/* Screen pairing: QR + steps */
.pair-grid { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: start; margin: .5rem 0 1rem; }
.pair-qr svg { width: 200px; height: 200px; background: #fff; border-radius: 10px; display: block; }
.pair-qr p { margin-top: .5rem; }
.tvaddr { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; margin: .2rem 0 .4rem; word-break: break-all; }
@media (max-width: 600px) { .pair-grid { grid-template-columns: 1fr; } .pair-qr svg { margin: 0 auto; } }

/* Free starter */
.starter-bar { max-width: 1120px; margin: 0 auto 8px; padding: 10px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--ochre-soft); border-radius: var(--r-sm); font-size: .95rem; }
.starter-bar .btn.small { min-height: 40px; padding: .3em .9em; }
.upgrade { border: 2px solid var(--ochre); }
.upgrade h3 { margin-bottom: .4rem; }

/* Calm lake scene on the front page */
.auth-art { background: var(--lake) url("scene.svg") center bottom / cover no-repeat; }
.auth-art::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,37,42,.82) 0%, rgba(36,71,79,.55) 38%, rgba(36,71,79,0) 62%); pointer-events: none; }
.auth-art > * { position: relative; }
.auth-art .lakeline, .auth-art blockquote.reflect { display: none; }
.auth-art p.small { text-shadow: 0 1px 6px rgba(20,37,42,.6); }
@media (max-width: 820px) {
  .auth-art { min-height: 260px; background-size: cover; background-position: center 72%; }
  .auth-art::before { background: linear-gradient(180deg, rgba(20,37,42,.85) 0%, rgba(36,71,79,.5) 55%, rgba(36,71,79,.1) 100%); }
}
