/* ============================================================
   QuizAll — AI Study Chat
   Perplexity-inspired minimal, high-tech UI
   ============================================================ */

/* ── Design tokens (scoped to chat app, won't touch other pages) ── */
.chat-app {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;

  /* Surfaces */
  --c-bg: #08080a;
  --c-bg-elevated: #101014;
  --c-panel: rgba(255, 255, 255, 0.028);
  --c-panel-hover: rgba(255, 255, 255, 0.055);
  --c-panel-active: rgba(255, 255, 255, 0.075);
  --c-border: rgba(255, 255, 255, 0.07);
  --c-border-strong: rgba(255, 255, 255, 0.12);
  --c-text: #f4f4f5;
  --c-text-dim: #a1a1aa;
  --c-text-faint: #71717a;
  --c-dot: rgba(255, 255, 255, 0.03);

  /* Brand */
  --g1: #8b5cf6;
  --g2: #06b6d4;
  --g3: #22d3ee;
  --glow-violet: rgba(139, 92, 246, 0.22);
  --glow-cyan: rgba(34, 211, 238, 0.14);

  /* Status */
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.12);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, 0.12);

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-dock: 0 -20px 60px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-composer: 0 16px 48px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html[data-theme="light"] .chat-app {
  --c-bg: #f8f8fa;
  --c-bg-elevated: #ffffff;
  --c-panel: rgba(0, 0, 0, 0.025);
  --c-panel-hover: rgba(0, 0, 0, 0.04);
  --c-panel-active: rgba(0, 0, 0, 0.06);
  --c-border: rgba(0, 0, 0, 0.08);
  --c-border-strong: rgba(0, 0, 0, 0.12);
  --c-text: #0b0b0c;
  --c-text-dim: #5c5c66;
  --c-text-faint: #9a9aa3;
  --c-dot: rgba(0, 0, 0, 0.04);
  --glow-violet: rgba(139, 92, 246, 0.12);
  --shadow-composer: 0 16px 48px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .msg.ai .msg-bubble {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.95) 0%, rgba(251, 251, 252, 0.9) 100%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .msg.user .msg-bubble {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(34, 211, 238, 0.06));
}

html[data-theme="light"] .quiz-card {
  background: rgba(255, 255, 255, 0.7);
}

html[data-theme="light"] .chat-main.has-messages .composer-region {
  background: linear-gradient(180deg, transparent 0%, rgba(248, 248, 250, 0.85) 30%, rgba(248, 248, 250, 0.98) 100%);
}

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

.hidden {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body.chat-app {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  color: var(--c-text);
  background-color: var(--c-bg);
  background-image:
    radial-gradient(circle at 1px 1px, var(--c-dot) 1px, transparent 0),
    radial-gradient(ellipse 80% 55% at 50% -15%, var(--glow-violet), transparent 65%),
    radial-gradient(ellipse 50% 40% at 100% 20%, rgba(6, 182, 212, 0.08), transparent 55%),
    radial-gradient(ellipse 40% 35% at 0% 80%, rgba(139, 92, 246, 0.06), transparent 50%);
  background-size: 24px 24px, 100% 100%, 100% 100%, 100% 100%;
  overflow: hidden;
  letter-spacing: -0.011em;
}

.app-shell {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ────────────────────────── Sidebar ────────────────────────── */
.sidebar {
  width: 260px;
  min-width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--c-border);
  background: linear-gradient(180deg, rgba(16, 16, 20, 0.92) 0%, rgba(8, 8, 10, 0.88) 100%);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  transition: width 0.2s var(--ease), min-width 0.2s var(--ease), transform 0.2s var(--ease), opacity 0.2s var(--ease);
}

body.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  border-right-width: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 499;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}

.sidebar-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

html[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88) 0%, rgba(251, 251, 252, 0.92) 100%);
}

.sidebar-brand {
  padding: 18px 16px 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

a.sidebar-brand,
a.sidebar-home-link {
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  margin: 6px 8px 0;
  padding: 10px 12px;
  transition: background 0.2s var(--ease);
}

a.sidebar-home-link:hover {
  background: var(--c-panel-hover);
}

.brand-home-hint {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-text-faint);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

a.sidebar-home-link:hover .brand-home-hint {
  opacity: 1;
  transform: none;
}

.sidebar-brand img {
  width: 24px;
  height: 24px;
}

.sidebar-brand span {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: var(--c-text);
}

.btn-new-chat {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 12px 8px;
  padding: 11px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(34, 211, 238, 0.08));
  color: var(--c-text);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.28);
}

.btn-new-chat::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(120deg, rgba(139, 92, 246, 0.5), rgba(34, 211, 238, 0.35));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  pointer-events: none;
}

.btn-new-chat:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.45), 0 8px 24px rgba(139, 92, 246, 0.15);
}

.btn-new-chat:hover::before {
  opacity: 1;
}

.btn-new-chat:active {
  transform: scale(0.99);
}

.btn-new-chat .icon {
  width: 16px;
  height: 16px;
  color: var(--g3);
}

/* Sidebar nav */
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--c-border);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 9px 12px 9px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--c-text-dim);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.nav-item::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--g1), var(--g3));
  transform: translateY(-50%);
  transition: height 0.25s var(--ease-spring);
}

.nav-item:hover {
  background: var(--c-panel-hover);
  color: var(--c-text);
}

.nav-item.is-active {
  background: var(--c-panel-active);
  color: var(--c-text);
}

.nav-item.is-active::before {
  height: 18px;
}

.nav-item .icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.nav-count {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--c-text-faint);
  background: var(--c-panel-active);
  padding: 1px 8px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

