/* ITZA Friend - the stylesheet.
 *
 * THE VIDEO IS THE INTERFACE (v1 7.7, spec 10.3). Everything here is the
 * thin chrome around a full-bleed stage: the AI badge, two toggles, the
 * captions, the frosted input bar, and the house shell behind it (the
 * start screen, the ITZA sign-in card copied verbatim, settings, first run,
 * the lock). The top 55% of the screen stays clear of chrome: nothing
 * covers the face.
 *
 * Rules with teeth (verify_feel.mjs, verify_css_live.mjs):
 *   - motion is transform and opacity only; no layout property animates;
 *   - every shadow is an elevation token;
 *   - logical properties for RTL (margin-inline, inset-inline), never left
 *     and right where a direction could flip;
 *   - no web fonts: Instrument Sans and Roboto ship from this origin.
 */

@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/instrument-sans-latin.woff2') format('woff2');
}
/* The wordmark's face is Roboto - brand, not prose (owner, 2026-09-07). */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/roboto-latin.woff2') format('woff2');
}

/* ---------------------------------------------------------------------
   Tokens - four rooms, one meaning
   --------------------------------------------------------------------- */

:root {
  --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --brand: 'Roboto', var(--sans);

  /* DEEP (the default): the clips are golden-hour footage and read best on
     deep neutrals. */
  --paper: #0b1016;
  --surface: #121923;
  --ink: #eef1f5;
  --muted: #9aa5b4;        /* 7:1 on --paper */
  --rule: #263140;
  --navy: #0b2a4a;
  --gold: #f5c711;
  --blue: #4d9bff;
  --accent: #4d9bff;
  --accent-ink: #081524;
  --frost: rgba(18, 25, 35, 0.72);
  --danger: #e05a5a;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --kb: 0px;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 999px;

  --m-tap: 90ms;
  --m-quick: 160ms;
  --m-enter: 280ms;
  --m-exit: 240ms;
  --ease-enter: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);

  /* Elevation tokens - the only shadows in the tree. */
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-float: 0 2px 6px rgba(0, 0, 0, 0.45), 0 12px 32px rgba(0, 0, 0, 0.55);
}

html[data-theme='paper'] {
  --paper: #fbfaf7;
  --surface: #ffffff;
  --ink: #12161c;
  --muted: #666d79;
  --rule: #e2ded6;
  --navy: #0b2a4a;
  --blue: #0b6ad4;
  --accent: #0b2a4a;
  --accent-ink: #ffffff;
  --frost: rgba(251, 250, 247, 0.78);
  --shadow-card: 0 1px 2px rgba(11, 42, 74, 0.06), 0 8px 24px rgba(11, 42, 74, 0.08);
  --shadow-float: 0 2px 6px rgba(11, 42, 74, 0.14), 0 12px 32px rgba(11, 42, 74, 0.18);
}

html[data-theme='dark'] {
  --paper: #14171c;
  --surface: #1b2027;
  --ink: #e8e6e1;
  --muted: #9aa1ad;
  --rule: #2b3038;
  --navy: #a9c6e8;
  --blue: #6fb3ff;
  --accent: #6fb3ff;
  --accent-ink: #081524;
  --frost: rgba(20, 23, 28, 0.78);
}

html[data-theme='hc'] {
  --paper: #000000;
  --surface: #000000;
  --ink: #ffffff;
  --muted: #d0d0d0;
  --rule: #ffffff;
  --navy: #ffffff;
  --gold: #ffd84d;
  --blue: #8ec6ff;
  --accent: #ffffff;
  --accent-ink: #000000;
  --frost: rgba(0, 0, 0, 0.85);
}

/* ---------------------------------------------------------------------
   The document - the body never scrolls; panes do
   --------------------------------------------------------------------- */

html {
  font-size: calc(100% * var(--text-scale, 1));
  -webkit-text-size-adjust: 100%;
}
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--paper);
  color: var(--ink);
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}
body {
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.45;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }
button { font: inherit; }

