/* NARD 2.0 — one look: arc cyan #5fd4ff on near-black space (same palette as Nard's form, the HUD and Nekron).
   No gold, no second accent. js/settings.js re-applies these same tokens at boot.
   Layout follows the voice-assistant pattern (ChatGPT voice / Perplexity): the orb owns the centre,
   two round buttons up top, an input pill + mic + talk at the bottom. */
:root {
  --bg: #04060b; --ink: #eef3fa; --ink-2: #a9b5c7; --ink-3: #7b879b;
  /* arc cyan: the only accent. deep = pressed / tracks, hot = hover / highlights, on-accent = text on a lit cyan button */
  --accent: #5fd4ff; --accent-2: #0a3a55; --accent-hot: #d6f4ff; --on-accent: #021019;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 45%, transparent);
  --glow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent), 0 0 24px color-mix(in srgb, var(--accent) 18%, transparent);
  --danger: #ff8a9a; /* status only (errors), never decoration */
  --glass: rgba(12, 18, 30, 0.62); --line: rgba(170, 205, 255, 0.11); --code: #070b14;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); overflow: hidden;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled, button[aria-disabled=true] { cursor: default; }
::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); color: var(--ink); }
input, textarea { caret-color: var(--accent); }
.mono { font-family: var(--mono); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

#field { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none;
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body.holding #field { cursor: grabbing; }
/* The orb has its own layer, cleared every frame, so its dots stay crisp while the field keeps its trails. */
.orb-glow { position: fixed; left: 0; top: 0; width: 1000px; height: 1000px; margin: -500px 0 0 -500px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 16%, transparent), color-mix(in srgb, var(--accent) 5%, transparent) 45%, transparent 72%);
  will-change: transform, opacity; }
#orb-layer { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; pointer-events: none; }
/* Holographic orb (Phase 1): thought-back (2D) → holo-layer (WebGL) → orb-layer (2D). Empty and free until body.holo. */
#thought-back, #holo-layer { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; pointer-events: none; }
body:not(.holo) #thought-back, body:not(.holo) #holo-layer { display: none; }
body.holo .orb-glow { background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 12%, transparent), color-mix(in srgb, var(--accent) 4%, transparent) 45%, transparent 72%); }

.grain { position: fixed; inset: 0; pointer-events: none; opacity: .035; /* no blend mode: it would re-blend the animated canvas every frame */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.floor-glow { position: fixed; left: -10%; right: -10%; bottom: -34vh; height: 60vh; pointer-events: none;
  background: radial-gradient(50% 50% at 50% 50%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
  opacity: calc(.25 + var(--lvl, 0) * 1.4); transition: opacity .4s var(--ease); }

/* ---------- glass + round buttons ---------- */
.glass { background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px) saturate(1.1); backdrop-filter: blur(18px) saturate(1.1);
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 40px rgba(0,0,0,.35); }
.round { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); flex: none;
  transition: background .25s var(--ease), color .25s var(--ease), transform .2s var(--ease); }
.round:active { transform: scale(.94); }
@media (hover: hover) { .round.glass:hover { color: var(--accent-hot); border-color: var(--accent-line); } }
.round[aria-expanded=true] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.round.big { width: 54px; height: 54px; }
.round.big svg { width: 22px; height: 22px; }
/* The lit primary (Talk): cyan with dark ink, like Nekron's primary button. */
.round.solid { background: linear-gradient(180deg, #8ae2ff, var(--accent)); color: var(--on-accent);
  box-shadow: var(--glow), 0 10px 30px rgba(0,0,0,.4); }
@media (hover: hover) { .round.solid:hover { background: linear-gradient(180deg, var(--accent-hot), #8ae2ff); } }
.round.solid:active { background: var(--accent); }
.round.solid[aria-pressed=true] { background: var(--accent-2); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-line), var(--glow); }

/* ---------- top bar ---------- */
.top { position: fixed; z-index: 10; top: calc(14px + var(--st)); left: calc(16px + var(--sl)); right: calc(16px + var(--sr));
  display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.top > * { pointer-events: auto; }

/* Dynamic Island: a quiet capsule that blooms when Nard talks. The dot is the visible mic indicator. */
.island { position: absolute; left: 50%; top: 5px; transform: translateX(-50%); display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; width: 96px; padding: 0 14px; border-radius: 999px; background: #050505;
  box-shadow: 0 0 0 1px rgba(255,255,255,.05), 0 10px 30px rgba(0,0,0,.5);
  transition: width .55s var(--ease), height .55s var(--ease), border-radius .55s var(--ease), top .55s var(--ease); overflow: hidden; }
.island-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); flex: none; transition: background .3s, box-shadow .3s; }
body.mic-live .island-dot { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); animation: breathe 2.4s var(--ease) infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 6%, transparent); } }
.island-label { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); transition: opacity .3s; }
#island-viz { position: absolute; inset: 8px 22px 8px 34px; width: calc(100% - 56px); height: calc(100% - 16px); opacity: 0; transition: opacity .35s .1s; }
body[data-mode=talk] .island { width: min(300px, 58vw); height: 46px; top: 0; border-radius: 24px; }
body[data-mode=talk] .island-label { opacity: 0; }
body[data-mode=talk] #island-viz { opacity: 1; }