.nav-count:empty {
  display: none;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.side-nav--projects {
  border-bottom: none;
  margin-bottom: 0;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--c-border);
  flex: 1;
  min-height: 0;
}

.side-nav--history {
  border-bottom: none;
  margin-bottom: 0;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--c-border);
}

.side-nav--history.history-highlight {
  animation: historyPulse 0.9s var(--ease);
}

@keyframes historyPulse {
  0%, 100% { background: transparent; }
  30% { background: rgba(139, 92, 246, 0.08); }
}

.nav-section-label,
.nav-item--section {
  pointer-events: none;
  cursor: default;
}

.nav-item--section:hover {
  background: transparent;
  color: var(--c-text-dim);
}

.nav-item--section .nav-inline-action {
  pointer-events: auto;
  cursor: pointer;
}

.nav-section-label {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px 9px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--c-text-dim);
  user-select: none;
}

.nav-section-label .icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--c-text-faint);
}

.nav-inline-action {
  margin-left: auto;
  border: none;
  background: transparent;
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--g3);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
}

.nav-inline-action:hover {
  background: var(--c-panel-hover);
  color: var(--c-text);
}

.side-nav--projects .nav-item {
  width: 100%;
}

.side-nav--projects .nav-count.project-meta {
  font-size: 0.68rem;
  font-weight: 500;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-sessions .nav-item.project-session {
  padding-left: 28px;
}

.project-row {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}

.project-row .nav-item.project-session {
  flex: 1;
  min-width: 0;
}

.project-row .nav-item > span:not(.nav-count) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-row .nav-item > span.session-name {
  white-space: normal;
  word-break: break-word;
  line-height: 1.25;
  text-overflow: unset;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.project-row .project-more {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0 10px 10px 0;
  background: transparent;
  color: var(--c-text-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s var(--ease), color 0.2s var(--ease), background 0.2s var(--ease);
}

.project-row.menu-open .project-more {
  opacity: 1;
}

.project-more:hover,
.project-more.is-open {
  color: var(--c-text);
  background: var(--c-panel-hover);
}

.project-more .icon {
  width: 16px;
  height: 16px;
}

.project-group-label,
.project-list-label,
.sidebar-section-head {
  display: none !important;
}

.project-row:hover .project-more,
.project-row.is-active .project-more,
.project-row.menu-open .project-more {
  opacity: 1;
}

.project-row.menu-open .nav-item {
  background: var(--c-panel-active);
}

.project-empty {
  padding: 8px 14px 12px;
  font-size: 0.8rem;
  color: var(--c-text-faint);
  line-height: 1.5;
}

/* Streak widget (rendered inside Usage tab) */
.streak-card {
  padding: 14px 15px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-panel);
}

.streak-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 10px;
}

.streak-head .icon {
  width: 15px;
  height: 15px;
  color: #fb923c;
}

.streak-head .streak-sub {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--c-text-faint);
}

.streak-dots {
  display: flex;
  gap: 5px;
}

.streak-dot {
  flex: 1;
  height: 22px;
  border-radius: 5px;
  background: var(--c-panel-active);
  border: 1px solid var(--c-border);
}

.streak-dot.lvl-1 { background: rgba(124, 58, 237, 0.35); border-color: transparent; }
.streak-dot.lvl-2 { background: rgba(124, 58, 237, 0.6); border-color: transparent; }
.streak-dot.lvl-3 { background: linear-gradient(135deg, var(--g1), var(--g3)); border-color: transparent; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--c-border);
}

.avatar-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.avatar-sub {
  font-size: 0.72rem;
  color: var(--c-text-faint);
}

.avatar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--c-text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s var(--ease);
}

.avatar-btn:hover {
  background: var(--c-panel-hover);
}

.avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.72rem;
  color: #fff;
  background: linear-gradient(135deg, var(--g1), var(--g3));
  flex-shrink: 0;
}

.avatar-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--c-text-dim);
  font-size: 0.8rem;
  font-weight: 450;
}

/* ────────────────────────── Main ────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.viewonly-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 8px 16px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-panel);
  font-size: 0.8rem;
  color: var(--c-text-dim);
}

.viewonly-banner.hidden {
  display: none;
}

.viewonly-banner-btn {
  padding: 4px 10px;
  border: 1px solid var(--c-border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--c-text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.viewonly-banner-btn:hover {
  background: var(--c-panel-active);
  border-color: var(--g2);
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 40px 0 8px;
}

.chat-main:not(.has-messages) {
  justify-content: flex-end;
  align-items: stretch;
  padding-bottom: 0;
}

.chat-main:not(.has-messages) .chat-scroll {
  display: none;
}

.chat-main:not(.has-messages) .composer-region {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 0;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

.chat-main.has-messages .composer-region {
  border-top: 1px solid var(--c-border);
  background: linear-gradient(180deg, transparent 0%, rgba(8, 8, 10, 0.65) 24%, rgba(8, 8, 10, 0.92) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.chat-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Hero (empty state) */
.hero {
  display: none;
  position: relative;
}

.chat-main:not(.has-messages) .hero {
  display: block;
  text-align: center;
  max-width: 720px;
  margin: 0 auto 40px;
  padding: 0 24px;
  animation: heroIn 0.65s var(--ease);
  flex-shrink: 0;
}

.hero-ambient {
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(480px, 90vw);
  height: 200px;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse, var(--glow-violet) 0%, transparent 70%);
  filter: blur(40px);
  pointer-events: none;
  z-index: -1;
}

@keyframes heroIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  margin-bottom: 24px;
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(34, 211, 238, 0.06));
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--c-text-dim);
  box-shadow: 0 4px 24px rgba(139, 92, 246, 0.12);
}

.hero-badge .icon {
  width: 14px;
  height: 14px;
  color: var(--g3);
}

