/* ============================================================
   Supreme AI — Premium AI Workspace
   Part 1: design tokens, base, ambient, shell, sidebar, topbar,
   hero, messages, markdown
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', var(--font-ui);
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --bg-0: #010204;
  --bg-1: #030509;
  --bg-2: #070b12;
  --surface-0: rgba(255, 255, 255, 0.02);
  --surface-1: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.075);
  --border-hi: rgba(255, 255, 255, 0.14);
  --border-soft: rgba(255, 255, 255, 0.045);

  --text-1: #E9EDF2;
  --text-2: #A6AFBD;
  --text-3: #6E7887;

  --accent: #4AA8FF;
  --accent-strong: #66BCFF;
  --accent-2: #8B7CFF;
  --accent-grad: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  --accent-glow: rgba(74, 168, 255, 0.22);
  --accent-2-glow: rgba(139, 124, 255, 0.2);

  --ok: #34D399;
  --warn: #FBBF24;
  --err: #F87171;
  --err-soft: rgba(248, 113, 113, 0.14);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 20px 60px rgba(0, 0, 0, 0.55);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --topbar-h: 60px;
  --sidebar-w: 304px;
  --t: 180ms cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-slow: 320ms cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: dark;
}

html[data-theme='light'] {
  --bg-0: #F5F7FB;
  --bg-1: #EEF1F7;
  --bg-2: #E6EAF2;
  --surface-0: rgba(255, 255, 255, 0.6);
  --surface-1: rgba(255, 255, 255, 0.72);
  --surface-2: rgba(255, 255, 255, 0.92);
  --border: rgba(15, 23, 42, 0.09);
  --border-hi: rgba(15, 23, 42, 0.16);
  --border-soft: rgba(15, 23, 42, 0.05);

  --text-1: #101828;
  --text-2: #475467;
  --text-3: #98A2B3;

  --accent: #2563EB;
  --accent-strong: #1D4ED8;
  --accent-2: #7C3AED;
  --accent-grad: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  --accent-glow: rgba(37, 99, 235, 0.16);
  --accent-2-glow: rgba(124, 58, 237, 0.14);

  --ok: #059669;
  --warn: #B45309;
  --err: #DC2626;

  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-2: 0 10px 30px rgba(16, 24, 40, 0.1);
  --shadow-3: 0 24px 60px rgba(16, 24, 40, 0.16);

  color-scheme: light;
}

/* ---------- reset / base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
  overflow-y: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font-family: inherit; color: inherit; }
::selection { background: var(--accent-glow); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; border: 3px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- ambient background (CSS only, GPU friendly) ---------- */
#bg-ambient {
  position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(ellipse 720px 460px at 8% 4%, rgba(0, 150, 210, .075), transparent 70%),
    radial-gradient(ellipse 620px 520px at 94% 92%, rgba(96, 0, 145, .065), transparent 72%),
    radial-gradient(ellipse at center, #080d16 0%, #020409 54%, #000102 100%);
}
#neural-bg { position: fixed; inset: 0; z-index: 0; width: 100vw; height: 100vh; pointer-events: none; opacity: .34; }
.aurora { position: absolute; border-radius: 50%; filter: blur(130px); will-change: transform; opacity: .22; }
.app { position: relative; z-index: 1; }
#bg-ambient, #noise { z-index: 0; }
.aurora.a1 { width: 560px; height: 560px; top: -180px; right: -120px; background: radial-gradient(circle, rgba(74, 168, 255, 0.16), transparent 65%); animation: drift1 22s ease-in-out infinite alternate; }
.aurora.a2 { width: 640px; height: 640px; bottom: -260px; left: -180px; background: radial-gradient(circle, rgba(139, 124, 255, 0.14), transparent 65%); animation: drift2 28s ease-in-out infinite alternate; }
.aurora.a3 { width: 420px; height: 420px; top: 40%; left: 44%; background: radial-gradient(circle, rgba(74, 168, 255, 0.07), transparent 65%); animation: drift1 34s ease-in-out infinite alternate-reverse; }
#noise { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .18; background-image: repeating-linear-gradient(0deg, transparent 0, transparent 3px, rgba(0, 230, 255, .025) 3px, rgba(0, 230, 255, .025) 4px); }
/* Keep the native cursor visible and immediate; a JS-following custom cursor
   adds input latency on lower-powered machines. */
body.is-resizing, body.is-resizing * { cursor: col-resize !important; }
@keyframes drift1 { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(-70px, 50px, 0) scale(1.12); } }
@keyframes drift2 { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(80px, -60px, 0) scale(1.14); } }

