/* ============================================================
   Socrates 3.0 — styles.css
   Premium dark blue · Claude-inspired conversational layout
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */

:root {
  color-scheme: dark;

  --bg-base: #0a0e1a;
  --bg-surface: #111827;
  --bg-raised: #1e293b;
  --bg-hover: #273548;
  --bg-input: #0d1322;
  --bg-header: rgba(17, 24, 39, 0.88);

  --bg-gutter: #080d18;
  --text-gutter: rgba(148, 163, 184, 0.68);
  --bg-terminal: #060a14;
  --text-terminal: #e2e8f0;
  --text-terminal-sandbox: #a7f3d0;
  --shadow-terminal: inset 0 2px 6px rgba(0,0,0,0.4);
  --syntax-number: #e2e8f0;
  --syntax-operator: #e2e8f0;

  --border-subtle: rgba(148, 163, 184, 0.06);
  --border-mid: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.20);

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

  --accent-bright: #22d3ee;
  --accent-glow: #0891b2;
  --accent-dim: #164e63;
  --accent-bg: rgba(34, 211, 238, 0.08);
  --accent-bg-hover: rgba(34, 211, 238, 0.14);

  --teal-bright: #34d399;
  --teal-dim: #065f46;
  --teal-bg: rgba(52, 211, 153, 0.07);

  --red-bright: #f87171;
  --red-bg: rgba(248, 113, 113, 0.08);

  --indigo-bright: #818cf8;
  --indigo-bg: rgba(129, 140, 248, 0.08);

  --green-bright: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.08);

  --font-mono: "JetBrains Mono", "IBM Plex Mono", "Cascadia Code", Consolas, monospace;
  --font-body: "Inter", "DM Sans", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --font-serif: "Noto Serif SC", "Lora", Georgia, serif;
  --font-chat: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, "Microsoft YaHei", serif;

  --chat-user-shadow: 0 14px 32px rgba(0, 0, 0, 0.12);
  --chat-step-icon-bg: transparent;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}


/* ── Reset ─────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
textarea, input {
  caret-shape: block;
  caret-color: var(--text-primary);
}


/* ── Scrollbar ─────────────────────────────────────────────── */

* { scrollbar-width: thin; scrollbar-color: var(--border-mid) transparent; }
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }


/* ── Keyframes ─────────────────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInScale { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse-glow { 0%,100% { opacity: 1; } 50% { opacity: 0.8; box-shadow: 0 0 14px rgba(34,211,238,0.2); } }
@keyframes typewriter-blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes thinking-pulse { 0%,100% { transform: scale(1); opacity: 0.35; } 50% { transform: scale(1.3); opacity: 1; } }
@keyframes splash-fade-in { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes splash-exit { to { opacity: 0; transform: scale(1.03); filter: blur(6px); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes glow-border { 0%,100% { border-color: rgba(34,211,238,0.2); } 50% { border-color: rgba(34,211,238,0.5); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

.fadeIn { animation: fadeIn 0.3s ease; }


/* ============================================================
   SPLASH SCREEN
   ============================================================ */

.splash-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, var(--bg-surface) 0%, var(--bg-base) 100%);
  transition: opacity 0.6s ease, transform 0.6s ease, filter 0.6s ease;
}
.splash-screen.exiting { animation: splash-exit 0.6s ease forwards; pointer-events: none; }
.splash-screen.hidden { display: none; }
.splash-canvas { position: absolute; inset: 0; z-index: 0; }

/* ── Content wrapper ── */
.splash-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 0;
  animation: splash-fade-in 1s ease 0.2s both;
  width: 360px;
}

/* ── Logo icon ── */
.splash-logo {
  width: 80px; height: 80px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(34,211,238,0.14) 0%, rgba(129,140,248,0.09) 100%);
  border: 1px solid rgba(34,211,238,0.18);
  display: flex; align-items: center; justify-content: center;
  animation: float 4s ease-in-out infinite;
  box-shadow: 0 0 48px rgba(34,211,238,0.10), 0 12px 40px rgba(0,0,0,0.35);
  margin-bottom: 24px;
}
.splash-logo img { width: 50px; height: 50px; object-fit: contain; }

/* ── Wordmark block ── */
.splash-wordmark { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 8px; }
.splash-title {
  font-family: var(--font-body);
  font-size: 38px; font-weight: 700;
  background: linear-gradient(135deg, #f1f5f9 0%, #22d3ee 80%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  letter-spacing: -0.03em; line-height: 1;
}
.splash-subtitle {
  font-family: var(--font-serif);
  font-size: 13px; color: var(--text-muted);
  letter-spacing: 0.12em;
  animation: splash-fade-in 1s ease 0.5s both;
}

/* ── Version tag ── */
.splash-version {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--text-muted); opacity: 0.45;
  letter-spacing: 0.14em;
  margin-top: 2px; margin-bottom: 28px;
  animation: splash-fade-in 1s ease 0.7s both;
}

/* ── Enter button (returning user) ── */
.splash-enter-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 36px;
  border: 1px solid rgba(34,211,238,0.28);
  border-radius: 100px;
  background: linear-gradient(135deg, rgba(34,211,238,0.08) 0%, rgba(129,140,248,0.05) 100%);
  color: var(--accent-bright);
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.3s ease;
  animation: splash-fade-in 1s ease 1s both;
}
.splash-enter-btn:hover {
  background: linear-gradient(135deg, rgba(34,211,238,0.16) 0%, rgba(129,140,248,0.08) 100%);
  border-color: var(--accent-bright);
  box-shadow: 0 0 32px rgba(34,211,238,0.14);
  transform: translateY(-2px);
}
.splash-enter-btn svg { flex-shrink: 0; opacity: 0.8; transition: transform 0.25s ease; }
.splash-enter-btn:hover svg { transform: translateX(3px); }

/* ── Name-prompt section (first-time user) ── */
.splash-name-section {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  width: 100%;
  animation: splash-fade-in 0.6s ease 0.3s both;
}
.splash-divider {
  width: 48px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(34,211,238,0.3), transparent);
  margin-bottom: 4px;
}
.splash-greeting-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(34,211,238,0.07);
  border: 1px solid rgba(34,211,238,0.14);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-bright);
}
.splash-greeting-label {
  font-family: var(--font-body); font-size: 15px; font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.splash-greeting-sub {
  font-family: var(--font-serif); font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7; text-align: center;
  max-width: 280px;
  margin-top: -4px;
}
.splash-name-field {
  position: relative;
  width: 260px;
}
.splash-name-input {
  width: 100%;
  padding: 12px 20px;
  border: 1px solid var(--border-mid);
  border-radius: 100px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px; font-family: var(--font-body);
  text-align: center; outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  letter-spacing: 0.02em;
}
.splash-name-input::placeholder { color: var(--text-muted); }
.splash-name-input:focus {
  border-color: rgba(34,211,238,0.5);
  box-shadow: 0 0 0 3px rgba(34,211,238,0.08), 0 0 20px rgba(34,211,238,0.12);
}
.splash-enter-btn--name {
  margin-top: 4px;
  padding: 11px 32px;
}



/* ============================================================
   APP SHELL
   ============================================================ */

.view-hidden { display: none !important; }


/* ============================================================
   CHAT HOME
   ============================================================ */

.chat-home {
  height: 100vh;
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  padding: 6vh 5vw 60px;
  animation: fadeIn 0.35s ease both;
  position: relative;
  overflow: hidden;
}

/* Aurora Background Blobs */
.home-bg-blobs {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.22;
  mix-blend-mode: screen;
  transition: background-color 0.5s ease;
}

/* Light theme pastel blending mode and opacity override */
body.theme-light .bg-blob {
  mix-blend-mode: normal;
  opacity: 0.18;
}

.blob-1 {
  top: -10%;
  left: -10%;
  width: 480px;
  height: 480px;
  background-color: var(--accent-bright);
  animation: drift-1 25s infinite alternate ease-in-out;
}

.blob-2 {
  bottom: -20%;
  right: -10%;
  width: 520px;
  height: 520px;
  background-color: var(--accent-bright);
  filter: hue-rotate(60deg) blur(140px);
  animation: drift-2 30s infinite alternate ease-in-out;
}

.blob-3 {
  top: 40%;
  right: -20%;
  width: 420px;
  height: 420px;
  background-color: var(--accent-dim);
  filter: hue-rotate(-40deg) blur(140px);
  animation: drift-3 28s infinite alternate ease-in-out;
}

.blob-4 {
  bottom: 20%;
  left: -20%;
  width: 380px;
  height: 380px;
  background-color: var(--accent-bright);
  opacity: 0.10;
  filter: saturate(1.4) blur(140px);
  animation: drift-4 22s infinite alternate ease-in-out;
}

body.theme-light .blob-4 {
  opacity: 0.10;
}

@keyframes drift-1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(80px, 60px) scale(1.1); }
  100% { transform: translate(-40px, 120px) scale(0.9); }
}

@keyframes drift-2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-100px, -80px) scale(0.9); }
  100% { transform: translate(60px, -40px) scale(1.15); }
}

@keyframes drift-3 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-80px, 100px) scale(1.2); }
  100% { transform: translate(-120px, -60px) scale(0.85); }
}

@keyframes drift-4 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(120px, -40px) scale(0.85); }
  100% { transform: translate(40px, 80px) scale(1.1); }
}

/* Decorative background canvas */
.home-bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}

.chat-home-inner {
  width: min(720px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-home-inner.animate {
  opacity: 1;
  transform: translateY(0);
}

/* ── Top Nav Bar ── */
.home-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 48px;
  padding: 0 4px;
}

.home-logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  font-family: var(--font-body);
  opacity: 0.95;
}