.hero h1 {
  margin: 0 0 20px;
  font-size: clamp(2.7rem, 7.2vw, 4.1rem) !important;
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.045em;
  color: var(--c-text);
}

.hero h1 .accent {
  background: linear-gradient(125deg, #c4b5fd 0%, var(--g2) 45%, var(--g3) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-sub {
  margin: 0 auto;
  max-width: 420px;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--c-text-dim);
}

.hero-flow {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 4px;
  margin-top: 28px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  background: rgba(255, 255, 255, 0.02);
}

.hero-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--c-text-dim);
}

.hero-step .icon {
  width: 14px;
  height: 14px;
  color: var(--g3);
  opacity: 0.9;
}

.hero-step-divider {
  width: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--c-border-strong), transparent);
  flex-shrink: 0;
}

/* Sidebar toggle */
.sidebar-toggle-btn {
  display: grid;
  place-items: center;
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 10;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--c-border);
  background: var(--c-panel);
  backdrop-filter: blur(12px);
  color: var(--c-text);
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.sidebar-toggle-btn:hover {
  background: var(--c-panel-hover);
  border-color: var(--c-border-strong);
}

.sidebar-toggle-btn .icon {
  width: 19px;
  height: 19px;
}

.sidebar-toggle-btn .icon-panel {
  display: none;
}

body.sidebar-collapsed .sidebar-toggle-btn .icon-menu {
  display: none;
}

body.sidebar-collapsed .sidebar-toggle-btn .icon-panel {
  display: block;
}

/* ────────────────────────── Messages ────────────────────────── */
.msg {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  animation: msgIn 0.35s var(--ease);
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.msg.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.msg.ai .msg-avatar {
  background: linear-gradient(135deg, var(--g1), var(--g2));
  color: #fff;
}

.msg.ai .msg-avatar .icon {
  width: 16px;
  height: 16px;
}

.msg.user .msg-avatar {
  background: var(--c-panel-active);
  border: 1px solid var(--c-border);
  color: var(--c-text-dim);
  font-size: 0.72rem;
  font-weight: 600;
}

.msg-bubble {
  max-width: 100%;
  min-width: 0;
  font-size: 0.94rem;
  line-height: 1.62;
  color: var(--c-text);
  padding-top: 3px;
}

.msg.ai .msg-bubble {
  flex: 1;
  min-width: 0;
  padding: 16px 18px;
  border-radius: 18px;
  border-top-left-radius: 6px;
  border: 1px solid var(--c-border);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.msg.ai .msg-bubble:has(.quiz-card) {
  padding-bottom: 14px;
}

.msg-user-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: 78%;
  gap: 4px;
}

.msg.user .msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  border-top-right-radius: 6px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.14), rgba(34, 211, 238, 0.08));
  border: 1px solid rgba(139, 92, 246, 0.22);
  color: var(--c-text);
  font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.1);
}

.msg-bubble h3 {
  margin: 0 0 10px;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.msg-bubble p {
  margin: 0 0 10px;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

/* ── Edit button on user messages ── */
.msg-edit-btn {
  display: none;
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.72rem;
  color: var(--c-text-dim);
  cursor: pointer;
  gap: 4px;
  align-items: center;
  transition: color 0.12s, border-color 0.12s;
  line-height: 1;
  white-space: nowrap;
  align-self: flex-end;
}
.msg-edit-btn svg { width: 11px; height: 11px; flex-shrink: 0; }
.msg.user:hover .msg-edit-btn { display: inline-flex; }
.msg-edit-btn:hover { color: var(--c-text); border-color: var(--c-text-dim); }

/* ── Inline edit area ── */
.msg-edit-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.msg-edit-textarea {
  width: 100%;
  min-height: 60px;
  max-height: 220px;
  resize: vertical;
  background: var(--c-input-bg, rgba(0,0,0,0.25));
  border: 1px solid var(--accent-border, rgba(139,92,246,0.4));
  border-radius: 10px;
  color: var(--c-text);
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.55;
  padding: 10px 12px;
  outline: none;
  box-sizing: border-box;
}
.msg-edit-textarea:focus { border-color: rgba(139,92,246,0.7); }
.msg-edit-actions { display: flex; gap: 6px; justify-content: flex-end; }
.msg-edit-save {
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  background: var(--accent, #7c6af0);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.12s;
}
.msg-edit-save:hover { opacity: 0.85; }
.msg-edit-cancel {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--c-border);
  background: transparent;
  color: var(--c-text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.12s;
}
.msg-edit-cancel:hover { color: var(--c-text); }

.msg-bubble strong {
  font-weight: 600;
}

.msg-bubble .meta-line {
  color: var(--c-text-dim);
  font-size: 0.88rem;
}

/* Plan steps */
.plan-steps {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plan-steps li {
  padding: 14px 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.04) 0%, transparent 55%);
  font-size: 0.9rem;
  line-height: 1.55;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
}

.plan-steps li:hover {
  border-color: rgba(139, 92, 246, 0.25);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, var(--c-panel-hover) 100%);
  transform: translateX(2px);
}

.plan-steps .step-title {
  display: block;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 3px;
}

.plan-steps .step-why {
  color: var(--c-text-dim);
}

.plan-steps .step-min {
  color: var(--c-text-faint);
  font-size: 0.8rem;
}

.topic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 4px;
}

.topic-tag {
  padding: 5px 12px;
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.08);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--c-text-dim);
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  gap: 5px;
  padding: 8px 0;
  align-items: center;
}

.typing-label {
  margin: 0 0 4px;
  font-size: 0.82rem;
  color: var(--c-text-dim);
  font-weight: 450;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g1), var(--g3));
  animation: typing 1.3s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.32s; }

