/* =========================================================================
   A.C.E. (Adaptive Command Engine) — Holographic HUD (Stark command center)
   Cyan (#2fe6ff) + gold (#ffcf6a) on deep near-black (#04070d).
   ========================================================================= */

:root {
  --bg:        #04070d;
  --cyan:      #2fe6ff;
  --cyan-dim:  #1aa6c4;
  --gold:      #ffcf6a;
  --gold-dim:  #c79a3e;
  --fg:        #cdeffb;
  --muted:     #5c8597;
  --danger:    #ff5d6c;
  --ok:        #43f0b0;
  --glass:     rgba(8, 22, 32, 0.45);
  --glass-line: rgba(47, 230, 255, 0.22);
  --glow-cyan: 0 0 8px rgba(47, 230, 255, 0.55), 0 0 22px rgba(47, 230, 255, 0.25);
  --glow-gold: 0 0 8px rgba(255, 207, 106, 0.55), 0 0 22px rgba(255, 207, 106, 0.22);
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* ---- Background environment: vignette + tech grid + scanlines ---------- */
#bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1200px 800px at 50% 46%, rgba(13, 40, 56, 0.55), rgba(4, 7, 13, 0) 60%),
    radial-gradient(1600px 1200px at 50% 50%, rgba(4, 7, 13, 0) 55%, rgba(0, 0, 0, 0.85) 100%),
    var(--bg);
}
#bg::before {
  /* faint tech grid */
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(47, 230, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 230, 255, 0.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 50%, black 35%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, black 35%, transparent 78%);
}
#bg::after {
  /* moving scanlines */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px,
    rgba(47, 230, 255, 0.025) 3px, rgba(0,0,0,0) 4px);
  animation: scan 7s linear infinite;
  opacity: 0.6;
}
@keyframes scan { from { background-position: 0 0; } to { background-position: 0 220px; } }

/* Orb canvas sits above bg, below HUD */
#orb {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  display: block; z-index: 1;
}

/* ---- HUD overlay shell ------------------------------------------------- */
#hud {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
}

/* Corner brackets (the four "frame" angles) */
.bracket {
  position: fixed; width: 64px; height: 64px; z-index: 3;
  border: 2px solid var(--cyan-dim);
  opacity: 0.55; pointer-events: none;
  box-shadow: var(--glow-cyan);
}
.bracket.tl { top: 20px; left: 20px; border-right: none; border-bottom: none; }
.bracket.tr { top: 20px; right: 20px; border-left: none; border-bottom: none; }
.bracket.bl { bottom: 20px; left: 20px; border-right: none; border-top: none; }
.bracket.br { bottom: 20px; right: 20px; border-left: none; border-top: none; }

/* Faint perimeter frame line */
#hud::before {
  content: ""; position: fixed; inset: 30px; z-index: 2;
  border: 1px solid rgba(47, 230, 255, 0.08);
  pointer-events: none;
}

/* ---- Top-left label + state readout ----------------------------------- */
#brand {
  position: fixed; top: 34px; left: 44px; z-index: 4; pointer-events: none;
}
#brand .name {
  font-size: 16px; letter-spacing: 0.5em; font-weight: 500;
  color: var(--cyan); text-shadow: var(--glow-cyan);
}
#brand .tag {
  font-size: 10px; letter-spacing: 0.34em; color: var(--muted);
  margin-top: 6px; text-transform: uppercase;
}
#brand .tag .online { color: var(--ok); text-shadow: 0 0 8px rgba(67,240,176,0.6); }

/* State readout, centered below brand */
#stateReadout {
  position: fixed; top: 84px; left: 44px; z-index: 4; pointer-events: none;
  display: flex; align-items: center; gap: 10px;
}
#stateReadout .lamp {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--cyan); box-shadow: var(--glow-cyan);
  animation: lampPulse 1.6s ease-in-out infinite;
}
@keyframes lampPulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }
#stateReadout .label {
  font-size: 13px; letter-spacing: 0.42em; color: var(--cyan);
  text-shadow: var(--glow-cyan);
}
/* state-driven tint */
body[data-state="listening"] #stateReadout .lamp,
body[data-state="listening"] #stateReadout .label { color: var(--gold); background: var(--gold); }
body[data-state="listening"] #stateReadout .lamp { box-shadow: var(--glow-gold); }
body[data-state="listening"] #stateReadout .label { text-shadow: var(--glow-gold); background: none; }
body[data-state="thinking"] #stateReadout .label { color: #9fb6c0; text-shadow: none; }
body[data-state="speaking"] #stateReadout .lamp { animation-duration: 0.5s; }