/* ── Centered Greeting Area ── */
.home-greeting-hero {
  text-align: center;
  margin-bottom: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.home-greeting-label {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text-primary);
  font-family: var(--font-body);
}

.student-name-highlight {
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  font-weight: 800;
}

body.theme-light .student-name-highlight {
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.home-greeting-sub {
  font-size: 14px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  letter-spacing: 0.02em;
  opacity: 0.85;
}

/* Button group in header */
.home-header-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-mid);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.home-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-bright);
  border-color: var(--accent-bright);
  transform: scale(1.03);
}

/* ── Search bar ── */
.home-search-wrap {
  height: 56px;
  border-radius: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 0 20px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
  position: relative;
}
.home-search-wrap:focus-within {
  border-color: var(--accent-bright);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08), 0 0 0 3px var(--accent-bg);
  transform: translateY(-1px);
}
.home-search-wrap .search-icon {
  width: 18px; height: 18px;
  stroke: var(--text-muted);
  fill: none; stroke-width: 2.2;
  flex-shrink: 0;
  transition: stroke 0.2s ease;
}
.home-search-wrap:focus-within .search-icon {
  stroke: var(--accent-bright);
}
.home-search-wrap input {
  flex: 1;
  border: 0; outline: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  padding: 0;
}
.home-search-wrap input::placeholder {
  color: var(--text-muted);
  opacity: 0.75;
}

.home-search-submit {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.home-search-submit:hover {
  transform: scale(1.05);
  filter: brightness(1.1);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}
.home-search-submit svg {
  stroke: #ffffff !important;
  stroke-width: 2.8;
}

/* ── Primary action ── */
.home-actions {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 44px;
}

.home-action-btn.primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: linear-gradient(135deg, #4f46e5, #3b82f6);
  color: #ffffff;
  border-radius: 9999px;
  padding: 10px 22px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.home-action-btn.primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.32);
}
.home-action-btn.primary.disabled, .home-action-btn.primary[aria-disabled="true"] {
  opacity: 0.42;
  cursor: not-allowed;
  filter: grayscale(1);
  box-shadow: none;
}
.home-action-btn.primary.disabled:hover, .home-action-btn.primary[aria-disabled="true"]:hover {
  transform: none;
  filter: grayscale(1);
  box-shadow: none;
}
.home-action-btn.primary svg {
  stroke: #ffffff !important;
}

/* ── Section label ── */
.home-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 4px;
}
.home-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-body);
  letter-spacing: -0.01em;
  text-transform: none;
}
.home-section-link {
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease, transform 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}
body.theme-light .home-section-link {
  color: #4f46e5;
}
body:not(.theme-light) .home-section-link {
  color: var(--accent-bright);
}
.home-section-link:hover {
  filter: brightness(1.15);
  transform: translateX(2px);
}

/* ── Chat list ── */
.home-chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  max-height: min(360px, 38vh);
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.home-chat-list.show-all {
  max-height: min(520px, 52vh);
}

.home-chat-item {
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  text-align: left;
  padding: 13px 18px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
  transition: background 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}
.home-chat-item:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
  transform: translateY(-1.5px);
}
.home-chat-item:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

/* Language Icon Wrap */
.home-chat-icon-wrap {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.home-chat-item:hover .home-chat-icon-wrap {
  transform: scale(1.05);
}

.home-chat-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-grow: 1;
  min-width: 0;
}

.home-chat-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0;
}

.home-chat-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-chat-lang {
  display: inline-block;
  font-size: 10px;
  font-family: var(--font-body);
  font-weight: 600;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: capitalize;
  letter-spacing: 0;
  border: none;
}

/* Specific Lang Badge Colors */
.badge-lang-py {
  background: rgba(99, 102, 241, 0.08) !important;
  color: #6366f1 !important;
}
.badge-lang-js, .badge-lang-ts {
  background: rgba(245, 158, 11, 0.08) !important;
  color: #d97706 !important;
}
.badge-lang-cpp, .badge-lang-c {
  background: rgba(6, 182, 212, 0.08) !important;
  color: #0891b2 !important;
}
.badge-lang-java, .badge-lang-cs {
  background: rgba(239, 68, 68, 0.08) !important;
  color: #ef4444 !important;
}
.badge-lang-go, .badge-lang-rs {
  background: rgba(16, 185, 129, 0.08) !important;
  color: #059669 !important;
}

.home-chat-file-name {
  color: var(--text-secondary);
  opacity: 0.85;
  font-size: 12px;
}

.home-chat-meta-sep {
  color: var(--text-muted);
  opacity: 0.5;
}

.home-chat-turns {
  color: var(--text-muted);
  font-size: 12px;
}

.home-chat-date {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-body);
  white-space: nowrap;
  flex-shrink: 0;
  padding-right: 28px;
}

/* Delete button — hidden until hover */
.home-chat-del {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.home-chat-item:hover .home-chat-del {
  opacity: 1;
  pointer-events: auto;
}
.home-chat-del:hover {
  background: var(--red-bg) !important;
  color: var(--red-bright) !important;
  border-color: rgba(248, 113, 113, 0.25) !important;
  transform: translateY(-50%) scale(1.05);
}

/* ── Empty state ── */
.home-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 56px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.home-empty svg { opacity: 0.3; }
.home-empty-sub {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.6;
}



.app-shell { display: flex; flex-direction: column; height: 100vh; }
.back-home-btn { margin-right: 8px; }
.chat-titlebar { display: flex; flex-direction: column; gap: 1px; min-width: 0; margin-left: 8px; }
.chat-titlebar strong { color: var(--text-primary); font-size: 13px; font-weight: 600; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-titlebar span { color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }


/* ============================================================
   TOP BAR
   ============================================================ */

.top-bar {
  position: sticky; top: 0; z-index: 30;
  min-height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 20px;
  background: var(--bg-header, rgba(17, 24, 39, 0.88));
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.top-bar-left { display: flex; align-items: center; gap: 16px; }
.top-bar-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-width: 0; flex: 1; }
.top-bar-right { display: flex; align-items: center; gap: 10px; }

/* Brand */
.brand-wordmark { display: flex; align-items: center; gap: 8px; }
.brand-icon { width: 26px; height: 26px; border-radius: var(--radius-sm); background: var(--accent-bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-icon img.brand-mark { width: 18px; height: 18px; object-fit: contain; }
.brand-name { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--text-primary); letter-spacing: 0.02em; }

/* Mode Toggle — inline segmented control */
.mode-toggle {
  display: flex; align-items: center; gap: 2px;
  background: var(--bg-input); border: 1px solid var(--border-subtle);
  border-radius: 100px; padding: 2px;
}
.mode-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 14px; border: none; border-radius: 100px;
  background: transparent; color: var(--text-muted);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.02em;
  cursor: pointer; transition: all 0.25s ease; white-space: nowrap;
}
.mode-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mode-btn:hover { color: var(--text-secondary); }
.mode-btn.active { background: var(--accent-bg); color: var(--accent-bright); border: 1px solid var(--accent-dim); }

/* Session Badge */
.session-badge {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em;
  padding: 3px 10px; border-radius: 100px;
  background: var(--bg-raised); border: 1px solid var(--border-subtle);
  color: var(--text-muted); white-space: nowrap;
  transition: all 0.3s ease;
}

/* Connection dot */
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); transition: all 0.3s ease; flex-shrink: 0; }
.dot.configured { background: #fbbf24; box-shadow: 0 0 6px rgba(251,191,36,0.32); }
.dot.active, .dot.connected { background: var(--teal-bright); box-shadow: 0 0 6px rgba(52,211,153,0.4); }
.dot.error { background: var(--red-bright); box-shadow: 0 0 6px rgba(248,113,113,0.4); }

/* Top bar button */
.top-bar-btn { width: 34px; height: 34px; border-radius: var(--radius-md); background: transparent; border: 1px solid var(--border-mid); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; }
.top-bar-btn:hover { border-color: var(--accent-dim); color: var(--accent-bright); transform: translateY(-1px); }
.top-bar-btn.disabled, .top-bar-btn[aria-disabled="true"] { opacity: 0.38; cursor: not-allowed; filter: grayscale(1); }
.top-bar-btn.disabled:hover, .top-bar-btn[aria-disabled="true"]:hover { border-color: var(--border-mid); color: var(--text-secondary); transform: none; }
.top-bar-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }


/* ============================================================
   PIPELINE
   ============================================================ */

.pipeline { display: flex; align-items: center; }
.pipe-step { display: flex; align-items: center; gap: 5px; padding: 4px 12px; border-radius: 100px; border: 1px solid var(--border-subtle); color: var(--text-muted); font-size: 11px; font-family: var(--font-mono); transition: all 0.3s ease; cursor: default; white-space: nowrap; }
.pipe-step.active { color: var(--accent-bright); border-color: var(--accent-dim); background: var(--accent-bg); }
.pipe-step.current { border-color: var(--accent-bright); box-shadow: 0 0 0 1px rgba(34,211,238,0.3), 0 0 12px rgba(34,211,238,0.1); }
.pipeline.disabled { opacity: 0.35; filter: grayscale(1); }
.pipeline.disabled .pipe-step, .pipeline.disabled .pipe-connector { border-color: var(--border-subtle); background: transparent; color: var(--text-muted); box-shadow: none; }
.pipe-num { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 600; background: var(--border-subtle); color: var(--text-muted); transition: all 0.3s ease; }
.pipe-step.active .pipe-num { background: var(--accent-dim); color: var(--accent-bright); }
.pipe-connector { width: 20px; height: 2px; background: var(--border-subtle); transition: background 0.3s ease; flex-shrink: 0; }
.pipe-connector.active { background: var(--accent-dim); }
.pipe-label { font-size: 11px; letter-spacing: 0.04em; }