/* ---------- sheets ---------- */
.sheet { position: absolute; top: 58px; width: 290px; padding: 10px; border-radius: 22px; display: grid; gap: 6px;
  font-size: 12px; color: var(--ink-2); animation: pop .22s var(--ease); }
.sheet.left { left: 0; transform-origin: top left; } .sheet.right { right: 0; transform-origin: top right; padding: 16px; gap: 14px; }
.sheet[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
#modes button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; text-align: left; color: var(--ink-2); transition: background .2s var(--ease); }
@media (hover: hover) { #modes button:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); } }
#modes button:active { background: var(--accent-soft); }
#modes button svg { flex: none; }
#modes button b { display: block; font-weight: 500; font-size: 13px; color: var(--ink); }
#modes button small { display: block; font-size: 11px; color: var(--ink-3); }
#modes button[aria-pressed=true] { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
#modes button[aria-pressed=true] svg { stroke: var(--accent); }
#modes hr { border: 0; border-top: 1px solid var(--line); margin: 2px 6px; }

#settings .row { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: center; }
#settings .row input[type=range] { grid-column: 1 / -1; }
#settings output { color: var(--ink); font-size: 11px; }
#settings .lbl { grid-column: 1 / -1; }
.surface summary { cursor: pointer; list-style: none; color: var(--ink-2); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.surface summary::-webkit-details-marker { display: none; }
.surface summary::after { content: ' +'; color: var(--ink-3); }
.surface[open] summary::after { content: ' −'; }
.surface[open] { display: grid; gap: 12px; }
.ghost { justify-self: start; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); font-size: 12px; transition: color .2s, border-color .2s, background .2s; }
.ghost:hover { color: var(--accent-hot); border-color: var(--accent-line); }
.ghost:active { background: var(--accent-soft); }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; touch-action: pan-x; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 22%, transparent); }
input[type=range]::-moz-range-track { height: 2px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 22%, transparent); }
input[type=range]::-moz-range-progress { height: 2px; border-radius: 2px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--accent); }
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

/* ---------- caption under the orb (Perplexity's "Say something…") ---------- */
.caption { position: fixed; z-index: 5; left: 50%; top: calc(45% + 22vmin + 34px); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none; text-align: center; white-space: nowrap; }
#caption-main { font-size: 15px; color: var(--ink-2); letter-spacing: .01em; }
#caption-sub { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
body.mic-live #caption-sub { color: color-mix(in srgb, var(--accent) 70%, var(--ink-3)); }
body.holding .caption, body.lifted .caption { opacity: 0; }
.caption { transition: opacity .3s var(--ease); }

/* ---------- camera ---------- */
.cam { position: fixed; z-index: 9; top: calc(74px + var(--st)); right: calc(16px + var(--sr)); width: 132px; aspect-ratio: 3/4;
  border-radius: 18px; overflow: hidden; display: none; padding: 0; }
body.cam-live .cam { display: block; animation: pop .3s var(--ease); }
.cam video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1);
  /* Design lock: a live feed can contain any colour, so it is toned to mono (one look, no warm tint). */
  filter: grayscale(1) contrast(1.06) brightness(.92); }
.cam figcaption { position: absolute; left: 9px; bottom: 7px; font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink);
  display: inline-flex; align-items: center; gap: 5px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.rec { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: breathe 1.6s infinite; }

/* ---------- chat + dock ---------- */
.chat { position: fixed; z-index: 8; left: 50%; bottom: calc(18px + var(--sb)); transform: translateX(-50%);
  width: min(720px, calc(100vw - 32px - var(--sl) - var(--sr))); display: flex; flex-direction: column; gap: 12px; pointer-events: none; }
