/* ================================================================
   ULTRA Code Studio 7.0 — Premium Dark UI
   Design: Deep Space Robotics IDE
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
  /* Core Palette */
  --bg-base:    #080c14;
  --bg-surface: #0d1421;
  --bg-card:    #111827;
  --bg-raised:  #1a2234;
  --bg-hover:   rgba(99,102,241,0.08);

  /* Accent System */
  --accent:       #6366f1;      /* indigo */
  --accent-2:     #8b5cf6;      /* violet */
  --accent-glow:  rgba(99,102,241,0.35);
  --cyan:         #06b6d4;
  --cyan-glow:    rgba(6,182,212,0.3);

  /* Semantic */
  --success:      #10b981;
  --success-glow: rgba(16,185,129,0.3);
  --danger:       #ef4444;
  --danger-glow:  rgba(239,68,68,0.3);
  --warning:      #f59e0b;
  --warning-glow: rgba(245,158,11,0.3);
  --purple:       #a855f7;
  --purple-glow:  rgba(168,85,247,0.3);

  /* Borders */
  --border:       rgba(255,255,255,0.06);
  --border-light: rgba(255,255,255,0.10);
  --border-accent: rgba(99,102,241,0.4);

  /* Text */
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;

  /* Nav height */
  --nav-h: 58px;

  /* Glassmorphism */
  --glass-bg:     rgba(15,20,35,0.8);
  --glass-border: rgba(255,255,255,0.08);
  --blur:         blur(20px);
}