.challenge-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: min(720px, 52vw);
  overflow-x: auto;
  padding: 1px 2px 2px;
  scrollbar-width: none;
}
.challenge-tabs[hidden] { display: none; }
.challenge-tabs::-webkit-scrollbar { display: none; }
.challenge-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 92px;
  max-width: 190px;
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}
.challenge-tab:hover {
  border-color: var(--accent-dim);
  color: var(--text-primary);
}
.challenge-tab.active {
  border-color: var(--accent-bright);
  background: var(--accent-bg);
  color: var(--accent-bright);
  box-shadow: 0 0 0 1px rgba(34,211,238,0.24);
}
.challenge-tab.passed {
  opacity: 0.72;
}
.challenge-tab.locked {
  opacity: 0.58;
}
.challenge-tab-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.challenge-tab-status {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 9px;
}
.challenge-tab.active .challenge-tab-status {
  color: var(--accent-bright);
}


/* ============================================================
   MAIN & WORKSPACE
   ============================================================ */

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }

.workspace {
  flex: 1; display: grid;
  grid-template-columns: 2fr 3fr;
  overflow: hidden; min-height: 0;
}

.pane { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.pane-code { border-right: 1px solid var(--border-subtle); }

.pane-header {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; background: var(--bg-surface);
}

.pane-title { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; color: var(--text-secondary); text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.pane-icon { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.pane-toolbar { display: flex; align-items: center; gap: 6px; }

.pane-body {
  flex: 1; overflow: hidden; overflow-x: hidden;
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 12px;
}


/* ── File Path Bar ─────────────────────────────────────────── */

.file-path-bar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 11px; }
.file-path-label { color: var(--text-muted); }
.file-path-text { color: var(--accent-bright); word-break: break-all; }


/* ── Code Editor ───────────────────────────────────────────── */

.code-editor-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 3;
  min-height: 0;
  transition: flex 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.code-editor-wrap.pane-shrunk {
  flex: 1 !important;
}
.code-editor-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--text-muted); text-transform: uppercase; }
.editor-toggle {
  border: 1px solid var(--border-mid);
  background: var(--bg-input);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 8px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.editor-toggle.active {
  border-color: rgba(52, 211, 153, 0.34);
  color: #34d399;
  background: rgba(52, 211, 153, 0.08);
}
.code-editor-shell {
  flex: 1;
  min-height: 120px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.code-editor-shell:focus-within {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(34,211,238,0.06);
}
.code-editor-shell.annotations-off { grid-template-columns: 44px minmax(0, 1fr); }
.code-line-gutter {
  background: var(--bg-gutter);
  border-right: 1px solid var(--border-subtle);
  color: var(--text-gutter);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 20.4px;
  padding: 12px 8px;
  text-align: right;
  user-select: none;
  overflow: hidden;
  white-space: pre;
}
.code-line-gutter-content { will-change: transform; }
.code-textarea-cell { position: relative; min-width: 0; min-height: 0; display: flex; }
.code-highlight-layer {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 20.4px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  pointer-events: none;
  z-index: 1;
}
.code-editor-shell.annotations-off .code-highlight-layer { display: none; }
#codeInput {
  flex: 1;
  min-height: 120px;
  resize: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 12px 14px;
  line-height: 20.4px;
  overflow: auto;
  position: relative;
  z-index: 2;
}
#codeInput:focus { box-shadow: none; border-color: transparent; }
.code-editor-shell.annotations-on #codeInput {
  color: transparent;
  caret-color: var(--text-primary);
}
.code-editor-shell.annotations-on #codeInput::selection {
  background: rgba(56, 189, 248, 0.28);
}
.syntax-keyword { color: #ff7b00; }
.syntax-builtin { color: #a855f7; }
.syntax-function { color: #a855f7; }
.syntax-string { color: #00aa00; }
.syntax-number { color: var(--syntax-number); }
.syntax-comment { color: #64748b; font-style: italic; }
.syntax-operator { color: var(--syntax-operator); }


/* ── Terminal Section ──────────────────────────────────────── */

.terminal-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
  transition: flex 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.terminal-section.pane-expanded {
  flex: 3 !important;
}
.terminal-header { display: flex; align-items: center; justify-content: space-between; }

.btn-terminal-run { display: flex; align-items: center; gap: 5px; background: var(--teal-bg); border: 1px solid var(--teal-dim); border-radius: var(--radius-sm); color: var(--teal-bright); font-family: var(--font-mono); font-size: 11px; padding: 4px 10px; cursor: pointer; transition: all 0.2s ease; }
.btn-terminal-run:hover:not(:disabled) { background: rgba(52,211,153,0.14); border-color: var(--teal-bright); box-shadow: 0 0 8px rgba(52,211,153,0.12); transform: translateY(-1px); }
.btn-terminal-run:disabled { opacity: 0.5; cursor: wait; }
.btn-run-icon { width: 10px; height: 10px; fill: currentColor; stroke: none; }

.textarea-terminal {
  background: var(--bg-terminal) !important;
  border-color: var(--border-strong) !important;
  color: var(--text-terminal) !important;
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
  padding: 10px 12px !important;
  box-shadow: var(--shadow-terminal) !important;
  min-height: 80px !important;
  flex: 1;
}
.textarea-terminal::placeholder { color: var(--text-muted); }


/* ── Textareas ─────────────────────────────────────────────── */

textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.7;
  padding: 12px 14px;
  resize: vertical; outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}
textarea:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(34,211,238,0.06); }
textarea::placeholder { color: var(--text-muted); }

select.select-compact { background: var(--bg-input); border: 1px solid var(--border-mid); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font-mono); font-size: 10px; padding: 4px 6px; outline: none; cursor: pointer; transition: border-color 0.2s ease; }
select.select-compact:focus { border-color: var(--accent-dim); }


/* ============================================================
   CONVERSATION AREA (Right Pane)
   ============================================================ */

.pane-mentor { display: flex; flex-direction: column; }

body.theme-light .pane-mentor {
  background:
    radial-gradient(circle at 16% 10%, rgba(191, 219, 254, 0.42), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, #f6f9fd 56%, #eef4fb 100%);
}

.conversation-area {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 24px 28px;
  display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth;
}


/* ── Welcome Card ──────────────────────────────────────────── */

.welcome-card {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  padding: 40px 32px;
  animation: fadeInScale 0.5s ease both;
}
.welcome-avatar { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, var(--accent-bg), var(--indigo-bg)); border: 1px solid var(--accent-dim); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.welcome-avatar img { width: 40px; height: 40px; object-fit: contain; }
.welcome-text { text-align: center; max-width: 420px; }
.welcome-text h2 { font-family: var(--font-body); font-size: 18px; font-weight: 500; color: var(--text-primary); margin-bottom: 8px; }
.welcome-text p { font-size: 13px; color: var(--text-secondary); line-height: 1.7; }

.welcome-principles { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 380px; margin-top: 4px; }
.wp-item { display: flex; align-items: flex-start; gap: 10px; font-size: 12px; color: var(--text-secondary); }
.wp-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-glow); flex-shrink: 0; margin-top: 6px; }
.wp-icon { width: 18px; height: 18px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; color: var(--accent-bright); margin-top: 1px; }
.wp-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.wp-item b { color: var(--accent-bright); font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: 0.04em; white-space: nowrap; margin-right: 4px; }

body.theme-light .welcome-avatar {
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(147, 197, 253, 0.72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 18px 38px rgba(37, 99, 235, 0.08);
}
body.theme-light .welcome-text h2 {
  color: #0f172a;
}
body.theme-light .welcome-text p {
  color: #475569;
}
body.theme-light .wp-item {
  color: #475569;
}
body.theme-light .wp-item b {
  color: #1d75d6;
}

.welcome-actions { display: flex; gap: 8px; margin-top: 8px; }
.wa-btn { display: flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--border-mid); border-radius: var(--radius-md); background: var(--bg-raised); color: var(--text-secondary); font-family: var(--font-mono); font-size: 11px; cursor: pointer; transition: all 0.2s ease; }
.wa-btn:hover:not(:disabled) { border-color: var(--accent-dim); color: var(--accent-bright); background: var(--accent-bg); transform: translateY(-1px); }
.wa-btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }
.wa-btn.disabled, .wa-btn[aria-disabled="true"] { opacity: 0.42; cursor: not-allowed; filter: grayscale(1); transform: none; }
.wa-btn.disabled:hover, .wa-btn[aria-disabled="true"]:hover { border-color: var(--border-mid); color: var(--text-secondary); background: var(--bg-raised); transform: none; }
.wa-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }


/* ── Turn History Cards ────────────────────────────────────── */

.turn-card {
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  animation: slide-up 0.35s ease both;
  color: var(--text-primary);
}

#turnHistory {
  display: flex;
  flex-direction: column;
  gap: 34px;
}

.turn-dialogue {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.turn-user-row {
  align-self: flex-end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  width: min(560px, 82%);
  margin-left: auto;
}

.turn-user-bubble {
  max-width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--border-mid);
  border-radius: 22px;
  border-top-right-radius: 9px;
  background: var(--bg-raised);
  box-shadow: var(--chat-user-shadow);
  color: var(--text-primary);
  font-family: var(--font-chat);
  font-size: 16px;
  line-height: 1.75;
  white-space: normal;
}