/* ---- Top-right telemetry ticks ---------------------------------------- */
#telemetry {
  position: fixed; top: 34px; right: 44px; z-index: 4; pointer-events: none;
  text-align: right; font-size: 10px; letter-spacing: 0.18em;
  color: var(--muted); line-height: 1.7;
}
#telemetry .row { white-space: nowrap; }
#telemetry .v { color: var(--cyan); text-shadow: 0 0 6px rgba(47,230,255,0.4); }
#telemetry .bar {
  display: inline-block; width: 70px; height: 5px; margin-left: 8px;
  vertical-align: middle; background: rgba(47,230,255,0.12);
  border: 1px solid rgba(47,230,255,0.2); overflow: hidden;
}
#telemetry .bar > span {
  display: block; height: 100%; width: 8%;
  background: var(--cyan); box-shadow: var(--glow-cyan);
  transition: width 0.08s linear;
}

/* ---- Holo console (transcript / reply log) ---------------------------- */
#console {
  position: fixed; right: 44px; top: 130px; bottom: 210px;
  width: min(420px, 40vw); z-index: 4;
  display: flex; flex-direction: column; pointer-events: none;
}
#console .chead {
  font-size: 10px; letter-spacing: 0.3em; color: var(--muted);
  text-transform: uppercase; padding-bottom: 8px;
  border-bottom: 1px solid var(--glass-line); margin-bottom: 10px;
}
#log {
  flex: 1; overflow-y: auto; pointer-events: auto;
  display: flex; flex-direction: column; gap: 9px;
  padding-right: 6px; scrollbar-width: thin;
  scrollbar-color: var(--cyan-dim) transparent;
  /* Override the global user-select:none so chat text can be selected/copied. */
  -webkit-user-select: text; user-select: text;
}
#log::-webkit-scrollbar { width: 5px; }
#log::-webkit-scrollbar-thumb { background: var(--cyan-dim); border-radius: 3px; }

.msg {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-left: 2px solid var(--cyan);
  padding: 9px 12px; font-size: 13px; line-height: 1.5;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: rise 0.2s ease-out;
  -webkit-user-select: text; user-select: text; cursor: text;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg .role {
  font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 4px;
  -webkit-user-select: text; user-select: text;
}
.msg.user { border-left-color: var(--gold); }
.msg.user .role { color: var(--gold); }
.msg.jarvis .role { color: var(--cyan); }
.msg.system {
  background: transparent; border: none; border-left: 2px solid rgba(92,133,151,0.4);
  color: var(--muted); font-size: 11px; letter-spacing: 0.06em;
}
.actions { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.action {
  font-size: 10px; color: var(--muted); letter-spacing: 0.04em;
  background: rgba(47,230,255,0.06); border: 1px solid rgba(47,230,255,0.14);
  padding: 5px 8px; white-space: pre-wrap; word-break: break-word;
}
.action b { color: var(--cyan); font-weight: 600; }

/* ---- Approvals (HUD-styled) ------------------------------------------- */
#approvals {
  position: fixed; left: 50%; top: 20%; transform: translateX(-50%);
  width: min(480px, 90vw); z-index: 6;
  display: flex; flex-direction: column; gap: 12px; pointer-events: auto;
}
.approval {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--gold);
  padding: 18px 20px;
  box-shadow: var(--glow-gold), 0 18px 60px rgba(0,0,0,0.6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: rise 0.2s ease-out;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}
.approval .head {
  font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--gold); text-shadow: var(--glow-gold); margin-bottom: 8px;
}
.approval .tool { font-weight: 600; font-size: 15px; color: var(--fg); letter-spacing: 0.04em; }
.approval .detail {
  font-size: 11px; color: var(--fg); opacity: 0.85; margin: 10px 0 14px;
  white-space: pre-wrap; word-break: break-word;
  max-height: 170px; overflow-y: auto; line-height: 1.5;
  border-left: 2px solid rgba(255,207,106,0.4); padding-left: 10px;
}
.approval .btns { display: flex; gap: 12px; }
.approval button {
  flex: 1; border: 1px solid; padding: 11px; cursor: pointer; pointer-events: auto;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  letter-spacing: 0.24em; text-transform: uppercase; background: transparent;
  transition: all 0.12s ease;
}
.approval .approve { color: var(--ok); border-color: var(--ok); }
.approval .approve:hover { background: rgba(67,240,176,0.12); box-shadow: 0 0 14px rgba(67,240,176,0.4); }
.approval .deny { color: var(--danger); border-color: var(--danger); }
.approval .deny:hover { background: rgba(255,93,108,0.12); box-shadow: 0 0 14px rgba(255,93,108,0.4); }