@keyframes typing {
  0%, 70%, 100% { opacity: 0.25; transform: scale(0.8); }
  35% { opacity: 1; transform: scale(1); }
}

/* Blinking caret for AI text */
.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--g3);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ────────────────────────── Quiz card ────────────────────────── */
.quiz-card {
  margin-top: 14px;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  background: rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
  overflow: hidden;
}

.quiz-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--g1), var(--g2), var(--g3));
  opacity: 0.7;
}

.quiz-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--c-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.quiz-question {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--c-border);
}

.quiz-question:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 4px;
}

.q-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--g3);
  margin-bottom: 8px;
}

.q-text {
  margin: 0 0 14px;
  font-size: 0.94rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--c-text);
}

.option-btn,
.tf-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--c-border);
  border-radius: 11px;
  background: transparent;
  color: var(--c-text);
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.15s var(--ease);
}

.option-btn:hover,
.tf-btn:hover {
  border-color: var(--c-border-strong);
  background: var(--c-panel-hover);
}

.option-btn .opt-key {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--c-border);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--c-text-dim);
  flex-shrink: 0;
  transition: all 0.2s var(--ease);
}

.option-btn.selected,
.tf-btn.selected {
  border-color: transparent;
  background: linear-gradient(120deg, rgba(124, 58, 237, 0.18), rgba(34, 211, 238, 0.14));
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.5);
}

.option-btn.selected .opt-key {
  background: linear-gradient(135deg, var(--g1), var(--g3));
  border-color: transparent;
  color: #fff;
}

.option-btn.correct {
  border-color: rgba(52, 211, 153, 0.55);
  background: var(--ok-bg);
}

.option-btn.wrong {
  border-color: rgba(248, 113, 113, 0.55);
  background: var(--bad-bg);
}

.training-artifact {
  margin-top: 8px;
}

.training-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.training-round {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--g3);
}

.training-topic {
  font-size: 0.78rem;
  color: var(--c-text-dim);
}

.training-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  font-size: 0.78rem;
}

.training-accuracy {
  font-weight: 600;
  color: var(--c-text);
}

.training-done,
.training-qnum {
  color: var(--c-text-dim);
  font-variant-numeric: tabular-nums;
}

.training-prev {
  margin-left: auto;
}

.training-feedback {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  font-size: 0.84rem;
}

.training-ok {
  color: var(--ok);
  font-weight: 600;
}

.training-miss {
  color: var(--bad);
  font-weight: 600;
}

.training-session-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--c-border);
  font-size: 0.75rem;
  color: var(--c-text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.training-citation {
  color: var(--c-text-faint);
}

.session-footer {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--c-border);
  background: var(--c-panel);
  font-size: 0.82rem;
}

.session-footer-block + .session-footer-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--c-border);
}

.session-footer-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-faint);
  margin-bottom: 6px;
}

.session-footer ul {
  margin: 0;
  padding-left: 18px;
}

.session-footer .citation {
  color: var(--c-text-faint);
  font-size: 0.78rem;
}

.plan-phase-table,
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.plan-phase-table th,
.plan-phase-table td,
.compare-table th,
.compare-table td {
  border: 1px solid var(--c-border);
  padding: 6px 8px;
  text-align: left;
}

.plan-phase-table th,
.compare-table th {
  background: var(--c-panel-hover);
  font-weight: 600;
}

.compare-block {
  margin: 12px 0;
}

.compare-title {
  margin: 0 0 6px;
  font-size: 0.84rem;
  font-weight: 600;
}

.concept-scenario {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--c-text-dim);
}

.plan-concepts {
  margin: 10px 0;
  padding-left: 18px;
  font-size: 0.84rem;
}

.fill-input,
.free-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--c-border) !important;
  background: transparent !important;
  color: var(--c-text) !important;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.fill-input:focus,
.free-input:focus {
  outline: none;
  border-color: transparent !important;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.55), 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.free-input {
  min-height: 92px;
  resize: vertical;
  line-height: 1.5;
}

.btn-round {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 11px 20px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--g1), var(--g2));
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  box-shadow: 0 4px 24px rgba(124, 58, 237, 0.28);
}

.btn-round:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 30px rgba(124, 58, 237, 0.4);
}

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

.btn-round:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.retry-btn {
  margin-top: 12px;
}

.retry-btn {
  margin-top: 12px;
}

.btn-round .icon {
  width: 16px;
  height: 16px;
}

/* ────────────────────────── Round review ────────────────────────── */
.review-score {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  background: var(--c-panel);
  margin: 4px 0 14px;
}

.review-score .num {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.review-score .lbl {
  font-size: 0.8rem;
  color: var(--c-text-dim);
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.history-toggle {
  display: inline-flex;
  align-items: center;
  margin: 0 0 10px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--g3);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s var(--ease);
}

.history-toggle:hover {
  opacity: 0.8;
}

.history-details.hidden {
  display: none;
}

.science-link-wrap {
  margin: 18px 0 0;
  font-size: 0.85rem;
  color: var(--c-text-dim);
}

.science-link {
  color: var(--g3);
  text-decoration: none;
  font-weight: 500;
}

.science-link:hover {
  text-decoration: underline;
}

.review-item {
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: var(--c-panel);
  border-left-width: 3px;
}

.review-item.correct {
  border-left-color: var(--ok);
}

.review-item.wrong {
  border-left-color: var(--bad);
}

.review-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.review-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.review-badge.correct {
  color: var(--ok);
  background: var(--ok-bg);
}

.review-badge.wrong {
  color: var(--bad);
  background: var(--bad-bg);
}

.review-badge .icon {
  width: 12px;
  height: 12px;
}

.review-q {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--c-text);
}

