:root {
  color-scheme: dark;
  --ink: #dcecfb;
  --muted: #7888a8;
  --line: rgba(120, 160, 255, 0.18);
  --paper: #05060f;
  --panel: rgba(12, 16, 34, 0.42);
  --panel-solid: rgba(10, 12, 28, 0.92);
  --nav: rgba(12, 16, 34, 0.42);
  --nav-soft: rgba(57, 230, 255, 0.16);
  --brand: #39e6ff;
  --brand-strong: #1aa9c9;
  --accent: #ffae3a;
  --warn: #ffae3a;
  --danger: #ff5066;
  --green: #4dffb0;
  --violet: #9a6bff;
  --glow: 0 0 18px rgba(57, 230, 255, 0.35);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  --font-ui: "Rajdhani", "Lusail", "Segoe UI", system-ui, sans-serif;
  --font-display: "Orbitron", "Lusail", "Segoe UI", sans-serif;
  --font-mono: "Share Tech Mono", "Lusail", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 15px;
  letter-spacing: 0.2px;
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
}

html[dir="rtl"] body {
  direction: rtl;
  font-family: "Lusail", "Rajdhani", "Segoe UI", Tahoma, Arial, sans-serif;
  letter-spacing: 0;
}

/* Orbitron/Share Tech Mono are latin-only; Arabic glyphs fall through to Lusail,
   where wide tracking breaks joined script. */
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] .eyebrow,
[dir="rtl"] .nav-group-label,
[dir="rtl"] .primary,
[dir="rtl"] .ghost,
[dir="rtl"] .danger,
[dir="rtl"] .file-button,
[dir="rtl"] .chip {
  letter-spacing: 0;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(6, 10, 22, 0.72);
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--glow);
}

input::placeholder, textarea::placeholder {
  color: rgba(120, 136, 168, 0.75);
}

textarea { resize: vertical; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(120, 160, 255, 0.22); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120, 160, 255, 0.38); }
::-webkit-scrollbar-track { background: transparent; }
::selection { background: rgba(57, 230, 255, 0.3); }

.hidden { display: none !important; }

/* ===== HUD background layers ===== */
.bg-neb, .bg-grid, .scan {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.bg-neb {
  background:
    radial-gradient(1000px 700px at 50% 46%, rgba(40, 120, 200, 0.20), transparent 62%),
    radial-gradient(700px 520px at 28% 22%, rgba(120, 70, 220, 0.16), transparent 60%),
    radial-gradient(700px 520px at 76% 30%, rgba(255, 150, 40, 0.06), transparent 60%),
    radial-gradient(900px 700px at 50% 110%, rgba(30, 90, 160, 0.18), transparent 60%);
  animation: nebdrift 30s ease-in-out infinite alternate;
}

@keyframes nebdrift {
  from { transform: scale(1) translate(0, 0); }
  to { transform: scale(1.14) translate(1.5%, -1.5%); }
}

/* polar instrument grid — concentric rings + radial spokes */
.bg-grid {
  background-image:
    repeating-radial-gradient(circle at 50% 43%, transparent 0 45px, rgba(120, 160, 255, 0.06) 45px 46px),
    repeating-conic-gradient(from 0deg at 50% 43%, rgba(120, 160, 255, 0.05) 0 0.35deg, transparent 0.35deg 15deg);
  mask-image: radial-gradient(circle at 50% 43%, #000 3%, #000 40%, transparent 74%);
  -webkit-mask-image: radial-gradient(circle at 50% 43%, #000 3%, #000 40%, transparent 74%);
  animation: gridspin 240s linear infinite;
}

@keyframes gridspin {
  to { transform: rotate(360deg); }
}

/* drifting starfield (canvas painted in app.js) */
.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.scan {
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
  opacity: 0.45;
  animation: scan 9s linear infinite;
}

@keyframes scan {
  from { background-position: 0 0; }
  to { background-position: 0 700px; }
}

@media (prefers-reduced-motion: reduce) {
  .scan { animation: none; }
  .bar i { animation: none; }
  .bg-neb, .bg-grid { animation: none; }
  .stage-fx .sweep, .stage-fx i, .stage-fx .well,
  .stage-fx .housing, .stage-fx .dust { animation: none; }
}

.glass {
  background: var(--panel);
  backdrop-filter: blur(12px) saturate(125%);
  -webkit-backdrop-filter: blur(12px) saturate(125%);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: inset 0 0 30px rgba(80, 140, 255, 0.05);
}

.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(440px, 100%);
  background: var(--panel-solid);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 2px;
}

.stack {
  display: grid;
  gap: 12px;
}

/* ===== HUD frame: 64px top bar / 236px rail / stage / 332px right panel /
   44px bottom strip. Views without a contextual panel use .app.no-right. ===== */
.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 44px;
  grid-template-columns: 236px minmax(0, 1fr) 332px;
  grid-template-areas:
    "top top top"
    "rail stage right"
    "bottom bottom bottom";
  gap: 14px;
  padding: 14px;
}

/* Views without a contextual right panel collapse to two columns. */
.app.no-right {
  grid-template-columns: 236px minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "rail stage"
    "bottom bottom";
}

/* ===== Top bar ===== */
.top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  min-width: 0;
}

.top-grow { flex: 1; }

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--brand);
  background: transparent;
  color: var(--brand);
  box-shadow: var(--glow);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 12px;
}

.brand b {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 2px;
  white-space: nowrap;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1.5px;
  margin-top: 2px;
  white-space: nowrap;
}

[dir="rtl"] .brand b,
[dir="rtl"] .brand small {
  letter-spacing: 0;
}

.status-chips {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 10px;
  background: rgba(120, 160, 255, 0.05);
  transition: 0.2s;
}

.chip:hover {
  border-color: var(--brand-strong);
  color: var(--ink);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  flex: none;
}

