/* ───────────────────────── Ask D2 — night-sea bioluminescence ───────────────────────── */
:root {
  --bg: #02040A;
  --bg-2: #060B18;
  --surface: #08111F;
  --surface-2: #0B1830;
  --border: rgba(80, 190, 255, 0.14);
  --border-strong: rgba(60, 210, 255, 0.38);
  --text: #F9FAFB;
  --text-dim: #A7B2C6;
  --text-faint: #6B7690;

  /* bioluminescence, sampled from the reference photos */
  --bio-deep: #0A5BFF;
  --bio: #12B8FF;
  --bio-bright: #22E4FF;
  --bio-foam: #8AF6FF;
  --bio-glow: rgba(34, 200, 255, 0.45);
  /* the only two accents besides the blues: nebula (attention, Angel, "not done") and one red, only for
     destroying, hanging up and recording. No green, no yellow, no orange anywhere. */
  --nebula: #A5B4FC;
  --nebula-soft: rgba(129, 140, 248, .35);
  --danger: #FF7A93;
  --danger-soft: rgba(255, 122, 147, .14);

  --radius: 18px;
  --maxw: 780px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
::selection { background: rgba(34, 228, 255, 0.28); }

/* ── ambient sea ── */
.sea { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.stars {
  position: absolute; inset: 0 0 40% 0; opacity: .55;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 27% 8%, #cfe8ff 50%, transparent 51%),
    radial-gradient(1px 1px at 41% 26%, #fff 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 58% 12%, #e6f6ff 50%, transparent 51%),
    radial-gradient(1px 1px at 73% 30%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 86% 9%, #cfe8ff 50%, transparent 51%),
    radial-gradient(1px 1px at 93% 22%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 36%, #e6f6ff 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 42%, #fff 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 66% 44%, #fff 50%, transparent 51%);
  mask-image: linear-gradient(#000 40%, transparent);
  animation: twinkle 7s ease-in-out infinite alternate;
}
.glow {
  position: absolute; left: 50%; bottom: -34vh; width: 150vw; height: 52vh;
  translate: -50% 0; border-radius: 50%; filter: blur(60px);
}
.glow-a {
  background: radial-gradient(closest-side, rgba(18, 184, 255, .22), rgba(10, 91, 255, .08) 60%, transparent);
  animation: tide 14s ease-in-out infinite alternate;
}
.glow-b {
  width: 90vw; height: 30vh; bottom: -16vh;
  background: radial-gradient(closest-side, rgba(34, 228, 255, .16), transparent 70%);
  animation: tide 9s ease-in-out -4s infinite alternate-reverse;
}
@keyframes tide {
  from { transform: translateX(-6%) scaleY(.9); opacity: .75; }
  to   { transform: translateX(6%) scaleY(1.1); opacity: 1; }
}
@keyframes twinkle { from { opacity: .35; } to { opacity: .65; } }

/* ── layout ── */
.layout { position: relative; z-index: 1; display: flex; height: 100dvh; }
.app {
  position: relative; flex: 1; min-width: 0;
  height: 100dvh; display: grid; grid-template-rows: auto 1fr auto;
}

/* ── sidebar (conversations) ── */
.sidebar {
  width: 272px; flex: none; display: flex; flex-direction: column; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 14px) 12px 14px;
  background: rgba(8, 11, 20, .82); border-right: 1px solid var(--border); backdrop-filter: blur(14px);
}
.sidebar[hidden] { display: none; }
.side-head { display: grid; gap: 8px; }
.side-new {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 12px; font-size: .9rem;
  background: rgba(0, 229, 255, .06); border: 1px solid var(--border); color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.side-new:hover { border-color: var(--border-strong); box-shadow: 0 0 18px rgba(0, 229, 255, .12); }
.side-new.shared { background: rgba(56, 189, 248, .05); color: var(--text-dim); }
.side-new svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; flex: none; }
.conv-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.conv-list h4 { margin: 14px 8px 6px; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
.conv-list .empty { margin: 4px 8px; font-size: .84rem; color: var(--text-faint); }
.conv { display: flex; align-items: center; border-radius: 10px; }
.conv:hover, .conv.active { background: rgba(0, 229, 255, .07); }
.conv.active { box-shadow: inset 2px 0 0 #00E5FF; }
.conv-open {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 9px 10px;
  color: var(--text-dim); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv.active .conv-open, .conv:hover .conv-open { color: var(--text); }
.conv-del { background: none; border: 0; color: var(--text-faint); font-size: 1.1rem; padding: 4px 10px; opacity: 0; }
.conv:hover .conv-del, .conv.active .conv-del { opacity: 1; }
.conv-del:hover { color: var(--danger); }
@media (hover: none) { .conv-del { opacity: .6; } }
.side-user { font-size: .8rem; color: var(--text-faint); padding: 6px 8px 0; border-top: 1px solid var(--border); }
.side-user strong { color: #BDF4FF; font-weight: 600; }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(3, 5, 10, .6); }
.scrim[hidden] { display: none; }
.top-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conv-title {
  max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  align-self: center; font-size: .86rem; color: var(--text-faint);
}
.menu-btn[hidden] { display: none; }
/* wide screens: the same button folds the sidebar away and brings it back */
@media (min-width: 900px) {
  .sidebar { transition: margin-left .28s ease, opacity .22s ease; }
  body.side-hidden .sidebar { margin-left: -272px; opacity: 0; pointer-events: none; visibility: hidden; transition: margin-left .28s ease, opacity .22s ease, visibility 0s .28s; }
}
@media (min-width: 900px) and (prefers-reduced-motion: reduce) { .sidebar, body.side-hidden .sidebar { transition: none; } }
@media (max-width: 899px) {
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(84vw, 300px); transform: translateX(-102%); transition: transform .25s ease; }
  .sidebar.open { transform: none; }
  .conv-title { display: none; }
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 20px 14px;
  background: linear-gradient(var(--bg) 40%, transparent);
}

/* ── brand: logo + "Ask" white + living "D2" ── */
.brand { text-decoration: none; display: inline-flex; align-items: center; gap: 8px; user-select: none; }
.brand-logo { display: inline-flex; width: 34px; height: 34px; }
.brand-text { display: inline-flex; align-items: baseline; gap: 2px; }
.brand-ask { color: #F9FAFB; font-weight: 650; font-size: 1.45rem; letter-spacing: -.02em; }
.brand-d2, .d2-inline {
  font-weight: 800; letter-spacing: -.01em;
  background: linear-gradient(100deg, #00E5FF 0%, #38BDF8 22%, #0284C7 45%, #38BDF8 68%, #00E5FF 90%, #38BDF8 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: biolum 7s ease-in-out infinite, pulse 4.5s ease-in-out infinite;
}
.brand-d2 { font-size: 1.45rem; }
@keyframes biolum {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes pulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(0, 229, 255, .35)) drop-shadow(0 0 12px rgba(2, 132, 199, .25)); }
  50%      { filter: drop-shadow(0 0 7px rgba(0, 229, 255, .7)) drop-shadow(0 0 22px rgba(56, 189, 248, .4)); }
}

/* ── D2 mark: four pieces of a disc (public/js/logo.js) ── */
.d2-logo { position: relative; display: block; width: 100%; height: 100%; }
.d2-logo .d2-mark { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 0 6px rgba(34, 228, 255, .28)); }
.d2-logo .d2-elite { display: none; width: 100%; height: 100%; object-fit: contain; user-select: none; }
.d2-logo .spin { transform-origin: 623.5px 601.5px; }
.d2-logo { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.d2-logo .d2-mark, .d2-logo .d2-elite { transform-origin: 50% 50%; }
.d2-logo .d2-glass { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; transform-origin: 50% 50%; }
.busy .d2-logo, .generating .brand-logo .d2-logo { cursor: default; }
/* thinking / planning: the pieces breathe out and in, then the disc does one full turn (a tyre) and settles */
.busy .d2-logo .spin, .generating .brand-logo .spin, .d2-logo.think .spin { animation: d2turn 2.8s infinite; }
.busy .d2-logo .pc, .generating .brand-logo .pc, .d2-logo.think .pc { animation: d2breathe 2.8s infinite; }
.busy .d2-logo .d2-mark, .generating .brand-logo .d2-mark { filter: drop-shadow(0 0 9px rgba(34, 228, 255, .55)); }
@keyframes d2breathe {
  0%   { transform: translate(0, 0); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  14%  { transform: translate(calc(var(--dx) * 74px), calc(var(--dy) * 74px)); animation-timing-function: cubic-bezier(.5, 0, .3, 1); }
  27%  { transform: translate(0, 0); animation-timing-function: cubic-bezier(.3, 0, .2, 1); }
  35%  { transform: translate(calc(var(--dx) * 40px), calc(var(--dy) * 40px)); animation-timing-function: cubic-bezier(.5, 0, .3, 1); }
  44%  { transform: translate(0, 0); animation-timing-function: cubic-bezier(.4, 0, .6, 1); }
  66%  { transform: translate(calc(var(--dx) * 26px), calc(var(--dy) * 26px)); animation-timing-function: cubic-bezier(.4, 0, .2, 1); }
  92%, 100% { transform: translate(0, 0); }
}
@keyframes d2turn {
  0%, 44% { transform: rotate(0deg); animation-timing-function: cubic-bezier(.62, -0.18, .24, 1.16); }
  96%, 100% { transform: rotate(360deg); }
}
.welcome-logo { width: 84px; height: 84px; margin: 0 auto 18px; }
.thinking-label {
  display: inline-block; padding: 8px 0; font-size: .92rem; letter-spacing: .01em;
  background: linear-gradient(90deg, var(--bio-deep) 0%, var(--bio-foam) 45%, var(--bio-bright) 55%, var(--bio-deep) 100%);
  background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.8s linear infinite;
}
@keyframes shimmer { from { background-position: 110% 0; } to { background-position: -110% 0; } }
@media (prefers-reduced-motion: reduce) { .d2-logo .spin, .d2-logo .pc, .d2-logo .d2-elite, .thinking-label { animation: none !important; } }
.mode-badge {
  align-self: center; font-size: .72rem; padding: 3px 9px; border-radius: 999px;
  color: #BDF4FF; border: 1px solid var(--border-strong); background: rgba(0, 229, 255, .08);
}

.top-actions { display: flex; gap: 8px; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 999px;
  background: rgba(14, 20, 34, .7); border: 1px solid var(--border);
  color: var(--text-dim); font-size: .88rem; backdrop-filter: blur(8px);
  transition: border-color .2s, color .2s, box-shadow .2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); box-shadow: 0 0 18px rgba(18, 184, 255, .15); }
.icon-btn svg, .send-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── thread ── */
.scroller { overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.scroller::-webkit-scrollbar { width: 8px; }
.scroller::-webkit-scrollbar-thumb { background: rgba(80, 190, 255, .15); border-radius: 8px; }
.thread { max-width: var(--maxw); margin: 0 auto; padding: 8px 20px 28px; }

.welcome { text-align: center; padding: 12vh 0 24px; animation: rise .6s ease both; }
.welcome h1 { font-size: clamp(1.8rem, 5vw, 2.5rem); font-weight: 650; letter-spacing: -.03em; margin: 0 0 6px; }
.welcome p { color: var(--text-dim); margin: 0 0 32px; }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.chip {
  padding: 14px 16px; border-radius: 14px; font-size: .92rem; line-height: 1.4;
  background: rgba(14, 20, 34, .6); border: 1px solid var(--border); color: var(--text-dim);
  transition: border-color .2s, color .2s, transform .2s, box-shadow .2s;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); box-shadow: 0 6px 24px rgba(18, 184, 255, .1); }

.msg { margin: 22px 0; animation: rise .35s ease both; }
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  max-width: 85%; padding: 11px 16px; border-radius: 20px 20px 6px 20px;
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-ai { display: grid; grid-template-columns: 30px 1fr; gap: 14px; }
.avatar { width: 30px; height: 30px; margin-top: 1px; }
.content { min-width: 0; overflow-wrap: anywhere; }
.msg-tools { display: flex; gap: 6px; margin-top: 6px; opacity: 0; transition: opacity .2s; }
.msg-ai:hover .msg-tools, .msg-tools:focus-within { opacity: 1; }
@media (hover: none) { .msg-tools { opacity: 1; } }
.tool-btn {
  background: none; border: 1px solid transparent; border-radius: 8px; padding: 3px 9px;
  font-size: .78rem; color: var(--text-faint);
}
.tool-btn:hover { color: var(--bio-bright); border-color: var(--border); }
.tool-btn[hidden] { display: none; }
.source { align-self: center; font-size: .74rem; color: var(--text-faint); margin-left: 4px; }
.error { color: var(--danger); }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* typing indicator */

/* ── markdown ── */
.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }
.content p { margin: 0 0 .85em; }
.content h2, .content h3, .content h4, .content h5, .content h6 { margin: 1.3em 0 .5em; line-height: 1.3; letter-spacing: -.01em; }
.content h2 { font-size: 1.3rem; } .content h3 { font-size: 1.13rem; } .content h4, .content h5, .content h6 { font-size: 1rem; }
.content ul, .content ol { margin: 0 0 .85em; padding-left: 1.4em; }
.content li { margin: .25em 0; }
.content li::marker { color: var(--bio); }
.content strong { color: #fff; font-weight: 650; }
.content a { color: var(--bio-bright); text-decoration: none; border-bottom: 1px solid rgba(34, 228, 255, .35); }
.content a:hover { border-bottom-color: var(--bio-bright); }
.content hr { border: 0; height: 1px; margin: 1.4em 0; background: linear-gradient(90deg, transparent, var(--border-strong), transparent); }
.content blockquote { margin: 0 0 .85em; padding: 2px 0 2px 14px; border-left: 3px solid var(--bio); color: var(--text-dim); }
.content :not(pre) > code {
  font: .88em var(--mono); padding: .15em .4em; border-radius: 6px;
  background: rgba(18, 184, 255, .1); border: 1px solid rgba(18, 184, 255, .16); color: #BDF4FF;
}
.code { margin: 0 0 1em; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #070B14; }
.code-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px 6px 14px; font: .76rem var(--mono); color: var(--text-faint);
  background: rgba(18, 184, 255, .05); border-bottom: 1px solid var(--border);
}
.copy-code {
  background: none; border: 1px solid var(--border); border-radius: 7px; padding: 3px 10px;
  font-size: .76rem; color: var(--text-dim); transition: all .2s;
}
.copy-code:hover, .copy-code.ok { color: var(--bio-bright); border-color: var(--border-strong); }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code code { font: .86rem/1.6 var(--mono); color: #E3EEFF; white-space: pre; }
.table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--border); border-radius: 12px; }
.content table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.content th, .content td { padding: 9px 13px; border-bottom: 1px solid var(--border); text-align: left; }
.content th { background: rgba(18, 184, 255, .06); font-weight: 600; }
.content tr:last-child td { border-bottom: 0; }
.content th[align="center"], .content td[align="center"] { text-align: center; }
.content th[align="right"], .content td[align="right"] { text-align: right; }
.content .katex { font-size: 1.06em; }
.content .katex-display { margin: .4em 0 1em; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.content .math-pending { color: var(--text-dim); }

/* highlight.js — night-sea theme */
.hljs-comment, .hljs-quote { color: #5B6B86; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type, .hljs-built_in { color: #38BDF8; }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute, .hljs-template-tag { color: var(--bio-foam); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: var(--nebula); }
.hljs-title, .hljs-title.function_, .hljs-section, .hljs-name { color: #00E5FF; }
.hljs-attr, .hljs-variable, .hljs-template-variable, .hljs-params, .hljs-property { color: #C4D6FF; }
.hljs-meta, .hljs-doctag, .hljs-subst { color: #8AA4D6; }
.hljs-deletion { color: var(--danger); }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }

/* ── composer ── */
.composer-wrap {
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
  background: linear-gradient(transparent, var(--bg) 35%);
}
.composer {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px; border-radius: 26px;
  background: rgba(14, 20, 34, .82); backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
  transition: border-color .25s, box-shadow .25s;
}
.composer:focus-within {
  border-color: var(--border-strong);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35), 0 0 0 4px rgba(18, 184, 255, .08), 0 0 34px rgba(18, 184, 255, .14);
}
.composer textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--text);
  font: 16px/1.5 var(--font); padding: 8px 0; max-height: 200px; min-height: 24px;
}
.composer textarea::placeholder { color: var(--text-faint); }
.send-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0;
  display: grid; place-items: center; color: #03111d;
  background: radial-gradient(circle at 35% 30%, var(--bio-foam), var(--bio-bright) 40%, var(--bio) 75%, var(--bio-deep));
  box-shadow: 0 0 18px rgba(18, 184, 255, .45);
  transition: transform .15s, box-shadow .2s, opacity .2s;
}
.send-btn svg { width: 19px; height: 19px; stroke-width: 2.4; }
.send-btn:hover:not(:disabled) { transform: scale(1.06); box-shadow: 0 0 28px rgba(34, 228, 255, .7); }
.send-btn:disabled { opacity: .3; box-shadow: none; cursor: default; }
.send-btn .i-stop { display: none; fill: currentColor; stroke: none; }
.busy .send-btn .i-send { display: none; }
.busy .send-btn .i-stop { display: block; }
.hint { text-align: center; color: var(--text-faint); font-size: .74rem; margin: 8px 0 0; min-height: 1.1em; }
.hint.show { color: #BDF4FF; display: block !important; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer.drop { border-color: #00E5FF; box-shadow: 0 0 0 4px rgba(0, 229, 255, .15); }
.tool-round {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: transparent; color: var(--text-dim); transition: color .2s, background .2s;
}
.tool-round:hover { color: #00E5FF; background: rgba(0, 229, 255, .08); }
.tool-round[hidden] { display: none; }
.tool-round svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#micBtn.recording { color: #03111d; background: var(--danger); animation: rec 1.2s ease-in-out infinite; }
#micBtn.working { color: #00E5FF; animation: rec 0.8s ease-in-out infinite; }
@keyframes rec { 50% { box-shadow: 0 0 0 8px var(--danger-soft); } }
.attachments { display: flex; gap: 8px; padding: 4px 6px 0; flex-wrap: wrap; }
.attachments[hidden] { display: none; }
.att { position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border-strong); }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att button {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: rgba(5, 7, 13, .8); color: #fff; font-size: .8rem; line-height: 1; display: grid; place-items: center;
}

/* user messages: author (shared space) + images */
.user-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 85%; }
.user-wrap .bubble { max-width: 100%; }
.author { font-size: .74rem; color: #7DD3FC; padding-right: 6px; }
.msg-images { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msg-images img { max-width: 220px; max-height: 220px; border-radius: 14px; border: 1px solid var(--border); object-fit: cover; }
.img-note { font-size: .8rem; color: var(--text-faint); }

/* assistant extras */
.status { font-size: .8rem; color: #7DD3FC; min-height: 0; }
.status:empty { display: none; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sources:empty { display: none; }
.src {
  font-size: .76rem; padding: 4px 10px; border-radius: 999px; text-decoration: none; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #BDF4FF; background: rgba(0, 229, 255, .07); border: 1px solid var(--border);
}
.src:hover { border-color: var(--border-strong); }
.facts { margin-top: 8px; font-size: .8rem; color: var(--bio-foam); }

/* memory list in settings */
.setting.column { flex-direction: column; align-items: stretch; }
.setting[hidden], .msg-tools[hidden] { display: none; }
.memory-form { display: flex; gap: 8px; }
.memory-form input { margin: 0 !important; padding: 9px 12px !important; font-size: .9rem !important; }
.memory-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; display: grid; gap: 6px; }
.memory-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 10px; font-size: .86rem; background: var(--bg-2); border: 1px solid var(--border);
}
.memory-list li.empty { color: var(--text-faint); justify-content: center; }
.memory-list button { background: none; border: 0; color: var(--text-faint); font-size: 1.05rem; }
.memory-list button:hover { color: var(--danger); }
.sheet { max-height: 88dvh; overflow-y: auto; }
.segmented { flex-wrap: wrap; }

/* ── dialogs (login + settings) ── */
.sheet {
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 24px; width: min(92vw, 420px);
  background: var(--surface); color: var(--text); box-shadow: 0 0 60px rgba(18, 184, 255, .2);
}
.ask { max-width: 420px; }
.ask p { color: var(--text); white-space: pre-line; }
.ask-input { width: 100%; margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; }
.ask-input:focus { outline: none; border-color: var(--bio-bright); box-shadow: 0 0 0 3px rgba(34, 228, 255, .15); }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sheet::backdrop { background: rgba(3, 5, 10, .75); backdrop-filter: blur(6px); }
.sheet h2 { margin: 0 0 6px; font-size: 1.2rem; }
.sheet p { margin: 0 0 16px; color: var(--text-dim); font-size: .92rem; }
.sheet input {
  width: 100%; padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 16px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border); outline: 0;
}
.sheet input:focus { border-color: var(--border-strong); }
.form-error { color: var(--danger) !important; margin: -4px 0 12px !important; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions > * { flex: 1; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; }
.primary {
  padding: 12px; border: 0; border-radius: 12px; font-weight: 650; color: #03111d;
  background: linear-gradient(100deg, #0284C7, #00E5FF);
}
.ghost {
  padding: 10px 14px; border-radius: 12px; font-size: .9rem; white-space: nowrap;
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
}
.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }
.ghost:disabled { opacity: .4; cursor: default; }
.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-top: 1px solid var(--border);
}
.setting h3 { margin: 0 0 2px; font-size: .95rem; font-weight: 600; }
.setting p { margin: 0; font-size: .82rem; }
.segmented { display: inline-flex; flex: none; padding: 3px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); }
.segmented button {
  border: 0; background: transparent; color: var(--text-dim); padding: 7px 12px; border-radius: 9px; font-size: .85rem;
}
.segmented button[aria-checked="true"] { color: #03111d; font-weight: 650; background: linear-gradient(100deg, #38BDF8, #00E5FF); }
.icon-only { width: 38px; padding: 0; justify-content: center; }
.about { margin: 10px 0 0 !important; font-size: .76rem !important; color: var(--text-faint) !important; text-align: center; }

/* ── responsive ── */
@media (max-width: 640px) {
  .topbar { padding-left: 16px; padding-right: 12px; }
  .btn-label { display: none; }
  .icon-btn { width: 38px; padding: 0; justify-content: center; }
  .thread { padding: 4px 14px 20px; }
  .welcome { padding-top: 7vh; }
  .chips { grid-template-columns: 1fr; }
  .chip:nth-child(n+3) { display: none; }
  .msg-ai { grid-template-columns: 1fr; gap: 6px; }
  .avatar { width: 26px; height: 26px; }
  .brand-logo { width: 30px; height: 30px; }
  .mode-badge { display: none; }
  .msg-user .bubble { max-width: 92%; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .brand-d2, .d2-inline { animation: biolum 20s linear infinite !important; animation-iteration-count: infinite !important; animation-duration: 20s !important; }
}

/* ═════════════════════ v4: deep space ═════════════════════ */
#space {
  position: fixed; inset: 0; width: 100vw; height: 100dvh; z-index: 0; display: block;
  transition: opacity 1.2s ease; opacity: 1;
}
html[data-space="chat"] #space { opacity: .45; }
.sea { display: none; }
html.no-webgl .sea { display: block; }
html.no-webgl #space { display: none; }
.layout[hidden], .login[hidden] { display: none !important; }

/* login: glass panel in front of the singularity */
.login { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(92vw, 400px); padding: 34px 30px 26px; border-radius: 26px; text-align: center;
  background: rgba(2, 4, 10, .42); backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid rgba(0, 229, 255, .22);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 0 60px rgba(0, 229, 255, .08), inset 0 1px 0 rgba(224, 242, 254, .06);
  animation: rise .8s ease both;
  transition: transform 1.4s cubic-bezier(.6, 0, .9, .4), opacity 1.2s ease, filter 1.2s ease;
}
.login.warping .login-card { transform: scale(.55) translateZ(0); opacity: 0; filter: blur(6px); }
.login-logo { width: 76px; height: 76px; margin: 0 auto 10px; }
.login-title { margin: 0; font-size: 2.1rem; letter-spacing: -.03em; display: flex; justify-content: center; align-items: baseline; gap: 3px; }
.login-title .brand-ask, .login-title .brand-d2 { font-size: 2.1rem; }
.login-sub { margin: 4px 0 26px; color: #7DD3FC; letter-spacing: .32em; text-transform: uppercase; font-size: .72rem; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%;
  padding: 13px 18px; border-radius: 14px; text-decoration: none; font-weight: 600; color: #F9FAFB;
  background: linear-gradient(120deg, rgba(2, 132, 199, .35), rgba(0, 229, 255, .18));
  border: 1px solid rgba(0, 229, 255, .45);
  box-shadow: 0 0 26px rgba(0, 229, 255, .18);
  transition: transform .15s, box-shadow .25s, border-color .25s;
}
.google-btn:hover { transform: translateY(-1px); box-shadow: 0 0 38px rgba(0, 229, 255, .35); border-color: #00E5FF; }
.google-btn svg { width: 20px; height: 20px; flex: none; background: #fff; border-radius: 50%; padding: 2px; }
.google-btn.disabled { opacity: .55; }
.local-login { display: grid; gap: 8px; margin-top: 16px; }
.local-login p { margin: 0; font-size: .75rem; color: var(--text-faint); letter-spacing: .1em; text-transform: uppercase; }
.login-msg { min-height: 1.3em; margin: 16px 0 0; color: #BDF4FF; font-size: .88rem; }

/* sidebar: Liminal pinned */
.liminal-btn {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 12px; border-radius: 14px; text-align: left;
  background: linear-gradient(120deg, rgba(3, 21, 56, .9), rgba(2, 132, 199, .16));
  border: 1px solid rgba(0, 229, 255, .28); color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.liminal-btn:hover, .liminal-btn.active { border-color: #00E5FF; box-shadow: 0 0 24px rgba(0, 229, 255, .18); }
.liminal-icon { width: 34px; height: 34px; flex: none; }
.liminal-icon { padding: 3px; }
.liminal-icon .d2-logo { cursor: inherit; }
.liminal-btn:hover .liminal-icon .d2-mark, .liminal-btn.active .liminal-icon .d2-mark { filter: drop-shadow(0 0 9px rgba(34, 228, 255, .55)); }
.liminal-text { display: flex; flex-direction: column; line-height: 1.25; flex: 1; }
.liminal-text strong { font-size: .98rem; letter-spacing: .02em; }
.liminal-text small { color: var(--text-faint); font-size: .74rem; }
.liminal-dot { width: 8px; height: 8px; border-radius: 50%; background: #00E5FF; box-shadow: 0 0 10px #00E5FF; }
.liminal-dot[hidden] { display: none; }
.sidebar { gap: 12px; }

/* D2 active switch (Liminal) */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .82rem; color: var(--text-dim); user-select: none; }
.switch[hidden] { display: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1px solid var(--border); position: relative; transition: background .2s; }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #6B7690; transition: transform .2s, background .2s; }
.switch input:checked + .track { background: rgba(0, 229, 255, .22); border-color: rgba(0, 229, 255, .5); }
.switch input:checked + .track .thumb { transform: translateX(16px); background: #00E5FF; box-shadow: 0 0 10px #00E5FF; }
.switch input:focus-visible + .track { outline: 2px solid #00E5FF; outline-offset: 2px; }

/* group chat bubbles */
.msg-user.group { align-items: flex-end; gap: 10px; }
.msg-user.group.theirs { justify-content: flex-start; }
.msg-user.group.theirs .user-wrap { align-items: flex-start; }
.msg-user.group.theirs .bubble { border-radius: 20px 20px 20px 6px; }
.avatar.person {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: .8rem; color: #02040A;
}
.by-yoshimoto .avatar.person { background: radial-gradient(circle at 35% 30%, #7DF9FF, #00E5FF 55%, #0284C7); }
.by-angel .avatar.person { background: radial-gradient(circle at 35% 30%, #E0E7FF, #A5B4FC 55%, #6366F1); }
.by-yoshimoto .bubble { border-color: rgba(0, 229, 255, .3); }
.by-angel .bubble { border-color: rgba(165, 180, 252, .35); background: linear-gradient(160deg, rgba(49, 46, 129, .45), var(--surface)); }
.author { font-size: .74rem; color: #7DD3FC; padding: 0 6px; }
.by-angel .author { color: #C7D2FE; }
.author time { color: var(--text-faint); margin-left: 6px; font-size: .7rem; }
.author.d2 { padding: 0 0 4px; color: #00E5FF; }

/* reasoning + citations */
.reasoning { margin: 0 0 8px; border: 1px solid var(--border); border-radius: 12px; background: rgba(3, 21, 56, .35); }
.reasoning[hidden] { display: none; }
.reasoning summary { cursor: pointer; padding: 7px 12px; font-size: .8rem; color: #7DD3FC; list-style: none; }
.reasoning summary::before { content: "◇ "; color: #00E5FF; }
.reasoning[open] summary::before { content: "◆ "; }
.reasoning-text { padding: 0 12px 10px; font-size: .82rem; color: var(--text-dim); white-space: pre-wrap; max-height: 260px; overflow-y: auto; }
.cite {
  display: inline-grid; place-items: center; min-width: 1.35em; height: 1.35em; padding: 0 3px; margin: 0 1px;
  border-radius: 6px; font-size: .72em; vertical-align: .25em; text-decoration: none !important; border: 0 !important;
  color: #02040A !important; background: #38BDF8; font-weight: 700;
}
.cite:hover { background: #00E5FF; }
.src-label { font-size: .72rem; color: var(--text-faint); align-self: center; margin-right: 2px; text-transform: uppercase; letter-spacing: .08em; }
.src b { color: #00E5FF; margin-right: 4px; }

/* code block actions + artifact panel */
.code-actions { display: flex; gap: 6px; }
.open-artifact {
  background: rgba(0, 229, 255, .12); border: 1px solid rgba(0, 229, 255, .45); border-radius: 7px; padding: 3px 10px;
  font-size: .76rem; color: #00E5FF;
}
.open-artifact:hover { background: rgba(0, 229, 255, .22); }
.artifact {
  position: relative; z-index: 2; width: 50vw; flex: none; display: flex; flex-direction: column;
  background: rgba(2, 4, 10, .92); border-left: 1px solid var(--border-strong); backdrop-filter: blur(12px);
}
.artifact[hidden] { display: none; }
.artifact-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); }
.tabs button { border: 0; background: transparent; color: var(--text-dim); padding: 6px 12px; border-radius: 9px; font-size: .84rem; }
.tabs button[aria-selected="true"] { background: linear-gradient(100deg, #38BDF8, #00E5FF); color: #02040A; font-weight: 650; }
.artifact-actions { display: flex; align-items: center; gap: 6px; }
.ghost.small { padding: 6px 10px; font-size: .8rem; }
#artFrame { flex: 1; width: 100%; border: 0; background: #02040A; }
#artFrame[hidden] { display: none; }
.art-code { flex: 1; margin: 0; overflow: auto; padding: 14px 16px; font: .84rem/1.6 var(--mono); color: #E3EEFF; }
.art-code[hidden] { display: none; }
@media (max-width: 899px) {
  .artifact { position: fixed; inset: 0; width: 100vw; z-index: 50; }
}

/* settings: diagnostics */
.quota { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .06); border: 1px solid var(--border); overflow: hidden; }
.quota-bar { height: 100%; width: 0; background: linear-gradient(90deg, #0284C7, #00E5FF); box-shadow: 0 0 14px rgba(0, 229, 255, .6); transition: width .6s ease; }
.quota-bar.warn { background: linear-gradient(90deg, var(--nebula), var(--danger)); }
.perf { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 4px 0 0; font-size: .84rem; }
.perf dt { color: var(--text-faint); }
.perf dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; }
.attempts h4 { margin: 8px 0 6px; font-size: .82rem; color: var(--nebula); font-weight: 600; }
.attempts ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 160px; overflow-y: auto; }
.attempts li { display: flex; justify-content: space-between; gap: 10px; font-size: .8rem; padding: 6px 10px; border-radius: 9px; background: var(--bg-2); border: 1px solid var(--border); }
.attempts time { color: var(--text-faint); white-space: nowrap; }
.attempts li.empty { justify-content: center; color: var(--text-faint); }
.setting [hidden] { display: none; }

/* translucent chrome so space shows through */
.topbar { background: linear-gradient(rgba(2, 4, 10, .85) 40%, transparent); }
.composer-wrap { background: linear-gradient(transparent, rgba(2, 4, 10, .9) 35%); }
.sidebar { background: rgba(2, 4, 10, .72); }
body.in-liminal .welcome { display: none; }

/* long code lines must never widen the conversation */
.msg-ai { grid-template-columns: 30px minmax(0, 1fr); }
.ai-body, .content, .code, .user-wrap { min-width: 0; max-width: 100%; }
.code-head { flex-wrap: wrap; gap: 6px; }
@media (max-width: 640px) { .msg-ai { grid-template-columns: minmax(0, 1fr); } }

/* the hidden attribute always wins over component display rules */
[hidden] { display: none !important; }

/* ═════════════════════ v5: attachments, presence, brain ═════════════════════ */
.att.file { width: auto; max-width: 200px; display: flex; align-items: center; gap: 8px; padding: 0 30px 0 10px; background: rgba(3, 21, 56, .6); }
.att.file .att-name { font-size: .78rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-ico { font-size: 1.05rem; }
.att-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.msg-user.group.theirs .att-list { justify-content: flex-start; }
.att-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 260px; padding: 8px 12px; border-radius: 12px;
  text-decoration: none; color: var(--text); background: rgba(3, 21, 56, .6); border: 1px solid var(--border);
}
.att-chip span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.att-chip small { color: var(--text-faint); font-size: .72rem; white-space: nowrap; }
.att-chip:hover { border-color: var(--border-strong); }
.att-thumb { max-width: 220px; max-height: 220px; border-radius: 14px; border: 1px solid var(--border); object-fit: cover; }
.liminal-btn.online .liminal-icon { filter: drop-shadow(0 0 8px rgba(0, 229, 255, .6)); }
.liminal-btn.online small { color: var(--bio-bright); }
.turnstile-box { margin-top: 14px; display: flex; justify-content: center; }
.brain-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.file-label { cursor: pointer; display: inline-flex; align-items: center; }

/* animated slogan (login) */
.slogan {
  min-height: 2.6em; margin: 8px 0 24px; font-size: .95rem; line-height: 1.35; letter-spacing: .01em;
  display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap;
}
.slogan-text {
  background: linear-gradient(100deg, #7DD3FC 0%, #E0F2FE 22%, #00E5FF 40%, #38BDF8 58%, #E0F2FE 76%, #7DD3FC 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
  animation: shimmer 4.5s linear infinite;
  filter: drop-shadow(0 0 10px rgba(0, 229, 255, .25));
}
.caret {
  display: inline-block; width: 2px; height: 1.1em; margin-left: 3px; transform: translateY(.18em);
  background: #00E5FF; box-shadow: 0 0 8px #00E5FF; animation: blink 1s steps(1) infinite;
}
@keyframes shimmer { to { background-position: -250% 0; } }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .slogan-text, .caret { animation: none; } }

/* ── Liquid Interfaces ── */
.lq-before:empty, .lq-after:empty { display: none; }
.lq-before { margin-bottom: 10px; }
.lq-after { margin-top: 10px; }
.lq-card {
  border: 1px solid var(--border-strong); border-radius: 16px; overflow: hidden;
  background: linear-gradient(180deg, rgba(11, 24, 48, .92), rgba(6, 11, 24, .92));
  box-shadow: 0 0 0 1px rgba(34, 200, 255, .06), 0 10px 40px -18px var(--bio-glow);
}
.lq-head { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.lq-head b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lq-tag { font-size: .72rem; color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
.lq-status { margin-left: auto; font-size: .72rem; color: var(--text-faint); }
.lq-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.lq-card[data-mode="live"] .lq-dot { background: var(--bio-bright); box-shadow: 0 0 10px var(--bio-bright); animation: lq-pulse 2.4s ease-in-out infinite; }
.lq-card[data-mode="live"] .lq-status { color: var(--bio-foam); }
.lq-body { padding: 12px 14px; }
.lq-frame { display: block; width: 100%; border: 0; background: transparent; color-scheme: dark; transition: height .18s ease; }
.lq-snap { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; font-size: .84rem; }
.lq-snap div { display: flex; gap: 6px; }
.lq-snap dt { color: var(--text-faint); }
.lq-snap dd { margin: 0; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.lq-snap-empty { margin: 0; color: var(--text-faint); font-size: .84rem; }
.lq-card[data-mode="snapshot"] { border-color: var(--border); box-shadow: none; opacity: .85; }
.lq-skeleton { height: 90px; border-radius: 10px; background: linear-gradient(90deg, rgba(34,200,255,.05), rgba(34,200,255,.14), rgba(34,200,255,.05)); background-size: 200% 100%; animation: lq-shimmer 1.4s linear infinite; }
.lq-broken { border-color: var(--nebula-soft); }
.msg-liquid .user-wrap { align-items: flex-end; }
.lq-turn {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: .8rem;
  color: var(--bio-foam); background: rgba(18, 184, 255, .08); border: 1px solid var(--border);
}
@keyframes lq-pulse { 50% { opacity: .45; } }
@keyframes lq-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .lq-dot, .lq-skeleton { animation: none !important; } }

/* feedback */
.tool-btn.fb { padding-inline: 8px; filter: grayscale(1); opacity: .6; }
.tool-btn.fb:hover, .tool-btn.fb[aria-pressed="true"] { filter: none; opacity: 1; }
.tool-btn.fb[aria-pressed="true"] { border-color: var(--border-strong); }

/* model versions */
.model-people { display: grid; gap: 12px; }
.model-person h4 { margin: 0 0 6px; font-size: .92rem; }
.model-person h4 small { font-weight: 400; color: var(--text-faint); margin-left: 6px; }
.model-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 240px; overflow-y: auto; }
.model-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 10px; font-size: .86rem; background: var(--bg-2); border: 1px solid var(--border);
}
.model-list li span { display: grid; }
.model-list li small { color: var(--text-faint); font-size: .76rem; }
.model-list li.on { border-color: var(--border-strong); }
.model-list li b { color: var(--bio-foam); font-weight: 500; font-size: .8rem; }
.model-list button { padding: 4px 12px; }
.model-run { margin: 6px 0 0; font-size: .8rem; color: var(--text-faint); }

/* ── Liquid: dissolve / metamorphosis, pin, verification seal ── */
.lq-card { transition: filter .42s ease, opacity .42s ease, transform .42s ease; }
.lq-dissolving { filter: blur(6px) saturate(.4); opacity: .25; transform: scale(.985); }
.lq-morph-in { animation: lq-morph .55s cubic-bezier(.2, .8, .2, 1); }
@keyframes lq-morph { from { opacity: 0; filter: blur(8px); transform: translateY(6px) scale(.985); } to { opacity: 1; filter: none; transform: none; } }
.lq-skeleton.short { height: 36px; width: 60%; margin-top: 10px; }
.lq-pending { margin-top: 10px; }
.lq-pin { margin-left: 8px; padding: 2px 10px; font-size: .74rem; border-radius: 999px; background: rgba(18, 184, 255, .08); border: 1px solid var(--border); color: var(--bio-foam); cursor: pointer; }
.lq-pin:hover { border-color: var(--border-strong); }
.lq-pin[hidden] { display: none; }
.lq-seal { border-top: 1px solid var(--border); padding: 8px 14px 10px; font-size: .78rem; color: var(--text-dim); }
.lq-seal b { font-weight: 600; }
.lq-seal.ok b { color: var(--bio-foam); }
.lq-seal.partial b { color: var(--nebula); }
.lq-seal.bad b { color: var(--danger); }
.lq-seal ol { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 2px; }
.lq-seal a { color: var(--bio-foam); text-decoration: none; overflow-wrap: anywhere; }
.lq-seal a:hover { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) { .lq-card, .lq-morph-in { transition: none; animation: none; } }

/* continue, sharing, cockpit */
.tool-btn.cont { color: var(--bio-foam); border-color: var(--border-strong); }
.share-btn { white-space: nowrap; }
.share-btn[hidden] { display: none; }
.share-btn:disabled { opacity: .8; cursor: default; }
.cockpit { margin: 2px auto 0; max-width: var(--maxw); text-align: right; font: 11px/1.4 var(--mono); color: var(--text-faint); padding: 0 6px; user-select: none; }
.cockpit[hidden] { display: none; }
.spend { margin: 6px 0 0; font-size: .82rem; color: var(--text-dim); }
.spend.warn { color: var(--nebula); }
button.danger { border-color: rgba(255, 122, 147, .45); color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }

/* artifacts drawer + editable panel */
.art-drawer { padding: 4px 12px 8px; border-top: 1px solid var(--border); max-height: 30vh; overflow-y: auto; }
.art-drawer h4 { margin: 8px 0 6px; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); font-weight: 600; }
.art-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.art-list button { width: 100%; text-align: left; background: none; border: 0; color: var(--text-dim); padding: 6px 8px; border-radius: 8px; font-size: .86rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art-list button:hover { background: var(--surface-2); color: var(--text); }
.art-list .empty { color: var(--text-faint); font-size: .8rem; padding: 4px 8px; }
.art-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; color: var(--text-dim); padding: 0 8px; }
.art-editor { flex: 1; width: 100%; box-sizing: border-box; resize: none; border: 0; padding: 14px; background: var(--bg-2); color: var(--text); font: 13px/1.5 var(--mono); tab-size: 2; }
.art-editor[hidden] { display: none; }

/* ── calls ── */
.call-btn.ringing { color: var(--bio-bright); animation: ring 1.2s ease-in-out infinite; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } }
body.in-call .call-btn { color: var(--danger); }
.call {
  position: fixed; inset: auto 12px 12px 12px; z-index: 60; max-width: 560px; margin: 0 auto;
  border: 1px solid var(--border-strong); border-radius: 24px; padding: 16px 16px 14px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(18, 184, 255, .16), transparent 60%), linear-gradient(180deg, rgba(11, 24, 48, .97), rgba(4, 8, 18, .97));
  box-shadow: 0 24px 80px -24px var(--bio-glow); backdrop-filter: blur(14px);
  animation: lq-morph .45s cubic-bezier(.2, .8, .2, 1);
}
.call-top { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; color: var(--text-dim); }
.call-title { font-weight: 600; color: var(--text); }
.call-timer { font: 12px var(--mono); color: var(--text-faint); }
.call-stage { display: flex; justify-content: center; gap: 18px; margin: 14px 0 6px; flex-wrap: wrap; }
.call-peer { display: grid; justify-items: center; gap: 4px; min-width: 88px; text-align: center; }
.call-peer b { font-size: .9rem; font-weight: 600; }
.call-peer .st { font-size: .74rem; color: var(--text-faint); min-height: 1.1em; }
.call-orb, .call-avatar { position: relative; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border-strong); background: var(--surface-2); }
.call-orb svg { width: 38px; height: 38px; }
.call-peer.d2[data-state="a falar"] .call-orb { box-shadow: 0 0 0 4px rgba(34, 228, 255, .18), 0 0 28px var(--bio-glow); animation: orb 1.1s ease-in-out infinite; }
.call-peer.d2[data-state="a pensar"] .call-orb { animation: orb-think 1.6s linear infinite; }
.call-peer.d2[data-state="em silêncio"] .call-orb { opacity: .45; filter: grayscale(.7); }
@keyframes orb { 50% { transform: scale(1.06); box-shadow: 0 0 0 9px rgba(34, 228, 255, .08), 0 0 40px var(--bio-glow); } }
@keyframes orb-think { from { box-shadow: 3px 0 12px var(--bio-glow); } 50% { box-shadow: -3px 0 12px var(--bio-glow); } to { box-shadow: 3px 0 12px var(--bio-glow); } }
.call-avatar { font-size: 1.4rem; font-weight: 600; color: var(--bio-foam); }
.call-peer.me .call-avatar .lvl { position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--bio-bright); opacity: calc(var(--lvl, 0) * 1.2); transform: scale(calc(1 + var(--lvl, 0) * .12)); transition: opacity .08s, transform .08s; }
.call-caption { margin: 4px 0 10px; min-height: 1.4em; text-align: center; font-size: .86rem; color: var(--text-dim); overflow-wrap: anywhere; }
.call-controls { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.cbtn { display: grid; justify-items: center; gap: 3px; min-width: 76px; padding: 10px 12px 8px; border-radius: 16px; border: 1px solid var(--border); background: rgba(255, 255, 255, .04); color: var(--text); font-size: .72rem; cursor: pointer; }
.cbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cbtn:hover:not(:disabled) { border-color: var(--border-strong); }
.cbtn:disabled { opacity: .45; cursor: default; }
.cbtn.off { color: var(--nebula); border-color: var(--nebula-soft); }
.cbtn.ptt { color: var(--bio-foam); border-color: var(--border-strong); }
.cbtn.ptt.live { background: rgba(34, 228, 255, .18); box-shadow: 0 0 20px var(--bio-glow); animation: orb 1s ease-in-out infinite; }
.cbtn.hang { background: var(--danger); border-color: transparent; color: #fff; }
.cbtn.hang:hover { background: #FF5C7C; }
body.in-call .composer-wrap { padding-bottom: 210px; }
.voice-pick { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; font-size: .86rem; }
.voice-pick select { flex: 1; min-width: 180px; background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; }
@media (prefers-reduced-motion: reduce) { .call, .call-orb, .cbtn.ptt.live, .call-btn.ringing { animation: none !important; } }
.install-desktop { color: var(--bio-foam); text-decoration: none; border-bottom: 1px solid var(--border-strong); }
.install-desktop:hover { color: var(--bio-bright); }

/* ── Liquid holograms: wider than the text column ── */
.msg-ai .content .lq-card { width: min(1200px, calc(100vw - 40px)); position: relative; left: 50%; transform: translateX(-50%); }
@media (min-width: 1100px) { body.artifact-open .msg-ai .content .lq-card, body.doc-open .msg-ai .content .lq-card { width: 100%; left: 0; transform: none; } }

/* ── D2's actions (chips under the answer) ── */
.act-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.act-chip { font-size: .76rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.03); color: var(--text-dim); }
.act-chip.ok { color: var(--bio-foam); border-color: rgba(34, 228, 255, .35); background: rgba(18, 184, 255, .08); box-shadow: 0 0 10px rgba(34, 200, 255, .12); }
.act-chip.no { color: var(--nebula); border-color: var(--nebula-soft); background: rgba(99, 102, 241, .08); }
.act-chip.run { color: var(--bio-foam); animation: lq-pulse 1.4s ease-in-out infinite; }

/* ── code sandbox ── */
.code-actions .run-code { color: var(--bio-bright); }
.sbx-card { max-width: var(--maxw); margin: 6px auto 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-2); overflow: hidden; }
.sbx-card.ok { border-color: var(--border-strong); }
.sbx-card.bad { border-color: rgba(255, 122, 147, .35); }
.sbx-head { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; font-size: .84rem; border-bottom: 1px solid var(--border); }
.sbx-st { color: var(--text-faint); font-size: .78rem; }
.sbx-code summary { cursor: pointer; padding: 6px 12px; font-size: .78rem; color: var(--text-faint); }
.sbx-code pre, .sbx-out { margin: 0; padding: 10px 12px; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; }
.sbx-out { color: #D6E4F0; border-top: 1px solid var(--border); }
.sbx-actions { padding: 6px 12px 10px; }
.sbx-actions[hidden] { display: none; }
.sbx-turn { font-size: .8rem; color: var(--bio-foam); border: 1px solid var(--border); border-radius: 12px; padding: 4px 12px; background: rgba(18,184,255,.06); max-width: 520px; }
.sbx-turn pre { white-space: pre-wrap; font: 11.5px/1.45 var(--mono); color: var(--text-dim); max-height: 220px; overflow: auto; }

/* ── documents workspace ── */
.drawer-add { float: right; background: none; border: 1px solid var(--border); color: var(--bio-foam); border-radius: 6px; width: 20px; height: 20px; line-height: 16px; cursor: pointer; padding: 0; }
.doc-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); z-index: 55; display: flex; flex-direction: column; background: linear-gradient(180deg, #060B18, #02040A); border-left: 1px solid var(--border-strong); box-shadow: -20px 0 60px -30px var(--bio-glow); animation: lq-morph .4s ease; }
.doc-panel[hidden] { display: none; }
@media (min-width: 1100px) { body.doc-open .app { margin-right: min(760px, 50vw); } }
.doc-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.doc-title { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text); font: 600 1.05rem var(--font); padding: 4px 6px; border-radius: 8px; }
.doc-title:focus { outline: 1px solid var(--border-strong); }
.doc-state { font-size: .74rem; color: var(--text-faint); white-space: nowrap; }
.doc-menu { display: flex; align-items: center; gap: 6px; }
.doc-export { position: relative; }
.doc-export summary { list-style: none; cursor: pointer; padding: 4px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: .8rem; }
.doc-export-list { position: absolute; right: 0; top: 110%; z-index: 2; display: grid; min-width: 190px; padding: 6px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); box-shadow: 0 16px 40px -16px #000; }
.doc-export-list button { text-align: left; background: none; border: 0; color: var(--text); padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: .86rem; }
.doc-export-list button:hover { background: var(--surface-2); }
.doc-tools { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.doc-tools button { min-width: 32px; height: 30px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--text-dim); cursor: pointer; font-size: .86rem; }
.doc-tools button:hover { border-color: var(--border); color: var(--text); }
.doc-page { flex: 1; overflow-y: auto; margin: 14px; padding: 36px 44px; border-radius: 6px; background: #FBFBF8; color: #1A1A1A; font: 16px/1.7 Georgia, "Times New Roman", serif; outline: none; box-shadow: 0 20px 60px -30px #000; }
.doc-page h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 .6em; }
.doc-page h2 { font-size: 1.35rem; margin: 1.4em 0 .4em; }
.doc-page h3 { font-size: 1.1rem; margin: 1.2em 0 .3em; }
.doc-page figure { margin: 1.2em 0; text-align: center; }
.doc-page img { max-width: 100%; border-radius: 4px; }
.doc-page figcaption { font-size: .82rem; color: #555; margin-top: .3em; }
.doc-page blockquote { border-left: 3px solid #12B8FF; margin: 1em 0; padding: .2em 1em; color: #333; font-style: italic; }
.doc-page table { border-collapse: collapse; width: 100%; margin: 1em 0; font-size: .92rem; }
.doc-page td, .doc-page th { border: 1px solid #BBB; padding: 4px 8px; }
.doc-page a { color: #0645AD; }
.doc-page sup.cite a { text-decoration: none; font-size: .72em; }
.doc-page .doc-sources { font-size: .86rem; color: #333; }
.doc-assist { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.doc-assist input { flex: 1; background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
@media (max-width: 700px) { .doc-page { margin: 8px; padding: 20px 18px; } }
.doc-kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--bio-foam); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.doc-primary { color: var(--bio-foam); border-color: rgba(34, 228, 255, .45); }
.doc-primary[hidden] { display: none; }
.doc-panel.writing .doc-page { box-shadow: 0 0 0 2px rgba(34, 228, 255, .35), 0 20px 60px -30px #000; }
.doc-panel.writing .doc-state { color: var(--bio-foam); animation: lq-pulse 1.4s ease-in-out infinite; }
.doc-page .doc-wait { color: #777; font-style: italic; }

/* live Swarm (owner settings) */
.swarm-live { margin: .6rem 0 .2rem; font-size: .85rem; opacity: .85; }
.swarm-nodes { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; font-size: .8rem; }
.swarm-nodes li { padding: .4rem .6rem; border-radius: .5rem; background: rgba(120, 200, 255, .06); }
.swarm-nodes li span { opacity: .75; }

/* ── to do lists (public/js/todo.js) ── */
.art-list button small { color: var(--text-faint); font-size: .72rem; margin-left: 4px; }
.todo-sheet { width: min(94vw, 480px); }
.todo-sheet .sheet-head { gap: 10px; }
.todo-title { flex: 1; margin: 0 !important; font-size: 1.15rem !important; font-weight: 650; background: transparent !important; border-color: transparent !important; padding: 6px 8px !important; }
.todo-title:hover, .todo-title:focus { border-color: var(--border) !important; }
.todo-progress { display: flex; align-items: center; gap: 10px; margin: 2px 0 14px; }
.todo-bar { flex: 1; height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.todo-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--bio-deep), var(--bio-bright)); box-shadow: 0 0 12px var(--bio-glow); transition: width .35s ease; }
.todo-count { color: var(--text-dim); font-size: .8rem; white-space: nowrap; }
.todo-items { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; max-height: 52dvh; overflow-y: auto; }
.todo-items li { display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 12px; transition: background .2s; }
.todo-items li:hover { background: var(--surface-2); }
.todo-items .todo-text { flex: 1; margin: 0 !important; padding: 8px 6px !important; background: transparent !important; border-color: transparent !important; font-size: .96rem !important; }
.todo-items .todo-text:focus { border-color: var(--border) !important; background: var(--bg-2) !important; }
.todo-items li.done .todo-text { color: var(--text-faint); text-decoration: line-through; text-decoration-color: var(--bio); }
.todo-check { position: relative; width: 22px; height: 22px; flex: none; cursor: pointer; }
.todo-check input { position: absolute; opacity: 0; inset: 0; margin: 0 !important; width: 100% !important; cursor: pointer; }
.todo-check span { position: absolute; inset: 0; border-radius: 7px; border: 1.5px solid var(--border-strong); background: var(--bg-2); transition: all .2s; }
.todo-check input:checked + span { background: linear-gradient(135deg, var(--bio-deep), var(--bio-bright)); border-color: var(--bio-bright); box-shadow: 0 0 10px var(--bio-glow); }
.todo-check input:checked + span::after { content: ""; position: absolute; left: 7px; top: 3px; width: 5px; height: 10px; border: solid #02040A; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.todo-check input:focus-visible + span { outline: 2px solid var(--bio-bright); outline-offset: 2px; }
.todo-del { background: none; border: 0; color: var(--text-faint); font-size: 1.2rem; cursor: pointer; padding: 0 6px; opacity: 0; transition: opacity .2s; }
.todo-items li:hover .todo-del, .todo-del:focus-visible { opacity: 1; }
.todo-del:hover { color: var(--danger); }
.todo-add { display: flex; gap: 8px; }
.todo-add input { margin: 0 !important; }
.todo-foot { display: flex; justify-content: space-between; margin-top: 14px; }
.ghost.danger { color: var(--danger); }
@media (hover: none) { .todo-del { opacity: 1; } }