.review-row {
  display: flex;
  gap: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-top: 4px;
}

.review-row .k {
  color: var(--c-text-faint);
  min-width: 92px;
  flex-shrink: 0;
}

.review-row .v {
  color: var(--c-text-dim);
}

.review-row .v.good {
  color: var(--ok);
}

.review-row .v.bad {
  color: var(--bad);
}

.review-explain {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--c-border);
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--c-text-dim);
}

/* Note card */
.note-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.note-list li {
  position: relative;
  padding-left: 20px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--c-text-dim);
}

.note-list li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--g1), var(--g3));
}

.note-section-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-text-faint);
  margin: 14px 0 6px;
}

/* ────────────────────────── Composer ────────────────────────── */
.composer-region {
  padding: 16px 24px max(24px, env(safe-area-inset-bottom));
}

.composer-dock {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.composer-wrap {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
}

.composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.composer-attachments:empty {
  display: none;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 9px;
  background: var(--c-panel-active);
  border: 1px solid var(--c-border);
  font-size: 0.8rem;
  color: var(--c-text-dim);
}

.attachment-chip .icon {
  width: 13px;
  height: 13px;
}

.attachment-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 2px;
  padding: 2px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--c-text-dim);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.attachment-remove .icon {
  width: 12px;
  height: 12px;
}

.attachment-remove:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 10px 10px 14px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--c-border-strong);
  background: linear-gradient(180deg, rgba(22, 22, 28, 0.95) 0%, rgba(12, 12, 16, 0.98) 100%);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
  box-shadow: var(--shadow-composer), 0 0 28px rgba(139, 92, 246, 0.18);
  transition: box-shadow 0.35s var(--ease), border-color 0.35s var(--ease), transform 0.35s var(--ease);
}

html[data-theme="light"] .composer {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(251, 251, 252, 0.98) 100%);
  box-shadow: var(--shadow-composer), 0 0 24px rgba(139, 92, 246, 0.12);
}

/* gradient glow border — always visible, stronger on focus */
.composer::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(120deg, var(--g1), var(--g2), var(--g3));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.72;
  transition: opacity 0.3s var(--ease);
  pointer-events: none;
}

.composer:focus-within {
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: var(--shadow-composer), 0 0 0 1px rgba(139, 92, 246, 0.35), 0 12px 48px var(--glow-violet);
}

.composer:focus-within::before {
  opacity: 1;
}

.composer textarea {
  flex: 1;
  min-height: 32px;
  max-height: 200px;
  padding: 10px 4px 10px 0;
  border: none !important;
  background: transparent !important;
  color: var(--c-text) !important;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
  outline: none !important;
}

.composer textarea::placeholder {
  color: var(--c-text-faint) !important;
}

.composer-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--c-text-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.btn-icon:hover {
  background: var(--c-panel-hover);
  color: var(--c-text);
  border-color: var(--c-border);
}

.btn-mix.is-active,
.btn-mix[aria-expanded="true"] {
  background: rgba(139, 92, 246, 0.15);
  color: var(--g3);
  border-color: rgba(139, 92, 246, 0.35);
}

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(145deg, #9b6dff 0%, var(--g2) 100%);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity 0.2s var(--ease), transform 0.25s var(--ease-spring), box-shadow 0.25s var(--ease);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}

.btn-send:hover {
  transform: scale(1.06) translateY(-1px);
  box-shadow: 0 8px 28px rgba(139, 92, 246, 0.5);
}

.btn-send:active {
  transform: scale(0.97);
}

.btn-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: var(--c-panel-active);
  color: var(--c-text-faint);
}

.btn-send .icon,
.btn-icon .icon {
  width: 18px;
  height: 18px;
}

.composer-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--c-text-faint);
  margin-top: 10px;
}

.composer-hint.is-error {
  color: var(--bad);
}

.mix-panel {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  right: 0;
  margin: 0 auto;
  max-width: 300px;
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border-strong);
  background: var(--c-bg-elevated);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18), 0 0 0 1px var(--c-border);
  z-index: 20;
  animation: panelIn 0.25s var(--ease);
}

html[data-theme="light"] .mix-panel {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px var(--c-border);
}

.mix-panel.is-expanded {
  padding: 8px 8px 10px;
}

.mix-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.mix-summary:hover {
  background: var(--c-panel-hover);
}

.mix-summary-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mix-summary-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--c-text-faint);
  text-transform: uppercase;
}

.mix-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--c-text-faint);
  transition: transform 0.2s var(--ease);
}

.mix-panel.is-expanded .mix-chevron {
  transform: rotate(180deg);
}

.mix-details {
  display: none;
  padding: 4px 6px 2px;
}

.mix-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.mix-mode-btn {
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: transparent;
  color: var(--c-text-dim);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.mix-mode-btn:hover {
  background: var(--c-panel-hover);
  color: var(--c-text);
}

.mix-mode-btn.is-active {
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.1);
  color: var(--c-text);
}

.mix-mode-hint {
  margin: 0 0 10px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--c-text-faint);
}

.mix-details--testing-only .mix-presets,
.mix-details--testing-only .mix-total {
  display: block;
}

.mix-details:not(.mix-details--testing-only) .mix-presets,
.mix-details:not(.mix-details--testing-only) .mix-total {
  display: none;
}

.mix-panel.is-expanded .mix-details {
  display: block;
  animation: panelIn 0.2s var(--ease);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.mix-panel-head {
  display: none;
}

.mix-preview {
  font-weight: 500;
  color: var(--c-text);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mix-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.mix-preset {
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: transparent;
  color: var(--c-text-dim);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.mix-preset:hover {
  background: var(--c-panel-hover);
  color: var(--c-text);
}

.mix-preset.is-active {
  border-color: rgba(139, 92, 246, 0.45);
  background: rgba(139, 92, 246, 0.12);
  color: var(--c-text);
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.2);
}

.mix-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--c-border);
}

