:root {
  --opal: #9d4edd;
  --opal-bright: #b67cf0;
  --opal-deep: #5a1ea0;
  --bg: #000;
  --fg: #f2eefa;
  --muted: #8e8799;
  --line: #1f1b26;
  --field: #141118;
  --raised: #1b1721;
  --danger: #e5484d;
  --bubble: #6a2bb8;
  --tint: #1d0b33;
  --hue: 0deg; /* how far the orb and aurora turn from Opal's purple */
  color-scheme: dark;
}
/* Accent themes (Settings › Appearance). The orb keeps its flowing look, turned to the theme's colour. */
:root[data-theme="sapphire"] { --opal: #3b6fe0; --opal-bright: #7aa2ff; --opal-deep: #1d3f9a; --bubble: #2f5fc8; --tint: #0b1733; --hue: -60deg; }
:root[data-theme="ice"] { --opal: #2bb3c9; --opal-bright: #7fe3f0; --opal-deep: #136c7a; --bubble: #1f94a8; --tint: #061f24; --hue: -80deg; }
:root[data-theme="emerald"] { --opal: #20a36b; --opal-bright: #5fd6a0; --opal-deep: #0f6b45; --bubble: #1c8a5c; --tint: #08241a; --hue: -125deg; }
:root[data-theme="gold"] { --opal: #c9971a; --opal-bright: #f2c95c; --opal-deep: #7d5a07; --bubble: #a87c10; --tint: #241a05; --hue: 140deg; }
:root[data-theme="ruby"] { --opal: #d9365b; --opal-bright: #ff7a95; --opal-deep: #8f1631; --bubble: #b82848; --tint: #2a0812; --hue: 75deg; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--fg); background: var(--field); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px; outline: none; width: 100%; }
input:focus, textarea:focus { border-color: var(--opal-deep); }
::placeholder { color: var(--muted); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; isolation: isolate;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); background: var(--bg); }
/* A slow aurora behind every screen. It only moves, so the phone's graphics chip does the work. */
.screen::before { content: ""; position: absolute; z-index: -1; left: -30%; right: -30%; top: -35%; height: 80%; pointer-events: none;
  background: radial-gradient(40% 45% at 35% 50%, rgba(120, 50, 200, var(--aurora, 0.25)), transparent 70%),
              radial-gradient(35% 40% at 70% 40%, rgba(70, 20, 150, var(--aurora, 0.25)), transparent 70%);
  filter: blur(20px) hue-rotate(var(--hue)); transition: filter 1.5s ease; animation: aurora 38s ease-in-out infinite alternate; }
@keyframes aurora { from { transform: translate3d(-6%, -2%, 0) rotate(-4deg); } to { transform: translate3d(6%, 3%, 0) rotate(5deg); } }
@media (prefers-reduced-motion: reduce) { .screen::before { animation: none; } }
[hidden] { display: none !important; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 24px; }
.muted { color: var(--muted); font-size: 14px; }

/* The ring: a band of slowly flowing purples, like a lava lamp.
   Two layers are cut to the band by a mask: a turning ombré, and soft blobs drifting the other way. */
.ring { --w: 7px; position: relative; flex: none; width: 72px; height: 72px; border-radius: 50%;
  box-shadow: 0 0 22px var(--opal-deep), inset 0 0 18px rgba(90, 30, 160, 0.6); }
.ring::before, .ring::after { content: ""; position: absolute; inset: 0; border-radius: 50%;
  -webkit-mask: radial-gradient(circle closest-side, transparent calc(100% - var(--w) - 0.5px), #000 calc(100% - var(--w)));
  mask: radial-gradient(circle closest-side, transparent calc(100% - var(--w) - 0.5px), #000 calc(100% - var(--w))); }
.ring::before { background: conic-gradient(#2a0a5c, #7b2fd0, #c39bff, #9d4edd, #3c0f7a, #d9b8ff, #6a2bb8, #2a0a5c);
  animation: ring-spin 10s linear infinite; }
.ring::after {
  background:
    radial-gradient(circle at 50% 50%, rgba(240, 222, 255, 0.9), transparent 18%),
    radial-gradient(circle at 50% 50%, rgba(40, 8, 90, 0.95), transparent 22%),
    radial-gradient(circle at 50% 50%, rgba(190, 130, 255, 0.85), transparent 16%),
    radial-gradient(circle at 50% 50%, rgba(110, 30, 190, 0.9), transparent 20%);
  background-size: 140% 140%, 160% 160%, 120% 120%, 150% 150%;
  background-repeat: no-repeat;
  filter: blur(calc(var(--w) * 0.35));
  animation: ring-spin 14s linear infinite reverse, ring-lava 6s ease-in-out infinite alternate; }
.ring.big { --w: 13px; width: 130px; height: 130px; }
.ring.glow { --w: 8px; width: 88px; height: 88px; box-shadow: 0 0 40px var(--opal-deep), inset 0 0 22px rgba(90, 30, 160, 0.6); }
.ring.tiny { --w: 3px; width: 18px; height: 18px; margin-top: 3px; box-shadow: 0 0 8px var(--opal-deep); }
@keyframes ring-spin { to { transform: rotate(360deg); } }
@keyframes ring-lava {
  0%   { background-position: 0% 0%, 100% 100%, 100% 0%, 0% 100%; }
  50%  { background-position: 100% 30%, 0% 60%, 30% 100%, 80% 0%; }
  100% { background-position: 40% 100%, 60% 0%, 0% 40%, 100% 70%; }
}
@media (prefers-reduced-motion: reduce) { .ring::before, .ring::after { animation: none; } }
.pulse { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); box-shadow: 0 0 44px var(--opal), inset 0 0 22px var(--opal-deep); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* The IMPERIAL logo: ultra-thin geometric capitals, widely spaced, in white fading to silver.
   The font is cut down to just these letters, so it's tiny. */
@font-face { font-family: "Imperial Logo"; src: url("fonts/JosefinSans.woff2") format("woff2"); font-display: block; }
.wordmark { display: flex; align-items: center; justify-content: center; margin: 0; font-size: 36px; font-weight: 200; }
.wordmark .word { font-family: "Imperial Logo", "Josefin Sans", "Helvetica Neue", sans-serif; font-weight: 200;
  letter-spacing: 0.45em; padding-left: 0.45em;
  background: linear-gradient(180deg, #ffffff 0%, #e6e3ec 45%, #a9a4b3 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.wordmark .rule { display: none; }
.wordmark.small { font-size: 18px; }

/* Setup */
progress { width: 220px; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--field); }
progress::-webkit-progress-bar { background: var(--field); border-radius: 3px; }
progress::-webkit-progress-value { background: var(--opal); border-radius: 3px; }
.choices { display: flex; flex-direction: column; gap: 10px; width: min(300px, 100%); }
.choices button, #diag-copy, .pill { background: var(--opal); padding: 12px 20px; border-radius: 22px; font-weight: 600; }
.choices button span { display: block; font-size: 13px; font-weight: 400; opacity: 0.8; }
.choices .secondary, #diag-copy { background: var(--raised); }
#diag { width: min(340px, 100%); text-align: left; color: var(--muted); font-size: 13px; }
#diag summary { text-align: center; cursor: pointer; }
#diag pre { white-space: pre-wrap; word-break: break-word; background: var(--field); border-radius: 10px; padding: 10px; max-height: 40vh; overflow-y: auto; }
#setup { overflow-y: auto; justify-content: safe center; }

/* Top bars */
.bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; min-height: 52px; }
.bar h2 { font-size: 16px; font-weight: 600; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 65%; }
.icon { width: 42px; height: 42px; display: grid; place-items: center; color: var(--opal-bright); border-radius: 50%; }
.icon:active { background: var(--raised); }
.icon.dim { color: var(--muted); }
.text { color: var(--opal-bright); font-weight: 600; padding: 6px 0; }

/* Chat list */
.search { display: flex; align-items: center; gap: 8px; margin: 2px 16px 10px; padding: 0 12px;
  background: var(--field); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }
.search svg { width: 18px; height: 18px; flex: none; }
.search input { background: none; border: 0; padding: 9px 0; }
#chats { list-style: none; margin: 0; padding: 0 12px 16px; overflow-y: auto; flex: 1; }
#chats .group { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; padding: 16px 8px 6px; }
#chats .row { position: relative; border-radius: 14px; overflow: hidden; margin-bottom: 2px; }
#chats .del { position: absolute; inset: 0 0 0 auto; width: 88px; background: var(--danger); color: #fff;
  display: grid; place-items: center; font-size: 14px; font-weight: 600; visibility: hidden; }
#chats .row.swiped .del { visibility: visible; }
#chats .item { position: relative; background: var(--bg); padding: 11px 12px; display: flex; flex-direction: column; gap: 2px;
  transition: transform 0.2s ease; touch-action: pan-y; }
#chats .item:active { background: var(--raised); }
#chats .row.dragging .item { transition: none; }
#chats .top { display: flex; justify-content: space-between; gap: 12px; }
#chats .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
#chats .when { color: var(--muted); font-size: 13px; flex: none; }
#chats .preview { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#no-chats { flex: 1; }
.hint { text-align: center; margin: 0 0 10px; font-size: 12px; }

/* Messages */
#messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 18px;
  -webkit-mask: linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
  mask: linear-gradient(to bottom, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%); }
#empty { flex: 1; gap: 22px; }
.greeting { font-size: 22px; font-weight: 600; margin: 0; }
.greeting .muted { font-size: 16px; font-weight: 400; }
.starters { display: flex; flex-direction: column; gap: 8px; width: min(300px, 100%); }
.starters button { background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 11px 14px; font-size: 15px; text-align: left; }
.starters button:active { border-color: var(--opal-deep); }
.msg { max-width: 100%; white-space: pre-wrap; word-wrap: break-word; -webkit-user-select: text; user-select: text; }
.msg.user { align-self: flex-end; max-width: 82%; padding: 10px 15px; border-radius: 20px 20px 6px 20px;
  background: linear-gradient(160deg, var(--bubble), var(--opal-deep)); }
.msg.opal { display: flex; gap: 12px; }
.msg.opal > div:last-child { min-width: 0; flex: 1; }
.msg .dot { color: var(--opal-bright); padding: 0 8px 0 2px; }
.msg .h { display: inline-block; font-size: 18px; margin-top: 4px; }
.msg .brain { color: var(--muted); font-size: 12px; margin-top: 6px; }
.msg .brain:empty { display: none; }
.msg code { background: var(--raised); border-radius: 6px; padding: 1px 5px; font-size: 15px; }
.msg pre { margin: 0; padding: 12px; overflow-x: auto; white-space: pre; }

/* Composer */
#composer { padding: 6px 12px 10px; }
.field { display: flex; align-items: flex-end; gap: 6px; padding: 5px 5px 5px 4px;
  background: linear-gradient(180deg, rgba(40, 32, 52, 0.62), rgba(20, 17, 24, 0.7)); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 24px;
  -webkit-backdrop-filter: blur(22px) saturate(160%); backdrop-filter: blur(22px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 8px 30px rgba(0, 0, 0, 0.45); }
.field:focus-within { border-color: var(--opal-deep); }
#input { resize: none; max-height: 140px; background: none; border: 0; padding: 8px 6px; line-height: 1.35; }
.round { width: 36px; height: 36px; border-radius: 50%; background: var(--opal); color: #fff; flex: none; display: grid; place-items: center; }
.round svg { width: 20px; height: 20px; stroke-width: 2.4; }
.round.ghost { background: none; color: var(--opal-bright); }
#send-btn:disabled { background: var(--raised); color: var(--muted); }
#mic-btn.listening { background: var(--opal); color: #fff; animation: pulse 1.2s infinite; }

/* Settings */
.sheet-body { overflow-y: auto; padding: 0 16px 40px; }
.sheet-body h3 { margin: 26px 4px 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.card { background: var(--field); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.card .muted { margin: 0; }
.card input, .card textarea { background: var(--bg); }
.card.rows { padding: 0 14px; gap: 0; }
.card.rows .toggle { padding: 12px 0; border-bottom: 1px solid var(--line); }
.card.rows .toggle:last-child { border-bottom: 0; }
#memory-form { display: flex; gap: 8px; }
#memory-form button { color: var(--opal-bright); font-weight: 600; }
#memories { list-style: none; padding: 0; margin: 0; }
#memories:empty { display: none; }
#memories li { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
#memories li span { flex: 1; }
#memories li button { color: var(--muted); }
#models { list-style: none; padding: 0; margin: 0; max-height: 40vh; overflow-y: auto; }
#models:empty { display: none; }
#models li { padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 15px; }
#models li.current { color: var(--opal-bright); font-weight: 600; }
.toggle { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.toggle small { display: block; color: var(--muted); font-size: 13px; }
.toggle input { appearance: none; -webkit-appearance: none; flex: none; width: 51px; height: 31px; padding: 0; border: 0;
  border-radius: 16px; background: #39343f; position: relative; transition: background 0.2s; }
.toggle input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; transition: transform 0.2s; }
.toggle input:checked { background: var(--opal); }
.toggle input:checked::after { transform: translateX(20px); }
.version { text-align: center; margin: 28px 0 0; font-size: 13px; letter-spacing: 0.08em; }

.msg a { color: var(--opal-bright); text-decoration: none; border-bottom: 1px solid rgba(182, 124, 240, 0.4); }
.suggest { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 8px 8px 12px; font-size: 14px;
  background: var(--field); border: 1px solid var(--line); border-radius: 12px; white-space: normal; }
.suggest span { flex: 1; }
.suggest .save { color: var(--opal-bright); font-weight: 600; }
.suggest .skip { color: var(--muted); }
#past-memories { list-style: none; padding: 0; margin: 0; }
#past-memories li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
#past-memories li span { flex: 1; }
#past-memories li small { font-size: 12px; }
#past-memories li button { color: var(--muted); }
#memories li span[contenteditable]:focus { outline: none; border-bottom: 1px solid var(--opal-deep); }
#usage-meter { width: 100%; }

/* Voice mode */
#voice { gap: 28px; }
#voice-ring { padding: 0; cursor: pointer; position: relative; z-index: 1; }
#voice-end { position: relative; z-index: 2; }
.voice-type { width: min(320px, 100%); margin: 0; }
.voice-type input { width: 100%; padding: 12px 16px; border-radius: 999px; border: 1px solid var(--line, #3a2458); background: rgba(255,255,255,0.04); color: inherit; font: inherit; font-size: 16px; text-align: center; }
#voice[data-state="listening"] #voice-ring { animation: pulse 1.6s ease-in-out infinite; }
#voice[data-state="thinking"] #voice-ring::before { animation-duration: 2.5s; }
#voice[data-state="speaking"] #voice-ring { animation: speak 0.9s ease-in-out infinite; }
#voice[data-state="idle"] #voice-ring { opacity: 0.6; }
@keyframes speak { 50% { transform: scale(1.1); box-shadow: 0 0 60px var(--opal), inset 0 0 26px var(--opal-deep); } }
.voice-status { font-size: 20px; font-weight: 600; margin: 0; }
.voice-heard { min-height: 3em; max-width: 320px; margin: 0; font-size: 16px; }
.pill.end { background: var(--raised); padding: 12px 36px; margin-top: 12px; }

/* Photos */
.msg.user img { display: block; max-width: 220px; max-height: 260px; border-radius: 14px; margin: 2px 0 8px; }
#attachment { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 8px 6px; padding-top: 8px; }
#attachment.reading::after { content: "Reading…"; align-self: center; color: var(--muted); font-size: 14px; }
#attachment .att { position: relative; }
#attachment .photo img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); display: block; }
#attachment .file-chip { height: 44px; padding: 0 14px; background: var(--raised); }
#attachment .remove { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--raised); border: 1px solid var(--line); color: var(--fg); display: grid; place-items: center; }
#attachment .remove svg { width: 14px; height: 14px; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 220px; padding: 8px 12px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); font-size: 14px; }
.file-chip svg { width: 18px; height: 18px; flex: none; color: var(--opal-bright); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.user .file-chip { display: flex; margin: 2px 0 8px; }

/* Code blocks and document cards */
.msg .code { background: var(--field); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 6px 0; white-space: normal; }
.code-bar { display: flex; align-items: center; gap: 14px; padding: 6px 12px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.code-bar span { flex: 1; }
.code-bar button { color: var(--opal-bright); font-weight: 600; font-size: 13px; }
.doc-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 6px 0; cursor: pointer; white-space: normal;
  background: var(--field); border: 1px solid var(--line); border-radius: 14px; }
.doc-card:active { border-color: var(--opal-deep); }
.doc-card strong { display: block; }
.doc-card small { color: var(--muted); font-size: 13px; }
.doc-icon { flex: none; width: 32px; height: 40px; border-radius: 6px; background: linear-gradient(160deg, #6a2bb8, var(--opal-deep)); }

/* Canvas */
#canvas-text { flex: 1; width: auto; margin: 0 12px; resize: none; border-radius: 14px; padding: 14px; font-size: 16px; line-height: 1.5; }
#canvas-text.mono { font: 14px/1.5 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre; overflow-x: auto; }
.canvas-tools { display: flex; gap: 20px; justify-content: flex-end; padding: 6px 20px 0; }
.canvas-tools button:disabled { color: var(--muted); opacity: 0.6; }
#canvas-ask { padding: 6px 12px 10px; }
#canvas-ask input { background: none; border: 0; padding: 7px 10px; }
#canvas.working #canvas-text { opacity: 0.75; }
.msg pre code { background: none; padding: 0; border-radius: 0; font-size: 14px; }

/* Projects */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 6px; scrollbar-width: none; flex: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 14px; border-radius: 16px; font-size: 14px; background: var(--field); border: 1px solid var(--line); color: var(--muted); }
.chip.on { background: var(--opal-deep); border-color: var(--opal); color: #fff; }
.chip.add { color: var(--opal-bright); }
.hint-small { margin: 0 20px 4px; font-size: 12px; }
#project-files { list-style: none; padding: 0; margin: 0; }
#project-files:empty { display: none; }
#project-files li { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
#project-files li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#project-files li small { color: var(--muted); }
#project-files li button { color: var(--muted); }

/* Calendar events */
.event-card { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 10px 12px; white-space: normal;
  background: var(--field); border: 1px solid var(--line); border-radius: 14px; }
.event-card .cal { flex: none; width: 44px; border-radius: 10px; overflow: hidden; text-align: center; background: var(--raised); }
.event-card .cal small { display: block; background: var(--opal-deep); color: #fff; font-size: 11px; font-weight: 600; text-transform: uppercase; padding: 2px 0; }
.event-card .cal strong { display: block; font-size: 18px; padding: 2px 0 4px; }
.event-card .what { flex: 1; min-width: 0; }
.event-card .what strong { display: block; }
.event-card .what small { color: var(--muted); font-size: 13px; }
.event-card button { color: var(--opal-bright); font-weight: 600; }

/* Shown when the iPhone closed IMPERIAL before Opal finished answering */
.pill.finish { align-self: flex-start; margin: 4px 0 8px 36px; padding: 10px 18px; background: var(--raised);
  border: 1px solid var(--opal-deep); color: var(--opal-bright); font-size: 15px; }

/* Pictures Opal drew */
.made-image { margin: 8px 0; max-width: 300px; }
.made-image img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 16px; border: 1px solid var(--line); background: var(--field); }
.made-image figcaption { display: none; font-size: 14px; color: var(--muted); margin-top: 6px; }
.made-image.chart { max-width: 100%; }
.made-image.chart img { aspect-ratio: auto; object-fit: contain; background: #fff; }
.made-image.loading img { animation: shimmer 1.4s ease-in-out infinite; }
.made-image.loading figcaption, .made-image.failed figcaption { display: block; }
.made-image.failed img { display: none; }
@keyframes shimmer { 50% { background: var(--raised); } }

/* Live camera */
.bar-end { display: flex; align-items: center; }
#camera { background: #000; }
#cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-close { position: absolute; top: calc(env(safe-area-inset-top) + 8px); left: 12px; z-index: 2; background: rgba(0, 0, 0, 0.45); color: #fff; }
.cam-answer { position: absolute; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 76px); z-index: 2; max-height: 40%; overflow: auto;
  padding: 12px 16px; border-radius: 18px; background: rgba(10, 6, 16, 0.78); border: 1px solid var(--opal-deep); backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px); font-size: 16px; line-height: 1.45; }
.cam-answer p { margin: 0 0 6px; }
.cam-bar { position: absolute; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 12px); z-index: 2; align-items: center;
  background: rgba(20, 17, 24, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
#cam-input { flex: 1; background: none; border: 0; padding: 8px 10px; }
#cam-mic.listening { background: var(--opal); color: #fff; animation: pulse 1.2s infinite; }

/* Artifacts: apps and pages Opal builds, running in the chat */
.msg .artifact { background: var(--field); border: 1px solid var(--opal-deep); border-radius: 14px; overflow: hidden; margin: 8px 0; white-space: normal; }
.art-title { flex: 1; color: var(--fg); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art-frame { height: 340px; display: grid; place-items: center; color: var(--muted); background: #fff; }
.art-frame span { color: #666; font-size: 14px; }
.art-frame iframe, #canvas-preview iframe { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
#canvas-preview { display: none; flex: 1; margin: 0 12px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
#canvas.previewing #canvas-preview { display: block; }
#canvas.previewing #canvas-text, #canvas.previewing #canvas-undo, #canvas.previewing #canvas-copy { display: none; }
.canvas-tools #canvas-mode { margin-right: auto; }

/* Under each answer */
.actions { display: flex; gap: 18px; margin-top: 6px; }
.actions button { color: var(--muted); font-size: 13px; font-weight: 600; padding: 4px 0; }
.actions button:active { color: var(--opal-bright); }
.actions .retry-btn { color: var(--opal-bright); }
.check { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); font-size: 14px; }
.check-head { display: block; color: var(--opal-bright); font-size: 13px; margin-bottom: 4px; }

/* Promises and other notices at the top of the chat list */
#banners { display: flex; flex-direction: column; gap: 8px; padding: 0 16px; }
#banners:empty { display: none; }
.banner { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; background: var(--raised);
  border: 1px solid var(--opal-deep); font-size: 14px; }
.banner span { flex: 1; }
.banner button { color: var(--opal-bright); font-weight: 600; }
#promises { list-style: none; margin: 0; padding: 0; }
#promises li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
#promises li:first-child { border-top: 0; }
#promises li span { flex: 1; }
#promises li small { color: var(--muted); }
#promises li button { color: var(--muted); }
#promises input { width: 20px; height: 20px; accent-color: var(--opal); }

/* Writing studio shortcuts above the message box */
.studio { padding: 0 2px 8px; }

/* Face ID lock */
#lock { position: fixed; inset: 0; z-index: 50; background: var(--bg, #000); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 22px; }
#lock[hidden] { display: none; }
#lock p { font-size: 18px; font-weight: 600; margin: 0; }

/* Siri steps */
.steps summary { color: var(--opal-bright); font-weight: 600; padding: 6px 0; }
.steps ol { padding-left: 20px; margin: 8px 0; font-size: 14px; line-height: 1.5; }
.steps li { margin-bottom: 8px; }
.steps code { font-size: 12px; word-break: break-all; }
.steps-buttons { display: flex; gap: 20px; }

/* Morning brief screen */
#brief { display: flex; flex-direction: column; background: radial-gradient(120% 60% at 50% 0%, var(--tint) 0%, var(--bg) 60%); }
.brief-head { display: flex; align-items: flex-start; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 18px) 16px 8px 20px; }
.brief-head h2 { margin: 0; font-size: 28px; font-weight: 700; }
.brief-head p { margin: 4px 0 0; }
#brief-body { flex: 1; overflow-y: auto; padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.brief-card { padding: 14px 16px; border-radius: 18px; background: var(--raised); border: 1px solid var(--line); line-height: 1.5; white-space: pre-wrap; }
.brief-card .h { color: var(--opal-bright); }
.brief-todo { list-style: none; margin: 6px 0 0; padding: 0; white-space: normal; }
.brief-todo li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.brief-todo li span { flex: 1; }
.brief-todo li small { color: var(--muted); }
.brief-todo li.done span { text-decoration: line-through; color: var(--muted); }
.brief-todo input { width: 20px; height: 20px; accent-color: var(--opal); }
.brief-q { align-self: flex-end; max-width: 80%; margin: 4px 0 0; padding: 8px 14px; border-radius: 18px 18px 6px 18px; background: var(--opal-deep); }
.brief-a { white-space: pre-wrap; line-height: 1.5; padding: 0 4px; }
.brief-loading { display: flex; flex-direction: column; align-items: center; gap: 16px; padding-top: 80px; }
#brief-ask { margin: 0 12px calc(env(safe-area-inset-bottom) + 10px); align-items: center; }
#brief-input { flex: 1; background: none; border: 0; padding: 8px 10px; }

/* Small line icons inside text, used instead of emojis */
.inline-icon { width: 15px; height: 15px; vertical-align: -2px; margin-right: 6px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.with-icon .inline-icon { color: var(--opal-bright); width: 17px; height: 17px; vertical-align: -3px; margin-right: 8px; }

/* Voice mode heads-up display */
#voice { background: radial-gradient(70% 45% at 50% 42%, var(--tint) 0%, var(--bg) 70%); }
.hud-top { position: absolute; top: calc(env(safe-area-inset-top) + 16px); left: 20px; right: 20px; display: flex; justify-content: space-between;
  font: 600 12px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.2em; text-transform: uppercase; color: var(--opal-bright); opacity: 0.8; }
.hud { position: relative; width: 250px; height: 250px; display: grid; place-items: center; }
.hud-rings { position: absolute; inset: 0; pointer-events: none; width: 100%; height: 100%; overflow: visible; }
.hud-rings circle { fill: none; stroke: var(--opal); transform-origin: 100px 100px; }
.hud-rings .r1 { stroke-width: 1; stroke-dasharray: 1 5; opacity: 0.7; animation: hud-spin 40s linear infinite; }
.hud-rings .r2 { stroke-width: 2.5; stroke-dasharray: 70 40 16 40; opacity: 0.55; animation: hud-spin 18s linear infinite reverse; }
.hud-rings .r3 { stroke-width: 0.8; opacity: 0.35; }
.hud-rings .r4 { stroke-width: 5; stroke-dasharray: 2 10; opacity: 0.25; animation: hud-spin 60s linear infinite; }
#voice[data-state="thinking"] .hud-rings .r2 { animation-duration: 3s; opacity: 0.9; }
#voice[data-state="thinking"] .hud-rings .r1 { animation-duration: 8s; }
#voice[data-state="speaking"] .hud-rings .r2 { opacity: 0.9; stroke: var(--opal-bright); }
#voice[data-state="standby"] .hud-rings { opacity: 0.45; }
#voice[data-state="standby"] #voice-ring { animation: pulse 3.5s ease-in-out infinite; opacity: 0.8; }
.voice-status { letter-spacing: 0.04em; }
@keyframes hud-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .hud-rings circle { animation: none !important; } }
#voice-pick { width: 100%; padding: 12px 14px; font-size: 16px; -webkit-appearance: none; appearance: none; }
.slider-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }
.slider-row input { accent-color: var(--opal); width: 55%; border: 0; background: none; padding: 0; }

/* Greeting at the top of the chats list */
#greeting { padding: 4px 20px 12px; }
.greet-hello { margin: 0; font-size: 24px; font-weight: 300; letter-spacing: 0.01em; }
.greet-status { margin: 4px 0 0; font-size: 12px; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase; }
.greet-status:empty { display: none; }

/* Protocols */
#protocols { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
#protocols li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--raised); }
#protocols li span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
#protocols li small { color: var(--muted); font-size: 13px; }
#protocols li button { color: var(--muted); }
.protocol-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.protocol-form input, .protocol-form textarea { padding: 12px 14px; font-size: 16px; }

/* Smoother chat: new messages rise in, and a soft cursor shows while Opal is writing */
.msg.fresh { animation: rise 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.body.streaming > :last-child::after, .body.streaming:not(:has(> *))::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px;
  border-radius: 50%; background: var(--opal-bright); box-shadow: 0 0 10px var(--opal); vertical-align: middle; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* Boot sequence on the splash screen */
.boot-ring { animation: boot-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.wordmark.boot .word { animation: boot-word 1.2s 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.boot-line { margin: 0; font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); position: relative; overflow: hidden; padding-bottom: 8px; }
.boot-line span { animation: boot-fade 0.6s 0.6s both; }
.boot-line::after { content: ""; position: absolute; left: 0; bottom: 0; height: 1px; width: 100%; background: linear-gradient(90deg, transparent, var(--opal-bright), transparent);
  animation: boot-scan 1.4s 0.6s ease-in-out infinite; }
@keyframes boot-in { from { opacity: 0; transform: scale(0.6); filter: blur(6px); } }
@keyframes boot-word { from { opacity: 0; letter-spacing: 0.6em; filter: blur(4px); } }
@keyframes boot-fade { from { opacity: 0; } }
@keyframes boot-scan { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .boot-ring, .wordmark.boot .word, .boot-line span, .boot-line::after, .msg.fresh { animation: none; } }
.brief-head > div { flex: 1; }
#protocols li .copy { align-self: flex-start; padding: 4px 0 0; font-size: 14px; color: var(--opal-bright); }
.suggest .alert { margin-right: 4px; }
.card.rows > p.muted { margin: 12px 0 4px; }

/* ---------- 1.20 interface ---------- */
.msg { -webkit-touch-callout: none; position: relative; }
@media (hover: none) { .msg { -webkit-user-select: none; user-select: none; } }

/* Living orb */
.ring[data-state="thinking"]::before { animation-duration: 2.2s; }
.ring[data-state="thinking"]::after { animation-duration: 3s, 2s; }
.ring[data-state="tool"]::before { animation-duration: 1.2s; filter: brightness(1.35) saturate(1.3); }
.ring[data-state="tool"] { box-shadow: 0 0 14px var(--opal-bright); }
.ring[data-state="writing"] { box-shadow: 0 0 12px var(--opal); }

/* Thought trail */
.trail { display: flex; flex-direction: column; gap: 4px; margin: 1px 0 8px; font-size: 13px; letter-spacing: 0.04em; }
.trail:empty { display: none; }
.trail .step { display: flex; align-items: center; gap: 8px; color: var(--muted); white-space: normal; }
.trail .step::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--opal-bright); box-shadow: 0 0 8px var(--opal); }
.trail .step.live { background: linear-gradient(90deg, var(--muted) 30%, #fff 50%, var(--muted) 70%); background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: trail-sheen 1.6s linear infinite; }
.trail .step.live::before { animation: blink 0.9s ease-in-out infinite; }
.trail .step.done::before { width: 10px; height: 6px; border-radius: 0; background: none; box-shadow: none;
  border-left: 2px solid var(--opal-bright); border-bottom: 2px solid var(--opal-bright); transform: rotate(-45deg) translate(1px, -1px); }
@keyframes trail-sheen { from { background-position: 100% 0; } to { background-position: -150% 0; } }

/* Radial menu */
.radial { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: boot-fade 0.18s both; }
.radial-core { position: absolute; left: var(--x); top: var(--y); width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  border: 2px solid var(--opal-bright); box-shadow: 0 0 24px var(--opal), inset 0 0 10px var(--opal); }
.radial-core::after { content: ""; position: absolute; inset: -66px; border-radius: 50%; border: 1px dashed rgba(182, 124, 240, 0.35); animation: hud-spin 20s linear infinite; }
.radial-item { position: absolute; left: var(--x); top: var(--y); width: 76px; margin: -28px 0 0 -38px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transform: translate(var(--dx), var(--dy)); animation: radial-in 0.32s calc(var(--i) * 30ms) cubic-bezier(0.2, 1.3, 0.4, 1) both; }
.radial-item .orb { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 35% 30%, rgba(190, 140, 255, 0.5), rgba(60, 20, 110, 0.85)); border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 18px rgba(157, 78, 221, 0.6); }
.radial-item small { font-size: 11px; font-weight: 600; letter-spacing: 0.03em; color: var(--fg); text-shadow: 0 1px 6px #000; }
.radial-item:active .orb { transform: scale(0.92); background: var(--opal); }
@keyframes radial-in { from { transform: translate(0, 0) scale(0.2); opacity: 0; } }

/* Swipe a message */
.swipe-hint { position: absolute; top: 50%; right: -44px; width: 32px; height: 32px; margin-top: -16px; border-radius: 50%; display: grid; place-items: center;
  color: var(--opal-bright); opacity: var(--pull, 0); transform: scale(calc(0.6 + var(--pull, 0) * 0.4)); pointer-events: none; }
.swipe-hint svg { width: 18px; height: 18px; }
.msg.armed .swipe-hint { background: var(--opal); color: #fff; }

/* Next-step chips */
.next-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; white-space: normal; }
.next-chips .chip { padding: 8px 13px; border-radius: 16px; font-size: 14px; text-align: left; color: var(--fg);
  background: rgba(157, 78, 221, 0.12); border: 1px solid rgba(182, 124, 240, 0.3); animation: rise 0.35s both; }
.next-chips .chip:nth-child(2) { animation-delay: 60ms; } .next-chips .chip:nth-child(3) { animation-delay: 120ms; }
.next-chips .chip:active { background: var(--opal); }

/* Pull down to talk */
.pull { display: flex; align-items: center; justify-content: center; gap: 8px; overflow: hidden; flex: none;
  height: calc(var(--p, 0) * 56px); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); pointer-events: none;
  opacity: var(--p, 0); }
.pull .ring { transform: scale(calc(0.6 + var(--p, 0) * 0.6)); }
.pull.ready { color: var(--opal-bright); }
.pull.ready .ring { box-shadow: 0 0 16px var(--opal-bright); }

/* Jump to latest */
.jump { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 78px); width: 40px; height: 40px; margin-left: -20px; border-radius: 50%; z-index: 4;
  display: grid; place-items: center; color: var(--fg); background: rgba(30, 24, 40, 0.8); border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); animation: rise 0.25s both; }
.jump svg { width: 18px; height: 18px; }
.jump.busy::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--opal-bright); animation: ring-spin 0.9s linear infinite; }

/* Glass header */
.bar { position: relative; }
.bar::after { content: ""; position: absolute; left: 16px; right: 16px; bottom: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(182, 124, 240, 0.25), transparent); }
@media (prefers-reduced-motion: reduce) { .trail .step.live, .radial-item, .next-chips .chip, .jump, .radial-core::after { animation: none; } }

.notes-head { margin: 14px 0 4px; }
#opal-notes, #decisions { list-style: none; margin: 0; padding: 0; }
#opal-notes li, #decisions li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
#opal-notes li span, #decisions li span { flex: 1; }
#opal-notes li button, #decisions li button { color: var(--muted); }
.diag-text { white-space: pre-wrap; word-break: break-word; font-size: 12px; max-height: 50vh; overflow-y: auto; background: var(--field); border-radius: 10px; padding: 10px; }

/* Opal's mood shows in every orb */
.ring::before, .ring::after { transition: filter 1.2s ease; filter: hue-rotate(var(--hue)); }
.ring { transition: box-shadow 1.2s ease; }
:root[data-mood="warm"] .ring::before { filter: hue-rotate(calc(var(--hue) + 40deg)) saturate(1.3) brightness(1.1); }
:root[data-mood="warm"] .ring { box-shadow: 0 0 26px rgba(214, 90, 200, 0.55), inset 0 0 18px rgba(150, 40, 140, 0.5); }
:root[data-mood="bright"] .ring::before { filter: hue-rotate(var(--hue)) saturate(1.5) brightness(1.3); animation-duration: 4s; }
:root[data-mood="bright"] .ring { box-shadow: 0 0 34px var(--opal-bright), inset 0 0 20px var(--opal); }
:root[data-mood="soft"] .ring::before { filter: hue-rotate(calc(var(--hue) - 40deg)) saturate(0.75) brightness(0.85); animation-duration: 18s; }
:root[data-mood="soft"] .ring::after { animation-duration: 24s, 10s; }
:root[data-mood="soft"] .ring { box-shadow: 0 0 18px rgba(70, 60, 170, 0.5), inset 0 0 16px rgba(40, 30, 110, 0.6); }
:root[data-mood="curious"] .ring::before { filter: hue-rotate(calc(var(--hue) - 20deg)) brightness(1.12); animation-duration: 7s; }
:root[data-mood="fiery"] .ring::before { filter: hue-rotate(calc(var(--hue) + 75deg)) saturate(1.6) brightness(1.15); animation-duration: 3.5s; }
:root[data-mood="fiery"] .ring::after { animation-duration: 8s, 3s; }
:root[data-mood="fiery"] .ring { box-shadow: 0 0 30px rgba(235, 80, 60, 0.6), inset 0 0 18px rgba(160, 40, 30, 0.55); }
:root[data-mood="calm"] .ring::before { filter: hue-rotate(calc(var(--hue) - 70deg)) saturate(0.9) brightness(0.95); animation-duration: 22s; }
:root[data-mood="calm"] .ring::after { animation-duration: 30s, 12s; }
:root[data-mood="calm"] .ring { box-shadow: 0 0 22px rgba(40, 140, 190, 0.5), inset 0 0 16px rgba(20, 80, 120, 0.55); }

/* She looks at you: a glint on the band that drifts towards your finger */
.ring > .glint { position: absolute; inset: 0; z-index: 1; border-radius: 50%; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(circle at calc(50% + var(--gx, 0) * 40%) calc(50% + var(--gy, -0.5) * 40%),
    rgba(255, 240, 255, 0.85), rgba(225, 190, 255, 0.3) 12%, transparent 26%);
  -webkit-mask: radial-gradient(circle closest-side, transparent calc(100% - var(--w) - 0.5px), #000 calc(100% - var(--w)));
  mask: radial-gradient(circle closest-side, transparent calc(100% - var(--w) - 0.5px), #000 calc(100% - var(--w))); }

/* Voice ripples: rings of sound sent out from the orb */
.ripple { position: absolute; inset: 0; margin: auto; width: 130px; height: 130px; border-radius: 50%; pointer-events: none;
  border: 1.5px solid var(--opal-bright); box-shadow: 0 0 14px var(--opal), inset 0 0 10px var(--opal-deep); }

/* Something's waiting: the orb on the list breathes, with a halo going out from it */
.greet-orb.calling .ring { animation: calling 2.6s ease-in-out infinite; }
.greet-orb.calling::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; pointer-events: none;
  border: 1.5px solid var(--opal-bright); animation: call-halo 2.6s ease-out infinite; }
@keyframes calling { 50% { transform: scale(1.12); box-shadow: 0 0 26px var(--opal-bright), 0 0 50px var(--opal); } }
@keyframes call-halo { from { transform: scale(0.7); opacity: 0.8; } to { transform: scale(1.35); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .greet-orb.calling .ring { animation: none; box-shadow: 0 0 26px var(--opal-bright); } .greet-orb.calling::after { animation: none; opacity: 0; } }

/* The chats list header has two buttons on the right, so keep the wordmark centred on the screen */
#list > .bar > .wordmark { position: absolute; left: 0; right: 0; margin: 0 auto; width: fit-content; pointer-events: none; }

/* Today's habits, under the greeting */
.chips.habits { padding: 0 16px 10px; }
.chip.habit { display: flex; align-items: center; gap: 2px; color: var(--fg); }
.chip.habit .inline-icon { color: var(--muted); margin-right: 4px; transition: color 0.2s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1); }
.chip.habit small { color: var(--opal-bright); font-weight: 600; font-variant-numeric: tabular-nums; }
.chip.habit.on { background: var(--opal-deep); border-color: var(--opal); }
.chip.habit.on .inline-icon { color: #fff; transform: scale(1.15); }
.chip.habit.on small { color: #fff; }

/* Life screen */
.life-tabs { padding: 2px 16px 10px; }
#life-body { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.life-card { position: relative; background: var(--field); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px; white-space: normal; }
.msg .life-card { margin-top: 10px; background: var(--raised); }
.life-card .h { color: var(--opal-bright); padding-right: 60px; }
.life-card p { margin: 0; line-height: 1.5; }
.life-card .corner { position: absolute; top: 6px; right: 14px; color: var(--muted); font-weight: 500; font-size: 14px; }
.ticks { list-style: none; margin: 0; padding: 0; }
.ticks li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.ticks li:first-child { border-top: 0; }
.ticks li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ticks li small { color: var(--muted); font-size: 13px; flex: none; }
.ticks li > button { color: var(--muted); flex: none; }
.ticks li.done span { color: var(--muted); text-decoration: line-through; }
.ticks input[type=checkbox] { width: 20px; height: 20px; flex: none; accent-color: var(--opal); padding: 0; }
.ticks .add-row form { flex: 1; }
.ticks .add-row input { padding: 6px 0; border: 0; background: none; border-radius: 0; }
.life-add { display: flex; gap: 10px; align-items: center; }
.life-add input { flex: 1; }
.play-one { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--raised); color: var(--opal-bright); flex: none; }
.play-one svg { width: 14px; height: 14px; }
.player { display: flex; align-items: center; gap: 18px; }
.player .round { width: 48px; height: 48px; }
.player .round:disabled { opacity: 0.4; }

/* Habits with the last seven days as dots */
.habit-rows { list-style: none; margin: 0; padding: 0; }
.habit-rows li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.habit-rows li > span:first-of-type { flex: 1; min-width: 0; }
.habit-rows .tick { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid rgba(255, 255, 255, 0.2); color: transparent; flex: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s; }
.habit-rows .tick svg { width: 16px; height: 16px; stroke-width: 2.6; }
.habit-rows .tick.on { background: var(--opal); border-color: var(--opal); color: #fff; }
.habit-rows .week { display: flex; gap: 4px; flex: none; }
.habit-rows .week i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); }
.habit-rows .week i.on { background: var(--opal-bright); box-shadow: 0 0 6px var(--opal); }
.habit-rows small { color: var(--muted); width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.habit-rows .remove-habit { color: var(--muted); flex: none; padding-left: 4px; }

/* Spending */
.budget-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.budget-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--opal-deep), var(--opal-bright)); border-radius: 4px; }
.budget-bar.over i { background: linear-gradient(90deg, #a0441e, #e5884d); }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 84px 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.bar-row span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row div { height: 10px; }
.bar-row i { display: block; height: 100%; min-width: 4px; border-radius: 5px; background: var(--opal); }
.bar-row small { font-variant-numeric: tabular-nums; }
.block { display: block; margin-top: 4px; color: var(--opal-bright); }
.pill.open-translator { align-self: flex-start; margin-top: 10px; background: var(--raised); color: var(--opal-bright); border: 1px solid var(--opal-deep); }
.pill .inline-icon { width: 17px; height: 17px; vertical-align: -3px; margin-right: 8px; }

/* Live translator */
#translate { padding-bottom: calc(env(safe-area-inset-bottom) + 10px); }
.tr-pick { display: flex; flex-direction: column; gap: 6px; padding: 0 16px 8px; font-size: 14px; }
#tr-log { flex: 1; overflow-y: auto; padding: 8px 16px; display: flex; flex-direction: column; gap: 12px; }
.tr-hint { text-align: center; margin: auto 12px; line-height: 1.5; }
.tr-turn { max-width: 88%; padding: 10px 14px; border-radius: 18px; background: var(--raised); border: 1px solid var(--line); }
.tr-turn.me { align-self: flex-end; border-color: var(--opal-deep); }
.tr-turn small { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.tr-turn p { margin: 2px 0 0; }
.tr-turn .said { color: var(--muted); font-size: 15px; }
.tr-turn .into { font-size: 20px; font-weight: 600; }
.tr-live { min-height: 24px; margin: 0 16px 6px; color: var(--opal-bright); text-align: center; }
.tr-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 16px 10px; }
.tr-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px; border-radius: 22px; font-weight: 600;
  background: var(--raised); border: 1px solid var(--opal-deep); transition: transform 0.2s, box-shadow 0.3s; }
.tr-btn svg { width: 28px; height: 28px; color: var(--opal-bright); }
.tr-btn.them { background: linear-gradient(160deg, var(--opal-deep), var(--tint)); }
.tr-btn.listening { transform: scale(0.97); box-shadow: 0 0 0 3px var(--opal), 0 0 30px var(--opal); }
.tr-type { margin: 0 16px; }
.tr-type input { border: 0; background: none; }
.tr-large { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: grid; place-items: center; padding: 32px;
  font-size: clamp(32px, 9vw, 64px); font-weight: 700; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.tr-large[hidden] { display: none; }

/* Greeting with Opal's orb, ringed by today's habits */
#greeting { display: flex; align-items: center; gap: 14px; }
.greet-text { flex: 1; min-width: 0; }
.greet-orb { position: relative; flex: none; width: 58px; height: 58px; display: grid; place-items: center; padding: 0; }
.greet-orb .ring { --w: 4px; width: 34px; height: 34px; box-shadow: 0 0 16px var(--opal-deep); transition: transform 0.3s, box-shadow 1.2s; }
.greet-orb:not(.has-rings) .ring { --w: 5px; width: 44px; height: 44px; }
.greet-orb:active .ring { transform: scale(0.92); }
.habit-rings { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.habit-rings circle { fill: none; stroke-linecap: round; transition: stroke-dasharray 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.habit-rings .seg { stroke: rgba(255, 255, 255, 0.1); }
.habit-rings .seg.on { stroke: var(--opal-bright); filter: drop-shadow(0 0 3px var(--opal)); }
.habit-rings .week { stroke: rgba(255, 255, 255, 0.07); }
.habit-rings .week.on { stroke: var(--opal); opacity: 0.8; }
.greet-orb.closed .ring { animation: rings-closed 1.5s ease-out; }
@keyframes rings-closed { 30% { transform: scale(1.25); box-shadow: 0 0 40px var(--opal-bright); } }

/* Notices as a deck: the top card in front, two peeking out behind it */
#banners.stack { position: relative; display: block; margin: 0 16px; padding: 0; transition: height 0.25s ease; touch-action: pan-y; }
#banners.stack .banner { position: absolute; top: 0; left: 0; right: 0; overflow: hidden; transform-origin: 50% 100%;
  transform: translateY(calc(var(--i, 0) * 9px)) scale(calc(1 - var(--i, 0) * 0.05));
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), translate 0.22s ease-out, rotate 0.22s ease-out, opacity 0.22s; }
#banners.stack .banner:not(:first-child) { filter: brightness(calc(1 - var(--i, 0) * 0.22)); }
#banners.stack .banner:nth-child(n+4) { opacity: 0; }
#banners.stack .banner:not(:first-child) > * { visibility: hidden; }
.stack-dots { display: flex; justify-content: center; gap: 5px; padding: 8px 0 2px; }
.stack-dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); }
.stack-dots i.on { background: var(--opal-bright); width: 14px; border-radius: 3px; }

/* Voice mode: the orb and its rings swell with the words */
#voice .hud { scale: calc(1 + var(--level, 0) * 0.14); transition: scale 0.08s linear; }
#voice-ring { filter: drop-shadow(0 0 calc(var(--level, 0) * 30px) var(--opal-bright)); }
#voice .hud-rings { opacity: calc(0.75 + var(--level, 0) * 0.5); }

/* Listen later mini-player */
.mini-player { position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 14px); display: flex; align-items: center; gap: 4px;
  padding: 6px 6px 6px 14px; border-radius: 22px; background: rgba(27, 23, 33, 0.88); border: 1px solid var(--opal-deep);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); animation: mp-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
body[data-screen="chat"] .mini-player { bottom: calc(env(safe-area-inset-bottom) + 78px); }
.mini-player[hidden] { display: none; }
.mp-title { flex: 1; min-width: 0; text-align: left; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 8px 6px; }
.mini-player .icon { width: 38px; height: 38px; }
.eq { display: flex; align-items: flex-end; gap: 2px; height: 16px; flex: none; }
.eq i { width: 3px; height: 100%; border-radius: 2px; background: var(--opal-bright); animation: eq 0.9s ease-in-out infinite; transform-origin: bottom; }
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.6s; }
.mini-player.preparing .eq i { animation-duration: 2.4s; opacity: 0.5; }
@keyframes eq { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }
@keyframes mp-in { from { transform: translateY(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .eq i, .mini-player { animation: none; } }

/* Pinned replies under the chat's title */
.chips.pins { padding: 0 16px 8px; }
.chip.pin { display: flex; align-items: center; color: var(--fg); max-width: 75vw; }
.chip.pin span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.pin .inline-icon { color: var(--opal-bright); }
.msg.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 15% { background: rgba(255, 255, 255, 0.08); box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.08); border-radius: 14px; } }

/* Theme swatches */
.themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 6px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.swatch i { width: 40px; height: 40px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35); transition: transform 0.2s, box-shadow 0.2s; }
.swatch small { font-size: 12px; color: var(--muted); }
.swatch.on i { transform: scale(1.08); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); }
.swatch.on small { color: var(--fg); }

/* Voice mode readouts, like a heads-up display */
.hud-pods { position: absolute; top: calc(env(safe-area-inset-top) + 46px); left: 20px; right: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px;
  font: 500 13px/1.3 ui-monospace, "SF Mono", Menlo, monospace; color: var(--fg); pointer-events: none; }
.pod { text-align: left; display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-left: 10px; border-left: 1px solid var(--opal-deep); }
.pod.right { text-align: right; padding: 0 10px 0 0; border-left: 0; border-right: 1px solid var(--opal-deep); }
.pod small { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--opal-bright); opacity: 0.8; }
.pod span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.9; }
@media (max-height: 700px) { .hud-pods { display: none; } }

/* Opal speaking up */
/* Speaking up: a small pill under the status bar, like the iPhone's Dynamic Island, not a banner. */
.speak-up { position: fixed; z-index: 35; top: calc(env(safe-area-inset-top) + 6px); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(340px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 9px; border-radius: 999px; background: rgba(18, 16, 22, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  animation: drop-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); transition: opacity 0.3s, transform 0.3s; }
.speak-up[hidden] { display: none; }
.speak-up.out { opacity: 0; transform: translate(-50%, -12px); }
.speak-up p { margin: 0; font-size: 13px; line-height: 1.35; opacity: 0.92; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.speak-up.open { border-radius: 18px; }
.speak-up.open p { -webkit-line-clamp: unset; }
.speak-up .ring { margin: 0; width: 14px; height: 14px; flex: none; }
@keyframes drop-in { from { transform: translate(-50%, -16px); opacity: 0; } }
#scenes:empty { display: none; }

/* Missions, links */
.mission-card p { margin: 6px 0 8px; }
.mission-state { display: flex; align-items: center; gap: 8px; }
.mission-state .ring { margin: 0; }
.mission-card .pill { margin-top: 10px; }
summary .linked { margin-left: 6px; color: var(--opal-bright); font-weight: 600; }
summary .linked:empty { display: none; }
#links-card input { margin-top: 8px; }
#routines:empty { display: none; }
.brain-note { display: block; width: fit-content; max-width: 100%; margin: 0 0 6px; padding: 2px 9px; border-radius: 10px; background: var(--line); color: var(--muted); font-size: 11px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }

/* Touching the orb: the command wheel, the glance card */
.orb-wheel { position: fixed; inset: 0; z-index: 60; pointer-events: none; background: radial-gradient(circle at var(--cx) var(--cy), rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.75) 60%);
  opacity: 0; transition: opacity 0.2s ease; }
.orb-wheel.open { opacity: 1; }
.wheel-item { position: absolute; left: var(--cx); top: var(--cy); display: grid; justify-items: center; gap: 4px; width: 72px; margin: -27px 0 0 -36px;
  transform: translate(0, 0) scale(0.3); opacity: 0; transition: transform 0.28s cubic-bezier(0.3, 1.4, 0.5, 1), opacity 0.2s ease; }
.orb-wheel.open .wheel-item { transform: translate(var(--x), var(--y)) scale(1); opacity: 1; }
.wheel-item span { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--raised);
  border: 1px solid var(--opal-deep); box-shadow: 0 0 14px rgba(0, 0, 0, 0.5); transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease; }
.wheel-item svg { width: 22px; height: 22px; color: var(--fg); }
.wheel-item small { font-size: 11px; color: var(--muted); font-weight: 600; transition: color 0.15s ease; }
.wheel-item.on span { transform: scale(1.18); background: var(--opal); border-color: var(--opal-bright); box-shadow: 0 0 22px var(--opal); }
.wheel-item.on small { color: var(--fg); }
.orb-glance { position: fixed; z-index: 55; width: 230px; box-sizing: border-box; padding: 14px 16px; border-radius: 18px; display: grid; gap: 8px;
  background: rgba(27, 23, 33, 0.92); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border: 1px solid var(--opal-deep);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 24px rgba(90, 30, 160, 0.35); }
.orb-glance > strong { font-size: 28px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.orb-glance > small { color: var(--muted); font-size: 12px; margin-top: -4px; }
.orb-glance div { display: grid; gap: 1px; padding-left: 9px; border-left: 1px solid var(--opal-deep); }
.orb-glance div small { font: 600 9px/1.4 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.16em; text-transform: uppercase; color: var(--opal-bright); }
.orb-glance div span { font-size: 13px; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .wheel-item, .orb-wheel { transition: none; } }
.orb-wheel::after { content: ""; position: absolute; left: var(--cx); top: var(--cy); width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: var(--opal-bright); box-shadow: 0 0 18px var(--opal); }
.orb-touch, .orb-touch *, body.no-select, body.no-select * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* Home: Opal with the day orbiting her */
#home { background: radial-gradient(70% 40% at 50% 46%, color-mix(in srgb, var(--tint) 70%, var(--bg)) 0%, var(--bg) 70%); align-items: center;
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 10px); gap: 14px; overflow: hidden; }
.home-top { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.hud-label { margin: 0; font-size: 13px; font-weight: 500; line-height: 1.3; color: var(--muted); }
.home-hello { margin: auto 0 0; font-size: 24px; font-weight: 600; text-align: center; text-wrap: balance; }
.orbit { position: relative; width: min(360px, 100%); aspect-ratio: 1 / 0.92; display: grid; place-items: center; flex: none; margin-top: 4px; }
.ring.xl { --w: 12px; width: 140px; height: 140px; padding: 0; border: 0; background: none; cursor: pointer; animation: home-breathe 5s ease-in-out infinite; }
@keyframes home-breathe { 50% { box-shadow: 0 0 26px color-mix(in srgb, var(--opal) 60%, transparent), inset 0 0 14px var(--opal-deep); } }
.sat { position: absolute; width: 112px; display: grid; gap: 2px; justify-items: center; text-align: center; padding: 6px; border-radius: 12px; color: var(--fg); background: none; }
.sat:active { background: rgba(255, 255, 255, 0.05); }
.sat small { font: 600 10px/1.3 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.16em; text-transform: uppercase; color: var(--opal-bright); }
.sat span { font-size: 14px; line-height: 1.3; text-wrap: balance; }
.sat.top { top: 0; left: 50%; transform: translateX(-50%); width: 240px; }
.sat.bottom { bottom: 0; left: 50%; transform: translateX(-50%); }
.sat.left { left: -6px; top: 50%; transform: translateY(-22px); width: 98px; align-content: start; }
.sat.right { right: -6px; top: 50%; transform: translateY(-22px); width: 98px; align-content: start; }
.home-waiting { width: 100%; max-width: 420px; display: flex; gap: 10px; align-items: center; text-align: left; padding: 12px 14px; border-radius: 16px;
  background: var(--field); border: 1px solid var(--line); color: var(--fg); font-size: 14px; line-height: 1.4; }
.home-waiting .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--opal-bright); animation: pulse 2s ease-in-out infinite; }
.home-ask { width: 100%; max-width: 420px; display: flex; gap: 8px; align-items: center; margin-top: auto; padding-top: 12px; }
.home-ask input { flex: 1; min-width: 0; border-radius: 22px; padding: 11px 16px; font-size: 16px; }
.home-chats { display: grid; justify-items: center; gap: 5px; color: var(--muted); font-size: 12px; padding: 2px 30px 0; background: none; }
.home-chats::before { content: ""; width: 38px; height: 4px; border-radius: 2px; background: var(--line); }
#home-orb.calling { animation: calling 2.6s ease-in-out infinite; }
#list > .bar > #home-btn { pointer-events: auto; cursor: pointer; }
.day-divider { align-self: center; margin: 10px 0 2px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .ring.xl, #home-orb.calling, .home-waiting .dot { animation: none; } }
@media (max-height: 700px) { .orbit { width: min(300px, 100%); } .ring.xl { --w: 10px; width: 110px; height: 110px; } .home-hello { font-size: 21px; } }

/* HUD look: frames with corner brackets, monospace labels and gauges, in the theme's colour */
.gauges { display: flex; justify-content: space-around; gap: 8px; padding: 2px 16px 12px; }
.gauges:empty { display: none; }
.gauge { position: relative; display: grid; justify-items: center; gap: 4px; background: none; padding: 0; color: var(--fg); }
.gauge svg { width: 58px; height: 58px; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 3.5; }
.gauge .track { stroke: var(--line); }
.gauge .fill { stroke: var(--opal-bright); stroke-linecap: round; transition: stroke-dasharray 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.gauge.warn .fill { stroke: #f2a65a; }
.gauge strong { position: absolute; top: 29px; transform: translateY(-50%); font: 600 13px/1 ui-monospace, "SF Mono", Menlo, monospace; }
.gauge small, #chats .group { font: 600 10px/1.3 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.16em; text-transform: uppercase; color: var(--opal-bright); }
#chats .group { padding: 16px 6px 8px; opacity: 0.85; }
#chats .row { border-radius: 14px; margin-bottom: 8px; }
#chats .item { border: 1px solid var(--line); border-radius: 14px; background: var(--raised); padding: 11px 14px; }
#chats .when { font-size: 12px; color: var(--muted); }
#banners .banner { position: relative; border-radius: 14px; border: 1px solid var(--line); background: var(--raised); }
#banners.stack .banner { position: absolute; }
.search { border-radius: 4px; border: 1px solid var(--line); }

/* Answers as cards: tables, to-do lists and the weather */
.answer-table { overflow-x: auto; margin: 6px 0; border: 1px solid var(--line); border-radius: 12px; white-space: normal; }
.answer-table table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
.answer-table th, .answer-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.answer-table th { font: 600 10px/1.4 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.12em; text-transform: uppercase; color: var(--opal-bright); background: var(--field); }
.answer-table tr:last-child td { border-bottom: 0; }
.tick { display: flex; align-items: flex-start; gap: 10px; padding: 7px 10px; margin: 2px 0; border-radius: 10px; background: var(--field); cursor: pointer; white-space: normal; }
.tick input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--opal); }
.tick input:checked + span { text-decoration: line-through; color: var(--muted); }
.weather-card { display: grid; gap: 12px; padding: 14px; border-radius: 16px; background: linear-gradient(160deg, color-mix(in srgb, var(--opal) 16%, var(--raised)), var(--raised)); border: 1px solid var(--line); white-space: normal; }
.wx-now { display: flex; align-items: center; gap: 12px; }
.wx-now .wx-icon { font-size: 34px; line-height: 1; }
.wx-now strong { font-size: 36px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.wx-now div { display: grid; gap: 2px; }
.wx-now small { color: var(--muted); font-size: 13px; }
.wx-days { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.wx-days div { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border-radius: 12px; background: rgba(0, 0, 0, 0.18); font-size: 13px; }
.wx-days small { font-size: 11px; }
.wx-days b { font-variant-numeric: tabular-nums; }

/* Life overview: tiles with tiny charts */
.dash-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dash-tile { display: grid; gap: 4px; align-content: start; text-align: left; padding: 12px; border-radius: 16px; background: var(--field); border: 1px solid var(--line); color: var(--fg); min-width: 0; }
.dash-tile:active { background: var(--raised); }
.dash-tile .hud-label { font-size: 9px; }
.dash-tile strong { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dash-tile small { font-size: 12px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-bars { display: flex; gap: 3px; align-items: flex-end; height: 36px; }
.dash-bars span { flex: 1; border-radius: 2px; background: var(--opal-deep); }
.dash-bars span.today { background: var(--opal-bright); box-shadow: 0 0 6px var(--opal); }
.dash-spark { width: 100%; height: 36px; overflow: visible; }
.dash-spark .area { fill: var(--opal-deep); opacity: 0.45; }
.dash-spark .line { fill: none; stroke: var(--opal-bright); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.dash-spark .limit { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.dash-journal { display: grid; gap: 6px; text-align: left; width: 100%; color: var(--fg); margin-top: 10px; }
.dash-journal p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 14px; }

/* Ambient mode */
#desk { background: #000; gap: 22px; padding: 24px; cursor: pointer; transition: opacity 1.5s ease; }
#desk .hud-label { opacity: 0.8; }
.desk-clock { font-size: min(26vw, 140px); font-weight: 200; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
#desk-orb { padding: 0; border: 0; background: none; cursor: pointer; animation: home-breathe 6s ease-in-out infinite; transition: translate 4s ease; }
.desk-line { margin: 0; color: var(--muted); font-size: 16px; text-align: center; }
.desk-hint { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 18px); margin: 0; font-size: 12px; color: #4a4552; }
#desk.night { filter: brightness(0.45) sepia(0.35); }
@media (orientation: landscape) and (max-height: 500px) { #desk { flex-direction: row; flex-wrap: wrap; justify-content: center; align-content: center; gap: 12px 40px; } }
@media (prefers-reduced-motion: reduce) { #desk-orb { animation: none; transition: none; } }

/* ---------- Start-up: systems check, then ignition ---------- */
#startup { position: fixed; inset: 0; z-index: 60; background: #000; overflow: hidden; }
#startup svg { position: absolute; left: var(--cx); top: var(--cy); width: 260px; height: 260px; margin: -130px 0 0 -130px; overflow: visible; }
#startup circle { fill: none; stroke: var(--opal); transform-origin: 100px 100px; transform-box: view-box; opacity: 0; }
#startup .scan { stroke: var(--opal-bright); }
#startup .spark { position: absolute; left: var(--cx); top: var(--cy); width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 12px #fff, 0 0 30px var(--opal-bright); opacity: 0; }
#startup .orb { position: absolute; left: var(--cx); top: var(--cy); width: var(--d); height: var(--d); margin: calc(var(--d) / -2) 0 0 calc(var(--d) / -2); --w: 12px; opacity: 0; }
#startup .greet { position: absolute; left: 16px; right: 16px; top: var(--hy); margin: 0; text-align: center; font-size: 24px; font-weight: 600; color: var(--fg); min-height: 1.3em; }
#startup .lines { position: absolute; left: 22px; right: 22px; bottom: calc(96px + env(safe-area-inset-bottom)); display: grid; gap: 4px;
  font: 500 11px/1.4 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.08em; color: var(--opal-bright); }
#startup .lines div { display: flex; justify-content: space-between; gap: 12px; opacity: 0; }
#startup .lines span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#startup .lines b { color: #7fe3a8; font-weight: 600; white-space: nowrap; }
#startup .status { position: absolute; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom)); margin: 0; text-align: center;
  font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.24em; text-transform: uppercase; color: var(--opal-bright); }
#startup .flash { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at var(--cx) var(--cy), rgba(214, 180, 255, 0.95), rgba(157, 78, 221, 0.35) 30%, transparent 60%); }

/* ---------- 1.41 clean-up ---------- */
/* The chats screen is for chats: the greeting, gauges and habits live on home. */
#list #greeting, #list #gauges, #list #habit-strip { display: none !important; }
#list #banners:not(:empty) { margin-top: 4px; }
/* Notices from Opal sit below the header so they never cover a title. */
body:is([data-screen="chat"], [data-screen="list"], [data-screen="life"]) .speak-up { top: calc(env(safe-area-inset-top) + 58px); }
/* Fact-check and second opinion only on the latest answer. */
#messages .msg.opal:has(~ .msg) .actions { display: none; }

/* Home: a line from Opal and the rest of today */
.home-line { margin: -6px 0 0; max-width: 340px; text-align: center; font-size: 15px; line-height: 1.45; color: color-mix(in srgb, var(--fg) 80%, var(--muted)); text-wrap: balance; }
.home-line:empty { display: none; }
.home-today { width: 100%; max-width: 420px; }
.home-today .hud-label { font-size: 12px; margin: 0 0 4px 2px; }
.home-today ol { list-style: none; margin: 0; padding: 0; display: grid; }
.home-today li { display: grid; grid-template-columns: 64px 12px 1fr; gap: 10px; align-items: center; padding: 6px 0; font-size: 14px; }
.home-today time { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.home-today i { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--opal-bright); justify-self: center; }
.home-today li.now { color: var(--fg); } .home-today li.now i { background: var(--opal-bright); }
.home-today span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-height: 760px) { .home-today li:nth-child(n+3) { display: none; } }
@media (max-height: 680px) { .home-today { display: none; } }

/* Rehearsal: a slim bar while Opal is in character */
.rehearsal-bar { display: flex; align-items: center; gap: 10px; margin: 6px 12px 0; padding: 8px 12px; border-radius: 12px; background: var(--raised); border: 1px solid var(--line); font-size: 13px; }
.rehearsal-bar[hidden] { display: none; }
.rehearsal-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: #e5484d; flex: none; animation: pulse 1.6s ease-in-out infinite; }
.rehearsal-bar .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.rehearsal-bar button { color: var(--opal-bright); font-weight: 600; font-size: 13px; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .rehearsal-bar .dot { animation: none; } }

/* Before you go */
.prep-sheet { position: fixed; inset: 0; z-index: 58; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; justify-content: center;
  padding: 12px 12px calc(env(safe-area-inset-bottom) + 12px); }
.prep-card { width: 100%; max-width: 440px; max-height: 80vh; overflow: auto; box-sizing: border-box; padding: 18px 18px 14px; border-radius: 22px; background: var(--raised); border: 1px solid var(--line); }
.prep-card h2 { margin: 4px 0 2px; font-size: 22px; }
.prep-when { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.prep-card dl { margin: 0; display: grid; grid-template-columns: 76px 1fr; gap: 10px 12px; font-size: 14px; line-height: 1.4; }
.prep-card dt { color: var(--muted); font-size: 13px; }
.prep-card dd { margin: 0; overflow-wrap: anywhere; }
.prep-card dd.link { color: var(--opal-bright); cursor: pointer; }
.prep-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }

/* Opal's log and learning out loud */
.journal-pick { padding: 0 0 4px; }
.log-entry p { font-style: italic; color: color-mix(in srgb, var(--fg) 85%, var(--muted)); }
.lesson-head { margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.lesson { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.4; }
.lesson span { flex: 1; }
.lesson .keep { color: var(--opal-bright); font-weight: 600; font-size: 13px; }
.lesson .veto { color: var(--muted); font-size: 14px; padding: 0 2px; }
.lesson small { color: var(--muted); font-size: 12px; }
.lesson.vetoed span { color: var(--muted); text-decoration: line-through; }
.prep-card .small { font-size: 12px; }

/* Light mode (Settings › Appearance). Black stays the default; this keeps Opal's colours on a soft white. */
:root[data-mode="light"] {
  --bg: #f6f4fa; --fg: #1a1622; --muted: #6e6878; --line: #e2dde9; --field: #fff; --raised: #fff;
  --opal-bright: var(--opal); --tint: color-mix(in srgb, var(--opal) 16%, #fff); --aurora: 0.12;
  color-scheme: light;
}
:root[data-mode="light"] .wordmark .word { background: linear-gradient(180deg, #2a2433 0%, #4a4352 55%, #7a7385 100%); -webkit-background-clip: text; background-clip: text; }
:root[data-mode="light"] .field { background: rgba(255, 255, 255, 0.85); border-color: var(--line); box-shadow: 0 6px 24px rgba(40, 20, 70, 0.1); }
:root[data-mode="light"] .toggle input:not(:checked) { background: #d9d4e0; }
:root[data-mode="light"] .voice-type input { background: #fff; }
:root[data-mode="light"] .trail .step.live { background: linear-gradient(90deg, var(--muted) 30%, var(--fg) 50%, var(--muted) 70%); background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; }
:root[data-mode="light"] .radial, :root[data-mode="light"] .prep-sheet { background: rgba(30, 20, 45, 0.3); }
:root[data-mode="light"] .radial-item small { text-shadow: 0 1px 6px #fff; }
:root[data-mode="light"] .orb-wheel { background: radial-gradient(circle at var(--cx) var(--cy), rgba(246, 244, 250, 0.6), rgba(246, 244, 250, 0.85) 60%); }
:root[data-mode="light"] .habit-rows .tick { border-color: rgba(0, 0, 0, 0.2); }
:root[data-mode="light"] .habit-rows .week i, :root[data-mode="light"] .stack-dots i { background: rgba(0, 0, 0, 0.12); }
:root[data-mode="light"] .habit-rings .seg { stroke: rgba(0, 0, 0, 0.1); }
:root[data-mode="light"] .habit-rings .week { stroke: rgba(0, 0, 0, 0.07); }
:root[data-mode="light"] .sat:active { background: rgba(0, 0, 0, 0.05); }
:root[data-mode="light"] .wx-days div { background: rgba(0, 0, 0, 0.04); }
:root[data-mode="light"] .desk-hint { color: #8e8799; }
:root[data-mode="light"] .file-chip { background: rgba(0, 0, 0, 0.04); }
:root[data-mode="light"] .jump, :root[data-mode="light"] .mini-player, :root[data-mode="light"] .speak-up, :root[data-mode="light"] .orb-glance {
  background: rgba(255, 255, 255, 0.9); border-color: var(--line); box-shadow: 0 8px 26px rgba(40, 20, 70, 0.14); }
:root[data-mode="light"] .msg.flash { animation-name: flash-light; }
@keyframes flash-light { 15% { background: rgba(0, 0, 0, 0.05); box-shadow: 0 0 0 6px rgba(0, 0, 0, 0.05); border-radius: 14px; } }
/* Words on Opal's colour stay white. */
:root[data-mode="light"] :is(.msg.user, .choices button, #diag-copy, .pill:not(.end, .finish, .open-translator), .brief-q, .chip.habit.on, .next-chips .chip:active, .tr-btn.them) { color: #fff; }
:root[data-mode="light"] .tr-btn.them svg { color: #fff; }

/* Vault: IMPERIAL's own code, read-only */
.vault-files { display: grid; gap: 10px; padding: 8px 16px 24px; overflow-y: auto; }
.vault-file { display: flex; gap: 12px; align-items: center; text-align: left; padding: 12px 14px; border-radius: 14px; background: var(--raised); border: 1px solid var(--line); }
.vault-file svg { color: var(--opal-bright); flex: none; }
.vault-file strong { display: block; font-size: 15px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.vault-file small { display: block; color: var(--muted); font-size: 13px; }
.vault-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.vault-find { display: flex; align-items: center; gap: 10px; padding: 4px 16px 8px; }
.vault-find small { flex: none; font-size: 12px; }
#vault-code { flex: 1; min-height: 0; overflow: auto; margin: 0 12px 12px; padding: 12px; border-radius: 14px; background: var(--field); border: 1px solid var(--line);
  font: 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; tab-size: 2; }
#vault-code mark { background: color-mix(in srgb, var(--opal) 35%, transparent); color: inherit; border-radius: 3px; }
#vault-code mark.here { background: var(--opal); color: #fff; }

/* The owner gate: what anyone but the owner sees */
#gate { position: fixed; inset: 0; z-index: 70; background: var(--bg, #000); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px; text-align: center; }
#gate[hidden] { display: none; }
#gate p { font-size: 18px; font-weight: 600; margin: 0; }
#gate small { min-height: 1.2em; font-size: 13px; }
