/* ============================================
   J.A.R.V.I.S. v4.0 — Electric-Blue HUD
   Just A Rather Very Intelligent System
   By Gaurav Kumar — Revived 2026
   ============================================ */

:root {
  /* MCU JARVIS electric-blue palette — OKLCH for perceptual uniformity */
  --primary:        oklch(0.70 0.13 216);   /* electric cyan — Stark UI blue     */
  --primary-dim:    oklch(0.56 0.12 220);   /* deeper cyan — secondary accents   */
  --primary-bright: oklch(0.82 0.09 210);   /* bright cyan — hover/highlights    */
  --primary-glow:   oklch(0.70 0.13 216 / 0.28);
  --accent-listen:  oklch(0.78 0.17 55);    /* amber — LISTENING/alert only      */
  --bg:             oklch(0.07 0.008 225);  /* near-black with blue tint         */
  --bg-lighter:     oklch(0.11 0.010 222);  /* panel bg                          */
  --bg-panel:       oklch(0.10 0.010 222 / 0.94);
  --surface:        oklch(0.70 0.13 216 / 0.04);
  --border:         oklch(0.70 0.13 216 / 0.13);
  --border-bright:  oklch(0.70 0.13 216 / 0.32);
  --text:           oklch(0.68 0.07 210);   /* mid-blue body text                */
  --text-bright:    oklch(0.93 0.025 210);  /* near-white with cyan tint         */
  --text-dim:       oklch(0.44 0.07 215);   /* dim blue labels (~4.7:1 contrast) */
  --font-display:   'Chakra Petch', 'Orbitron', sans-serif;
  --font-mono:      'JetBrains Mono', 'Roboto Mono', monospace;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Two-layer HUD grid — 96px coarse + 24px fine subdivision */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(oklch(0.70 0.13 216 / 0.030) 1px, transparent 1px),
    linear-gradient(90deg, oklch(0.70 0.13 216 / 0.030) 1px, transparent 1px),
    linear-gradient(oklch(0.70 0.13 216 / 0.012) 1px, transparent 1px),
    linear-gradient(90deg, oklch(0.70 0.13 216 / 0.012) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px, 24px 24px, 24px 24px;
  pointer-events: none;
  z-index: 0;
}

/* Corner vignette */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, oklch(0.07 0.008 225 / 0.85) 100%);
  pointer-events: none;
  z-index: 0;
}

/* ---- Scan Lines ---- */

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.06) 3px,
    rgba(0, 0, 0, 0.06) 4px
  );
}

/* ---- Boot Overlay ---- */

.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.9s ease, visibility 0.9s ease;
}

.boot-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: min(400px, 90vw);
}

.boot-logo {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--primary);
  text-shadow: 0 0 30px var(--primary-glow);
  animation: flickerIn 0.5s ease forwards;
}

.boot-text {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: pre-line;
  text-align: left;
  line-height: 1.9;
  width: 100%;
  min-height: 140px;
}

.boot-bar {
  width: 100%;
  height: 2px;
  background: var(--border);
}

.boot-progress {
  height: 100%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
  width: 0%;
  transition: width 0.2s ease;
}


/* ---- Status Bar ---- */

.status-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 24px;
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

/* Top edge accent on status bar */
.status-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, var(--primary) 0%, var(--primary-dim) 35%, transparent 75%);
}

.status-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  text-shadow: 0 0 10px var(--primary-glow);
  letter-spacing: 3px;
}

.version {
  font-size: 0.6rem;
  color: var(--text-dim);
  border: 1px solid var(--text-dim);
  padding: 1px 5px;
  letter-spacing: 1px;
}

.divider {
  width: 1px;
  height: 14px;
  background: var(--border-bright);
}

.system-label {
  font-size: 0.6rem;
  letter-spacing: 2px;
  color: var(--primary-dim);
}

.status-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.status-item i,
.status-icon {
  color: var(--primary-dim);
  flex-shrink: 0;
}

.status-value {
  color: var(--text);
  letter-spacing: 0.5px;
}

.clock-item .status-value {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--primary);
}

/* ---- Main ---- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 70px 20px 230px;
  position: relative;
  z-index: 1;
}

/* ---- Core Visualization ---- */

