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

:root {
  --bg: #1a1520;
  --bg-surface: #231e2e;
  --bg-hover: #2d2640;
  --border: #3d3350;
  --accent: #8B5CF6;
  --accent-hover: #7C3AED;
  --accent-gradient: linear-gradient(135deg, #8B5CF6, #EC4899, #F97316);
  --text: #e8e0f0;
  --text-muted: #9b8fb0;
  --text-dim: #6b5f80;
  --user-bubble: #2a2040;
  --assistant-bubble: #231e2e;
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
  --radius: 12px;
  --sidebar-width: 280px;
  --mode-study: #3a7d52;
  --mode-support: #8a6d1e;
  --mode-interview: #7d3030;
  --bg-primary: #1a1520;
  --bg-secondary: #231e2e;
  --bg-tertiary: #2d2640;
  --text-primary: #e8e0f0;
  --text-secondary: #9b8fb0;
  --border-color: #3d3350;
  --border-subtle: #2d2640;
  --link-color: #c084fc;
  --accent-color: #8B5CF6;
}

body.light-theme {
  --bg: #faf8fc;
  --bg-surface: #ffffff;
  --bg-hover: #f3eef8;
  --border: #e0d5ec;
  --accent: #7C3AED;
  --accent-hover: #6D28D9;
  --accent-gradient: linear-gradient(135deg, #7C3AED, #DB2777, #EA580C);
  --text: #2d1f42;
  --text-muted: #6b5a80;
  --text-dim: #9b8fb0;
  --user-bubble: #f0e8f8;
  --assistant-bubble: #ffffff;
  --success: #1a7f37;
  --error: #cf222e;
  --warning: #9a6700;
  --mode-study: #1a7f37;
  --mode-support: #9a6700;
  --mode-interview: #cf222e;
  --bg-primary: #faf8fc;
  --bg-secondary: #f3eef8;
  --bg-tertiary: #ebe4f3;
  --text-primary: #2d1f42;
  --text-secondary: #6b5a80;
  --border-color: #e0d5ec;
  --border-subtle: #ebe4f3;
  --link-color: #7C3AED;
  --accent-color: #7C3AED;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* Placeholder visibility */
input::placeholder, textarea::placeholder {
  color: var(--text-dim);
  opacity: 1;
}

/* Layout */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar — collapsible on all screen sizes, resizable via drag handle */
.sidebar {
  width: var(--sidebar-width);
  min-width: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.25s ease;
  overflow: hidden;
  position: relative;
  /* Collapsed by default on all screens; initApp adds .open on desktop */
}
.sidebar.resizing {
  transition: none;
}
body:has(.sidebar.resizing) {
  user-select: none;
  cursor: col-resize;
}

/* Resize drag handle on right edge */
.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.active {
  background: var(--accent);
  opacity: 0.5;
}

/* Desktop: sidebar collapses in-place (no absolute positioning) */
@media (min-width: 641px) {
  .sidebar {
    position: relative;
    width: 0;
    border-right-width: 0;
  }

  .sidebar.open {
    width: var(--sidebar-width);
    border-right-width: 1px;
  }
}

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

.sidebar-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}
.sidebar-close-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}
.logo .logo-text {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}
.logo-icon svg {
  width: 100%;
  height: 100%;
}
.logo-svg {
  display: inline-block;
  vertical-align: middle;
}
.login-subtitle {
  display: block;
  font-size: 0.85em;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: none;
  margin-top: 4px;
  text-align: center;
  max-width: 320px;
  white-space: normal;
  word-wrap: break-word;
}

.sidebar-status-text {
  font-size: 12px;
  color: var(--link-color);
  font-weight: 500;
}

.sidebar-search {
  padding: 6px 12px;
}
.sidebar-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  box-sizing: border-box;
  font-family: inherit;
}
.sidebar-search input:focus {
  outline: none;
  border-color: var(--accent);
}
.sidebar-search input::placeholder {
  color: var(--text-dim);
}

.sidebar-modules {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
}

.loading-sidebar {
  color: var(--text-muted);
  font-size: 13px;
  padding: 16px;
  text-align: center;
}

/* Course-level toggle (top of sidebar hierarchy) */
.course-group {
  margin-bottom: 2px;
}

.course-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  user-select: none;
  transition: background 0.1s, color 0.1s;
}

.course-header:hover {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.course-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-arrow {
  font-size: 9px;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.course-group.open .course-arrow {
  transform: rotate(90deg);
}

.course-body {
  display: none;
  padding-left: 8px;
  margin-bottom: 4px;
}

.course-group.open .course-body {
  display: block;
}

.module-group {
  margin-bottom: 4px;
}

.module-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  user-select: none;
  transition: background 0.1s;
}

.module-header:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.module-lesson-count {
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-hover);
  color: var(--text-dim);
  border-radius: 10px;
  padding: 1px 7px;
  letter-spacing: 0;
  text-transform: none;
}

.module-arrow {
  margin-left: auto;
  transition: transform 0.2s;
  font-size: 10px;
}

.module-group.open .module-arrow {
  transform: rotate(90deg);
}

.lesson-list {
  display: none;
  padding-left: 10px;
  margin-bottom: 4px;
}

.module-group.open .lesson-list {
  display: block;
}

.lesson-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
  min-width: 0;
}