/* ---------- app shell ---------- */
.app { position: relative; z-index: 1; display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.backdrop { position: fixed; inset: 0; z-index: 900; background: rgba(2, 4, 8, 0.55); opacity: 0; pointer-events: none; transition: opacity var(--t); }
.backdrop.show { opacity: 1; pointer-events: auto; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.side {
  width: var(--sidebar-w); min-width: var(--sidebar-w); height: 100%;
  display: flex; flex-direction: column;
  background: var(--surface-0);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  transition: transform var(--t-slow), background var(--t);
  z-index: 1000;
}
.side-top { padding: 16px 14px 6px; }

.brand { display: flex; align-items: center; gap: 12px; padding: 2px 4px 14px; }
.brand .mark {
  width: 38px; height: 38px; border-radius: 11px; padding: 3px; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(74, 168, 255, 0.22), rgba(139, 124, 255, 0.22));
  border: 1px solid var(--border-hi);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 4px 14px var(--accent-glow);
}
.brand .mark img { width: 100%; height: 100%; border-radius: 8px; object-fit: cover; display: block; }
.brand .b-text { min-width: 0; display: flex; flex-direction: column; justify-content: center; line-height: 1; }
.brand .b-name {
  font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 0.32em;
  background: linear-gradient(120deg, var(--text-1) 0%, var(--text-1) 45%, var(--accent-strong) 135%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  white-space: nowrap;
}
.brand .b-sub { display: block; font-size: 8px; line-height: 1.2; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-3); margin-top: 6px; }

.btn-new {
  position: relative; isolation: isolate; overflow: hidden;
  width: 100%; min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 10px 14px; border: 1px solid rgba(125, 170, 255, .28); border-radius: 11px;
  background: linear-gradient(135deg, rgba(74, 168, 255, .96), rgba(108, 92, 224, .96));
  color: #fff; font-weight: 650; font-size: 13.5px; letter-spacing: .01em;
  box-shadow: 0 5px 18px rgba(74, 168, 255, .18), inset 0 1px 0 rgba(255, 255, 255, .24);
  transition: transform var(--t), box-shadow var(--t), filter var(--t), border-color var(--t);
}
.btn-new::after {
  content: ''; position: absolute; z-index: -1; inset: 0; opacity: 0;
  background: linear-gradient(110deg, transparent 25%, rgba(255,255,255,.2) 50%, transparent 75%);
  transform: translateX(-120%); transition: opacity var(--t), transform 520ms ease;
}
.btn-new:hover {
  transform: translateY(-1px); border-color: rgba(154, 205, 255, .55);
  box-shadow: 0 9px 25px rgba(74, 168, 255, .28), inset 0 1px 0 rgba(255, 255, 255, .28);
  filter: brightness(1.07);
}
.btn-new:hover::after { opacity: 1; transform: translateX(120%); }
.btn-new:active { transform: translateY(0) scale(.98); box-shadow: 0 3px 10px rgba(74, 168, 255, .18); }
.btn-new:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 3px; }
.btn-new .ic { width: 17px; height: 17px; stroke-width: 2.2; }

.side-scroll { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }

.hist-label {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 8px 7px; font-size: 10.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-3); font-weight: 600;
}
.hist-label::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }
.conv-group + .conv-group { margin-top: 2px; }

.conv-item {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 8px 10px; margin-bottom: 2px; border-radius: 10px;
  color: var(--text-2); cursor: pointer; text-align: left; position: relative;
  border: 1px solid transparent;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.conv-item:hover { background: var(--surface-1); color: var(--text-1); }
.conv-item.active { background: var(--surface-2); color: var(--text-1); border-color: var(--border-soft); box-shadow: inset 2px 0 0 var(--accent); }
.conv-item .ci-icon { width: 14px; height: 14px; flex-shrink: 0; color: var(--text-3); }
.conv-item:hover .ci-icon { color: var(--accent); }
.conv-item .ci-main { flex: 1; min-width: 0; }
.conv-item .ci-title { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.conv-item .ci-time { display: block; font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
.conv-item .ci-menu {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--text-3);
  opacity: 0; transition: opacity var(--t), background var(--t), color var(--t);
}
.conv-item:hover .ci-menu, .conv-item.active .ci-menu { opacity: 1; }
.conv-item .ci-menu:hover { background: var(--surface-2); color: var(--text-1); }
.conv-item .ci-menu .ic { width: 15px; height: 15px; }

.menu-pop {
  position: absolute; right: 8px; top: calc(100% - 4px); z-index: 60; min-width: 172px;
  background: var(--bg-2); border: 1px solid var(--border-hi); border-radius: 11px;
  padding: 5px; box-shadow: var(--shadow-2);
  animation: popIn 140ms var(--t);
}
.menu-pop button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 7px; font-size: 13px; color: var(--text-2); text-align: left; transition: background var(--t), color var(--t); }
.menu-pop button .ic { width: 14px; height: 14px; }
.menu-pop button:hover { background: var(--surface-2); color: var(--text-1); }
.menu-pop button.danger:hover { background: var(--err-soft); color: var(--err); }
.menu-pop .rename-input { width: 100%; background: var(--surface-1); border: 1px solid var(--accent); color: var(--text-1); border-radius: 7px; padding: 8px 10px; font-size: 13px; outline: none; }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }

.side-foot { padding: 10px 12px 12px; border-top: 1px solid var(--border); }
.status-row { display: flex; align-items: center; gap: 9px; padding: 6px 6px 12px; font-size: 12.5px; color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text-3); }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.bad { background: var(--err); box-shadow: 0 0 8px var(--err); }
.dot.busy { background: var(--accent); animation: breathe 1.3s ease-in-out infinite; }
.dot.busy.web { background: var(--accent-2); animation: breathe 0.9s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.4; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.25); } }

.side-actions { display: flex; flex-direction: column; gap: 2px; }
.side-action { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; border-radius: 10px; color: var(--text-2); font-size: 13.5px; font-weight: 500; transition: background var(--t), color var(--t); }
.side-action .ic { width: 17px; height: 17px; color: var(--text-3); transition: color var(--t); }
.side-action:hover { background: var(--surface-1); color: var(--text-1); }
.side-action:hover .ic { color: var(--accent); }

/* ============================================================
   MAIN / TOPBAR
   ============================================================ */
.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; height: 100%; position: relative; padding-top: 60px; }

.topbar {
  height: 60px; flex-shrink: 0; display: flex; align-items: center; gap: 14px;
  padding: 0; position: absolute; inset: 0 0 auto; width: 100%;
  background: transparent;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 0;
  z-index: 50;
}
.top-right { display: none !important; }
.topbar .model-block { position: absolute; top: 12px; left: 18px; }
.topbar .btn-hamb { position: absolute; top: 8px; left: 10px; }
.topbar .btn-hamb + .model-block { left: 62px; }
.token-meter {
  position: absolute; top: 18px; right: 18px; z-index: 55;
  width: 20px; height: 20px; display: grid; place-items: center;
  color: var(--text-1); pointer-events: none;
  filter: drop-shadow(0 3px 12px rgba(0, 0, 0, .35));
}
.token-meter svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.token-ring-track, .token-ring { fill: none; stroke-width: 3; }
.token-ring-track { stroke: rgba(255, 255, 255, .1); }
.token-ring { stroke: var(--ok); stroke-linecap: round; stroke-dasharray: 113.1; stroke-dashoffset: 0; transition: stroke .35s ease, stroke-dashoffset .45s ease; }
.token-meter-core { position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; display: grid; place-items: center; border-radius: 50%; background: transparent; transform: translate(-50%, -50%); }
.token-server-dot { display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 5px var(--accent); transition: background .2s ease, box-shadow .2s ease; }
.token-server-dot.online { background: var(--ok); box-shadow: 0 0 9px var(--ok); }
.token-server-dot.virgious { background: var(--accent); box-shadow: 0 0 9px var(--accent); }
.token-server-dot.offline { background: var(--err); box-shadow: 0 0 9px var(--err); }
.token-meter-label { display: none; }
.model-popover { position: absolute; z-index: 120; top: 52px; left: 18px; width: 250px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; opacity: 0; visibility: hidden; transform: translateY(-5px); transform-origin: top left; transition: opacity var(--t), transform var(--t), visibility var(--t); }
.model-popover.open { opacity: 1; visibility: visible; transform: none; }
.model-popover .control-label { display: none; }
.btn-hamb { display: none; width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0; align-items: center; justify-content: center; color: var(--text-2); border: 0; background: transparent; transition: background var(--t), transform var(--t), filter var(--t); }
.btn-hamb:hover { background: rgba(74, 168, 255, .06); transform: translateY(-1px); filter: drop-shadow(0 0 7px rgba(74, 168, 255, .35)); }
.btn-hamb:active { transform: scale(.94); }
.btn-hamb img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; display: block; opacity: .9; filter: drop-shadow(0 0 5px rgba(74, 168, 255, .32)); }