.dot.amber {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.clock {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
}

.iconbtn {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(120, 160, 255, 0.06);
  color: var(--brand);
  cursor: pointer;
  font-size: 14px;
  display: grid;
  place-items: center;
  transition: 0.2s;
  padding: 0;
}

.iconbtn:hover {
  background: rgba(57, 230, 255, 0.16);
  box-shadow: var(--glow);
}

/* sound toggle lit state (17.7) — off by default; glows only when the user enables it. */
.iconbtn.on {
  background: rgba(77, 255, 176, 0.16);
  border-color: color-mix(in srgb, var(--green) 55%, transparent);
  color: var(--green);
  box-shadow: 0 0 14px -3px var(--green);
}

/* ===== Mobile navigation drawer (17.8) =====
   Ported from the prototype's two-tier drawer. The ☰ button and the drawer are
   hidden on desktop (the rail handles navigation there) and appear only at the
   phone breakpoint (≤820px, shown in the media query below). */
#menu-btn { display: none; }
dialog.drawer {
  width: min(340px, 92vw);
  max-height: 82vh;
  overflow: auto;
  padding: 16px;
  margin: auto;
  color: var(--ink);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 0 60px rgba(57, 230, 255, 0.18);
}
dialog.drawer::backdrop {
  background: rgba(2, 6, 14, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.drawer .dhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.drawer .dhead button { border: none; background: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }
.drawer .dhead button:hover { color: var(--ink); }
.drawer .dgroup { font-family: var(--font-display); font-size: 9px; letter-spacing: 2.5px; color: var(--muted); margin: 12px 2px 7px; }
.drawer .ditem {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; margin-bottom: 6px; cursor: pointer;
  color: var(--ink); font-family: inherit; font-weight: 600; font-size: 14px; text-align: start;
  background: rgba(120, 160, 255, 0.05); border: 1px solid var(--line); border-radius: 11px; transition: 0.18s;
}
.drawer .ditem i { font-style: normal; color: var(--brand); width: 18px; text-align: center; }
.drawer .ditem small { margin-inline-start: auto; color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.drawer .ditem:hover { border-color: var(--brand); box-shadow: var(--glow); }
.drawer .ditem.primary { border-color: var(--brand); background: linear-gradient(90deg, rgba(57, 230, 255, 0.18), rgba(120, 160, 255, 0.04)); box-shadow: var(--glow); }
.drawer .ditem.active { border-color: color-mix(in srgb, var(--brand) 55%, transparent); }
.drawer .dlist { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.drawer .dlist .ditem { margin-bottom: 0; font-size: 13px; padding: 10px; }
[dir="rtl"] .drawer .dgroup { font-family: "Lusail", var(--font-display); letter-spacing: 0; }

/* ===== Rail ===== */
.sidebar {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px 12px;
  overflow-y: auto;
  min-height: 0;
  color: var(--ink);
}

nav {
  display: grid;
  gap: 7px;
  padding-right: 2px;
}

.nav-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  text-align: left;
  background: linear-gradient(90deg, rgba(120, 160, 255, 0.08), rgba(120, 160, 255, 0.01));
  border: 1px solid transparent;
  border-left: 2px solid var(--brand-strong);
  border-radius: 0;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  transition: 0.18s;
}

.nav-button.active,
.nav-button:hover {
  background: linear-gradient(90deg, rgba(57, 230, 255, 0.22), rgba(120, 160, 255, 0.03));
  border-left-color: var(--brand);
  box-shadow: var(--glow);
  transform: translateX(3px);
  color: #fff;
}

.nav-button small {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  border: 1px solid rgba(255, 174, 58, 0.4);
  border-radius: 10px;
  padding: 1px 7px;
}

.nav-button small:empty { display: none; }

[dir="rtl"] .nav-button {
  text-align: right;
  border-left: 1px solid transparent;
  border-right: 2px solid var(--brand-strong);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%);
}

[dir="rtl"] .nav-button.active,
[dir="rtl"] .nav-button:hover {
  border-right-color: var(--brand);
  transform: translateX(-3px);
}

.nav-group-label {
  margin: 10px 4px 2px;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-group-label:first-child {
  margin-top: 2px;
}

[dir="rtl"] .nav-group-label {
  letter-spacing: 0;
  font-size: 11px;
}

/* ===== Stage ===== */
.workspace {
  grid-area: stage;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
  background: var(--panel);
  backdrop-filter: blur(12px) saturate(125%);
  -webkit-backdrop-filter: blur(12px) saturate(125%);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: inset 0 0 30px rgba(80, 140, 255, 0.05);
}

/* ===== Bottom status strip ===== */
.bottom {
  grid-area: bottom;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
}

.power {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--green);
  white-space: nowrap;
}

[dir="rtl"] .power { letter-spacing: 0; font-size: 12px; }

.bar {
  width: 170px;
  height: 6px;
  flex: none;
  border-radius: 4px;
  background: rgba(120, 160, 255, 0.12);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--brand), var(--violet));
  box-shadow: var(--glow);
  animation: flow 3s ease-in-out infinite;
}

@keyframes flow {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.hud-readout {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.bottom .top-grow { flex: 1; }

.topbar,
.section-head,
.button-row,
.toolbar,
.top-actions,
.voice-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 22px;
}

/* One-box command view: no "Command Center" heading — the stage speaks for itself. */
body.on-command .topbar { display: none; }

.mobile-action-bar {
  display: none;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

h2, h3, p {
  margin-top: 0;
}

h2 {
  margin-bottom: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 0 24px rgba(57, 230, 255, 0.25);
}

h3 {
  margin-bottom: 14px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

[dir="rtl"] h3 { text-transform: none; font-size: 16px; }

/* Uppercase is chrome-only: user data titles (items, reviews, jobs) render as typed. */
.item-card h3,
.review-card h3,
.jarvis-job h3 {
  font-family: var(--font-ui);
  font-size: 16px;
  letter-spacing: 0.3px;
  text-transform: none;
}

.eyebrow {
  margin-bottom: 6px;
  font-family: var(--font-display);
  color: var(--brand-strong);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 3px;
}

.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 20px; }
.save-message {
  min-height: 22px;
  margin: 12px 0 6px;
  color: var(--muted);
  font-weight: 700;
}
.save-message.success { color: var(--green); }
.save-message.warn { color: var(--warn); }
.save-message.error { color: var(--danger); }
.compact-copy {
  margin-bottom: 0;
  max-width: 760px;
}

.primary,
.ghost,
.danger,
.file-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  padding: 10px 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1.2px;
  transition: 0.2s;
}

.primary {
  background: linear-gradient(180deg, var(--brand), var(--brand-strong));
  color: #02141b;
  box-shadow: var(--glow);
}

.primary:hover { filter: brightness(1.15); }

.ghost {
  background: rgba(57, 230, 255, 0.06);
  color: var(--brand);
  border: 1px solid var(--line);
}

.ghost:hover {
  background: rgba(57, 230, 255, 0.14);
  border-color: var(--brand-strong);
}

.mic-active {
  background: rgba(255, 174, 58, 0.2);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(255, 174, 58, 0.35);
}

.danger {
  background: rgba(255, 80, 102, 0.1);
  border: 1px solid rgba(255, 80, 102, 0.4);
  color: var(--danger);
}

.danger:hover {
  background: rgba(255, 80, 102, 0.2);
}

.small {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 11px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric,
section,
.item-card {
  background: rgba(10, 14, 30, 0.55);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: inset 0 0 24px rgba(80, 140, 255, 0.04);
}

.metric {
  padding: 16px;
}

.metric strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 28px;
  color: var(--brand);
  text-shadow: 0 0 14px rgba(57, 230, 255, 0.3);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
}

.recent-panel {
  margin-top: 18px;
}

.start-panel,
.voice-panel,
.briefing-panel,
.module-briefing {
  margin-bottom: 18px;
}

.briefing-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 12px;
}

.briefing-card {
  min-height: 178px;
  display: grid;
  align-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(120, 160, 255, 0.05);
}

.briefing-card.urgent {
  border-color: rgba(255, 80, 102, 0.45);
  background: rgba(255, 80, 102, 0.07);
  box-shadow: inset 0 0 24px rgba(255, 80, 102, 0.06);
}

.briefing-card.warn {
  border-color: rgba(255, 174, 58, 0.45);
  background: rgba(255, 174, 58, 0.06);
}

.briefing-card.ok {
  border-color: rgba(77, 255, 176, 0.35);
  background: rgba(77, 255, 176, 0.05);
}

.briefing-card h3,
.module-briefing h3 {
  margin: 10px 0 8px;
}

.briefing-card p,
.module-briefing p {
  margin-bottom: 0;
}

.module-briefing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.compact-briefing {
  margin-bottom: 14px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 12px;
}

.action-card {
  min-height: 190px;
  display: grid;
  align-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(120, 160, 255, 0.05);
  transition: 0.18s;
}

.action-card:hover {
  border-color: var(--brand-strong);
  box-shadow: var(--glow);
}

.action-card h3 {
  margin: 10px 0 8px;
}

.action-card p {
  margin-bottom: 0;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(120, 160, 255, 0.05);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-chip.ok {
  background: rgba(77, 255, 176, 0.08);
  border-color: rgba(77, 255, 176, 0.35);
  color: var(--green);
}

.status-chip.warn {
  background: rgba(255, 174, 58, 0.08);
  border-color: rgba(255, 174, 58, 0.4);
  color: var(--accent);
}

.voice-grid {
  align-items: stretch;
}

.voice-command,
.voice-grid input {
  min-width: 240px;
}

.voice-command {
  flex: 1;
}

.report-output {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(6, 10, 22, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 0;
}

/* ===== Phase 17.3 → one-box glass bar ===== */
/* Chrome lives on #command .command-bar (glass overlay); this stays neutral. */
.command-bar {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.command-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.command-input-row input {
  flex: 1;
  min-width: 0;
  background: rgba(4, 8, 18, 0.35);
}

.command-input-row .primary { flex: none; }
.command-input-row .pill { flex: none; white-space: nowrap; }

.iconbtn-lg {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(120, 160, 255, 0.06);
  color: var(--brand);
  cursor: pointer;
  font-size: 18px;
  display: grid;
  place-items: center;
  transition: 0.2s;
  padding: 0;
}

.iconbtn-lg:hover {
  background: rgba(57, 230, 255, 0.16);
  box-shadow: var(--glow);
}

.response-console {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(4, 8, 18, 0.72);
  max-height: min(46vh, 380px);
  overflow-y: auto;
}

.response-summary {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 14px;
}

.response-console .report-output { max-height: 320px; overflow-y: auto; }

/* ===== Right panel (332px) ===== */
.rightpanel {
  grid-area: right;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  overflow-y: auto;
  min-height: 0;
}

.rightpanel h3 { font-size: 13px; margin-bottom: 10px; }
.rightpanel .section-head { margin-bottom: 12px; }
.rightpanel .briefing-grid { grid-template-columns: 1fr; }
.rightpanel .briefing-card { min-height: 0; }
.rightpanel .action-grid { grid-template-columns: 1fr; }
.rightpanel .action-card { min-height: 0; }

/* Contextual right panel — owning-agent header + area signals + quick actions (17.4b) */
.context-panel { display: flex; flex-direction: column; gap: 14px; }
.ctx-agent {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(6, 10, 22, 0.55);
}
.ctx-orb {
  width: 48px; height: 48px; flex: none;
  border-radius: 14px;
  display: grid; place-items: center;
  color: var(--ac, var(--brand));
  border: 1.5px solid color-mix(in srgb, var(--ac, var(--brand)) 70%, transparent);
  background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--ac, var(--brand)) 28%, transparent), rgba(8, 12, 26, 0.8) 72%);
  box-shadow: 0 0 18px -4px color-mix(in srgb, var(--ac, var(--brand)) 65%, transparent);
}
.ctx-orb svg { width: 24px; height: 24px; display: block; overflow: visible; }
.ctx-agent.planned .ctx-orb {
  border-style: dashed;
  opacity: 0.72;
  box-shadow: none;
}
.ctx-agent-meta { flex: 1 1 auto; min-width: 0; }
.ctx-agent-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--ac, var(--brand));
}
[dir="rtl"] .ctx-agent-name { font-family: "Lusail", var(--font-display); letter-spacing: 0; }
.ctx-agent-role { font-size: 11px; color: var(--muted); margin-top: 3px; }
.ctx-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

