/* NexA workspace UI v1
   A single presentation layer for the premium blue study workspace.
   Chat behavior remains in nexa-main.css; this file owns layout and polish. */

:root {
  /* Shared base tokens live here so the workspace has one visual owner. */
  --primary: #625BEE;
  --primary-strong: #86A8FF;
  --accent: #625BEE;
  --accent2: #A6A2FF;
  --bg: #F6FAFF;
  --bg2: #F1F3FF;
  --bg3: #EBEDFB;
  --surface: rgba(255,255,255,0.92);
  --surface2: #ffffff;
  --border: rgba(21, 67, 146, 0.10);
  --border2: rgba(21, 67, 146, 0.16);
  --text: #1B2430;
  --text2: #9099A8;
  --text3: #B2B8C3;
  --shadow: 0 16px 46px rgba(21, 61, 135, 0.10);
  --shadow-sm: 0 7px 22px rgba(21, 61, 135, 0.08);
  --glow-primary: 0 14px 34px rgba(98, 91, 238, 0.20);
  --glow-blue: 0 0 36px rgba(98, 91, 238, 0.14);
  --header-h: 72px;
  --workspace-sidebar: 268px;
  --workspace-primary: #625BEE;
  --workspace-primary-deep: #1748B5;
  --workspace-ink: #1B2430;
  --workspace-muted: #9099A8;
  --workspace-soft: #F6FAFF;
  --workspace-line: rgba(38, 43, 93, .10);
  --workspace-line-strong: rgba(38, 43, 93, .16);
  --workspace-card: rgba(255,255,255,.88);
  --workspace-shadow: 0 22px 60px rgba(38, 43, 93, .11);
}

[data-theme="dark"] {
  --bg: #000000;
  --workspace-ink: #FFFFFF;
  --workspace-ink-2: #E2E8F0;
  --workspace-muted: #A0AEC0;
  --workspace-soft: #000000;
  --workspace-line: #1C1C20;
  --workspace-line-strong: #2A2A30;
  --workspace-card: #0A0A0C;
  --workspace-shadow: 0 24px 64px rgba(0, 0, 0, 0.95);
}

.splash {
  background: var(--bg);
}

body {
  color: var(--workspace-ink);
  background:
    radial-gradient(circle at 82% 0%, rgba(112, 202, 255, .22), transparent 29rem),
    radial-gradient(circle at 15% 100%, rgba(191, 229, 255, .36), transparent 34rem),
    var(--workspace-soft);
}

[data-theme="dark"] body {
  color: #FFFFFF;
  background: #000000 !important;
}

[data-theme="dark"] .bg-orb {
  display: none !important;
  opacity: 0 !important;
}

.app {
  isolation: isolate;
}

.app-header {
  height: 74px;
  padding: 0 28px;
  background: rgba(255,255,255,.78);
  border-bottom: 1px solid var(--workspace-line);
  box-shadow: 0 8px 30px rgba(38,43,93,.05);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  flex: 0 0 auto;
}

[data-theme="dark"] .app-header {
  background: #000000 !important;
  border-bottom: 1px solid #1C1C20 !important;
  box-shadow: none !important;
}

.header-left { gap: 12px; }
.header-logo {
  width: 38px;
  height: 38px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 13px;
  box-shadow: 0 8px 22px rgba(98,91,238,.20);
}
.header-logo img { padding: 5px; }
.header-brand { font-size: 19px; color: var(--workspace-ink); }
.header-sub { margin-top: 3px; color: var(--workspace-muted); }
.header-brand span { color: var(--workspace-primary); }
.header-right { gap: 8px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--workspace-muted);
  background: rgba(255,255,255,.68);
  border-color: var(--workspace-line);
}
.icon-btn:hover {
  color: var(--workspace-primary);
  border-color: rgba(98,91,238,.32);
  background: #fff;
}
[data-theme="dark"] .icon-btn {
  color: #F1F5F9;
  background: #1A1D2B;
  border-color: #2E3346;
}
[data-theme="dark"] .icon-btn:hover {
  color: #FFFFFF;
  background: #25293C;
  border-color: rgba(98,91,238,0.5);
}
.profile-btn {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--workspace-primary), #A6A2FF);
  box-shadow: 0 8px 22px rgba(98,91,238,.24);
}

.workspace-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.workspace-sidebar {
  width: var(--workspace-sidebar);
  flex: 0 0 var(--workspace-sidebar);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  height: 100%;
  padding: 18px 14px 14px;
  background: rgba(255,255,255,.70);
  border-right: 1px solid var(--workspace-line);
  overflow: hidden;
}

[data-theme="dark"] .workspace-sidebar {
  background: #000000 !important;
  border-right: 1px solid #1C1C20 !important;
}

.workspace-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}
.workspace-sidebar__mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 34px;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 7px 18px rgba(98,91,238,.16);
}
.workspace-sidebar__mark img { width: 100%; height: 100%; padding: 4px; object-fit: contain; }
.workspace-sidebar__brand strong { display: block; color: var(--workspace-ink); font-size: 14px; letter-spacing: -.02em; }
.workspace-sidebar__brand strong span { color: var(--workspace-primary); }
.workspace-sidebar__brand small { display: block; margin-top: 2px; color: var(--workspace-muted); font-size: 10px; }

.workspace-new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid rgba(98,91,238,.18);
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--workspace-primary), #86A8FF);
  box-shadow: 0 10px 22px rgba(98,91,238,.18);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.workspace-new-chat:hover { transform: translateY(-1px); box-shadow: 0 14px 26px rgba(98,91,238,.24); }
.workspace-new-chat__icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(255,255,255,.20);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}

.workspace-nav,
.workspace-history { display: grid; gap: 5px; }
.workspace-nav__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 7px;
  color: var(--workspace-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.workspace-nav__item,
.workspace-history__item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  color: var(--workspace-muted);
  background: transparent;
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.workspace-nav__item:hover,
.workspace-history__item:hover { color: var(--workspace-ink); background: rgba(98,91,238,.06); }
.workspace-nav__item.is-active {
  color: var(--workspace-primary);
  background: rgba(98,91,238,.10);
  font-weight: 700;
}
.workspace-nav__icon {
  width: 30px;
  color: currentColor;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: -.05em;
  opacity: .9;
}
.workspace-history { padding-top: 2px; }
.workspace-history__count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(98,91,238,.10);
  color: var(--workspace-primary);
  font-size: 10px;
  letter-spacing: 0;
}
.workspace-history__item { min-height: 34px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-sidebar__brand,
.workspace-new-chat {
  flex: 0 0 auto;
}

.workspace-sidebar__content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
}
.workspace-sidebar__content::-webkit-scrollbar { width: 3px; }
.workspace-sidebar__content::-webkit-scrollbar-thumb { background: rgba(98, 91, 238, 0.12); border-radius: 3px; }