html[data-motion='reduce'] *,
html[data-motion='reduce'] *::before,
html[data-motion='reduce'] *::after {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}
/* The character's clips are content: they keep moving under reduced motion.
   (The videos carry no CSS animation; the crossfade is opacity only.) */

/* ---------------------------------------------------------------------
   Screens, panes, modal, toast (the shell)
   --------------------------------------------------------------------- */

.screen { position: fixed; inset: 0; display: none; }
.screen.on { display: block; }
.screen:focus { outline: none; }

#view { position: absolute; inset: 0; }

.pane {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  isolation: isolate;
  scrollbar-width: none;
}
.pane::-webkit-scrollbar { display: none; }
.pane:focus, .pane:focus-visible { outline: none; }
.pane-under { pointer-events: none; }

@keyframes paneIn { from { transform: translate3d(100%, 0, 0); } to { transform: translate3d(0, 0, 0); } }
@keyframes paneOut { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(100%, 0, 0); } }
@keyframes paneFade { from { opacity: 0; } to { opacity: 1; } }
.pane-enter { animation: paneIn var(--m-enter) var(--ease-enter); }
.pane-exit { animation: paneOut var(--m-exit) var(--ease-exit) forwards; z-index: 5; }
.pane-fade { animation: paneFade 180ms ease-out; }
html[dir='rtl'] .pane-enter { animation-name: paneInRtl; }
html[dir='rtl'] .pane-exit { animation-name: paneOutRtl; }
@keyframes paneInRtl { from { transform: translate3d(-100%, 0, 0); } to { transform: translate3d(0, 0, 0); } }
@keyframes paneOutRtl { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-100%, 0, 0); } }

#scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 60;
  padding: 1rem;
  overflow-y: auto;
}
#scrim.on { display: flex; align-items: safe center; justify-content: center; }
#modal {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 32rem;
  margin: 3vh auto;
  padding: 1.25rem;
  font-size: 1rem;
  max-height: calc(100vh - 6vh - 2rem);
  overflow-y: auto;
  box-shadow: var(--shadow-float);
}
#modal input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 0.55rem 0.7rem;
  margin: 0.4rem 0 0.2rem;
}
.mhead { font-weight: 700; font-size: 1.25rem; color: var(--ink); margin-bottom: 0.8rem; }
.mtext { font-size: 0.95rem; line-height: 1.5; color: var(--ink); margin: 0 0 0.8rem; }
.mbtns { margin-top: 1.1rem; display: flex; justify-content: flex-end; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
@media (max-width: 480px) { .mbtns { flex-direction: column-reverse; align-items: stretch; } }
.mbtns-stack { flex-direction: column; align-items: stretch; }
.diag { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.diag td { padding: 0.3rem 0.2rem; border-bottom: 1px solid var(--rule); word-break: break-all; }
.diag td:first-child { color: var(--muted); white-space: nowrap; }

#toast {
  position: fixed;
  inset-inline-start: 50%;
  bottom: calc(var(--safe-b) + 7.5rem);
  transform: translateX(-50%) translateY(1rem);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 0.7rem 1rem;
  border-radius: var(--r-md);
  max-width: min(34rem, calc(100vw - 2rem));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 90;
  box-shadow: var(--shadow-float);
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.has-act { pointer-events: auto; }

/* ---------------------------------------------------------------------
   Controls
   --------------------------------------------------------------------- */

.btn {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--r-full);
  padding: 0.7rem 1.3rem;
  min-height: 48px;
  cursor: pointer;
  text-align: center;
  transition: transform var(--m-tap) ease-out, opacity var(--m-tap) ease-out;
}
.btn:active { transform: scale(0.96); }
.btn.wide { display: block; width: 100%; }
.btn.ghost { background: var(--frost); color: var(--ink); border-color: var(--rule); font-weight: 500; }
/* The named PRIMARY of a screen: ITZA gold. Acting is blue, kept is gold -
   Start and Create are the two gold acts in this app. */
.btn.gold { background: var(--gold); color: #231c00; font-weight: 700; box-shadow: var(--shadow-float); }
.btn.danger { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.linklike { background: none; border: none; color: var(--blue); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 8px; }

.tbtn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--r-full);
  background: var(--frost);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  color: var(--ink);
  cursor: pointer;
  transition: transform var(--m-tap) ease-out;
}
.tbtn:active { transform: scale(0.92); }
.tbtn.on { background: var(--accent); color: var(--accent-ink); }

.fieldErr {
  margin-top: 8px; padding: 9px 12px; border-radius: 9px;
  border: 2px solid var(--danger); color: var(--danger);
  font-size: 0.9rem; font-weight: 700; line-height: 1.4;
}

/* ---------------------------------------------------------------------
   The start screen (v1 7.2)
   --------------------------------------------------------------------- */

#screen-start.on { display: flex; align-items: flex-end; justify-content: center; }
.start-poster {
  position: absolute; inset: 0;
  background: linear-gradient(170deg, #1c2a3a 0%, #0b1016 60%, #06090d 100%);
  background-size: cover; background-position: center top;
  filter: blur(14px) saturate(1.1);
  transform: scale(1.06);
}
.start-poster::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.25) 45%, rgba(0,0,0,0.75) 100%);
}
.start-card {
  position: relative;
  width: 100%;
  max-width: 30rem;
  padding: 24px 24px calc(var(--safe-b) + 28px);
  display: flex; flex-direction: column; gap: 14px;
  color: #eef1f5;
  text-align: start;
}
.wordmark { font-family: var(--brand); font-weight: 800; font-size: 1.1rem; letter-spacing: 0.02em; display: flex; gap: 0; }
.wm-itza { color: #ffffff; }
.wm-prod {
  color: var(--gold);
  background: linear-gradient(180deg, #ffe17a 0%, #f5c711 48%, #c99a05 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.start-name { font-size: 2rem; font-weight: 700; margin: 0; line-height: 1.1; }
.start-name:empty { display: none; }
.start-line { margin: 0; color: #d7dde6; font-size: 1.05rem; }
.start-adult { display: flex; align-items: center; gap: 12px; font-size: 1rem; cursor: pointer; min-height: 48px; }
.start-adult input { width: 1.4em; height: 1.4em; accent-color: var(--gold); }
.start-adult[hidden] { display: none; }
.start-go { font-size: 1.15rem; min-height: 56px; }

/* ---------------------------------------------------------------------
   Sign in - PORTED 1:1 FROM ITZA CHESS via ITZA DIARY (pillar 02). The only
   per-app changes: the h1, the tagline, the logo and the gate note. Dark
   follows the room: deep and dark use the dark card.
   --------------------------------------------------------------------- */

#screen-onboard{
  --ob-blue:#0c7ffb; --ob-blue-soft:#1d6fd0; --ob-gold:#f5c711;
  --ob-acc:#0c7ffb; --ob-acc-ink:#ffffff;
  --ob-bg:#f3f4f6; --ob-bg2:#ffffff; --ob-bg3:#f7f7f8;
  --ob-ink:#0b2a4a; --ob-ink2:#1e416b; --ob-ink3:#41618c;
  --ob-line:#d7dbe2; --ob-line2:#c5ccd6; --ob-hover:rgba(12,127,251,.06);
  --ob-card-shadow:var(--shadow-float);
  --ob-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  --ob-r-sm:8px;
  --ob-danger:#c62828;
}
html[data-theme="dark"] #screen-onboard, html[data-theme="deep"] #screen-onboard, html[data-theme="hc"] #screen-onboard{
  --ob-bg:#0b1f3a; --ob-bg2:#10294a; --ob-bg3:#173058;
  --ob-ink:#e8edf4; --ob-ink2:#9db0c7; --ob-ink3:#5b7089;
  --ob-line:#1e3a63; --ob-line2:#28466f; --ob-hover:rgba(255,255,255,.05);
}
#screen-onboard{padding:0}
#screen-onboard.on{
  position:fixed; inset:0; z-index:50; display:flex; align-items:center; justify-content:center;
  padding:16px; overflow-y:auto; overscroll-behavior:contain;
  padding-top:calc(var(--safe-t) + 16px); padding-bottom:calc(var(--safe-b) + 16px);
  background:linear-gradient(to bottom,#ffffff 0,#ffffff 200px,var(--ob-blue) 200px,var(--ob-blue) 224px,var(--ob-bg) 224px);
}
html[data-theme="dark"] #screen-onboard.on, html[data-theme="deep"] #screen-onboard.on, html[data-theme="hc"] #screen-onboard.on{
  background:linear-gradient(to bottom,#10294a 0,#10294a 200px,var(--ob-blue) 200px,var(--ob-blue) 224px,var(--ob-bg) 224px);
}
#screen-onboard .obcard{
  width:100%; max-width:430px; margin:0; text-align:start;
  background:var(--ob-bg2); border:1px solid var(--ob-line); border-radius:22px;
  padding:22px; box-shadow:var(--ob-card-shadow); color:var(--ob-ink);
  font:13px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
}
#screen-onboard .hd{display:flex; align-items:center; gap:10px; margin-bottom:4px}
#screen-onboard .pyr{width:44px; height:auto}
#screen-onboard h1{font-size:19px; letter-spacing:.01em; font-weight:700; margin:0; font-family:inherit; color:var(--ob-ink)}
#screen-onboard .tag{font-size:11.5px; color:var(--ob-ink2); margin-bottom:14px}
#screen-onboard .tag b{color:#8d6f00}
html[data-theme="dark"] #screen-onboard .tag b, html[data-theme="deep"] #screen-onboard .tag b, html[data-theme="hc"] #screen-onboard .tag b{color:var(--ob-gold)}
#screen-onboard label{display:block; margin:12px 0 4px; font-size:11.5px; color:var(--ob-ink2); font-weight:600; text-align:start}
#screen-onboard input,#screen-onboard textarea{
  width:100%; box-sizing:border-box; font:inherit; color:var(--ob-ink); background:var(--ob-bg3);
  border:1px solid var(--ob-line2); border-radius:var(--ob-r-sm); padding:6px 9px; outline:none;
}
#screen-onboard input:focus,#screen-onboard textarea:focus{border-color:var(--ob-acc)}
#screen-onboard ::placeholder{color:var(--ob-ink3)}
#screen-onboard .obtoggle{display:flex; gap:4px; margin-bottom:12px}
#screen-onboard .obtoggle button{flex:1; font-size:11.5px; padding:6px; border-radius:var(--ob-r-sm); border:1px solid var(--ob-line2); color:var(--ob-ink2); background:none; cursor:pointer}
#screen-onboard .obtoggle button.on{border-color:var(--ob-acc); color:var(--ob-ink); background:var(--ob-hover); font-weight:700}
#screen-onboard .row2{display:flex; gap:8px}
#screen-onboard .row2 .btn,#screen-onboard .row2 input{flex:1; min-width:0}
#screen-onboard .btn{
  background:linear-gradient(135deg,var(--ob-acc),var(--ob-blue-soft)); color:var(--ob-acc-ink);
  font-weight:700; font-size:12.5px; padding:8px 16px; min-height:0; border-radius:10px; border:none; cursor:pointer;
  box-shadow:var(--shadow-card);
}
#screen-onboard .btn:disabled{opacity:.45; cursor:default; box-shadow:none}
#screen-onboard .btn.ghost{background:var(--ob-bg3); color:var(--ob-ink); border:1px solid var(--ob-line2); font-weight:600; box-shadow:none}
#screen-onboard .btn.gold{background:var(--ob-gold); color:#231c00; box-shadow:none}
#screen-onboard .btn.wide{width:100%}
#screen-onboard .feenote{font-size:10px; color:var(--ob-ink3); text-align:start; margin-top:0}
#screen-onboard .feenote b{color:var(--ob-ink2)}
#screen-onboard .linklike{display:block; margin:14px auto 0; background:none; border:none; color:var(--ob-blue); font-size:12px; cursor:pointer; text-decoration:underline; text-underline-offset:3px}
#screen-onboard .qrframe{display:flex; justify-content:center; margin:6px 0 2px}
#screen-onboard #obQrBox{width:190px; height:190px; border-radius:12px; background:#fff; border:1px solid var(--ob-line); display:flex; align-items:center; justify-content:center; position:relative}
#screen-onboard #obQrBox .qrph{font-family:var(--ob-mono); font-size:34px; color:var(--ob-line2); letter-spacing:2px}
#screen-onboard .savekey{display:flex; gap:8px; align-items:flex-start; margin-top:9px; font-size:11.5px; color:var(--ob-ink2); font-weight:400}
#screen-onboard .savekey input{width:auto; margin-top:2px}
#screen-onboard .settingsec{border-top:1px solid var(--ob-line); margin-top:12px; padding-top:10px}
#screen-onboard .settingsec h4{font-size:11px; text-transform:uppercase; letter-spacing:.07em; color:var(--ob-ink3); margin-bottom:6px}
#screen-onboard .spinner{display:inline-block; width:13px; height:13px; border:2px solid var(--ob-line2); border-top-color:var(--ob-blue); border-radius:50%; animation:spin .8s linear infinite; vertical-align:-2px; margin-inline-end:4px}
@keyframes spin{to{transform:rotate(360deg)}}
#screen-onboard #obChoose{ display:flex; flex-direction:column; gap:10px; margin:16px 0 4px; }
#screen-onboard #obChoose .btn{ height:46px; font-size:15px; font-weight:700; }
#screen-onboard #obBack{ margin-top:0; margin-bottom:10px; display:inline-block; }
.pwwrap{ position:relative; display:block; }
.pwwrap input{ width:100%; padding-inline-end:44px; }
.pweye{
  position:absolute; top:50%; inset-inline-end:6px; transform:translateY(-50%);
  width:32px; height:32px; display:flex; align-items:center; justify-content:center;
  border-radius:8px; color:var(--ob-ink3); cursor:pointer; padding:0;
  background:none; border:none;
}
.pweye svg{ width:20px; height:20px; display:block; }
.pweye.on{ color:var(--ob-acc); }
#screen-onboard .pwwrap input{ padding-inline-end:44px; }
#screen-onboard .fieldErr{ color:#c62828; border-color:#c62828; background:rgba(198,40,40,.07); }
html[data-theme="hc"] #screen-onboard .fieldErr{ color:#ffb3b3; border-color:#ffb3b3; background:rgba(140,0,0,.10); }
#screen-onboard input.err{ border-color:#c62828; box-shadow:0 0 0 3px rgba(198,40,40,.16); }
.obWarnBig{ border:2px solid var(--danger); border-radius:12px; padding:14px 16px; margin:4px 0 6px; font-size:1rem; line-height:1.55; }
.aw-wrote { display:flex; align-items:flex-start; gap:10px; font-size:0.9rem; line-height:1.5; margin:14px 2px; cursor:pointer; }
.aw-wrote input { width:1.1em; height:1.1em; margin-top:0.15em; accent-color:var(--gold); }
#screen-onboard .feenote.gate{ margin-top:14px; }