.lesson-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.lesson-item.active {
  background: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(236,72,153,0.15), rgba(249,115,22,0.1));
  border-left: 3px solid;
  border-image: var(--accent-gradient) 1;
  color: var(--text);
}
.lesson-item.active .lesson-type-icon,
.lesson-item.active .lesson-name {
  opacity: 1;
  color: var(--text);
}
body.light-theme .lesson-item.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.12), rgba(219,39,119,0.08), rgba(234,88,12,0.05));
  border-left: 3px solid;
  border-image: linear-gradient(135deg, #7C3AED, #DB2777, #EA580C) 1;
}

.lesson-type-icon {
  font-size: 11px;
  opacity: 0.7;
  flex-shrink: 0;
}

.lesson-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.lesson-check {
  border: 1px solid var(--text-dim);
  border-radius: 50%;
  color: var(--text-dim);
  font-size: 10px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.lesson-check.done {
  background: var(--success);
  border-color: var(--success);
  color: #000;
  font-weight: 700;
}

.lesson-item.completed .lesson-name {
  opacity: 0.45;
  text-decoration: line-through;
}

/* Visited (opened) lessons are brighter; unvisited are dimmer */
.lesson-item.visited:not(.completed) .lesson-name {
  color: var(--text);
}
.lesson-item:not(.visited):not(.completed):not(.active) .lesson-name {
  color: var(--text-muted);
}

.lesson-reading-time {
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
  margin-left: auto;
  padding-left: 6px;
  white-space: nowrap;
}

/* Chat area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.sidebar-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-family: inherit;
  flex-shrink: 0;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
  white-space: nowrap;
}

.sidebar-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

.sidebar-toggle-label {
  font-size: 13px;
  font-weight: 500;
}

.chat-header-info {
  display: none;  /* hidden by default when sidebar shows branding */
  align-items: center;
  gap: 8px;
}

.header-logo-icon {
  font-size: 18px;
}

.chat-header-info h1 {
  font-size: 17px;
  font-weight: 700;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.status-dot.error {
  background: var(--error);
}

.status-text {
  font-size: 13px;
  color: var(--text-muted);
}

/* Tab bar */
.tab-bar {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 8px;
  overflow: hidden;
}

.tab-list {
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  scroll-behavior: smooth;
  flex: 1;
  padding: 4px 0;
  /* Hide scrollbar but allow scrolling */
  scrollbar-width: none;
}

.tab-list::-webkit-scrollbar {
  display: none;
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 180px;
  transition: background 0.1s, color 0.1s, border-color 0.1s, margin 0.12s ease;
  user-select: none;
}

.tab-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.tab-item.active {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

.tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.tab-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: color 0.1s, background 0.1s;
}

.tab-close:hover {
  color: var(--error);
  background: rgba(248, 113, 113, 0.15);
}

.tab-add-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  padding: 3px 10px;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 6px;
  white-space: nowrap;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}