body.chat-hidden .log { display: none; }
.log { max-height: 24vh; max-height: 24dvh; overflow-y: auto; padding: 18px 2px 2px; display: flex; flex-direction: column; gap: 12px;
  pointer-events: auto; scrollbar-width: none; overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px); mask-image: linear-gradient(to bottom, transparent, #000 28px); }
.log:empty { display: none; }
.log::-webkit-scrollbar { display: none; }
.msg { display: flex; flex-direction: column; gap: 8px; max-width: 100%; animation: rise .35s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg.user { align-items: flex-end; }
.msg.user .bubble { background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid var(--line); padding: 8px 13px; border-radius: 18px 18px 6px 18px; max-width: 82%; }
.msg.nard .bubble { color: var(--ink); max-width: 92%; text-shadow: 0 1px 12px var(--bg); white-space: pre-wrap; }

/* Grok-style status lines */
.think { font: 12px var(--mono); color: var(--ink-2); }
.think summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.think summary::-webkit-details-marker { display: none; }
.think .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: think 1.1s ease-in-out infinite; }
.think.done .pulse { animation: none; background: var(--ink-3); }
.think.done summary::after { content: '›'; color: var(--ink-3); transition: transform .2s; }
.think[open].done summary::after { transform: rotate(90deg); }
.think-sep { color: var(--ink-3); }
.think-secs { color: var(--ink); font-variant-numeric: tabular-nums; }
.think-steps { margin: 8px 0 0 3px; padding-left: 14px; border-left: 1px solid var(--line); list-style: none; display: grid; gap: 4px; color: var(--ink-3); }
.think.done:not([open]) .think-steps { display: none; }
@keyframes think { 50% { opacity: .35; transform: scale(.75); } }
.writing { display: inline-flex; align-items: center; gap: 8px; font: 12px var(--mono); color: var(--ink-2); position: relative; padding-bottom: 4px; }
.writing-name { color: var(--ink); }
.file-ico { width: 11px; height: 13px; border: 1.3px solid var(--ink-2); border-radius: 2px 5px 2px 2px; }
.writing::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: scan 1.2s linear infinite; }
.writing.done::after { animation: none; background: var(--line); }
@keyframes scan { from { background-position: -60% 0; } to { background-position: 160% 0; } }
.code { background: var(--code); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.code-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--line); font: 11px var(--mono); color: var(--ink-2); }
.code-lang { color: var(--ink-3); margin-right: auto; }
.code-copy { padding: 3px 9px; border-radius: 8px; border: 1px solid var(--line); font: 11px var(--mono); color: var(--ink-2); }
.code-copy:hover { color: var(--accent-hot); border-color: var(--accent-line); }
.code pre { margin: 0; padding: 12px 14px 14px; overflow-x: auto; font: 12px/1.6 var(--mono); color: var(--ink); tab-size: 2; }
.tk-k { color: var(--accent); } .tk-s { color: color-mix(in srgb, var(--ink) 72%, var(--accent)); } .tk-n { color: var(--ink-2); } .tk-c { color: var(--ink-3); font-style: italic; }

.dock { display: flex; align-items: center; gap: 10px; pointer-events: auto; }
.composer { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; height: 54px; padding: 6px; border-radius: 999px; }
.composer input { flex: 1; min-width: 0; height: 100%; background: transparent; border: 0; outline: none; color: var(--ink); font: 16px var(--sans); padding: 0 4px; }
.composer input::placeholder { color: var(--ink-3); }
.composer { transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.composer:focus-within { border-color: var(--accent-line); box-shadow: var(--glow), 0 12px 40px rgba(0,0,0,.35); }
.icon { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); transition: background .2s, color .2s, opacity .2s, transform .3s var(--ease); }
@media (hover: hover) { .icon:hover { color: var(--accent-hot); } }
.icon:active { background: var(--accent-soft); }
#cam-btn[aria-pressed=true] { color: var(--accent); transform: rotate(45deg); }
.send { opacity: 0; pointer-events: none; background: var(--accent); color: var(--on-accent); width: 36px; height: 36px; box-shadow: var(--glow); }
.composer:focus-within .send, .composer:has(input:not(:placeholder-shown)) .send { opacity: 1; pointer-events: auto; }
@media (hover: hover) { .send:hover { background: var(--accent-hot); color: var(--on-accent); } }
.send:active { transform: scale(.92); }
body.busy .send { opacity: .5; }
#mic-btn .mic-on { display: none; }
#mic-btn[aria-pressed=true] { color: var(--accent); border-color: var(--accent-line); box-shadow: var(--glow); }
#mic-btn[aria-pressed=true] .mic-on { display: block; } #mic-btn[aria-pressed=true] .mic-off { display: none; }
#talk-btn .talk-off { display: none; }
#talk-btn[aria-pressed=true] .talk-on { display: none; } #talk-btn[aria-pressed=true] .talk-off { display: block; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .caption { top: calc(44% + 27vmin + 26px); }
  .log { max-height: 20vh; max-height: 20dvh; }
  .sheet { width: min(300px, calc(100vw - 32px)); }
  .cam { width: 100px; }
  .round.big { width: 50px; height: 50px; }
  .composer { height: 50px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