/* ---------------------------------------------------------------------
   The conversation (v1 7.7)
   --------------------------------------------------------------------- */

.pane.talk { overflow: hidden; background: #000; }
.stage { position: absolute; inset: 0; background: #000; }
.stage-poster {
  position: absolute; inset: 0;
  background: #000 center top / cover no-repeat;
}
.stage-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
  opacity: 0;
  transition: opacity 250ms linear;
  pointer-events: none;
}
.stage-video.on { opacity: 1; }
.stage-video.fade { opacity: 0; }
.stage-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0) 18%),
    linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.45) 22%, rgba(0,0,0,0) 40%);
}
.ai-badge {
  position: absolute;
  top: calc(var(--safe-t) + 14px);
  inset-inline-start: calc(var(--safe-l) + 16px);
  font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em;
  color: #fff;
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--r-sm);
  padding: 4px 8px;
}
.top-right {
  position: absolute;
  top: calc(var(--safe-t) + 10px);
  inset-inline-end: calc(var(--safe-r) + 12px);
  display: flex; gap: 8px;
}
.pane.talk .tbtn { background: rgba(0, 0, 0, 0.42); color: #fff; }
.pane.talk .tbtn.on { background: rgba(255, 255, 255, 0.9); color: #111; }

/* The bottom 40%: captions over the gradient, then the input bar. */
.bottom {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 0 16px calc(var(--safe-b) + 12px + var(--kb));
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.bottom > * { pointer-events: auto; }
.captions { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.pane.no-captions .captions .cap.them { visibility: hidden; }
.cap {
  color: #fff;
  font-size: 1.0625rem;       /* v1: 17 px */
  line-height: 1.4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6), 0 0 12px rgba(0, 0, 0, 0.5);
  max-width: 100%;
  overflow-wrap: anywhere;
  transition: opacity var(--m-enter) ease-out, transform var(--m-enter) var(--ease-enter);
}
.cap.me { color: #d7dde6; font-size: 0.95rem; align-self: flex-end; text-align: end; }
.cap.older { opacity: 0.55; }
.cap.latest { opacity: 1; }
.status { color: #e8e6e1; font-size: 0.85rem; background: rgba(0, 0, 0, 0.5); border-radius: var(--r-sm); padding: 6px 10px; align-self: flex-start; }
.status[hidden] { display: none; }

.inbar {
  display: flex; align-items: flex-end; gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 26px;
  padding: 6px 6px 6px 16px;
  margin: 0;
}
.inbar textarea {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none; resize: none;
  color: #fff; font: inherit; font-size: 1.0625rem; line-height: 1.35;
  padding: 10px 0; max-height: 120px;
}
.inbar textarea::placeholder { color: rgba(255, 255, 255, 0.6); }
.sendbtn {
  width: 48px; height: 48px; flex: none;
  border: none; border-radius: var(--r-full);
  background: var(--gold); color: #231c00;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform var(--m-tap) ease-out;
}
.sendbtn:active { transform: scale(0.92); }

/* Landscape: the stage is portrait; say so (v1 7.7). */
.rotate-note { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  .rotate-note {
    display: block; position: absolute; top: 50%; inset-inline: 16px; transform: translateY(-50%);
    text-align: center; color: #fff; font-size: 1.1rem; z-index: 3;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  }
}
/* Tablets and desktops: the 9:16 stage centred, blurred poster at the sides. */
@media (min-aspect-ratio: 3/4) and (min-width: 700px) {
  .pane.talk .stage, .pane.talk .stage-vignette, .pane.talk .bottom, .pane.talk .ai-badge, .pane.talk .top-right {
    inset-inline: calc(50% - min(50vw, 56.25vh * 0.5));
    width: min(100vw, 56.25vh);
  }
  .pane.talk .ai-badge { inset-inline-end: auto; inset-inline-start: calc(50% - min(50vw, 56.25vh * 0.5) + 16px); width: auto; }
  .pane.talk .top-right { inset-inline-start: auto; inset-inline-end: calc(50% - min(50vw, 56.25vh * 0.5) + 12px); width: auto; }
  .pane.talk { background: #000 url('') center / cover; }
}

/* ---------------------------------------------------------------------
   Settings, first run, the bar
   --------------------------------------------------------------------- */

.tbar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 10px) 12px 10px;
  background: var(--frost);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--rule);
}
.tbar h2 { margin: 0; font-size: 1.1rem; font-weight: 700; }
html[dir='rtl'] .tbar .tbtn svg { transform: scaleX(-1); }

.set-list { max-width: 32rem; margin: 0 auto; padding: 8px 16px calc(var(--safe-b) + 32px); }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 56px;
  border: none; border-bottom: 1px solid var(--rule);
  background: transparent; color: var(--ink);
  text-align: start; font: inherit; font-size: 1rem;
  padding: 12px 4px; cursor: pointer;
}
.set-row b { color: var(--muted); font-weight: 500; font-size: 0.9rem; }
.set-row.danger { color: var(--danger); }
.set-row:active { opacity: 0.6; }
.set-toggle input { width: 1.4em; height: 1.4em; accent-color: var(--accent); }
.set-swatches { cursor: default; border-bottom: none; }
.sw-row { display: flex; gap: 10px; padding: 4px 4px 14px; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.sw-swatch { flex: none; width: 88px; border: 2px solid transparent; border-radius: 12px; background: transparent; padding: 3px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; align-items: center; color: var(--muted); font-size: 0.78rem; }
.sw-swatch.on { border-color: var(--accent); color: var(--ink); }
.sw-card { display: block; width: 78px; height: 52px; border-radius: 8px; position: relative; overflow: hidden; border: 1px solid rgba(0,0,0,0.15); }
.sw-bar { position: absolute; top: 0; inset-inline: 0; height: 12px; }
.sw-line { position: absolute; top: 22px; inset-inline: 10px; height: 4px; border-radius: 2px; }
.sw-dots { position: absolute; bottom: 8px; inset-inline-start: 10px; display: flex; gap: 6px; }
.sw-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.sw-deep { background: #0b1016; } .sw-deep .sw-bar { background: #121923; } .sw-deep .sw-line { background: #263140; } .sw-deep .sw-dot-accent { background: #4d9bff; } .sw-deep .sw-dot-gold { background: #f5c711; }
.sw-paper { background: #fbfaf7; } .sw-paper .sw-bar { background: #0b2a4a; } .sw-paper .sw-line { background: #e2ded6; } .sw-paper .sw-dot-accent { background: #0b2a4a; } .sw-paper .sw-dot-gold { background: #f5c711; }
.sw-dark { background: #14171c; } .sw-dark .sw-bar { background: #1b2027; } .sw-dark .sw-line { background: #2b3038; } .sw-dark .sw-dot-accent { background: #6fb3ff; } .sw-dark .sw-dot-gold { background: #f5c711; }
.sw-hc { background: #000; } .sw-hc .sw-bar { background: #fff; } .sw-hc .sw-line { background: #fff; } .sw-hc .sw-dot-accent { background: #fff; } .sw-hc .sw-dot-gold { background: #ffd84d; }

.fr {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 14px;
  padding: calc(var(--safe-t) + 30px) 26px calc(var(--safe-b) + 30px);
  max-width: 26rem; margin: 0 auto; box-sizing: border-box;
}
.fr-q { font-size: 1.5rem; font-weight: 700; margin: 0; text-align: center; }
.fr-sub { color: var(--muted); text-align: center; margin: 0; }
.fr-in {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 1.15rem;
  color: var(--ink); background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r-md); padding: 14px 16px; text-align: center;
}
.fr-in:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Text size calibrator (Diary's) */
.tsc { display: flex; flex-direction: column; min-height: 40vh; }
.tsc-head { margin: 0 0 0.8rem; }
.tsc-sample { flex: 1; overflow-y: auto; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 1rem 1.1rem; }
.tsc-sample p { margin: 0; line-height: 1.55; }
.tsc-bar { position: sticky; bottom: 0; padding: 12px 0 8px; background: var(--surface); }
.tsc-steps { display: flex; gap: 10px; margin-bottom: 10px; }
.tsc-btn { flex: 1 1 0; min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); color: var(--ink); cursor: pointer; }
.tsc-a { font-size: 14px; line-height: 1; }
.tsc-A { font-size: 24px; line-height: 1; font-weight: 600; }
.tsc-ch { display: inline-flex; }
.tsc-ch.up svg { transform: rotate(180deg); }
.tsc-btn.dim { opacity: 0.35; }
.sr-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Sheets (the lock's setup) */
.scrim2 { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.5); opacity: 0; transition: opacity var(--m-quick); }
.scrim2.on { opacity: 1; }
.sheet {
  position: fixed; inset-inline-start: 50%; transform: translate(-50%, 105%); bottom: 0; z-index: 81;
  width: min(100%, 30rem); max-height: 86vh; overflow-y: auto;
  background: var(--surface); color: var(--ink);
  border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: var(--shadow-float);
  padding: 8px 18px calc(var(--safe-b) + 18px);
  transition: transform var(--m-enter) var(--ease-enter);
}
.sheet.on { transform: translate(-50%, 0); }
.sheet-grab { width: 38px; height: 4px; border-radius: var(--r-full); background: var(--rule); margin: 6px auto 12px; }
.sheet h3 { font-size: 1.1rem; margin: 0 0 10px; }
.se-note { color: var(--muted); font-size: 0.85rem; }
.sheet-row { display: flex; align-items: center; gap: 14px; width: 100%; border: none; background: transparent; text-align: start; padding: 13px 2px; font: inherit; color: var(--ink); cursor: pointer; border-bottom: 1px solid var(--rule); }
.sheet-row:last-child { border-bottom: none; }
.sheet-row svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.sheet-row.danger, .sheet-row.danger svg { color: var(--danger); }
.mform label { display: block; margin: 10px 0 4px; font-size: 0.9rem; color: var(--muted); }

/* The lock (Tab's) */
.lockgate { position: fixed; inset: 0; z-index: 300; background: var(--paper); display: flex; align-items: center; justify-content: center; padding: 20px; }
.lock-card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-float); padding: 26px 22px; max-width: 21rem; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--ink); }
.lock-card > svg { color: var(--gold); }
.lock-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.lock-dots { display: flex; gap: 10px; min-height: 14px; }
.lock-dots i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--muted); display: inline-block; }
.lock-dots i.on { background: var(--accent); border-color: var(--accent); }
.lock-dots.err i { border-color: var(--danger); }
.lock-pad { display: grid; grid-template-columns: repeat(3, 64px); gap: 10px; justify-content: center; }
.lock-key { height: 54px; border: 1px solid var(--rule); border-radius: var(--r-md); background: transparent; color: var(--ink); font-size: 1.2rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.lock-key:active { transform: scale(0.94); }
.lock-note { font-size: 0.78rem; color: var(--muted); text-align: center; margin: 4px 0 0; }

/* The offline pill */
.offline-pill {
  position: fixed; top: calc(var(--safe-t) + 64px); inset-inline-start: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 8px;
  background: var(--frost); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--rule); border-radius: var(--r-full);
  color: var(--ink); font-size: 0.8rem; padding: 6px 10px 6px 14px; cursor: pointer; text-align: start;
}
.offline-pill[hidden] { display: none !important; }
.offline-pill .offline-x { flex: none; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(127, 127, 127, 0.25); font-size: 0.9rem; line-height: 1; }

/* The noscript article */
.article { max-width: 32rem; margin: 10vh auto; padding: 0 20px; }