/* TODAY | RECENT pill toggle */
.pill-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(120, 160, 255, 0.05);
}

.pill-tab {
  min-height: 26px;
  padding: 4px 12px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: 0.18s;
}

.pill-tab.active {
  background: rgba(57, 230, 255, 0.16);
  color: var(--brand);
}

/* Agent roster (right panel) */
.home-roster {
  display: grid;
  gap: 8px;
}

.roster-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(120, 160, 255, 0.05);
}

.roster-name { font-weight: 600; font-size: 13px; }

/* ===== Bottom-strip live metrics ===== */
.hud-metrics {
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
}

.hud-metric {
  display: flex;
  align-items: baseline;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  white-space: nowrap;
  padding: 0;
  transition: 0.18s;
}

.hud-metric:hover { color: var(--ink); }

.hud-metric strong {
  color: var(--brand);
  font-size: 15px;
  text-shadow: 0 0 10px rgba(57, 230, 255, 0.3);
}

[dir="rtl"] .hud-metric { letter-spacing: 0; }

section {
  padding: 18px;
}

.list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(120, 160, 255, 0.05);
}

.list-row small,
.item-meta {
  color: var(--muted);
}

.toolbar {
  margin-bottom: 16px;
}

.toolbar input { max-width: 520px; }
.toolbar select { max-width: 180px; }

.item-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}

.item-card {
  min-height: 190px;
  padding: 16px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.review-layout {
  align-items: start;
}

.review-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(120, 160, 255, 0.05);
}