.turn-user-text {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.turn-message-time {
  padding-right: 2px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1;
}

.turn-thought {
  width: 100%;
}

.turn-thought-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  user-select: none;
}

.turn-thought-header:hover {
  color: var(--text-primary);
}

.turn-thought-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: currentColor;
  font-family: var(--font-chat);
  font-size: 18px;
  font-weight: 650;
  line-height: 1.2;
}

.turn-thought-title svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.86;
}

.turn-thought-meta {
  min-width: 0;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.turn-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.turn-thought-header:hover .turn-toggle { background: var(--bg-hover); color: var(--text-secondary); }
.turn-toggle svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.turn-toggle.open { transform: rotate(180deg); }

.turn-thought-body {
  max-width: 860px;
  padding: 14px 0 2px 31px;
  color: var(--text-secondary);
}
.turn-thought-body.collapsed { display: none; }

.turn-thought-track {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-left: 18px;
  border-left: 1px solid var(--border-mid);
}

.turn-thought-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  font-size: 13px;
  line-height: 1.55;
}

.turn-thought-step-icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-mid);
  border-radius: 999px;
  background: var(--chat-step-icon-bg);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
}

.turn-thought-step-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.turn-thought-step-copy strong {
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 650;
}

.turn-thought-step-copy span {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.turn-assistant-row {
  max-width: 960px;
}

.turn-assistant-text {
  color: var(--text-primary);
  font-family: var(--font-chat);
  font-size: 17px;
  line-height: 1.95;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.turn-mindmap-wrap {
  margin-top: 4px;
}

.turn-target-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  margin: 0 0 8px;
  padding: 4px 8px;
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: var(--radius-sm);
  background: rgba(37, 99, 235, 0.08);
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
}
.turn-target-chip span {
  color: var(--accent-bright);
  font-family: var(--font-mono);
  font-size: 10px;
}
.turn-target-chip strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  font-weight: 600;
}

body.theme-light {
  --chat-user-shadow: none;
  --chat-step-icon-bg: var(--bg-surface);
}


/* ── Response Card (current) ───────────────────────────────── */

.response-card {
  width: 100%;
  max-width: 960px;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  animation: slide-up 0.35s ease both;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}
.response-card.thinking {
  border-color: transparent;
  box-shadow: none;
  animation: slide-up 0.35s ease both;
}

.response-card-header {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 0 0 6px;
  border-bottom: 0;
}
.response-avatar { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent-bg), var(--indigo-bg)); display: none; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.response-avatar img { width: 20px; height: 20px; object-fit: contain; }
.response-author { display: none; font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text-primary); flex: 1; }
.response-time { font-family: var(--font-body); font-size: 12px; color: var(--text-muted); }

.response-box {
  padding: 0;
  font-family: var(--font-chat);
  font-size: 17px; line-height: 1.95;
  color: var(--text-primary);
  white-space: pre-wrap;
  min-height: 0;
  overflow: visible;
  position: relative;
  overflow-wrap: anywhere;
}

.response-box.thinking {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.response-box .placeholder { font-family: var(--font-serif); font-style: italic; color: var(--text-muted); font-size: 13px; white-space: normal; }
.response-box code { font-family: var(--font-mono); font-size: 11px; background: var(--bg-raised); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 1px 5px; color: var(--accent-bright); }


/* ── Typewriter & Thinking ─────────────────────────────────── */

.typewriter-cursor { display: inline-block; width: 8px; height: 1.1em; background: var(--text-primary); margin-left: 1px; vertical-align: text-bottom; animation: typewriter-blink 1s step-end infinite; }

.thinking-dots { display: inline-flex; align-items: center; gap: 5px; padding: 4px 0; margin-right: 6px; }
.thinking-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-bright); animation: thinking-pulse 1.4s ease-in-out infinite; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

.skip-animation-btn { position: absolute; bottom: 10px; right: 10px; padding: 3px 10px; border: 1px solid var(--border-mid); border-radius: 100px; background: var(--bg-raised); color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; cursor: pointer; transition: all 0.2s ease; opacity: 0.7; z-index: 5; }
.skip-animation-btn:hover { opacity: 1; border-color: var(--accent-dim); color: var(--text-secondary); }


/* ============================================================
   INPUT DOCK (bottom of mentor pane)
   ============================================================ */

.input-dock {
  flex-shrink: 0;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex; flex-direction: column; gap: 10px;
  transition: padding 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.input-dock-field { display: flex; flex-direction: column; gap: 4px; }
.hypothesis-target-banner {
  display: grid;
  grid-template-columns: max-content minmax(120px, 150px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 62px;
  padding: 12px 16px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--bg-raised), var(--bg-surface));
  color: var(--text-secondary);
  box-shadow: inset 0 1px 0 var(--border-subtle);
  font-size: 13px;
}
.hypothesis-target-title {
  position: relative;
  min-width: 0;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 18px;
  line-height: 1.28;
  overflow-wrap: anywhere;
}
.hypothesis-target-title::before,
.hypothesis-target-summary::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 50%;
  width: 1px;
  height: 38px;
  transform: translateY(-50%);
  background: var(--border-mid);
}
.hypothesis-target-summary {
  position: relative;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}
.hypothesis-target-kicker {
  flex: 0 0 auto;
  color: var(--accent-bright);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}
.tutorial-ref-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 120px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid var(--border-mid);
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--accent-bright);
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.10);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}
.tutorial-ref-chip svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tutorial-ref-chip span {
  color: currentColor;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.tutorial-ref-chip:hover {
  color: var(--accent-bright);
  border-color: rgba(59, 130, 246, 0.38);
  box-shadow: 0 16px 32px rgba(30, 64, 175, 0.16);
  transform: translateY(-1px);
}
.dock-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--text-muted); text-transform: uppercase; }
.dock-textarea {
  background: var(--bg-input); border: 1px solid var(--border-mid); border-radius: var(--radius-lg);
  color: var(--text-primary); font-family: var(--font-body); font-size: 14px;
  padding: 10px 14px; resize: none; outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%; min-height: 46px; line-height: 1.45;
}
.dock-textarea:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(34,211,238,0.06); }
.dock-textarea::placeholder { color: var(--text-muted); }

.input-dock-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; }
.input-dock-left,
.input-dock-actions { display: flex; align-items: center; gap: 12px; }
.shortcut-hint { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); opacity: 0.72; letter-spacing: 0.06em; }

.dock-collapse-btn,
.dock-upload-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  margin-top: 0;
}

.dock-collapse-btn svg,
.dock-upload-btn svg {
  width: 17px;
  height: 17px;
}

.dock-collapse-btn svg {
  transition: transform 0.2s ease;
}

.input-dock.collapsed {
  padding-top: 9px;
  padding-bottom: 9px;
  gap: 0;
}

.input-dock.collapsed .attachment-preview-bar,
.input-dock.collapsed .hypothesis-target-banner,
.input-dock.collapsed .input-dock-field {
  display: none !important;
}

.input-dock.collapsed .dock-collapse-btn svg {
  transform: rotate(180deg);
}

.btn-ghost.challenge-pass-btn {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}

#diagnose.btn-primary {
  min-height: 40px;
  padding: 0 18px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

body.theme-light .input-dock {
  border-top-color: rgba(203, 213, 225, 0.8);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 -14px 36px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255,255,255,0.8);
}

body.theme-light .hypothesis-target-banner {
  border-color: rgba(147, 197, 253, 0.8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.86);
}

body.theme-light .dock-textarea {
  background: rgba(255,255,255,0.86);
  border-color: rgba(148, 163, 184, 0.38);
  color: #0f172a;
}

body.theme-light .dock-textarea:focus {
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.10);
}

body.theme-light .dock-upload-btn,
body.theme-light .dock-collapse-btn,
body.theme-light .challenge-pass-btn {
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.28);
  color: #475569;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

body.theme-light #diagnose.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, #2f8df4 0%, #4058f2 100%);
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.26);
}

body.theme-light #diagnose.btn-primary:hover:not(:disabled) {
  border-color: transparent;
  background: linear-gradient(135deg, #247ee6 0%, #3549dc 100%);
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.34);
}

body.theme-light #diagnose.btn-primary svg {
  stroke: #ffffff;
}

@media (max-width: 980px) {
  .hypothesis-target-banner {
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: stretch;
  }

  .hypothesis-target-title::before,
  .hypothesis-target-summary::before {
    display: none;
  }

  .tutorial-ref-chip {
    justify-self: start;
  }

  .input-dock-bar,
  .input-dock-actions {
    flex-wrap: wrap;
  }
}


/* ============================================================
   BUTTONS
   ============================================================ */

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  background: linear-gradient(135deg, rgba(34,211,238,0.14), rgba(129,140,248,0.06));
  border: 1px solid var(--accent-glow); border-radius: var(--radius-md);
  color: var(--accent-bright); font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.04em; padding: 9px 20px;
  cursor: pointer; transition: all 0.2s ease;
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, rgba(34,211,238,0.22), rgba(129,140,248,0.1)); border-color: var(--accent-bright); box-shadow: 0 0 16px rgba(34,211,238,0.12); transform: translateY(-1px); }
.btn-primary:disabled { cursor: wait; opacity: 0.6; }
.btn-primary svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; animation: none; }
.btn-primary.loading svg { animation: spin 1s linear infinite; }