.mix-total-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--c-text-dim);
}

.mix-stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  background: var(--c-panel);
}

.mix-total-val {
  min-width: 28px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--c-text);
}

.mix-step {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--c-text-dim);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.mix-step:hover {
  background: var(--c-panel-hover);
  color: var(--c-text);
}

.sidebar-section-head {
  display: none !important;
}

.folder-group {
  margin: 0 0 4px;
}

.folder-group.is-open .folder-sessions {
  display: block;
}

.folder-toggle.nav-item {
  width: 100%;
}

.folder-sessions {
  display: none;
  padding: 0 0 2px 0;
}

.folder-sessions .project-row {
  padding-left: 6px;
}

.folder-empty {
  padding: 6px 10px;
  font-size: 0.75rem;
  color: var(--c-text-faint);
}

.folder-move-submenu {
  border-top: 1px solid var(--c-border);
  margin-top: 4px;
  padding-top: 4px;
  max-height: 180px;
  overflow-y: auto;
}

.folder-move-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--c-text-dim);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.folder-move-item:hover {
  background: var(--c-panel-hover);
  color: var(--c-text);
}

.hint-link {
  border: none;
  background: transparent;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  color: var(--g3);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.2s var(--ease);
}

.hint-link:hover {
  opacity: 0.8;
}

/* ────────────────────────── Popup menu ────────────────────────── */
.popup-menu.project-item-menu {
  width: 168px;
  padding: 5px;
  bottom: auto;
  left: auto;
  z-index: 1100;
}

.popup-menu.project-item-menu button {
  padding: 9px 10px;
  font-size: 0.8125rem;
}

.popup-menu {
  position: fixed;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--c-border-strong);
  background: var(--c-bg-elevated);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  z-index: 1000;
  animation: popIn 0.2s var(--ease);
}

html[data-theme="light"] .popup-menu {
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

#avatarMenu.popup-menu {
  bottom: 76px;
  left: 14px;
  width: 232px;
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.popup-menu.hidden {
  display: none;
}

.popup-menu button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--c-text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 450;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}

.popup-menu button:hover {
  background: var(--c-panel-hover);
}

.popup-menu button .icon {
  width: 16px;
  height: 16px;
  color: var(--c-text-dim);
}

.popup-menu .divider {
  height: 1px;
  background: var(--c-border);
  margin: 5px 4px;
}

.popup-menu .danger {
  color: var(--bad);
}

.popup-menu .danger .icon {
  color: var(--bad);
}

/* ────────────────────────── Settings modal (native) ────────────────────────── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 28px;
  animation: fadeIn 0.2s var(--ease);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.settings-overlay.hidden {
  display: none;
}

.settings-modal {
  width: min(720px, 100%);
  height: min(70vh, 560px);
  border-radius: 18px;
  border: 1px solid var(--c-border-strong);
  background: var(--c-bg);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  display: flex;
  overflow: hidden;
  animation: panelIn 0.25s var(--ease);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.settings-side {
  width: 180px;
  flex-shrink: 0;
  padding: 16px 10px;
  border-right: 1px solid var(--c-border);
  background: var(--c-panel);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-side-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--c-text-faint);
  padding: 4px 10px 10px;
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--c-text-dim);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.settings-tab:hover {
  background: var(--c-panel-hover);
  color: var(--c-text);
}

.settings-tab.is-active {
  background: var(--c-panel-active);
  color: var(--c-text);
}

.settings-tab .icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.settings-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.settings-content-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--c-border);
}

.settings-content-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.settings-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--c-text-dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s var(--ease);
}

.settings-close:hover {
  background: var(--c-panel-hover);
  color: var(--c-text);
}

.settings-close .icon {
  width: 18px;
  height: 18px;
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-loading {
  color: var(--c-text-faint);
  font-size: 0.86rem;
  padding: 8px 0;
}

/* rows & cards inside settings */
.set-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 13px 15px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-panel);
}

.set-row .set-k {
  font-size: 0.82rem;
  color: var(--c-text-dim);
}

.set-row .set-v {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--c-text);
  text-align: right;
  word-break: break-all;
}

.set-v .badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--c-panel-active);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  text-transform: capitalize;
}

.set-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.set-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--c-border-strong);
  border-radius: 10px;
  background: var(--c-panel);
  color: var(--c-text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.set-btn:hover {
  background: var(--c-panel-hover);
}

.set-btn.primary {
  border: none;
  background: linear-gradient(120deg, var(--g1), var(--g2));
  color: #fff;
  font-weight: 600;
}

.set-btn.danger {
  color: var(--bad);
  border-color: rgba(248, 113, 113, 0.3);
}

.set-btn.danger:hover {
  background: var(--bad-bg);
}

.set-note {
  font-size: 0.76rem;
  color: var(--c-text-faint);
  line-height: 1.5;
}

.set-banner {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.45;
  margin-bottom: 12px;
}

.set-banner.warn {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: #fbbf24;
}

.set-debug {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  opacity: 0.85;
  word-break: break-all;
}

.set-note a,
.set-link {
  color: var(--g3);
  text-decoration: none;
}

.set-note a:hover,
.set-link:hover {
  text-decoration: underline;
}

/* theme picker */
.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-panel);
  color: var(--c-text-dim);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease);
}

.theme-option:hover {
  background: var(--c-panel-hover);
}

.theme-option.is-active {
  border-color: transparent;
  box-shadow: inset 0 0 0 1.5px rgba(139, 92, 246, 0.6);
  color: var(--c-text);
}

