:root {
  --void: #080406;
  --wine: #14080C;
  --wine-deep: #5C1528;
  --sormeyi: #7A1F3A;
  --sormeyi-bright: #9B2D4A;
  --gold: #D4AF37;
  --gold-bright: #F0D78A;
  --champagne: #F6E8D2;
  --ink: #14080C;
  --ink-soft: #C9B08A;
  --bg: #12080C;
  --bg-elev: #1A0D12;
  --surface: #231016;
  --surface-alt: #2C141C;
  --border: rgba(212, 175, 55, 0.16);
  --text: #F7EBD8;
  --muted: #C4A888;
  --brand: #7A1F3A;
  --brand-2: #D4AF37;
  --accent: #D4AF37;
  --good: #D4AF37;
  --danger: #E07070;
  --user: #4A1422;
  --shadow: 0 28px 80px rgba(4, 1, 3, 0.62);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 18px;
  --display: "Plus Jakarta Sans", "Noto Sans Arabic", "Segoe UI", sans-serif;
  --serif: "Plus Jakarta Sans", "Noto Sans Arabic", "Segoe UI", sans-serif;
  --ui: "Plus Jakarta Sans", "Noto Sans Arabic", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --font: var(--ui);
  --text-size: 16px;
  --pane-w: 42%;
}
[data-theme="light"] {
  --bg: #F7EFE2;
  --bg-elev: #F3E6D0;
  --surface: #FFF8EC;
  --surface-alt: #F4E6D0;
  --border: #E0C48A;
  --text: #2A0E16;
  --muted: #7A1F3A;
  --brand: #7A1F3A;
  --brand-2: #D4AF37;
  --accent: #B8860B;
  --ink: #2A0E16;
  --ink-soft: #6E1B33;
  --user: #F0D9A8;
  --shadow: 0 18px 48px rgba(42, 14, 22, 0.12);
  --good: #7A1F3A;
  --champagne: #2A0E16;
}
[data-text="sm"] { --text-size: 14px; }
[data-text="md"] { --text-size: 16px; }
[data-text="lg"] { --text-size: 20px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html {
  font-size: var(--text-size);
}
html, body {
  margin: 0; height: 100%;
  max-width: 100%;
  overflow-x: clip;
  background: var(--bg); color: var(--text);
  font-family: var(--ui);
  font-size: var(--text-size);
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, textarea, .nav-btn, .tier-chip, .settings-row { font-family: var(--ui); font-size: inherit; }
button { cursor: pointer; }
#root { min-height: 100dvh; }

.screen { min-height: 100dvh; display: flex; flex-direction: column; }
.center { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }

.splash { background:
  radial-gradient(900px 520px at 50% -8%, rgba(212,175,55,0.22), transparent 58%),
  radial-gradient(640px 380px at 12% 110%, rgba(122,31,58,0.45), transparent 52%),
  var(--bg);
  text-align: center;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.brand-logo { display: block; object-fit: contain; }
.brand-logo.lockup { width: 200px; height: auto; margin: 0 auto 4px; }
.brand-logo.mark { width: 40px; height: 40px; margin: 0 auto; }
.brand-mark .brand-logo.mark { width: 32px; height: 32px; margin: 0; flex-shrink: 0; }
.auth-card .brand-logo.mark { margin-bottom: 4px; }
.empty .brand-logo.mark { width: 56px; height: 56px; }
.legal-brand { margin: 0 0 18px; }
.legal-brand img { width: 160px; height: auto; display: block; }
@media (max-width: 480px) {
  .brand-logo.lockup { width: 168px; }
}
.splash h1 {
  font-family: var(--display); font-size: 42px; letter-spacing: 0.02em;
  margin: 18px 0 6px; font-weight: 700;
}
.splash .tag {
  font-family: var(--ui); color: var(--accent); letter-spacing: 0.12em;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.splash .sub { color: var(--muted); margin-top: 10px; font-size: 17px; }
.splash-actions {
  display: flex; flex-direction: column; gap: 10px;
  width: min(360px, 92vw); margin: 28px auto 0; text-align: center;
}
.splash-actions .btn { width: 100%; justify-content: center; }

.card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
  position: relative;
}
.card.auth-card::before {
  content: "";
  position: absolute; left: 22px; right: 22px; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.card h2 { margin: 0 0 6px; font-size: 26px; font-family: var(--display); font-weight: 650; }
.card p.lead { color: var(--muted); margin: 0 0 22px; font-size: 0.95rem; line-height: 1.55; }
.lead { font-size: 1rem; color: var(--muted); }
label { display: block; font-family: var(--ui); font-size: 12px; color: var(--muted); margin: 12px 0 6px; letter-spacing: 0.4px; font-weight: 700; }
.input {
  width: 100%; background: var(--surface-alt); border: 1px solid var(--border);
  color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 1rem;
  font-family: var(--ui);
}
.input:focus { outline: 2px solid rgba(212,175,55,0.45); border-color: var(--gold); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: auto; border: none; border-radius: 12px; padding: 12px 16px;
  font-weight: 700; font-size: 0.95rem; transition: transform .18s var(--ease), opacity .18s;
}
.card .btn,
.splash-actions .btn,
.oauth .btn,
.settings .btn,
.auth-card .btn { width: 100%; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--gold); color: var(--ink); margin-top: 16px; }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); margin-top: 10px; }
.btn-ghost { background: transparent; color: var(--muted); margin-top: 8px; }
.btn-danger { background: rgba(184,92,74,0.12); color: var(--danger); border: 1px solid rgba(184,92,74,0.3); }
.btn-gold { background: var(--accent); color: var(--ink); margin-top: 10px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; font-family: var(--ui); }
.link { color: var(--gold); text-decoration: none; font-size: 13px; font-family: var(--ui); font-weight: 700; }
.oauth .btn { justify-content: flex-start; padding-left: 16px; }
.oauth .btn svg { flex: 0 0 auto; }
.row-between { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.oauth { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; font-family: var(--ui); }
.divider:before, .divider:after { content: ""; flex: 1; height: 1px; background: var(--border); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--surface-alt); color: var(--text);
  border-radius: 999px; padding: 8px 14px; font-size: 0.82rem; font-weight: 650;
}
.chip[data-sz="sm"] { font-size: 13px; }
.chip[data-sz="md"] { font-size: 16px; }
.chip[data-sz="lg"] { font-size: 21px; }
.chip.on { border-color: var(--gold); background: rgba(212,175,55,0.18); color: var(--text); }
.chip.gold.on { border-color: var(--accent); background: rgba(212,175,55,0.18); color: var(--text); }
[data-theme="dark"] .chip.on { color: var(--text); }

.app-shell { height: 100dvh; display: grid; grid-template-columns: 268px minmax(0, 1fr); }
.sidebar {
  position: relative;
  border-right: 1px solid rgba(212,175,55,0.12);
  background:
    linear-gradient(180deg, rgba(240,215,138,0.08), transparent 160px),
    linear-gradient(180deg, rgba(20,8,12,0.2), transparent 40%),
    color-mix(in srgb, var(--bg-elev) 88%, #000);
  display: flex; flex-direction: column; padding: 16px 12px 12px;
  backdrop-filter: blur(18px);
}
.sidebar::after {
  content: "";
  position: absolute; inset: 0 auto 0 0; width: 1px;
  background: linear-gradient(180deg, rgba(240,215,138,0.35), transparent 42%, transparent);
  pointer-events: none;
}
.brand-mark {
  display: flex; align-items: center; gap: 10px;
  width: 100%; background: none; border: none; color: inherit;
  padding: 2px 8px 14px; text-align: left; cursor: pointer;
}
.brand-mark strong { font-family: var(--display); letter-spacing: 0.08em; font-size: 19px; font-weight: 650; }
.brand-mark small { display: block; font-family: var(--ui); color: var(--accent); letter-spacing: 0.22em; font-size: 8px; font-weight: 700; }
.nav-search { position: relative; margin: 0 2px 10px; z-index: 4; }
.nav-search-box {
  display: flex; align-items: center; gap: 8px; margin: 0;
  padding: 0 10px; height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(212,175,55,0.22);
  background: color-mix(in srgb, var(--void) 55%, var(--surface));
  box-shadow: inset 0 1px 0 rgba(255,236,200,0.06);
}
.nav-search-box:focus-within {
  border-color: rgba(212,175,55,0.55);
  box-shadow: 0 0 0 3px rgba(212,175,55,0.12), inset 0 1px 0 rgba(255,236,200,0.08);
}
.nav-search-ico { width: 15px; height: 15px; color: var(--gold); flex: none; opacity: 0.85; }
.nav-search-q {
  flex: 1; min-width: 0; height: 36px; padding: 0;
  border: none; background: transparent; color: var(--text);
  font: 600 13px var(--ui); letter-spacing: 0.01em;
}
.nav-search-q:focus { outline: none; }
.nav-search-q::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); font-weight: 550; }
.nav-search-kbd {
  flex: none; padding: 2px 6px;
  border: 1px solid rgba(212,175,55,0.22); border-radius: 6px;
  color: var(--muted); font: 650 10px var(--mono); letter-spacing: 0.04em;
}
.nav-search-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  max-height: min(58vh, 420px); overflow: auto;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid rgba(212,175,55,0.2);
  background: color-mix(in srgb, var(--bg-elev) 92%, #000);
  box-shadow: 0 22px 50px rgba(4,1,3,0.5);
}
.nav-search-menu[hidden] { display: none; }
.nav-search-hit {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  width: 100%; text-align: start;
  border: none; border-radius: 10px; padding: 8px 10px;
  background: transparent; color: var(--text); cursor: pointer;
}
.nav-search-hit:hover, .nav-search-hit.on {
  background: rgba(212,175,55,0.1);
}
.nav-search-hit strong { font-size: 13px; font-weight: 650; }
.nav-search-hit small { grid-column: 1; color: var(--muted); font-size: 11px; }
.nav-search-hit em {
  grid-column: 2; grid-row: 1 / span 2; align-self: center;
  font-style: normal; color: var(--gold); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700;
}
.nav-search-empty { margin: 8px 10px; color: var(--muted); font-size: 12px; }
.nav-new {
  width: calc(100% - 4px); margin: 0 2px 14px; padding: 9px 14px;
  border-radius: 12px; border: 1px solid rgba(212,175,55,0.38);
  background: linear-gradient(180deg, rgba(212,175,55,0.12), rgba(212,175,55,0.04));
  color: var(--gold); font-weight: 650; letter-spacing: 0.03em;
}
.nav-new:hover { background: rgba(212,175,55,0.16); border-color: var(--gold); }
.nav-label {
  margin: 2px 10px 6px; color: var(--gold);
  font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
}
.nav-cluster { display: flex; flex-direction: column; gap: 1px; margin-bottom: 14px; }
.nav-btn {
  display: flex; align-items: center; gap: 12px;
  text-align: left; background: transparent; border: none; color: var(--muted);
  padding: 8px 12px; border-radius: 11px; font-size: 0.9rem; font-weight: 600;
}
.nav-btn svg { width: 16px; height: 16px; flex: none; opacity: 0.72; }
.nav-btn.active, .nav-btn:hover { background: rgba(212,175,55,0.08); color: var(--text); }
.nav-btn.active { color: var(--champagne); }
.nav-btn.active svg, .nav-btn:hover svg { opacity: 1; color: var(--gold); }
.nav-btn.running .nav-pulse {
  margin-inline-start: auto;
  width: 7px; height: 7px; border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 0 0 rgba(212,175,55,0.5);
  animation: navPulse 1.6s ease-out infinite;
}
@keyframes navPulse {
  70% { box-shadow: 0 0 0 8px rgba(212,175,55,0); }
}
.nav-empty { margin: 8px 12px; color: var(--muted); font-size: 0.8rem; }
.nav-foot {
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid rgba(212,175,55,0.14);
  display: flex; flex-direction: column; gap: 2px;
}
.devices-wrap { padding: 8px 20px 32px; max-width: 820px; }
.device-grid { display: grid; gap: 12px; margin: 16px 0 24px; }
.device-card {
  padding: 16px; border-radius: 16px;
  border: 1px solid rgba(212,175,55,0.18);
  background: var(--surface);
}
.device-card header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.device-code { font-size: 1.15rem; letter-spacing: 0.08em; }
.device-code-box {
  margin: 16px 0; padding: 16px; border-radius: 16px;
  border: 1px solid rgba(212,175,55,0.28); background: var(--surface);
}
.device-code-box strong { font-family: var(--mono, inherit); }
.device-steps { margin: 10px 0 4px; color: var(--muted); }
.device-jobs { list-style: none; padding: 0; display: grid; gap: 8px; }
.device-job {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border);
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.row-actions .btn,
.topbar .btn,
.quiz-actions .btn,
.quiz-tools .btn,
.page-back { width: auto; margin-top: 0; }
.nav-project {
  width: 100%; margin: 0 0 8px; padding: 8px 10px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 0.8rem;
}
.conv-list { flex: 1; overflow: auto; margin-top: 0; min-height: 0; }
.conv-row {
  display: flex; align-items: stretch; gap: 2px;
  border-radius: 10px; margin-bottom: 4px;
}
.conv-row.on { background: var(--surface); }
.conv-item {
  flex: 1; min-width: 0; text-align: left; background: transparent; border: none;
  color: var(--text); padding: 10px 12px; border-radius: 10px;
  font-family: var(--ui); font-size: 0.9rem;
}
.conv-item small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; font-family: var(--ui); }
.conv-row:hover, .conv-item:hover { background: var(--surface); }
.conv-actions {
  display: none; flex-direction: column; justify-content: center; gap: 2px; padding: 4px 4px 4px 0;
}
.conv-row:hover .conv-actions, .conv-row.on .conv-actions { display: flex; }
.conv-act {
  width: 26px; height: 22px; border: none; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer;
}
.conv-act:hover { color: var(--text); background: var(--surface-alt); }
.conv-act.danger:hover { color: var(--danger); }
.task-tabs {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px 0;
  overflow-x: auto; border-bottom: 1px solid var(--border);
  min-height: 40px;
}
.task-tab {
  display: inline-flex; align-items: center; gap: 6px; max-width: 180px;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  border-radius: 10px 10px 0 0; padding: 6px 8px; font-family: var(--ui); font-size: 12px; font-weight: 650;
  white-space: nowrap;
}
.task-tab.on { color: var(--text); background: var(--surface); border-color: var(--border); border-bottom-color: transparent; }
.task-tab:hover { color: var(--text); background: var(--surface); }
.task-tab.running .task-dot { background: var(--gold); box-shadow: 0 0 0 3px rgba(212,175,55,0.22); }
.task-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); flex: none; }
.task-label {
  background: none; border: none; color: inherit; font: inherit; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.task-x {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px;
}
.task-x:hover { color: var(--danger); }
.task-tab.add { max-width: none; padding: 6px 10px; font-size: 16px; }

.main {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background:
    radial-gradient(980px 460px at 50% -18%, rgba(240,215,138,0.12), transparent 58%),
    radial-gradient(720px 400px at 100% 118%, rgba(122,31,58,0.22), transparent 52%),
    var(--bg);
}
.main.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr;
}
.main.workspace.pane-open {
  grid-template-columns: minmax(280px, 1fr) 6px var(--pane-w);
}
.chat-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; overflow: hidden; }
.chat-col-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 22px; border-bottom: 1px solid rgba(212,175,55,0.1);
  font-family: var(--ui);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
}
.topbar strong { font-family: var(--display); font-weight: 650; font-size: 1.05rem; }
.topbar-start { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-end { display: flex; align-items: center; gap: 8px; }
.page-back {
  flex: 0 0 auto; padding: 6px 10px; font-size: 0.82rem;
  border: 1px solid rgba(212,175,55,0.28); border-radius: 999px;
}
.pill {
  font-family: var(--ui); font-size: 11px; letter-spacing: 0.12em; font-weight: 700;
  color: var(--accent); border: 1px solid rgba(212,175,55,0.45);
  padding: 4px 9px; border-radius: 999px;
}
.pill.good { color: var(--gold); border-color: rgba(212,175,55,0.45); }

.chat { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 0 10px; }
.chat-inner { max-width: 780px; margin: 0 auto; padding: 0 22px; }
.msg { display: flex; margin: 12px 0; }
.msg.user { justify-content: flex-end; }
.msg-stack { display: flex; flex-direction: column; max-width: 88%; min-width: 0; }
.msg.user .msg-stack { align-items: flex-end; }
.msg.assistant .msg-stack { align-items: flex-start; }
.bubble {
  max-width: 100%; border-radius: var(--radius); padding: 13px 16px;
  font-size: var(--text-size); line-height: 1.65; overflow-wrap: anywhere;
}
.msg.assistant .bubble { max-width: 46rem; }
.msg-body { max-width: 100%; }
.msg-body p:first-child { margin-top: 0; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-spell { font-size: 12px; color: var(--muted); margin-top: 2px; }
.msg-copy {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.msg-copy:hover, .msg-copy:focus-visible {
  color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, transparent);
  outline: none;
}
.msg-copy .msg-copy-check { display: none; }
.msg-copy.copied { color: var(--gold); }
.msg-copy.copied .msg-copy-icon { display: none; }
.msg-copy.copied .msg-copy-check { display: block; }
@media (hover: hover) and (pointer: fine) {
  .msg-actions { opacity: 0; transition: opacity 0.15s var(--ease); }
  .msg:hover .msg-actions, .msg:focus-within .msg-actions, .msg-actions:has(.copied) { opacity: 1; }
}
.msg.assistant .bubble {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid rgba(212,175,55,0.14);
  box-shadow: 0 10px 28px rgba(4,1,3,0.18);
}
.msg.user .bubble {
  background: linear-gradient(180deg, color-mix(in srgb, var(--user) 88%, #7A1F3A), var(--user));
  border: 1px solid rgba(212,175,55,0.12);
}
.bubble .katex { font-size: 1.08em; }
.bubble .eq { margin: 14px 0; overflow-x: auto; text-align: center; }
.bubble .eq-i { direction: ltr; unicode-bidi: isolate; }
.bubble h2, .bubble h3, .bubble h4 { font-family: var(--display); margin: 14px 0 8px; line-height: 1.3; }
.bubble h4 { font-size: 1.02em; font-weight: 650; }
.bubble ul, .bubble ol { margin: 8px 0; padding-inline-start: 1.35em; }
.bubble ul ul, .bubble ol ol, .bubble ul ol, .bubble ol ul { margin: 4px 0; }
.bubble .task { display: flex; align-items: flex-start; gap: 8px; }
.bubble .md-table { overflow-x: auto; margin: 12px 0; -webkit-overflow-scrolling: touch; }
.bubble table {
  width: 100%; border-collapse: collapse; font-size: 0.94em;
  background: var(--surface-alt, transparent);
}
.bubble th, .bubble td {
  border: 1px solid var(--border); padding: 7px 10px; text-align: start; vertical-align: top;
}
.bubble th { font-family: var(--ui); font-weight: 700; background: color-mix(in srgb, var(--gold) 12%, var(--surface)); }
.bubble tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--gold) 5%, transparent); }
.bubble td { font-variant-numeric: tabular-nums; }
.bubble td.num { text-align: end; }
.bubble blockquote {
  margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--gold); color: var(--ink-soft);
}
.bubble blockquote.callout {
  border-radius: 12px; border: 1px solid var(--border); border-left-width: 3px;
}
.bubble .callout-note { border-left-color: var(--gold); }
.bubble .callout-tip { border-left-color: #3c9a6b; }
.bubble .callout-warning, .bubble .callout-caution { border-left-color: #d4a017; }
.bubble .footnotes { margin-top: 16px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 0.88em; color: var(--muted); }
.bubble a { color: var(--gold); }
.code-block {
  margin: 10px 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: #12080C;
}
.code-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; background: color-mix(in srgb, var(--gold) 10%, #12080C);
  font-family: var(--ui);
}
.code-lang { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.code-block .code { margin: 0; border-radius: 0; }
.code {
  font-family: var(--mono); font-size: 13.5px; background: #12080C; color: #F4E6D0;
  border-radius: 12px; padding: 12px; overflow: auto; margin: 10px 0; white-space: pre;
}
.code .tok-k { color: #E6B84B; }
.code .tok-s { color: #9ad0b1; }
[data-theme="dark"] .code, [data-theme="dark"] .code-block { background: #151A16; }
[data-theme="dark"] .code-head { background: color-mix(in srgb, var(--gold) 10%, #151A16); }
[data-theme="light"] .code-block { background: #2A0E16; }
.copy { background: transparent; border: none; color: var(--gold); font-size: 12px; font-family: var(--ui); cursor: pointer; }
[dir="rtl"] .bubble .eq,
[dir="rtl"] .bubble .eq-i,
[dir="rtl"] .bubble .katex,
[dir="rtl"] .bubble .code-block,
[dir="rtl"] .bubble pre.code { direction: ltr; unicode-bidi: isolate; text-align: left; }
.bubble pre.schematic, .bubble pre.code.schematic {
  background: #12080C; border: 1px solid #e6b84b55; color: #f4e6d0; white-space: pre; line-height: 1.35;
}
[data-theme="light"] .bubble pre.schematic, [data-theme="light"] .bubble pre.code.schematic {
  background: #2A0E16; color: #F4E6D0;
}
.bubble p { margin: 8px 0; }
.msg.assistant .bubble:empty { min-height: 48px; }

.msg-attach {
  margin-top: 10px; display: flex; flex-direction: column; gap: 8px;
  width: 100%; max-width: 420px;
}
.msg-attach-img {
  width: 100%; max-height: 320px; object-fit: contain;
  border-radius: 12px; border: 1px solid var(--border); background: #fff;
}
.msg-attach-pdf .wb-pdf, .msg-attach-frame .wb-pdf {
  min-height: 280px; height: 42vh; width: 100%;
  border: 1px solid var(--border); border-radius: 12px; background: #fff;
}
.msg-attach-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.msg-attach .fig-chip { margin-top: 0; }
.zip-list {
  margin: 0; padding: 10px 16px; width: 100%;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font-size: 13px; text-align: start;
}
.zip-list li { margin: 4px 0; }
.fig-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 10px; padding: 7px 12px;
  border: 1px solid var(--border); background: var(--surface-alt);
  border-radius: 999px; color: var(--ink-soft); font-family: var(--ui);
  font-size: 13px; font-weight: 700;
}
.fig-chip:hover { border-color: var(--gold); color: var(--text); }
.fig-chip .fig-kind { color: var(--gold); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

.art-strip { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.art-card {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); background: var(--surface-alt);
  border-radius: 14px; text-align: start;
}
.art-card:hover { border-color: var(--gold); }
.art-card.is-error { border-color: color-mix(in srgb, #c45c5c 50%, var(--border)); }
.art-thumb {
  width: 44px; height: 44px; border-radius: 10px; background: #0b1733; color: #e6b84b;
  display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 18px;
}
.art-thumb img { width: 100%; height: 100%; object-fit: cover; }
.art-meta { min-width: 0; }
.art-meta strong { display: block; font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.art-meta span { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.art-trust {
  display: inline-block; margin-inline-start: 6px; font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: #0b1733; background: #e6b84b; border-radius: 999px; padding: 1px 7px; font-weight: 700;
}
.art-actions { display: flex; gap: 6px; flex-shrink: 0; }
.art-actions button, .art-actions a {
  font-family: var(--ui); font-size: 12px; font-weight: 700; border-radius: 999px; padding: 6px 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
}
.art-actions .art-open { background: #e6b84b; color: #0b1733; border-color: #e6b84b; }
.art-skel { opacity: 0.72; }
.art-skel .art-thumb { animation: art-pulse 1.1s ease-in-out infinite; }
@keyframes art-pulse { 50% { opacity: 0.45; } }
.art-viewer {
  position: fixed; inset: 0; background: rgba(8, 12, 24, 0.82); z-index: 60;
  display: flex; flex-direction: column; padding: 12px;
}
.art-viewer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  color: #f4e6d0; padding: 4px 8px 10px;
}
.art-viewer-head h2 { margin: 0; font-size: 16px; font-weight: 650; color: #e6b84b; }
.art-viewer-body {
  flex: 1; min-height: 0; background: #0b1733; border: 1px solid #e6b84b33; border-radius: 16px; overflow: auto;
  display: flex; flex-direction: column;
}
.art-viewer-body img, .art-viewer-body iframe, .art-viewer-body canvas { width: 100%; height: 100%; border: 0; }
.art-viewer-body pre {
  margin: 0; padding: 16px; color: #f4e6d0; font-family: var(--mono); font-size: 13px; white-space: pre-wrap;
}
.art-viewer-body table { width: 100%; border-collapse: collapse; color: #f4e6d0; font-size: 13px; }
.art-viewer-body td, .art-viewer-body th { border: 1px solid #e6b84b33; padding: 6px 8px; }
.art-group { display: flex; flex-direction: column; gap: 6px; }
[dir="rtl"] .art-card { text-align: start; }
[dir="rtl"] .art-actions { flex-direction: row-reverse; }

.empty { text-align: center; padding: 64px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin: 14px 0 8px; font-size: 22px; font-family: var(--display); font-weight: 650; }

.composer-wrap {
  flex: 0 0 auto;
  position: sticky; bottom: 0; z-index: 6;
  border-top: 1px solid rgba(212,175,55,0.1);
  padding: 14px 18px 20px;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--bg-elev) 92%, #000) 28%);
}
.composer {
  max-width: 780px; margin: 0 auto;
  display: flex; gap: 8px; align-items: flex-end;
  background: color-mix(in srgb, var(--surface) 90%, #000);
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: 24px;
  padding: 8px 8px 8px 12px;
  box-shadow: 0 16px 40px rgba(4, 1, 3, 0.32), inset 0 1px 0 rgba(255,236,200,0.06);
}
.composer:focus-within {
  border-color: rgba(212,175,55,0.48);
  box-shadow: 0 0 0 4px rgba(212,175,55,0.1), 0 16px 40px rgba(4, 1, 3, 0.32);
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; background: transparent;
  border: none; color: var(--muted); font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--gold); background: rgba(212,175,55,0.08); }
.icon-btn.live {
  color: var(--gold); background: rgba(122,31,58,0.55);
  box-shadow: 0 0 0 3px rgba(212,175,55,0.22);
  animation: pulse-mic 1.2s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 3px rgba(212,175,55,0.18); }
  50% { box-shadow: 0 0 0 7px rgba(212,175,55,0.08); }
}
.ta {
  flex: 1; min-height: 40px; max-height: 78vh; resize: none;
  background: transparent; border: none; color: var(--text);
  border-radius: 14px; padding: 10px 8px; font-size: var(--text-size);
  font-family: var(--ui);
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45;
  overflow-y: hidden;
}
.ta:focus { outline: none; }
.send {
  width: 40px; height: 40px; border-radius: 20px; border: none;
  background: var(--gold); color: var(--ink); font-size: 20px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  flex: 0 0 40px;
}
.send .send-glyph { width: 18px; height: 18px; display: block; }
.send.is-stop {
  border-radius: 10px;
  background: var(--sormeyi);
  color: #f8efe4;
}
.send.is-stop .send-glyph { width: 13px; height: 13px; }
.send:disabled { opacity: 0.45; cursor: default; }
.icon-btn svg { display: block; }
.file-chip {
  max-width: 760px; margin: 0 auto 8px; display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; font-family: var(--ui);
}
.thumb-row { max-width: 760px; margin: 0 auto 8px; display: flex; align-items: center; gap: 8px; }
.thumb-row img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }
.composer-meta {
  max-width: 760px; margin: 0 auto 8px; display: flex; align-items: center; gap: 8px;
}
.composer-meta .pdf-btn {
  margin-left: auto; border: 1px solid var(--border); background: var(--surface);
  color: var(--gold); border-radius: 999px; padding: 6px 12px;
  font-size: 12px; font-weight: 700; font-family: var(--ui);
}
.composer-meta .pdf-btn:disabled { opacity: 0.45; }
.tier-chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700;
}
.tier-chip small { color: var(--muted); font-weight: 600; margin-left: 6px; }

/* Workbench — figures & files, Cursor-style right pane */
.pane-resize {
  cursor: col-resize; background: var(--border); width: 6px; min-width: 6px;
  border: none; padding: 0; align-self: stretch;
}
.pane-resize:hover, .pane-resize:focus { background: var(--gold); }
.workbench {
  min-width: 0; min-height: 0; height: 100%;
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
}
.wb-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.wb-head h2 {
  margin: 0; font-family: var(--display); font-size: 16px; font-weight: 650;
}
.wb-head .wb-sub { display: block; font-family: var(--ui); font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: 0.04em; }
.wb-tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.wb-tab {
  flex: 0 0 auto; border: 1px solid transparent; background: transparent;
  color: var(--muted); border-radius: 8px; padding: 6px 10px;
  font-size: 12px; font-weight: 700; max-width: 160px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wb-tab.on { background: var(--surface); border-color: var(--border); color: var(--text); }
.wb-body {
  flex: 1; min-height: 0; overflow: auto; padding: 16px;
  display: flex; align-items: flex-start; justify-content: center;
}
.wb-figure {
  width: 100%; background: #fff; border-radius: 12px; border: 1px solid var(--border);
  display: block;
}
.wb-pdf {
  width: 100%; height: 100%; min-height: 420px; border: 0; background: #fff; border-radius: 8px;
}
.sim-frame-wrap { width: 100%; height: 100%; min-height: 520px; display: flex; }
.msg .sim-frame-wrap { min-height: 480px; height: 62vh; margin: 10px 0 4px; border-radius: 12px; overflow: hidden; border: 1px solid #1e2f5c; }
.sim-frame {
  flex: 1; width: 100%; height: 100%; min-height: 520px; border: 0;
  background: #0b1733; border-radius: 8px;
}
.wb-body:has(.sim-frame-wrap) { padding: 0; align-items: stretch; }
.json-view-wrap { width: 100%; height: 100%; min-height: 280px; overflow: auto; }
.wb-body:has(.json-view-wrap) { padding: 0; align-items: stretch; justify-content: stretch; }
.json-view {
  margin: 0; padding: 16px; color: #f4e6d0; font-family: var(--mono); font-size: 13px;
  white-space: pre; width: 100%; box-sizing: border-box;
}
.wb-empty {
  color: var(--muted); text-align: center; padding: 40px 16px; font-size: 15px;
}
.wb-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.wb-actions a, .wb-actions button {
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; text-decoration: none; font-family: var(--ui); font-weight: 700;
}

.settings { max-width: 640px; margin: 24px auto 48px; padding: 0 16px; }
.settings-group {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  margin-bottom: 16px; overflow: hidden;
}
.settings-group h3 {
  margin: 0; padding: 14px 16px 8px; font-size: 12px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted); font-weight: 700; font-family: var(--ui);
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; background: transparent; border: none; border-top: 1px solid var(--border);
  color: var(--text); padding: 14px 16px; text-align: left; font-size: 1rem;
}
.settings-row span.muted { color: var(--muted); font-size: 13px; }
.settings-row .plan-badge {
  background: rgba(212,175,55,0.22); color: var(--ink); border-radius: 999px;
  padding: 3px 10px; font-size: 11px; letter-spacing: 0.6px; font-weight: 700;
}
[data-theme="dark"] .settings-row .plan-badge { color: var(--text); }
.student-badge { background: rgba(91,140,255,0.22) !important; letter-spacing: 0.4px; }
.toggle {
  width: 42px; height: 24px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-alt); position: relative;
}
.toggle.on { background: var(--sormeyi); border-color: var(--gold); }
.toggle i {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: left .18s var(--ease);
}
.toggle.on i { left: 20px; }

.overlay {
  position: fixed; inset: 0; background: rgba(14, 7, 9, 0.72); display: flex;
  align-items: center; justify-content: center; z-index: 40; padding: 20px;
}
.overlay img { max-width: 96vw; max-height: 90vh; border-radius: 12px; }

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(14, 7, 9, 0.62); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: min(520px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px 20px 0 0; padding: 18px 16px 28px; box-shadow: var(--shadow);
}
.sheet h3 { margin: 0 8px 12px; font-size: 20px; font-family: var(--display); font-weight: 650; }
.preview-banner {
  max-width: 760px; margin: 0 auto 8px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: color-mix(in srgb, var(--gold) 10%, var(--surface));
  color: var(--text); font-size: 12.5px; font-weight: 600; line-height: 1.45;
}
.feedback-ta { width: calc(100% - 32px); margin: 0 16px; min-height: 72px; max-height: 180px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.credits-alert {
  margin: 12px 16px 8px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 16%, var(--surface-alt));
}
.credits-alert strong { display: block; margin-bottom: 6px; }
.credits-alert .lead { margin: 0; color: inherit; }
.credits-alert-inline {
  display: block;
  width: calc(100% - 24px);
  margin: 8px 12px 0;
  text-align: start;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.tier-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; background: transparent; border: 1px solid transparent;
  border-radius: 12px; padding: 12px; color: var(--text); text-align: left; margin-bottom: 6px;
}
.tier-row:hover { background: var(--surface-alt); }
.tier-row.on { border-color: var(--gold); background: rgba(212,175,55,0.12); }
.tier-row.locked { opacity: 0.55; }
.tier-row .name { font-weight: 700; display: block; }
.tier-row .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tier-row .cost { color: var(--accent); font-size: 12px; font-weight: 700; white-space: nowrap; }

.nav-dim { position: fixed; inset: 0; background: rgba(14, 7, 9, 0.5); z-index: 25; }

@media (max-width: 840px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: flex; position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 30; }
  .main.workspace.pane-open {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(150px, 34dvh);
  }
  .main.workspace.pane-open .chat-col {
    grid-row: 1;
    height: auto;
    min-height: 0;
  }
  .main.workspace.pane-open .pane-resize { display: none; }
  .main.workspace.pane-open .workbench {
    grid-row: 2;
    position: relative;
    inset: auto;
    height: 100%;
    max-height: none;
    z-index: 2;
    border-left: none;
    border-top: 1px solid var(--border);
    box-shadow: none;
  }
  .composer-wrap { position: sticky; bottom: 0; z-index: 24; }
  .composer-meta { display: none; }
  .desk-only { display: none !important; }
  .conv-actions { display: flex; }
  .home .mode-card p { display: none; }
  .home-hi { font-size: 1.1rem; }
  .export-row span { display: none; }
  .export-row.lab-export { display: none; }
  .topbar { padding: 8px 12px; }
  .nav-search-kbd { display: none; }
  .composer-wrap { padding: 8px 10px 12px; }
  .auth-card { width: min(100%, 420px); padding: 20px 16px; }
  .mode-cards { grid-template-columns: 1fr; }
}

.nernst-think {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 14px 6px 8px;
  color: var(--muted); font-size: 0.9rem; font-style: italic; font-family: var(--ui);
}
.think-copy { display: inline-flex; align-items: baseline; gap: 10px; min-width: 0; }
.think-label { min-width: 0; }
.think-clock {
  font-family: var(--mono);
  font-style: normal;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  color: var(--gold);
  font-size: 0.82rem;
  min-width: 3.4em;
  text-align: end;
  letter-spacing: 0.02em;
}
.nernst-atom { overflow: visible; }
.nernst-atom .orbit { fill: none; stroke: var(--gold); stroke-width: 1.45; opacity: 0.78; }
.nernst-atom .nucleus-glow { fill: rgba(212, 175, 55, 0.32); }
.nernst-atom .nucleus { fill: var(--gold); }
.nernst-atom .nucleus-hole { fill: var(--bg); }
.nernst-atom .e-gold { fill: var(--gold); filter: drop-shadow(0 0 2px rgba(212,175,55,0.7)); }
.nernst-atom .e-sage { fill: var(--sormeyi-bright); filter: drop-shadow(0 0 2px rgba(155,45,74,0.55)); }
[data-theme="light"] .nernst-atom .e-sage { fill: var(--sormeyi); }
.live-log {
  margin: 8px 0 4px;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--gold);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.live-log-line {
  color: var(--muted);
  font-size: 0.86rem;
  font-family: var(--ui);
  line-height: 1.35;
}
.live-log-line.now {
  color: var(--text);
  font-weight: 650;
}
.splash .nernst-atom { width: 88px; height: 88px; }
.legal-check {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 16px; color: var(--muted); font-size: 13px; line-height: 1.45;
}
.legal-check input { margin-top: 3px; accent-color: var(--gold); }
.disclaimer {
  margin-top: 10px; font-size: 12px; color: var(--muted); font-family: var(--ui);
  font-style: italic; opacity: 0.85;
}
.disclaimer.strong { color: var(--gold); font-style: normal; font-weight: 650; opacity: 1; }
.trust { margin-top: 12px; }
.trust-badge {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 12px; padding: 8px 10px; text-align: left; font-family: var(--ui); font-size: 12px;
}
.trust-badge strong { font-weight: 700; }
.trust-badge small { margin-left: auto; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.trust-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.trust-badge.verified { border-color: rgba(80, 160, 110, 0.55); }
.trust-badge.verified .trust-dot { background: #4CAF7A; box-shadow: 0 0 0 3px rgba(76,175,122,0.18); }
.trust-badge.partial { border-color: rgba(212,175,55,0.55); }
.trust-badge.partial .trust-dot { background: var(--gold); box-shadow: 0 0 0 3px rgba(212,175,55,0.16); }
.trust-badge.unverified { border-color: var(--border); }
.trust-badge.unverified .trust-dot { background: #8a6a72; }
.trust-panel {
  margin-top: 8px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); font-size: 13px; color: var(--text);
}
.trust-method { margin: 0 0 6px; }
.trust-caveat { margin: 8px 0 0; color: var(--gold); font-style: italic; }
.widget-card {
  margin-top: 12px; padding: 12px; border-radius: 16px;
  border: 1px solid var(--border); background: var(--bg);
}
.widget-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.widget-head strong { color: var(--text); font-family: var(--ui); }
.widget-mode { color: var(--gold); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }
.widget-slider { display: block; margin: 8px 0; color: var(--muted); font-size: 13px; font-family: var(--ui); }
.widget-slider input { width: 100%; accent-color: var(--gold); margin-top: 4px; }
.widget-val { color: var(--gold); font-style: normal; font-weight: 700; }
.widget-outs { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.widget-chip {
  border: 1px solid var(--border); border-radius: 12px; padding: 6px 10px;
  background: var(--surface); color: var(--text); font-family: var(--ui);
}
.widget-chip small { display: block; color: var(--muted); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; }
.widget-chip strong { color: var(--gold); font-size: 16px; }
.widget-plot { width: 100%; height: 140px; border-radius: 12px; display: block; background: var(--bg); }
.widget-status { color: var(--gold); font-size: 12px; margin: 6px 0 0; }
.filechip-hint { color: var(--gold); font-size: 11px; margin-left: 8px; }
.lab-card {
  margin-top: 12px; padding: 12px; border-radius: 16px;
  border: 1px solid var(--border); background: var(--bg);
}
.lab-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.lab-head strong { color: var(--text); font-family: var(--ui); }
.lab-method { color: var(--gold); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }
.lab-params { display: flex; flex-wrap: wrap; gap: 8px; }
.lab-param {
  border: 1px solid var(--border); border-radius: 12px; padding: 6px 10px;
  background: var(--surface); color: var(--text); font-family: var(--ui);
}
.lab-param small { display: block; color: var(--muted); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; }
.lab-param strong { color: var(--text); font-size: 16px; }
.lab-param .pm { color: var(--gold); font-weight: 800; }
.lab-stats { margin: 10px 0 0; color: var(--muted); font-size: 12px; font-family: var(--ui); }
.lab-notes { margin: 8px 0 0; color: var(--gold); font-size: 12px; font-style: italic; }
.export-row.lab-export span { color: var(--gold); font-weight: 700; }
.mode-toggle {
  display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 999px; overflow: hidden;
  max-width: 100%;
}
.mode-btn {
  border: 0; background: transparent; color: var(--muted);
  padding: 5px 12px; font-size: 12px; font-weight: 700; font-family: var(--ui);
}
.mode-btn.on { background: var(--gold); color: #1A0B10; }
.tutor-bar {
  max-width: 760px; margin: 0 auto 8px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.tutor-progress { color: var(--gold); font-size: 12px; font-weight: 700; font-family: var(--ui); }
.tutor-act {
  border: 1px solid var(--border); background: var(--bg); color: var(--gold);
  border-radius: 999px; padding: 4px 10px; font-size: 11px; font-weight: 700;
}
.tutor-act:hover { background: rgba(212,175,55,0.1); }
.wpt-card {
  margin-top: 12px; padding: 12px; border-radius: 16px;
  border: 1px solid var(--border); background: var(--bg);
}
.wpt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wpt-head strong { color: var(--text); font-family: var(--ui); }
.wpt-eta { color: var(--gold); font-size: 22px; font-weight: 800; font-family: var(--ui); }
.wpt-topo { margin: 4px 0 10px; color: var(--muted); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.wpt-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.wpt-cell {
  border: 1px solid var(--border); border-radius: 12px; padding: 6px 10px;
  background: var(--surface); min-width: 72px;
}
.wpt-cell small { display: block; color: var(--muted); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; }
.wpt-cell strong { color: var(--text); font-size: 14px; }
.wpt-notes { margin: 8px 0 0; color: var(--gold); font-size: 12px; font-style: italic; }
.export-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 10px; font-family: var(--ui); font-size: 12px; color: var(--muted);
}
.export-row button {
  border: 1px solid var(--border); background: var(--bg); color: var(--gold);
  border-radius: 999px; padding: 4px 10px; font-size: 11px; font-weight: 700;
}
.export-row button:hover { background: rgba(212,175,55,0.1); }
a.settings-row { text-decoration: none; }

.voice-dock {
  max-width: 760px; margin: 0 auto 10px;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 10px 12px;
  box-shadow: 0 10px 28px rgba(8, 3, 5, 0.22);
}
.voice-dock[hidden] { display: none; }
.voice-orb {
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto;
  background: radial-gradient(circle at 35% 30%, #F4E6D0, var(--gold) 42%, var(--sormeyi) 78%);
  box-shadow: 0 0 0 4px rgba(212,175,55,0.16);
}
.voice-dock.listening .voice-orb { animation: pulse-mic 1.1s ease-in-out infinite; }
.voice-dock.organizing .voice-orb { animation: none; opacity: 0.7; }
.voice-dock strong { display: block; color: var(--text); font-family: var(--ui); font-size: 13px; }
.voice-dock p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.voice-live { font-family: var(--ui); font-style: italic; color: var(--text) !important; }
.voice-stop {
  margin-left: auto; border: none; border-radius: 999px;
  background: var(--gold); color: var(--ink);
  font-weight: 700; font-size: 12px; padding: 8px 12px; font-family: var(--ui);
}
.voice-note {
  max-width: 760px; margin: 0 auto 8px;
  color: var(--gold); font-size: 12px; font-family: var(--ui);
}

.math-pad {
  max-width: 760px; margin: 0 auto 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 12px;
}
.math-pad[hidden] { display: none; }
.math-pad-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px; color: var(--text); font-family: var(--ui); font-weight: 700; font-size: 13px;
}
.math-tabs { display: flex; gap: 6px; }
.math-tabs button, .math-key {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 10px; min-width: 36px; height: 36px; padding: 0 10px;
  font-family: var(--ui); font-size: 16px;
}
.math-tabs button.on, .math-key.on {
  border-color: var(--gold); color: var(--ink); background: var(--gold);
}
.math-label {
  margin: 10px 0 6px; color: var(--muted); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; font-family: var(--ui);
}
.math-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.math-custom {
  margin-top: 8px; width: 140px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); border-radius: 10px; padding: 8px 10px; font-family: var(--ui);
}
.math-preview { margin: 10px 0 0; color: var(--muted); font-size: 13px; font-family: var(--ui); }
.math-preview span { color: var(--text); font-family: var(--ui); font-size: 22px; margin-left: 8px; }
.icon-btn.on { color: var(--gold); background: rgba(212,175,55,0.1); }

.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.lang-grid .chip { justify-content: center; text-align: center; }

[dir="rtl"] .app-shell { direction: rtl; }
[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .sidebar::after { left: auto; right: 0; }
[dir="rtl"] .nav-search-box { flex-direction: row-reverse; }
[dir="rtl"] .nav-search-hit { text-align: right; }
[dir="rtl"] .nav-btn,
[dir="rtl"] .conv-item { text-align: right; }
[dir="rtl"] .settings-row { flex-direction: row-reverse; }
[dir="rtl"] .composer { flex-direction: row-reverse; }
[dir="rtl"] .composer-meta { flex-direction: row-reverse; }
[dir="rtl"] .topbar { flex-direction: row-reverse; }
[dir="rtl"] .brand-mark { flex-direction: row-reverse; }
[dir="rtl"] .oauth .btn { justify-content: flex-end; padding-left: 12px; padding-right: 16px; }
[dir="rtl"] .tutor-bar { flex-direction: row-reverse; }
@media (max-width: 840px) {
  [dir="rtl"] .sidebar.open { inset: 0 0 0 auto; }
}

.home-wrap, .quiz-wrap, .lab-wrap { height: 100%; overflow: auto; }
.home, .quiz-card {
  max-width: 860px; margin: 0 auto; padding: 28px 20px 48px;
}
.home-hi { font-family: var(--display); font-size: 1.35rem; color: var(--gold-bright); margin: 0 0 8px; letter-spacing: 0.01em; }
.mode-cards { display: grid; gap: 14px; margin-top: 18px; }
@media (min-width: 800px) { .mode-cards { grid-template-columns: 1fr 1fr; } }
.mode-card {
  position: relative; overflow: hidden;
  text-align: left; border: 1px solid rgba(212,175,55,0.16); background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-radius: 20px; padding: 22px 20px; color: var(--text); cursor: pointer;
  box-shadow: 0 18px 40px rgba(4,1,3,0.22);
  transition: transform .2s var(--ease), border-color .2s var(--ease);
}
.mode-card::before {
  content: ""; position: absolute; left: 18px; right: 18px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(240,215,138,0.7), transparent);
}
.mode-card h3 { margin: 0 0 8px; font-family: var(--display); color: var(--gold); font-size: 1.22rem; }
.mode-card p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 0.9rem; }
.mode-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.mode-card:disabled { opacity: 0.55; cursor: default; }
.lab-3d-host { width: 100%; min-height: 360px; height: 420px; border-radius: 14px; overflow: hidden; background: #0b1733; margin: 10px 0; border: 1px solid var(--border); }
.lab-3d-canvas { width: 100%; height: 100%; min-height: 360px; display: block; background: #0b1733; }
.lab-dim { margin: 8px 0 12px; }
.lab-workspace {
  display: grid; gap: 16px; padding: 16px 20px 48px; max-width: 1200px; margin: 0 auto;
}
@media (min-width: 960px) {
  .lab-workspace { grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr); align-items: start; }
}
.lab-scene label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; font-family: var(--ui); }
.lab-scene .ta { width: 100%; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 12px; padding: 10px 12px; font-family: var(--ui); }
.lab-chat {
  border: 1px solid var(--border); border-radius: 20px; background: var(--surface);
  min-height: 360px; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.lab-chat-list { flex: 1; overflow: auto; padding: 12px; max-height: 520px; }
.lab-composer { padding: 12px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.lab-composer textarea { width: 100%; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 12px; padding: 10px; font-family: var(--ui); }
.lab-readings { list-style: none; padding: 0; margin: 0 0 12px; }
.lab-reading { font-size: 12px; color: var(--muted); padding: 6px 0; border-bottom: 1px solid var(--border); word-break: break-word; }
.lab-fields { margin: 12px 0; }
.lab-run { margin-top: 12px; }
.quiz-scope {
  margin: 16px 0 8px;
  padding: 14px 14px 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
}
.quiz-scope > label:first-child { margin-top: 0; }
.quiz-scope-hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.quiz-card label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; font-family: var(--ui); }
.quiz-card select, .quiz-card .ta {
  width: 100%; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 12px; padding: 10px 12px; font-family: var(--ui);
}
.quiz-note, .quiz-cost, .quiz-est, .quiz-scoreline { color: var(--gold); font-size: 13px; font-family: var(--ui); }
.quiz-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.quiz-clock { color: var(--gold); font-weight: 800; font-family: var(--ui); }
.quiz-clock.late { color: var(--danger); }
.quiz-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.quiz-tools { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.quiz-chrono {
  font-variant-numeric: tabular-nums; font-weight: 800; color: var(--gold);
  font-family: var(--ui); min-width: 4.4em; text-align: end; letter-spacing: 0.04em;
}
.quiz-stop { border-color: var(--danger) !important; color: var(--danger) !important; }
.prove-lock { font-weight: 800; }
.homework-card { margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; }
.homework-card h3 { margin: 0 0 8px; }
.quiz-q { font-size: 1.05rem; line-height: 1.5; margin: 8px 0 16px; }
.quiz-fb { margin-top: 14px; padding: 12px; border-radius: 14px; border: 1px solid var(--border); }
.quiz-fb.ok { border-color: var(--gold); }
.quiz-fb.bad { border-color: var(--danger); }
.quiz-up { margin: 12px 0; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.quiz-stat { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.quiz-saved { display: grid; gap: 10px; margin-top: 12px; }
.quiz-saved-item h3 { font-size: 16px; }
.quiz-edit-item { margin: 16px 0; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.project-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 0 8px 12px; }
.project-row .muted { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; width: 100%; }
.continuum-ask { display: grid; gap: 10px; margin: 18px 0 22px; }
@media (min-width: 720px) {
  .continuum-ask { grid-template-columns: 1fr auto; align-items: center; }
  .continuum-ask .btn { width: auto; margin: 0; }
}
.continuum-stage {
  position: relative;
  border: 1px solid #1c3a66;
  border-radius: 16px;
  overflow: hidden;
  background: #0b1733;
  margin: 12px 0;
}
.continuum-stage .lab-3d-host, .continuum-stage .lab-3d-canvas {
  background: #0b1733;
  min-height: 420px;
  height: 480px;
}
.continuum-export { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-inline-start: 8px; }
.continuum-export button { width: auto; margin: 0; padding: 6px 10px; }
.continuum-hud {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  pointer-events: none;
  background: rgba(11, 23, 51, 0.82);
  border: 1px solid rgba(230, 184, 75, 0.38);
  border-radius: 14px;
  padding: 10px 12px;
  backdrop-filter: blur(10px);
  max-width: calc(100% - 24px);
  box-shadow: 0 10px 28px rgba(5, 10, 24, 0.45);
}
.continuum-hud .trust { margin: 0; pointer-events: auto; max-width: 100%; }
.continuum-hud .trust-badge { width: auto; background: rgba(11, 23, 51, 0.55); }
.continuum-hud .trust-badge small { margin-inline-start: auto; }
.continuum-hud .trust, .continuum-hud button { pointer-events: auto; }
.continuum-play { display: flex; gap: 6px; pointer-events: auto; }
.continuum-play .btn { width: auto; margin: 0; padding: 6px 12px; font-size: 12px; }
.continuum-computed { font-size: 11px; color: #e6b84b; letter-spacing: 0.02em; }
.continuum-explain {
  margin: 8px 0 0; padding: 10px 12px; border-radius: 12px;
  background: rgba(11, 23, 51, 0.55); border: 1px solid rgba(230, 184, 75, 0.28);
  color: #d7e2f5; font-size: 0.92rem; line-height: 1.45;
}
.continuum-gold {
  color: #e6b84b; font-weight: 750; font-size: 1.05rem;
  text-shadow: 0 2px 12px rgba(11, 23, 51, 0.8);
}
.continuum-legend {
  margin-inline-start: auto; font-size: 11px; color: #c4d4f0; letter-spacing: 0.04em;
  background: rgba(11, 23, 51, 0.72); border: 1px solid rgba(230, 184, 75, 0.35);
  border-radius: 999px; padding: 4px 10px;
}
.scene-stage { margin: 0; }
.scene-stage .lab-3d-host { min-height: 360px; height: 420px; }
.scene-stage .widget-sliders { padding: 8px 12px 4px; }
.continuum-legend .neg { color: #6ea0e8; }
.continuum-honesty { max-width: 860px; margin: 8px auto 24px; padding: 0 20px; }
.continuum-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px 0; }
.continuum-actions .btn { width: auto; margin: 0; }
.continuum-board { max-width: 1280px; }
.continuum-side { display: grid; gap: 12px; min-width: 0; }
.continuum-explain-card {
  border: 1px solid rgba(230, 184, 75, 0.35);
  border-radius: 16px;
  background: rgba(11, 23, 51, 0.78);
  padding: 14px 16px;
  color: #d7e2f5;
}
.continuum-explain-card h3 {
  margin: 0 0 8px;
  color: #e6b84b;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--ui);
}
.continuum-explain-card p { margin: 0; line-height: 1.5; font-size: 0.92rem; }
.continuum-embed-shell { min-height: 100vh; background: #0b1733; }
.continuum-embed .topbar, .continuum-embed-shell .sidebar { display: none; }
[dir="rtl"] .mode-card { text-align: right; }
[dir="rtl"] .mode-cards { direction: rtl; }
[dir="rtl"] .lab-workspace { direction: rtl; }
[dir="rtl"] .continuum-legend { margin-inline-start: auto; }

/* Phone / compact: keep beauty when JS marks the device, including landscape phones >840px */
html.is-phone .app-shell { grid-template-columns: minmax(0, 1fr); }
html.is-phone .sidebar { display: none; }
html.is-phone .sidebar.open {
  display: flex; position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 30;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
html.is-phone[dir="rtl"] .sidebar.open { inset: 0 0 0 auto; }
html.is-phone .main,
html.is-phone .home-wrap,
html.is-phone .quiz-wrap,
html.is-phone .lab-wrap,
html.is-phone .devices-wrap,
html.is-phone .settings { min-width: 0; }
html.is-phone .main.workspace.pane-open {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(140px, 34dvh);
}
html.is-phone .main.workspace.pane-open .pane-resize { display: none; }
html.is-phone .main.workspace.pane-open .workbench {
  border-left: none; border-top: 1px solid var(--border);
}
html.is-phone .desk-only { display: none !important; }
html.is-phone .composer-meta { display: none; }
html.is-phone .composer-wrap {
  position: sticky; bottom: 0; z-index: 24;
  padding: 8px 10px max(12px, env(safe-area-inset-bottom));
}
html.is-phone .topbar,
html.is-phone .page-topbar,
html.is-phone .quiz-topbar {
  flex-wrap: wrap;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  align-items: center;
}
html.is-phone .topbar-start {
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
}
html.is-phone .topbar strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}
html.is-phone .page-back {
  width: auto;
  margin: 0;
  padding: 6px 12px;
  white-space: nowrap;
  font-size: 0.8rem;
}
html.is-phone .quiz-tools { flex-wrap: wrap; }
html.is-phone .quiz-scope { padding: 12px 10px 8px; }
html.is-phone .home, html.is-phone .quiz-card { padding: 16px 14px 36px; }
html.is-phone .home .mode-card p { display: none; }
html.is-phone .home-hi { font-size: 1.12rem; }
html.is-phone .mode-cards { grid-template-columns: 1fr; }
html.is-phone .mode-card { padding: 18px 16px; }
html.is-phone .mode-card h3 { font-size: 1.08rem; }
html.is-phone .lab-workspace {
  grid-template-columns: minmax(0, 1fr);
  padding: 12px 12px max(28px, env(safe-area-inset-bottom));
}
html.is-phone .lab-3d-host,
html.is-phone .lab-3d-canvas,
html.is-phone .scene-stage .lab-3d-host { min-height: 240px; height: 52vw; max-height: 360px; }
html.is-phone .lab-chat { min-height: 240px; }
html.is-phone .settings { padding: 0 12px 36px; margin-top: 12px; }
html.is-phone .devices-wrap { padding: 8px 12px 32px; }
html.is-phone .row-actions { gap: 8px; }
html.is-phone .device-code { font-size: 1rem; letter-spacing: 0.04em; word-break: break-all; }
html.is-phone .settings-row { gap: 10px; }
html.is-phone .settings-row span { min-width: 0; overflow-wrap: anywhere; }
html.is-phone .chips { gap: 6px; }
html.is-phone .task-tabs { overflow-x: auto; }
html.is-phone .msg-stack { max-width: 94%; }
html.is-phone .bubble { overflow-wrap: anywhere; }
html.is-phone img, html.is-phone canvas, html.is-phone svg, html.is-phone video, html.is-phone pre, html.is-phone table {
  max-width: 100%;
}
html.is-phone .nav-search-kbd { display: none; }
html.is-phone .export-row span { display: none; }
html.is-phone .auth-card { width: min(100%, 420px); padding: 20px 16px; }
html.is-phone .card { width: min(100% - 24px, 420px); }

.lit-body { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.lit-body h3 { margin: 0 0 6px; font-size: 1.15rem; }
.lit-body h4 { margin: 18px 0 8px; color: var(--gold); font-size: 0.92rem; letter-spacing: 0.02em; }
.lit-theme { margin: 0 0 14px; }
.lit-refs { display: grid; gap: 12px; }
.lit-ref { padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.lit-ref h4 { margin: 0 0 6px; color: var(--text); font-size: 0.98rem; }
.lit-ref a { color: var(--gold-bright); }
.lit-ref-k { margin: 0 0 4px; font-size: 0.75rem; color: var(--muted); }
.lit-past { margin: 16px 0 0; }

.campaign-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
}
.campaign-step {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-family: var(--ui);
}
.campaign-step.done, .campaign-step.ready, .campaign-step.proposed { color: var(--gold); border-color: var(--gold); }
.campaign-step.on { background: var(--surface); color: var(--text); }
.campaign-papers { margin: 8px 0 16px; padding-inline-start: 18px; color: var(--muted); }
.bridge-ask {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.bridge-ask h4 { margin: 0 0 6px; color: var(--gold); font-size: 0.98rem; }