.btn-icon { background: var(--bg-raised); border: 1px solid var(--border-mid); border-radius: var(--radius-md); color: var(--text-secondary); padding: 8px 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s ease; }
.btn-icon:hover { color: var(--text-primary); border-color: var(--border-strong); transform: translateY(-1px); }
.btn-icon svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn-icon-small { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 3px; border-radius: var(--radius-sm); transition: color 0.2s ease; display: flex; align-items: center; justify-content: center; }
.btn-icon-small:hover { color: var(--text-secondary); }
.btn-icon-small.disabled, .btn-icon-small[aria-disabled="true"] { opacity: 0.34; cursor: not-allowed; filter: grayscale(1); }
.btn-icon-small.disabled:hover, .btn-icon-small[aria-disabled="true"]:hover { color: var(--text-muted); }
.btn-icon-small.danger:hover { color: var(--red-bright); }
.btn-icon-small svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn-ghost { background: none; border: 1px solid var(--border-mid); border-radius: var(--radius-md); color: var(--text-secondary); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; padding: 8px 16px; cursor: pointer; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; gap: 6px; }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-strong); background: var(--bg-hover); transform: translateY(-1px); }
.btn-ghost svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }


/* ============================================================
   BADGE
   ============================================================ */

.badge { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; padding: 3px 9px; border-radius: 100px; color: var(--text-muted); background: var(--bg-raised); border: 1px solid var(--border-subtle); transition: all 0.3s ease; white-space: nowrap; }
.badge.waiting { color: var(--text-muted); }
.badge.thinking { color: var(--accent-bright); background: var(--accent-bg); border-color: var(--accent-dim); animation: pulse-glow 2s ease-in-out infinite; }
.badge.done { color: var(--teal-bright); background: var(--teal-bg); border-color: var(--teal-dim); }
.badge.error { color: var(--red-bright); background: var(--red-bg); border-color: #7f1d1d; }


/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-md);
  background: var(--bg-raised); border: 1px solid var(--border-mid);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary);
  pointer-events: auto; animation: toast-in 0.3s ease;
  max-width: 320px;
}
.toast.exiting { animation: toast-out 0.3s ease forwards; }
.toast.success { border-color: var(--teal-dim); color: var(--teal-bright); }
.toast.error { border-color: #7f1d1d; color: var(--red-bright); }
.toast.info { border-color: var(--accent-dim); color: var(--accent-bright); }

.soft-notice {
  max-width: 260px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s ease;
}

.soft-notice.success {
  color: var(--teal-bright);
  border-color: var(--teal-dim);
  background: var(--teal-bg);
}

.soft-notice.info {
  color: var(--text-secondary);
}

.soft-notice.fading {
  opacity: 0;
}


/* ============================================================
   DRAWER
   ============================================================ */

.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 40; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 380px; background: var(--bg-surface); border-left: 1px solid var(--border-mid); z-index: 41; display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.35s cubic-bezier(0.4,0,0.2,1); box-shadow: -8px 0 40px rgba(0,0,0,0.4); }
.drawer.open { transform: translateX(0); }

.drawer-header { padding: 18px 20px 14px; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: flex-start; justify-content: space-between; flex-shrink: 0; gap: 12px; }
.drawer-title { font-size: 15px; font-weight: 500; color: var(--text-primary); }
.drawer-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; overflow-x: hidden; }
.drawer-section { padding: 14px 20px; border-bottom: 1px solid var(--border-subtle); }
.section-label { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); margin-bottom: 10px; }


/* ── Mentor Identity ───────────────────────────────────────── */

.mentor-identity { display: flex; align-items: flex-start; gap: 12px; }
.mentor-avatar { width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--bg-raised); border: 1px solid var(--border-mid); overflow: hidden; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.mentor-avatar img.asset-logo { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.mentor-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mentor-name { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text-primary); }
.mentor-desc { font-size: 11px; color: var(--text-muted); line-height: 1.5; }


/* ── Model Menu ────────────────────────────────────────────── */

.model-menu-card { background: var(--bg-raised); border: 1px solid var(--border-mid); border-radius: var(--radius-md); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.model-menu-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.model-menu-row { display: flex; align-items: center; gap: 8px; }
.model-combobox { position: relative; flex: 1; min-width: 0; }
.model-menu-button { width: 100%; background: var(--bg-input); border: 1px solid var(--border-mid); border-radius: var(--radius-sm); padding: 8px 12px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; transition: border-color 0.2s ease; color: var(--text-primary); }
.model-menu-button:hover { border-color: var(--border-strong); }
.model-menu-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; overflow: hidden; }
.model-menu-title { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-menu-provider { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-menu-id { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.7; }
.model-menu-arrow { width: 14px; height: 14px; stroke: var(--text-muted); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; transition: transform 0.2s ease; }
.model-combobox.open .model-menu-arrow { transform: rotate(180deg); }
.model-menu-panel { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--bg-raised); border: 1px solid var(--border-mid); border-radius: var(--radius-md); padding: 6px; z-index: 10; max-height: 280px; overflow-y: auto; display: none; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.model-combobox.open .model-menu-panel { display: block; }
.model-menu-section { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); padding: 8px 10px 4px; }
.model-menu-option { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.15s ease; }
.model-menu-option:hover { background: var(--bg-hover); }
.model-menu-option.selected { background: var(--accent-bg); }
.model-option-main { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.model-option-name { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text-primary); }
.model-option-provider { font-size: 10px; color: var(--text-muted); }
.model-option-id { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); opacity: 0.7; }
.model-option-check { width: 14px; height: 14px; stroke: var(--accent-bright); fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; opacity: 0; transition: opacity 0.2s ease; }
.model-menu-option.selected .model-option-check { opacity: 1; }
.model-settings-trigger { background: none; border: 1px solid var(--border-mid); border-radius: var(--radius-sm); color: var(--text-muted); padding: 6px 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; flex-shrink: 0; }
.model-settings-trigger:hover { color: var(--text-secondary); border-color: var(--border-strong); }
.model-settings-trigger svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.model-summary { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }


/* ── Records ───────────────────────────────────────────────── */

.records-section { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.record-tabs { background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); padding: 2px; }
.record-tab { background: transparent; border: none; border-radius: 5px; color: var(--text-muted); cursor: pointer; font-size: 11px; padding: 6px 4px; text-align: center; transition: all 0.2s ease; font-family: var(--font-mono); }
.record-tab:hover { color: var(--text-secondary); }
.record-tab.active { background: var(--accent-bg); color: var(--accent-bright); }
.record-folder { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); padding: 4px 0; display: flex; align-items: center; gap: 6px; word-break: break-all; }
.record-list { display: flex; flex-direction: column; gap: 2px; }
.record-file { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background 0.15s ease; gap: 8px; }
.record-file:hover { background: var(--bg-hover); }
.record-file.active { background: var(--accent-bg); }
.record-file-name { font-family: var(--font-mono); font-size: 12px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.record-file-meta { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.record-empty { font-size: 12px; color: var(--text-muted); text-align: center; padding: 16px 10px; font-style: italic; }
.record-editor-card { background: var(--bg-input); border: 1px solid var(--border-mid); border-radius: var(--radius-md); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.record-editor-header { display: flex; align-items: center; justify-content: space-between; font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }
#recordEditor { flex: 1; min-height: 120px; resize: none; background: var(--bg-base); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); font-size: 11px; padding: 8px 10px; }
#recordEditor.student-summary { font-family: var(--font-body); font-size: 12px; line-height: 1.7; color: var(--text-primary); white-space: pre-wrap; }
#recordEditor.student-summary:read-only { cursor: default; background: rgba(15, 23, 42, 0.76); }
.record-editor-actions .btn-icon-small:disabled { opacity: 0.38; cursor: not-allowed; transform: none; }
.record-status { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); text-align: right; }
.record-status.saved { color: var(--teal-bright); }
.record-status.error { color: var(--red-bright); }


/* ── Advanced Settings ─────────────────────────────────────── */

.settings-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50; }
.model-settings-popover { position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 400px; max-height: calc(100vh - 80px); overflow-y: auto; box-shadow: 0 24px 60px rgba(0,0,0,0.5); border-radius: var(--radius-lg); }
.advanced-panel { background: var(--bg-surface); border: 1px solid var(--border-mid); border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.advanced-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.advanced-kicker { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); display: block; margin-bottom: 2px; }
.advanced-header strong { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--text-muted); text-transform: uppercase; }
.field select { background: var(--bg-input); border: 1px solid var(--border-mid); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font-mono); font-size: 12px; padding: 8px 10px; outline: none; transition: border-color 0.2s ease; }
.field select:focus { border-color: var(--accent-dim); }
.field input[type="text"], .field input[type="number"], .field input[type="password"] { background: var(--bg-input); border: 1px solid var(--border-mid); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font-mono); font-size: 12px; padding: 8px 10px; outline: none; width: 100%; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.field input:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(34,211,238,0.06); }
.field input::placeholder { color: var(--text-muted); }
.secret-wrap { position: relative; display: flex; align-items: center; }
.secret-wrap input { flex: 1; padding-right: 36px; }
.secret-wrap .toggle-secret { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; transition: color 0.2s ease; }
.secret-wrap .toggle-secret:hover { color: var(--text-secondary); }
.secret-wrap .toggle-secret svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.config-footer { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; border-top: 1px solid var(--border-subtle); }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); }
.check-row input[type="checkbox"] { accent-color: var(--accent-bright); width: 14px; height: 14px; cursor: pointer; }


/* ── Utilities ─────────────────────────────────────────────── */