.theme-swatch {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--c-border);
}

.theme-swatch.dark { background: #0b0b0c; }
.theme-swatch.light { background: #fbfbfc; }
.theme-swatch.system { background: linear-gradient(105deg, #0b0b0c 50%, #fbfbfc 50%); }

/* usage meters */
.usage-meter {
  padding: 13px 15px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-panel);
}

.usage-meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 9px;
}

.usage-meter-head .um-label {
  font-size: 0.82rem;
  color: var(--c-text-dim);
}

.usage-meter-head .um-value {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--c-text);
}

.usage-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--c-panel-active);
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--g1), var(--g3));
  transition: width 0.4s var(--ease);
}

@media (max-width: 680px) {
  .settings-modal {
    flex-direction: column;
    height: min(86vh, 640px);
  }

  .settings-side {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--c-border);
    padding: 10px;
  }

  .settings-side-title {
    display: none;
  }
}

/* ────────────────────────── Responsive sidebar ────────────────────────── */
@media (max-width: 767px) {
  body.sidebar-collapsed .sidebar {
    width: min(280px, 88vw);
    min-width: 0;
    opacity: 1;
    pointer-events: auto;
    border-right-width: 1px;
  }

  .sidebar-backdrop {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 500;
    width: min(280px, 88vw);
    min-width: 0;
    transform: translateX(-100%);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
  }

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

  .chat-inner,
  .composer-region,
  .chat-main:not(.has-messages) .hero {
    padding-left: 18px;
    padding-right: 18px;
  }

  .hero h1 {
    font-size: clamp(2.2rem, 8vw, 4rem) !important;
  }

  .sidebar-toggle-btn .icon-panel {
    display: none !important;
  }

  .sidebar-toggle-btn .icon-menu {
    display: block !important;
  }
}

@media (min-width: 768px) {
  .sidebar-toggle-btn .icon-menu {
    display: block;
  }

  .sidebar-toggle-btn .icon-panel {
    display: none;
  }

  body:not(.sidebar-collapsed) .sidebar-toggle-btn .icon-menu {
    display: none;
  }

  body:not(.sidebar-collapsed) .sidebar-toggle-btn .icon-panel {
    display: block;
  }
}

/* ────────────────────────── Projects page ────────────────────────── */
.projects-page {
  overflow: hidden;
}

.projects-main {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.projects-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 48px;
}

.projects-inner {
  max-width: 920px;
  margin: 0 auto;
}

.projects-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 36px;
}

.projects-head-copy h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--c-text);
}

.projects-head-copy p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--c-text-dim);
  max-width: 480px;
}

.projects-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(34, 211, 238, 0.1));
  color: var(--c-text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.3);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.projects-new-btn:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.45), 0 8px 24px rgba(139, 92, 246, 0.12);
}

.projects-new-btn .icon {
  width: 15px;
  height: 15px;
  color: var(--g3);
}

.projects-section {
  margin-bottom: 40px;
}

.projects-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.projects-section-title {
  margin: 0 0 14px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-faint);
}

.projects-section-head .projects-section-title {
  margin-bottom: 0;
}

.projects-filter-clear {
  border: none;
  background: transparent;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--g3);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.projects-filter-clear:hover {
  background: var(--c-panel-hover);
}

.projects-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}

.project-folder-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-panel);
  color: var(--c-text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
}

.project-folder-card:hover {
  border-color: var(--c-border-strong);
  background: var(--c-panel-hover);
  transform: translateY(-1px);
}

.project-folder-card.is-active {
  border-color: rgba(139, 92, 246, 0.45);
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.1), rgba(34, 211, 238, 0.05));
  box-shadow: 0 8px 28px rgba(139, 92, 246, 0.1);
}

.project-folder-card--new {
  border-style: dashed;
  color: var(--c-text-dim);
}

.project-folder-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.12);
}

.project-folder-card--new .project-folder-icon {
  background: var(--c-panel-active);
}

.project-folder-icon .icon {
  width: 18px;
  height: 18px;
  color: var(--g3);
}

.project-folder-name {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  word-break: break-word;
}

.project-folder-meta {
  font-size: 0.75rem;
  color: var(--c-text-faint);
}

.projects-empty-card {
  grid-column: 1 / -1;
  padding: 20px;
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-md);
  color: var(--c-text-dim);
  font-size: 0.875rem;
  line-height: 1.5;
}

.projects-empty-card p {
  margin: 0 0 14px;
}

.projects-empty-card .project-folder-card--new {
  width: 168px;
}

.projects-session-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.projects-session-row {
  display: flex;
  align-items: stretch;
  gap: 0;
}

a.projects-session-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-panel);
  text-decoration: none;
  color: inherit;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

a.projects-session-row:hover {
  background: var(--c-panel-hover);
  border-color: var(--c-border-strong);
  transform: translateY(-1px);
}

.projects-session-name {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-text);
}

.projects-session-meta {
  font-size: 0.75rem;
  color: var(--c-text-faint);
}

.projects-session-hint {
  margin: 6px 0 14px;
  font-size: 0.82rem;
  color: var(--c-text-dim);
}

.projects-session-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 10px;
  background: linear-gradient(120deg, var(--g1), var(--g2));
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.25);
}

.projects-session-cta:hover {
  opacity: 0.95;
}

.projects-session-card {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--c-panel);
  color: var(--c-text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.projects-session-row:has(.session-more) .projects-session-card {
  border-right: none;
}

.projects-session-card:hover {
  background: var(--c-panel-hover);
  border-color: var(--c-border-strong);
}

.session-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 9px;
  background: rgba(34, 211, 238, 0.08);
}

.session-icon .icon {
  width: 16px;
  height: 16px;
  color: var(--g3);
}