.workspace-sidebar__footer { display: grid; gap: 12px; margin-top: auto; flex: 0 0 auto; padding-top: 8px; }
.workspace-plan-card {
  display: grid;
  gap: 6px;
  padding: 15px;
  border: 1px solid rgba(98,91,238,.16);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(226,241,255,.84), rgba(255,255,255,.88));
}
[data-theme="dark"] .workspace-plan-card { background: linear-gradient(145deg, rgba(31,72,150,.34), rgba(255,255,255,.04)); }
.workspace-plan-card__eyebrow { color: var(--workspace-primary); font-size: 8px; font-weight: 800; letter-spacing: .11em; }
.workspace-plan-card strong { color: var(--workspace-ink); font-size: 13px; }
.workspace-plan-card > span:last-child { color: var(--workspace-muted); font-size: 10px; line-height: 1.45; }
.workspace-user {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 5px 6px;
  border: 0;
  border-radius: 12px;
  color: var(--workspace-ink);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.workspace-user:hover { background: rgba(98,91,238,.06); }
.workspace-user__avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, var(--workspace-primary), #A6A2FF); font-size: 12px; font-weight: 800; }
.workspace-user__copy { display: grid; gap: 2px; min-width: 0; flex: 1; }
.workspace-user__copy strong { overflow: hidden; color: var(--workspace-ink); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.workspace-user__copy small { color: var(--workspace-muted); font-size: 10px; }
.workspace-user__arrow { color: var(--workspace-muted); font-size: 15px; }

.main-content {
  width: auto;
  min-width: 0;
  min-height: 0;
  height: auto;
  flex: 1;
  margin: 0;
  padding: 0 28px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-area {
  flex: 1 1 auto;
  min-height: 0;
  width: min(100%, 920px);
  margin: 0 auto;
  padding: clamp(24px, 4vh, 48px) 0 24px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.welcome-state.exam-picker {
  justify-content: flex-start;
}

.welcome-state {
  width: min(100%, 760px);
  min-height: 340px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 54px) 36px;
  border: 1px solid var(--workspace-line);
  border-radius: 26px;
  background: var(--workspace-card);
  box-shadow: var(--workspace-shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  flex: 0 0 auto;
}
.welcome-logo { width: 68px; height: 68px; margin-bottom: 12px; border-radius: 20px; box-shadow: 0 12px 28px rgba(98,91,238,.18); }
.welcome-kicker { color: var(--workspace-primary); }
.welcome-title { color: var(--workspace-ink); }
.welcome-title em { color: var(--workspace-primary); }
.welcome-sub, .welcome-context { color: var(--workspace-muted); }
.welcome-sub strong { color: var(--workspace-primary); }
.welcome-chip,
.suggestion-chip { color: var(--workspace-muted); background: rgba(255,255,255,.76); border-color: var(--workspace-line-strong); box-shadow: 0 6px 18px rgba(38,43,93,.06); }
.welcome-chip:hover,
.suggestion-chip:hover { color: var(--workspace-primary); background: #fff; border-color: rgba(98,91,238,.38); }
[data-theme="dark"] .welcome-chip,
[data-theme="dark"] .suggestion-chip { background: rgba(255,255,255,.06); }
[data-theme="dark"] .welcome-chip:hover,
[data-theme="dark"] .suggestion-chip:hover { background: rgba(255,255,255,.10); }

.prominent-quiz-banner { display: flex; justify-content: center; margin-bottom: 10px; }
.input-island { padding: 10px 11px 9px; border-radius: 18px; background: rgba(255,255,255,.90); border-color: var(--workspace-line-strong); box-shadow: 0 18px 44px rgba(38,43,93,.12); }
[data-theme="dark"] .input-island { background: #0A0A0C !important; border-color: #222226 !important; }
.input-island:focus-within { border-color: rgba(98,91,238,.48); box-shadow: 0 18px 44px rgba(38,43,93,.12), 0 0 0 4px rgba(98,91,238,.08); }
.question-input { color: var(--workspace-ink); font-size: clamp(14.5px, 1.05vw, 17px); }
.question-input::placeholder { color: var(--workspace-muted); }
.input-actions { gap: 6px; }
.input-actions .icon-btn { background: transparent; }
.send-btn { width: 40px; height: 40px; border-radius: 13px; background: linear-gradient(135deg, var(--workspace-primary), #86A8FF); box-shadow: 0 9px 20px rgba(98,91,238,.22); }
.send-btn:hover { box-shadow: 0 12px 26px rgba(98,91,238,.28); }

.msg.user {
  display: flex !important;
  flex-direction: row-reverse !important;
  justify-content: flex-start !important;
  margin-left: auto !important;
  margin-right: 0 !important;
  align-self: flex-end !important;
  width: auto !important;
  max-width: 85% !important;
}
.msg.user .bubble {
  background: linear-gradient(135deg, var(--workspace-primary), #86A8FF);
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 20px rgba(98,91,238,0.3);
  margin-left: auto !important;
}
.ai-text h1,.ai-text h2,.ai-text h3,.ai-text strong { color: var(--workspace-ink); }
.ai-text a,.ai-text em { color: var(--workspace-primary); }

@media (max-width: 1040px) {
  :root { --workspace-sidebar: 236px; }
  .workspace-sidebar { padding-left: 14px; padding-right: 14px; }
  .main-content { padding-left: 22px; padding-right: 22px; }
}

@media (max-width: 820px) {
  .workspace-sidebar { display: none; }
  .app-header { height: 68px; padding: 0 16px; }
  .main-content { padding: 0 14px; }
  .chat-area { padding-top: 24px; }
  .welcome-state { min-height: 0; padding: 30px 20px; border-radius: 22px; }
  .input-footer-wrap { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .question-input { font-size: 16px !important; }
}

@media (max-width: 480px) {
  .header-sub { display: none; }
  .header-brand { font-size: 17px; }
  .header-right { gap: 5px; }
  .icon-btn, .profile-btn { width: 36px; height: 36px; }
  .input-island { margin: 0; }
  .input-actions .quiz-trigger-btn { display: none; }
  .welcome-title { font-size: 28px; }
}


/* Onboarding actions and exam picker */
.welcome-exam-link {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--workspace-primary);
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.welcome-exam-link:hover {
  background: rgba(98,91,238,.08);
  border-color: rgba(98,91,238,.14);
  transform: translateY(-1px);
}
.welcome-exam-link:focus-visible {
  outline: 3px solid rgba(98,91,238,.22);
  outline-offset: 2px;
}
.general-welcome .welcome-sub { max-width: 560px; }
.exam-picker {
  gap: 10px;
  min-height: 0;
}
.exam-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 440px);
  margin: 10px 0 0;
}
.exam-grid .quiz-count-btn { min-height: 40px; }
.exam-other-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(100%, 440px);
  margin-top: 0;
}
.exam-other-input {
  flex: 1;
  min-height: 42px;
  border-radius: 14px;
}
.exam-other-submit {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}
.exam-picker .welcome-exam-link { margin-top: -2px; }
[data-theme="dark"] .exam-grid .quiz-count-btn {
  color: var(--workspace-ink);
  background: rgba(255,255,255,.06);
  border-color: var(--workspace-line-strong);
}
[data-theme="dark"] .exam-grid .quiz-count-btn:hover {
  background: rgba(98,91,238,.12);
}
@media (max-height: 760px) {
  .welcome-state.exam-picker {
    gap: 8px;
    padding: 18px 28px 12px;
  }
  .welcome-state.exam-picker .welcome-logo {
    width: 52px;
    height: 52px;
    margin-bottom: 0;
  }
  .welcome-state.exam-picker .welcome-title { font-size: 28px; }
  .welcome-state.exam-picker .welcome-sub { margin-top: 2px; font-size: 13px; }
  .welcome-state.exam-picker .exam-grid { gap: 7px; margin: 6px 0 0; }
  .welcome-state.exam-picker .exam-grid .quiz-count-btn { min-height: 35px; }
  .welcome-state.exam-picker .exam-other-input,
  .welcome-state.exam-picker .exam-other-submit { min-height: 38px; height: 38px; }
  .welcome-state.exam-picker .exam-other-submit { width: 38px; flex-basis: 38px; }
}


/* Compact saved-exam welcome state */
@media (max-height: 760px) {
  .welcome-state:not(.exam-picker) {
    gap: 12px;
    padding: 22px 28px 16px;
  }
  .welcome-state:not(.exam-picker) .welcome-logo {
    width: 56px;
    height: 56px;
    margin-bottom: 0;
  }
  .welcome-state:not(.exam-picker) .welcome-title { font-size: 30px; }
  .welcome-state:not(.exam-picker) .welcome-sub { margin-top: 4px; }
  .welcome-state:not(.exam-picker) .welcome-context { margin: 4px auto 10px; }
  .welcome-state:not(.exam-picker) .welcome-chips { gap: 7px; }
  .welcome-state:not(.exam-picker) .welcome-chip { padding: 8px 12px; }
  .welcome-state:not(.exam-picker) .welcome-exam-link { margin-top: 0; }
}



.sidebar-toggle-btn { display: inline-grid; place-items: center; }
.sidebar-toggle-btn svg { transition: transform .22s ease; }
.sidebar-scrim { display: none; }

/* ── TRUE PITCH BLACK DARK MODE SURFACES & ACCENTS ── */
[data-theme="dark"] .welcome-state {
  background: #0A0A0C !important;
  border: 1px solid #1C1C20 !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.9) !important;
}

[data-theme="dark"] .msg.ai .bubble {
  background: #0D0D0F !important;
  border: 1px solid #1E1E22 !important;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.8) !important;
  color: #F8FAFC !important;
}

[data-theme="dark"] .ai-text,
[data-theme="dark"] .ai-text p,
[data-theme="dark"] .ai-text li {
  color: #F8FAFC !important;
}

[data-theme="dark"] .input-island {
  background: #0A0A0C !important;
  border: 1px solid #222226 !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.9) !important;
}

[data-theme="dark"] .question-input {
  color: #FFFFFF !important;
}
[data-theme="dark"] .question-input::placeholder {
  color: #94A3B8 !important;
}

[data-theme="dark"] .welcome-chip {
  background: #141418 !important;
  border: 1px solid #22222A !important;
  color: #E2E8F0 !important;
}
[data-theme="dark"] .welcome-chip:hover {
  background: rgba(98, 91, 238, 0.22) !important;
  border-color: rgba(98, 91, 238, 0.45) !important;
  color: #FFFFFF !important;
}

[data-theme="dark"] .workspace-plan-card {
  background: #0A0A0C !important;
  border: 1px solid #1C1C20 !important;
}
[data-theme="dark"] .workspace-plan-card strong {
  color: #FFFFFF !important;
}
[data-theme="dark"] .workspace-plan-card span {
  color: #A0AEC0 !important;
}

/* Hide native scrollbar on inner sidebar content */
.workspace-sidebar__content {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.workspace-sidebar__content::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}
.workspace-sidebar {
  overflow: hidden;
  transition: width .24s ease, flex-basis .24s ease, padding .24s ease, transform .24s ease, opacity .2s ease;
}
.app.sidebar-collapsed { --workspace-sidebar: 0px; }
.app.sidebar-collapsed .workspace-sidebar {
  width: 0;
  flex-basis: 0;
  padding-left: 0;
  padding-right: 0;
  border-right: 0;
  opacity: 0;
  transform: translateX(-20px);
  pointer-events: none;
}


/* Keep the composer in document flow so it cannot cover chat content. */
.input-footer-wrap {
  flex: 0 0 auto;
  width: 100%;
  margin: 0 auto;
  padding: 10px 0 max(20px, env(safe-area-inset-bottom));
  background: transparent;
  z-index: 20;
  pointer-events: auto;
}
.input-footer-wrap .input-island,
.input-footer-wrap .prominent-quiz-banner {
  width: min(100%, 920px);
  margin-left: auto;
  margin-right: auto;
}
.input-footer-wrap .prominent-quiz-banner { margin-bottom: 14px; }
.prominent-quiz-btn {
  width: min(100%, 420px);
  max-width: 420px;
  min-height: 50px;
  padding: 0 22px;
  border: 0;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, #625BEE 0%, #7A78F5 100%);
  box-shadow: 0 14px 30px rgba(98,91,238,.30), 0 0 0 1px rgba(255,255,255,.08) inset;
  letter-spacing: .01em;
}
.prominent-quiz-btn:hover {
  background: linear-gradient(135deg, #86A8FF 0%, #86A8FF 100%);
  box-shadow: 0 17px 34px rgba(98,91,238,.38), 0 0 0 1px rgba(255,255,255,.12) inset;
  transform: translateY(-2px);
}
.prominent-quiz-btn .pq-icon,
.prominent-quiz-btn .pq-text,
.prominent-quiz-btn .pq-arrow { color: #fff; }
.prominent-quiz-btn .pq-icon { font-size: 11px; letter-spacing: .11em; }
.prominent-quiz-btn .pq-arrow { font-size: 17px; }

/* Explicit message colors prevent dark mode from rendering AI copy on dark copy. */
.msg.ai .bubble,
.msg.ai .bubble .ai-text,
.msg.ai .bubble .ai-text p,
.msg.ai .bubble .ai-text li,
.msg.ai .bubble .ai-text td { color: var(--workspace-ink); }
[data-theme="dark"] .msg.ai .bubble,
[data-theme="dark"] .msg.ai .bubble .ai-text,
[data-theme="dark"] .msg.ai .bubble .ai-text p,
[data-theme="dark"] .msg.ai .bubble .ai-text li,
[data-theme="dark"] .msg.ai .bubble .ai-text td { color: #F1F3FF; }
[data-theme="dark"] .msg.ai .bubble .ai-text h1,
[data-theme="dark"] .msg.ai .bubble .ai-text h2,
[data-theme="dark"] .msg.ai .bubble .ai-text h3,
[data-theme="dark"] .msg.ai .bubble .ai-text strong { color: #F4FAFF; }
[data-theme="dark"] .msg.ai .bubble .ai-text a,
[data-theme="dark"] .msg.ai .bubble .ai-text em { color: #A6A2FF; }

@media (max-width: 820px) {
  .sidebar-toggle-btn { display: inline-grid; }
  .workspace-sidebar {
    display: flex;
    position: fixed;
    z-index: 70;
    top: var(--header-h);
    bottom: 0;
    left: 0;
    width: min(300px, 86vw);
    flex: 0 0 min(300px, 86vw);
    padding: 22px 16px 18px;
    overflow-y: auto;
    background: rgba(255,255,255,.96);
    box-shadow: 20px 0 50px rgba(40,18,18,.18);
    transform: translateX(-105%);
    opacity: 0;
    pointer-events: none;
  }
  [data-theme="dark"] .workspace-sidebar { background: rgba(25,16,18,.98); }
  .app.sidebar-open .workspace-sidebar {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar-scrim {
    display: block;
    position: fixed;
    z-index: 60;
    inset: var(--header-h) 0 0;
    width: 100%;
    border: 0;
    background: rgba(17,21,42,.84);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity .24s ease;
  }
  .app.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }
  .input-footer-wrap {
    left: 0;
    padding-left: 14px;
    padding-right: 14px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .input-footer-wrap .input-island,
  .input-footer-wrap .prominent-quiz-banner { width: 100%; }
  .prominent-quiz-btn { min-height: 48px; border-radius: 16px; }
}


/* Dark-mode reaction controls and focus states */
.sidebar-toggle-btn:focus-visible,
.workspace-nav__item:focus-visible,
.workspace-new-chat:focus-visible,
.workspace-history__item:focus-visible,
.workspace-user:focus-visible,
.prominent-quiz-btn:focus-visible {
  outline: 3px solid rgba(104,196,255,.62);
  outline-offset: 2px;
}
[data-theme="dark"] .msg.ai .chat-timestamp { color: #9CAFD0; }
[data-theme="dark"] .msg.ai .reaction-bar { border-top-color: rgba(255,255,255,.14); }
[data-theme="dark"] .msg.ai .reaction-bar button { color: #D9E7FF; }
[data-theme="dark"] .msg.ai .reaction-bar button:hover { color: #F4FAFF; background: rgba(255,255,255,.09); }

/* Accessible controls and compact utility variants. */
.sr-file-input,
.hidden-utility { display: none !important; }

.drawer-section-title--actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ref-copy-btn--compact {
  padding: 4px 10px;
  font-size: 11px;
}

.icon-btn:focus-visible,
.profile-btn:focus-visible,
.send-btn:focus-visible,
.setting-btn:focus-visible,
.ref-copy-btn:focus-visible,
.logout-btn:focus-visible,
.quiz-count-btn:focus-visible,
.quiz-diff-btn:focus-visible,
.start-quiz-btn:focus-visible,
.quiz-option:focus-visible,
.welcome-chip:focus-visible,
.suggestion-chip:focus-visible,
.drawer-close-btn:focus-visible {
  outline: 3px solid rgba(98,91,238,.34);
  outline-offset: 3px;
}

[data-theme="dark"] .icon-btn:focus-visible,
[data-theme="dark"] .profile-btn:focus-visible,
[data-theme="dark"] .send-btn:focus-visible,
[data-theme="dark"] .setting-btn:focus-visible,
[data-theme="dark"] .ref-copy-btn:focus-visible,
[data-theme="dark"] .logout-btn:focus-visible,
[data-theme="dark"] .quiz-count-btn:focus-visible,
[data-theme="dark"] .quiz-diff-btn:focus-visible,
[data-theme="dark"] .start-quiz-btn:focus-visible,
[data-theme="dark"] .quiz-option:focus-visible,
[data-theme="dark"] .welcome-chip:focus-visible,
[data-theme="dark"] .suggestion-chip:focus-visible,
[data-theme="dark"] .drawer-close-btn:focus-visible {
  outline-color: rgba(104,196,255,.72);
}

@media (prefers-reduced-motion: reduce) {
  .workspace-sidebar,
  .sidebar-scrim,
  .sidebar-toggle-btn svg,
  .welcome-exam-link,
  .prominent-quiz-btn,
  .icon-btn,
  .profile-btn,
  .send-btn {
    transition: none !important;
  }
}
/* End of NexA Workspace Core Styles */
[data-theme="dark"] body {
  background: radial-gradient(circle at 88% 0%, rgba(129,124,255,.16), transparent 28rem), #11152A;
}

.app-header {
  height: 72px;
  padding: 0 30px;
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid #EAECF2;
  box-shadow: 0 5px 20px rgba(38,43,93,.04);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
[data-theme="dark"] .app-header {
  background: rgba(17,21,42,.96);
  border-bottom-color: rgba(255,255,255,.09);
  box-shadow: 0 5px 20px rgba(0,0,0,.16);
}
.header-left { gap: 12px; }
.header-logo {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  box-shadow: 0 8px 22px rgba(98,91,238,.14);
}
.header-brand { font-size: 19px; font-weight: 800; letter-spacing: -.035em; }
.header-sub { font-size: 10px; color: var(--workspace-muted); }
.header-right { gap: 8px; }
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--workspace-muted);
  background: #FFFFFF;
  border-color: #E7E9F0;
}
.icon-btn:hover {
  color: var(--workspace-primary);
  border-color: rgba(98,91,238,.30);
  background: #F5F3FF;
}
.profile-btn {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #625BEE, #86A8FF);
  box-shadow: 0 8px 22px rgba(98,91,238,.20);
}
[data-theme="dark"] .icon-btn,
[data-theme="dark"] .profile-btn { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.12); }
[data-theme="dark"] .icon-btn:hover { background: rgba(129,124,255,.14); }

.workspace-sidebar {
  width: 280px;
  flex-basis: 280px;
  gap: 25px;
  padding: 28px 18px 18px;
  background: rgba(252,252,255,.96);
  border-right: 1px solid #EAECF2;
}
[data-theme="dark"] .workspace-sidebar { background: #000000 !important; border-right-color: #1C1C20 !important; }
.workspace-sidebar__brand { padding: 0 7px; }
.workspace-sidebar__brand strong { font-size: 15px; letter-spacing: -.03em; }
.workspace-sidebar__brand small { font-size: 10px; }
.workspace-sidebar__mark {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  border-radius: 11px;
  box-shadow: 0 7px 18px rgba(98,91,238,.13);
}
.workspace-new-chat {
  min-height: 48px;
  border: 0;
  border-radius: 15px;
  padding: 0 14px;
  background: linear-gradient(135deg, #625BEE, #7E9CF8);
  box-shadow: 0 10px 24px rgba(98,91,238,.18);
  font-size: 13px;
}
.workspace-new-chat:hover { box-shadow: 0 14px 28px rgba(98,91,238,.24); }
.workspace-new-chat__icon { background: rgba(255,255,255,.20); }
.workspace-nav, .workspace-history { gap: 6px; }
.workspace-nav__label { padding: 0 10px 8px; font-size: 10px; letter-spacing: .13em; }
.workspace-nav__item, .workspace-history__item {
  min-height: 40px;
  border-radius: 12px;
  color: #8D96A5;
}
.workspace-nav__item:hover, .workspace-history__item:hover { color: var(--workspace-ink); background: #F3F2FF; }
.workspace-nav__item.is-active {
  color: var(--workspace-primary);
  background: #F0EFFF;
  font-weight: 750;
}
.workspace-nav__icon { width: 31px; color: currentColor; }
.workspace-history__item.is-current { background: #FFFFFF; box-shadow: 0 7px 18px rgba(38,43,93,.06); }
[data-theme="dark"] .workspace-nav__item:hover,
[data-theme="dark"] .workspace-history__item:hover { background: rgba(255,255,255,.08); color: #FFFFFF; }
[data-theme="dark"] .workspace-nav__item.is-active { background: rgba(99,102,241,.20); color: #818CF8; border: 1px solid rgba(99,102,241,.30); }
[data-theme="dark"] .workspace-history__item.is-current { background: rgba(255,255,255,.10); color: #FFFFFF; }
.workspace-plan-card {
  border-radius: 18px;
  padding: 17px 16px;
  background: linear-gradient(145deg, #F3F1FF, #FFFFFF);
  border: 1px solid #E5E1FF;
  box-shadow: 0 10px 22px rgba(38,43,93,.05);
}
.workspace-plan-card__eyebrow { color: var(--workspace-primary); }
[data-theme="dark"] .workspace-plan-card { background: #0A0A0C !important; border-color: #1C1C20 !important; }
.workspace-user { border-radius: 13px; }
.workspace-user:hover { background: #F3F2FF; }
.workspace-user__avatar { background: linear-gradient(135deg, #625BEE, #86A8FF); }
[data-theme="dark"] .workspace-user:hover { background: rgba(255,255,255,.08); }

.main-content { padding: 0 34px; }
.chat-area {
  width: min(100%, 960px);
  padding: clamp(28px, 5vh, 56px) 0 30px;
}
.welcome-state {
  width: min(100%, 860px);
  min-height: 360px;
  padding: clamp(34px, 5vw, 54px) 42px;
  border: 1px solid #E8E9F1;
  border-radius: 25px;
  background: #FFFFFF;
  box-shadow: 0 18px 46px rgba(38,43,93,.08);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.welcome-logo { width: 72px; height: 72px; border-radius: 21px; box-shadow: 0 12px 28px rgba(98,91,238,.14); }
.welcome-kicker { color: var(--workspace-primary); font-size: 11px; letter-spacing: .16em; }
.welcome-title { color: var(--workspace-ink); font-size: clamp(30px, 5vw, 38px); letter-spacing: -.045em; }
.welcome-title em { color: var(--workspace-primary); }
.welcome-sub, .welcome-context { color: var(--workspace-muted); }
.welcome-sub strong { color: var(--workspace-primary); }
.welcome-chip, .suggestion-chip {
  color: #737C8C;
  background: #F4F3FF;
  border-color: #E5E2FF;
  border-radius: 999px;
  box-shadow: none;
}
.welcome-chip:hover, .suggestion-chip:hover { color: var(--workspace-primary); background: #EEECFF; border-color: #CBC6FF; }
[data-theme="dark"] .welcome-state { background: #0A0A0C !important; border-color: #1C1C20 !important; box-shadow: 0 20px 56px rgba(0,0,0,.9) !important; }
[data-theme="dark"] .welcome-chip, [data-theme="dark"] .suggestion-chip { background: #141418 !important; border-color: #22222A !important; color: #E2E8F0 !important; }
[data-theme="dark"] .welcome-chip:hover, [data-theme="dark"] .suggestion-chip:hover { background: rgba(98,91,238,.25) !important; border-color: rgba(98,91,238,.5) !important; color: #FFFFFF !important; }

.prominent-quiz-banner { margin-bottom: 12px; padding-top: 6px; }
.prominent-quiz-btn {
  width: min(100%, 430px);
  min-height: 54px;
  padding: 12px 20px;
  border: 0;
  border-radius: 17px;
  color: #FFFFFF;
  background: linear-gradient(135deg, #625BEE, #7E9CF8);
  box-shadow: 0 12px 26px rgba(98,91,238,.20);
}
.prominent-quiz-btn:hover { color: #FFFFFF; background: linear-gradient(135deg, #544CE5, #7191F1); border-color: transparent; box-shadow: 0 15px 30px rgba(98,91,238,.25); }
.pq-text { color: #FFFFFF; }
.pq-arrow { color: #FFFFFF; }
.input-footer-wrap { width: min(100%, 960px); padding: 0 0 max(24px, env(safe-area-inset-bottom)); }
.input-island {
  margin: 0;
  padding: 10px 11px 9px;
  border-radius: 18px;
  background: #FFFFFF;
  border-color: #E4E6EE;
  box-shadow: 0 16px 38px rgba(38,43,93,.10);
}
.input-island:focus-within { border-color: rgba(98,91,238,.42); box-shadow: 0 16px 38px rgba(38,43,93,.10), 0 0 0 4px rgba(98,91,238,.08); }
[data-theme="dark"] .input-island { background: #0A0A0C !important; border-color: #222226 !important; }
.send-btn { background: linear-gradient(135deg, #625BEE, #7E9CF8); box-shadow: 0 9px 20px rgba(98,91,238,.22); }
.send-btn:hover { box-shadow: 0 12px 26px rgba(98,91,238,.30); }
.input-actions .icon-btn { background: transparent; border-color: #E7E9F0; }
[data-theme="dark"] .input-actions .icon-btn { border-color: rgba(255,255,255,.18); }
.msg.ai .bubble { background: #FFFFFF; border-color: #E8E9F1; box-shadow: 0 9px 24px rgba(38,43,93,.06); }
.msg.user .bubble { background: linear-gradient(135deg, #625BEE, #7E9CF8); }
.ai-text h1, .ai-text h2, .ai-text h3, .ai-text strong { color: var(--workspace-ink); }
.ai-text a, .ai-text em { color: var(--workspace-primary); }
[data-theme="dark"] .msg.ai .bubble { background: #0D0D0F !important; border-color: #1E1E22 !important; color: #FFFFFF !important; }

/* ── HIGH-VISIBILITY WAVE TYPING ANIMATION IN WORKSPACE ── */
.typing-indicator .bubble {
  padding: 12px 18px !important;
  min-height: 40px !important;
  display: inline-flex !important;
  align-items: center !important;
}

.typing-dots {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  min-height: 24px !important;
  min-width: 48px !important;
  padding: 4px 6px !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.typing-dots span {
  width: 9px !important;
  height: 9px !important;
  border-radius: 50% !important;
  background: #818CF8 !important;
  box-shadow: 0 0 10px rgba(129, 124, 255, 0.95), 0 0 4px #FFFFFF !important;
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  animation: wavePulse 1.0s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite !important;
  will-change: transform, opacity, background-color !important;
}

[data-theme="light"] .typing-dots span {
  background: #625BEE !important;
  box-shadow: 0 0 8px rgba(98, 91, 238, 0.6) !important;
}

.typing-dots span:nth-child(1) { animation-delay: 0s !important; }
.typing-dots span:nth-child(2) { animation-delay: 0.16s !important; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s !important; }

.modal-overlay { background: rgba(0,0,0,.75); backdrop-filter: blur(8px); }
.quiz-setup-card, .report-card {
  background: #FFFFFF;
  border-color: #E7E8F0;
  box-shadow: 0 25px 70px rgba(38,43,93,.18);
}
.quiz-setup-header h2, .quiz-question { color: #1B2430; }
.quiz-field input, .quiz-field textarea, .quiz-count-btn, .quiz-diff-btn, .quiz-option {
  background: #F8F9FC;
  border-color: #E4E6EE;
  color: #1B2430;
}
.quiz-count-btn:hover, .quiz-diff-btn:hover, .quiz-option:hover:not(.answered) { background: #F1F0FF; border-color: #CFCBFF; color: #1B2430; }
.quiz-count-btn--active, .quiz-diff-btn--active { background: #F0EFFF; border-color: #AAA5FF; color: #5A52D8; }
.start-quiz-btn, #submitReportBtn { background: linear-gradient(135deg, #625BEE, #7E9CF8); box-shadow: 0 10px 24px rgba(98,91,238,.20); }
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.85); }
[data-theme="dark"] .quiz-setup-card, [data-theme="dark"] .report-card { background: #0A0A0C !important; border-color: #1C1C20 !important; }
[data-theme="dark"] .quiz-setup-header h2, [data-theme="dark"] .quiz-question { color: #FFFFFF !important; }
[data-theme="dark"] .quiz-field input, [data-theme="dark"] .quiz-field textarea, [data-theme="dark"] .quiz-count-btn, [data-theme="dark"] .quiz-diff-btn, [data-theme="dark"] .quiz-option { background: #141418 !important; border-color: #22222A !important; color: #FFFFFF !important; }

@media (max-width: 820px) {
  .main-content { padding: 0 16px; }
  .chat-area { padding-top: 24px; }
  .welcome-state { padding: 30px 22px; border-radius: 22px; }
  .input-footer-wrap { width: 100%; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

/* Workspace icon system */
.workspace-new-chat__icon .nexa-icon{width:15px;height:15px}
.workspace-nav__icon[data-icon]{display:inline-flex;align-items:center;justify-content:flex-start}
.workspace-nav__icon .nexa-icon{width:17px;height:17px}
.pq-icon .nexa-icon,.pq-arrow .nexa-icon,.setting-icon .nexa-icon,.workspace-user__arrow .nexa-icon{width:17px;height:17px}

/* Profile drawer styles managed by master drawer system at end of file */


/* Mobile responsive drawer */
@media (max-width: 520px) {
  .profile-drawer {
    width: 100%;
    border-left: none;
  }
}
[data-theme="dark"] .streak-fire { background: rgba(245,158,11,.18); color: #FCD34D; }
[data-theme="dark"] .streak-copy strong { color: #FFE7A3; }
[data-theme="dark"] .streak-copy > span, [data-theme="dark"] .streak-best { color: #D8B96A; }
[data-theme="dark"] .bookmark-item {
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.10);
}
[data-theme="dark"] .bookmark-item:hover { background: rgba(129,124,255,.12); }
[data-theme="dark"] .bookmark-text { color: #AEB6CA; }
[data-theme="dark"] .bookmark-time { color: #7F8AA5; }
[data-theme="dark"] .bookmark-del { color: #9BA6BE; }
@media (max-width: 520px) {
  .profile-drawer { width: min(100%, 420px); }
  .drawer-header, .drawer-section { padding-left: 20px; padding-right: 20px; }
  .drawer-footer { padding-left: 20px; padding-right: 20px; }
}

/* Study planner workspace */
.planner-panel {
  width: min(100%, 1040px);
  height: 100%;
  margin: 0 auto;
  overflow-y: auto;
  padding: clamp(24px, 4vw, 48px) 0 36px;
  scrollbar-width: thin;
}
.planner-panel__header { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 22px; }
.planner-auth-prompt { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 18px; padding: 18px 20px; border: 1px solid #DCD9FF; border-radius: 17px; background: #F7F6FF; color: #3B4160; }
.planner-auth-prompt > .nexa-icon { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 2px; color: #625BEE; }
.planner-auth-prompt strong { display: block; margin-bottom: 4px; font-size: 14px; }
.planner-auth-prompt p { margin: 0 0 10px; color: #7C879A; font-size: 13px; line-height: 1.5; }
.planner-auth-prompt a { color: #625BEE; font-size: 13px; font-weight: 750; text-decoration: none; }
.planner-auth-prompt a:hover { text-decoration: underline; }
.planner-eyebrow, .planner-step { display: block; color: #625BEE; font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.planner-panel__header h2 { max-width: 700px; margin: 7px 0 8px; color: #20263A; font-size: clamp(26px, 4vw, 40px); line-height: 1.08; letter-spacing: -.04em; }
.planner-panel__header p, .planner-card__heading p, .planner-form__footer p, .planner-diagnostic-body > p { margin: 0; color: #7C879A; font-size: 14px; line-height: 1.55; }
.planner-icon-button { display: inline-flex; width: 42px; height: 42px; flex: 0 0 auto; align-items: center; justify-content: center; border: 1px solid #E4E6EE; border-radius: 13px; background: #FFFFFF; color: #69758A; cursor: pointer; }
.planner-icon-button:hover { border-color: #B8B4FF; color: #625BEE; }
.planner-icon-button .nexa-icon { width: 18px; height: 18px; }
.planner-card { padding: clamp(20px, 3vw, 30px); border: 1px solid #E5E7EF; border-radius: 22px; background: rgba(255,255,255,.9); box-shadow: 0 18px 44px rgba(38,43,93,.07); }
.planner-card + .planner-card { margin-top: 18px; }
.planner-card__heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 22px; }
.planner-card__heading h3 { margin: 5px 0 7px; color: #252B3D; font-size: 21px; letter-spacing: -.025em; }
.planner-card__icon { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; border-radius: 13px; background: #F0EFFF; color: #625BEE; }
.planner-card__icon .nexa-icon { width: 20px; height: 20px; }
.planner-form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.planner-field { display: grid; gap: 7px; color: #59657A; font-size: 12px; font-weight: 700; }
.planner-field--wide { grid-column: 1 / -1; }
.planner-field small { color: #98A2B2; font-weight: 500; }
.planner-field input, .planner-field select { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid #DDE1EB; border-radius: 12px; background: #FBFCFE; color: #232A3B; font: inherit; font-weight: 500; outline: none; }
.planner-field input:focus, .planner-field select:focus { border-color: #817CFF; box-shadow: 0 0 0 3px rgba(98,91,238,.12); }
.planner-days { margin: 20px 0 0; padding: 0; border: 0; }
.planner-days legend { margin-bottom: 10px; color: #59657A; font-size: 12px; font-weight: 700; }
.planner-days__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.planner-days__grid label { display: flex; min-height: 42px; align-items: center; justify-content: center; gap: 7px; border: 1px solid #E1E4ED; border-radius: 11px; color: #69758A; cursor: pointer; font-size: 12px; font-weight: 700; }
.planner-days__grid label:has(input:checked) { border-color: #B8B4FF; background: #F1F0FF; color: #625BEE; }
.planner-days__grid input { accent-color: #625BEE; }
.planner-form__footer { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 22px; }
.planner-form__footer p { max-width: 500px; font-size: 12px; }
.planner-primary-button, .planner-secondary-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 9px; padding: 0 17px; border-radius: 12px; cursor: pointer; font: inherit; font-weight: 750; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.planner-primary-button { border: 1px solid #625BEE; background: #625BEE; color: #FFFFFF; box-shadow: 0 10px 22px rgba(98,91,238,.22); }
.planner-primary-button:hover:not(:disabled) { transform: translateY(-1px); background: #5149DF; box-shadow: 0 13px 26px rgba(98,91,238,.28); }
.planner-secondary-button { border: 1px solid #D9DCEA; background: #FFFFFF; color: #625BEE; font-size: 12px; }
.planner-secondary-button:hover:not(:disabled) { border-color: #B8B4FF; background: #F7F6FF; }
.planner-primary-button:disabled, .planner-secondary-button:disabled { opacity: .55; cursor: wait; }
.planner-primary-button .nexa-icon, .planner-secondary-button .nexa-icon { width: 16px; height: 16px; }
.planner-diagnostic-body { display: grid; gap: 14px; }
.planner-question-card { padding: 17px; border: 1px solid #E6E8F0; border-radius: 15px; background: #FBFCFF; }
.planner-question-card__meta { color: #625BEE; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.planner-question-card h4 { margin: 9px 0 15px; color: #252B3D; font-size: 16px; line-height: 1.45; }
.planner-question-options { display: grid; gap: 8px; }
.planner-option-button { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 11px 13px; border: 1px solid #E0E3EC; border-radius: 11px; background: #FFFFFF; color: #59657A; cursor: pointer; text-align: left; font: inherit; font-size: 13px; line-height: 1.4; }
.planner-option-button:hover:not(:disabled) { border-color: #AAA6FF; background: #F6F5FF; }
.planner-option-button.is-selected { border-color: #625BEE; background: #F0EFFF; color: #4039BD; }
.planner-option-button:disabled { cursor: default; }
.planner-option-button strong { color: #625BEE; }
.planner-task-list { display: grid; gap: 10px; }
.planner-task-item { display: flex; align-items: center; gap: 13px; padding: 15px; border: 1px solid #E6E8F0; border-radius: 15px; background: #FBFCFF; }
.planner-task-item__icon { display: inline-flex; width: 36px; height: 36px; flex: 0 0 auto; align-items: center; justify-content: center; border-radius: 11px; background: #F0EFFF; color: #625BEE; font-size: 11px; font-weight: 850; letter-spacing: .04em; }
.planner-task-item__copy { min-width: 0; }
.planner-task-item h4 { margin: 0 0 4px; color: #252B3D; font-size: 14px; line-height: 1.35; }
.planner-task-item p { margin: 0; color: #8A95A6; font-size: 12px; text-transform: capitalize; }
.planner-task-actions { display: flex; gap: 7px; flex: 0 0 auto; align-items: center; }
.planner-task-action { display: inline-flex; min-height: 30px; align-items: center; gap: 5px; padding: 0 9px; border: 1px solid #D9DCEA; border-radius: 9px; background: #FFFFFF; color: #625BEE; cursor: pointer; font: inherit; font-size: 11px; font-weight: 750; }
.planner-task-action:hover:not(:disabled) { border-color: #B8B4FF; background: #F7F6FF; }
.planner-task-action:disabled { opacity: .55; cursor: wait; }
.planner-task-action .nexa-icon { width: 13px; height: 13px; }
.planner-task-status { flex: 0 0 auto; color: #7C879A; font-size: 11px; font-weight: 700; text-transform: capitalize; }
.planner-empty-state { padding: 24px 0; color: #8A95A6; text-align: center; font-size: 14px; }
[data-theme="dark"] .planner-auth-prompt { border-color: rgba(129,124,255,.35); background: rgba(129,124,255,.10); color: #F1F3FF; }
[data-theme="dark"] .planner-auth-prompt p { color: #AEB6CA; }
[data-theme="dark"] .planner-panel__header h2, [data-theme="dark"] .planner-card__heading h3, [data-theme="dark"] .planner-question-card h4, [data-theme="dark"] .planner-task-item h4 { color: #F1F3FF; }
[data-theme="dark"] .planner-panel__header p, [data-theme="dark"] .planner-card__heading p, [data-theme="dark"] .planner-form__footer p, [data-theme="dark"] .planner-diagnostic-body > p, [data-theme="dark"] .planner-field, [data-theme="dark"] .planner-days legend { color: #AEB6CA; }
[data-theme="dark"] .planner-card, [data-theme="dark"] .planner-field input, [data-theme="dark"] .planner-field select, [data-theme="dark"] .planner-question-card, [data-theme="dark"] .planner-option-button, [data-theme="dark"] .planner-task-item, [data-theme="dark"] .planner-icon-button, [data-theme="dark"] .planner-secondary-button { border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.045); color: #D6DCEC; }
[data-theme="dark"] .planner-days__grid label { border-color: rgba(255,255,255,.13); color: #AEB6CA; }
[data-theme="dark"] .planner-days__grid label:has(input:checked), [data-theme="dark"] .planner-option-button.is-selected { border-color: rgba(129,124,255,.72); background: rgba(129,124,255,.16); color: #C6C3FF; }
[data-theme="dark"] .planner-option-button:hover:not(:disabled), [data-theme="dark"] .planner-secondary-button:hover:not(:disabled), [data-theme="dark"] .planner-task-action:hover:not(:disabled) { border-color: rgba(129,124,255,.6); background: rgba(129,124,255,.12); }
[data-theme="dark"] .planner-task-action { border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.05); color: #C6C3FF; }
@media (max-width: 720px) {
  .planner-panel { padding-top: 22px; }
  .planner-form__grid { grid-template-columns: 1fr; }
  .planner-field--wide { grid-column: auto; }
  .planner-days__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .planner-form__footer { align-items: stretch; flex-direction: column; }
  .planner-primary-button, .planner-secondary-button { width: 100%; }
}
@media (max-width: 440px) {
  .planner-panel__header h2 { font-size: 27px; }
  .planner-card { padding: 18px; border-radius: 18px; }
  .planner-days__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Planner surfaces: one coherent navigation model across day, week, month, and progress. */
.planner-view-tabs { display: flex; gap: 7px; margin: -2px 0 22px; padding: 4px; overflow-x: auto; border: 1px solid #E6E8F0; border-radius: 14px; background: #F7F8FC; scrollbar-width: none; }
.planner-view-tabs::-webkit-scrollbar { display: none; }
.planner-view-tab { display: inline-flex; min-height: 36px; flex: 1 0 auto; align-items: center; justify-content: center; gap: 7px; padding: 0 13px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: #7C879A; cursor: pointer; font: inherit; font-size: 12px; font-weight: 750; white-space: nowrap; }
.planner-view-tab:hover { color: #625BEE; }
.planner-view-tab.is-active { border-color: #DDD9FF; background: #FFFFFF; color: #4F49D5; box-shadow: 0 3px 10px rgba(38,43,93,.06); }
.planner-view-tab .nexa-icon { width: 15px; height: 15px; }
.planner-view-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.planner-view-heading h4 { margin: 5px 0 5px; color: #252B3D; font-size: 17px; letter-spacing: -.02em; }
.planner-view-heading p { margin: 0; color: #8A95A6; font-size: 12px; line-height: 1.5; }
.planner-view-note { color: #8A95A6; font-size: 12px; white-space: nowrap; }
.planner-week-subjects { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; padding: 13px; border: 1px solid #E7E8F0; border-radius: 14px; background: #FBFCFF; }
.planner-chip-list { display: flex; flex-wrap: wrap; gap: 7px; }
.planner-subject-chip { display: inline-flex; min-height: 32px; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid #DDE1EB; border-radius: 9px; background: #FFFFFF; color: #69758A; cursor: pointer; font: inherit; font-size: 11px; font-weight: 750; }
.planner-subject-chip.is-selected { border-color: #AAA6FF; background: #F0EFFF; color: #5048D6; }
.planner-subject-chip input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.planner-week-task-list { display: grid; gap: 10px; }
.planner-week-day { padding: 12px; border: 1px solid #E7E8F0; border-radius: 14px; background: #FBFCFF; }
.planner-week-day__header { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 9px; color: #59657A; font-size: 12px; font-weight: 800; }
.planner-week-day__header span:last-child { color: #9AA3B2; font-weight: 600; }
.planner-week-day__tasks { display: grid; gap: 6px; }
.planner-week-task { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border-radius: 9px; background: #FFFFFF; color: #69758A; font-size: 12px; }
.planner-week-task strong { color: #252B3D; font-size: 12px; font-weight: 700; }
.planner-week-task small { color: #9AA3B2; white-space: nowrap; }
.planner-month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.planner-month-day-label { padding: 0 3px 3px; color: #9AA3B2; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-align: center; text-transform: uppercase; }
.planner-month-day { min-height: 78px; padding: 8px; border: 1px solid #E9EAF1; border-radius: 10px; background: #FBFCFF; color: #69758A; }
.planner-month-day.is-empty { border-color: transparent; background: transparent; }
.planner-month-day.is-today { border-color: #AAA6FF; box-shadow: 0 0 0 2px rgba(98,91,238,.08); }
.planner-month-day__number { display: flex; align-items: center; justify-content: space-between; color: #59657A; font-size: 11px; font-weight: 800; }
.planner-month-day__count { color: #625BEE; font-size: 10px; }
.planner-month-day__bar { height: 5px; margin-top: 14px; border-radius: 99px; background: #E7E5FF; overflow: hidden; }
.planner-month-day__bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #625BEE, #8B86FF); }
.planner-month-day__meta { display: block; margin-top: 7px; color: #9AA3B2; font-size: 10px; }
.planner-progress-list { display: grid; gap: 9px; }
.planner-progress-row { padding: 13px; border: 1px solid #E7E8F0; border-radius: 13px; background: #FBFCFF; }
.planner-progress-row__top { display: flex; justify-content: space-between; gap: 12px; color: #252B3D; font-size: 12px; font-weight: 750; }
.planner-progress-row__top span:last-child { color: #625BEE; }
.planner-progress-row p { margin: 4px 0 9px; color: #8A95A6; font-size: 11px; }
.planner-progress-bar { height: 7px; border-radius: 99px; background: #EBECF4; overflow: hidden; }
.planner-progress-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #625BEE, #8B86FF); }
.planner-task-item.is-completed { background: #F7FBFA; border-color: #CFECE0; }
.planner-task-item.is-skipped { opacity: .68; }
.planner-task-question { margin: 8px 0 0; color: #625BEE; font-size: 11px; font-weight: 700; }
[data-theme="dark"] .planner-view-tabs, [data-theme="dark"] .planner-week-subjects, [data-theme="dark"] .planner-week-day, [data-theme="dark"] .planner-week-task, [data-theme="dark"] .planner-month-day, [data-theme="dark"] .planner-progress-row { border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.045); }
[data-theme="dark"] .planner-view-tab { color: #AEB6CA; }
[data-theme="dark"] .planner-view-tab.is-active, [data-theme="dark"] .planner-subject-chip.is-selected { border-color: rgba(129,124,255,.65); background: rgba(129,124,255,.16); color: #C6C3FF; }
[data-theme="dark"] .planner-view-heading h4, [data-theme="dark"] .planner-week-day__header, [data-theme="dark"] .planner-week-task strong, [data-theme="dark"] .planner-month-day__number, [data-theme="dark"] .planner-progress-row__top { color: #F1F3FF; }
[data-theme="dark"] .planner-subject-chip, [data-theme="dark"] .planner-week-task { border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.06); color: #D6DCEC; }
[data-theme="dark"] .planner-task-item.is-completed { border-color: rgba(66,190,146,.35); background: rgba(66,190,146,.08); }
@media (max-width: 600px) {
  .planner-week-subjects { align-items: stretch; flex-direction: column; }
  .planner-week-subjects .planner-secondary-button { width: 100%; }
  .planner-month-grid { gap: 4px; }
  .planner-month-day { min-height: 64px; padding: 6px; }
  .planner-month-day__bar { margin-top: 10px; }
  .planner-month-day__meta { display: none; }
}
.planner-question-modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.planner-question-modal.hidden { display: none; }
.planner-question-modal__backdrop { position: absolute; inset: 0; background: rgba(24,28,48,.42); backdrop-filter: blur(5px); }
.planner-question-modal__surface { position: relative; width: min(100%, 620px); max-height: min(720px, 92vh); overflow-y: auto; padding: 24px; border: 1px solid #E2E4EE; border-radius: 20px; background: #FFFFFF; box-shadow: 0 24px 70px rgba(22,27,62,.24); }
.planner-question-modal__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.planner-question-modal__header h3 { margin: 6px 0 0; color: #252B3D; font-size: 21px; letter-spacing: -.025em; }
.planner-question-modal__meta { margin: 20px 0 8px; color: #625BEE; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.planner-question-modal__prompt { margin: 0 0 18px; color: #252B3D; font-size: 16px; line-height: 1.55; }
.planner-question-modal__footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.planner-question-feedback { min-height: 20px; margin-top: 13px; color: #59657A; font-size: 13px; line-height: 1.5; }
.planner-question-feedback.is-correct { color: #15805F; }
.planner-question-feedback.is-incorrect { color: #B54747; }
.planner-task-question { cursor: pointer; }
[data-theme="dark"] .planner-question-modal__surface { border-color: rgba(255,255,255,.14); background: #1C2038; }
[data-theme="dark"] .planner-question-modal__header h3, [data-theme="dark"] .planner-question-modal__prompt { color: #F1F3FF; }
[data-theme="dark"] .planner-question-modal__meta, [data-theme="dark"] .planner-question-feedback { color: #BFC6DA; }
@media (max-width: 520px) { .planner-question-modal__surface { padding: 19px; border-radius: 17px; } .planner-question-modal__footer { flex-direction: column-reverse; } .planner-question-modal__footer button { width: 100%; } }
/* Manual planning keeps student control inside the same validated task system. */
.planner-manual-modal { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 20px; }
.planner-manual-modal.hidden { display: none; }
.planner-manual-modal__backdrop { position: absolute; inset: 0; background: rgba(24,28,48,.46); backdrop-filter: blur(6px); }
.planner-manual-modal__surface { position: relative; width: min(100%, 760px); max-height: min(820px, 92vh); overflow-y: auto; padding: 25px; border: 1px solid #E2E4EE; border-radius: 21px; background: #FFFFFF; box-shadow: 0 24px 70px rgba(22,27,62,.25); }
.planner-manual-modal__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.planner-manual-modal__header h3 { margin: 6px 0 6px; color: #252B3D; font-size: 22px; letter-spacing: -.025em; }
.planner-manual-modal__header p { max-width: 560px; margin: 0; color: #7C879A; font-size: 13px; line-height: 1.5; }
.planner-manual-mode-tabs { display: flex; gap: 6px; margin-bottom: 20px; padding: 4px; border: 1px solid #E6E8F0; border-radius: 13px; background: #F7F8FC; }
.planner-manual-mode-tab { min-height: 36px; flex: 1; border: 1px solid transparent; border-radius: 9px; background: transparent; color: #7C879A; cursor: pointer; font: inherit; font-size: 12px; font-weight: 750; }
.planner-manual-mode-tab:hover { color: #625BEE; }
.planner-manual-mode-tab.is-active { border-color: #DDD9FF; background: #FFFFFF; color: #4F49D5; box-shadow: 0 3px 10px rgba(38,43,93,.06); }
.planner-manual-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.planner-manual-field { display: grid; min-width: 0; gap: 7px; color: #59657A; font-size: 11px; font-weight: 750; }
.planner-manual-field--wide { grid-column: 1 / -1; }
.planner-manual-field small { color: #98A2B2; font-weight: 500; }
.planner-manual-field input, .planner-manual-field select { width: 100%; min-height: 43px; padding: 0 11px; border: 1px solid #DDE1EB; border-radius: 11px; background: #FBFCFE; color: #252B3D; font: inherit; font-size: 12px; font-weight: 500; outline: none; }
.planner-manual-field input:focus, .planner-manual-field select:focus { border-color: #817CFF; box-shadow: 0 0 0 3px rgba(98,91,238,.12); }
.planner-manual-week-start { max-width: 240px; margin-bottom: 16px; }
.planner-manual-week-rows { display: grid; gap: 10px; }
.planner-manual-week-row { display: grid; grid-template-columns: 1.1fr 1fr 1.6fr 1fr .65fr 36px; gap: 8px; align-items: end; padding: 11px; border: 1px solid #E7E8F0; border-radius: 13px; background: #FBFCFF; }
.planner-manual-week-row .planner-manual-field { gap: 5px; font-size: 10px; }
.planner-manual-week-row .planner-manual-field input, .planner-manual-week-row .planner-manual-field select { min-height: 38px; padding: 0 8px; font-size: 11px; }
.planner-manual-remove { width: 36px; height: 38px; min-height: 38px; border-radius: 10px; }
.planner-manual-remove .nexa-icon { width: 15px; height: 15px; }
.planner-manual-add-row { margin-top: 12px; }
.planner-manual-modal__footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; padding-top: 17px; border-top: 1px solid #E8E9F0; }
.planner-manual-modal__footer .planner-primary-button, .planner-manual-modal__footer .planner-secondary-button { min-width: 145px; }
[data-theme="dark"] .planner-manual-modal__surface { border-color: rgba(255,255,255,.14); background: #1C2038; }
[data-theme="dark"] .planner-manual-modal__header h3 { color: #F1F3FF; }
[data-theme="dark"] .planner-manual-modal__header p, [data-theme="dark"] .planner-manual-field { color: #AEB6CA; }
[data-theme="dark"] .planner-manual-mode-tabs, [data-theme="dark"] .planner-manual-week-row { border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.045); }
[data-theme="dark"] .planner-manual-mode-tab { color: #AEB6CA; }
[data-theme="dark"] .planner-manual-mode-tab.is-active { border-color: rgba(129,124,255,.65); background: rgba(129,124,255,.16); color: #C6C3FF; }
[data-theme="dark"] .planner-manual-field input, [data-theme="dark"] .planner-manual-field select { border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: #F1F3FF; }
[data-theme="dark"] .planner-manual-modal__footer { border-color: rgba(255,255,255,.12); }
@media (max-width: 720px) {
  .planner-manual-week-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .planner-manual-week-row .planner-manual-field:nth-child(3) { grid-column: 1 / -1; }
  .planner-manual-remove { align-self: end; }
}
@media (max-width: 520px) {
  .planner-manual-modal { padding: 10px; }
  .planner-manual-modal__surface { padding: 18px; border-radius: 17px; }
  .planner-manual-grid { grid-template-columns: 1fr; }
  .planner-manual-field--wide { grid-column: auto; }
  .planner-manual-modal__footer { flex-direction: column-reverse; }
  .planner-manual-modal__footer button, .planner-manual-add-row { width: 100%; }
}

/* Profile drawer master design system: Dark obsidian surface matching main chat theme */
.profile-drawer {
  width: min(380px, 92vw);
  background: #0A0A0C !important;
  color: #FFFFFF !important;
  border-left: 1px solid #1C1C20 !important;
  box-shadow: -24px 0 70px rgba(0, 0, 0, 0.7) !important;
}

[data-theme="light"] .profile-drawer {
  background: #FFFFFF !important;
  color: #1B2430 !important;
  border-left: 1px solid rgba(0, 0, 0, 0.08) !important;
  box-shadow: -16px 0 50px rgba(0, 0, 0, 0.08) !important;
}

.drawer-header {
  position: relative;
  gap: 14px;
  padding: 22px 20px 18px;
  background: linear-gradient(180deg, rgba(98, 91, 238, 0.09) 0%, transparent 100%) !important;
  border-bottom: 1px solid #1C1C20 !important;
}

[data-theme="light"] .drawer-header {
  background: linear-gradient(180deg, rgba(98, 91, 238, 0.04) 0%, transparent 100%) !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
}

.drawer-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #625BEE, #4F46E5) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: #FFFFFF !important;
  box-shadow: 0 0 20px rgba(98, 91, 238, 0.4) !important;
  border: 2px solid rgba(255, 255, 255, 0.2) !important;
}

.drawer-name {
  font-size: 16px !important;
  font-weight: 700 !important;
  color: #FFFFFF !important;
  letter-spacing: -0.02em !important;
}

[data-theme="light"] .drawer-name {
  color: #1B2430 !important;
}

.drawer-email {
  margin-top: 2px;
  font-size: 12.5px !important;
  color: #A0AEC0 !important;
}

[data-theme="light"] .drawer-email {
  color: #64748B !important;
}

.drawer-type-badge {
  margin-top: 5px;
  padding: 2px 9px;
  border-radius: 8px;
  font-size: 10px !important;
  font-weight: 700 !important;
  background: rgba(98, 91, 238, 0.15) !important;
  color: #8E8BFF !important;
  border: 1px solid rgba(98, 91, 238, 0.3) !important;
  text-transform: uppercase;
  letter-spacing: 0.08em !important;
}

[data-theme="light"] .drawer-type-badge {
  color: #4F46E5 !important;
}

.drawer-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid #1C1C20 !important;
  color: #A0AEC0 !important;
}

[data-theme="light"] .drawer-close-btn {
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  color: #64748B !important;
}

.drawer-close-btn:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  color: #FFFFFF !important;
}

[data-theme="light"] .drawer-close-btn:hover {
  background: rgba(0, 0, 0, 0.08) !important;
  color: #0F172A !important;
}

.streak-banner {
  min-height: 52px;
  margin: 14px 20px 4px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(245, 158, 11, 0.09) !important;
  border: 1px solid rgba(245, 158, 11, 0.2) !important;
  color: #FCD34D !important;
}

[data-theme="light"] .streak-banner {
  background: rgba(245, 158, 11, 0.08) !important;
  border-color: rgba(245, 158, 11, 0.22) !important;
  color: #D97706 !important;
}

.streak-fire {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.2) !important;
  color: #FCD34D !important;
}

[data-theme="light"] .streak-fire {
  background: rgba(245, 158, 11, 0.18) !important;
  color: #D97706 !important;
}

.streak-copy strong {
  font-size: 12.5px !important;
  font-weight: 700 !important;
  color: #FFE7A3 !important;
}

[data-theme="light"] .streak-copy strong {
  color: #92400E !important;
}

.streak-copy > span,
.streak-best {
  font-size: 11px !important;
  color: #D8B96A !important;
}

[data-theme="light"] .streak-copy > span,
[data-theme="light"] .streak-best {
  color: #B45309 !important;
}

.drawer-body {
  padding: 4px 0;
}

.drawer-section {
  padding: 18px 20px 14px;
  border-bottom: 1px solid #1C1C20 !important;
}

[data-theme="light"] .drawer-section {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
}

.drawer-section:last-child {
  border-bottom: none !important;
}

.drawer-section-title {
  margin-bottom: 12px;
  font-family: var(--mono) !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  letter-spacing: 0.14em !important;
  color: #A0AEC0 !important;
  text-transform: uppercase;
}

[data-theme="light"] .drawer-section-title {
  color: #64748B !important;
}

.usage-bar {
  height: 7px !important;
  border-radius: 7px !important;
  background: #1C1C20 !important;
  overflow: hidden;
}

[data-theme="light"] .usage-bar {
  background: rgba(0, 0, 0, 0.08) !important;
}

.usage-bar-fill {
  height: 100% !important;
  border-radius: 7px !important;
  background: linear-gradient(90deg, #625BEE, #8E8BFF) !important;
  box-shadow: 0 0 12px rgba(98, 91, 238, 0.4) !important;
}

.usage-label {
  font-family: var(--mono) !important;
  font-size: 12px !important;
  color: #A0AEC0 !important;
}

[data-theme="light"] .usage-label {
  color: #475569 !important;
}

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

.ref-code {
  flex: 1;
  background: #121216 !important;
  border: 1px solid #2A2A30 !important;
  border-radius: 10px !important;
  padding: 9px 14px;
  font-family: var(--mono) !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  color: #8E8BFF !important;
  letter-spacing: 3px !important;
  text-align: center;
}

[data-theme="light"] .ref-code {
  background: #F1F5F9 !important;
  border-color: #CBD5E1 !important;
  color: #4F46E5 !important;
}

.ref-copy-btn {
  padding: 9px 16px;
  border-radius: 10px !important;
  background: rgba(98, 91, 238, 0.14) !important;
  border: 1px solid rgba(98, 91, 238, 0.28) !important;
  color: #8E8BFF !important;
  font-family: var(--sans) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

[data-theme="light"] .ref-copy-btn {
  background: rgba(98, 91, 238, 0.1) !important;
  border-color: rgba(98, 91, 238, 0.22) !important;
  color: #4F46E5 !important;
}

.ref-copy-btn:hover {
  background: #625BEE !important;
  color: #FFFFFF !important;
  border-color: #625BEE !important;
}

.ref-hint {
  color: #A0AEC0 !important;
  font-size: 11.5px !important;
  margin-top: 6px;
}

[data-theme="light"] .ref-hint {
  color: #64748B !important;
}

.bookmark-empty {
  padding: 12px 14px;
  border: 1px solid #1C1C20 !important;
  border-radius: 12px !important;
  background: #121216 !important;
  color: #A0AEC0 !important;
  font-size: 12.5px !important;
  line-height: 1.5;
  text-align: left;
}

[data-theme="light"] .bookmark-empty {
  background: #F8FAFC !important;
  border-color: #E2E8F0 !important;
  color: #64748B !important;
}

.bookmark-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px !important;
  background: #121216 !important;
  border: 1px solid #1C1C20 !important;
  margin-bottom: 6px;
  transition: all 0.2s ease;
}

[data-theme="light"] .bookmark-item {
  background: #F8FAFC !important;
  border-color: #E2E8F0 !important;
}

.bookmark-item:hover {
  background: rgba(98, 91, 238, 0.08) !important;
  border-color: rgba(98, 91, 238, 0.24) !important;
}

.bookmark-text {
  font-size: 13px !important;
  color: #E2E8F0 !important;
}

[data-theme="light"] .bookmark-text {
  color: #334155 !important;
}

.bookmark-time {
  font-size: 11px !important;
  font-family: var(--mono) !important;
  color: #A0AEC0 !important;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 12px !important;
  font-family: var(--sans) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  color: #E2E8F0 !important;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent !important;
  border: 1px solid transparent !important;
  width: 100%;
  text-align: left;
}

[data-theme="light"] .setting-row {
  color: #334155 !important;
}

.setting-row:hover {
  color: #FFFFFF !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: transparent !important;
}

[data-theme="light"] .setting-row:hover {
  color: #0F172A !important;
  background: #F1F5F9 !important;
}

.setting-icon {
  color: #6B6EF3 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 24px !important;
  background: #2A2A30 !important;
  cursor: pointer;
  transition: background 0.25s ease;
}

[data-theme="light"] .toggle-slider {
  background: #CBD5E1 !important;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  border-radius: 50%;
  left: 3px;
  bottom: 3px;
  background: #FFFFFF !important;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: #625BEE !important;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px) !important;
}

.drawer-footer {
  padding: 16px 20px 20px;
  border-top: 1px solid #1C1C20 !important;
  background: #0A0A0C !important;
}

[data-theme="light"] .drawer-footer {
  background: #FFFFFF !important;
  border-top: 1px solid rgba(0, 0, 0, 0.06) !important;
}

.logout-btn {
  width: 100%;
  padding: 13px;
  min-height: 48px;
  border-radius: 14px !important;
  background: rgba(239, 68, 68, 0.1) !important;
  border: 1px solid rgba(239, 68, 68, 0.22) !important;
  color: #F87171 !important;
  font-family: var(--sans) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

[data-theme="light"] .logout-btn {
  background: rgba(239, 68, 68, 0.08) !important;
  border-color: rgba(239, 68, 68, 0.2) !important;
  color: #EF4444 !important;
}

.logout-btn:hover {
  background: #EF4444 !important;
  color: #FFFFFF !important;
  border-color: #EF4444 !important;
}

@media (max-width: 520px) {
  .profile-drawer { width: 100%; }
  .drawer-header, .drawer-section { padding-left: 20px; padding-right: 20px; }
  .streak-banner { margin-left: 20px; margin-right: 20px; }
  .drawer-footer { padding-left: 20px; padding-right: 20px; }
}

/* Mobile controls keep a comfortable hit area without changing desktop density. */
@media (max-width: 640px) {
  .icon-btn,
  .send-btn,
  .stop-inline-btn,
  .profile-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 12px;
  }
}

/* Final mobile containment layer.
   The base chat stylesheet and workspace presentation layer both define
   mobile spacing. Keep the last responsive rule authoritative so cards,
   quiz messages, and the footer never grow beyond the usable viewport. */
@media (max-width: 640px) {
  .app {
    padding-bottom: 0;
  }

  html,
  body,
  #app,
  .workspace-layout,
  .main-content,
  .chat-area,
  .input-footer-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .main-content {
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
    padding-left: 10px;
    padding-right: 10px;
    overflow: hidden;
  }

  .app-header {
    width: 100%;
    min-width: 0;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    gap: 8px;
  }

  .header-left {
    min-width: 0;
    flex: 1 1 auto;
  }

  .header-titles {
    min-width: 0;
    flex: 1 1 auto;
  }

  .header-brand {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-right {
    flex: 0 0 auto;
  }

  .workspace-layout {
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  .chat-area {
    width: 100%;
    padding: 12px 0 8px;
    gap: 12px;
  }

  .msg,
  .msg.user,
  .quiz-message,
  .bubble {
    min-width: 0;
    max-width: 100%;
  }

  .msg {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 8px;
    margin-bottom: 10px;
  }

  .msg.ai .msg-avatar {
    grid-column: 1;
    grid-row: 1;
  }

  .msg.ai .bubble {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    max-width: 100%;
  }

  .msg.user {
    grid-template-columns: minmax(0, 1fr) 32px;
    flex-direction: initial;
  }

  .msg.user .bubble {
    grid-column: 1;
    grid-row: 1;
    width: fit-content;
    max-width: 100%;
    justify-self: end;
    order: initial;
  }

  .msg.user .msg-avatar {
    grid-column: 2;
    grid-row: 1;
    order: initial;
    margin-left: 0;
  }

  .msg-avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .bubble {
    padding: 12px;
  }

  .welcome-state {
    width: 100%;
    max-width: 100%;
    min-height: 0;
    padding: 24px 16px;
    gap: 16px;
  }

  .welcome-logo {
    width: 60px;
    height: 60px;
    margin-bottom: 2px;
  }

  .welcome-kicker {
    font-size: 10px;
  }

  .welcome-title {
    max-width: 100%;
    font-size: clamp(24px, 7.5vw, 30px);
    line-height: 1.12;
  }

  .welcome-sub,
  .welcome-context {
    max-width: 32ch;
    font-size: 14px;
    line-height: 1.5;
  }

  .welcome-chips {
    width: 100%;
    max-width: 100%;
    gap: 6px;
  }

  .welcome-chip,
  .suggestion-chip {
    max-width: 100%;
    padding: 8px 10px;
    font-size: 12px;
  }

  .quiz-question,
  .quiz-option,
  .ai-text,
  .ai-text p,
  .ai-text li {
    overflow-wrap: anywhere;
  }

  .quiz-question {
    font-size: 16px !important;
    line-height: 1.5;
  }

  .quiz-option {
    width: 100%;
    padding: 12px;
    font-size: 14px;
  }

  .input-footer-wrap {
    flex: 0 0 auto;
    position: relative;
    z-index: 30;
    padding: 8px 10px max(10px, env(safe-area-inset-bottom));
    background: var(--workspace-soft);
  }

  /* Keep the composer in the shell's second flow row. The chat area owns the
     only scrolling region, so response content cannot sit underneath it. */
  .main-content {
    position: relative;
  }

  .chat-area {
    padding-bottom: 12px;
  }

  .input-footer-wrap {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--workspace-line);
    background: var(--workspace-soft);
    background: color-mix(in srgb, var(--workspace-soft) 94%, transparent);
    box-shadow: 0 -12px 28px rgba(38, 43, 93, .10);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  [data-theme="dark"] .input-footer-wrap {
    border-top-color: #1C1C20;
    background: rgba(0, 0, 0, .94);
    box-shadow: 0 -12px 28px rgba(0, 0, 0, .55);
  }

  .input-footer-wrap .prominent-quiz-banner,
  .input-footer-wrap .input-island {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .input-footer-wrap .prominent-quiz-banner {
    padding: 0;
    margin-bottom: 10px;
  }

  .prominent-quiz-btn {
    width: 100%;
    max-width: none;
    min-height: 50px;
    padding: 10px 14px;
  }

  .input-island {
    width: 100%;
    padding: 8px;
  }

  .input-row {
    align-items: center;
    min-height: 44px;
  }

  .input-wrap {
    min-width: 0;
  }

  .question-input {
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    padding: 10px 0;
    line-height: 1.4;
  }

  .input-actions {
    flex: 0 0 auto;
    gap: 5px;
  }
}