.model-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.model-trigger { display: inline-flex; align-items: center; gap: 8px; min-width: 142px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--text-1); font-size: 12.5px; font-weight: 600; text-align: left; transition: border-color var(--t), background var(--t); }
.model-trigger:hover, .model-trigger[aria-expanded='true'] { border-color: rgba(0,230,255,.4); background: transparent; }
.model-trigger-mark { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 9px var(--accent); }
.model-picker { display: grid; gap: 2px; }
.model-picker button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 2px; border: 0; border-radius: 0; color: var(--text-2); background: transparent; font-size: 13px; font-weight: 600; text-align: left; transition: color var(--t), transform var(--t), text-shadow var(--t); }
.model-picker button:hover { color: var(--text-1); background: transparent; transform: translateX(2px); }
.model-picker button.active { color: var(--text-1); background: transparent; text-shadow: 0 0 10px rgba(0,230,255,.3); }
.model-picker button:disabled { color: var(--text-3); cursor: not-allowed; opacity: .65; }
.model-picker button:disabled:hover { transform: none; }
.model-picker button::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.model-picker button.active::before { background: var(--accent); box-shadow: 0 0 9px var(--accent); }
.model-picker .mini { margin-left: auto; color: var(--text-3); font: 600 10px var(--font-mono); }
.model-drawer-section { margin-top: 0; }

.chip-status { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; font-size: 12px; color: var(--text-2); border: 1px solid var(--border); background: var(--surface-1); white-space: nowrap; }
.chip-status .dot { width: 7px; height: 7px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--text-2); border: 1px solid transparent; transition: background var(--t), color var(--t), border-color var(--t), transform var(--t); }
.icon-btn .ic { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-1); color: var(--text-1); border-color: var(--border); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.primary { width: auto; gap: 7px; padding: 0 13px; font-size: 13px; font-weight: 600; color: var(--text-1); }
.icon-btn.primary .ic { width: 15px; height: 15px; }

/* ============================================================
   MESSAGES
   ============================================================ */
#messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; }
.msgs-inner { max-width: 860px; min-height: 100%; margin: 0 auto; padding: 22px 20px 28px; display: flex; flex-direction: column; gap: 22px; }
/* Floats over the thread, centred, only while a reply is live and the reader
   has scrolled up. Makes "auto-follow paused" obvious instead of feeling like
   the chat froze at the bottom. */
.jump-latest {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  border: 1px solid rgba(74, 168, 255, .32);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-1);
  font: 600 11.5px var(--font-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow-2);
  animation: jumpIn 200ms var(--t);
}
.jump-latest:hover { border-color: rgba(0, 230, 255, .5); color: #fff; }
.jump-latest svg { animation: nudgeDown 1.4s ease-in-out infinite; }
@keyframes jumpIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes nudgeDown { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(2px); } }
@media (prefers-reduced-motion: reduce) { .jump-latest { animation: none; } .jump-latest svg { animation: none; } }
.msg-tokens:empty { display: none; }