.hidden { display: none !important; }
.settings-backdrop[hidden], .advanced-panel[hidden], .model-settings-popover[hidden], .model-menu-panel[hidden] { display: none; }
::selection { background: rgba(34,211,238,0.25); color: var(--text-primary); }
:focus-visible { outline: 2px solid var(--accent-dim); outline-offset: 2px; }


/* ── Responsive ≤ 1120px ───────────────────────────────────── */

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 1fr; }
  .pane-code { border-right: none; border-bottom: 1px solid var(--border-subtle); max-height: 45vh; }
  .top-bar-center { display: none; }
  .drawer { width: 100%; }
  .pane-body { padding: 14px 16px; }
  .pane-header { padding: 8px 16px; }
  .top-bar { padding: 0 16px; }
  .conversation-area { padding: 16px; }
  .model-settings-popover { width: calc(100vw - 32px); max-width: 400px; }
}

@media (max-width: 640px) {
  .chat-home { padding: 4vh 16px 32px; }
  .home-top-bar { margin-bottom: 24px; }
  .home-greeting-hero { margin-bottom: 24px; }
  .home-greeting-label { font-size: 26px; }
  .home-search-wrap { height: 48px; border-radius: 12px; padding: 0 10px 0 14px; gap: 8px; margin-bottom: 14px; }
  .home-search-submit { width: 30px; height: 30px; }
  .home-actions { margin-bottom: 28px; }
  .home-chat-list { gap: 8px; }
  .home-chat-item { padding: 12px 14px; border-radius: 12px; gap: 12px; }
  .home-chat-icon-wrap { width: 32px; height: 32px; }
  .home-chat-title { font-size: 14px; }
  .home-chat-date { font-size: 11px; padding-right: 20px; }
  .mode-toggle { display: none; }
  .top-bar { padding: 0 12px; height: 48px; }
  .pane-body { padding: 10px 12px; }
  .pane-header { padding: 8px 12px; }
  .conversation-area { padding: 12px; }
  #turnHistory { gap: 26px; }
  .turn-user-row,
  .student-message-card { width: min(100%, 92%); }
  .turn-user-bubble,
  .student-msg-box { font-size: 15px; padding: 12px 15px; }
  .turn-thought-title { font-size: 16px; }
  .turn-assistant-text { font-size: 16px; line-height: 1.85; }
  .turn-thought-meta { display: none; }
  .model-settings-popover { width: calc(100vw - 16px); }
  .input-dock { padding: 10px 12px 14px; }
}

/* ── Sandbox Verification Modal ────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 12, 24, 0.75);
  backdrop-filter: blur(12px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-backdrop.open {
  opacity: 1; pointer-events: auto;
}
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-lg);
  width: 800px; max-width: 90%;
  height: 600px; max-height: 90vh;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(34, 211, 238, 0.1);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.verify-confirm-card {
  width: 520px;
  height: auto;
  max-height: 80vh;
}
.verify-confirm-body {
  padding: 22px 24px;
  background: var(--bg-base);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 12px;
  line-height: 1.7;
  font-size: 14px;
}
.verify-confirm-body p { margin: 0; }
.primary-confirm {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.36);
  color: #34d399;
}
@keyframes modalScaleUp {
  from { transform: scale(0.9) translateY(20px); }
  to { transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 16px 20px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-subtle);
}
.modal-title {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-serif); font-size: 16px; font-weight: 600;
  color: var(--accent-bright);
}
.modal-icon {
  width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2;
}
.modal-subtitle {
  font-size: 11px; color: var(--text-muted); font-family: var(--font-mono);
  margin-top: 4px; display: block;
}
.modal-body {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  padding: 20px; overflow: hidden;
  background: var(--bg-base);
}
.sandbox-code-section, .sandbox-terminal-section {
  display: flex; flex-direction: column; gap: 8px; height: 100%; min-height: 0;
}
.section-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em;
  color: var(--text-muted); text-transform: uppercase;
}
#sandboxCodeInput {
  flex: 1; resize: none; background: var(--bg-input);
  border: 1px solid var(--border-mid); border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  padding: 12px; color: var(--text-primary); outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
#sandboxCodeInput:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(34,211,238,0.06);
}
#sandboxCodeInput[readonly] {
  opacity: 0.72;
  cursor: progress;
}
.sandbox-terminal-section .terminal-header {
  display: flex; align-items: center; justify-content: space-between;
}
#sandboxTerminalOutput {
  flex: 1; resize: none; background: var(--bg-terminal);
  border: 1px solid var(--border-mid); border-radius: var(--radius-md);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  padding: 12px; color: var(--text-terminal-sandbox); outline: none;
}
.modal-footer {
  padding: 16px 20px;
  background: var(--bg-raised);
  border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
}
.footer-question {
  font-size: 13px; color: var(--text-secondary);
}
.footer-actions {
  display: flex; gap: 12px;
}

/* ── Themes ─────────────────────────────────────────── */

body.theme-purple {
  --bg-base: #0b0914;
  --bg-surface: #110f22;
  --bg-raised: #1f1b3d;
  --bg-hover: #2f2b5a;
  --bg-input: #0e0c1b;
  --accent-bright: #a78bfa;
  --accent-glow: #8b5cf6;
  --accent-dim: #4c1d95;
  --accent-bg: rgba(167, 139, 250, 0.08);
  --accent-bg-hover: rgba(167, 139, 250, 0.14);

  --bg-header: rgba(17, 15, 34, 0.88);

  --bg-gutter: #08060f;
  --text-gutter: rgba(167, 139, 250, 0.6);
  --bg-terminal: #07050d;
  --text-terminal: #e2d9f3;
  --text-terminal-sandbox: #c084fc;
  --shadow-terminal: inset 0 2px 6px rgba(0,0,0,0.4);
  --syntax-number: #e2e8f0;
  --syntax-operator: #e2e8f0;
}

body.theme-cyber {
  --bg-base: #020202;
  --bg-surface: #0a0a0a;
  --bg-raised: #161616;
  --bg-hover: #222222;
  --bg-input: #070707;
  --accent-bright: #10b981;
  --accent-glow: #059669;
  --accent-dim: #064e3b;
  --accent-bg: rgba(16, 185, 129, 0.08);
  --accent-bg-hover: rgba(16, 185, 129, 0.14);

  --bg-header: rgba(10, 10, 10, 0.88);

  --bg-gutter: #010101;
  --text-gutter: rgba(16, 185, 129, 0.6);
  --bg-terminal: #000000;
  --text-terminal: #10b981;
  --text-terminal-sandbox: #34d399;
  --shadow-terminal: inset 0 2px 6px rgba(0,0,0,0.6);
  --syntax-number: #a7f3d0;
  --syntax-operator: #34d399;
}

body.theme-light {
  color-scheme: light;
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-raised: #f1f5f9;
  --bg-hover: #e2e8f0;
  --bg-input: #f8fafc;
  --border-subtle: rgba(100, 116, 139, 0.08);
  --border-mid: rgba(100, 116, 139, 0.15);
  --border-strong: rgba(100, 116, 139, 0.25);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-bright: #0284c7;
  --accent-glow: #0369a1;
  --accent-dim: #bae6fd;
  --accent-bg: rgba(2, 132, 199, 0.08);
  --accent-bg-hover: rgba(2, 132, 199, 0.14);

  --bg-header: rgba(255, 255, 255, 0.88);

  --bg-gutter: #f1f5f9;
  --text-gutter: rgba(100, 116, 139, 0.6);
  --bg-terminal: #f8fafc;
  --text-terminal: #0f172a;
  --text-terminal-sandbox: #0f172a;
  --shadow-terminal: inset 0 1px 3px rgba(0,0,0,0.06);
  --syntax-number: #0f172a;
  --syntax-operator: #0f172a;
}

/* .splash-name-input:focus is defined in the SPLASH SCREEN section above */

/* ── Student Message Card ── */
.student-message-card {
  align-self: flex-end;
  width: min(560px, 82%);
  margin-left: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  animation: slide-up 0.35s ease both;
  margin-bottom: 2px;
}
.student-msg-header {
  padding: 7px 2px 0;
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1;
  color: var(--text-muted);
  text-align: right;
}
.student-msg-box {
  max-width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--border-mid);
  border-radius: 22px;
  border-top-right-radius: 9px;
  background: var(--bg-raised);
  box-shadow: var(--chat-user-shadow);
  color: var(--text-primary);
  font-family: var(--font-chat);
  font-size: 16px;
  line-height: 1.75;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ── Drag & Drop / Attachments ── */
.conversation-area.drag-over {
  border: 2px dashed var(--accent-bright) !important;
  background: var(--accent-bg) !important;
  transition: border-color 0.25s ease, background-color 0.25s ease;
}

.attachment-preview-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}

.attachment-thumb {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  max-width: 180px;
  animation: fadeIn 0.2s ease;
}

.attachment-img-preview {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.attachment-file-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.attachment-name {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.attachment-remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  margin-left: 2px;
  transition: background 0.2s ease, color 0.2s ease;
}

.attachment-remove-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red-bright);
}

.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 4px;
}

.chat-attachment-img {
  max-width: 240px;
  max-height: 180px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-mid);
  cursor: pointer;
  object-fit: contain;
  background: var(--bg-input);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-attachment-img:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  text-decoration: none;
  transition: border-color 0.2s ease;
}

.chat-attachment-file:hover {
  border-color: var(--accent-bright);
}

/* ============================================================
   MINDMAP (ANALYSIS MODE) STYLES
   ============================================================ */

.master-mindmap-wrap {
  width: 100%;
  height: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 480px;
}