.core-container {
  position: relative;
  width: 280px;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  flex-shrink: 0;
}

/* SVG tick marks */
.core-ticks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  animation: rotate 60s linear infinite;
  will-change: transform;
}

.core-image {
  position: relative;
  z-index: 4;
  width: 152px;
  height: 152px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border-bright);
  box-shadow: 0 0 0 4px oklch(0.70 0.13 216 / 0.07), 0 0 50px var(--primary-glow);
  transition: box-shadow 0.3s ease;
}

/* Scan lines layered on top of the GIF */
.core-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.12) 3px,
    rgba(0, 0, 0, 0.12) 4px
  );
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}

.core-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.core-glow {
  position: absolute;
  width: 176px;
  height: 176px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  z-index: 2;
  animation: pulse 3.5s ease-in-out infinite;
}

/* Radar sweep — conic gradient rotating like an active scan */
.core-scan {
  position: absolute;
  width: 204px;
  height: 204px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    oklch(0.70 0.13 216 / 0.20) 0deg,
    oklch(0.70 0.13 216 / 0.07) 40deg,
    transparent 70deg,
    transparent 360deg
  );
  animation: rotate 5s linear infinite;
  z-index: 3;
  will-change: transform;
}

/* Animated Rings */
.core-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid transparent;
  z-index: 3;
  will-change: transform;
}

.ring-1 {
  width: 188px;
  height: 188px;
  border-top-color: oklch(0.70 0.13 216 / 0.52);
  border-right-color: oklch(0.70 0.13 216 / 0.12);
  animation: rotate 8s linear infinite;
}

.ring-2 {
  width: 210px;
  height: 210px;
  border-bottom-color: oklch(0.70 0.13 216 / 0.30);
  border-left-color: oklch(0.70 0.13 216 / 0.08);
  animation: rotate 14s linear infinite reverse;
}

.ring-3 {
  width: 232px;
  height: 232px;
  border-style: dashed;
  border-color: oklch(0.70 0.13 216 / 0.11);
  animation: rotate 40s linear infinite;
}

.ring-4 {
  width: 252px;
  height: 252px;
  border-top-color: oklch(0.70 0.13 216 / 0.20);
  border-bottom-color: oklch(0.70 0.13 216 / 0.06);
  animation: rotate 25s linear infinite reverse;
}

/* Outer arc ring */
.ring-5 {
  width: 272px;
  height: 272px;
  border-top-color: oklch(0.70 0.13 216 / 0.32);
  border-left-color: oklch(0.70 0.13 216 / 0.10);
  animation: rotate 18s linear infinite;
}

/* Voice Wave */
.voice-wave {
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 3px;
  z-index: 6;
  height: 28px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.voice-wave.active {
  opacity: 1;
}

.voice-wave span {
  display: block;
  width: 3px;
  height: 4px;
  background: var(--primary);
  box-shadow: 0 0 4px var(--primary-glow);
}

.voice-wave.active span {
  animation: wave 0.55s ease-in-out infinite;
}

.voice-wave span:nth-child(1) { animation-delay: 0.00s; }
.voice-wave span:nth-child(2) { animation-delay: 0.07s; }
.voice-wave span:nth-child(3) { animation-delay: 0.14s; }
.voice-wave span:nth-child(4) { animation-delay: 0.21s; }
.voice-wave span:nth-child(5) { animation-delay: 0.28s; }
.voice-wave span:nth-child(6) { animation-delay: 0.21s; }
.voice-wave span:nth-child(7) { animation-delay: 0.14s; }
.voice-wave span:nth-child(8) { animation-delay: 0.07s; }
.voice-wave span:nth-child(9) { animation-delay: 0.00s; }

/* ---- Status Badge ---- */

.status-badge {
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 4px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 4px 14px;
  margin-top: 6px;
  margin-bottom: 20px;
  position: relative;
  z-index: 5;
  transition: all 0.3s ease;
}

.status-badge.listening {
  color: var(--accent-listen);
  border-color: color-mix(in srgb, var(--accent-listen) 40%, transparent);
  text-shadow: 0 0 8px color-mix(in srgb, var(--accent-listen) 50%, transparent);
}

.status-badge.speaking {
  color: var(--primary);
  border-color: var(--border-bright);
  text-shadow: 0 0 8px var(--primary-glow);
}

/* States — core visual changes */
body.listening .core-glow {
  animation: pulse-fast 0.9s ease-in-out infinite;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-listen) 35%, transparent) 0%, transparent 70%);
}