/* ── LIGHT THEME overrides ─────────────────────────────────────── */
[data-theme="light"] {
  --bg-base:      #f1f5f9;
  --bg-surface:   #ffffff;
  --bg-card:      #f8fafc;
  --bg-raised:    #e2e8f0;
  --bg-hover:     rgba(99,102,241,0.07);
  --border:       rgba(15,23,42,0.09);
  --border-light: rgba(15,23,42,0.13);
  --text-primary:   #0f172a;
  --text-secondary: #334155;
  --text-muted:     #64748b;
  --glass-bg:     rgba(255,255,255,0.9);
  --glass-border: rgba(0,0,0,0.08);
}
[data-theme="light"] body {
  background: var(--bg-base);
  background-image:
    linear-gradient(rgba(99,102,241,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.04) 1px, transparent 1px);
  background-size: 32px 32px;
}
[data-theme="light"] .nav-bar {
  background: rgba(255,255,255,0.96);
  box-shadow: 0 1px 0 rgba(0,0,0,0.08), 0 4px 24px rgba(0,0,0,0.06);
}
[data-theme="light"] .nav-logo {
  background: linear-gradient(135deg, #1e1b4b 30%, var(--accent) 60%, #0891b2 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
[data-theme="light"] button {
  background: white;
  border-color: rgba(15,23,42,0.13);
  color: var(--text-primary);
}
[data-theme="light"] .btn-ui   { background: #f8fafc; color: var(--text-secondary); }
[data-theme="light"] .btn-file { background: #f1f5f9; color: var(--text-muted); }
[data-theme="light"] .btn-theme { background: rgba(168,85,247,0.08); }
[data-theme="light"] .btn-run   { background: linear-gradient(135deg,#059669,#10b981); color: white; }
[data-theme="light"] .btn-flash { background: linear-gradient(135deg,#b91c1c,#ef4444); color: white; }
[data-theme="light"] .btn-console { background: linear-gradient(135deg,#92400e,#f59e0b); color: white; }
[data-theme="light"] .btn-save { background: rgba(16,185,129,0.08); color: var(--success); }
[data-theme="light"] .dropdown-btn { background: rgba(99,102,241,0.08); }
[data-theme="light"] .dropdown-ai  { background: rgba(168,85,247,0.08); }
[data-theme="light"] .dropdown-content {
  background: rgba(255,255,255,0.98);
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
}
[data-theme="light"] .dropdown-content button { color: var(--text-secondary); background: transparent; }
[data-theme="light"] .dropdown-content button:hover { background: var(--bg-hover); color: var(--text-primary); }
[data-theme="light"] #sidebar { background: #ffffff; border-right-color: rgba(0,0,0,0.09); }
[data-theme="light"] .tab-buttons { background: #f1f5f9; border-bottom-color: rgba(0,0,0,0.08); }
[data-theme="light"] .tab-button { color: var(--text-muted); }
[data-theme="light"] .tab-button.active { background: rgba(99,102,241,0.08); color: var(--accent); }
[data-theme="light"] .project-item { background: white; color: var(--text-secondary); border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .icon-btn { color: var(--text-muted); }
[data-theme="light"] #codeConsole { background: #1e2030; border-left-color: rgba(0,0,0,0.1); }
[data-theme="light"] .modal-content { background: #ffffff; }
[data-theme="light"] .modal-btn { background: #f8fafc; color: var(--text-secondary); border-color: rgba(0,0,0,0.1); }
[data-theme="light"] .quest-card { background: white; border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .quest-card.quest-done { background: #f0fdf4; }
[data-theme="light"] .quest-title { color: var(--text-primary); }
[data-theme="light"] .quest-desc  { color: var(--text-muted); }
[data-theme="light"] #questXPBar { background: #f8fafc; border-bottom-color: rgba(0,0,0,0.08); }
[data-theme="light"] #questDetailPanel { background: #f8fafc; color: var(--text-primary); }
/* Blockly light theme */
[data-theme="light"] .blocklySvg            { background: #f8fafc !important; }
[data-theme="light"] .blocklyMainBackground { fill: #f8fafc !important; }
[data-theme="light"] .blocklyToolboxDiv     { background: #ffffff !important; border-right: 1px solid rgba(0,0,0,0.09) !important; }
[data-theme="light"] .blocklyTreeLabel      { color: #334155 !important; }
[data-theme="light"] .blocklyTreeRow:hover  { background: rgba(99,102,241,0.07) !important; }
[data-theme="light"] .blocklyGridLine       { stroke: rgba(15,23,42,0.05) !important; }
[data-theme="light"] .blocklyTreeSelected   { background: rgba(99,102,241,0.12) !important; }

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0; padding: 0;
  font-family: 'Outfit', -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
  transition: none;

  /* Subtle grid pattern */
  background-image:
    linear-gradient(rgba(99,102,241,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.03) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* ── Scrollbars ───────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.4); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Nav Bar ─────────────────────────────────────────────────── */
.nav-bar {
  width: 100%; height: var(--nav-h);
  background: rgba(8,12,20,0.95);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; gap: 12px;
  box-sizing: border-box;
  justify-content: space-between;
  z-index: 100;
  position: relative;
  box-shadow: 0 1px 0 var(--border), 0 4px 24px rgba(0,0,0,0.4);
}

/* Animated accent line at bottom of nav */
.nav-bar::after {
  content: '';
  position: absolute; bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--cyan), var(--accent), transparent);
  opacity: 0.6;
}

/* ── Logo ─────────────────────────────────────────────────────── */
.nav-logo {
  margin: 0 12px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1.5px;
  white-space: nowrap;
  background: linear-gradient(135deg, #fff 30%, var(--accent) 60%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-logo .version {
  -webkit-text-fill-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
}
.nav-logo .edition {
  font-size: 10px; font-weight: 500;
  -webkit-text-fill-color: var(--warning);
  letter-spacing: 0.5px; margin-left: 4px;
}

/* ── Button System ────────────────────────────────────────────── */
.btn-group { display: flex; gap: 6px; align-items: center; }

button, .btn {
  padding: 7px 13px; font-weight: 600;
  border: 1px solid var(--border-light);
  border-radius: 8px; cursor: pointer;
  transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-family: 'Outfit', sans-serif;
  white-space: nowrap; position: relative; overflow: hidden;
  background: var(--bg-raised); color: var(--text-primary);
  letter-spacing: 0.3px;
}
button::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.04), transparent);
  opacity: 0; transition: opacity 0.18s;
}
button:hover { transform: translateY(-1px); }
button:hover::before { opacity: 1; }
button:active { transform: translateY(1px) scale(0.98); }

/* Specific button variants */
.btn-ui {
  background: var(--bg-raised);
  border-color: var(--border-light);
  color: var(--text-secondary);
}
.btn-ui:hover { border-color: var(--accent); color: var(--text-primary); box-shadow: 0 0 12px var(--accent-glow); }

.btn-file {
  background: rgba(148,163,184,0.08);
  border-color: rgba(148,163,184,0.15);
  color: var(--text-secondary);
}
.btn-file:hover { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 10px var(--cyan-glow); }

.btn-theme {
  background: rgba(168,85,247,0.1);
  border-color: rgba(168,85,247,0.25);
  color: var(--purple);
}
.btn-theme:hover { background: rgba(168,85,247,0.2); box-shadow: 0 0 12px var(--purple-glow); }

.btn-run {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: transparent; color: white;
  box-shadow: 0 2px 12px var(--success-glow);
  font-weight: 700; padding: 7px 16px;
}
.btn-run:hover { box-shadow: 0 4px 20px var(--success-glow), 0 0 0 1px var(--success); transform: translateY(-2px); }

.btn-flash {
  background: linear-gradient(135deg, #b91c1c, #ef4444);
  border-color: transparent; color: white;
  box-shadow: 0 2px 12px var(--danger-glow);
  font-weight: 700; padding: 7px 16px;
}
.btn-flash:hover { box-shadow: 0 4px 20px var(--danger-glow), 0 0 0 1px var(--danger); transform: translateY(-2px); }

.btn-console {
  background: linear-gradient(135deg, #92400e, #f59e0b);
  border-color: transparent; color: white;
  box-shadow: 0 2px 12px var(--warning-glow);
  font-weight: 700;
}
.btn-console:hover { box-shadow: 0 4px 20px var(--warning-glow); transform: translateY(-2px); }

/* ── Dropdown ─────────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }

.dropdown-btn {
  background: rgba(99,102,241,0.1);
  border-color: rgba(99,102,241,0.25);
  color: var(--accent);
}
.dropdown-btn:hover { background: rgba(99,102,241,0.2); box-shadow: 0 0 12px var(--accent-glow); }

.dropdown-ai {
  background: rgba(168,85,247,0.1);
  border-color: rgba(168,85,247,0.25);
  color: var(--purple);
}
.dropdown-ai:hover { background: rgba(168,85,247,0.2); box-shadow: 0 0 12px var(--purple-glow); }

/* Fix 2: Click-based dropdown — show when .open class is present */
.dropdown.open .dropdown-content { display: block; }

/* Remove any hover-based show */
.dropdown-content {
  display: none; position: absolute;
  background: rgba(13,20,33,0.97);
  backdrop-filter: blur(20px);
  min-width: 200px;
  border: 1px solid var(--border-light);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px var(--border);
  z-index: 500; border-radius: 12px; overflow: hidden;
  top: 100%;   /* no gap — fixes cursor jump issue */
  right: 0;
  margin-top: 4px;
  animation: dropIn 0.15s ease;
}

/* ── Workspace ────────────────────────────────────────────────── */
.workspace-area {
  display: flex; width: 100%;
  height: calc(100vh - var(--nav-h)); position: relative;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
  width: 280px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 50;
  transition: margin-left 0.35s cubic-bezier(0.4,0,0.2,1);
  flex-shrink: 0;
}
.sidebar-hidden { margin-left: -280px; }

.tab-buttons { display: flex; background: var(--bg-base); border-bottom: 1px solid var(--border); padding: 0 2px; }
.tab-button {
  flex: 1; padding: 11px 4px;
  border: none; font-size: 10px; font-weight: 700;
  cursor: pointer; color: var(--text-muted);
  border-bottom: 2px solid transparent;
  background: transparent; letter-spacing: 0.5px;
  text-transform: uppercase; transition: all 0.2s;
  font-family: 'Outfit', sans-serif;
}
.tab-button:hover  { color: var(--text-secondary); background: rgba(255,255,255,0.02); transform: none; }
/* Fix 4: Strong active tab highlight */
.tab-button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(99,102,241,0.12);
  text-shadow: 0 0 12px var(--accent-glow);
}

.tab-content { padding: 12px; display: none; flex-direction: column; overflow-y: auto; flex: 1; }
.tab-content.active { display: flex; }

/* Project items */
.project-item {
  background: var(--bg-card);
  padding: 11px 14px;
  margin-bottom: 8px; border-radius: 10px;
  border: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; transition: all 0.2s; font-size: 13px;
  color: var(--text-secondary);
}
.project-item:hover {
  border-color: var(--accent); color: var(--text-primary);
  background: var(--bg-hover); transform: translateX(3px);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.icon-btn {
  background: none; border: none; padding: 3px; cursor: pointer;
  font-size: 14px; color: var(--text-muted); transition: color 0.15s;
}
.icon-btn:hover { color: var(--danger); transform: none; }

/* ── Blockly Canvas ───────────────────────────────────────────── */
#blocklyDiv { flex-grow: 1; position: relative; }

/* Override Blockly background to match dark theme */
.blocklySvg                    { background: var(--bg-base) !important; }
.blocklyMainBackground         { fill: var(--bg-base) !important; }
.blocklyToolboxDiv             { background: var(--bg-surface) !important; border-right: 1px solid var(--border) !important; }
.blocklyTreeLabel              { color: var(--text-secondary) !important; font-family: 'Outfit', sans-serif !important; font-size: 12px !important; }
.blocklyTreeRow:hover          { background: var(--bg-hover) !important; }
.blocklyTreeSelected, .blocklyTreeRow.blocklyTreeSelected { background: rgba(99,102,241,0.2) !important; }
.blocklyGridLine               { stroke: rgba(255,255,255,0.04) !important; }
.blocklyScrollbarBackground    { fill: transparent !important; }
.blocklyScrollbarHandle        { fill: rgba(99,102,241,0.3) !important; rx: 3; }
.blocklyScrollbarHandle:hover  { fill: var(--accent) !important; }

/* ── Console Panel ────────────────────────────────────────────── */
#codeConsole {
  width: 400px; display: none; flex-direction: column;
  border-left: 1px solid var(--border);
  background: #06080f;
  flex-shrink: 0;
  box-shadow: -8px 0 32px rgba(0,0,0,0.4);
}

.console-header {
  background: rgba(10,14,22,0.98);
  padding: 0 12px;
  height: 40px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}

/* Terminal dots decoration */
.console-header::before {
  content: '● ● ●';
  font-size: 8px; letter-spacing: 4px;
  color: var(--text-muted); margin-right: 8px;
}

.tab-btn {
  background: transparent; color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 4px 10px; border-radius: 6px;
  font-size: 11px; margin-right: 5px; cursor: pointer;
  font-family: 'Outfit', sans-serif; font-weight: 600;
  transition: all 0.15s;
}
.tab-btn.active { color: var(--warning); border-color: rgba(245,158,11,0.4);
                  background: rgba(245,158,11,0.08); }
.tab-btn:hover { color: var(--text-primary); transform: none; }

#generatedCode, #serialOutput {
  flex-grow: 1; background: transparent; padding: 14px 16px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 12px; line-height: 1.7; border: none; outline: none;
  resize: none; white-space: pre-wrap; color: #4ade80;
}
#generatedCode { color: #4ade80; }      /* Green for code */
#serialOutput  { color: #fbbf24; }      /* Amber for serial */

/* Scanline effect on console */
#codeConsole::after {
  content: '';
  position: absolute; top: 40px; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
  pointer-events: none; z-index: 1;
}

#fileInput { display: none; }

/* ── Modals ───────────────────────────────────────────────────── */
#fileModal {
  display: none; position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 200; justify-content: center; align-items: center;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  padding: 28px; border-radius: 16px;
  width: 420px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6), 0 0 0 1px var(--border);
  position: relative; overflow: hidden;
}
/* Top accent bar on modal */
.modal-content::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--cyan), var(--purple));
}

.modal-content h3 {
  margin: 0 0 6px; color: var(--text-primary); font-size: 16px; font-weight: 700;
}
.modal-content p { margin: 0 0 20px; font-size: 13px; color: var(--text-secondary); }

.modal-btn-group { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.modal-btn {
  background: var(--bg-card); color: var(--text-secondary);
  border: 1px solid var(--border-light); padding: 12px 16px;
  font-size: 13px; justify-content: flex-start; border-radius: 10px;
  cursor: pointer; transition: all 0.18s; font-weight: 500;
}
.modal-btn:hover {
  background: var(--bg-hover); color: var(--text-primary);
  border-color: var(--accent); transform: translateX(4px);
}

.close-modal {
  position: absolute; top: 16px; right: 16px;
  cursor: pointer; font-size: 18px; color: var(--text-muted);
  border: none; background: rgba(255,255,255,0.06); border-radius: 6px;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.close-modal:hover { background: rgba(239,68,68,0.15); color: var(--danger); transform: none; }

/* ── Quest Mode Cards ─────────────────────────────────────────── */
.quest-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; margin-bottom: 8px;
  cursor: pointer; transition: all 0.2s; user-select: none;
}
.quest-card:hover {
  border-color: var(--accent); background: var(--bg-hover);
  transform: translateX(4px);
  box-shadow: 0 0 16px rgba(99,102,241,0.15);
}
.quest-card.quest-done {
  border-color: rgba(16,185,129,0.4); background: rgba(16,185,129,0.05);
}
.quest-card-top { display: flex; align-items: center; gap: 10px; }
.quest-icon     { font-size: 22px; flex-shrink: 0; }
.quest-info     { flex: 1; }
.quest-title    { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.quest-stars    { font-size: 11px; margin-top: 2px; color: var(--text-muted); }
.quest-xp       { color: var(--purple); font-weight: bold; }
.quest-status   { font-size: 16px; flex-shrink: 0; }
.quest-desc     { font-size: 11px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }

#questXPBar {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--bg-base); flex-shrink: 0;
}

#questDetailPanel {
  display: none; background: var(--bg-raised);
  border-top: 2px solid var(--accent);
  padding: 14px; font-size: 13px; flex-shrink: 0;
}
.quest-detail-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }

/* ── Talk to Build Modal ──────────────────────────────────────── */
#talkToBuildModal textarea {
  background: var(--bg-base); color: var(--text-primary);
  border: 1px solid var(--border-light); border-radius: 10px;
  padding: 12px; font-family: 'Outfit', sans-serif; font-size: 14px;
  outline: none; resize: vertical;
}
#talkToBuildModal textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-glow); }

/* ── Scrollbars in sidebar ────────────────────────────────────── */
.tab-content { scrollbar-width: thin; scrollbar-color: rgba(99,102,241,0.3) transparent; }

/* ── Status indicator ─────────────────────────────────────────── */
#btnConnectMaster {
  position: relative;
}
#btnConnectMaster.connected-usb  { background: rgba(16,185,129,0.15); border-color: var(--success); color: var(--success); box-shadow: 0 0 12px var(--success-glow); }
#btnConnectMaster.connected-ble  { background: rgba(99,102,241,0.15); border-color: var(--accent);  color: var(--accent);  box-shadow: 0 0 12px var(--accent-glow); }
#btnConnectMaster.connected-wifi { background: rgba(6,182,212,0.15);  border-color: var(--cyan);    color: var(--cyan);    box-shadow: 0 0 12px var(--cyan-glow); }

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeIn   { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
@keyframes neonPulse {
  0%, 100% { box-shadow: 0 0 8px  var(--accent-glow); }
  50%       { box-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(99,102,241,0.1); }
}
@keyframes gradient-shift {
  0%   { background-position: 0%   50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0%   50%; }
}

/* ── Vision Modal inner style ─────────────────────────────────── */
#visionModal .modal-content { text-align: center; }
#visionModal input {
  width: 100%; padding: 10px; border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--bg-base); color: var(--text-primary);
  font-family: 'Outfit', sans-serif; outline: none;
  margin-bottom: 12px;
}
#visionModal input:focus { border-color: var(--success); box-shadow: 0 0 0 3px var(--success-glow); }

/* ── Kbd styling ─────────────────────────────────────────────── */
kbd {
  background: var(--bg-raised); border: 1px solid var(--border-light);
  border-radius: 4px; padding: 1px 6px; font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
}

/* ── Save button in sidebar ───────────────────────────────────── */
.btn-save {
  background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(16,185,129,0.08));
  border: 1px solid rgba(16,185,129,0.3);
  color: var(--success); width: 100%;
  justify-content: center; padding: 11px;
  border-radius: 10px; margin-bottom: 12px; font-size: 13px;
  font-weight: 700;
}
.btn-save:hover {
  background: linear-gradient(135deg, rgba(16,185,129,0.25), rgba(16,185,129,0.15));
  box-shadow: 0 0 16px var(--success-glow); transform: none;
}

/* ── Tooltip hint ─────────────────────────────────────────────── */
.pro-badge {
  display: inline-block; background: linear-gradient(135deg, var(--accent), var(--purple));
  color: white; font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  letter-spacing: 0.5px; text-transform: uppercase; vertical-align: middle; margin-left: 4px;
}

/* ── Ultra Tutor Panel ────────────────────────────────────────── */
#tutorPanel {
  position: fixed;
  top: var(--nav-h); right: -440px;
  width: 420px;
  height: calc(100vh - var(--nav-h));
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 300;
  transition: right 0.35s cubic-bezier(0.4,0,0.2,1);
  box-shadow: -12px 0 40px rgba(0,0,0,0.5);
}
#tutorPanel.open { right: 0; }

.tutor-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tutor-header-title {
  font-size: 14px; font-weight: 800; color: var(--text-primary);
  font-family: 'Outfit', sans-serif; flex: 1;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tutor-mode-btns { display: flex; gap: 4px; }
.tutor-mode-btn {
  padding: 5px 10px; font-size: 11px; font-weight: 700;
  border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border-light);
  background: var(--bg-raised); color: var(--text-muted);
  font-family: 'Outfit', sans-serif; transition: all 0.15s;
}
.tutor-mode-btn.active {
  background: var(--accent); color: white;
  border-color: transparent; box-shadow: 0 0 10px var(--accent-glow);
}
.tutor-close-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; padding: 4px 6px;
  border-radius: 4px; transition: all 0.15s;
}
.tutor-close-btn:hover { color: var(--danger); background: rgba(239,68,68,0.1); transform: none; }

.tutor-messages {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin; scrollbar-color: rgba(99,102,241,0.3) transparent;
}

.tutor-msg { display: flex; }
.tutor-msg-user  { justify-content: flex-end; }
.tutor-msg-bot   { justify-content: flex-start; }

.tutor-bubble {
  max-width: 85%; padding: 10px 14px;
  border-radius: 14px; font-size: 13px; line-height: 1.55;
  word-break: break-word; animation: fadeIn 0.2s ease;
  font-family: 'Outfit', sans-serif;
}
.tutor-msg-user .tutor-bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; border-bottom-right-radius: 4px;
}
.tutor-msg-bot .tutor-bubble {
  background: var(--bg-raised); color: var(--text-primary);
  border: 1px solid var(--border); border-bottom-left-radius: 4px;
}

/* Thinking animation */
.tutor-thinking-bubble { display: flex; gap: 5px; align-items: center; padding: 12px 16px; }
.tutor-thinking-bubble span {
  display: inline-block; width: 7px; height: 7px;
  background: var(--accent); border-radius: 50%;
  animation: tutorDot 1.2s infinite;
}
.tutor-thinking-bubble span:nth-child(2) { animation-delay: 0.2s; }
.tutor-thinking-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tutorDot {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
  40%            { transform: scale(1.2); opacity: 1; }
}

.tutor-footer {
  border-top: 1px solid var(--border); padding: 10px 12px;
  background: var(--bg-base); flex-shrink: 0;
}
.tutor-actions { display: flex; gap: 6px; margin-bottom: 8px; }
.tutor-action-btn {
  flex: 1; padding: 6px 10px; font-size: 11px; font-weight: 600;
  border-radius: 7px; cursor: pointer; font-family: 'Outfit', sans-serif;
  border: 1px solid var(--border-light); background: var(--bg-raised);
  color: var(--text-secondary); transition: all 0.15s;
}
.tutor-action-btn:hover { border-color: var(--accent); color: var(--accent); transform: none; }

.tutor-input-row { display: flex; gap: 6px; }
#tutorInput {
  flex: 1; background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border-light); border-radius: 10px;
  padding: 9px 12px; font-family: 'Outfit', sans-serif; font-size: 13px;
  resize: none; outline: none; transition: border-color 0.2s;
  line-height: 1.4;
}
#tutorInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
#tutorInput::placeholder { color: var(--text-muted); }