.master-mindmap-wrap:fullscreen,
.master-mindmap-wrap.mindmap-app-fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  padding: 16px;
  background: var(--bg-base);
  z-index: 1000;
}

.master-mindmap-wrap.mindmap-app-fullscreen {
  position: fixed;
  inset: 0;
}

.master-mindmap-wrap:fullscreen .svg-viewport,
.master-mindmap-wrap.mindmap-app-fullscreen .svg-viewport {
  border-radius: var(--radius-lg);
}

.svg-viewport {
  width: 100%;
  height: 100%;
  flex: 1;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-mid);
  background: var(--bg-surface);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

#mindmapSvg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  background-color: var(--bg-surface);
}

#mindmapSvg:active {
  cursor: grabbing;
}

/* Variable mapping for dark/light themes */
:root {
  --mindmap-grid-dot: rgba(30, 58, 138, 0.05);
  --mindmap-line: #bfdbfe;
  --mindmap-toggle-bg: #ffffff;
  --mindmap-toggle-border: #93c5fd;
  --mindmap-toggle-color: #1d4ed8;
  
  /* Standard node fallback */
  --node-bg: #ffffff;
  --node-border: #bfdbfe;
  --node-text-color: #1e3a8a;
}

body.theme-light {
  --mindmap-grid-dot: rgba(15, 23, 42, 0.06);
  --mindmap-line: #c7d2fe;
  --mindmap-toggle-bg: #ffffff;
  --mindmap-toggle-border: #a5b4fc;
  --mindmap-toggle-color: #4f46e5;
  
  --node-bg: #ffffff;
  --node-border: #cbd5e1;
  --node-text-color: #0f172a;
}

/* Node Specific Colors - Light and Dark Theme Harmonized */
/* Root node (Main project title) */
.mindmap-svg-node.node-root rect {
  fill: #eff6ff;
  stroke: #2563eb;
  stroke-width: 1.5px;
}
.mindmap-svg-node.node-root text {
  fill: #1d4ed8;
  font-weight: 600;
}

/* Goal Category */
.mindmap-svg-node.category-goal rect {
  fill: #ecfdf5;
  stroke: #10b981;
  stroke-width: 1.2px;
}
.mindmap-svg-node.category-goal text {
  fill: #065f46;
  font-weight: 600;
}

/* Problem Category */
.mindmap-svg-node.category-problem rect {
  fill: #fff5f5;
  stroke: #f43f5e;
  stroke-width: 1.2px;
}
.mindmap-svg-node.category-problem text {
  fill: #9f1239;
  font-weight: 600;
}

/* Module Node */
.mindmap-svg-node.node-module rect {
  fill: #f0fdfa;
  stroke: #5eead4;
  stroke-width: 1.2px;
}
.mindmap-svg-node.node-module text {
  fill: #0f766e;
}
.mindmap-svg-node.node-module:hover rect {
  stroke: #14b8a6;
  fill: #ccfbf1;
}

/* Task Node */
.mindmap-svg-node.node-task rect {
  fill: #f0fdf4;
  stroke: #86efac;
  stroke-width: 1px;
}
.mindmap-svg-node.node-task text {
  fill: #15803d;
}
.mindmap-svg-node.node-task:hover rect {
  stroke: #22c55e;
  fill: #dcfce7;
}

/* Rule Node */
.mindmap-svg-node.node-rule rect {
  fill: #f8fafc;
  stroke: #cbd5e1;
  stroke-dasharray: 3 3;
  stroke-width: 1px;
}
.mindmap-svg-node.node-rule text {
  fill: #475569;
}
.mindmap-svg-node.node-rule:hover rect {
  stroke: #94a3b8;
  fill: #f1f5f9;
}

/* Problem Node */
.mindmap-svg-node.node-problem rect {
  fill: #fff1f2;
  stroke: #fecdd3;
  stroke-width: 1.2px;
}
.mindmap-svg-node.node-problem text {
  fill: #be123c;
}
.mindmap-svg-node.node-problem:hover rect {
  stroke: #f43f5e;
  fill: #ffe4e6;
}

/* Cause Node */
.mindmap-svg-node.node-cause rect {
  fill: #fffbeb;
  stroke: #fde68a;
  stroke-width: 1px;
}
.mindmap-svg-node.node-cause text {
  fill: #b45309;
}
.mindmap-svg-node.node-cause:hover rect {
  stroke: #f59e0b;
  fill: #fef3c7;
}

/* Fix Hint Node */
.mindmap-svg-node.node-fix_hint rect {
  fill: #f8fafc;
  stroke: #cbd5e1;
  stroke-dasharray: 4 3;
  stroke-width: 1px;
}
.mindmap-svg-node.node-fix_hint text {
  fill: #64748b;
  font-style: italic;
}
.mindmap-svg-node.node-fix_hint:hover rect {
  stroke: #94a3b8;
  fill: #f1f5f9;
}
.mindmap-svg-node.node-fix_hint.challenge-active rect {
  fill: #dbeafe;
  stroke: #3b82f6;
  stroke-dasharray: none;
}
.mindmap-svg-node.node-fix_hint.challenge-active text {
  fill: #1d4ed8;
  font-style: normal;
}
.mindmap-svg-node.node-fix_hint.challenge-passed rect {
  fill: #dcfce7;
  stroke: #22c55e;
  stroke-dasharray: none;
}
.mindmap-svg-node.node-fix_hint.challenge-passed text {
  fill: #15803d;
  font-style: normal;
}

/* Empty Node */
.mindmap-svg-node.node-empty rect {
  fill: transparent;
  stroke: #cbd5e1;
  stroke-dasharray: 4 4;
}
.mindmap-svg-node.node-empty text {
  fill: #94a3b8;
  font-style: italic;
}

/* Dark theme overrides for svg nodes */
body:not(.theme-light) {
  --mindmap-grid-dot: rgba(255, 255, 255, 0.05);
  --mindmap-line: #1e3a8a;
  --mindmap-toggle-bg: #1e293b;
  --mindmap-toggle-border: #334155;
  --mindmap-toggle-color: #60a5fa;

  --node-bg: #1e293b;
  --node-border: #334155;
  --node-text-color: #e2e8f0;
}

body:not(.theme-light) .mindmap-svg-node.node-root rect {
  fill: #1e3a8a;
  stroke: #3b82f6;
}
body:not(.theme-light) .mindmap-svg-node.node-root text {
  fill: #eff6ff;
}

body:not(.theme-light) .mindmap-svg-node.category-goal rect {
  fill: #064e3b;
  stroke: #10b981;
}
body:not(.theme-light) .mindmap-svg-node.category-goal text {
  fill: #d1fae5;
}

body:not(.theme-light) .mindmap-svg-node.category-problem rect {
  fill: #4c0519;
  stroke: #f43f5e;
}
body:not(.theme-light) .mindmap-svg-node.category-problem text {
  fill: #ffe4e6;
}

body:not(.theme-light) .mindmap-svg-node.node-module rect {
  fill: #115e59;
  stroke: #14b8a6;
}
body:not(.theme-light) .mindmap-svg-node.node-module text {
  fill: #ccfbf1;
}
body:not(.theme-light) .mindmap-svg-node.node-module:hover rect {
  stroke: #2dd4bf;
  fill: #134e4a;
}

body:not(.theme-light) .mindmap-svg-node.node-task rect {
  fill: #166534;
  stroke: #22c55e;
}
body:not(.theme-light) .mindmap-svg-node.node-task text {
  fill: #dcfce7;
}
body:not(.theme-light) .mindmap-svg-node.node-task:hover rect {
  stroke: #4ade80;
  fill: #14532d;
}

body:not(.theme-light) .mindmap-svg-node.node-rule rect {
  fill: #1e293b;
  stroke: #475569;
}
body:not(.theme-light) .mindmap-svg-node.node-rule text {
  fill: #94a3b8;
}
body:not(.theme-light) .mindmap-svg-node.node-rule:hover rect {
  stroke: #64748b;
  fill: #0f172a;
}

body:not(.theme-light) .mindmap-svg-node.node-problem rect {
  fill: #881337;
  stroke: #f43f5e;
}
body:not(.theme-light) .mindmap-svg-node.node-problem text {
  fill: #ffe4e6;
}
body:not(.theme-light) .mindmap-svg-node.node-problem:hover rect {
  stroke: #fda4af;
  fill: #4c0519;
}

body:not(.theme-light) .mindmap-svg-node.node-cause rect {
  fill: #78350f;
  stroke: #f59e0b;
}
body:not(.theme-light) .mindmap-svg-node.node-cause text {
  fill: #fef3c7;
}
body:not(.theme-light) .mindmap-svg-node.node-cause:hover rect {
  stroke: #fcd34d;
  fill: #451a03;
}

body:not(.theme-light) .mindmap-svg-node.node-fix_hint rect {
  fill: #1e293b;
  stroke: #475569;
  stroke-dasharray: 4 3;
}
body:not(.theme-light) .mindmap-svg-node.node-fix_hint text {
  fill: #94a3b8;
  font-style: italic;
}
body:not(.theme-light) .mindmap-svg-node.node-fix_hint:hover rect {
  stroke: #64748b;
  fill: #0f172a;
}
body:not(.theme-light) .mindmap-svg-node.node-fix_hint.challenge-active rect {
  fill: #1d4ed8;
  stroke: #93c5fd;
  stroke-dasharray: none;
}
body:not(.theme-light) .mindmap-svg-node.node-fix_hint.challenge-active text {
  fill: #eff6ff;
  font-style: normal;
}
body:not(.theme-light) .mindmap-svg-node.node-fix_hint.challenge-passed rect {
  fill: #166534;
  stroke: #86efac;
  stroke-dasharray: none;
}
body:not(.theme-light) .mindmap-svg-node.node-fix_hint.challenge-passed text {
  fill: #f0fdf4;
  font-style: normal;
}