/* ---- Bottom command bar (mic + interim transcript + text fallback) ---- */
#dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding-bottom: 40px; pointer-events: none;
}

/* live interim transcript above the mic */
#interim {
  min-height: 22px; max-width: min(620px, 86vw); text-align: center;
  font-size: 15px; letter-spacing: 0.04em; color: var(--gold);
  text-shadow: var(--glow-gold); opacity: 0; transition: opacity 0.15s ease;
  pointer-events: none; padding: 0 18px;
}
#interim.show { opacity: 0.92; }
#interim .caret {
  display: inline-block; width: 8px; height: 16px; margin-left: 4px;
  background: var(--gold); vertical-align: middle;
  animation: blink 0.9s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

#micWrap { position: relative; pointer-events: none; }
#mic {
  pointer-events: auto;
  width: 84px; height: 84px; border-radius: 50%;
  border: 1px solid var(--cyan);
  background: radial-gradient(circle at 50% 40%, rgba(47,230,255,0.18), rgba(4,12,20,0.85));
  color: var(--cyan); font-size: 26px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--glow-cyan), inset 0 0 18px rgba(47,230,255,0.25);
  transition: transform 0.1s ease, box-shadow 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
#mic:hover { transform: scale(1.04); }
#mic.recording {
  transform: scale(1.1);
  border-color: var(--gold); color: var(--gold);
  background: radial-gradient(circle at 50% 40%, rgba(255,207,106,0.28), rgba(20,12,4,0.9));
  box-shadow: var(--glow-gold), 0 0 0 10px rgba(255,207,106,0.10), inset 0 0 22px rgba(255,207,106,0.35);
  animation: micPulse 1.1s ease-in-out infinite;
}
@keyframes micPulse {
  0%,100% { box-shadow: var(--glow-gold), 0 0 0 8px rgba(255,207,106,0.10), inset 0 0 22px rgba(255,207,106,0.35); }
  50%     { box-shadow: var(--glow-gold), 0 0 0 16px rgba(255,207,106,0.04), inset 0 0 28px rgba(255,207,106,0.5); }
}
/* AUTO mode: continuous session is active (but not currently recording this
   instant — e.g. waiting for / playing Jarvis's reply). A calmer, steady
   gold ring distinguishes "session armed" from the pulsing "recording" state. */
#mic.auto-active:not(.recording) {
  border-color: var(--gold); color: var(--gold);
  box-shadow: var(--glow-gold), 0 0 0 6px rgba(255,207,106,0.08), inset 0 0 16px rgba(255,207,106,0.2);
}
/* rotating ring around mic */
#micWrap::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 1px dashed rgba(47,230,255,0.28); animation: spin 9s linear infinite;
  pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

#micLabel {
  font-size: 10px; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--muted); pointer-events: none;
}