body.listening .core-image {
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--accent-listen) 10%, transparent),
    0 0 50px color-mix(in srgb, var(--accent-listen) 40%, transparent);
}

body.listening .mic-btn {
  background: color-mix(in srgb, var(--accent-listen) 15%, transparent);
  color: var(--accent-listen);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent-listen) 30%, transparent);
}

body.speaking .core-glow {
  animation: pulse 1.8s ease-in-out infinite;
  background: radial-gradient(circle, color-mix(in srgb, var(--primary) 50%, transparent) 0%, transparent 70%);
}

body.speaking .core-image {
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--primary) 12%, transparent),
    0 0 60px var(--primary-glow);
}

/* ---- Conversation ---- */

.conversation {
  width: 100%;
  max-width: 640px;
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-dim) transparent;
  position: relative;
}

/* Top-left bracket */
.conversation::before {
  content: '';
  position: sticky;
  top: 0;
  left: 0;
  display: block;
  width: 20px;
  height: 20px;
  border-top: 1px solid var(--border-bright);
  border-left: 1px solid var(--border-bright);
  pointer-events: none;
  flex-shrink: 0;
  align-self: flex-start;
}

.conversation::-webkit-scrollbar { width: 3px; }
.conversation::-webkit-scrollbar-thumb {
  background: var(--primary-dim);
  border-radius: 2px;
}

.message {
  animation: messageIn 0.25s ease forwards;
  padding: 9px 14px;
  max-width: 88%;
  line-height: 1.65;
  position: relative;
}

.message.jarvis {
  background: oklch(0.70 0.13 216 / 0.07);
  border: 1px solid oklch(0.70 0.13 216 / 0.22);
  align-self: flex-start;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}

.message.user {
  background: oklch(0.70 0.13 216 / 0.03);
  border: 1px solid oklch(0.70 0.13 216 / 0.09);
  align-self: flex-end;
  text-align: right;
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
}

.message.system {
  align-self: center;
  font-size: 0.68rem;
  color: var(--text-dim);
  background: none;
  border: none;
  padding: 2px 0;
  letter-spacing: 1px;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.message.user .message-header {
  justify-content: flex-end;
}

.sender {
  font-family: var(--font-display);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.message.jarvis .sender { color: var(--primary); }
.message.user   .sender { color: oklch(0.70 0.13 216 / 0.55); }

.timestamp {
  font-size: 0.58rem;
  color: var(--text-dim);
}

.message-body {
  font-size: 0.85rem;
  word-wrap: break-word;
}

.message-body strong {
  color: var(--text-bright);
  font-weight: 500;
}

.message-body code {
  background: oklch(0.70 0.13 216 / 0.10);
  border: 1px solid var(--border);
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--primary);
  user-select: all;
  letter-spacing: 0.5px;
}

/* Thinking dots */
.thinking-dots {
  display: inline-flex;
  gap: 5px;
}

.thinking-dots span {
  width: 5px;
  height: 5px;
  background: var(--primary);
  border-radius: 50%;
  animation: thinking 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ---- Bottom Panel ---- */

.bottom-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: linear-gradient(to top, oklch(0.07 0.008 225 / 0.98) 70%, transparent);
  padding: 12px 20px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Top edge line */
.bottom-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, var(--primary-dim), transparent 60%);
}

/* Quick Actions */
.quick-actions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  max-width: 640px;
  width: 100%;
  scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar { display: none; }

.action-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  min-height: 44px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
  letter-spacing: 0.5px;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
}

.action-chip:hover {
  background: oklch(0.70 0.13 216 / 0.09);
  border-color: var(--primary-dim);
  color: var(--text);
}

.action-chip:active { transform: scale(0.95); }

.action-chip i,
.action-chip svg {
  color: var(--primary-dim);
  flex-shrink: 0;
}

.action-chip:hover i,
.action-chip:hover svg { color: var(--primary); }