.review-card h3 {
  margin: 10px 0 8px;
}

.review-card pre {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 10, 22, 0.72);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
}

.jarvis-layout {
  align-items: start;
}

.jarvis-job {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(120, 160, 255, 0.05);
}

.jarvis-job h3 {
  margin: 0 0 6px;
}

.jarvis-job .report-output {
  max-height: 240px;
  overflow: auto;
}

/* Mermaid stays on a light surface: its default theme draws dark text/strokes,
   which would vanish on the HUD background. */
.mermaid-diagram {
  background: #eef3fb;
  color: #1c2434;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
  text-align: center;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto;
}

/* Until a diagram renders (or if it fails), the source stays visible as an
   inline text fallback rather than a blank box. */
.mermaid-diagram .mermaid-source {
  margin: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.mermaid-diagram.mermaid-error {
  border-color: var(--accent);
}

.item-card h3 {
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(120, 160, 255, 0.08);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
}

.pill.high {
  background: rgba(255, 174, 58, 0.12);
  border: 1px solid rgba(255, 174, 58, 0.4);
  color: var(--accent);
  padding: 4px 8px;
}

.pill.done {
  background: rgba(77, 255, 176, 0.1);
  border: 1px solid rgba(77, 255, 176, 0.35);
  color: var(--green);
  padding: 4px 8px;
}

.settings-tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.settings-tab {
  min-height: 34px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(120, 160, 255, 0.05);
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: 0.18s;
}

.settings-tab:hover { color: var(--ink); border-color: var(--brand-strong); }

.settings-tab.active {
  background: linear-gradient(180deg, var(--brand), var(--brand-strong));
  border-color: transparent;
  color: #02141b;
  box-shadow: var(--glow);
}

[dir="rtl"] .settings-tab { letter-spacing: 0; font-size: 13px; }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 18px;
}

.full-settings {
  grid-column: 1 / -1;
}

.compact-metrics {
  margin: 12px 0;
}

.wardrobe-layout {
  align-items: start;
}

.connection-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(120, 160, 255, 0.05);
}

.connection-panel small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.setup-guide {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.setup-step {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(120, 160, 255, 0.05);
}

.setup-step small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.step-number {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(120, 160, 255, 0.12);
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 400;
}

.setup-step.current {
  border-color: rgba(57, 230, 255, 0.55);
  background: rgba(57, 230, 255, 0.06);
}

.setup-step.done .step-number {
  background: var(--brand-strong);
  color: #02141b;
}

.setup-step.pending {
  opacity: 0.72;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #9fb0cd;
  font-size: 13px;
  font-weight: 700;
}

.full { grid-column: 1 / -1; }

.check {
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 10px;
}

.check input,
.file-button input {
  width: auto;
}

.file-button {
  position: relative;
  overflow: hidden;
  background: rgba(57, 230, 255, 0.06);
  color: var(--brand);
  border: 1px solid var(--line);
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.compact .list-row {
  font-size: 13px;
  padding: 10px;
}

dialog {
  width: min(760px, calc(100vw - 32px));
  background: var(--panel-solid);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow), 0 0 40px rgba(57, 230, 255, 0.12);
}

dialog::backdrop {
  background: rgba(2, 4, 12, 0.7);
}

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .item-grid { grid-template-columns: repeat(2, 1fr); }
  .action-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  html,
  body,
  .app,
  .sidebar,
  .workspace,
  .view,
  section {
    max-width: 100%;
    min-width: 0;
  }

  body {
    overflow: auto;
  }

  /* .app.no-right also targeted so its higher specificity can't reinstate the
     desktop two-column grid on phones (the rail is hidden here). */
  .app,
  .app.no-right {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "top"
      "stage"
      "right";
    gap: 10px;
    padding: 10px;
  }

  /* Right panel stacks below the stage on phones (no glass frame, flows inline). */
  .rightpanel {
    overflow: visible;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .top {
    flex-wrap: wrap;
    min-height: 52px;
    padding: 8px 12px;
    gap: 10px;
  }

  .status-chips,
  .clock {
    display: none;
  }

  .sidebar,
  .bottom {
    display: none;
  }

  /* Scoped to the rail's own nav so it can't also hide the drawer's <nav>. */
  #nav {
    display: none;
  }

  /* The drawer replaces the rail on phones: reveal the ☰ trigger. */
  #menu-btn {
    display: grid;
  }

  .nav-button {
    min-width: 112px;
  }

  .workspace {
    overflow: visible;
    padding: 14px;
    width: 100%;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 12px;
  }

  .mobile-action-bar {
    display: grid;
    grid-template-columns: minmax(150px, 1.4fr) repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 0 -14px 16px;
    padding: 10px 14px;
    background: rgba(8, 11, 24, 0.96);
    border-bottom: 1px solid var(--line);
  }

  .mobile-action-bar button {
    min-width: 0;
    min-height: 42px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .mobile-module-picker {
    gap: 3px;
    font-size: 12px;
  }

  .mobile-module-picker select {
    min-height: 42px;
    padding: 8px 10px;
  }

  .top-actions,
  .voice-grid,
  .connection-panel {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .top-actions > *,
  .voice-grid > *,
  .connection-panel > * {
    min-width: 0;
  }

  .metric-grid,
  .briefing-grid,
  .action-grid,
  .split,
  .settings-grid,
  .item-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .mobile-action-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-module-picker {
    grid-column: 1 / -1;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row,
  .module-briefing {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row {
    flex-direction: column;
  }

  .button-row button,
  .button-row .file-button {
    width: 100%;
  }

  .toolbar input,
  .toolbar select {
    max-width: none;
  }
}

/* ============================================================
   Constellation (home stage) — brain canvas + breathing core +
   live agent ring. Ported from prototype/jarvis-agents.html.
   Prototype --cyan maps to var(--brand).
   ============================================================ */
/* One-box command view: the section card chrome is stripped so the brain scene
   is the only visible box, with the glass command bar floating on top of it. */
#command.view:not(.hidden) { display: flex; flex-direction: column; height: 100%; }
#command {
  position: relative;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  --scene-cy: 0.47; /* mirrors sceneCy() in app.js; JS keeps it in sync */
}
#command .command-bar {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 32px));
  z-index: 8;
  padding: 10px 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(57, 230, 255, 0.22);
  background: rgba(6, 12, 24, 0.42);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 0 24px rgba(57, 230, 255, 0.05);
  overflow: hidden;
  transition: opacity 0.3s;
}
/* Step back while the dossier or war-room takes the stage. */
#command:has(.dossier.show) .command-bar,
#command:has(.scene.waron) .command-bar {
  opacity: 0;
  pointer-events: none;
}
.bar-wave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 24px;
  display: block;
  opacity: 0.8;
  pointer-events: none;
}