body:not(.theme-light) .mindmap-svg-node.node-empty rect {
  fill: transparent;
  stroke: #475569;
}
body:not(.theme-light) .mindmap-svg-node.node-empty text {
  fill: #64748b;
}

/* SVG Text elements font specification */
.mindmap-svg-node text {
  font-family: var(--font-body), sans-serif;
  user-select: none;
  pointer-events: none;
}

/* SVG link connection lines */
.mindmap-svg-link {
  transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

/* Hover effects for node group elements */
.mindmap-svg-node rect {
  transition: fill 0.2s ease, stroke 0.2s ease, stroke-width 0.2s ease, transform 0.2s ease;
  transform-origin: 50% 50%;
}
.mindmap-svg-node:hover rect {
  transform: scale(1.03);
}

/* SVG Expand/Collapse Toggle Group */
.node-toggle circle {
  transition: fill 0.2s ease, stroke 0.2s ease, r 0.2s ease;
}
.node-toggle:hover circle {
  fill: var(--accent-bright, #3b82f6);
  stroke: var(--accent-bright, #3b82f6);
}
.node-toggle:hover text {
  fill: #ffffff !important;
}

/* Floating controls styling */
.mindmap-controls {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

body:not(.theme-light) .mindmap-controls {
  background: rgba(15, 23, 42, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.mindmap-control-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-mid);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  outline: none;
}

.mindmap-control-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mindmap-control-btn.active {
  color: var(--accent-bright);
  border-color: var(--accent-bright);
  background: var(--accent-bg);
}

.mindmap-control-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-bright);
  transform: translateY(-1px);
}

.mindmap-control-btn:active {
  transform: translateY(0);
}

.mindmap-action-btn {
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent-dim);
  background: var(--accent-bg);
  color: var(--accent-bright);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 0 12px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  white-space: nowrap;
}

.mindmap-action-btn.secondary {
  border-color: var(--border-mid);
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.mindmap-action-btn:hover {
  border-color: var(--accent-bright);
  background: var(--accent-bg-hover);
  transform: translateY(-1px);
}

.mindmap-action-btn.secondary:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.mindmap-action-btn:active {
  transform: translateY(0);
}

/* Absolute Floating Title bar inside SVG viewport */
.mindmap-title-bar {
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 10;
  pointer-events: none;
}

.mindmap-title-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 5px 12px;
  border-radius: 9999px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-mid);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Floating Detail Panel */
.mindmap-detail-panel {
  position: absolute;
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: 320px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  box-shadow: -2px 4px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
  animation: slide-in-right 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

body.theme-light .mindmap-detail-panel {
  background: #ffffff;
  box-shadow: -2px 4px 20px rgba(0, 0, 0, 0.08);
}

.detail-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-header strong {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
}

.detail-close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.2s ease, color 0.2s ease;
}

.detail-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.detail-body {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.detail-val {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.detail-val.text-block {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

body.theme-light .detail-val.text-block {
  background: #f8fafc;
}

/* Custom Tag lists in detail panel */
.detail-alias-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-dim);
  color: var(--accent-bright);
  border-radius: 4px;
  margin-right: 4px;
  margin-bottom: 4px;
}

body.theme-light .detail-alias-tag {
  background: rgba(2, 132, 199, 0.06);
  border: 1px solid rgba(2, 132, 199, 0.2);
  color: #0284c7;
}

.detail-evidence-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px dashed var(--border-mid);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.detail-evidence-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.evidence-source-tag {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: bold;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.evidence-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

@keyframes slide-in-right {
  from {
    transform: translateX(340px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}


/* ============================================================
   ANALYSIS DASHBOARD STYLES
   ============================================================ */

.analysis-dashboard {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  height: 100%;
  overflow-y: auto;
}

.observation-mini-map {
  position: fixed;
  right: 24px;
  bottom: var(--observation-float-bottom, 156px);
  width: 210px;
  z-index: 38;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  background: rgba(17, 24, 39, 0.92);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}

body.theme-light .observation-mini-map {
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.14);
}

.observation-mini-map.expanded {
  width: 300px;
  max-height: min(340px, calc(100vh - var(--observation-float-bottom, 156px) - 72px));
  display: flex;
  flex-direction: column;
}

.observation-mini-head {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}

.observation-mini-head span {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-bright);
  white-space: nowrap;
}

.observation-mini-head small {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.observation-mini-body {
  border-top: 1px solid var(--border-subtle);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

.observation-mini-preview {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  padding: 10px;
  min-height: 92px;
}

.observation-mini-preview strong {
  display: block;
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.35;
  margin-bottom: 8px;
  word-break: break-word;
}

.observation-mini-branch {
  border-left: 2px solid var(--accent-dim);
  padding: 7px 8px;
  margin-top: 6px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
}

.observation-mini-branch span {
  display: block;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.35;
  word-break: break-word;
}

.observation-mini-branch small,
.observation-mini-empty {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.observation-mini-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.observation-mini-actions button {
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 6px 10px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.observation-mini-actions button:hover {
  color: var(--accent-bright);
  border-color: var(--accent-dim);
  background: var(--accent-bg);
}

@media (max-width: 760px) {
  .observation-mini-map {
    right: 14px;
    width: min(240px, calc(100vw - 28px));
  }

  .observation-mini-map.expanded {
    width: min(320px, calc(100vw - 28px));
  }
}

.tutor-guidance-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.tutor-guidance-card.thinking {
  background: var(--bg-surface);
}

.tg-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.tg-card-header .response-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border-mid);
}

.tg-card-header .response-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tg-card-header .response-author {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
}

.tg-card-header .response-time {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-left: auto;
}

.tg-card-body {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.tg-card-body .placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.dashboard-history-feed {
  margin-top: 8px;
  animation: slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.history-details {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
}

.history-summary {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  background: var(--bg-raised);
  user-select: none;
  outline: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.history-summary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.history-list {
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-input);
}

.dashboard-history-item {
  border-bottom: 1px dashed var(--border-mid);
  transition: background 0.2s ease;
}

.dashboard-history-item:last-child {
  border-bottom: none;
}

.dashboard-history-item:hover {
  background: rgba(255, 255, 255, 0.01);
}

.observation-mindmap-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.72);
}

.observation-mindmap-card.compact {
  margin-top: 10px;
  padding: 12px;
}

.observation-mindmap-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.observation-mindmap-kicker {
  color: var(--teal-bright);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0;
}

.observation-mindmap-head strong {
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.35;
}

.observation-mindmap-head p {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
}

.observation-inline-map {
  width: 100%;
  min-height: 340px;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.observation-inline-svg {
  display: block;
  width: 100%;
  min-width: 760px;
  height: auto;
  min-height: 340px;
  background: var(--bg-surface);
}

.observation-inline-map .mindmap-svg-node {
  cursor: pointer;
}

.observation-inline-detail {
  padding: 12px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}

.observation-inline-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.observation-inline-detail-head strong {
  color: var(--text-primary);
  font-size: 13px;
}

.observation-inline-detail-head span {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.observation-inline-detail p {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.observation-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.observation-detail-tags span {
  padding: 2px 6px;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  color: var(--accent-bright);
  background: var(--accent-bg);
  font-size: 11px;
}

.observation-detail-evidence {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.observation-detail-evidence div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border-mid);
}

.observation-detail-evidence div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.observation-detail-evidence b {
  color: var(--accent-bright);
  font-family: var(--font-mono);
  font-size: 10px;
}

.observation-detail-evidence span {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.observation-mindmap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.observation-section {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: rgba(2, 6, 23, 0.32);
}

.observation-section h4 {
  margin-bottom: 8px;
  color: var(--accent-bright);
  font-size: 12px;
  font-weight: 700;
}

.observation-section.problem h4 { color: var(--red-bright); }
.observation-section.evidence h4 { color: var(--indigo-bright); }
.observation-section.gap h4 { color: var(--teal-bright); }

.observation-node-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.observation-node {
  padding: 8px;
  border-left: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
}

.observation-node strong {
  display: block;
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.observation-node p {
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.observation-empty {
  padding: 12px;
  color: var(--text-secondary);
  border: 1px dashed var(--border-mid);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.observation-mindmap-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

@media (max-width: 760px) {
  .observation-mindmap-grid {
    grid-template-columns: 1fr;
  }
}

/* Selected Mindmap Node and Highlighted Editor Lines */
.mindmap-svg-node.selected rect {
  stroke: #ef4444 !important;
  stroke-width: 2px !important;
  stroke-dasharray: none !important;
  fill: rgba(239, 68, 68, 0.05) !important;
}

.mindmap-svg-node.selected text {
  fill: #ef4444 !important;
  font-weight: 600;
}

body:not(.theme-light) .mindmap-svg-node.selected rect {
  fill: rgba(239, 68, 68, 0.15) !important;
}

.gutter-line-highlight {
  color: #ef4444 !important;
  font-weight: bold;
}

.code-decoration-layer {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
  z-index: 0;
}

.editor-line-decoration {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(239, 68, 68, 0.12);
  border-left: 3px solid #ef4444;
  pointer-events: none;
}

body:not(.theme-light) .editor-line-decoration {
  background: rgba(239, 68, 68, 0.22);
}