.tab-add-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Pane-visibility dot — which pane is displaying this tab (split mode) */
.tab-pane-dot {
  font-size: 6px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.8;
}
.tab-pane-dot.left  { color: var(--accent); }
.tab-pane-dot.right { color: #f0a060; }

/* Context mark — EMA will respond in this tab's lesson */
.tab-ctx-mark {
  font-size: 11px;
  color: var(--accent);
  opacity: 0.7;
  flex-shrink: 0;
  margin-left: -2px;
}
.tab-item.tab-context {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

/* Drag-and-drop tab reordering */
.tab-item.dragging {
  opacity: 0.35;
  cursor: grabbing;
}

.tab-item.drop-before {
  border-left: 2px solid var(--accent);
}

.tab-item.drop-after {
  border-right: 2px solid var(--accent);
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome {
  text-align: center;
  max-width: 520px;
  margin: auto;
  padding: 32px 16px;
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.welcome h2 {
  font-size: 24px;
  margin-bottom: 10px;
}

.welcome p {
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.7;
}

.welcome-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.suggestion {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.suggestion:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

/* Message bubbles */
.message {
  display: flex;
  gap: 12px;
  max-width: 820px;
  width: 100%;
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.user .avatar {
  background: var(--accent);
  color: #fff;
}

.message.assistant .avatar {
  background: transparent;
  padding: 0;
  overflow: hidden;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  max-width: calc(100% - 44px);
  word-break: break-word;
}

.message.user .bubble {
  background: var(--user-bubble);
}

/* Mode-colored left border on messages */
.message.mode-study .bubble {
  border-left: 3px solid var(--mode-study);
  background: color-mix(in srgb, var(--mode-study) 8%, var(--assistant-bubble));
}
.message.user.mode-study .bubble {
  background: color-mix(in srgb, var(--mode-study) 8%, var(--user-bubble));
}

.message.mode-support .bubble {
  border-left: 3px solid var(--mode-support);
  background: color-mix(in srgb, var(--mode-support) 8%, var(--assistant-bubble));
}
.message.user.mode-support .bubble {
  background: color-mix(in srgb, var(--mode-support) 8%, var(--user-bubble));
}

.message.mode-interview .bubble {
  border-left: 3px solid var(--mode-interview);
  background: color-mix(in srgb, var(--mode-interview) 8%, var(--assistant-bubble));
}
.message.user.mode-interview .bubble {
  background: color-mix(in srgb, var(--mode-interview) 8%, var(--user-bubble));
}

/* Streaming cursor on the active response */
.bubble.streaming::after {
  content: "▊";
  color: var(--accent);
  animation: blink-cursor 1s step-end infinite;
  font-size: 0.85em;
  margin-left: 2px;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Error state bubble */
.bubble.error-bubble {
  color: var(--error);
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.05);
}

/* Markdown content inside bubbles */
.bubble p { margin-bottom: 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3 { margin: 12px 0 6px; }
.bubble ul, .bubble ol { padding-left: 20px; margin-bottom: 10px; }
.bubble li { margin-bottom: 4px; }
.bubble code {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 13px;
  color: #c4b5fd;
}
.bubble pre {
  background: #151020;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  margin: 10px 0;
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  padding: 3px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.copy-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}
.bubble pre code {
  background: none;
  border: none;
  padding: 0;
  color: #d4c8f0;
}
.bubble a { color: var(--accent); text-decoration: none; }
.bubble a:hover { text-decoration: underline; }
.bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-muted);
  margin: 8px 0;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 20px;
  padding: 4px 0;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Input area */
.input-area {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
}

textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 160px;
  line-height: 1.6;
}

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

.btn-send {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}

.btn-send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.btn-stuck {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  padding: 4px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-stuck:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
}

.btn-stuck:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Mode guide modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 780px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-modes {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.modal-mode-card {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-mode-name {
  font-size: 15px;
  font-weight: 700;
}

.mode-study-text  { color: var(--mode-study); }
.mode-support-text { color: var(--mode-support); }
.mode-interview-text { color: var(--mode-interview); }

.modal-mode-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
}

.modal-best-for {
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  line-height: 1.5;
}

.best-for-label {
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 4px;
}

.btn-got-it {
  display: block;
  margin: 0 auto;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 32px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-got-it:hover {
  background: var(--accent-hover);
}

@media (max-width: 600px) {
  .modal-modes {
    flex-direction: column;
  }
  .modal-card {
    padding: 20px 16px;
  }
}

/* Modal course/lesson list */
.modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0 20px;
}

.modal-modules-section {
  margin-bottom: 24px;
}

.modal-modules-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}

.modal-modules-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 14px;
  line-height: 1.5;
}

.modal-module-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
  transition: background 0.15s;
}

.modal-module-header:hover {
  background: var(--bg-hover);
}

.modal-module-arrow {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.modal-module-group.open .modal-module-arrow {
  transform: rotate(90deg);
}

.modal-lesson-list {
  display: none;
  flex-direction: column;
  padding: 4px 0 4px 10px;
}

.modal-module-group.open .modal-lesson-list {
  display: flex;
}

.modal-lesson-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
}

.modal-lesson-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.modal-lesson-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.modal-lesson-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-explain-lesson {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  padding: 2px 8px;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s, opacity 0.15s;
}

.modal-lesson-item:hover .btn-explain-lesson {
  opacity: 1;
}

.btn-explain-lesson:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Feedback button in header */
.btn-feedback {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-right: 8px;
}
.btn-feedback:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Feedback modal */
.feedback-modal-card {
  max-width: 480px;
}
.feedback-type-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.feedback-type-btn {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 0;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.feedback-type-btn.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--bg-hover);
}
.feedback-type-btn:hover:not(.active) {
  border-color: var(--text-dim);
  color: var(--text);
}
.feedback-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  padding: 10px 12px;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.feedback-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.feedback-char-counter {
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
  margin: 4px 0 12px;
}
.feedback-error {
  color: #e06c75;
  font-size: 13px;
  margin-bottom: 10px;
}
.feedback-success {
  color: #98c379;
  font-size: 13px;
  text-align: center;
  margin-bottom: 10px;
}

/* Screenshot upload row */
.feedback-screenshot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.btn-screenshot {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  padding: 5px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn-screenshot:hover {
  color: var(--text);
  border-color: var(--accent);
}
.feedback-screenshot-name {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.feedback-screenshot-clear {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.feedback-screenshot-clear:hover {
  color: #e06c75;
}

/* Background knowledge chips (onboarding) */
.bg-chips-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 4px 0;
}

.bg-chip {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  padding: 5px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.bg-chip:hover {
  color: var(--text);
  border-color: var(--accent);
}

.bg-chip.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.15);
}

/* ? button next to mode pills */
.btn-mode-guide {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.btn-mode-guide:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Mode pill hover tooltip */
.mode-tooltip {
  position: fixed;
  z-index: 999;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  max-width: 240px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.mode-tooltip.visible {
  opacity: 1;
}

.mode-tooltip-title {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 4px;
}

.mode-tooltip-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Topic chips */
.topic-chips-prompt {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.topic-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-chip {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  padding: 5px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.topic-chip:hover:not(.frozen) {
  border-color: var(--accent);
  color: var(--text);
}

.topic-chip.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(139, 92, 246, 0.15);
}

.topic-chip.frozen {
  opacity: 0.45;
  cursor: default;
}

/* Mode selector pills */
.mode-selector {
  display: flex;
  gap: 6px;
  align-items: center;
}

.mode-pill {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  padding: 4px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.mode-pill[data-mode="study"].active {
  border-color: var(--mode-study);
  color: var(--text);
  background: color-mix(in srgb, var(--mode-study) 15%, transparent);
}

.mode-pill[data-mode="support"].active {
  border-color: var(--mode-support);
  color: var(--text);
  background: color-mix(in srgb, var(--mode-support) 15%, transparent);
}

.mode-pill[data-mode="interview"].active {
  border-color: var(--mode-interview);
  color: var(--text);
  background: color-mix(in srgb, var(--mode-interview) 15%, transparent);
}

.mode-pill[data-mode="study"]:hover:not(.active) {
  color: var(--text);
  border-color: var(--mode-study);
}

.mode-pill[data-mode="support"]:hover:not(.active) {
  color: var(--text);
  border-color: var(--mode-support);
}

.mode-pill[data-mode="interview"]:hover:not(.active) {
  color: var(--text);
  border-color: var(--mode-interview);
}

/* Character counter */
.char-counter {
  font-size: 11px;
  color: transparent;
  transition: color 0.2s;
}

.char-counter.warn {
  color: var(--warning);
}

.char-counter.danger {
  color: var(--error);
}

.quiz-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.quiz-chip {
  display: inline-block;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  padding: 4px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.quiz-chip:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Answer chips — numbered options from EMA responses */
.answer-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.answer-chip {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  padding: 5px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  text-align: left;
}

.answer-chip:hover:not(.frozen) {
  border-color: var(--accent);
  color: var(--text);
}

.answer-chip.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(139, 92, 246, 0.15);
}

.answer-chip.frozen {
  opacity: 0.45;
  cursor: default;
}

.input-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  text-align: center;
}

/* Entry chips (first-time and returning welcome) */
.entry-chips-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: auto;
  padding: 40px 16px;
  max-width: 480px;
  width: 100%;
}

.entry-chips-prompt {
  color: var(--text-muted);
  font-size: 15px;
  text-align: center;
}

.entry-chip-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.entry-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 12px 20px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}

.entry-chip:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

/* Lesson welcome — title line above chips */
.lesson-welcome-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}

/* Hint line below chips */
.entry-chips-hint {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  margin-top: 4px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(236, 72, 153, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 50%, rgba(249, 115, 22, 0.04) 0%, transparent 60%);
  animation: loginAmbient 20s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes loginAmbient {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-3%, -3%) rotate(3deg); }
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(139, 92, 246, 0.15);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 24px;
  color: var(--text);
  flex-wrap: wrap;
}

.login-logo .logo-icon {
  position: relative;
}
.login-logo .logo-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 140px;
  height: 140px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(139, 92, 246, 0.2) 0%, transparent 70%);
  border-radius: 50%;
  z-index: -1;
}