#tutorSendBtn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; border: none; border-radius: 10px;
  width: 42px; font-size: 16px; cursor: pointer;
  flex-shrink: 0; transition: all 0.15s;
  box-shadow: 0 2px 10px var(--accent-glow);
}
#tutorSendBtn:hover { box-shadow: 0 4px 16px var(--accent-glow); transform: translateY(-1px); }
#tutorSendBtn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* Light mode tutor */
[data-theme="light"] .tutor-msg-bot .tutor-bubble { background: #f1f5f9; border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .tutor-header { background: #f8fafc; }
[data-theme="light"] .tutor-footer { background: #f8fafc; }
[data-theme="light"] #tutorPanel { background: white; }
[data-theme="light"] #tutorInput { background: #f1f5f9; }

/* SW install toast */
#swInstallToast {
  display: none; position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  border: 1px solid var(--border-accent);
  padding: 12px 20px; border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 999; font-size: 13px; color: var(--text-primary);
  display: flex; align-items: center; gap: 12px; animation: slideInUp 0.4s ease;
}

/* CP2102 Driver & Firmware Upgrade Modals */
.drv-tab-content {
  animation: fadeIn 0.25s ease;
}
#driverModal .modal-content, #firmwareModal .modal-content {
  animation: slideInUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.status-badge.pending { background: rgba(148,163,184,0.12); color: var(--text-secondary); }
.status-badge.writing { background: rgba(245,158,11,0.15); color: var(--warning); animation: pulse-opacity 1s infinite alternate; }
.status-badge.done { background: rgba(16,185,129,0.15); color: var(--success); }
.status-badge.error { background: rgba(239,68,68,0.15); color: var(--danger); }

@keyframes pulse-opacity {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

/* Radar & Connection Pointer Keyframes */
@keyframes radar-expand {
  0% {
    transform: scale(0.1);
    opacity: 0.8;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

@keyframes bounce-y {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-8px);
  }
}

/* ── Student Voice Command Modal Styles ── */
.voice-connection-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  border: 1px solid rgba(255,255,255,0.06);
}
.voice-connection-status.connected {
  background: rgba(16,185,129,0.12);
  color: var(--success);
  border-color: rgba(16,185,129,0.25);
}
.voice-connection-status.simulated {
  background: rgba(245,158,11,0.12);
  color: var(--warning);
  border-color: rgba(245,158,11,0.25);
}

.voice-mic-container {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.voice-mic-icon-button {
  z-index: 2;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 26px;
  cursor: pointer;
  user-select: none;
}
.voice-mic-icon-button:hover {
  transform: scale(1.08);
  border-color: var(--purple);
}
.voice-mic-icon-button.listening {
  border-color: var(--purple);
  box-shadow: 0 0 25px var(--purple-glow);
  animation: mic-listen-pulse 1.5s infinite ease-in-out;
  background: radial-gradient(circle, var(--bg-raised) 60%, rgba(168,85,247,0.15) 100%);
}

@keyframes mic-listen-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 12px var(--purple-glow);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(168,85,247,0.5);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 12px var(--purple-glow);
  }
}

.voice-suggestions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.voice-chip {
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.voice-chip:hover {
  background: rgba(168,85,247,0.1);
  border-color: var(--purple);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(168,85,247,0.15);
}
.voice-chip:active {
  transform: translateY(0) scale(0.95);
}

.voice-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.voice-text-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: white;
  font-size: 12px;
  font-family: inherit;
  transition: border-color 0.2s;
}
.voice-text-input:focus {
  border-color: var(--purple);
  outline: none;
}
.voice-btn-send {
  background: linear-gradient(135deg, var(--purple), var(--accent-2));
  border: none;
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px var(--purple-glow);
}
.voice-btn-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(168,85,247,0.4);
}
.voice-btn-send:active {
  transform: translateY(0);
}

.voice-guide-details {
  text-align: left;
  background: rgba(255,255,255,0.02);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}
.voice-guide-details summary {
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}
.voice-guide-details summary:hover {
  color: var(--text-secondary);
}
.voice-guide-details pre {
  margin: 8px 0 0 0;
  padding: 8px;
  background: var(--bg-base);
  border-radius: 6px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  color: #a855f7;
  border: 1px solid rgba(255,255,255,0.04);
}
