[hidden] { display: none !important; }
/* Night sky, aurora, a breathing orb that brightens while the AI thinks. System fonts only (the CSP allows no outside files). */
:root {
  --bg: #07060f; --ink: #f3eee6; --muted: #a49db3; --faint: #6f6883; --line: rgba(255,255,255,.09);
  --glass: rgba(20,17,38,.55); --glass-2: rgba(255,255,255,.06);
  --gold: #f6c56b; --rose: #ff7a9c; --violet: #9b7bff; --teal: #4fe0c9;
  --ok: #6ee7a8; --warn: #ffcc66; --bad: #ff7b7b;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 18px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
html { overflow-x: clip; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--serif);
  -webkit-font-smoothing: antialiased; overflow-x: clip;
}
::selection { background: rgba(246,197,107,.35); }

/* ---------- the sky ---------- */
.sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; contain: paint; clip-path: inset(0); background: radial-gradient(120% 90% at 50% 110%, #1a1036 0%, #07060f 60%); }
.aurora { position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; filter: blur(80px); opacity: .45; mix-blend-mode: screen; }
.a1 { background: radial-gradient(circle, var(--violet), transparent 60%); top: -25vmax; left: -15vmax; animation: drift1 28s ease-in-out infinite alternate; }
.a2 { background: radial-gradient(circle, var(--rose), transparent 60%); top: 10vmax; right: -30vmax; opacity: .3; animation: drift2 34s ease-in-out infinite alternate; }
.a3 { background: radial-gradient(circle, var(--teal), transparent 60%); bottom: -40vmax; left: 10vmax; opacity: .25; animation: drift3 40s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(18vmax, 12vmax) scale(1.2); } }
@keyframes drift2 { to { transform: translate(-20vmax, 8vmax) scale(.9); } }
@keyframes drift3 { to { transform: translate(14vmax, -16vmax) scale(1.15); } }
.stars { position: absolute; inset: -50%; background-repeat: repeat; }
.s1 { background-image: radial-gradient(1px 1px at 20px 30px, #fff8, transparent), radial-gradient(1px 1px at 120px 80px, #fff6, transparent), radial-gradient(1.5px 1.5px at 200px 150px, #ffe9b8aa, transparent), radial-gradient(1px 1px at 300px 40px, #fff5, transparent); background-size: 340px 220px; animation: twinkle 120s linear infinite; }
.s2 { background-image: radial-gradient(1px 1px at 60px 120px, #c9b8ff88, transparent), radial-gradient(1px 1px at 260px 200px, #fff7, transparent), radial-gradient(1.5px 1.5px at 400px 90px, #ffffff99, transparent); background-size: 480px 300px; animation: twinkle 200s linear infinite reverse; opacity: .7; }
@keyframes twinkle { to { transform: translateY(-300px); } }
.grain { position: absolute; inset: 0; opacity: .06; background-image: repeating-radial-gradient(circle at 17% 32%, #fff 0 .5px, transparent .5px 3px); mix-blend-mode: overlay; }

/* ---------- layout ---------- */
header, main, #status { width: min(760px, 100% - 32px); margin-inline: auto; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 8px; position: sticky; top: 0; z-index: 5; }
header::before { content: ""; position: absolute; inset: 0 -100vw; background: linear-gradient(var(--bg) 30%, transparent); z-index: -1; }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(from 0deg, var(--gold), var(--rose), var(--violet), var(--teal), var(--gold)); box-shadow: 0 0 18px rgba(246,197,107,.6); animation: spin 12s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
h1 { font: 600 1.15rem/1 var(--sans); letter-spacing: .28em; text-transform: uppercase; margin: 0; }
h2 { font-weight: 500; font-size: 1.35rem; margin: 0 0 .6em; }
h3 { font: 600 .78rem var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin: 1.6em 0 .6em; }
a { color: var(--gold); }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 6vh 0 2vh; transition: opacity .6s, transform .6s, max-height .8s; max-height: 80vh; }
body.talking .hero { opacity: 0; transform: translateY(-30px) scale(.96); max-height: 0; padding: 0; overflow: hidden; pointer-events: none; }
.kicker { font: 600 .72rem var(--sans); letter-spacing: .5em; text-transform: uppercase; color: var(--gold); margin: 26px 0 8px; }
.headline { font-size: clamp(2.3rem, 7vw, 4.4rem); line-height: 1.02; font-weight: 400; margin: 0 0 16px; letter-spacing: -.01em; }
.headline em { font-style: italic; background: linear-gradient(100deg, var(--gold), var(--rose) 45%, var(--violet) 80%); -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 200% 100%; animation: sheen 6s ease-in-out infinite alternate; }
@keyframes sheen { to { background-position: 100% 0; } }
.sub { color: var(--muted); max-width: 30em; margin: 0 auto; }

/* ---------- the orb ---------- */
.orb { position: relative; width: 132px; height: 132px; margin: 0 auto; }
.orb-core { position: absolute; inset: 28%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, var(--gold) 30%, var(--rose) 65%, var(--violet)); box-shadow: 0 0 40px rgba(246,197,107,.7), 0 0 110px rgba(255,122,156,.45); animation: breathe 5s ease-in-out infinite; }
.orb-ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(246,197,107,.35); animation: ripple 5s ease-out infinite; }
.r2 { animation-delay: 1.66s; } .r3 { animation-delay: 3.33s; }
@keyframes breathe { 50% { transform: scale(1.12); filter: brightness(1.15); } }
@keyframes ripple { 0% { transform: scale(.45); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }

/* ---------- panels ---------- */
.glass { background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%); box-shadow: 0 20px 60px -20px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06); }
.panel { margin: 22px 0; padding: 22px 24px; animation: rise .6s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
.choices { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 4px; }
.form { margin-top: 16px; animation: rise .4s both; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.who { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0 0 14px; font: .85rem var(--sans); color: var(--muted); }
.who label { display: inline-flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; }
.who input { width: auto; margin: 0; accent-color: var(--gold); }

/* ---------- controls ---------- */
button { font: 600 .92rem var(--sans); padding: 11px 18px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; color: #1b1222;
  background: linear-gradient(120deg, var(--gold), #ffb38a 50%, var(--rose)); box-shadow: 0 6px 24px -8px rgba(255,122,156,.7); transition: transform .15s, box-shadow .2s, opacity .2s; }
button:hover { transform: translateY(-1px); box-shadow: 0 10px 30px -8px rgba(255,122,156,.9); }
button:active { transform: translateY(1px) scale(.98); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.ghost { background: var(--glass-2); color: var(--ink); border-color: var(--line); box-shadow: none; }
button.ghost:hover { border-color: rgba(246,197,107,.5); }
button.big { padding: 14px 26px; font-size: 1rem; margin-top: 14px; }
button.link { background: none; box-shadow: none; color: var(--muted); padding: 6px 4px; font-weight: 500; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 4px; }
button.link:hover { color: var(--ink); transform: none; }
button.danger { color: var(--bad); }
label { display: block; margin: 12px 0; font: .85rem var(--sans); color: var(--muted); }
input, textarea { font: inherit; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.25); color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s; }
input:focus, textarea:focus { border-color: rgba(246,197,107,.6); box-shadow: 0 0 0 4px rgba(246,197,107,.12); }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 1px; }
.switch span { width: 34px; height: 20px; border-radius: 999px; background: var(--glass-2); border: 1px solid var(--line); position: relative; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch input:checked + span { background: rgba(110,231,168,.25); }
.switch input:checked + span::after { transform: translateX(14px); background: var(--ok); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(246,197,107,.4); }

/* ---------- badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 8px; font: 600 .74rem var(--sans); letter-spacing: .04em; padding: 7px 12px; background: var(--glass-2); color: var(--muted); border: 1px solid var(--line); box-shadow: none; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.badge.pending .dot { animation: pulse 1.2s ease-in-out infinite; }
.badge.ok { color: var(--ok); border-color: rgba(110,231,168,.4); }
.badge.warn { color: var(--warn); border-color: rgba(255,204,102,.4); }
.badge.bad { color: var(--bad); border-color: rgba(255,123,123,.5); }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- the dialogue ---------- */
#chat { display: flex; flex-direction: column; }
#chat #log { flex: 1; }
/* The input and its links stay pinned to the bottom of the screen (keyboard open or not). */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; padding: 10px max(16px, calc((100% - 760px) / 2)) calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(7,6,15,0), #07060f 30%); }
#chat { padding-bottom: calc(var(--dock-h, 138px) + 12px); }   /* --dock-h: the dock's height, kept by app.js */
#log { list-style: none; padding: 0; margin: 18px 0 12px; display: flex; flex-direction: column; gap: 18px; }
#log li { white-space: pre-wrap; animation: msg .5s cubic-bezier(.2,.8,.2,1) both; }
@keyframes msg { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } }
#log li.me { align-self: flex-end; max-width: 82%; padding: 12px 16px; border-radius: 20px 20px 6px 20px; font: 16px/1.5 var(--sans);
  background: linear-gradient(135deg, rgba(155,123,255,.28), rgba(255,122,156,.2)); border: 1px solid rgba(255,255,255,.1); }
#log li.socrates { position: relative; padding: 4px 0 4px 26px; font-size: 1.12rem; line-height: 1.65; max-width: 95%; }
#log li.socrates::before { content: ""; position: absolute; left: 0; top: .55em; width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--gold) 40%, var(--rose)); box-shadow: 0 0 14px rgba(246,197,107,.8); }
#log li.socrates::after { content: attr(data-who); position: absolute; left: 26px; top: -1.2em; font: 600 .62rem var(--sans); letter-spacing: .3em; text-transform: uppercase; color: var(--faint); }
#log li.thinking { color: var(--muted); font-style: italic; }
#log li.notice { align-self: center; max-width: 90%; padding: 10px 16px; border-radius: 12px; font: 600 .82rem/1.5 var(--sans); color: var(--warn); background: rgba(255,204,102,.08); border: 1px solid rgba(255,204,102,.35); text-align: center; }
#log .explain { display: block; margin-top: 8px; padding: 4px 12px; font: 600 .72rem var(--sans); letter-spacing: .08em; color: var(--gold); background: rgba(246,197,107,.08); border: 1px solid rgba(246,197,107,.3); box-shadow: none; }
#log .explain:hover { background: rgba(246,197,107,.16); }
#log li.thinking::before { animation: breathe 1.4s ease-in-out infinite; }
#log li.thinking.dots { font-style: normal; }
#log li.thinking.dots span { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--gold); opacity: .3; animation: dot 1.2s infinite; }
#log li.thinking.dots span:nth-child(2) { animation-delay: .15s; } #log li.thinking.dots span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 30% { opacity: 1; transform: translateY(-4px); } }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 8px 8px 8px 16px; border-radius: 26px; }
.composer textarea { margin: 0; border: none; background: transparent; padding: 10px 0; resize: none; max-height: 40vh; box-shadow: none; font: 16px/1.5 var(--sans); }
.composer textarea:focus { box-shadow: none; }
#mic { width: 44px; height: 44px; padding: 0; flex: none; display: grid; place-items: center; color: var(--gold); background: transparent; border: 1px solid rgba(246,197,107,.3); box-shadow: none; }
#mic.on { width: auto; padding: 0 14px; color: #fff; background: rgba(255,90,90,.25); border-color: rgba(255,90,90,.7); animation: breathe 1.4s ease-in-out infinite; }
#mic .stop { display: none; align-items: center; gap: 6px; font: 600 .85rem var(--sans); }
#mic.on .stop { display: inline-flex; } #mic.on .mic-ico { display: none; }
#log .acts { display: flex; gap: 8px; margin-top: 8px; }
#log .acts .explain { margin-top: 0; }
#log li.insight { margin: 6px 0 6px 26px; padding: 10px 14px; max-width: 90%; font: .95rem/1.6 var(--sans); color: var(--ink, inherit); border-left: 2px solid rgba(246,197,107,.5); background: rgba(246,197,107,.05); border-radius: 4px; }
#log li.insight .insight-label { font: 600 .62rem var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--gold); margin-bottom: 4px; }
#log .speak { display: grid; place-items: center; padding: 4px 10px; font: 600 .72rem var(--sans); color: var(--gold); background: rgba(246,197,107,.08); border: 1px solid rgba(246,197,107,.3); box-shadow: none; }
#log .speak.on { background: rgba(246,197,107,.25); }
#send { width: 44px; height: 44px; padding: 0; font-size: 1.2rem; flex: none; }
.actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; margin: 10px 4px 0; gap: 0 10px; }
#talk.on { color: #fff; }

/* ---------- the call screen (Talk): full screen, or a bar over the chat ---------- */
.call { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); text-align: center; background: radial-gradient(120% 90% at 50% 110%, #1a1036, #07060f 60%); animation: rise .35s cubic-bezier(.2,.8,.2,1) both; }
.call-top { margin: 0; font: 600 .8rem var(--sans); letter-spacing: .3em; text-transform: uppercase; color: var(--muted); }
#call-time { letter-spacing: .05em; color: var(--faint); margin-left: 8px; font-variant-numeric: tabular-nums; }
.call-orb { width: min(56vw, 240px); height: min(56vw, 240px); margin: 4vh auto 2vh; padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.call-orb span { display: block; pointer-events: none; }
body[data-talk="recording"] .call .orb-core, body[data-talk="locked"] .call .orb-core { inset: 18%; filter: hue-rotate(160deg) brightness(1.15); animation: breathe .8s ease-in-out infinite; }
.call .orb-core { transition: inset .5s, filter .5s; }
body[data-talk="idle"] .call .orb-core { inset: 30%; animation-duration: 2.4s; }
body[data-talk="thinking"] .call .orb-core { inset: 32%; animation: breathe 1s ease-in-out infinite; filter: hue-rotate(-25deg) brightness(1.1); }
body[data-talk="speaking"] .call .orb-core { inset: 22%; animation: breathe .7s ease-in-out infinite; }
body[data-talk="thinking"] .call .orb-ring, body[data-talk="speaking"] .call .orb-ring { animation-duration: 2s; }
#talk-state { margin: 0; color: var(--gold); font: 600 1.05rem var(--sans); min-height: 1.6em; }
body[data-talk="speaking"] #talk-state { color: #fff; }
body[data-talk="thinking"] #talk-state::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.call-caption { margin: 0; max-width: 32em; min-height: 4.8em; color: var(--ink); font-size: 1.05rem; line-height: 1.5; }
.call-caption.heard { color: var(--muted); font-style: italic; }
.call-hint { margin: 0; }
.call-buttons { display: flex; gap: 22px; margin-top: 3vh; }
.round { width: 64px; height: 64px; padding: 0; border-radius: 50%; display: grid; place-items: center; color: var(--ink); background: rgba(255,255,255,.1); border: 1px solid var(--line); box-shadow: none; }
.round .slash { display: none; }
.round[aria-pressed="true"] { color: #1b1222; background: var(--ink); }
.round[aria-pressed="true"] .slash { display: inline; }
.round.end { background: #e5484d; border-color: #e5484d; color: #fff; }
.call.mini { inset: 72px 12px auto; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 8px 10px 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(20,17,38,.92); box-shadow: 0 12px 40px -12px rgba(0,0,0,.7); }
.call.mini .call-top, .call.mini .call-caption, .call.mini .call-hint { display: none; }
.call.mini .call-orb { width: 36px; height: 36px; margin: 0; flex: none; }
.call.mini .orb-ring { display: none; }
.call.mini #talk-state { flex: 1; text-align: left; font-size: .9rem; }
.call.mini .call-buttons { margin: 0; gap: 8px; }
.call.mini .round { width: 40px; height: 40px; } .call.mini .round svg { width: 18px; height: 18px; }
body.calling #talk, body.calling #mic { display: none; }
body.thinking .mark { animation-duration: 1.2s; box-shadow: 0 0 30px rgba(255,122,156,.9); }
body.thinking .a1, body.thinking .a2 { opacity: .6; transition: opacity 1s; }

/* ---------- end, notebook, misc ---------- */
pre { white-space: pre-wrap; background: rgba(0,0,0,.25); border: 1px solid var(--line); padding: 14px 16px; border-radius: 12px; font: 1rem/1.6 var(--serif); }
.small, #status { font: .78rem/1.5 var(--sans); color: var(--muted); }
ul.small { padding-left: 1.1em; margin: 10px 0; } ul.small li { margin: 6px 0; }
#status { text-align: center; padding-bottom: 20px; min-height: 1.5em; }
.error { color: var(--bad); font: .88rem var(--sans); }
dl { font: .76rem var(--sans); word-break: break-all; } dt { color: var(--muted); margin-top: 8px; }
#exp-entries { margin-top: 10px; }
.entry { display: flex; gap: 10px; align-items: baseline; border-bottom: 1px solid var(--line); padding: 10px 0; }
.entry span { flex: 1; } .entry small { color: var(--faint); font: .72rem var(--sans); }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .panel { padding: 18px; }
  #log li.me { max-width: 90%; }
  .orb { width: 104px; height: 104px; }
  #timing { display: none; }
  .actions button.link { font-size: .82rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- print: "Save as PDF" keeps only the conversation ---------- */
@media print {
  body { background: #fff !important; color: #000 !important; }
  body * { visibility: hidden; }
  #log, #log * { visibility: visible; }
  #log { position: absolute; left: 0; top: 0; width: 100%; }
  #log li { background: none !important; box-shadow: none !important; border: 1px solid #ccc !important; color: #000 !important; break-inside: avoid; }
  #log button, #log .small { display: none !important; }
  #log li { animation: none !important; filter: none !important; }
}

ol.rules { margin: 6px 0 18px; padding-left: 1.3em; } ol.rules li { margin: 8px 0; }

#newmsg { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--dock-h, 138px) + 2px); z-index: 5; padding: 8px 14px; border-radius: 999px; font: 600 .82rem var(--sans); }

.job { font-size: clamp(1.25rem, 4.2vw, 1.6rem); line-height: 1.3; margin: 22px auto 8px; max-width: 22em; }
.test-banner { margin: 0; padding: 8px 16px; text-align: center; font: 600 .8rem/1.4 var(--sans); color: #1b1222; background: var(--warn); }
#share { width: min(680px, 100vw - 32px); max-height: 85vh; overflow: auto; color: var(--ink); margin: auto; }
#share::backdrop { background: rgba(7,6,15,.7); }
#share pre { max-height: 50vh; overflow: auto; font-size: .9rem; }
#log li.insight p { margin: 2px 0; }
#log li.insight p.ins-item { padding-left: 14px; position: relative; }
#log li.insight p.ins-item::before { content: "–"; position: absolute; left: 0; color: var(--gold); }
#reel-lines textarea { width: 100%; min-height: 4.5em; font: .95rem var(--sans); }
#reel-lines .orig { margin: 2px 0 12px; }
#reel-canvas { display: block; width: 180px; height: 320px; margin: 10px auto; border-radius: 10px; }
#reel-canvas[hidden] { display: none; }
.who-sep { color: var(--faint); font-weight: 400; }
#title { font-weight: inherit; }