/* hero / empty state */
.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 8vh 8px 28px; min-height: 68vh; transform: translateY(7vh);
  user-select: none; -webkit-user-select: none; caret-color: transparent;
}
.empty-state * { user-select: none; -webkit-user-select: none; caret-color: transparent; }
.orb-wrap { position: relative; width: 168px; height: 148px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.orb { position: relative; width: 124px; height: 124px; }
.orb .ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 34%, var(--accent) 50%, var(--accent-2) 64%, transparent 78% 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1.4px), #000 calc(100% - 1.1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 1.4px), #000 calc(100% - 1.1px));
  opacity: 0.85;
}
.orb .core {
  position: absolute; inset: 15px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, var(--accent-2), transparent 58%), radial-gradient(circle at 72% 70%, var(--accent), transparent 62%);
  filter: blur(8px); opacity: 0.78; box-shadow: inset 0 0 18px rgba(255,255,255,.12), 0 0 34px var(--accent-glow);
  animation: corePulse 4.5s ease-in-out infinite;
}
@keyframes corePulse { 0%, 100% { transform: scale(.92); opacity: .64; } 50% { transform: scale(1.04); opacity: .9; } }
.orb .dash { position: absolute; inset: 0; border-radius: 50%; border: 1px dashed var(--border-hi); }
.orb-glow { position: absolute; inset: -40px; border-radius: 50%; background: radial-gradient(circle, var(--accent-glow), var(--accent-2-glow) 45%, transparent 70%); filter: blur(30px); }
.hero-title {
  font-family: "Orbitron", sans-serif; font-weight: 900; font-size: clamp(38px, 7vw, 64px);
  letter-spacing: 10px; line-height: 1.1; text-transform: uppercase;
  color: #fff; position: relative; animation: heroGlitch 2s infinite;
  text-shadow: 0 0 5px rgba(0, 255, 255, .5);
}
.hero-title::before, .hero-title::after { content: attr(data-text); position: absolute; inset: 0; pointer-events: none; }
.hero-title::before { color: #00e6ff; z-index: -1; animation: heroGlitchOne .5s infinite; }
.hero-title::after { color: #ff00ea; z-index: -2; animation: heroGlitchTwo .5s infinite; }
@keyframes heroGlitch { 0%, 100% { text-shadow: 0 0 5px rgba(0,255,255,.5); } 50% { text-shadow: 0 0 20px rgba(255,0,234,.5); } }
@keyframes heroGlitchOne { 0%, 100% { clip: rect(42px, 9999px, 44px, 0); transform: translate(0); } 50% { clip: rect(12px, 9999px, 59px, 0); transform: translate(-2px, -2px); } }
@keyframes heroGlitchTwo { 0%, 100% { clip: rect(12px, 9999px, 85px, 0); transform: translate(0); } 50% { clip: rect(78px, 9999px, 93px, 0); transform: translate(2px, 2px); } }
.hero-tag {
  margin-top: 11px; font-family: "Orbitron", sans-serif; font-size: 15px; font-weight: 500;
  letter-spacing: .22em; text-transform: uppercase;
  background: linear-gradient(90deg, #7d8cff, #ff00ea);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-sub { margin-top: 6px; max-width: 460px; font-family: "Exo 2", Inter, sans-serif; font-size: 14px; letter-spacing: .12em; color: var(--text-3); line-height: 1.5; }

.sugg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 34px; width: 100%; max-width: 720px; }
.sugg-card {
  display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 7px;
  padding: 15px 15px 13px; border-radius: var(--radius-lg);
  background: var(--surface-1); border: 1px solid var(--border);
  position: relative; overflow: hidden;
  transition: transform var(--t-slow), border-color var(--t-slow), background var(--t-slow), box-shadow var(--t-slow);
}
.sugg-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity var(--t-slow);
}
.sugg-card:hover { transform: translateY(-3px); background: var(--surface-2); border-color: transparent; box-shadow: var(--shadow-2); }
.sugg-card:hover::before { opacity: 0.55; }
.sugg-card .sc-icon { width: 33px; height: 33px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--accent); background: var(--accent-glow); margin-bottom: 2px; }
.sugg-card .sc-icon.v { color: var(--accent-2); background: var(--accent-2-glow); }
.sugg-card .sc-icon .ic { width: 16px; height: 16px; }
.sugg-card .sc-title { font-size: 13.5px; font-weight: 600; color: var(--text-1); }
.sugg-card .sc-desc { font-size: 12px; color: var(--text-3); line-height: 1.5; }

/* messages */
.msg { display: flex; gap: 13px; animation: msgIn 220ms var(--t); position: relative; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; margin-top: 22px; background: var(--surface-2); border: 1px solid var(--border-hi); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg.user .msg-avatar { display: none; }
.msg-body { max-width: min(82%, 720px); display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.msg.user .msg-body { align-items: flex-end; }

.msg-meta { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--text-3); min-height: 20px; flex-wrap: wrap; }
.msg.user .msg-meta { justify-content: flex-end; }
.msg-meta .who { font-weight: 600; color: var(--text-2); }
.msg-meta .sep { color: var(--border-hi); }
.msg-meta-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: 0 0 auto; }
.msg-actions { display: flex; gap: 2px; }
.msg.user .msg-actions { margin-left: 0; }
.act-btn { width: 28px; height: 28px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: var(--text-3); transition: background var(--t), color var(--t); }
.act-btn .ic { width: 13.5px; height: 13.5px; }
.act-btn:hover { background: var(--surface-2); color: var(--text-1); }

.msg-card { padding: 13px 16px; font-size: 14.5px; line-height: 1.72; color: var(--text-1); word-wrap: break-word; overflow-wrap: break-word; }
.msg.user .msg-card { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 16px 16px 5px 16px; box-shadow: var(--shadow-1); padding: 10px 14px; }
.msg.user .msg-card p { margin: 0; }
.msg.assistant .msg-card { padding: 0; }

.thinking-row { display: flex; flex-direction: column; gap: 0; padding: 2px 0 8px; }
.thinking-row[hidden] { display: none !important; }
.tp-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 2px 6px 2px 2px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .18s;
}
.tp-head:hover { background: var(--surface-2); }
.tp-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tp-timer {
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
}
.tp-chev { display: inline-flex; margin-left: auto; color: var(--text-3); transition: transform .2s ease; }
.tp-chev .ic { width: 15px; height: 15px; }
.thinking-row.open .tp-chev { transform: rotate(180deg); }
.tp-body { display: none; }
.thinking-row.open .tp-body { display: block; }
/* Light, low-contrast reasoning text: readable, never louder than the answer. */
.tp-text {
  margin: 6px 0 2px 30px;
  padding: 10px 13px;
  border-left: 2px solid var(--border-hi);
  border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--surface-1) 60%, transparent);
  color: var(--text-3);
  font-size: 12.8px;
  line-height: 1.68;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 340px;
  overflow-y: auto;
}
.tp-text > :first-child { margin-top: 0; }
.tp-text > :last-child { margin-bottom: 0; }
.tp-text code { font-size: 12px; }
.tp-idle { font-style: italic; opacity: .8; }
.thinking-row[data-state='live'] .thinking-label { color: var(--text-1); }
/* Finished: the ring stops spinning and only the quiet activity icon remains. */
.thinking-row[data-state='done'] .think-dots,
.thinking-row[data-state='done'] .think-dots::before,
.thinking-row[data-state='done'] .think-dots::after { animation: none; }
.thinking-row[data-state='done'] .think-dots { opacity: .3; }
.thinking-row[data-state='done'] .thinking-orbit { opacity: .85; }
.thinking-row[data-state='done'] .thinking-label { color: var(--text-2); }
.turn-note {
  margin: 2px 0 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(246,184,107,.28);
  background: rgba(246,184,107,.1);
  color: var(--text-2);
  font-size: 12.5px;
}
/* Failed / stopped turn: the row states what happened and carries the one
   action that helps, so the reader is never stranded on a dead turn. */