.login-logo .logo-text {
  font-size: 1.8em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.login-field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
}

.login-field input:focus {
  border-color: var(--accent);
}

.login-error {
  font-size: 13px;
  color: var(--error);
  min-height: 18px;
}

.btn-login {
  background: var(--accent-gradient);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  padding: 11px;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
  margin-top: 4px;
}

.btn-login:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-login:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.login-links {
  text-align: right;
  margin-top: 4px;
}

.forgot-link {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.forgot-link:hover {
  text-decoration: underline;
}

.login-success {
  font-size: 13px;
  color: var(--success);
  min-height: 18px;
  margin-bottom: 4px;
}

.btn-change-pw {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: inherit;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-change-pw:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Google Sign-In divider + button */
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.g_id_signin {
  display: flex;
  justify-content: center;
}

/* Header user / logout */
.header-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-username {
  font-size: 13px;
  color: var(--text-muted);
}

.app-version {
  font-size: 11px;
  color: var(--text-dim);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
}
.app-version:empty {
  display: none;
}

.btn-logout {
  display: flex;
  align-items: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn-logout:hover {
  color: #e57373;
  border-color: #e57373;
  background: rgba(229, 115, 115, 0.08);
}

/* Responsive — mobile sidebar overlays content */
@media (max-width: 640px) {
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    width: var(--sidebar-width) !important;
    transform: translateX(-100%);
    border-right-width: 1px !important;
  }

  .sidebar.open {
    transform: translateX(0);
    width: var(--sidebar-width) !important;
  }

  .sidebar-toggle-label {
    display: none;
  }
}

/* ── Two-pane layout ─────────────────────────────────────────────────────── */

.pane-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

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

/* ── Layout modes ─────────────────────────────────────────────────────── */

/* Default: right pane hidden (fallback before layout class applied) */
#paneRight { display: none; }

/* Content-only: left pane full, right hidden */
.pane-container.layout-content #paneLeft  { display: flex; flex: 1; }
.pane-container.layout-content #paneRight { display: none; }
.pane-container.layout-content .pane-divider { display: none; }

/* Split: both panes side by side */
.pane-container.layout-split #paneLeft  { display: flex; flex: 1 1 50%; }
.pane-container.layout-split #paneRight { display: flex; flex: 1 1 50%; border-left: 1px solid var(--border); }
.pane-container.layout-split .pane-divider { display: block; }

/* Chat-only: right pane full, left hidden */
.pane-container.layout-chat #paneLeft  { display: none; }
.pane-container.layout-chat #paneRight { display: flex; flex: 1; }
.pane-container.layout-chat .pane-divider { display: none; }

/* Resizable divider */
.pane-divider {
  width: 4px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  display: none;
  transition: background 0.15s;
}
.pane-divider:hover, .pane-divider.dragging { background: var(--accent); }

/* Per-pane tab bar */
.pane-tab-bar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  transition: background 0.1s, border-color 0.1s;
}
.pane-tab-bar.drag-over {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  border-bottom-color: var(--accent);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

/* Split toggle button */
.pane-split-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.pane-split-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}
.pane-split-toggle .toggle-label {
  font-weight: 500;
}
.pane-split-toggle.active {
  border-color: var(--accent);
  color: var(--text);
}

/* Pane layout toggle (content left/right flip) */
.pane-layout-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  transition: color 0.1s, border-color 0.1s;
  flex-shrink: 0;
}
.pane-layout-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* Tab move button */
.tab-move-btn {
  background: none;
  border: none;
  color: var(--text-dim, var(--text-muted));
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
}
.tab-item:hover .tab-move-btn { opacity: 1; }
.tab-move-btn:hover { color: var(--accent); }