.scene {
  position: relative;
  flex: 1 1 auto;
  min-height: min(70vh, 560px);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 47%, rgba(57, 230, 255, 0.06), rgba(4, 6, 15, 0) 62%);
}

/* ---- radar stage backdrop (ported from prototype/jarvis-agents.html) ---- */
.stage-fx { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.stage-fx .sweep {
  position: absolute; left: 50%; top: 47%; width: 150%; height: 150%; transform: translate(-50%, -50%);
  background: conic-gradient(from 0deg, color-mix(in srgb, var(--brand) 11%, transparent), transparent 16% 100%);
  mix-blend-mode: screen; opacity: 0.55; animation: rspin 16s linear infinite;
}
.stage-fx .sweep.b {
  background: conic-gradient(from 180deg, color-mix(in srgb, var(--violet) 9%, transparent), transparent 14% 100%);
  animation-duration: 24s; animation-direction: reverse; opacity: 0.4;
}
.stage-fx i {
  position: absolute; left: 50%; top: 47%; border-radius: 50%;
  border: 1px dashed color-mix(in srgb, var(--brand) 18%, transparent);
  transform: translate(-50%, -50%); animation: rspin linear infinite;
}
@keyframes rspin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.stage-fx .well {
  position: absolute; left: 50%; top: 47%; width: 780px; height: 780px; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle, rgba(57, 230, 255, 0.12) 0 7%, rgba(8, 16, 34, 0) 20%, rgba(3, 7, 18, 0.45) 44%, rgba(1, 4, 12, 0.78) 66%, transparent 80%);
  animation: wellpulse 7s ease-in-out infinite;
}
@keyframes wellpulse {
  0%, 100% { opacity: 0.82; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.03); }
}
.stage-fx .housing {
  position: absolute; left: 50%; top: 47%; width: 300px; height: 300px; transform: translate(-50%, -50%); border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--brand) 30%, transparent) 0 1.4deg, transparent 1.4deg 9deg);
  mask: radial-gradient(circle, transparent 0 47%, #000 48% 50%, transparent 51%);
  -webkit-mask: radial-gradient(circle, transparent 0 47%, #000 48% 50%, transparent 51%);
  animation: rspin 120s linear infinite reverse; opacity: 0.5;
}
.stage-fx .dust {
  position: absolute; inset: -20%;
  background-image:
    radial-gradient(circle, rgba(150, 200, 255, 0.5) 0.7px, transparent 1.2px),
    radial-gradient(circle, rgba(120, 160, 255, 0.35) 0.7px, transparent 1.2px);
  background-size: 120px 120px, 200px 200px; background-position: 0 0, 40px 60px;
  opacity: 0.35; animation: dustfloat 36s linear infinite;
}
@keyframes dustfloat { from { transform: translateY(0); } to { transform: translateY(-120px); } }

.brain-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; display: block; }
.fx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 6; display: block; pointer-events: none; }

.core-label { position: absolute; top: calc(var(--scene-cy, 0.47) * 100%); left: 0; right: 0; transform: translateY(-50%); text-align: center; z-index: 2; pointer-events: none; transition: color 0.4s, transform 0.95s cubic-bezier(0.2, 1, 0.3, 1); }
.core-label b { font-family: var(--font-display); font-weight: 900; font-size: 24px; letter-spacing: 6px; color: #eafaff; text-shadow: 0 0 22px rgba(143, 233, 255, 0.7), 0 0 6px rgba(255, 255, 255, 0.6); }
.core-label span { display: block; font-size: 11px; letter-spacing: 4px; color: #b8e6ff; margin-top: 5px; }

.ring { position: absolute; left: 50%; top: calc(var(--scene-cy, 0.47) * 100%); width: 1px; height: 1px; z-index: 4; animation: ringspin 160s linear infinite; }
.ring.paused { animation-play-state: paused; }
@keyframes ringspin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.agent {
  position: absolute; left: 0; top: 0; width: 96px; height: 104px; margin: -52px 0 0 -48px;
  transform: rotate(var(--a)) translateY(calc(-1 * var(--R, 190px))) rotate(calc(-1 * var(--a)));
  display: flex; flex-direction: column; align-items: center; gap: 7px; cursor: pointer; background: none; border: none; padding: 0;
}
.agent .spin { display: flex; flex-direction: column; align-items: center; gap: 7px; animation: ringspin 160s linear infinite reverse; }
.ring.paused .agent .spin { animation-play-state: paused; }
.orbwrap { position: relative; width: 58px; height: 58px; display: grid; place-items: center; opacity: 0; transform: scale(0.35); transition: opacity 0.5s ease, transform 0.55s cubic-bezier(0.2, 1.4, 0.3, 1); }
.ring.ready .orbwrap { opacity: 1; transform: scale(1); }
.agent .orb {
  width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; line-height: 1; color: var(--ac);
  border: 1.5px solid color-mix(in srgb, var(--ac) 70%, transparent);
  background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--ac) 26%, transparent), rgba(8, 12, 26, 0.78) 72%);
  box-shadow: 0 0 16px -2px color-mix(in srgb, var(--ac) 60%, transparent), inset 0 0 14px -4px color-mix(in srgb, var(--ac) 70%, transparent);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.agent .orb svg { width: 27px; height: 27px; display: block; overflow: visible; filter: drop-shadow(0 0 4px color-mix(in srgb, currentColor 55%, transparent)); }
.agent .nm { font-family: var(--font-display); font-weight: 700; font-size: 10px; letter-spacing: 2px; color: var(--ink); text-shadow: 0 0 8px rgba(0, 0, 0, 0.8); }
.agent .rl { font-size: 10px; color: var(--muted); max-width: 104px; text-align: center; line-height: 1.15; opacity: 0; transition: 0.2s; height: 0; overflow: hidden; }
.agent .ptag { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 1.5px; color: var(--muted); }
[dir="rtl"] .agent .ptag { font-family: "Lusail", var(--font-mono); }
.agent:hover .orb { transform: scale(1.16); box-shadow: 0 0 26px color-mix(in srgb, var(--ac) 85%, transparent), inset 0 0 16px -2px color-mix(in srgb, var(--ac) 80%, transparent); }
.agent:hover .rl { opacity: 1; height: auto; margin-top: -2px; }
.agent:hover .nm { color: var(--ac); }
.agent.engaged .orb { transform: scale(1.1); border-color: var(--ac); box-shadow: 0 0 34px color-mix(in srgb, var(--ac) 95%, transparent), inset 0 0 18px color-mix(in srgb, var(--ac) 60%, transparent); animation: apulse 1.8s ease-in-out infinite; }
@keyframes apulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }
.agent.planned .orb { border-style: dashed; filter: saturate(0.30) brightness(0.72); box-shadow: none; }
.agent.planned:hover .orb { transform: scale(1.08); filter: saturate(0.45) brightness(0.85); }