/* ---- Wake-word toggle (hands-free "Jarvis…") -------------------------- */
.wake-toggle {
  pointer-events: auto; cursor: pointer;
  background: transparent; color: var(--muted);
  border: 1px solid var(--glass-line);
  padding: 8px 16px; font-family: var(--mono); font-weight: 500;
  font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.14s ease;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 9px 100%, 0 calc(100% - 9px));
}
.wake-toggle:hover {
  color: var(--cyan); border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(47,230,255,0.3);
}
.wake-toggle #wakeState { color: var(--muted); font-weight: 600; }
/* ON state — cyan, lit */
.wake-toggle[data-wake="on"] {
  color: var(--cyan); border-color: var(--cyan);
  box-shadow: var(--glow-cyan), inset 0 0 12px rgba(47,230,255,0.12);
}
.wake-toggle[data-wake="on"] #wakeState {
  color: var(--cyan); text-shadow: var(--glow-cyan);
}
/* ARMED & LISTENING — wake heard, gold flash while it grabs the command */
.wake-toggle.armed {
  color: var(--gold); border-color: var(--gold);
  box-shadow: var(--glow-gold), inset 0 0 14px rgba(255,207,106,0.2);
  animation: wakeFlash 0.5s ease-in-out infinite alternate;
}
.wake-toggle.armed #wakeState { color: var(--gold); text-shadow: var(--glow-gold); }
@keyframes wakeFlash {
  from { box-shadow: var(--glow-gold), inset 0 0 12px rgba(255,207,106,0.15); }
  to   { box-shadow: var(--glow-gold), 0 0 0 6px rgba(255,207,106,0.08), inset 0 0 20px rgba(255,207,106,0.32); }
}

/* ---- Control row: voice controls + mic + wake, side by side ------------ */
#controlRow {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; flex-wrap: wrap; pointer-events: none;
}
#voiceControls {
  display: inline-flex; align-items: center; gap: 8px; pointer-events: none;
}

/* ---- Voice mode toggle (MANUAL/AUTO) — gold when AUTO -------------------- */
.voice-mode-toggle #voiceModeState { color: var(--muted); font-weight: 600; }
.voice-mode-toggle[data-mode="auto"] {
  color: var(--gold); border-color: var(--gold);
  box-shadow: var(--glow-gold), inset 0 0 12px rgba(255,207,106,0.12);
}
.voice-mode-toggle[data-mode="auto"] #voiceModeState {
  color: var(--gold); text-shadow: var(--glow-gold);
}

/* ---- Training mode toggle — keeps the mic open continuously, no auto-send,
   until toggled off (then everything captured is sent to Ace at once). Uses
   --danger (red) so it's unmistakable when armed — Ace will NOT respond
   mid-explanation while this is ON. ------------------------------------- */
.training-toggle #trainingModeState { color: var(--muted); font-weight: 600; }
.training-toggle[data-training="on"] {
  color: var(--danger); border-color: var(--danger);
  box-shadow: 0 0 8px rgba(255,93,108,0.55), 0 0 22px rgba(255,93,108,0.22),
              inset 0 0 12px rgba(255,93,108,0.14);
  animation: trainingPulse 1.4s ease-in-out infinite alternate;
}
.training-toggle[data-training="on"] #trainingModeState {
  color: var(--danger); text-shadow: 0 0 8px rgba(255,93,108,0.55);
}
@keyframes trainingPulse {
  from { box-shadow: 0 0 8px rgba(255,93,108,0.45), inset 0 0 10px rgba(255,93,108,0.12); }
  to   { box-shadow: 0 0 8px rgba(255,93,108,0.65), 0 0 0 6px rgba(255,93,108,0.08), inset 0 0 18px rgba(255,93,108,0.28); }
}

/* ---- Pause-trigger seconds input ----------------------------------------- */
.pause-control {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--glass-line);
  padding: 8px 14px; font-family: var(--mono); font-weight: 500;
  font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 9px 100%, 0 calc(100% - 9px));
  transition: all 0.14s ease;
}
.pause-control:hover { color: var(--cyan); border-color: var(--cyan); }
.pause-control input {
  width: 28px; background: transparent; border: none; outline: none;
  color: var(--cyan); font-family: var(--mono); font-weight: 600;
  font-size: 12px; letter-spacing: 0.05em; text-align: center;
}
.pause-control.disabled { opacity: 0.4; }
.pause-control.disabled input { pointer-events: none; }

#wakeNote {
  font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); opacity: 0.6; pointer-events: none;
}