/* Empty pane placeholder */
.pane-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Lesson content viewer ───────────────────────────────────────────────── */

.lesson-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  max-width: 900px;
  margin: 16px auto;
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.lesson-content-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.lesson-content-type {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 24px;
  background: var(--bg-hover);
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.lesson-content-body {
  line-height: 1.7;
  color: var(--text);
}

.lesson-content-body img { max-width: 100%; height: auto; border-radius: 6px; }
.lesson-content-body p { margin: 0 0 1em; }
.lesson-content-body h1,
.lesson-content-body h2,
.lesson-content-body h3 { margin: 1.4em 0 0.5em; font-weight: 600; }
.lesson-content-body h1 { font-size: 1.4em; }
.lesson-content-body h2 { font-size: 1.2em; }
.lesson-content-body h3 { font-size: 1.05em; }
.lesson-content-body code {
  font-family: var(--font-mono, monospace);
  font-size: 0.875em;
  background: var(--bg-code, var(--bg-hover));
  padding: 1px 5px;
  border-radius: 4px;
}
.lesson-content-body pre {
  background: var(--bg-code, #1a1525);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 1em;
  position: relative;
}
.lesson-content-body pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
}
.lesson-content-body ul,
.lesson-content-body ol { margin: 0 0 1em 1.4em; }
.lesson-content-body li { margin-bottom: 0.25em; }
.lesson-content-body a { color: var(--accent); text-decoration: none; }
.lesson-content-body a:hover { text-decoration: underline; }
.lesson-content-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 0 0 1em;
  padding: 8px 16px;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-radius: 0 6px 6px 0;
}
.lesson-content-body table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1em;
  font-size: 0.9em;
}
.lesson-content-body th,
.lesson-content-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.lesson-content-body th { background: var(--bg-hover); font-weight: 600; }