.statusring { position: absolute; left: 50%; top: 50%; width: 76px; height: 76px; transform: translate(-50%, -50%) rotate(-90deg); pointer-events: none; overflow: visible; }
.statusring .track { fill: none; stroke: color-mix(in srgb, var(--ac) 16%, transparent); stroke-width: 3; }
.statusring .fill { fill: none; stroke: var(--ac); stroke-width: 3; stroke-linecap: round; filter: drop-shadow(0 0 4px color-mix(in srgb, var(--ac) 80%, transparent)); transition: stroke-dashoffset 1.1s cubic-bezier(0.2, 0.8, 0.2, 1); }
.agent.working .statusring { animation: ringtwirl 8s linear infinite; }
@keyframes ringtwirl { to { transform: translate(-50%, -50%) rotate(270deg); } }
.brackets { position: absolute; inset: -10px; pointer-events: none; opacity: 0; transform: scale(1.3); transition: opacity 0.3s, transform 0.3s; }
.agent.engaged .brackets { opacity: 1; transform: scale(1); animation: brkpulse 1.8s ease-in-out infinite; }
@keyframes brkpulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.6); } }
.brackets i { position: absolute; width: 13px; height: 13px; border: 2px solid var(--ac); filter: drop-shadow(0 0 5px color-mix(in srgb, var(--ac) 85%, transparent)); }
.brackets i:nth-child(1) { left: 0; top: 0; border-right: none; border-bottom: none; }
.brackets i:nth-child(2) { right: 0; top: 0; border-left: none; border-bottom: none; }
.brackets i:nth-child(3) { left: 0; bottom: 0; border-right: none; border-top: none; }
.brackets i:nth-child(4) { right: 0; bottom: 0; border-left: none; border-top: none; }

/* ---- War-room council briefing (ported from prototype/jarvis-agents.html) ---------
   Press B (or the Daily-briefing control): the ring pauses and flattens into a glowing
   council table below the core; agents glide to seats; each presents ONE real line from
   live state (same figures as the executive-briefing cards), then the ring reforms. The
   flatten uses CSS transitions, so reduced-motion users simply see it snap. */
.ring.warroom .agent { transition: transform 0.95s cubic-bezier(0.25, 1.25, 0.35, 1); }
.ring.warroom.presenting .agent:not(.present) { filter: brightness(0.55) saturate(0.7); }
.ring.warroom .agent.present { z-index: 6; }
.ring.warroom .agent.present .orb { border-color: var(--ac); box-shadow: 0 0 16px var(--ac), inset 0 0 18px rgba(255, 255, 255, 0.08); }
.wartable {
  position: absolute; border-radius: 50%; pointer-events: none; opacity: 0; transform: scale(0.55); z-index: 1;
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 1.1, 0.3, 1);
  border: 1px solid rgba(90, 225, 255, 0.65);
  background: radial-gradient(ellipse at 50% 38%, rgba(80, 220, 255, 0.16), rgba(80, 220, 255, 0.05) 52%, transparent 74%);
  box-shadow: inset 0 0 46px rgba(80, 220, 255, 0.16), 0 0 26px rgba(90, 225, 255, 0.30), 0 0 70px rgba(80, 220, 255, 0.14);
}
.wartable::before { content: ''; position: absolute; inset: 10% 8%; border-radius: 50%; border: 1px dashed rgba(90, 225, 255, 0.32); }
.wartable::after { content: ''; position: absolute; inset: 40% 37%; border-radius: 50%; border: 1px solid rgba(90, 225, 255, 0.40); background: radial-gradient(circle, rgba(80, 220, 255, 0.14), transparent 70%); }
.wartable.show { opacity: 1; transform: none; }
/* the constellation steps back while the council is seated */
.brain-canvas { transition: transform 0.95s cubic-bezier(0.2, 1, 0.3, 1), opacity 0.95s; transform-origin: 50% 47%; }
.scene.waron .brain-canvas { transform: scale(0.55); opacity: 0.55; }
.scene.waron .core-label { transform: translateY(calc(-50% - 46px)); }
.warcap {
  position: absolute; left: 6%; right: 6%; top: calc(47% - 152px); z-index: 5; text-align: center; pointer-events: none;
  font-weight: 600; font-size: 17px; letter-spacing: 0.4px; color: #cfeeff;
  text-shadow: 0 0 12px rgba(57, 230, 255, 0.45), 0 2px 8px rgba(0, 0, 0, 0.7); opacity: 0; transition: opacity 0.4s;
}
.warcap.show { opacity: 1; }
.warcap.typing::after { content: '▍'; color: var(--brand); margin-inline-start: 2px; animation: warblink 1s steps(1) infinite; }
@keyframes warblink { 50% { opacity: 0; } }
@media (max-width: 820px) {
  .warcap { left: 4%; right: 4%; top: calc(54% - 128px); font-size: 12.5px; }
  .brain-canvas { transform-origin: 50% 54%; }
}

.foot-hint { position: absolute; left: 0; right: 0; bottom: 14px; z-index: 3; text-align: center; font-size: 11px; letter-spacing: 2px; color: var(--muted); pointer-events: none; padding: 0 18px; }

/* ---- 17.6 live job-loop feedback --------------------------------------------------
   The HUD reflects the REAL job loop. #scene-hint (.foot-hint) carries the genuine,
   server-reported state; the core + engaged orb resolve only to an agent the server
   actually names. Everything below is decoration — JS skips the comet under reduced
   motion, and the reduced-motion block freezes the core/predict pulses. */