.session-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-name {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-meta {
  font-size: 0.75rem;
  color: var(--c-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-folder-tag {
  color: var(--g3);
}

.session-date {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--c-text-faint);
  font-variant-numeric: tabular-nums;
}

.session-more {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  flex-shrink: 0;
  border: 1px solid var(--c-border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--c-panel);
  color: var(--c-text-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease);
}

.projects-session-row:hover .session-more,
.session-more.is-open {
  opacity: 1;
}

.session-more:hover,
.session-more.is-open {
  background: var(--c-panel-hover);
  color: var(--c-text);
}

.session-more .icon {
  width: 16px;
  height: 16px;
}

.projects-session-empty {
  padding: 24px 16px;
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.875rem;
  color: var(--c-text-faint);
  line-height: 1.5;
}

@media (max-width: 767px) {
  .projects-scroll {
    padding: 20px 18px 36px;
  }

  .projects-head {
    flex-direction: column;
    align-items: stretch;
  }

  .projects-new-btn {
    align-self: flex-start;
  }

  .session-date {
    display: none;
  }

  .session-more {
    opacity: 1;
  }
}

/* ────────────────────────── App dialog ────────────────────────── */
.qa-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.2s var(--ease);
}

.qa-dialog-overlay.hidden {
  display: none;
}

.qa-dialog {
  position: relative;
  width: min(400px, 100%);
  padding: 22px 22px 18px;
  border-radius: 16px;
  border: 1px solid var(--c-border-strong);
  background: var(--c-bg-elevated);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: panelIn 0.22s var(--ease);
}

.qa-dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--c-text-faint);
  cursor: pointer;
}

.qa-dialog-close:hover {
  background: var(--c-panel-hover);
  color: var(--c-text);
}

.qa-dialog-close .icon {
  width: 16px;
  height: 16px;
}

.qa-dialog-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--c-text);
}

.qa-dialog-sub {
  margin: 0 0 14px;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--c-text-dim);
}

.qa-dialog-input {
  width: 100%;
  margin-bottom: 16px;
  padding: 11px 12px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  background: var(--c-panel);
  color: var(--c-text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.qa-dialog-input:focus {
  border-color: rgba(139, 92, 246, 0.45);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.qa-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.qa-dialog-btn {
  padding: 9px 14px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  background: var(--c-panel);
  color: var(--c-text-dim);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.qa-dialog-btn:hover {
  background: var(--c-panel-hover);
  color: var(--c-text);
}

.qa-dialog-btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(6, 182, 212, 0.85));
  color: #fff;
  font-weight: 600;
}

.qa-dialog-btn.primary:hover {
  filter: brightness(1.05);
}

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

.sidebar-streak-card {
  margin: 0 10px 12px;
  padding: 10px 12px;
}

.sidebar-wrongbook {
  margin: 0 10px 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--c-panel);
  border: 1px solid var(--c-border);
}

.wrongbook-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--c-text-dim);
  margin-bottom: 8px;
}

.wrongbook-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  margin-bottom: 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--c-text);
  font-size: 0.8rem;
  cursor: pointer;
}

.wrongbook-item:hover {
  background: var(--c-panel-hover);
}

.wrongbook-q {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mindmap-artifact {
  margin-top: 8px;
}

.mindmap-tree {
  margin: 12px 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--c-panel);
  border: 1px solid var(--c-border);
}

.mind-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.mind-topic-btn {
  border: none;
  background: transparent;
  padding: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.mind-status-dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-text-dim);
}

.mind-node.status-green .mind-status-dot { background: #22c55e; }
.mind-node.status-yellow .mind-status-dot { background: #eab308; }
.mind-node.status-red .mind-status-dot { background: #ef4444; }

.mind-label {
  flex: 1;
  font-size: 0.9rem;
  padding: 4px 6px;
  border-radius: 6px;
  outline: none;
}

.mind-label:focus {
  background: var(--c-panel-hover);
}

.mind-node-btn {
  border: 1px solid var(--c-border);
  background: transparent;
  color: var(--c-text-dim);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.mindmap-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.material-summary {
  opacity: 0.9;
}

.usage-warn a {
  color: var(--g1, #8b5cf6);
}

/* Sidebar credits */
.sidebar-credits {
  margin: 10px 12px 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: var(--c-panel);
}
.sidebar-credits.is-empty { border-color: rgba(248, 113, 113, 0.45); }
.credits-head { display: flex; justify-content: space-between; font-size: 0.875rem; margin-bottom: 8px; }
.credits-label { font-weight: 600; color: var(--c-text-dim); }
.credits-value { font-variant-numeric: tabular-nums; }
.credits-bar { height: 4px; border-radius: 999px; background: var(--c-panel-active); overflow: hidden; }
.credits-bar-fill { height: 100%; background: linear-gradient(90deg, var(--g1), var(--g3)); transition: width 0.3s var(--ease); }
.credits-bar-fill.is-low { background: var(--bad); }
.credits-reset { margin: 6px 0 0; font-size: 0.72rem; color: var(--c-text-faint); }
.credit-toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  z-index: 120;
}
.credit-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Training loop */
.training-loop-artifact { margin-top: 12px; }
.training-loop-head { display: flex; justify-content: space-between; font-size: 0.875rem; color: var(--c-text-dim); margin-bottom: 12px; }
.training-loop-history { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; max-height: 220px; overflow-y: auto; }
.training-history-item { border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 0.875rem; }
.training-loop-active { max-width: 520px; margin: 0 auto 12px; }
.training-loop-active .option-btn.correct { border-left: 3px solid var(--ok); }
.training-loop-active .option-btn.wrong { border-left: 3px solid var(--bad); }