.lesson-content-loading,
.lesson-content-error {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 48px 20px;
}
.lesson-content-error { color: #e57373; }

.slides-open-btn {
  display: inline-block;
  padding: 10px 22px;
  background: var(--accent, #8B5CF6);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  margin: 1.2em 0;
  transition: opacity 0.15s;
}
.slides-open-btn:hover { opacity: 0.8; }

/* Mobile: single pane only */
@media (max-width: 640px) {
  .pane-container.layout-split #paneRight { display: none !important; }
  .pane-container.layout-chat #paneLeft { display: flex !important; }
  .pane-container.layout-chat #paneRight { display: none !important; }
  #paneDivider,
  .pane-split-toggle,
  .pane-layout-toggle { display: none !important; }
  .lesson-content { padding: 16px !important; }
  .modal-card { max-width: 90vw !important; }
}

/* Hide progress bars when parent toggle is collapsed */
.course-group:not(.open) .course-progress {
  display: none;
}
.module-group:not(.open) .module-progress {
  display: none;
}

/* Mastery dot indicators on lessons (legacy — replaced by progress rings) */
.mastery-dot {
  font-size: 10px;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

/* Lesson progress ring */
.lesson-ring {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  background: conic-gradient(
    var(--accent) calc(var(--progress) * 3.6deg),
    var(--border) 0
  );
  vertical-align: middle;
}
.lesson-ring.not-started {
  background: none;
  border: 2px solid var(--text-dim);
}
.lesson-ring.completed {
  background: var(--success);
}

/* Light theme */
body.light-theme .lesson-ring.not-started {
  border-color: #c8b8d8;
}

/* Progress bar track (replaces segmented bar) */
.progress-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* Segmented progress bar — green/yellow/red segments */
.segmented-bar {
  display: flex;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  overflow: hidden;
}
.seg-mastered {
  background: var(--success, #4ade80);
  height: 100%;
  transition: width 0.3s ease;
}
.seg-partial {
  background: #facc15;
  height: 100%;
  transition: width 0.3s ease;
}
/* .seg-struggling removed — no longer used */

/* Per-course progress bar */
.course-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.course-progress-text {
  white-space: nowrap;
}
.course-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}
.course-progress-fill,
.module-progress-fill {
  /* Legacy — kept for backward compat; segmented bar renders inside the bar div */
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Per-module progress bar */
.module-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 12px 6px;
  font-size: 10px;
  color: var(--text-dim);
}
.module-progress-text {
  white-space: nowrap;
  min-width: 28px;
}
.module-progress-bar {
  flex: 1;
  height: 3px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}
.module-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Search results (backend content matches) */
.search-results {
  border-top: 1px solid var(--border);
  padding: 8px 0;
  max-height: 300px;
  overflow-y: auto;
}
.search-results-header {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 12px 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.search-result-item {
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 4px;
  margin: 0 4px;
}
.search-result-item:hover {
  background: var(--bg-hover);
}
.search-result-lesson {
  font-size: 13px;
  color: var(--text);
}
.search-result-module {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 1px;
}
.search-result-snippet {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── Chat error with retry ────────────────────────────────────────────────── */

.chat-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 100, 100, 0.08);
  border: 1px solid rgba(255, 100, 100, 0.15);
  border-radius: 8px;
  margin: 8px 0;
  font-size: 13px;
  color: var(--text-muted);
}
.chat-error-icon {
  flex-shrink: 0;
}
.chat-error-text {
  flex: 1;
}
.chat-error-retry {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  padding: 4px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.chat-error-retry:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Inline PDF viewer ────────────────────────────────────────────────────── */

.pdf-viewer-container {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.pdf-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-surface);
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.pdf-download-btn {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}
.pdf-download-btn:hover {
  text-decoration: underline;
}
.pdf-viewer-frame {
  width: 100%;
  height: 500px;
  border: none;
  background: var(--bg);
}

@media (max-width: 640px) {
  .pdf-viewer-frame { height: 350px; }
}

/* Onboarding explanation text */
.onboarding-explain {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
  max-width: 380px;
}

/* Calibration badge (shown after profile save) */
.calibration-badge {
  text-align: center;
  color: var(--success);
  font-size: 13px;
  padding: 10px 16px;
  margin: 8px auto;
  max-width: 320px;
  background: color-mix(in srgb, var(--success) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
  border-radius: 8px;
  transition: opacity 0.8s;
}
.calibration-badge.fade-out {
  opacity: 0;
}

/* Calibration indicator next to mode pills */
.calibration-indicator {
  font-size: 11px;
  color: var(--success);
  padding: 3px 8px;
  border: 1px solid color-mix(in srgb, var(--success) 30%, transparent);
  border-radius: 12px;
  cursor: default;
  white-space: nowrap;
}

/* Prev/next lesson navigation */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  padding: 16px 0;
  margin-top: 24px;
  border-top: 1px solid var(--border);
  gap: 12px;
}
.lesson-nav-prev, .lesson-nav-next {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  padding: 6px 0;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lesson-nav-prev:hover, .lesson-nav-next:hover {
  text-decoration: underline;
}
.lesson-nav-next {
  margin-left: auto;
  text-align: right;
}

/* ── File link cards (download links in lesson content) ────────────────────── */
.file-link-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
  margin: 4px 0;
}
.file-link-card:hover {
  border-color: var(--accent);
}
.file-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.file-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.file-name {
  font-size: 13px;
  color: var(--text);
}
.file-ext {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.file-download-icon {
  color: var(--text-muted);
  margin-left: auto;
}
.img-placeholder {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  background: var(--bg-hover);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Accessibility: respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Knowledge tags (personalized per student) ───────────────────────────── */

.knowledge-tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.knowledge-tag {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.15s;
  font-family: inherit;
  background: none;
}

.tag-green {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.25);
  color: #4ade80;
}
.tag-yellow {
  background: rgba(250, 204, 21, 0.1);
  border-color: rgba(250, 204, 21, 0.25);
  color: #facc15;
}
/* .tag-red removed — red mastery level no longer used */
.tag-gray {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  color: var(--text-muted);
}

.knowledge-tag:hover {
  filter: brightness(1.2);
}

.knowledge-tag.active {
  filter: brightness(1.3);
  box-shadow: 0 0 8px currentColor;
}

/* ── Theme toggle button ───────────────────────────────────────────────────── */
.btn-theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 1.1em;
  margin-right: 8px;
  line-height: 1;
  transition: border-color 0.15s, background 0.15s;
}
.btn-theme-toggle:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

/* ── Light theme overrides for hardcoded colors ────────────────────────────── */
body.light-theme .bubble code {
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.2);
  color: #7C3AED;
}
body.light-theme .bubble pre {
  background: #f5f0fa;
  border-color: var(--border);
}
body.light-theme .bubble pre code {
  color: #2d1f42;
}
body.light-theme .login-card {
  box-shadow: 0 8px 40px rgba(124, 58, 237, 0.12);
}
body.light-theme .login-page::before {
  background: radial-gradient(ellipse at 30% 20%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(219, 39, 119, 0.04) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 50%, rgba(234, 88, 12, 0.03) 0%, transparent 60%);
}
body.light-theme .modal-overlay {
  background: rgba(0, 0, 0, 0.4);
}
body.light-theme .mode-tooltip {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
body.light-theme ::-webkit-scrollbar-thumb {
  background: #c8b8d8;
}
body.light-theme ::-webkit-scrollbar-thumb:hover {
  background: #a898b8;
}
body.light-theme .lesson-content-body pre {
  background: #f5f0fa;
}
body.light-theme .lesson-content-body code {
  background: #ede6f5;
}

/* ── Interactive Tour ──────────────────────────────────────────────────── */

/* Overlay */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.6);
}

/* Spotlight cutout */
.tour-spotlight {
  position: fixed;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  z-index: 10001;
  transition: all 0.3s ease;
  pointer-events: none;
}

/* Spotlight pulse on appear */
.tour-spotlight-pulse {
  animation: tourSpotlightPulse 0.6s ease-out;
}

@keyframes tourSpotlightPulse {
  0%   { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6), 0 0 0 0 rgba(139, 92, 246, 0.4); }
  50%  { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6), 0 0 0 6px rgba(139, 92, 246, 0.25); }
  100% { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6), 0 0 0 0 rgba(139, 92, 246, 0); }
}