.comet { position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none; display: flex; align-items: center; gap: 9px; white-space: nowrap; font-weight: 700; font-size: 15px; letter-spacing: 0.5px; color: #eaffff; text-shadow: 0 0 8px rgba(255, 255, 255, 0.6), 0 0 22px rgba(57, 230, 255, 0.85); will-change: transform, opacity; }
.comet .chead { width: 16px; height: 16px; border-radius: 50%; flex: none; background: radial-gradient(circle, #fff 0 28%, rgba(140, 242, 255, 0.95) 52%, rgba(57, 230, 255, 0) 74%); box-shadow: 0 0 14px 5px rgba(150, 246, 255, 0.9), 0 0 40px 14px rgba(57, 230, 255, 0.5); }
.comet .clabel { font-family: var(--font-mono); }
[dir="rtl"] .comet .clabel { font-family: "Lusail", var(--font-mono); }
.cspark { position: fixed; z-index: 79; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(57, 230, 255, 0.6) 50%, transparent 75%); animation: csparkfade 0.8s ease-out forwards; }
@keyframes csparkfade { to { opacity: 0; transform: scale(0.3); } }
/* core brightens while a real job is in flight; one-shot pop when it resolves */
.scene.working .core-label b { animation: coreWork 1.2s ease-in-out infinite; }
@keyframes coreWork { 0%, 100% { text-shadow: 0 0 22px rgba(143, 233, 255, 0.7), 0 0 6px rgba(255, 255, 255, 0.6); } 50% { text-shadow: 0 0 36px rgba(143, 233, 255, 0.98), 0 0 12px rgba(255, 255, 255, 0.9); } }
.core-label.resolved b { animation: coreResolve 0.7s ease-out 1; }
@keyframes coreResolve { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* predictive / anticipatory card — real proposals only; stays hidden until a genuine
   proposals feed exists (never a canned suggestion). */
.predict { position: absolute; left: 18px; bottom: 46px; z-index: 6; width: min(264px, 60%); background: linear-gradient(180deg, color-mix(in srgb, var(--warn) 12%, transparent), rgba(9, 15, 26, 0.86)); border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); border-left: 2px solid var(--warn); border-radius: 14px; padding: 11px 13px 12px; backdrop-filter: blur(9px); box-shadow: 0 0 34px -10px color-mix(in srgb, var(--warn) 55%, transparent); }
.predict.hidden { display: none; }
.predict-h { display: flex; align-items: center; gap: 7px; font-family: var(--font-display); font-size: 9px; letter-spacing: 2px; color: var(--warn); }
.predict-h .pby { margin-left: auto; font-family: var(--font-mono); font-size: 9.5px; color: var(--warn); opacity: 0.85; }
[dir="rtl"] .predict { left: auto; right: 18px; border-left: 1px solid color-mix(in srgb, var(--warn) 50%, transparent); border-right: 2px solid var(--warn); }
[dir="rtl"] .predict-h .pby { margin-left: 0; margin-right: auto; }
.predict .ppulse { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 8px var(--warn); animation: ppulse 1.8s infinite; }
@keyframes ppulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.6); } }
.predict-t { font-size: 13.5px; line-height: 1.36; color: #e3ecff; margin: 9px 0 11px; }
[dir="rtl"] .predict-t { font-family: "Lusail", sans-serif; font-size: 15px; }
.predict-a { display: flex; gap: 8px; align-items: center; }
.predict .pyes { flex: 1; font-family: var(--font-display); font-size: 10px; letter-spacing: 1.5px; color: #0a0f1c; background: var(--warn); border: none; border-radius: 9px; padding: 8px; cursor: pointer; font-weight: 700; }
[dir="rtl"] .predict .pyes { font-family: "Lusail", var(--font-display); letter-spacing: 0; }
.predict .pyes:hover { box-shadow: 0 0 16px var(--warn); }
.predict .pno { width: 30px; height: 30px; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--warn) 38%, transparent); background: transparent; color: var(--warn); cursor: pointer; font-size: 12px; }
.predict .pno:hover { background: color-mix(in srgb, var(--warn) 16%, transparent); }