/* Input Area */
.input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 640px;
  width: 100%;
  padding: 7px 7px 7px 16px;
  background: var(--bg-lighter);
  border: 1px solid var(--border);
  transition: border-color 0.2s ease;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.input-area:focus-within {
  border-color: var(--primary-dim);
  box-shadow: 0 0 0 2px oklch(0.70 0.13 216 / 0.28);
}

.text-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  min-width: 0;
  letter-spacing: 0.3px;
}

.text-input::placeholder { color: var(--text-dim); }

.mic-btn,
.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.18s ease;
  flex-shrink: 0;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

.mic-btn {
  background: transparent;
  color: var(--primary-dim);
}

.mic-btn:hover {
  background: oklch(0.70 0.13 216 / 0.10);
  border-color: var(--primary-dim);
  color: var(--primary);
}

.send-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--bg);
}

.send-btn:hover {
  background: var(--primary-bright);
  box-shadow: 0 0 16px var(--primary-glow);
}

.send-btn:active,
.mic-btn:active { transform: scale(0.92); }

body.no-speech .mic-btn { display: none; }

/* Credits */
.credits {
  font-size: 0.62rem;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.credits strong { color: var(--text-dim); font-weight: 500; }

/* ---- Animations ---- */

@keyframes pulse {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50%       { opacity: 0.9;  transform: scale(1.06); }
}

@keyframes pulse-fast {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%       { opacity: 1;    transform: scale(1.12); }
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes wave {
  0%, 100% { height: 4px; }
  50%       { height: 22px; }
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes thinking {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.75); }
  40%           { opacity: 1;    transform: scale(1); }
}

@keyframes flickerIn {
  0%   { opacity: 0; }
  30%  { opacity: 0.8; }
  45%  { opacity: 0.2; }
  60%  { opacity: 1; }
  75%  { opacity: 0.6; }
  100% { opacity: 1; }
}

/* Boot animations — staggered reveal */
.anim-slide-down {
  opacity: 0;
  transform: translateY(-16px);
  animation: revealDown 0.5s ease forwards;
  animation-delay: 3.4s;
}

.anim-fade-in {
  opacity: 0;
  animation: revealFade 0.7s ease forwards;
  animation-delay: 3.7s;
}

.anim-slide-up {
  opacity: 0;
  transform: translateY(16px);
  animation: revealUp 0.5s ease forwards;
  animation-delay: 4.1s;
}

.anim-fade-in-delayed {
  opacity: 0;
  animation: revealFade 0.5s ease forwards;
  animation-delay: 4.4s;
}

@keyframes revealDown { to { opacity: 1; transform: translateY(0); } }
@keyframes revealFade { to { opacity: 1; } }
@keyframes revealUp   { to { opacity: 1; transform: translateY(0); } }

/* ---- Sidebar Toggle Button ---- */

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
}

.sidebar-toggle:hover {
  background: oklch(0.70 0.13 216 / 0.10);
  border-color: var(--primary-dim);
  color: var(--primary);
}

.sidebar-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* ---- Sidebar Overlay ---- */

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 199;
  background: oklch(0.04 0.005 225 / 0.70);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ---- Chat History Sidebar ---- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  z-index: 200;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Left accent line */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  right: -1px;
  bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, var(--primary-dim), transparent 80%);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  background: oklch(0.70 0.13 216 / 0.09);
  border: 1px solid var(--border-bright);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.18s ease;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
}

.new-chat-btn:hover {
  background: oklch(0.70 0.13 216 / 0.16);
  border-color: var(--primary-dim);
  color: var(--primary);
}

.new-chat-btn svg { color: var(--primary); }

.sidebar-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.18s ease;
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
}

.sidebar-close:hover {
  background: oklch(0.70 0.13 216 / 0.09);
  border-color: var(--primary-dim);
  color: var(--primary);
}

.sidebar-close:focus-visible,
.new-chat-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Sidebar search */
.sidebar-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  color: var(--text-dim);
}

.sidebar-search {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.3px;
}

.sidebar-search::placeholder { color: var(--text-dim); }

/* Chat list */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-dim) transparent;
}

.chat-list::-webkit-scrollbar { width: 3px; }
.chat-list::-webkit-scrollbar-thumb {
  background: var(--primary-dim);
  border-radius: 2px;
}