.turn-problem { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.turn-problem b { color: var(--text-1); }
.turn-stopped { border-color: rgba(145,220,255,.26); background: rgba(145,220,255,.08); }
.turn-retry {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 5px 11px;
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font: 600 11px var(--font-mono);
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .18s, border-color .18s, background .18s;
}
.turn-retry:hover { color: var(--text-1); border-color: rgba(0,230,255,.45); background: rgba(120,210,255,.08); }
.turn-retry .ic { width: 12px; height: 12px; }
.thinking-orbit { position: relative; width: 21px; height: 21px; flex: 0 0 21px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--accent); background: var(--accent-glow); border: 1px solid rgba(74,168,255,.22); transition: color .2s, background .2s, border-color .2s; }
/* The drawer is the only activity indicator, so it carries the icon for
   whatever is running right now. The ring sits behind that icon. */
.thinking-orbit .think-dots { position: absolute; inset: 0; margin: auto; }
.thinking-orbit .tp-icon { display: inline-flex; align-items: center; justify-content: center; position: relative; }
.thinking-orbit .tp-icon .ic { width: 12px; height: 12px; }
.thinking-orbit .think-dots { width: 13px; height: 13px; border-width: 1px; opacity: .55; }
.thinking-orbit .think-dots::before { inset: 2px; border-width: 1px; }
.thinking-orbit .think-dots::after { inset: 4px; border-width: 1px; }
.thinking-row[data-activity='web'] .thinking-orbit { color: var(--accent-2); background: var(--accent-2-glow); border-color: rgba(139,124,255,.3); }
.thinking-row[data-activity='shell'] .thinking-orbit { color: #f6b86b; background: rgba(246,184,107,.12); border-color: rgba(246,184,107,.28); }
.thinking-row[data-activity='code'] .thinking-orbit { color: #67e8b4; background: rgba(103,232,180,.11); border-color: rgba(103,232,180,.27); }
.thinking-row[data-activity='file'] .thinking-orbit { color: #f4a7d5; background: rgba(244,167,213,.11); border-color: rgba(244,167,213,.26); }
.thinking-row[data-activity='read'] .thinking-orbit { color: #8dd9ff; background: rgba(141,217,255,.11); border-color: rgba(141,217,255,.25); }.think-dots { position: relative; display: inline-block; width: 18px; height: 18px; border: 1.5px solid var(--border-hi); border-radius: 50%; }
.think-dots::before, .think-dots::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; border: 1.5px solid transparent; border-top-color: var(--accent); animation: spin 1s linear infinite; }
.think-dots::after { inset: 6px; border-top-color: var(--accent-2); animation-direction: reverse; animation-duration: .7s; }
.think-dots i { display: none; }
.think-dots i:nth-child(2) { animation-delay: 0.15s; }
.think-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes hop { 0%, 100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-3px); opacity: 1; } }
.thinking-label { font-size: 12.5px; font-weight: 550; color: var(--text-2); letter-spacing: .01em; animation: activityIn .2s ease both; }
@keyframes activityIn { from { opacity: .25; transform: translateX(-4px); } to { opacity: 1; transform: none; } }
.web-label { color: var(--accent-2); }

.stream-caret { display: inline-block; width: 8px; height: 15px; margin-left: 2px; vertical-align: -2px; border-radius: 2px; background: var(--accent); animation: caretBlink 0.9s steps(1) infinite; }
@keyframes caretBlink { 50% { opacity: 0; } }

.msg.error .msg-card { color: var(--err); background: var(--err-soft); border: 1px solid rgba(248, 113, 113, 0.28); border-radius: 12px; padding: 11px 14px; font-size: 13.5px; }

.attach-note { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 9px; font-size: 12px; color: var(--text-2); background: var(--surface-1); border: 1px solid var(--border-soft); }
.attach-note .ic { width: 13px; height: 13px; color: var(--accent); }
.thumb-inline { max-width: 220px; max-height: 140px; border-radius: 12px; border: 1px solid var(--border); display: block; margin-top: 4px; }

/* markdown */
.md p { margin: 7px 0; }
.md h1, .md h2, .md h3, .md h4 { font-weight: 700; color: var(--text-1); margin: 18px 0 8px; line-height: 1.35; letter-spacing: -0.01em; }
.md h1 { font-size: 22px; } .md h2 { font-size: 19px; } .md h3 { font-size: 16.5px; } .md h4 { font-size: 15px; }
.md ul, .md ol { margin: 8px 0; padding-left: 22px; }
.md li { margin: 3.5px 0; }
.md li::marker { color: var(--accent); }
.md a { color: var(--accent-strong); text-decoration: none; border-bottom: 1px solid rgba(74, 168, 255, 0.35); transition: border-color var(--t), color var(--t); }
.md a:hover { color: var(--text-1); border-bottom-color: var(--text-1); }
.md blockquote { margin: 10px 0; padding: 2px 14px; border-left: 2.5px solid var(--accent-2); background: var(--accent-2-glow); border-radius: 0 10px 10px 0; color: var(--text-2); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.md table { border-collapse: collapse; margin: 12px 0; width: 100%; font-size: 13px; }
.md thead th, .md tbody td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.md thead th { background: var(--surface-1); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); }
.md tr:nth-child(even) td { background: var(--surface-0); }

.md pre { position: relative; margin: 12px 0; border-radius: 12px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--border); }
.md pre .code-head { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; background: var(--surface-1); border-bottom: 1px solid var(--border-soft); }
.md pre .code-lang { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); font-family: var(--font-mono); }
.md pre .copy-code { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 7px; font-size: 11.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); transition: background var(--t), color var(--t); }
.md pre .copy-code .ic { width: 12px; height: 12px; }
.md pre .copy-code:hover { color: var(--text-1); background: var(--surface-1); }
.md pre code { display: block; padding: 13px 15px; font-family: var(--font-mono); font-size: 12.8px; line-height: 1.6; color: #DDE6F1; overflow-x: auto; }
html[data-theme='light'] .md pre code { color: #1F2937; }
.md :not(pre) > code { font-family: var(--font-mono); font-size: 0.86em; padding: 2px 6px; border-radius: 6px; background: var(--accent-glow); color: var(--accent-strong); }
.md img { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); }
.msg.user .file-chip { margin: 2px 0; background: rgba(255,255,255,.045); border-color: rgba(255,255,255,.12); text-align: left; }
.msg.user .file-chip .fc-sub { color: var(--text-3); }

/* Workspace controls and the optional command drawer. */
.side { position: relative; }
.side.is-collapsed { width: 78px; min-width: 78px; }
.side.is-collapsed .b-text, .side.is-collapsed .btn-new, .side.is-collapsed .side-scroll, .side.is-collapsed .status-row, .side.is-collapsed .side-action span:last-child, .side.is-collapsed .hist-label, .side.is-collapsed .ci-main, .side.is-collapsed .ci-menu { display: none; }
.side.is-collapsed { background: transparent; border-right-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; overflow: hidden; }
.side.is-collapsed .side-top { padding-inline: 0; }
.side.is-collapsed .brand { position: relative; justify-content: center; width: 100%; height: 58px; padding: 2px 0 14px; overflow: hidden; }
.side.is-collapsed .brand .mark { margin-inline: auto; }
.side.is-collapsed .side-action { justify-content: center; padding-inline: 0; }
.side.is-collapsed .side-collapse { transform: rotate(180deg); }
.side-collapse { margin-left: auto; width: 30px; height: 30px; opacity: 0; transition: opacity var(--t), background var(--t), transform var(--t); }
.side.is-collapsed .side-collapse { position: absolute; top: 6px; right: 3px; margin: 0; width: 24px; height: 24px; }
.brand:hover .side-collapse, .side-collapse:focus-visible { opacity: 1; }
.side-collapse .ic { width: 16px; height: 16px; }
.side::after { content: ''; position: absolute; z-index: 4; top: 0; right: -3px; width: 6px; height: 100%; cursor: col-resize; }
.controls-trigger { color: var(--accent-strong); }
.control-drawer { position: fixed; z-index: 1800; top: 0; right: 0; width: min(360px, 92vw); height: 100%; transform: translateX(105%); background: color-mix(in srgb, var(--bg-2) 96%, transparent); border-left: 1px solid var(--border-hi); box-shadow: -18px 0 50px rgba(0,0,0,.28); transition: transform var(--t-slow); }
.control-drawer.open { transform: none; }
.drawer-head { display: flex; align-items: flex-start; gap: 14px; padding: 24px 22px 19px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin-top: 4px; font: 600 22px var(--font-display); letter-spacing: -.02em; }
.drawer-head .icon-btn { margin-left: auto; }
.eyebrow { color: var(--accent-strong); font: 600 10px var(--font-mono); letter-spacing: .16em; }
.drawer-body { padding: 18px 22px; overflow-y: auto; height: calc(100% - 86px); }
.control-intro { display: flex; gap: 11px; padding: 13px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface-1); }
.control-intro b { font-size: 13px; }.control-intro p { color: var(--text-3); font-size: 11.5px; margin-top: 3px; line-height: 1.45; }
.control-pulse { width: 9px; height: 9px; flex: 0 0 auto; margin-top: 4px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 5px rgba(52,211,153,.12), 0 0 16px var(--ok); }
.control-section { margin-top: 24px; }.control-label { display: block; margin-bottom: 9px; color: var(--text-3); font: 600 10px var(--font-mono); letter-spacing: .12em; text-transform: uppercase; }
.seg-control { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-1); }.seg-control button { padding: 8px; border-radius: 8px; color: var(--text-3); font-size: 12px; }.seg-control button.active { color: var(--text-1); background: var(--surface-2); box-shadow: var(--shadow-1); }
.toggle-row, .drawer-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 0; border-bottom: 1px solid var(--border-soft); text-align: left; }.toggle-row b, .drawer-action b { display: block; font-size: 13px; font-weight: 600; }.toggle-row small, .drawer-action small { display: block; color: var(--text-3); font-size: 11px; margin-top: 2px; }.toggle-row input { display: none; }.toggle-row i { position: relative; width: 35px; height: 20px; border-radius: 99px; flex: 0 0 auto; background: var(--surface-2); border: 1px solid var(--border-hi); transition: background var(--t); }.toggle-row i::after { content: ''; position: absolute; width: 14px; height: 14px; top: 2px; left: 2px; border-radius: 50%; background: var(--text-3); transition: transform var(--t), background var(--t); }.toggle-row input:checked + i { background: var(--accent); border-color: var(--accent); }.toggle-row input:checked + i::after { transform: translateX(15px); background: #fff; }
.toggle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  min-height: 54px;
  padding: 11px 0;
  cursor: pointer;
  transition: border-color var(--t), color var(--t), background var(--t);
}
.toggle-row .toggle-copy {
  display: block;
  min-width: 0;
  width: 100%;
  padding-right: 12px;
  overflow-wrap: anywhere;
}
.toggle-row .toggle-copy b,
.toggle-row .toggle-copy small {
  display: block;
  overflow-wrap: anywhere;
}
.toggle-row:hover { border-bottom-color: var(--border-hi); }
.toggle-row:hover > span:first-child b { color: var(--text-1); }
.toggle-row .toggle-switch {
  position: relative;
  grid-column: 2;
  justify-self: end;
  flex: none;
  width: 38px;
  height: 22px;
  padding: 2px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.18);
  transition: background var(--t), border-color var(--t), box-shadow var(--t);
}
.toggle-row .toggle-switch::after {
  width: 16px;
  height: 16px;
  top: 2px;
  left: 2px;
  background: var(--text-3);
  box-shadow: 0 2px 5px rgba(0,0,0,.3);
  transition: transform var(--t), background var(--t), box-shadow var(--t);
}
.toggle-row input:checked + .toggle-switch {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--accent-glow), 0 3px 9px var(--accent-glow);
}
.toggle-row input:checked + .toggle-switch::after {
  transform: translateX(16px);
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.28);
}
.toggle-row input:focus-visible + .toggle-switch {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}
.toggle-row:has(input:checked) .toggle-copy b { color: var(--text-1); }
@media (max-width: 560px) {
  .toggle-row { min-height: 58px; }
  .toggle-row small { max-width: 220px; line-height: 1.35; }
}
.drawer-action { color: var(--text-2); border: 0; }.drawer-action:hover { color: var(--text-1); }.drawer-action .ic { width: 16px; color: var(--text-3); }
@media (max-width: 1023px) { .side::after { display: none; } }