/* Tooltip */
.tour-tooltip {
  position: fixed;
  z-index: 10002;
  background: var(--bg-secondary, #231e2e);
  border: 1px solid var(--border-color, #3d3350);
  border-radius: 12px;
  padding: 20px;
  max-width: 340px;
  min-width: 260px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.tour-tooltip-title {
  font-size: 1.1em;
  font-weight: 700;
  color: var(--text-primary, #e8e0f0);
  margin-bottom: 8px;
}

.tour-tooltip-text {
  font-size: 0.9em;
  color: var(--text-secondary, #9b8fb0);
  line-height: 1.5;
}

/* Footer — step count + buttons */
.tour-tooltip-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.tour-step-count {
  font-size: 0.8em;
  color: var(--text-secondary, #6b5f80);
}

.tour-buttons {
  display: flex;
  gap: 8px;
}

/* Buttons — shared */
.tour-btn {
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 0.85em;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}

.tour-btn:active {
  transform: scale(0.96);
}

/* Skip button */
.tour-btn-skip {
  background: transparent;
  color: var(--text-secondary, #9b8fb0);
}

.tour-btn-skip:hover {
  color: var(--text-primary, #e8e0f0);
}

/* Back button */
.tour-btn-back {
  background: transparent;
  color: var(--text-secondary, #9b8fb0);
  border: 1px solid var(--border-color, #3d3350);
}

.tour-btn-back:hover {
  color: var(--text-primary, #e8e0f0);
  border-color: var(--text-secondary, #9b8fb0);
}

/* Next / Done button */
.tour-btn-next {
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 600;
}

.tour-btn-next:hover {
  filter: brightness(1.1);
}

/* "All set!" celebration state */
.tour-btn-celebrate {
  background: var(--accent-gradient);
  color: #fff;
  animation: tourCelebrate 0.5s ease-out;
}

@keyframes tourCelebrate {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ── Progress bar ─────────────────────────────────────────────────────── */

.tour-progress-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  margin-bottom: 14px;
  overflow: hidden;
}

.tour-progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  transition: width 0.35s ease;
  width: 0;
}

/* ── Tooltip arrow (CSS triangle) ─────────────────────────────────────── */

.tour-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--bg-secondary, #231e2e);
  border: 1px solid var(--border-color, #3d3350);
  transform: rotate(45deg);
  z-index: -1;
}

/* Arrow pointing up (tooltip below target) */
.tour-arrow-top {
  top: -7px;
  left: 28px;
  border-right: none;
  border-bottom: none;
}

/* Arrow pointing down (tooltip above target) */
.tour-arrow-bottom {
  bottom: -7px;
  left: 28px;
  border-left: none;
  border-top: none;
}

/* Arrow pointing left (tooltip right of target) */
.tour-arrow-left {
  left: -7px;
  top: 18px;
  border-right: none;
  border-top: none;
}

/* Arrow pointing right (tooltip left of target) */
.tour-arrow-right {
  right: -7px;
  top: 18px;
  border-left: none;
  border-bottom: none;
}

/* ── Fade animations ──────────────────────────────────────────────────── */

.tour-fade-in {
  animation: tourFadeIn 0.3s ease-out forwards;
}

.tour-fade-out {
  animation: tourFadeOut 0.3s ease-in forwards;
}

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

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

/* ── Tour button class (replaces inline style) ────────────────────────── */

.btn-tour {
  font-size: 0.8em;
}

/* ── Light-theme overrides ────────────────────────────────────────────── */

body.light-theme .tour-overlay {
  background: rgba(0, 0, 0, 0.45);
}

body.light-theme .tour-spotlight {
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
}

body.light-theme .tour-tooltip {
  background: #fff;
  border-color: #e0d5ec;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

body.light-theme .tour-tooltip-title {
  color: #2d1f42;
}

body.light-theme .tour-tooltip-text {
  color: #6b5a80;
}

body.light-theme .tour-arrow {
  background: #fff;
  border-color: #e0d5ec;
}

body.light-theme .tour-progress-bar {
  background: rgba(0, 0, 0, 0.06);
}

body.light-theme .tour-btn-skip:hover {
  color: #2d1f42;
}

body.light-theme .tour-btn-back {
  color: #6b5a80;
  border-color: #e0d5ec;
}

body.light-theme .tour-btn-back:hover {
  color: #2d1f42;
  border-color: #6b5a80;
}

/* ── Admin↔Student view switch button ─────────────────────────────────────── */
.btn-switch-view {
  background: var(--accent-color, #8B5CF6);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.8em;
  cursor: pointer;
  margin-right: 8px;
  width: auto;
  height: auto;
}
.btn-switch-view:hover {
  opacity: 0.9;
  color: #fff;
  border-color: transparent;
}

/* ── In-Chat Search ──────────────────────────────────────────────────── */
.chat-search-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.chat-search-toggle:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.chat-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-search-bar-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.chat-search-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  width: 140px;
}
.chat-search-bar .chat-search-input { flex: 1; width: auto; padding: 5px 10px; font-size: 13px; }
.chat-search-input:focus {
  border-color: var(--accent);
}
.chat-search-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 60px;
}
.chat-search-nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  line-height: 1;
}
.chat-search-nav-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}
.chat-search-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 14px;
}
.chat-search-close:hover {
  color: var(--error);
}

.search-highlight {
  background: rgba(139, 92, 246, 0.08) !important;
  border-left: 2px solid var(--accent) !important;
}
.search-current {
  background: rgba(139, 92, 246, 0.15) !important;
}
mark.search-mark {
  background: rgba(236, 72, 153, 0.3);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
body.light-theme .search-highlight {
  background: rgba(124, 58, 237, 0.06) !important;
}
body.light-theme mark.search-mark {
  background: rgba(219, 39, 119, 0.2);
}

/* ── Lesson context menu ─────────────────────────────────────────────── */
.lesson-context-menu {
  position: fixed;
  z-index: 9999;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 6px;
  text-align: left;
}
.ctx-menu-item:hover {
  background: var(--bg-hover);
}
.ctx-menu-item svg {
  flex-shrink: 0;
  color: var(--text-muted);
}
body.light-theme .lesson-context-menu {
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

/* ── Keyboard shortcuts panel ─────────────────────────────────────────── */
.shortcuts-panel {
  position: fixed;
  z-index: 9000;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-width: 240px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.shortcuts-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
  margin-bottom: 12px;
  user-select: none;
}
.shortcuts-titlebar:active { cursor: grabbing; }
.shortcuts-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.shortcuts-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.shortcuts-close:hover { color: var(--error); }
}
.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.shortcut-row kbd {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-muted);
  white-space: nowrap;
}
.shortcut-row span {
  font-size: 13px;
  color: var(--text);
}
body.light-theme .shortcuts-panel {
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

/* ── Search resizer (drag between tree and content matches) ───────────── */
.search-resizer {
  height: 6px;
  background: var(--border);
  cursor: row-resize;
  flex-shrink: 0;
  margin: 0;
  transition: background 0.15s;
  display: none;
}
.search-resizer:hover {
  background: var(--accent);
}
.search-resizer.active {
  display: block;
}

/* ── Classmates modal ────────────────────────────────────────────── */
.classmates-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}
.classmates-modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    min-width: 300px;
    max-width: 400px;
    max-height: 60vh;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.classmates-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.classmates-modal-header h3 {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text);
}
.classmates-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}
.classmates-modal-close:hover { color: var(--error); }
.classmates-modal-subtitle {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.classmates-modal-list {
    overflow-y: auto;
    max-height: 40vh;
}
.classmates-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.classmates-item:last-child { border-bottom: none; }
.classmates-name {
    font-weight: 500;
    color: var(--text);
}
.classmates-date {
    font-size: 0.8em;
    color: var(--text-muted);
}
.classmates-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 0;
    font-size: 0.9em;
}
body.light-theme .classmates-modal-overlay {
    background: rgba(0, 0, 0, 0.3);
}
body.light-theme .classmates-modal {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* ── Profile dropdown menu ──────────────────────────────────────────────────── */
.profile-menu-wrapper {
    position: relative;
}
.profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--border, rgba(255,255,255,.1));
    border-radius: 8px;
    padding: 4px 10px 4px 4px;
    cursor: pointer;
    color: var(--text, #e6e1e8);
    font-size: 0.85rem;
    transition: background .15s, border-color .15s;
}
.profile-btn:hover {
    background: var(--bg-hover, rgba(255,255,255,.06));
    border-color: var(--accent, #8B5CF6);
}
.profile-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8B5CF6, #EC4899);
    color: #fff;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.profile-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.profile-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: var(--bg-surface, #1e1b2e);
    border: 1px solid var(--border, rgba(255,255,255,.1));
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.45);
    z-index: 9999;
    overflow: hidden;
}
.profile-dropdown-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.profile-dropdown-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text, #e6e1e8);
}
.profile-dropdown-role {
    font-size: 0.75rem;
    color: var(--text-muted, #9b8fb0);
    text-transform: capitalize;
}
.profile-dropdown-items {
    padding: 6px;
}
.profile-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text, #e6e1e8);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background .12s;
    text-align: left;
}
.profile-item:hover {
    background: var(--bg-hover, rgba(255,255,255,.06));
}
.profile-item svg {
    flex-shrink: 0;
}
.profile-item-divider {
    height: 1px;
    background: var(--border, rgba(255,255,255,.08));
    margin: 4px 6px;
}
.profile-item-danger {
    color: #f87171;
}
.profile-item-danger:hover {
    background: rgba(248, 113, 113, .1);
}
/* Light theme overrides */
body.light-theme .profile-btn {
    border-color: var(--border, rgba(0,0,0,.12));
    color: var(--text, #1e1b2e);
}
body.light-theme .profile-btn:hover {
    background: var(--bg-hover, rgba(0,0,0,.04));
}
body.light-theme .profile-dropdown {
    background: var(--bg-surface, #fff);
    border-color: var(--border, rgba(0,0,0,.12));
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
}
body.light-theme .profile-dropdown-header {
    border-bottom-color: var(--border, rgba(0,0,0,.08));
}
body.light-theme .profile-item:hover {
    background: var(--bg-hover, rgba(0,0,0,.04));
}
body.light-theme .profile-item-divider {
    background: var(--border, rgba(0,0,0,.08));
}