.chat-empty {
  padding: 20px 16px;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  text-align: center;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-left: 2px solid transparent;
  position: relative;
}

.chat-item:hover {
  background: oklch(0.70 0.13 216 / 0.06);
}

.chat-item.active {
  background: oklch(0.70 0.13 216 / 0.10);
  border-left-color: var(--primary-dim);
}

.chat-item-main {
  flex: 1;
  min-width: 0;
}

.chat-item-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.2px;
}

.chat-item.active .chat-item-title {
  color: var(--text-bright);
}

.chat-item-meta {
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-top: 2px;
  letter-spacing: 0.3px;
}

.chat-item-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
  flex-shrink: 0;
}

.chat-item:hover .chat-item-actions,
.chat-item.active .chat-item-actions {
  opacity: 1;
}

.chat-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chat-action-btn:hover {
  background: oklch(0.70 0.13 216 / 0.12);
  border-color: var(--primary-dim);
  color: var(--primary);
}

.delete-btn:hover {
  border-color: oklch(0.60 0.15 15 / 0.50);
  color: oklch(0.65 0.15 15);
  background: oklch(0.60 0.15 15 / 0.08);
}

.chat-action-btn:focus-visible {
  outline: 1px solid var(--primary);
  outline-offset: 1px;
}

/* ---- Focus Indicators ---- */

.mic-btn:focus-visible,
.send-btn:focus-visible,
.action-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-color: var(--primary-dim);
}

.text-input:focus-visible {
  outline: none;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
  .status-bar { padding: 8px 14px; }
  .logo { font-size: 0.78rem; }
  .system-label, .divider { display: none; }
  .status-right { gap: 12px; }
  .status-item .status-value { display: none; }
  .clock-item .status-value { display: block; font-size: 0.7rem; }
  .status-item i { font-size: 0.7rem; }

  .main { padding: 58px 14px 210px; }

  .core-container {
    width: 220px;
    height: 220px;
    margin-bottom: 10px;
  }

  .core-image { width: 118px; height: 118px; }
  .core-glow  { width: 138px; height: 138px; }
  .core-scan  { width: 158px; height: 158px; }
  .ring-1     { width: 148px; height: 148px; }
  .ring-2     { width: 164px; height: 164px; }
  .ring-3     { width: 180px; height: 180px; }
  .ring-4     { width: 196px; height: 196px; }
  .ring-5     { width: 210px; height: 210px; }

  .core-ticks { width: 220px; height: 220px; }

  .message { max-width: 94%; }
  .bottom-panel { padding: 8px 12px 12px; }
  .input-area { padding: 6px 6px 6px 14px; }
  .text-input { font-size: 0.82rem; }
  .mic-btn, .send-btn { width: 44px; height: 44px; font-size: 0.8rem; }
}

@media (max-width: 400px) {
  .version { display: none; }
  .core-container { width: 180px; height: 180px; }
  .core-image { width: 100px; height: 100px; }
  .ring-4, .ring-5 { display: none; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .main { padding: 52px 14px 190px; }
  .core-container { width: 160px; height: 160px; margin-bottom: 6px; }
  .core-image { width: 94px; height: 94px; }
  .core-glow  { width: 110px; height: 110px; }
  .core-scan  { width: 126px; height: 126px; }
  .ring-1     { width: 120px; height: 120px; }
  .ring-2     { width: 134px; height: 134px; }
  .ring-3     { width: 146px; height: 146px; }
  .ring-4     { width: 154px; height: 154px; }
  .ring-5     { width: 160px; height: 160px; }
  .core-ticks { width: 160px; height: 160px; }
}

/* ---- Reduced Motion ---- */

@media (prefers-reduced-motion: reduce) {
  .core-ring,
  .core-ticks,
  .core-glow,
  .core-scan {
    animation: none;
    will-change: auto;
  }

  .anim-slide-down,
  .anim-fade-in,
  .anim-slide-up,
  .anim-fade-in-delayed {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .message {
    animation: none;
  }

  .voice-wave.active span {
    animation: none;
    height: 12px;
  }

  .thinking-dots span {
    animation: none;
    opacity: 1;
    transform: scale(1);
  }

  .boot-progress {
    transition: none;
  }
}