/* dossier */
.dossier { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.28s; background: rgba(4, 6, 15, 0.5); backdrop-filter: blur(3px); }
.dossier.show { opacity: 1; pointer-events: auto; }
.dossier-card { width: min(420px, 82%); background: var(--panel-solid); border: 1px solid var(--dc, var(--brand)); border-radius: 18px; padding: 22px; box-shadow: 0 0 46px -6px color-mix(in srgb, var(--dc, var(--brand)) 60%, transparent), inset 0 0 30px rgba(80, 140, 255, 0.05); transform: translateY(14px) scale(0.97); transition: transform 0.3s; position: relative; }
.dossier.show .dossier-card { transform: none; }
.dossier-x { position: absolute; top: 12px; right: 14px; border: none; background: none; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; }
[dir="rtl"] .dossier-x { right: auto; left: 14px; }
.dossier-x:hover { color: var(--ink); }
.dossier-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.dossier-orb { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; flex: none; color: var(--dc, var(--brand)); border: 1.5px solid color-mix(in srgb, var(--dc, var(--brand)) 70%, transparent); background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--dc, var(--brand)) 30%, transparent), rgba(8, 12, 26, 0.8) 72%); box-shadow: 0 0 20px -4px color-mix(in srgb, var(--dc, var(--brand)) 70%, transparent); }
.dossier-orb svg { width: 31px; height: 31px; display: block; overflow: visible; }
.dossier-card h2 { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: 21px; letter-spacing: 3px; color: var(--dc, var(--brand)); text-shadow: 0 0 16px color-mix(in srgb, var(--dc, var(--brand)) 55%, transparent); }
.dossier-role { font-size: 12px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; }
[dir="rtl"] .dossier-role { text-transform: none; }
.dossier-stat { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--green); margin-top: 4px; }
.dossier-stat .d { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.dossier-stat.planned { color: var(--muted); }
.dossier-stat.planned .d { background: var(--muted); box-shadow: none; }
[dir="rtl"] .dossier-stat { font-family: "Lusail", var(--font-mono); }
.dossier-desc { font-size: 14px; line-height: 1.5; color: var(--ink); margin: 14px 0 4px; }
.dossier-sk-h { font-family: var(--font-display); font-size: 10px; letter-spacing: 2.5px; color: var(--muted); margin: 14px 0 9px; }
[dir="rtl"] .dossier-sk-h { font-family: "Lusail", var(--font-display); letter-spacing: 0; }
.dossier-skills { display: flex; flex-wrap: wrap; gap: 7px; }
.dossier-skill { font-size: 12px; color: var(--ink); border: 1px solid color-mix(in srgb, var(--dc, var(--brand)) 40%, var(--line)); border-radius: 9px; padding: 6px 11px; background: color-mix(in srgb, var(--dc, var(--brand)) 8%, transparent); display: flex; align-items: center; gap: 6px; }
.dossier-skill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--dc, var(--brand)); box-shadow: 0 0 6px var(--dc, var(--brand)); }
.dossier-acts { display: flex; gap: 10px; margin-top: 18px; }
.dossier-acts button { flex: 1; border: none; border-radius: 11px; padding: 12px; font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: 1.5px; cursor: pointer; transition: 0.2s; }
[dir="rtl"] .dossier-acts button { font-family: "Lusail", var(--font-display); letter-spacing: 0; }
.dossier-engage { background: linear-gradient(180deg, var(--dc, var(--brand)), color-mix(in srgb, var(--dc, var(--brand)) 55%, #000)); color: #02141b; box-shadow: 0 0 18px -2px color-mix(in srgb, var(--dc, var(--brand)) 70%, transparent); }
.dossier-ask { background: color-mix(in srgb, var(--dc, var(--brand)) 8%, transparent); border: 1px solid color-mix(in srgb, var(--dc, var(--brand)) 40%, var(--line)); color: var(--dc, var(--brand)); }
.dossier-acts button:hover { filter: brightness(1.12); transform: translateY(-1px); }

@media (max-width: 820px) {
  .scene { min-height: min(70vh, 520px); }
  .core-label b { font-size: 20px; letter-spacing: 4px; }
  #command .command-bar { top: 10px; width: calc(100% - 20px); padding: 8px 10px 12px; }
  .command-input-row { gap: 8px; }
  .command-input-row .pill { display: none; }
}

/* ===== boot overlay (17.7) — cockpit power-up on entry, then self-removes ===== */
.boot { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: radial-gradient(circle at 50% 42%, rgba(12, 22, 44, 0.96), rgba(4, 6, 15, 0.99)); transition: opacity 0.5s ease; }
.boot.hidden { display: none; }
.boot.done { opacity: 0; pointer-events: none; }
.boot .col { text-align: center; }
.boot .r2 { position: relative; width: 128px; height: 128px; margin: 0 auto 26px; }
.boot .r2 > div { position: absolute; inset: 0; border-radius: 50%; border: 2px solid transparent; }
.boot .r2 > div:nth-child(1) { border-top-color: var(--brand); box-shadow: var(--glow); animation: spin360 1s linear infinite; }
.boot .r2 > div:nth-child(2) { inset: 14px; border-right-color: var(--violet); animation: spin360 1.6s linear infinite reverse; }
.boot .r2 > div:nth-child(3) { inset: 30px; border-bottom-color: var(--warn); animation: spin360 0.8s linear infinite; }
.boot .r2 b { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 900; font-size: 13px; letter-spacing: 3px; color: var(--brand); text-shadow: var(--glow); }
@keyframes spin360 { to { transform: rotate(360deg); } }
.boot .bt { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: 7px; color: #eafaff; text-shadow: var(--glow); }
[dir="rtl"] .boot .bt { font-family: "Lusail", var(--font-display); letter-spacing: 2px; }
.boot .bl { font-family: var(--font-mono); font-size: 12px; letter-spacing: 2px; color: var(--brand); margin-top: 14px; min-height: 18px; }
[dir="rtl"] .boot .bl { font-family: "Lusail", var(--font-mono); letter-spacing: 0; }
.boot .bl::before { content: "> "; }
[dir="rtl"] .boot .bl::before { content: ""; }

/* Reduced motion: freeze the ring and orb pulses; JS draws a single static frame. */
@media (prefers-reduced-motion: reduce) {
  .ring, .agent .spin { animation: none !important; }
  .agent.engaged .orb, .agent.working .statusring, .agent.engaged .brackets { animation: none !important; }
  .orbwrap { opacity: 1; transform: none; transition: none; }
  .scene.working .core-label b, .core-label.resolved b, .predict .ppulse { animation: none !important; }
  .comet, .chead, .cspark { animation: none !important; }
  .warcap.typing::after { animation: none !important; }
  .boot .r2 > div { animation: none !important; }
  .boot { transition: none; }
}

/* Areas hub — five life-area cards, each a live-count mini-dashboard tile. */
.areas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.area-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  text-align: start;
  border: 1px solid var(--line, #2a3550);
  border-radius: 14px;
  background: var(--panel, #121a2e);
  color: inherit;
  cursor: pointer;
  transition: border-color 160ms ease-out, transform 160ms ease-out;
}
.area-card:hover { border-color: var(--accent, #4da3ff); transform: translateY(-2px); }
.area-card:focus-visible { outline: 2px solid var(--accent, #4da3ff); outline-offset: 2px; }
.area-card h3 { margin: 0; font-size: 1.1rem; }
.area-card .area-count { font-size: 1.6rem; font-weight: 700; }
.area-card .area-hint { color: var(--muted, #9fb0d0); font-size: 0.85rem; }
@media (prefers-reduced-motion: reduce) {
  .area-card { transition: none; }
  .area-card:hover { transform: none; }
}

/* Agents tab — JARVIS hierarchy + per-agent skill map (intent §5). */
.agents-hierarchy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 16px 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(6, 10, 22, 0.55);
  margin-bottom: 18px;
}
.agents-root { text-align: center; display: grid; gap: 4px; }
.agents-root-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 4px;
  color: var(--brand);
}
.agents-root-sub { font-size: 12px; color: var(--muted); }
.agents-branches {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.agents-branch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid color-mix(in srgb, var(--ac, var(--brand)) 45%, transparent);
  border-radius: 12px;
  background: rgba(8, 12, 26, 0.6);
}
.agents-branch.planned { border-style: dashed; opacity: 0.78; }
.agents-branch .branch-orb { width: 34px; height: 34px; border-radius: 10px; }
.agents-branch .branch-orb svg { width: 18px; height: 18px; }
.branch-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--ac, var(--brand));
}
[dir="rtl"] .branch-name { font-family: "Lusail", var(--font-display); letter-spacing: 0; }
.agents-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.agent-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--ac, var(--brand)) 40%, var(--line));
  border-radius: 14px;
  background: rgba(6, 10, 22, 0.55);
}
.agent-card.planned { border-style: dashed; }
.agent-card-head { display: flex; align-items: center; gap: 12px; }
.agent-card-title { flex: 1 1 auto; min-width: 0; display: grid; gap: 3px; }
.agent-card-role { font-size: 11px; color: var(--muted); }
.agent-card-desc { margin: 0; font-size: 13px; line-height: 1.55; }
.agent-card-authority {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 10px;
  border-inline-start: 2px solid var(--ac, var(--brand));
  background: rgba(120, 160, 255, 0.05);
  border-radius: 0 8px 8px 0;
}
[dir="rtl"] .agent-card-authority { border-radius: 8px 0 0 8px; }
.agent-card-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.agent-card-cols h4 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.agent-skill-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.agent-skill-list li { font-size: 12px; }
.agent-skill-list code {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(120, 160, 255, 0.08);
}
@media (max-width: 640px) {
  .agent-card-cols { grid-template-columns: 1fr; }
}