#textbar {
  pointer-events: auto; display: flex; gap: 8px; width: min(540px, 86vw);
}
#textInput {
  flex: 1; background: var(--glass); border: 1px solid var(--glass-line);
  padding: 10px 14px; color: var(--fg); font-size: 13px; font-family: var(--mono);
  letter-spacing: 0.02em; backdrop-filter: blur(6px); pointer-events: auto;
}
#textInput::placeholder { color: var(--muted); letter-spacing: 0.1em; }
#textInput:focus { outline: none; border-color: var(--cyan); box-shadow: var(--glow-cyan); }
#textSend {
  background: transparent; color: var(--cyan); border: 1px solid var(--cyan);
  padding: 0 18px; font-family: var(--mono); font-weight: 600; cursor: pointer;
  letter-spacing: 0.2em; text-transform: uppercase; font-size: 11px;
  transition: all 0.12s ease;
}
#textSend:hover { background: rgba(47,230,255,0.12); box-shadow: var(--glow-cyan); }

/* ---- Bottom-left connection status ------------------------------------ */
#status {
  position: fixed; left: 44px; bottom: 34px; z-index: 4;
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted); pointer-events: none;
}
#status .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); margin-right: 8px; vertical-align: middle;
}
#status.live .dot { background: var(--ok); box-shadow: 0 0 8px rgba(67,240,176,0.7); }
#status.off .dot  { background: var(--danger); box-shadow: 0 0 8px rgba(255,93,108,0.7); }

/* Session-muted banner (BUG 1): shown when another Jarvis tab/PWA is the active
   voice session and this one is muted. Tap the mic or talk to take over. */
#sessionBanner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 8;
  padding: 12px 20px;
  font-family: var(--mono);
  font-size: 13px; letter-spacing: 0.04em; line-height: 1.4;
  text-align: center;
  color: var(--gold);
  background: linear-gradient(180deg, rgba(20, 14, 4, 0.92), rgba(12, 9, 4, 0.82));
  border-bottom: 1px solid var(--gold-dim);
  text-shadow: var(--glow-gold);
  box-shadow: 0 4px 22px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transform: translateY(-100%);
  transition: transform 0.25s ease;
  pointer-events: none;
}
#sessionBanner.show { transform: translateY(0); }
#sessionBanner[hidden] { display: none; }

/* ---- Workspace sidebar (Projects & Chats) ----------------------------- */
#sidebarToggle {
  position: fixed; top: 126px; left: 44px; z-index: 7;
  pointer-events: auto; cursor: pointer;
  background: transparent; color: var(--muted);
  border: 1px solid var(--glass-line);
  width: 38px; height: 38px; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.14s ease;
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
}
#sidebarToggle:hover {
  color: var(--cyan); border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(47,230,255,0.3);
}

#sidebarOverlay {
  position: fixed; inset: 0; z-index: 8;
  background: rgba(2, 5, 10, 0.55);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
#sidebarOverlay.show { opacity: 1; pointer-events: auto; }

#sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 9;
  width: min(320px, 86vw);
  background: rgba(6, 16, 24, 0.92);
  border-right: 1px solid var(--glass-line);
  box-shadow: var(--glow-cyan), 4px 0 32px rgba(0,0,0,0.6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  display: flex; flex-direction: column;
  pointer-events: auto;
  -webkit-user-select: text; user-select: text;
}
#sidebar.open { transform: translateX(0); }

.sidebarHead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 12px; border-bottom: 1px solid var(--glass-line);
}
.sidebarTitle {
  font-size: 12px; letter-spacing: 0.34em; color: var(--cyan);
  text-shadow: var(--glow-cyan);
}
#sidebarClose {
  background: transparent; border: 1px solid var(--glass-line); color: var(--muted);
  width: 28px; height: 28px; font-size: 16px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.14s ease;
}
#sidebarClose:hover { color: var(--cyan); border-color: var(--cyan); }

.sidebarActiveChat {
  padding: 10px 18px; font-size: 11px; letter-spacing: 0.06em;
  color: var(--gold); text-shadow: var(--glow-gold);
  border-bottom: 1px solid var(--glass-line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sidebarSection {
  display: flex; flex-direction: column;
  flex: 1 1 auto; min-height: 0;
  border-bottom: 1px solid var(--glass-line);
  overflow: hidden;
}
.sidebarSection:last-child { border-bottom: none; }
.sidebarSectionHead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px 8px;
  font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--muted);
}
.sidebarAddBtn {
  background: transparent; border: 1px solid var(--glass-line); color: var(--muted);
  width: 22px; height: 22px; font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.14s ease;
}
.sidebarAddBtn:hover { color: var(--cyan); border-color: var(--cyan); box-shadow: var(--glow-cyan); }

.sidebarList {
  flex: 1; overflow-y: auto; padding: 0 10px 12px;
  scrollbar-width: thin; scrollbar-color: var(--cyan-dim) transparent;
}
.sidebarList::-webkit-scrollbar { width: 5px; }
.sidebarList::-webkit-scrollbar-thumb { background: var(--cyan-dim); border-radius: 3px; }

.sidebarProject { margin-bottom: 4px; }
.sidebarProjectHead, .sidebarChat {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; cursor: pointer;
  border: 1px solid transparent;
  font-size: 12px; color: var(--fg);
  transition: all 0.12s ease;
}
.sidebarProjectHead:hover, .sidebarChat:hover {
  border-color: var(--glass-line); background: var(--glass);
}
.sidebarChat.active {
  border-color: var(--cyan); background: rgba(47,230,255,0.08);
}
.sidebarItemName {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebarChat.active .sidebarItemName { color: var(--cyan); text-shadow: var(--glow-cyan); }
.sidebarMeta {
  font-size: 9px; letter-spacing: 0.08em; color: var(--muted); white-space: nowrap;
}

.sidebarProjectBody {
  padding: 4px 0 8px 14px;
  border-left: 1px solid var(--glass-line);
  margin-left: 10px;
  display: flex; flex-direction: column; gap: 4px;
}

.sidebarMiniBtn {
  align-self: flex-start;
  background: transparent; border: 1px solid var(--glass-line); color: var(--muted);
  padding: 5px 10px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer;
  transition: all 0.12s ease; margin-bottom: 4px;
}
.sidebarMiniBtn:hover { color: var(--cyan); border-color: var(--cyan); }

.sidebarSubHead {
  font-size: 9px; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--muted); margin: 6px 0 2px;
}

.sidebarFileList { display: flex; flex-direction: column; gap: 3px; }
.sidebarFileChip {
  font-size: 11px; color: var(--fg); opacity: 0.85;
  padding: 4px 8px; background: rgba(47,230,255,0.05);
  border: 1px solid rgba(47,230,255,0.1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.sidebarUploadBtn {
  align-self: flex-start; margin-top: 6px;
  background: transparent; border: 1px solid var(--gold-dim); color: var(--gold);
  padding: 5px 10px; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer; transition: all 0.12s ease;
}
.sidebarUploadBtn:hover { border-color: var(--gold); box-shadow: var(--glow-gold); }

.sidebarMenuBtn {
  background: transparent; border: none; color: var(--muted);
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0 4px;
  flex: 0 0 auto;
}
.sidebarMenuBtn:hover { color: var(--cyan); }

.sidebarMenu {
  position: absolute; right: 8px; top: 32px; z-index: 10;
  background: rgba(6, 16, 24, 0.97);
  border: 1px solid var(--glass-line);
  box-shadow: var(--glow-cyan), 0 8px 24px rgba(0,0,0,0.5);
  min-width: 160px;
  display: flex; flex-direction: column;
}
.sidebarMenuItem {
  padding: 8px 12px; font-size: 11px; color: var(--fg); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background 0.1s ease;
}
.sidebarMenuItem:hover { background: rgba(47,230,255,0.1); color: var(--cyan); }
.sidebarMenuItem.danger { color: var(--danger); }
.sidebarMenuItem.danger:hover { background: rgba(255,93,108,0.12); color: var(--danger); }

.sidebarChat, .sidebarProjectHead { position: relative; }

/* Narrow screens: collapse console to keep the orb the star */
@media (max-width: 720px) {
  #console { width: 86vw; right: 7vw; top: 120px; bottom: 250px; }
  #telemetry { display: none; }
  #brand { left: 26px; }
  #stateReadout { left: 26px; }
  #sidebarToggle { left: 26px; }
  .bracket { width: 44px; height: 44px; }
}
