:root {
  --brand: #DF995B;
  --brand-ink: #B36E30;
  --brand-deep: #8C5422;
  --brand-soft: #F6D9B8;
  --sec: #496F82;
  --sec-ink: #2F4E5E;
  --sec-soft: #C9DCE6;
  --bg: #FCEDD0;
  --bg-warm: #F9E4BE;
  --bg-deep: #F4DAAF;
  --surface: #FFFDF8;
  --surface-2: #FAF3E8;
  --ink: #1F2937;
  --ink-2: #4B5563;
  --ink-3: #6B7280;
  --line: rgba(31, 41, 55, .1);
  --line-2: rgba(31, 41, 55, .16);
  --good: #10B981;
  --good-soft: #DDEBD2;
  --bad: #EF4444;
  --bad-soft: #F5D4C4;
  --gold: #F59E0B;
  --blue: #3B82F6;
  --teal: #319795;
  --radius: 12px;
  --radius-card: 20px;
  --radius-btn: 16px;
  --radius-action: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(79, 54, 24, .05), 0 4px 12px -6px rgba(79, 54, 24, .15);
  --shadow-md: 0 4px 12px rgba(79, 54, 24, .06), 0 16px 32px -16px rgba(79, 54, 24, .22);
  --shadow-lg: 0 8px 24px rgba(79, 54, 24, .08), 0 32px 64px -32px rgba(79, 54, 24, .25);
  --paper-edge: rgba(140, 84, 34, .18);
  --subj-physics: #3B82F6;
  --subj-chemistry: #10B981;
  --subj-biology: #14B8A6;
  --subj-math: #8B5CF6;
  --subj-geography: #F59E0B;
  --subj-socials: #E8764A;
  --subj-history: #A0522D;
  --subj-informatics: #5B4FD4;
  --subj-russian: #2B6CB0;
  --subj-literature: #7B5EA7;
  --subj-language: #319795;
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring: cubic-bezier(0.22, 1.0, 0.36, 1);
  --dur-fast: 200ms;
  --dur-smooth: 300ms;
  --dur-slow: 500ms;
  --rail-w: 256px;
  --topbar-h: 76px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --mobile-nav-h: 64px;
  --mobile-nav-radius: 22px;
  --text: var(--ink);
  --muted: var(--ink-3);
  --border: var(--line);
  --bg-soft: var(--bg-warm);
}

[data-theme="dark"] {
  /* Brand palette from design_system.md — warm amber/brown, NO purple */
  --brand: #DF995B;
  --brand-ink: #D4923C;
  --brand-deep: #c47a2e;
  --brand-soft: #3D2A1A;
  --sec: #6A9BB2;
  --sec-ink: #8CBAD3;
  --sec-soft: #1C2C34;
  --bg: #1A1410;
  --bg-warm: #201A14;
  --bg-deep: #141010;
  --surface: #241E17;
  --surface-2: #2E261E;
  --ink: #F5EDE0;
  --ink-2: #B8AFA3;
  --ink-3: #8A8078;
  --line: rgba(245,237,224,.1);
  --line-2: rgba(245,237,224,.16);
  --good: #34D399;
  --good-soft: #1A2E24;
  --bad: #F87171;
  --bad-soft: #3B2020;
  --gold: #FBBF24;
  --blue: #60A5FA;
  --teal: #5EEAD4;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.6);
  --paper-edge: rgba(245,237,224,.08);
  --text: var(--ink);
  --muted: var(--ink-3);
  --border: var(--line);
  --bg-soft: var(--bg-warm);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
}

button,
a,
input,
textarea,
select,
[tabindex]:not([tabindex="-1"]) {
  -webkit-tap-highlight-color: rgba(223, 153, 91, .2);
}

button:focus {
  outline: none;
}

:where(button, a, input, textarea, select, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 3px solid rgba(73, 111, 130, .46);
  outline-offset: 3px;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.h-font,
h1,
h2,
h3,
h4 {
  font-family: "Unbounded", "Manrope", sans-serif;
  letter-spacing: -0.02em;
}

h1 {
  letter-spacing: -0.04em;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

.muted {
  color: var(--ink-3);
}

.top-title,
.auth-copy,
.auth-panel,
.hero-copy,
.panel,
.tile,
.stat-card,
.quick-card,
.item-main,
.message,
.bubble,
.question-text,
.feedback,
.table,
.toast {
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}

.small {
  font-size: .85rem;
}

.tiny {
  font-size: .76rem;
}

.strong {
  font-weight: 800;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 280px;
  text-align: center;
  padding: 28px;
  color: var(--ink-3);
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

:where(.btn, .icon-btn, .nav-item, .badge, .chip, .tag, .source-pill, .item, .tile, .stat-card, .quick-card, .choice, .match-tile, .criterion, .field, textarea, select) {
  min-width: 0;
}

:where(.btn, .nav-item, .choice, .match-tile, .quick-card, .criterion, .table td, .table th) {
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 14px 24px;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 3px solid var(--line-2);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-bounce), box-shadow var(--dur-fast) ease, background var(--dur-fast) ease, color var(--dur-fast) ease, border-color var(--dur-fast) ease;
  will-change: transform;
}

.btn:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: scale(0.96);
  transition-duration: 80ms;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  border-bottom: 4px solid #9E6B2E;
  box-shadow: 0 12px 24px -16px rgba(140, 84, 34, .75);
}

.btn-primary:hover {
  box-shadow: 0 16px 28px -14px rgba(140, 84, 34, .85);
}

.btn-primary:active {
  transform: scale(0.92);
  border-bottom-width: 2px;
  padding-bottom: 16px;
  transition-duration: 80ms;
}

.btn-secondary {
  background: var(--sec);
  color: #fff;
  border-color: transparent;
  border-bottom: 4px solid #1E3E4D;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line-2);
  border-bottom-color: var(--line-2);
  border-bottom-width: 3px;
  box-shadow: none;
}

.btn-danger {
  background: var(--bad-soft);
  color: #8B2F22;
  border-bottom: 4px solid #C03A2A;
  border-color: rgba(239, 68, 68, .22);
}

.icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
}

.field,
.select,
.textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
  -webkit-appearance: none;
  appearance: none;
}

.textarea {
  min-height: 132px;
  resize: vertical;
  line-height: 1.5;
}

.field:focus,
.select:focus,
.textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(223, 153, 91, .18);
}

.auth-screen {
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  display: grid;
  grid-template-columns: minmax(320px, 560px) minmax(280px, 1fr);
  gap: 44px;
  align-items: center;
  padding: 36px;
}

.auth-copy {
  display: grid;
  gap: 18px;
  min-width: 0;
  max-width: 100%;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: "Unbounded", "Manrope", sans-serif;
  font-weight: 800;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .06), 0 8px 16px -10px rgba(223, 153, 91, .55);
}

.brand-mark img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.auth-title {
  font-size: 1.95rem;
  line-height: 1.05;
  max-width: 420px;
  white-space: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

.auth-lead {
  color: var(--ink-2);
  font-size: 1rem;
  line-height: 1.65;
  max-width: 420px;
  white-space: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

.auth-panel {
  background: rgba(255, 253, 248, .88);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  padding: 28px;
  display: grid;
  gap: 18px;
  min-width: 0;
  max-width: 100%;
}

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

.auth-provider-card {
  min-width: 0;
  min-height: 68px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(73, 111, 130, .14);
  background: rgba(255, 247, 236, .68);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 12px 28px -26px rgba(31, 41, 55, .45), inset 0 1px 0 rgba(255, 255, 255, .78);
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.auth-provider-card:hover {
  transform: translateY(-1px);
  border-color: rgba(73, 111, 130, .24);
  background: rgba(255, 253, 248, .84);
  box-shadow: 0 18px 34px -28px rgba(31, 41, 55, .52), inset 0 1px 0 rgba(255, 255, 255, .86);
}

.auth-provider-card strong,
.auth-provider-card small {
  display: block;
  min-width: 0;
  overflow-wrap: break-word;
}

.auth-provider-card strong {
  font-weight: 900;
  line-height: 1.18;
}

.auth-provider-card small {
  margin-top: 3px;
  color: var(--ink-3);
  font-size: .78rem;
  line-height: 1.25;
}

.provider-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28);
}

.provider-mark.vk {
  background: #2F6FED;
}

.provider-mark.yandex {
  background: #1F2937;
  color: #FFD15C;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-3);
  font-size: .78rem;
  font-weight: 900;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.auth-mascot {
  align-self: end;
  justify-self: center;
  max-height: 560px;
  filter: drop-shadow(0 36px 34px rgba(79, 54, 24, .24));
}

.onboarding-screen {
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  display: grid;
  grid-template-columns: minmax(300px, 430px) minmax(0, 860px);
  gap: 28px;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: var(--bg);
}

.onboarding-hero {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.onboarding-hero .auth-title {
  max-width: 430px;
  font-size: 2.08rem;
}

.onboarding-panel {
  max-height: calc(100vh - 56px);
  overflow: auto;
  padding: 22px;
  border: 1px solid rgba(140, 84, 34, .14);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.onboarding-form {
  display: grid;
  gap: 16px;
}

.setup-section {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.setup-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.setup-title h2 {
  font-size: 1rem;
  line-height: 1.35;
}

.setup-grid {
  display: grid;
  gap: 10px;
}

.setup-grid-2,
.setup-split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.setup-split label,
.setup-grid-2 label {
  min-width: 0;
  overflow: hidden;
}

.setup-card {
  position: relative;
  min-width: 0;
  min-height: 82px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: flex-start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.setup-card:hover,
.subject-card:hover,
.tutorial-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.setup-card input,
.subject-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.setup-card:has(input:checked),
.subject-card:has(input:checked) {
  background: var(--brand-soft);
  border-color: rgba(223, 153, 91, .48);
  box-shadow: inset 3px 0 0 var(--brand);
}

.setup-card.compact {
  min-height: 54px;
  align-items: center;
}

.setup-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--brand-deep);
  background: rgba(255, 253, 248, .62);
}

.setup-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.setup-copy strong,
.subject-card strong,
.tutorial-card strong {
  line-height: 1.3;
  overflow-wrap: break-word;
  hyphens: auto;
}

.setup-copy small,
.tutorial-card small {
  color: var(--ink-3);
  line-height: 1.42;
}

.subject-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.subject-card {
  position: relative;
  min-height: 66px;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.subject-card span {
  color: var(--brand-deep);
  font-weight: 900;
}

.onboarding-preview {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(140, 84, 34, .14);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.route-stack {
  display: grid;
  gap: 10px;
}

.route-stack div {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.route-stack span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sec-soft);
  color: var(--sec-ink);
  font-weight: 900;
}

.route-stack small {
  grid-column: 2;
  color: var(--ink-3);
  overflow-wrap: break-word;
}

.onboarding-actions {
  position: sticky;
  bottom: var(--safe-bottom);
  z-index: 2;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin: 0 -22px -22px;
  padding: 14px 22px calc(14px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.app-shell {
  min-height: 100vh;
}

.rail {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--rail-w);
  height: 100vh;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF8EC 40%, #FFF4E0 100%);
  border-right: 1px solid rgba(223, 153, 91, .12);
  backdrop-filter: blur(16px) saturate(1.16);
  z-index: 30;
  overflow-y: auto;
  overflow-x: hidden;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  font-family: "Unbounded", "Manrope", sans-serif;
  font-weight: 800;
  padding: 10px 12px;
  border: 1px solid rgba(223, 153, 91, .25);
  border-radius: var(--radius-btn);
  background: linear-gradient(135deg, #FFF4E0, var(--brand-soft));
  color: #000;
  box-shadow: 0 4px 12px -6px rgba(223, 153, 91, .3);
}

.rail-brand .brand-mark {
  background: linear-gradient(160deg, #FFE6C5, #F3B880);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .06), 0 4px 12px rgba(223, 153, 91, .35);
}

.rail-nav,
.rail-extra {
  display: grid;
  gap: 6px;
}

.rail-extra {
  margin-top: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-action);
  color: var(--ink-3);
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  transition: all var(--dur-fast) var(--ease-spring);
}

.nav-item:hover {
  color: var(--brand-ink);
  background: rgba(223, 153, 91, .08);
  transform: translateX(2px);
}

.nav-item.active {
  color: var(--brand-deep);
  background: var(--surface);
  border-color: rgba(223, 153, 91, .18);
  box-shadow: 0 2px 8px -3px rgba(223, 153, 91, .3), inset 3px 0 0 var(--brand);
  font-weight: 800;
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--rail-w);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 26px;
  background: linear-gradient(180deg, rgba(255, 253, 248, .95), rgba(255, 248, 236, .88));
  backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid rgba(223, 153, 91, .1);
}

.top-title {
  min-width: 0;
}

.top-title h1 {
  font-size: 1.18rem;
  line-height: 1.2;
  overflow-wrap: break-word;
  hyphens: auto;
}

.top-title p {
  color: var(--ink-3);
  margin-top: 3px;
  font-size: .9rem;
}

.top-source {
  margin-top: 8px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.subject-switcher {
  width: 230px;
}

.content {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 26px 26px 104px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel,
.tile,
.stat-card,
.table-shell {
  background: var(--surface);
  border: 1px solid rgba(140, 84, 34, .1);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) ease;
}

.panel {
  padding: 22px;
  position: relative;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .72);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head > * {
  min-width: 0;
}

.panel-head > :first-child {
  flex: 1 1 220px;
}

.panel-head h2,
.section-title {
  font-family: "Unbounded", "Manrope", sans-serif;
  font-size: 1.08rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.section-row .section-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-row .section-title::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--brand);
  flex-shrink: 0;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0 12px;
}

.hero-app {
  min-height: 320px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 18px;
  align-items: end;
  overflow: hidden;
  background: var(--surface-2);
}

.hero-app h2 {
  font-size: 1.65rem;
  line-height: 1.18;
  margin-bottom: 14px;
  overflow-wrap: break-word;
  hyphens: auto;
}

.hero-copy {
  align-self: center;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.hero-mascot {
  align-self: end;
  max-height: 300px;
  justify-self: end;
  filter: drop-shadow(0 24px 28px rgba(79, 54, 24, .22));
}

.quick-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.quick-card {
  padding: 18px;
  min-height: 130px;
  display: grid;
  align-content: space-between;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) ease;
}

.quick-card::before {
  content: "";
  position: absolute;
  top: -30px;
  right: -30px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--brand-soft);
  opacity: .4;
  transition: transform var(--dur-smooth) var(--ease-spring);
}

.quick-card:hover::before {
  transform: scale(1.8);
  opacity: .6;
}

.quick-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-md);
  border-color: rgba(223, 153, 91, .25);
}

.quick-card:active,
.tile:active {
  transform: scale(0.96);
  transition-duration: 80ms;
}

.quick-card .tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), #E8B07C);
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(223, 153, 91, .4);
}

.quick-card .tile-icon .icon {
  color: #fff;
}

.quick-card h3 {
  font-size: .92rem;
  margin-top: 12px;
}

.quick-card p {
  font-size: .78rem;
  color: var(--ink-3);
  margin-top: 2px;
}

.stat-card {
  padding: 16px;
}

.stat-num {
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
  overflow-wrap: break-word;
}

.badge,
.chip,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
  width: auto;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 800;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
  text-align: left;
}

.badge {
  padding: 7px 10px;
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.badge.bad {
  background: var(--bad-soft);
  color: #8B2F22;
}

.badge.good {
  background: var(--good-soft);
  color: #2F6B3B;
}

.chip {
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.chip.active {
  background: var(--brand-soft);
  color: var(--brand-deep);
  border-color: rgba(223, 153, 91, .42);
}

.tag {
  padding: 6px 9px;
  background: var(--sec-soft);
  color: var(--sec-ink);
}

.tag.good {
  background: var(--good-soft);
  color: #2F6B3B;
}

.tag.bad {
  background: var(--bad-soft);
  color: #8B2F22;
}

.source-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .01em;
  border: 1px solid rgba(73, 111, 130, .18);
  background: rgba(201, 220, 230, .45);
  color: var(--sec-ink);
  max-width: 100%;
  overflow-wrap: break-word;
  hyphens: auto;
}

.source-pill.ok::before,
.source-pill.bad::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--good);
}

.source-pill.bad {
  border-color: rgba(239, 68, 68, .24);
  background: rgba(245, 212, 196, .62);
  color: #8B2F22;
}

.source-pill.bad::before {
  background: var(--bad);
}

.data-state-panel {
  border-color: rgba(239, 68, 68, .22);
  background: #FFF8F4;
}

.backend-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.backend-card.good {
  border-color: rgba(16, 185, 129, .28);
  background: #F5FAF0;
}

.backend-card.bad {
  border-color: rgba(239, 68, 68, .22);
  background: #FFF8F4;
}

.backend-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.quota-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  color: var(--ink-3);
  font-size: .78rem;
  font-weight: 800;
}

.quota-row span {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, .7);
}

.progress {
  height: 10px;
  background: rgba(31, 41, 55, .08);
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  width: var(--value, 50%);
  border-radius: inherit;
  background: var(--brand);
}

.list {
  display: grid;
  gap: 10px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.quiz-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.quiz-actions .btn:first-child {
  margin-right: auto;
}

.item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  min-width: 0;
}

.item.active {
  background: #FFF4DC;
  border-color: rgba(223, 153, 91, .38);
  box-shadow: inset 3px 0 0 var(--brand);
}

.item.active .item-title {
  color: var(--brand-deep);
}

.item-main {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-weight: 900;
  margin-bottom: 3px;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
  min-width: 0;
}

.item-sub {
  color: var(--ink-3);
  font-size: .88rem;
  line-height: 1.45;
}

.tile {
  display: grid;
  gap: 12px;
  padding: 18px;
  min-height: 150px;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(223, 153, 91, .34);
}

.tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand-soft), rgba(246, 217, 184, .6));
  color: var(--brand-deep);
  box-shadow: 0 2px 6px -2px rgba(223, 153, 91, .2);
}

.tile h3 {
  font-size: 1rem;
  line-height: 1.35;
  overflow-wrap: break-word;
  hyphens: auto;
}

.tile p {
  color: var(--ink-3);
  line-height: 1.48;
  font-size: .9rem;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 16px;
  min-height: calc(100vh - var(--topbar-h) - 52px);
}

.chat-sidebar {
  display: grid;
  align-content: start;
  gap: 10px;
}

.chat-room {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 640px;
  overflow: hidden;
}

.messages {
  padding: 18px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: min(720px, 86%);
  display: grid;
  gap: 5px;
}

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

.bubble {
  border-radius: var(--radius);
  padding: 12px 14px;
  line-height: 1.55;
  border: 1px solid var(--line);
  background: var(--surface-2);
  overflow-wrap: break-word;
  hyphens: auto;
}

.message.user .bubble {
  background: var(--sec);
  color: #fff;
  border-color: transparent;
}

.message.pending .bubble {
  color: var(--ink-3);
  border-style: dashed;
  background: #f3efe5;
}

.message.error .bubble {
  border-color: #df9f8f;
  background: #fff3ef;
}

.message-meta {
  font-size: .73rem;
  color: var(--ink-3);
}

.message.user .message-meta {
  text-align: right;
}

.chat-input {
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, .92);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.input-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.input-row .field {
  min-width: 0;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.question-card {
  display: grid;
  gap: 18px;
}

.question-text {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface-2);
  line-height: 1.62;
  border: 1px dashed var(--line-2);
  overflow-wrap: break-word;
  hyphens: auto;
}

.answer-grid {
  display: grid;
  gap: 10px;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.choice input {
  margin-top: 4px;
}

.match-tile {
  width: 100%;
  min-height: 76px;
  color: var(--ink);
  text-align: left;
}

.match-tile.selected {
  border-color: var(--brand);
  background: #FFF4DC;
  box-shadow: inset 3px 0 0 var(--brand);
}

.match-tile.active {
  border-color: rgba(16, 185, 129, .35);
  background: var(--good-soft);
  color: #285D34;
}

.feedback {
  padding: 14px;
  border-radius: var(--radius);
  line-height: 1.55;
  border: 1px solid var(--line);
}

.feedback.good {
  background: var(--good-soft);
  color: #285D34;
}

.feedback.bad {
  background: var(--bad-soft);
  color: #7B2D20;
}

.diagnostic-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.diagnostic-intro {
  display: grid;
  gap: 14px;
}

.diagnostic-intro h2 {
  font-size: 1.28rem;
  line-height: 1.25;
}

.diagnostic-meter {
  display: grid;
  gap: 10px;
}

.diagnostic-meter div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.diagnostic-meter span {
  color: var(--ink-3);
  font-size: .84rem;
  font-weight: 800;
}

.diagnostic-form {
  display: grid;
  gap: 14px;
}

.diagnostic-card {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.diagnostic-card legend {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  font-weight: 900;
}

.diagnostic-card legend span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.diagnostic-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tutorial-layout {
  display: grid;
  gap: 16px;
}

.tutorial-command {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: stretch;
  overflow: hidden;
}

.tutorial-copy {
  display: grid;
  gap: 14px;
  align-content: center;
  min-width: 0;
}

.tutorial-copy h2 {
  font-size: 1.42rem;
  line-height: 1.22;
}

.tutorial-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tutorial-device {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.device-top,
.device-card,
.device-tabs {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}

.device-top {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
}

.device-top span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--good);
}

.device-top small {
  color: var(--ink-3);
  font-weight: 800;
}

.device-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.device-card.active {
  border-color: rgba(223, 153, 91, .45);
  box-shadow: inset 3px 0 0 var(--brand);
}

.device-card span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.device-card small {
  color: var(--ink-3);
  font-weight: 800;
}

.device-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
}

.device-tabs span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: var(--radius);
  color: var(--ink-3);
}

.device-tabs span.active {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.tutorial-map-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.tutorial-card {
  min-height: 220px;
  display: grid;
  gap: 10px;
  align-content: start;
  text-align: left;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(140, 84, 34, .14);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.tutorial-card:hover {
  border-color: rgba(223, 153, 91, .42);
}

.tutorial-card .tile-icon {
  justify-self: start;
  margin-top: 6px;
}

.tutorial-card .tag {
  justify-self: start;
}

.tutorial-num {
  font-family: "Unbounded", "Manrope", sans-serif;
  color: var(--brand-deep);
  font-size: .82rem;
  font-weight: 900;
}

.tutorial-card > span:not(.tile-icon):not(.tag):not(.tutorial-num) {
  color: var(--ink-2);
  line-height: 1.5;
}

.tutorial-rhythm {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.tutorial-checklist {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tutorial-checklist div {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.tutorial-checklist .icon {
  color: var(--brand-deep);
}

.tutorial-checklist span {
  display: grid;
  gap: 2px;
}

.tutorial-checklist small {
  color: var(--ink-3);
  line-height: 1.35;
}

.task-paper {
  background: var(--surface);
  border-left: 5px solid rgba(223, 153, 91, .35);
}

.check-panel {
  border-color: rgba(73, 111, 130, .2);
}

.ai-result {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 16px;
  border: 1px solid rgba(16, 185, 129, .24);
  border-radius: var(--radius);
  background: #F5FAF0;
}

.score-orbit {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background: var(--surface);
  border: 10px solid rgba(16, 185, 129, .28);
  color: var(--ink);
  text-align: center;
}

.score-orbit strong {
  display: block;
  font-family: "Unbounded", "Manrope", sans-serif;
  font-size: 1.45rem;
  line-height: 1;
}

.score-orbit span {
  font-size: .78rem;
  font-weight: 900;
  color: var(--ink-3);
}

.criteria-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.criterion {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, .78);
}

.criterion p {
  color: var(--ink-3);
  font-size: .84rem;
  line-height: 1.45;
}

.timer-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: #FFF4DC;
  color: var(--brand-deep);
  font-weight: 900;
}

/* Flashcard 3D flip */
.flashcard-scene {
  perspective: 1000px;
  width: 100%;
  min-height: 280px;
}

.flashcard {
  width: 100%;
  min-height: 280px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  position: relative;
  transform-style: preserve-3d;
  transition: transform .6s var(--ease-spring);
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  backface-visibility: hidden;
  border-radius: inherit;
}

.flashcard-back {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, #FFF8EC, var(--surface));
  border-top: 4px solid var(--brand);
}

.flashcard-button {
  color: var(--ink);
}

.flashcard h2 {
  font-size: 1.38rem;
  line-height: 1.32;
  overflow-wrap: break-word;
  hyphens: none;
}

/* Exam timer urgency */
.timer-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-family: "Unbounded", sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 2px solid var(--line);
  transition: all .5s ease;
}

.timer-box.warning {
  background: #FEF3C7;
  border-color: #F59E0B;
  color: #92400E;
}

.timer-box.danger {
  background: #FEE2E2;
  border-color: #EF4444;
  color: #991B1B;
  animation: timer-pulse 1s ease-in-out infinite;
}

@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); box-shadow: 0 0 16px rgba(239, 68, 68, .3); }
}

/* Flashcard swipe labels */
.swipe-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-family: "Unbounded", sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 8px 16px;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 2;
}
.swipe-label-left { right: 16px; background: var(--bad-soft); color: #7B2D20; border: 2px solid var(--bad); }
.swipe-label-right { left: 16px; background: var(--good-soft); color: #285D34; border: 2px solid var(--good); }
.flashcard { position: relative; touch-action: pan-y; user-select: none; }

.match-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .match-grid { grid-template-columns: repeat(2, 1fr); } }

.match-tile.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
  animation: tile-shake 0.4s ease;
}

@keyframes tile-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Learn stage dots */
.stage-dots { display: flex; align-items: center; justify-content: center; gap: 0; margin-bottom: 14px; }
.stage-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; border: 2px solid var(--line); color: var(--ink-3); background: var(--surface); }
.stage-dot.active { border-color: var(--brand); background: var(--brand); color: #fff; }
.stage-dot-line { width: 40px; height: 2px; background: var(--line); }
.stage-dot-line.active { background: var(--brand); }

/* Test mode progress bar */
.progress-bar { width: 100%; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-bottom: 14px; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--brand); transition: width 0.3s var(--ease-spring); }

/* Skeleton empty states */
.empty {
  display: grid;
  place-items: center;
  min-height: 240px;
  text-align: center;
  padding: 32px;
  color: var(--ink-3);
  gap: 16px;
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand-soft), rgba(246, 217, 184, .4));
  display: grid;
  place-items: center;
  color: var(--brand);
}

.empty-icon .icon {
  width: 28px;
  height: 28px;
}

.empty-title {
  font-family: "Unbounded", sans-serif;
  font-weight: 700;
  font-size: .95rem;
  color: var(--ink-2);
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, rgba(255, 253, 248, .6) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.skeleton-line {
  height: 14px;
  border-radius: 7px;
  margin-bottom: 10px;
}

.skeleton-line:last-child { width: 60%; }

/* Page transitions */
.content {
  position: relative;
}

.content.page-enter > * {
  animation: page-slide-in var(--dur-smooth) var(--ease-spring) both;
}

@keyframes page-slide-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.map-block {
  display: grid;
  gap: 10px;
}

.topic-node {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.node-code {
  font-weight: 900;
  color: var(--brand-ink);
  min-width: 44px;
}

.table-shell {
  overflow: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.table th,
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--ink-3);
  font-size: .8rem;
  text-transform: uppercase;
}

.avatar-xl {
  width: 124px;
  height: 124px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: #FFF4DC;
  border: 1px solid var(--line);
  overflow: hidden;
}

.avatar-xl img {
  width: 112px;
  height: 112px;
  object-fit: contain;
}

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

.swatch {
  min-height: 76px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: var(--surface-2);
}

.swatch.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(223, 153, 91, .18);
}

.weekday-grid,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekday-grid {
  margin: 8px 0 10px;
  color: var(--ink-3);
  font-size: .78rem;
  font-weight: 900;
  text-align: center;
}

.day-cell {
  aspect-ratio: 1;
  min-width: 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, .86);
  color: var(--ink);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  font-weight: 900;
  cursor: pointer;
}

.day-cell small {
  min-height: 14px;
  color: var(--ink-3);
  font-size: .58rem;
  font-weight: 800;
}

.day-cell.active {
  background: var(--brand-soft);
  border-color: rgba(223, 153, 91, .45);
  color: var(--brand-deep);
}

.day-cell.freeze {
  background: var(--sec-soft);
  border-color: rgba(73, 111, 130, .34);
  color: var(--sec-ink);
}

.empty-day {
  visibility: hidden;
}

.mood-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.mood-card {
  min-height: 82px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  padding: 12px;
  cursor: pointer;
  font-weight: 900;
}

.mood-card input {
  position: absolute;
  opacity: 0;
}

.mood-card:has(input:checked) {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-deep);
}

.social-layout {
  align-items: start;
}

.social-overview {
  grid-column: 1 / -1;
}

.social-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.friend-card {
  align-items: stretch;
}

.friend-tags,
.item-actions,
.support-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.item-actions {
  justify-content: flex-end;
  margin-top: 0;
  min-width: min(220px, 100%);
}

.item-actions .btn {
  flex: 1 1 104px;
}

.support-card {
  min-height: 240px;
  display: grid;
  align-content: space-between;
  gap: 16px;
}

.support-card h3 {
  margin-top: 14px;
  font-size: 1rem;
  line-height: 1.38;
}

.support-actions {
  justify-content: space-between;
}

.support-actions .btn {
  flex: 1 1 142px;
}

.social-session {
  grid-column: 1 / -1;
}

.session-active-banner {
  background: linear-gradient(135deg, var(--brand-soft), var(--sec-soft));
  border-radius: 20px;
  padding: 24px 24px 20px;
  text-align: center;
}

.session-countdown {
  font-family: 'Unbounded', sans-serif;
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 2px;
  margin-top: 8px;
  color: var(--ink);
}

.session-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  margin-top: 16px;
  overflow: hidden;
}

.session-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s linear, background-color 0.5s;
}

.session-friend-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.95rem;
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: 12px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  background: #f44336;
  color: #fff;
  border-radius: 9px;
  padding: 0 4px;
  pointer-events: none;
}

.nav-item {
  position: relative;
}

.item.expired {
  opacity: 0.4;
  pointer-events: none;
}

.kudos-bounce {
  animation: kudos-pop 0.3s ease;
}

@keyframes kudos-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ── Mobile: new social/session components ── */

@media (max-width: 860px) {
  .session-active-banner { padding: 20px 16px 16px; border-radius: 16px; }
  .session-countdown { font-size: 2rem; }
  .session-friend-row { font-size: 0.88rem; }
}

@media (max-width: 560px) {
  .session-active-banner { padding: 16px 14px 14px; border-radius: 14px; }
  .session-countdown { font-size: 1.6rem; letter-spacing: 1px; }
  .session-friend-row { gap: 8px; font-size: 0.84rem; flex-wrap: wrap; justify-content: center; }
  .session-progress { margin-top: 12px; }
  .social-status { grid-template-columns: 1fr !important; }
  .feedback { font-size: 0.88rem; padding: 12px; }
  .question-card { gap: 12px; }
}

@media (max-width: 420px) {
  .session-countdown { font-size: 1.4rem; }
  .session-active-banner { padding: 14px 12px 12px; }
  .nav-badge { top: 2px; right: 8px; min-width: 16px; height: 16px; line-height: 16px; font-size: 0.6rem; }
  .friend-profile-header { padding: 12px 14px; }
  .friend-profile-body { padding: 8px 12px; }
}

.levelup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: all;
}

.levelup-overlay.visible {
  opacity: 1;
}

.levelup-card {
  text-align: center;
  background: linear-gradient(135deg, #FFF4E0, #fff);
  border-radius: 24px;
  padding: 40px 48px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  transform: scale(0.7);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.levelup-overlay.visible .levelup-card {
  transform: scale(1);
}

.levelup-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  animation: levelup-star 0.6s ease 0.3s both;
}

@keyframes levelup-star {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.levelup-title {
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 1.8rem;
  color: var(--ink);
  margin-bottom: 8px;
}

.levelup-sub {
  color: var(--ink-2);
  font-size: 1rem;
}

.subject-topbar-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: 2px solid var(--brand);
  border-radius: 10px;
  background: var(--brand-soft);
  cursor: pointer;
  flex-shrink: 0;
  place-items: center;
}

@media (max-width: 860px) {
  .subject-topbar-btn {
    display: grid;
  }
}

.subject-emoji {
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
}

.subject-picker-modal {
  max-width: 400px;
  width: calc(100vw - 32px);
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
}

.subject-picker-modal h3 {
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 16px;
  text-align: center;
}

.subject-picker-list {
  display: grid;
  gap: 6px;
}

.subject-picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.subject-picker-item:hover,
.subject-picker-item:focus {
  background: var(--brand-soft);
}

.subject-picker-item.active {
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}

.subject-picker-item .subject-emoji {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
}

.lab-canvas {
  width: 100%;
  height: 360px;
  border-radius: var(--radius);
  background: #FFFDF8;
  border: 1px solid var(--line);
}

.slider-row {
  display: grid;
  grid-template-columns: 80px 1fr 54px;
  gap: 12px;
  align-items: center;
}

.bottom-nav {
  display: none;
}

#toast-root {
  position: fixed;
  right: calc(18px + var(--safe-right));
  bottom: calc(18px + var(--safe-bottom));
  z-index: 80;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: 360px;
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease both;
}

@keyframes toast-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.loading {
  min-height: 420px;
  display: grid;
  place-items: center;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 4px solid rgba(31, 41, 55, .12);
  border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1120px) {
  .grid-4,
  .quick-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tutorial-map-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-app {
    grid-template-columns: 1fr;
  }

  .hero-mascot {
    max-height: 220px;
    justify-self: start;
  }
}

@media (max-width: 860px) {
  .onboarding-screen {
    min-height: auto;
    align-items: start;
    grid-template-columns: 1fr;
    padding: calc(18px + var(--safe-top)) calc(14px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(14px + var(--safe-left));
  }

  .onboarding-hero .auth-title {
    font-size: 1.72rem;
  }

  .onboarding-panel {
    max-height: none;
    overflow: visible;
    padding: 16px;
  }

  .onboarding-actions {
    bottom: var(--safe-bottom);
    margin: 0 -16px -16px;
    padding: 12px 16px calc(12px + var(--safe-bottom));
  }

  .app-flow-actions {
    bottom: calc(var(--mobile-nav-h) + 22px + var(--safe-bottom));
  }

  .setup-grid-2,
  .setup-split,
  .diagnostic-layout,
  .tutorial-command,
  .tutorial-rhythm {
    grid-template-columns: 1fr;
  }

  .subject-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .diagnostic-options,
  .tutorial-checklist {
    grid-template-columns: 1fr;
  }

  .tutorial-map-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-screen {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .auth-copy {
    max-width: 360px;
  }

  .auth-title,
  .auth-lead {
    max-width: 360px;
  }

  .auth-title {
    font-size: 1.8rem;
  }

  .auth-mascot {
    display: none;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    overflow: hidden;
  }

  .rail {
    display: none;
  }

  .workspace {
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-left: 0;
  }

  .topbar {
    min-height: 66px;
    padding: 10px 14px;
  }

  .top-title p {
    display: none;
  }

  .top-source {
    display: none;
  }

  .subject-switcher {
    display: none;
  }

  .content {
    padding: 16px 14px 28px;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .quick-strip,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .social-status {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .social-status .stat-card {
    padding: 12px;
  }

  .social-status .stat-num {
    font-size: .98rem;
  }

  .social-status .stat-card,
  .social-status .stat-num,
  .social-status .strong {
    overflow-wrap: normal;
    word-break: keep-all;
    hyphens: none;
  }

  .chat-sidebar {
    display: none;
  }

  .panel.chat-room {
    min-height: calc(100vh - 176px);
    min-height: calc(100dvh - 176px);
    padding-bottom: 0;
  }

  .message {
    max-width: 94%;
  }

  .input-row {
    grid-template-columns: auto auto 1fr auto;
  }

  .bottom-nav {
    position: fixed;
    left: 50%;
    right: auto;
    bottom: calc(12px + var(--safe-bottom));
    z-index: 70;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    width: min(420px, calc(100vw - 24px - var(--safe-left) - var(--safe-right)));
    min-height: 58px;
    padding: 5px;
    overflow: hidden;
    isolation: isolate;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, .1)),
      rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 24px;
    -webkit-backdrop-filter: blur(34px) saturate(1.75) brightness(1.08);
    backdrop-filter: blur(34px) saturate(1.75) brightness(1.08);
    box-shadow:
      0 18px 42px -32px rgba(79, 54, 24, .5),
      inset 0 1px 0 rgba(255, 255, 255, .86),
      inset 0 -1px 0 rgba(255, 255, 255, .24);
    transform: translate3d(-50%, 0, 0);
  }

  .bottom-nav .nav-item {
    justify-content: center;
    padding: 7px 4px;
    min-width: 0;
    min-height: 48px;
    position: relative;
    border-radius: 16px;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
  }

  .bottom-nav .nav-item.active {
    background: transparent;
    border-color: transparent;
    color: var(--brand-deep);
    box-shadow: none;
  }

  .bottom-nav .nav-item.active .icon {
    transform: translateY(-1px);
  }

  .bottom-nav .nav-item span {
    display: none;
  }

  .bottom-nav .nav-item.active::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 5px;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: rgba(179, 110, 48, .78);
    box-shadow: 0 0 14px rgba(223, 153, 91, .58);
    transform: translateX(-50%);
  }

  .hero-app h2 {
    font-size: 1.35rem;
  }

  .ai-result {
    grid-template-columns: 1fr;
  }

  .backend-card {
    grid-template-columns: 1fr;
  }

  .score-orbit {
    width: 116px;
  }

  .wardrobe-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .onboarding-screen {
    padding: 14px;
  }

  .onboarding-hero {
    gap: 12px;
  }

  .onboarding-hero .auth-title {
    font-size: 1.42rem;
    line-height: 1.16;
  }

  .onboarding-preview {
    padding: 12px;
  }

  .setup-section {
    gap: 10px;
  }

  .setup-grid-2,
  .subject-picker,
  .tutorial-map-grid {
    grid-template-columns: 1fr;
  }

  .setup-card,
  .subject-card,
  .tutorial-card {
    min-height: auto;
  }

  .onboarding-actions {
    display: grid;
  }

  .onboarding-actions .btn,
  .tutorial-actions .btn {
    width: 100%;
  }

  .tutorial-device {
    display: none;
  }

  .tutorial-card {
    min-height: 178px;
  }

  .auth-screen {
    padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
    max-width: 100vw;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .auth-copy,
  .auth-panel {
    width: 100%;
    max-width: calc(100vw - 32px);
  }

  .auth-title {
    font-size: 1.38rem;
    line-height: 1.18;
  }

  .auth-lead {
    font-size: .92rem;
  }

  .stat-num {
    font-size: 1.12rem;
  }

  .btn,
  .badge,
  .chip,
  .tag {
    font-size: .82rem;
  }

  .top-actions .btn:not(.icon-btn) {
    display: none;
  }

  .panel {
    padding: 16px;
  }

  .panel-head,
  .row,
  .quiz-actions {
    align-items: stretch;
  }

  .panel-head .btn,
  .row > .btn,
  .row > .badge,
  .quiz-actions > .btn {
    max-width: 100%;
  }

  .item {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .item-actions,
  .item > .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .item-actions .btn,
  .support-actions .btn {
    flex-basis: 100%;
  }

  .support-actions {
    align-items: stretch;
  }

  .quiz-actions {
    display: grid;
    grid-template-columns: 1fr;
    position: sticky;
    bottom: 10px;
    z-index: 45;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }

  .quiz-actions .btn:first-child {
    margin-right: 0;
  }

  .quiz-actions.checked {
    grid-template-columns: 1fr 1fr;
  }

  .quiz-actions.checked .btn[data-action="quiz-hint"],
  .quiz-actions.checked .btn[data-action="quiz-skip"] {
    display: none;
  }

  .hero-actions {
    display: grid;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .quick-strip {
    grid-template-columns: 1fr;
  }

  .chat-input {
    padding: 10px;
  }

  .chat-input .row {
    display: none;
  }

  .input-row {
    grid-template-columns: 44px 44px minmax(0, 1fr) 44px;
  }
}

@media (max-width: 420px) {
  .chat-input .input-row {
    grid-template-columns: 40px 40px minmax(0, 1fr) 40px;
  }

  .chat-input .input-row .field,
  .chat-input .input-row .btn,
  .chat-input .input-row .btn[type="submit"] {
    grid-column: auto;
    grid-row: auto;
    justify-self: stretch;
  }
}

@media (max-width: 860px) {
  html,
  body {
    min-height: 100%;
    overflow-x: hidden;
  }

  .app-shell {
    background: var(--bg);
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    overflow: hidden;
  }

  .workspace {
    min-height: 0;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .topbar {
    min-height: 58px;
    padding: calc(8px + var(--safe-top)) 12px 8px;
  }

  .top-title h1 {
    font-size: 1.08rem;
  }

  .top-actions {
    gap: 8px;
  }

  .top-actions > .badge {
    max-width: 92px;
    font-size: .68rem;
    padding: 6px 8px;
  }

  .content {
    padding: 12px 10px 18px;
  }

  .bottom-nav {
    position: fixed;
    left: 50%;
    right: auto;
    bottom: calc(12px + var(--safe-bottom));
    width: min(420px, calc(100vw - 24px - var(--safe-left) - var(--safe-right)));
    margin: 0;
    min-height: 58px;
    padding: 5px;
    border-radius: 24px;
    overflow: hidden;
    isolation: isolate;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, .1)),
      rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .72);
    -webkit-backdrop-filter: blur(34px) saturate(1.75) brightness(1.08);
    backdrop-filter: blur(34px) saturate(1.75) brightness(1.08);
    box-shadow:
      0 18px 42px -32px rgba(79, 54, 24, .5),
      inset 0 1px 0 rgba(255, 255, 255, .86),
      inset 0 -1px 0 rgba(255, 255, 255, .24);
    transform: translate3d(-50%, 0, 0);
  }

  .bottom-nav .nav-item {
    min-height: 48px;
    padding: 7px 4px;
    border-radius: 16px;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
  }

  #toast-root {
    left: calc(12px + var(--safe-left));
    right: calc(12px + var(--safe-right));
    bottom: calc(var(--mobile-nav-h) + 28px + var(--safe-bottom));
  }

  .toast {
    max-width: none;
  }

  .panel {
    padding: 16px;
  }

  .panel-head {
    gap: 10px;
    margin-bottom: 12px;
  }

  .panel-head h2,
  .section-title {
    font-size: 1rem;
  }

  .hero-app {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: start;
  }

  .hero-app h2 {
    font-size: 1.22rem;
    line-height: 1.22;
    margin-bottom: 10px;
  }

  .hero-copy {
    align-self: start;
  }

  .hero-copy .auth-lead {
    max-width: none;
    font-size: .92rem;
    line-height: 1.55;
  }

  .hero-actions {
    gap: 8px;
    margin-top: 14px;
  }

  .hero-mascot {
    display: none;
  }

  .quick-strip,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat-card {
    padding: 12px;
    min-height: 82px;
  }

  .stat-num {
    font-size: 1.02rem;
    margin-bottom: 2px;
  }

  .stat-card .strong {
    font-size: .92rem;
    line-height: 1.25;
  }

  .stat-card .small {
    font-size: .76rem;
    line-height: 1.35;
  }

  .tile,
  .quick-card {
    min-height: 0;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    align-content: center;
    padding: 13px;
    text-align: left;
  }

  .tile-icon {
    width: 42px;
    height: 42px;
  }

  .tile h3 {
    color: var(--ink);
    font-size: .96rem;
    line-height: 1.28;
    margin: 0 0 3px;
  }

  .tile p {
    font-size: .82rem;
    line-height: 1.36;
    margin: 0;
  }

  .avatar-xl {
    width: 76px;
    height: 76px;
  }

  .avatar-xl img {
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 15px;
  }

  .auth-screen {
    min-height: auto;
    padding: calc(18px + var(--safe-top)) calc(12px + var(--safe-right)) calc(28px + var(--safe-bottom)) calc(12px + var(--safe-left));
    overflow: visible;
  }

  .auth-copy,
  .auth-panel {
    max-width: 100%;
  }

  .auth-panel {
    padding: 18px;
  }

  .auth-panel h2 {
    font-size: 1.35rem;
    line-height: 1.18;
  }

  .auth-title {
    font-size: 1.34rem;
    line-height: 1.16;
    max-width: none;
  }

  .auth-lead {
    max-width: none;
    font-size: .92rem;
    line-height: 1.52;
  }

  .auth-screen .quick-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field,
  .select {
    min-height: 46px;
    padding: 10px 12px;
    font-size: .96rem;
  }

  .btn {
    min-height: 44px;
    padding: 10px 12px;
    font-size: .9rem;
  }

  .icon-btn {
    width: 42px;
    height: 42px;
  }

  .content {
    padding-inline: 8px;
    padding-bottom: 18px;
  }

  .grid {
    gap: 12px;
  }

  .panel {
    padding: 14px;
  }

  .panel-head,
  .row {
    gap: 10px;
  }

  .hero-app {
    padding: 16px;
  }

  .hero-app h2 {
    font-size: 1.16rem;
    line-height: 1.22;
  }

  .hero-actions {
    display: grid;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .quick-strip,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .stat-card {
    min-height: 74px;
    padding: 11px;
  }

  .stat-num {
    font-size: .98rem;
  }

  .quick-card,
  .tile {
    padding: 12px;
  }

  .tile-icon {
    width: 40px;
    height: 40px;
  }

  .item {
    padding: 11px;
    gap: 10px;
  }

  .item-title {
    font-size: .92rem;
    line-height: 1.32;
  }

  .item-sub {
    font-size: .8rem;
    line-height: 1.34;
  }

  .badge,
  .chip,
  .tag {
    font-size: .72rem;
  }
}

/* Mobile fit and light glass nav override. */
@media (max-width: 860px) {
  :root {
    --mobile-gutter: clamp(14px, 3.6vw, 18px);
    --mobile-sheet-max: 760px;
  }

  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    font-size: 16px;
  }

  input,
  textarea,
  select,
  .field,
  .select,
  .textarea {
    font-size: 16px;
  }

  .topbar {
    padding-right: calc(var(--mobile-gutter) + var(--safe-right));
    padding-left: calc(var(--mobile-gutter) + var(--safe-left));
  }

  .content {
    width: min(100%, var(--mobile-sheet-max));
    margin-inline: auto;
    padding: 16px var(--mobile-gutter) calc(104px + var(--safe-bottom));
  }

  .auth-screen,
  .onboarding-screen {
    padding-right: calc(var(--mobile-gutter) + var(--safe-right));
    padding-left: calc(var(--mobile-gutter) + var(--safe-left));
  }

  .auth-copy,
  .auth-panel,
  .onboarding-hero,
  .onboarding-panel {
    width: min(100%, var(--mobile-sheet-max));
    margin-inline: auto;
  }

  .panel {
    padding: clamp(16px, 4vw, 22px);
  }

  .grid {
    gap: 14px;
  }

  .app-shell {
    grid-template-rows: minmax(0, 1fr);
  }

  .workspace {
    padding-bottom: 0;
  }

  .bottom-nav {
    position: fixed;
    left: 50%;
    right: auto;
    bottom: calc(12px + var(--safe-bottom));
    z-index: 70;
    width: min(420px, calc(100vw - 24px - var(--safe-left) - var(--safe-right)));
    margin: 0;
    min-height: 58px;
    padding: 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 24px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .42), rgba(255, 255, 255, .10)),
      rgba(255, 255, 255, .16);
    -webkit-backdrop-filter: blur(34px) saturate(1.75) brightness(1.08);
    backdrop-filter: blur(34px) saturate(1.75) brightness(1.08);
    box-shadow:
      0 18px 42px -32px rgba(79, 54, 24, .5),
      inset 0 1px 0 rgba(255, 255, 255, .86),
      inset 0 -1px 0 rgba(255, 255, 255, .24);
    transform: translate3d(-50%, 0, 0);
    touch-action: pan-y;
  }

  .nav-active-pill {
    position: absolute;
    z-index: 1;
    top: 5px;
    bottom: 5px;
    left: calc(5px + var(--nav-pill-x, 0%));
    width: calc(20% - 8px);
    pointer-events: none;
    border-radius: 19px;
    background:
      linear-gradient(180deg, rgba(255, 238, 213, .72), rgba(223, 153, 91, .38)),
      rgba(223, 153, 91, .34);
    border: 1px solid rgba(255, 244, 230, .72);
    -webkit-backdrop-filter: blur(22px) saturate(1.45) brightness(1.06);
    backdrop-filter: blur(22px) saturate(1.45) brightness(1.06);
    box-shadow:
      0 12px 24px -18px rgba(140, 84, 34, .68),
      inset 0 1px 0 rgba(255, 255, 255, .78),
      inset 0 -2px 0 rgba(179, 110, 48, .22);
    transition: left .24s cubic-bezier(.2, .8, .2, 1), transform .18s ease, box-shadow .18s ease;
  }

  .bottom-nav.dragging .nav-active-pill {
    transition: none;
    transform: scale(1.035);
    box-shadow:
      0 18px 30px -20px rgba(140, 84, 34, .78),
      inset 0 1px 0 rgba(255, 255, 255, .84),
      inset 0 -2px 0 rgba(179, 110, 48, .24);
  }

  .bottom-nav::before {
    content: "";
    position: absolute;
    inset: 1px 1px auto 1px;
    height: 54%;
    pointer-events: none;
    border-radius: 23px 23px 18px 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .46), rgba(255, 255, 255, 0));
    mix-blend-mode: screen;
  }

  .bottom-nav .nav-item {
    z-index: 2;
    min-height: 48px;
    padding: 7px 4px;
    color: rgba(31, 41, 55, .74);
    background: transparent;
    border-color: transparent;
    box-shadow: none;
  }

  .bottom-nav .nav-item.active {
    color: var(--brand-deep);
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    cursor: grab;
    touch-action: none;
  }

  .bottom-nav.dragging .nav-item.active {
    cursor: grabbing;
  }

  .bottom-nav .nav-item.active::after {
    display: none;
  }
}

@media (max-width: 380px) {
  :root {
    --mobile-gutter: 16px;
  }

  .content {
    padding-inline: var(--mobile-gutter);
  }

  .bottom-nav {
    width: calc(100vw - 20px - var(--safe-left) - var(--safe-right));
  }
}

@media (max-width: 860px) {
  .bottom-nav {
    position: fixed !important;
    left: 50% !important;
    right: auto !important;
    bottom: calc(12px + var(--safe-bottom)) !important;
    width: min(420px, calc(100vw - 24px - var(--safe-left) - var(--safe-right))) !important;
    margin: 0 !important;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .38), rgba(255, 255, 255, .08)),
      rgba(255, 255, 255, .14) !important;
    border: 1px solid rgba(255, 255, 255, .68) !important;
    box-shadow:
      0 18px 42px -32px rgba(79, 54, 24, .5),
      inset 0 1px 0 rgba(255, 255, 255, .86),
      inset 0 -1px 0 rgba(255, 255, 255, .2) !important;
    -webkit-backdrop-filter: blur(34px) saturate(1.75) brightness(1.08) !important;
    backdrop-filter: blur(34px) saturate(1.75) brightness(1.08) !important;
    transform: translate3d(-50%, 0, 0) !important;
  }

  .bottom-nav .nav-item,
  .bottom-nav .nav-item.active {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
  }

  .bottom-nav .nav-item.active::after {
    display: none !important;
  }

  .nav-active-pill {
    display: block !important;
  }
}

/* App-wide visual refresh. */
:root {
  --radius: 10px;
  --radius-lg: 16px;
  --surface: #FFFDF8;
  --surface-2: #FFF7EC;
  --surface-3: #FFF1E0;
  --line: rgba(73, 111, 130, .13);
  --line-2: rgba(140, 84, 34, .2);
  --shadow-sm: 0 2px 5px rgba(79, 54, 24, .06), 0 14px 30px -26px rgba(79, 54, 24, .42);
  --shadow-md: 0 8px 18px rgba(79, 54, 24, .1), 0 26px 52px -34px rgba(79, 54, 24, .48);
  --shadow-glass: 0 18px 48px -36px rgba(79, 54, 24, .52), inset 0 1px 0 rgba(255, 255, 255, .82);
}

body,
.app-shell {
  background: var(--bg);
}

.workspace {
  background:
    radial-gradient(ellipse 50% 30% at 80% 5%, rgba(223, 153, 91, .06), transparent),
    radial-gradient(ellipse 40% 25% at 15% 90%, rgba(73, 111, 130, .04), transparent),
    transparent;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #FFF3DC;
  border: 1px solid rgba(140, 84, 34, .18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .82), 0 10px 22px -18px rgba(140, 84, 34, .64);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rail {
  padding: 18px 16px;
  background: rgba(255, 253, 248, .74);
  border-right: 1px solid rgba(73, 111, 130, .12);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .72);
  -webkit-backdrop-filter: blur(24px) saturate(1.24);
  backdrop-filter: blur(24px) saturate(1.24);
}

.rail-brand {
  min-height: 58px;
  padding: 7px;
  border-radius: 15px;
  border-color: rgba(140, 84, 34, .16);
  background: rgba(255, 253, 248, .78);
  box-shadow: var(--shadow-sm);
}

.rail .nav-item {
  position: relative;
  min-height: 46px;
  padding: 11px 12px;
  border-radius: 13px;
  color: rgba(31, 41, 55, .72);
}

.rail .nav-item:hover {
  color: var(--brand-deep);
  background: rgba(255, 247, 236, .9);
  border-color: rgba(140, 84, 34, .12);
}

.rail .nav-item.active {
  color: var(--brand-deep);
  background: rgba(246, 217, 184, .68);
  border-color: rgba(179, 110, 48, .24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 12px 26px -24px rgba(140, 84, 34, .72);
}

.rail .nav-item.active::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--sec);
  box-shadow: 0 0 0 5px rgba(73, 111, 130, .1);
  transform: translateY(-50%);
}

.topbar {
  min-height: 72px;
  padding: 13px 28px;
  background: rgba(255, 253, 248, .78);
  border-bottom: 1px solid rgba(73, 111, 130, .12);
  box-shadow: 0 12px 34px -34px rgba(79, 54, 24, .5);
  -webkit-backdrop-filter: blur(24px) saturate(1.22);
  backdrop-filter: blur(24px) saturate(1.22);
}

.top-title h1 {
  font-size: 1.24rem;
  line-height: 1.18;
}

.top-title p {
  color: rgba(75, 85, 99, .86);
}

.top-actions .badge.bad {
  background: #F2D5C6;
  border: 1px solid rgba(139, 47, 34, .14);
  color: #8B3B30;
}

.content {
  width: min(1180px, 100%);
  padding-top: 24px;
}

.panel,
.tile,
.stat-card,
.table-shell,
.tutorial-card,
.diagnostic-card,
.criterion,
.flashcard,
.mood-card,
.day-cell {
  border-radius: var(--radius-lg);
  border-color: rgba(140, 84, 34, .13);
  background: rgba(255, 253, 248, .92);
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: 24px;
}

.panel::before {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .86);
}

.panel-head {
  gap: 16px;
  margin-bottom: 18px;
}

.panel-head h2,
.section-title,
.diagnostic-intro h2,
.tutorial-copy h2 {
  font-size: 1.16rem;
  line-height: 1.28;
}

.muted,
.item-sub,
.tile p,
.auth-lead {
  color: rgba(75, 85, 99, .86);
}

.btn {
  min-height: 46px;
  border-radius: 13px;
  border-color: rgba(73, 111, 130, .14);
  background: rgba(255, 253, 248, .88);
  box-shadow: 0 2px 4px rgba(79, 54, 24, .06), 0 12px 24px -22px rgba(79, 54, 24, .46);
}

.btn:hover {
  box-shadow: var(--shadow-md);
}

.btn-primary {
  background: #DF995B;
  color: #fff;
  border-color: rgba(140, 84, 34, .12);
  box-shadow: 0 16px 28px -22px rgba(140, 84, 34, .86), inset 0 -3px 0 rgba(140, 84, 34, .28);
}

.btn-secondary {
  background: var(--sec);
  color: #fff;
  box-shadow: 0 16px 28px -24px rgba(47, 78, 94, .8), inset 0 -2px 0 rgba(0, 0, 0, .12);
}

.btn-ghost {
  background: rgba(255, 253, 248, .5);
  border-color: rgba(73, 111, 130, .16);
}

.field,
.select,
.textarea {
  min-height: 48px;
  border-radius: 13px;
  background: rgba(255, 253, 248, .94);
  border-color: rgba(73, 111, 130, .18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .72);
}

.hero-app {
  min-height: 300px;
  grid-template-columns: minmax(0, 1fr) 246px;
  align-items: center;
  background: #FAF3E8;
  border-color: rgba(140, 84, 34, .16);
  overflow: hidden;
}

.hero-app h2 {
  font-size: 1.56rem;
  line-height: 1.18;
  max-width: 760px;
}

.hero-copy .auth-lead {
  max-width: 720px;
  line-height: 1.62;
}

.hero-actions {
  gap: 12px;
}

.hero-mascot {
  width: min(246px, 100%);
  max-height: 270px;
  padding: 8px;
  border-radius: 22px;
  background: rgba(255, 253, 248, .58);
  border: 1px solid rgba(140, 84, 34, .1);
  object-fit: contain;
  filter: drop-shadow(0 24px 28px rgba(79, 54, 24, .2));
}

.badge,
.chip,
.tag,
.source-pill {
  border-radius: 999px;
  border: 1px solid rgba(140, 84, 34, .12);
}

.badge,
.tag {
  background: #F6D9B8;
  color: var(--brand-deep);
}

.chip,
.source-pill {
  background: rgba(255, 247, 236, .9);
}

.source-pill.ok {
  border-color: rgba(16, 185, 129, .2);
  background: rgba(221, 235, 210, .66);
}

.quick-strip {
  gap: 14px;
}

.quick-card,
.tile {
  min-height: 122px;
  padding: 18px;
  align-content: center;
  background: rgba(255, 253, 248, .9);
}

.quick-card:hover,
.tile:hover,
.item:hover {
  border-color: rgba(223, 153, 91, .3);
}

.tile-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-soft), rgba(246, 217, 184, .6));
  color: var(--brand-deep);
  box-shadow: 0 2px 8px -3px rgba(223, 153, 91, .25), inset 0 1px 0 rgba(255, 255, 255, .62);
}

.tile h3 {
  font-size: 1.04rem;
  line-height: 1.28;
}

.tile p {
  font-size: .92rem;
  line-height: 1.45;
}

.stat-card {
  min-height: 108px;
  padding: 17px;
  background: rgba(255, 253, 248, .9);
}

.stat-num {
  font-size: 1.28rem;
  line-height: 1.15;
  color: var(--ink);
}

.progress {
  height: 9px;
  background: rgba(31, 41, 55, .07);
}

.progress > span {
  background: #DF995B;
  box-shadow: 0 0 0 1px rgba(179, 110, 48, .08), 0 4px 12px rgba(223, 153, 91, .3);
}

.item,
.topic-node,
.diagnostic-meter div,
.tutorial-device,
.tutorial-checklist div,
.question-text,
.choice,
.match-tile,
.backend-card,
.ai-result {
  border-radius: 14px;
  background: rgba(255, 247, 236, .74);
  border-color: rgba(140, 84, 34, .13);
}

.item {
  padding: 14px;
  align-items: center;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.item.active,
.match-tile.selected {
  background: #FFF2DA;
  border-color: rgba(223, 153, 91, .42);
  box-shadow: inset 4px 0 0 #DF995B;
}

.item > .tile-icon,
.topic-node > .tile-icon {
  flex: 0 0 auto;
}

.item-title {
  font-size: .98rem;
  line-height: 1.32;
}

.item-sub {
  font-size: .9rem;
}

.chat-layout {
  gap: 18px;
}

.chat-room {
  min-height: calc(100vh - var(--topbar-h) - 64px);
}

.messages {
  background: rgba(255, 247, 236, .38);
}

.bubble {
  border-radius: 17px;
  background: rgba(255, 253, 248, .92);
  border-color: rgba(140, 84, 34, .12);
  box-shadow: 0 10px 22px -24px rgba(79, 54, 24, .5);
}

.message.user .bubble {
  background: var(--sec);
  color: #fff;
}

.chat-input {
  background: rgba(255, 253, 248, .82);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  backdrop-filter: blur(22px) saturate(1.2);
}

.question-text {
  border-style: solid;
  background: #FFF7EC;
}

.choice {
  align-items: center;
  background: rgba(255, 253, 248, .92);
}

.choice:has(input:checked) {
  border-color: rgba(223, 153, 91, .45);
  background: #FFF2DA;
  box-shadow: inset 4px 0 0 #DF995B;
}

.feedback.good,
.ai-result,
.backend-card.good {
  background: #F5FAF0;
  border-color: rgba(16, 185, 129, .24);
}

.feedback.bad,
.backend-card.bad {
  background: #FFF0EA;
  border-color: rgba(239, 68, 68, .22);
}

.map-block {
  padding: 16px;
  border: 1px solid rgba(140, 84, 34, .12);
  border-radius: var(--radius-lg);
  background: rgba(255, 247, 236, .52);
}

.topic-node {
  grid-template-columns: minmax(42px, auto) minmax(0, 1fr) auto;
}

.node-code {
  color: var(--sec-ink);
}

.social-status {
  gap: 14px;
}

.friend-card {
  align-items: center;
}

.item-actions .btn,
.support-actions .btn {
  min-height: 44px;
}

.avatar-xl {
  border-radius: 18px;
  background: #FFF3DC;
  border-color: rgba(140, 84, 34, .16);
}

.table-shell {
  background: rgba(255, 253, 248, .92);
}

.table th {
  color: rgba(75, 85, 99, .82);
}

@media (max-width: 1120px) {
  .hero-app {
    grid-template-columns: 1fr;
  }

  .hero-mascot {
    justify-self: start;
  }
}

@media (max-width: 860px) {
  :root {
    --mobile-gutter: clamp(12px, 3.2vw, 16px);
    --mobile-sheet-max: 820px;
  }

  body {
    font-size: 16px;
  }

  .topbar {
    min-height: 64px;
    padding: calc(8px + var(--safe-top)) calc(var(--mobile-gutter) + var(--safe-right)) 9px calc(var(--mobile-gutter) + var(--safe-left));
  }

  .top-title h1 {
    font-size: 1.12rem;
  }

  .top-actions > .badge {
    max-width: 110px;
  }

  .content {
    width: min(100%, var(--mobile-sheet-max));
    padding: 15px var(--mobile-gutter) calc(110px + var(--safe-bottom));
  }

  .grid {
    gap: 14px;
  }

  .panel {
    padding: 17px;
    border-radius: 16px;
  }

  .panel-head {
    margin-bottom: 14px;
  }

  .panel-head h2,
  .section-title {
    font-size: 1.08rem;
  }

  .hero-app {
    padding: 18px;
    gap: 12px;
  }

  .hero-app h2 {
    font-size: 1.3rem;
    line-height: 1.2;
  }

  .hero-copy .auth-lead {
    font-size: .96rem;
    line-height: 1.55;
  }

  .quick-strip,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .tile,
  .quick-card {
    min-height: 80px;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    text-align: left;
  }

  .tile-icon {
    width: 46px;
    height: 46px;
  }

  .tile h3 {
    font-size: 1.04rem;
  }

  .tile p {
    font-size: .88rem;
    line-height: 1.38;
  }

  .stat-card {
    min-height: 92px;
    padding: 14px;
  }

  .stat-num {
    font-size: 1.16rem;
  }

  .item {
    padding: 13px;
  }

  .bottom-nav {
    bottom: calc(11px + var(--safe-bottom)) !important;
    width: min(430px, calc(100vw - 28px - var(--safe-left) - var(--safe-right))) !important;
    min-height: 62px !important;
    padding: 6px !important;
    border-radius: 28px !important;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .14)),
      rgba(255, 255, 255, .18) !important;
    border-color: rgba(255, 255, 255, .74) !important;
    box-shadow:
      0 22px 48px -30px rgba(79, 54, 24, .58),
      inset 0 1px 0 rgba(255, 255, 255, .9),
      inset 0 -1px 0 rgba(255, 255, 255, .26) !important;
    -webkit-backdrop-filter: blur(38px) saturate(1.85) brightness(1.08) !important;
    backdrop-filter: blur(38px) saturate(1.85) brightness(1.08) !important;
  }

  .nav-active-pill {
    top: 6px;
    bottom: 6px;
    left: calc(6px + var(--nav-pill-x, 0%));
    width: calc(20% - 10px);
    border-radius: 22px;
    background:
      radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, .88), rgba(255, 255, 255, .22) 58%, rgba(255, 255, 255, .08)),
      linear-gradient(145deg, rgba(255, 249, 238, .44), rgba(223, 153, 91, .16) 48%, rgba(73, 111, 130, .08)),
      rgba(255, 255, 255, .24);
    border: 1px solid rgba(255, 255, 255, .78);
    -webkit-backdrop-filter: blur(30px) saturate(1.75) brightness(1.08);
    backdrop-filter: blur(30px) saturate(1.75) brightness(1.08);
    box-shadow:
      0 18px 32px -24px rgba(79, 54, 24, .46),
      0 1px 0 rgba(255, 255, 255, .5),
      inset 0 1px 0 rgba(255, 255, 255, .96),
      inset 0 -1px 0 rgba(140, 84, 34, .08),
      inset 0 0 18px rgba(255, 255, 255, .22);
  }

  .nav-active-pill::before {
    content: "";
    position: absolute;
    inset: 3px 5px auto;
    height: 42%;
    border-radius: 18px 18px 14px 14px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, .72), rgba(255, 255, 255, 0));
    opacity: .72;
  }

  .bottom-nav.dragging .nav-active-pill {
    transition: none;
    transform: scale(1.035);
    box-shadow:
      0 22px 36px -24px rgba(47, 78, 94, .36),
      0 2px 0 rgba(255, 255, 255, .42),
      inset 0 1px 0 rgba(255, 255, 255, .98),
      inset 0 -1px 0 rgba(73, 111, 130, .12),
      inset 0 0 22px rgba(255, 255, 255, .28);
  }

  .nav-active-pill::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 6px;
    width: 22px;
    height: 3px;
    border-radius: 999px;
    background: rgba(73, 111, 130, .24);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .58);
    transform: translateX(-50%);
  }

  .bottom-nav .nav-item {
    min-height: 50px;
    color: rgba(31, 41, 55, .72);
  }

  .bottom-nav .nav-item.active {
    color: #2F4E5E;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .content {
    padding-inline: 12px;
  }

  .panel {
    padding: 16px;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .quick-strip,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-app h2 {
    font-size: 1.24rem;
  }

  .hero-actions {
    gap: 9px;
  }

  .tile,
  .quick-card {
    min-height: 78px;
    padding: 13px;
  }

  .tile h3 {
    font-size: 1rem;
  }

  .tile p,
  .item-sub {
    font-size: .88rem;
  }

  .item-title {
    font-size: 1rem;
  }

  .social-status {
    grid-template-columns: 1fr;
  }

  .social-overview .row {
    width: 100%;
  }

  .social-overview .row .btn {
    flex: 1 1 150px;
  }

  .friend-card {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .item-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    width: 100%;
    min-width: 0;
  }

  .item-actions .btn {
    min-width: 0;
    width: 100%;
  }

  .topic-node {
    grid-template-columns: minmax(38px, auto) minmax(0, 1fr);
  }

  .topic-node > .row {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .topic-node > .row .btn,
  .topic-node > .row .badge {
    flex: 1 1 44px;
  }

  .bottom-nav {
    width: min(430px, calc(100vw - 24px - var(--safe-left) - var(--safe-right))) !important;
  }
}

@media (max-width: 460px) {
  .auth-provider-strip {
    grid-template-columns: 1fr;
  }
}

/* Structural refresh for app-like screens. */
.home-dashboard,
.practice-hub,
.map-hub,
.social-hub,
.profile-hub {
  display: grid;
  gap: 18px;
}

.home-command,
.practice-command,
.map-overview,
.social-command,
.profile-command {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 32px;
  background:
    radial-gradient(ellipse 80% 60% at 90% 20%, rgba(223, 153, 91, .12), transparent 55%),
    radial-gradient(ellipse 60% 50% at 10% 80%, rgba(73, 111, 130, .08), transparent 50%),
    linear-gradient(165deg, #FFFDF8, #FFF6E6);
  border-color: rgba(73, 111, 130, .12);
  border-bottom: 3px solid rgba(223, 153, 91, .15);
}

.home-command h2,
.practice-command h2,
.map-overview h2,
.social-command h2,
.profile-command h2 {
  margin-top: 12px;
  font-size: 2.2rem;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--ink), var(--brand-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.08;
}

.home-command-copy,
.social-command-copy,
.profile-command-copy {
  min-width: 0;
}

.home-route {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.route-step {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 24px;
  gap: 12px;
  align-items: center;
  min-height: 74px;
  padding: 14px 16px;
  border-radius: var(--radius-btn);
  border: 1px solid rgba(73, 111, 130, .1);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 2px 8px -4px rgba(79, 54, 24, .1);
  transition: all var(--dur-fast) var(--ease-spring);
}

.route-step:hover {
  transform: translateY(-2px) scale(1.01);
  border-color: rgba(223, 153, 91, .3);
  box-shadow: var(--shadow-md);
}

.route-step.done {
  border-color: rgba(16, 185, 129, .25);
  background: linear-gradient(135deg, rgba(16, 185, 129, .04), var(--surface));
}

.route-index {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(73, 111, 130, .12), rgba(73, 111, 130, .06));
  color: var(--sec-ink);
  font-weight: 900;
  font-size: .9rem;
  border: 1px solid rgba(73, 111, 130, .1);
}

.route-step.done .route-index {
  background: linear-gradient(135deg, #10B981, #34D399);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px -4px rgba(16, 185, 129, .4);
}

.route-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.route-copy strong {
  font-weight: 900;
  line-height: 1.22;
}

.route-copy small {
  color: rgba(75, 85, 99, .86);
  line-height: 1.35;
}

.route-icon {
  color: rgba(47, 78, 94, .72);
}

.home-command-aside {
  width: min(282px, 100%);
  display: grid;
  gap: 14px;
  justify-items: center;
}

.misha-frame {
  width: 100%;
  min-height: 236px;
  display: grid;
  place-items: end center;
  padding: 14px 18px 0;
  border-radius: var(--radius-card);
  background:
    radial-gradient(circle at 70% 30%, rgba(223, 153, 91, .15), transparent 50%),
    radial-gradient(circle at 20% 80%, rgba(73, 111, 130, .08), transparent 50%),
    linear-gradient(160deg, #FFF4E0, #FAF3E8);
  border: 1px solid rgba(223, 153, 91, .15);
  overflow: hidden;
  position: relative;
}

.misha-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(223, 153, 91, .12) 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: .5;
  pointer-events: none;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%);
}

.misha-frame .hero-mascot {
  width: min(230px, 100%);
  max-height: 250px;
  padding: 0;
  border: 0;
  background: transparent;
}

.home-score-card {
  width: 100%;
  display: grid;
  gap: 7px;
  padding: 14px;
  border-radius: var(--radius-btn);
  background: linear-gradient(135deg, var(--brand), #E8B07C);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(223, 153, 91, .4);
}

.home-score-card .tiny { color: rgba(255,255,255,.7); }
.home-score-card small { color: rgba(255,255,255,.75); }

.home-score-card strong {
  font-family: "Unbounded", "Manrope", sans-serif;
  font-size: 1.28rem;
  color: #fff;
}

.home-score-card .progress {
  background: rgba(255,255,255,.2);
}

.home-score-card .progress span {
  background: #fff;
}

.home-metrics,
.profile-metrics,
.social-status,
.map-overview-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.map-overview-stats,
.social-status {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.map-overview-stats {
  min-width: min(420px, 100%);
}

.metric-card {
  min-height: 96px;
  padding: 18px;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--brand);
  border-radius: 0 0 4px 4px;
}

.metric-card:nth-child(1)::after { background: var(--brand); }
.metric-card:nth-child(2)::after { background: var(--gold); }
.metric-card:nth-child(3)::after { background: var(--sec); }
.metric-card:nth-child(4)::after { background: var(--good); }

.metric-card .stat-num {
  font-size: 1.65rem;
  font-weight: 800;
  font-family: "Unbounded", sans-serif;
  letter-spacing: -0.03em;
}

.home-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr);
  gap: 18px;
  align-items: stretch;
}

.home-navigator,
.next-action-panel,
.activity-panel,
.profile-routes,
.achievements-panel,
.map-board,
.friends-panel,
.feed-panel,
.social-requests-panel {
  background: rgba(255, 253, 248, .88);
}

.home-navigator .quick-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.next-action-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 118px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(73, 111, 130, .13);
  background: #FFF7EC;
}

.tutorial-teaser {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.activity-timeline {
  display: grid;
  gap: 0;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 10px;
  border-radius: var(--radius);
  transition: background var(--dur-fast) ease;
}

.timeline-item:hover {
  background: rgba(223, 153, 91, .04);
}

.timeline-item + .timeline-item {
  border-top: 1px solid rgba(73, 111, 130, .06);
}

.timeline-dot {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--sec-ink);
  background: linear-gradient(135deg, rgba(73, 111, 130, .12), rgba(73, 111, 130, .06));
  border: 1px solid rgba(73, 111, 130, .08);
}

.practice-command {
  grid-template-columns: minmax(0, 1fr) auto;
}

.practice-section {
  display: grid;
  gap: 12px;
}

.mode-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mode-list-compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mode-tile {
  grid-template-columns: 56px minmax(0, 1fr);
  min-height: 112px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) ease, border-color var(--dur-fast) ease;
}

.mode-tile:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: var(--shadow-md);
  border-color: rgba(223, 153, 91, .2);
}

.mode-primary {
  min-height: 138px;
  background: linear-gradient(155deg, #FFF7EC, #FFFDF8);
  border-left: 4px solid var(--brand);
}

.knowledge-blocks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.map-block {
  align-content: start;
}

.map-block h3 {
  margin: 0;
  font-size: 1rem;
}

.map-block .list {
  margin-top: 10px;
}

.social-command {
  grid-template-columns: minmax(0, 1fr) minmax(230px, 310px);
}

.social-actions,
.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.partner-code-card {
  display: grid;
  gap: 8px;
  align-content: center;
  min-height: 168px;
  padding: 22px;
  border-radius: 20px;
  background: #FAF3E8;
  border: 1px solid rgba(73, 111, 130, .14);
}

.partner-code-card span,
.partner-code-card small {
  color: rgba(75, 85, 99, .86);
  font-weight: 800;
}

.partner-code-card strong {
  font-family: "Unbounded", "Manrope", sans-serif;
  font-size: 2rem;
  letter-spacing: .08em;
}

.social-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 18px;
  align-items: start;
}

.profile-command {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.profile-avatar-stack {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.profile-command .avatar-xl {
  width: 148px;
  height: 148px;
  border: 3px solid var(--brand);
  box-shadow: 0 8px 24px -8px rgba(223, 153, 91, .4);
}

.profile-command .avatar-xl img {
  width: 144px;
  height: 144px;
}

.profile-command .progress {
  max-width: 540px;
  margin-top: 18px;
}

.profile-route-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.achievement-card {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 166px;
  padding: 18px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid rgba(73, 111, 130, .1);
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) ease;
}

.achievement-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.achievement-card.done {
  background: linear-gradient(160deg, rgba(16, 185, 129, .05), var(--surface));
  border-color: rgba(16, 185, 129, .25);
}

.achievement-card.done .tile-icon {
  background: linear-gradient(135deg, #10B981, #34D399);
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(16, 185, 129, .35);
}

.achievement-card:not(.done) {
  opacity: .65;
}

.achievement-card:not(.done)[data-rarity="rare"],
.achievement-card:not(.done)[data-rarity="epic"],
.achievement-card:not(.done)[data-rarity="legendary"] {
  opacity: .8;
}

.achievement-card:not(.done)[data-rarity="common"] .tile-icon {
  filter: grayscale(.5);
}

.chat-list-hub,
.subject-change-hub {
  display: grid;
  gap: 18px;
}

.chat-list-command,
.subject-command {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  background: rgba(255, 253, 248, .9);
  border-color: rgba(73, 111, 130, .14);
}

.chat-list-command h2,
.subject-command h2 {
  margin-top: 12px;
  font-size: 2.05rem;
  line-height: 1.08;
}

.chat-list-command .hero-actions {
  justify-content: flex-end;
}

.subject-current-card {
  min-width: 250px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(73, 111, 130, .12);
  background: rgba(255, 247, 236, .66);
}

.subject-current-card strong {
  display: block;
  margin-top: 3px;
  font-family: "Unbounded", "Manrope", sans-serif;
  font-size: 1.02rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.subject-choice-card {
  width: 100%;
  min-height: 102px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  text-align: left;
  border-radius: 18px;
  border: 1px solid rgba(73, 111, 130, .12);
  background: rgba(255, 253, 248, .86);
  box-shadow: 0 10px 24px -22px rgba(31, 41, 55, .45);
}

.subject-choice-card.active {
  background: rgba(245, 250, 240, .78);
  border-color: rgba(16, 185, 129, .24);
}

.subject-mark {
  width: 54px;
  height: 54px;
  display: inline-grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(248, 220, 180, .76);
  color: #9A632B;
  font-weight: 900;
}

.diagnostics-panel,
.app-parity-panel {
  background: rgba(255, 253, 248, .88);
}

.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.diagnostic-tile {
  display: grid;
  gap: 6px;
  min-height: 118px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(73, 111, 130, .12);
  background: rgba(255, 247, 236, .66);
}

.diagnostic-tile span,
.diagnostic-tile small,
.parity-row small {
  color: rgba(75, 85, 99, .86);
  line-height: 1.35;
}

.diagnostic-tile strong {
  font-family: "Unbounded", "Manrope", sans-serif;
  font-size: 1.08rem;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.diagnostic-tile.good {
  background: rgba(245, 250, 240, .74);
  border-color: rgba(16, 185, 129, .2);
}

.diagnostic-tile.bad {
  background: rgba(255, 240, 234, .84);
  border-color: rgba(239, 68, 68, .2);
}

.diagnostic-tile.warn {
  background: rgba(255, 247, 236, .84);
  border-color: rgba(245, 158, 11, .22);
}

.diagnostics-issues {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.parity-list {
  display: grid;
  gap: 10px;
}

.parity-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 13px;
  border-radius: 15px;
  border: 1px solid rgba(73, 111, 130, .12);
  background: rgba(255, 247, 236, .56);
}

.parity-row.deep {
  background: rgba(245, 250, 240, .66);
  border-color: rgba(16, 185, 129, .18);
}

.parity-row.core {
  background: rgba(255, 253, 248, .76);
}

@media (max-width: 1120px) {
  .home-main-grid,
  .social-grid {
    grid-template-columns: 1fr;
  }

  .mode-list-compact,
  .profile-route-grid,
  .achievement-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .knowledge-blocks {
    grid-template-columns: 1fr;
  }

  .diagnostics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .home-command,
  .practice-command,
  .map-overview,
  .social-command,
  .profile-command,
  .chat-list-command,
  .subject-command {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 18px;
  }

  .home-command h2,
  .practice-command h2,
  .map-overview h2,
  .social-command h2,
  .profile-command h2,
  .chat-list-command h2,
  .subject-command h2 {
    font-size: 1.55rem;
  }

  .home-command-aside {
    width: 100%;
    justify-items: stretch;
  }

  .misha-frame {
    display: none;
  }

  .home-route,
  .mode-list,
  .mode-list-compact,
  .home-navigator .quick-strip,
  .subject-grid,
  .profile-route-grid,
  .achievement-grid {
    grid-template-columns: 1fr;
  }

  .home-metrics,
  .profile-metrics,
  .social-status,
  .map-overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-overview-stats {
    min-width: 0;
  }

  .next-action-card,
  .tutorial-teaser {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .next-action-card .btn,
  .tutorial-teaser .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .practice-command > .btn,
  .social-actions .btn,
  .profile-actions .btn,
  .chat-list-command .btn {
    width: 100%;
  }

  .chat-list-command .hero-actions {
    display: grid;
    justify-content: stretch;
  }

  .subject-current-card {
    min-width: 0;
  }

  .social-actions,
  .profile-actions {
    display: grid;
  }

  .partner-code-card {
    min-height: 128px;
  }

  .profile-command .avatar-xl {
    width: 124px;
    height: 124px;
  }

  .profile-command .avatar-xl img {
    width: 120px;
    height: 120px;
  }

  .parity-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .home-metrics,
  .profile-metrics,
  .social-status,
  .map-overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .route-step,
  .mode-tile {
    min-height: 82px;
  }

  .partner-code-card strong {
    font-size: 1.42rem;
  }

  .diagnostics-grid {
    grid-template-columns: 1fr;
  }

  .subject-choice-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .subject-choice-card .tag {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 860px) {
  .bottom-nav {
    width: min(452px, calc(100vw - 24px - var(--safe-left) - var(--safe-right))) !important;
    min-height: 64px !important;
    padding: 6px !important;
    border-radius: 30px !important;
    border-color: rgba(255, 255, 255, .74) !important;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .48), rgba(255, 255, 255, .16)),
      rgba(255, 255, 255, .2) !important;
    -webkit-backdrop-filter: blur(42px) saturate(1.9) brightness(1.08) !important;
    backdrop-filter: blur(42px) saturate(1.9) brightness(1.08) !important;
    box-shadow:
      0 26px 60px -34px rgba(47, 78, 94, .42),
      0 10px 26px -24px rgba(140, 84, 34, .3),
      inset 0 1px 0 rgba(255, 255, 255, .94),
      inset 0 -1px 0 rgba(255, 255, 255, .28) !important;
  }

  .nav-active-pill {
    top: 6px !important;
    bottom: 6px !important;
    left: calc(6px + var(--nav-pill-x, 0%)) !important;
    width: calc(20% - 10px) !important;
    border-radius: 24px !important;
    background:
      radial-gradient(130% 90% at 50% 0%, rgba(255, 255, 255, .92), rgba(255, 255, 255, .28) 58%, rgba(255, 255, 255, .08)),
      linear-gradient(145deg, rgba(255, 253, 248, .52), rgba(201, 220, 230, .28) 56%, rgba(223, 153, 91, .08)),
      rgba(255, 255, 255, .22) !important;
    border: 1px solid rgba(255, 255, 255, .82) !important;
    -webkit-backdrop-filter: blur(32px) saturate(1.85) brightness(1.08) !important;
    backdrop-filter: blur(32px) saturate(1.85) brightness(1.08) !important;
    box-shadow:
      0 20px 34px -25px rgba(47, 78, 94, .34),
      inset 0 1px 0 rgba(255, 255, 255, .98),
      inset 0 -1px 0 rgba(73, 111, 130, .1),
      inset 0 0 22px rgba(255, 255, 255, .28) !important;
  }

  .bottom-nav.dragging .nav-active-pill {
    transform: scale(1.04);
    box-shadow:
      0 24px 38px -25px rgba(47, 78, 94, .42),
      inset 0 1px 0 rgba(255, 255, 255, .98),
      inset 0 -1px 0 rgba(73, 111, 130, .12),
      inset 0 0 26px rgba(255, 255, 255, .32) !important;
  }

  .bottom-nav .nav-item.active {
    color: var(--sec-ink) !important;
  }
}

/* ===== Keyframe animations (matching MishaMotion) ===== */

@keyframes slide-up {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes bounce-in {
  0% { transform: scale(0.88); opacity: 0; }
  55% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scale-bounce {
  0% { transform: scale(1); }
  40% { transform: scale(0.92); }
  70% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(200%); }
}

/* Stagger animation for list children (StaggerDelayMs = 50) */
.list > .item,
.achievement-grid > .achievement-card,
.quick-strip > .quick-card,
.mode-list > .tile,
.profile-route-grid > .tile {
  animation: slide-up var(--dur-smooth) var(--ease-spring) both;
}

.list > .item:nth-child(1),
.achievement-grid > .achievement-card:nth-child(1),
.quick-strip > .quick-card:nth-child(1) { animation-delay: 0ms; }
.list > .item:nth-child(2),
.achievement-grid > .achievement-card:nth-child(2),
.quick-strip > .quick-card:nth-child(2) { animation-delay: 50ms; }
.list > .item:nth-child(3),
.achievement-grid > .achievement-card:nth-child(3),
.quick-strip > .quick-card:nth-child(3) { animation-delay: 100ms; }
.list > .item:nth-child(4),
.achievement-grid > .achievement-card:nth-child(4),
.quick-strip > .quick-card:nth-child(4) { animation-delay: 150ms; }
.list > .item:nth-child(5),
.achievement-grid > .achievement-card:nth-child(5),
.quick-strip > .quick-card:nth-child(5) { animation-delay: 200ms; }
.list > .item:nth-child(6) { animation-delay: 250ms; }
.list > .item:nth-child(7) { animation-delay: 300ms; }
.list > .item:nth-child(8) { animation-delay: 350ms; }

/* Progress bar shimmer */
.progress span {
  position: relative;
  overflow: hidden;
}

.progress span::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .28), transparent);
  animation: shimmer 2.5s infinite;
}

/* Page content entrance */
.content > .home-dashboard,
.content > .practice-hub,
.content > .profile-hub,
.content > .subject-change-hub,
.content > .lifebook-hub,
.content > .panel,
.content > .grid,
.content > .diagnostic-layout {
  animation: slide-up var(--dur-smooth) var(--ease-spring) both;
}

/* Achievement rarity tiers (matching WrappedColors) */
/* Rarity badge inline labels */
.rarity-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.rarity-rare {
  background: rgba(59, 130, 246, .12);
  color: #2563EB;
  border: 1px solid rgba(59, 130, 246, .2);
}

.rarity-epic {
  background: rgba(139, 92, 246, .12);
  color: #7C3AED;
  border: 1px solid rgba(139, 92, 246, .2);
}

.rarity-legendary {
  background: rgba(245, 158, 11, .15);
  color: #B45309;
  border: 1px solid rgba(245, 158, 11, .3);
}

/* Rarity card visual differentiation */
.achievement-card[data-rarity="rare"] {
  border-color: rgba(59, 130, 246, .2);
  border-left: 4px solid #3B82F6;
  background: linear-gradient(145deg, rgba(59, 130, 246, .04), var(--surface));
}

.achievement-card[data-rarity="rare"] .tile-icon {
  background: linear-gradient(135deg, #3B82F6, #60A5FA) !important;
  color: #fff !important;
  box-shadow: 0 4px 10px -4px rgba(59, 130, 246, .35);
}

.achievement-card[data-rarity="epic"] {
  border-color: rgba(139, 92, 246, .2);
  border-left: 4px solid #8B5CF6;
  background: linear-gradient(145deg, rgba(139, 92, 246, .04), var(--surface));
}

.achievement-card[data-rarity="epic"] .tile-icon {
  background: linear-gradient(135deg, #8B5CF6, #A78BFA) !important;
  color: #fff !important;
  box-shadow: 0 4px 10px -4px rgba(139, 92, 246, .35);
}

.achievement-card[data-rarity="legendary"] {
  border-color: rgba(245, 158, 11, .3);
  border-left: 4px solid #F59E0B;
  background: linear-gradient(145deg, rgba(245, 158, 11, .06), var(--surface));
  box-shadow: 0 0 20px -8px rgba(245, 158, 11, .2);
}

.achievement-card[data-rarity="legendary"] .tile-icon {
  background: linear-gradient(135deg, #F59E0B, #FBBF24) !important;
  color: #fff !important;
  box-shadow: 0 4px 14px -4px rgba(245, 158, 11, .5);
}

.achievement-card.done[data-rarity="legendary"] {
  box-shadow: 0 0 32px -6px rgba(255, 214, 110, .4), var(--shadow-sm);
}

/* Subject-accent tiles (lab cards) */
.mode-tile[data-subject-accent] {
  border-top: 5px solid var(--subject-color, var(--brand));
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--subject-color, var(--brand)) 6%, var(--surface)),
    var(--surface) 56px
  );
}

/* Hover polish for items and chips */
.item {
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) ease;
}

.item:hover {
  transform: translateY(-1px);
}

.chip {
  transition: transform var(--dur-fast) var(--ease-spring), background var(--dur-fast) ease, border-color var(--dur-fast) ease;
}

.chip:hover {
  transform: scale(1.03);
}

/* Wrapped Stories viewer */
.wrapped-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0A0A0A;
  animation: fade-in var(--dur-smooth) ease both;
}

.wrapped-progress {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  gap: 4px;
  z-index: 2;
}

.wrapped-progress-seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .25);
  overflow: hidden;
}

.wrapped-progress-seg.done {
  background: rgba(255, 255, 255, .9);
}

.wrapped-progress-seg.active .wrapped-progress-fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  animation: wrapped-fill 8s linear forwards;
}

@keyframes wrapped-fill {
  from { width: 0%; }
  to { width: 100%; }
}

.wrapped-card {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  height: min(680px, calc(100vh - 100px));
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  text-align: center;
  color: #fff;
  overflow: hidden;
  animation: bounce-in var(--dur-smooth) var(--ease-spring) both;
}

.wrapped-card-bg {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 0;
}

.wrapped-card > * {
  position: relative;
  z-index: 1;
}

.wrapped-big {
  font-family: "Unbounded", sans-serif;
  font-size: clamp(48px, 12vw, 80px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 16px 0;
  text-shadow: 0 4px 20px rgba(0, 0, 0, .25);
}

.wrapped-label {
  font-size: 1.1rem;
  font-weight: 700;
  opacity: .85;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.wrapped-sub {
  font-size: .95rem;
  opacity: .7;
  margin-top: 12px;
  max-width: 280px;
  line-height: 1.5;
}

.wrapped-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .15);
  backdrop-filter: blur(8px);
  border: none;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--dur-fast) ease;
}

.wrapped-close:hover {
  background: rgba(255, 255, 255, .3);
}

.wrapped-nav {
  position: absolute;
  top: 60px;
  bottom: 60px;
  width: 40%;
  z-index: 3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.wrapped-nav.left { left: 0; }
.wrapped-nav.right { right: 0; }

/* LifeBook timeline */
.lifebook-hub {
  display: grid;
  gap: 20px;
}

.book-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 220px;
  padding: 36px 24px;
  border-radius: var(--radius-card);
  background: linear-gradient(150deg, #6B4226, #3E2313);
  color: #FAF0DC;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.book-cover::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(212, 165, 74, .25);
  border-radius: 14px;
  pointer-events: none;
}

.book-cover h2 {
  color: #FAF0DC;
  font-size: 1.4rem;
}

.book-cover .icon {
  width: 36px;
  height: 36px;
  color: #D4A54A;
}

.book-label {
  font-family: "Unbounded", sans-serif;
  font-weight: 800;
  font-size: .7rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #D4A54A;
  border: 1px solid rgba(212, 165, 74, .4);
  padding: 4px 14px;
  border-radius: var(--radius-pill);
}

.book-subject {
  font-size: .85rem;
  opacity: .7;
}

.book-sub {
  font-size: .8rem;
  opacity: .55;
  margin-top: 4px;
}

.book-divider {
  width: 40px;
  height: 1px;
  background: rgba(212, 165, 74, .35);
}

.book-timeline {
  padding: 22px;
}

.book-timeline .timeline {
  position: relative;
  padding-left: 28px;
}

.book-timeline .timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: linear-gradient(180deg, var(--brand-soft), var(--line));
  border-radius: 1px;
}

.book-timeline .timeline-entry {
  position: relative;
  padding: 0 0 20px;
  animation: slide-up var(--dur-smooth) var(--ease-spring) both;
}

.book-timeline .timeline-entry:last-child {
  padding-bottom: 0;
}

.book-timeline .timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand-soft);
  border: 2px solid var(--brand);
}

.book-timeline .timeline-dot.dot-gold {
  background: rgba(245, 158, 11, .2);
  border-color: var(--gold);
}

.book-timeline .timeline-dot.dot-teal {
  background: rgba(16, 185, 129, .2);
  border-color: var(--good);
}

.book-timeline .timeline-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.book-timeline .timeline-card .timeline-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  color: var(--brand-ink);
}

.book-timeline .timeline-card .timeline-icon .icon {
  width: 16px;
  height: 16px;
}

/* Score prediction panel */
.score-prediction-panel .prediction-display {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding: 20px 0 8px;
}

.prediction-big {
  font-family: "Unbounded", sans-serif;
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--brand);
  line-height: 1;
}

.prediction-display .muted {
  font-size: 1.1rem;
}

.prediction-status {
  font-size: .85rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.prediction-status.good {
  background: var(--good-soft);
  color: #2F6B3B;
}

/* ===== Spotlight onboarding tour ===== */
html.spotlight-lock {
  scroll-behavior: auto;
}

html.spotlight-lock .content > * {
  animation: none !important;
}

html.spotlight-lock .topbar {
  z-index: 9999;
}

.spotlight-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 12, 8, .5);
  animation: fade-in var(--dur-fast) ease both;
  overflow: hidden;
}

.spotlight-cutout {
  display: none;
}

.spotlight-target {
  position: relative !important;
  z-index: 10001 !important;
  outline: 3px solid var(--brand) !important;
  outline-offset: 8px !important;
  box-shadow: 0 0 0 8px rgba(223, 153, 91, .12), 0 0 60px 12px rgba(223, 153, 91, .18), var(--shadow-lg) !important;
  border-radius: var(--radius-card) !important;
  animation: spotlight-pulse 2s ease-in-out infinite !important;
}

@keyframes spotlight-pulse {
  0%, 100% { outline-color: var(--brand); }
  50% { outline-color: rgba(223, 153, 91, .5); }
}

.spotlight-tooltip {
  position: fixed;
  width: min(370px, calc(100vw - 32px));
  padding: 24px;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 24px 64px -16px rgba(15, 12, 8, .35), 0 8px 20px rgba(79, 54, 24, .12);
  animation: bounce-in var(--dur-smooth) var(--ease-spring) both;
  z-index: 10005;
  border: 1px solid rgba(223, 153, 91, .15);
}

.spotlight-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.spotlight-step {
  font-size: .72rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.spotlight-progress-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.spotlight-progress-bar span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--brand), #E8B07C);
  transition: width var(--dur-smooth) var(--ease-spring);
}

.spotlight-tooltip h3 {
  font-size: 1.18rem;
  margin-bottom: 8px;
}

.spotlight-tooltip p {
  color: var(--ink-2);
  font-size: .88rem;
  line-height: 1.6;
  margin-bottom: 20px;
}

.spotlight-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.spotlight-actions .btn {
  min-height: 42px;
  padding: 10px 20px;
  font-size: .84rem;
}

.spotlight-skip {
  margin-left: auto;
  opacity: .5;
  font-size: .78rem !important;
  min-height: 36px !important;
  padding: 8px 12px !important;
}

@media (max-width: 860px) {
  .spotlight-tooltip {
    position: fixed;
    bottom: calc(var(--mobile-nav-h, 72px) + 16px + var(--safe-bottom, 0px)) !important;
    top: auto !important;
    left: 12px !important;
    right: 12px;
    width: auto;
    max-width: none;
    padding: 14px 16px;
    font-size: 0.88rem;
  }
  .spotlight-tooltip h3 {
    font-size: 1rem;
    margin-bottom: 4px;
  }
  .spotlight-tooltip p {
    font-size: 0.82rem;
    margin-bottom: 12px;
    line-height: 1.5;
  }
  .spotlight-actions {
    flex-direction: row;
    gap: 6px;
  }
  .spotlight-actions .btn {
    min-height: 38px;
    padding: 8px 14px;
    font-size: 0.8rem;
    flex: 1;
    justify-content: center;
  }
  .spotlight-skip {
    flex: 0;
    margin-left: auto;
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Final mobile tabbar pass: wider liquid-glass dock with a light movable selector. */
@media (max-width: 860px) {
  :root {
    --mobile-gutter: clamp(14px, 3.2vw, 18px);
    --mobile-nav-h: 82px;
  }

  .content {
    width: min(100%, 780px);
    padding: 16px var(--mobile-gutter) calc(108px + var(--safe-bottom));
  }

  .bottom-nav {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 6px !important;
    bottom: calc(10px + var(--safe-bottom)) !important;
    width: min(476px, calc(100vw - 16px - var(--safe-left) - var(--safe-right))) !important;
    min-height: 70px !important;
    padding: 7px !important;
    border-radius: 34px !important;
    border: 1px solid rgba(255, 255, 255, .8) !important;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, .54), rgba(255, 255, 255, .18)),
      rgba(255, 253, 248, .58) !important;
    -webkit-backdrop-filter: blur(44px) saturate(1.85) brightness(1.08) !important;
    backdrop-filter: blur(44px) saturate(1.85) brightness(1.08) !important;
    box-shadow:
      0 24px 64px -36px rgba(47, 78, 94, .5),
      0 14px 30px -28px rgba(140, 84, 34, .42),
      inset 0 1px 0 rgba(255, 255, 255, .96),
      inset 0 -1px 0 rgba(255, 255, 255, .32) !important;
    isolation: isolate;
    touch-action: pan-y;
  }

  .bottom-nav::before {
    inset: 2px 2px auto 2px;
    height: 48%;
    border-radius: 32px 32px 24px 24px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .62), rgba(255, 255, 255, 0));
    opacity: .86;
  }

  .nav-active-pill {
    display: block !important;
    top: 7px !important;
    bottom: 7px !important;
    left: calc(7px + var(--nav-pill-x, 0%)) !important;
    width: calc(20% - 14px) !important;
    border-radius: 27px !important;
    background:
      radial-gradient(120% 72% at 50% 7%, rgba(255, 255, 255, .96), rgba(255, 255, 255, .36) 58%, rgba(255, 255, 255, .08)),
      linear-gradient(145deg, rgba(255, 248, 236, .52), rgba(201, 220, 230, .24) 48%, rgba(223, 153, 91, .12)),
      rgba(255, 247, 236, .26) !important;
    border: 1px solid rgba(255, 255, 255, .86) !important;
    -webkit-backdrop-filter: blur(34px) saturate(1.9) brightness(1.09) !important;
    backdrop-filter: blur(34px) saturate(1.9) brightness(1.09) !important;
    box-shadow:
      0 18px 34px -26px rgba(47, 78, 94, .42),
      inset 0 1px 0 rgba(255, 255, 255, .98),
      inset 0 -1px 0 rgba(140, 84, 34, .08),
      inset 0 0 24px rgba(255, 255, 255, .32) !important;
  }

  .nav-active-pill::before {
    inset: 4px 6px auto;
    height: 40%;
    border-radius: 22px 22px 16px 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .78), rgba(255, 255, 255, 0));
  }

  .nav-active-pill::after {
    bottom: 7px;
    width: 22px;
    height: 3px;
    background: rgba(73, 111, 130, .23);
  }

  .bottom-nav.dragging .nav-active-pill {
    transform: scale(1.045);
    transition: none !important;
    box-shadow:
      0 24px 42px -26px rgba(47, 78, 94, .48),
      inset 0 1px 0 rgba(255, 255, 255, .98),
      inset 0 -1px 0 rgba(73, 111, 130, .12),
      inset 0 0 28px rgba(255, 255, 255, .36) !important;
  }

  .bottom-nav .nav-item {
    min-height: 56px !important;
    padding: 9px 4px !important;
    border-radius: 26px !important;
    color: rgba(31, 41, 55, .7) !important;
  }

  .bottom-nav .nav-item .icon {
    width: 24px;
    height: 24px;
    stroke-width: 2.25;
  }

  .bottom-nav .nav-item span {
    display: none !important;
  }

  .bottom-nav .nav-item.active {
    color: #2F4E5E !important;
    cursor: grab;
    touch-action: none;
  }

  .bottom-nav.dragging .nav-item.active {
    cursor: grabbing;
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  @media (max-width: 860px) {
    .bottom-nav {
      background: rgba(255, 253, 248, .94) !important;
    }
  }
}

/* ── Task 1: Confirmation dialog ── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(31, 41, 55, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: confirmFadeIn var(--dur-fast) ease;
}

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

.confirm-dialog {
  width: min(420px, 90vw);
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 28px 24px 20px;
  box-shadow: var(--shadow-lg);
  animation: confirmSlideUp var(--dur-smooth) var(--ease-spring);
}

@keyframes confirmSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.confirm-dialog h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 800;
}

.confirm-dialog p {
  margin: 0 0 20px;
  color: var(--ink-2);
  line-height: 1.5;
}

.confirm-dialog .confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Task 2: Hint panel ── */
.hint-panel {
  background: var(--brand-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 12px;
  line-height: 1.55;
  color: var(--brand-deep);
  font-weight: 600;
  animation: hintSlideDown var(--dur-smooth) var(--ease-spring);
  border: 1px solid rgba(223, 153, 91, .22);
}

@keyframes hintSlideDown {
  from { opacity: 0; transform: translateY(-10px); max-height: 0; }
  to { opacity: 1; transform: translateY(0); max-height: 200px; }
}

/* ── Task 3: Form validation feedback ── */
.field:invalid:not(:placeholder-shown) {
  border-color: var(--bad);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23EF4444' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' stroke='%23EF4444' stroke-width='1.5' fill='none'/%3E%3Cline x1='8' y1='4.5' x2='8' y2='9' stroke='%23EF4444' stroke-width='1.5' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11.5' r='1' fill='%23EF4444'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.field:valid:not(:placeholder-shown) {
  border-color: var(--good);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' stroke='%2310B981' stroke-width='1.5'/%3E%3Cpath d='M5 8.5l2 2 4-4.5' stroke='%2310B981' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.field-error {
  display: block;
  margin-top: 6px;
  font-size: .82rem;
  font-weight: 700;
  color: var(--bad);
  line-height: 1.3;
}

.textarea-counter {
  display: block;
  text-align: right;
  margin-top: 4px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-3);
}

.textarea-counter.over {
  color: var(--bad);
  font-weight: 800;
}

/* ── Task 4: Loading button state ── */
.btn.loading {
  opacity: .65;
  pointer-events: none;
  position: relative;
}

.btn.loading .icon {
  visibility: hidden;
}

.btn.loading::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border: 2.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btnSpin .65s linear infinite;
}

@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

/* === Task 1: Topic node progress bar & mastery badge === */

.topic-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mastery-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  line-height: 1;
  white-space: nowrap;
}

.mastery-badge.mastery-low {
  background: rgba(107, 114, 128, .15);
  color: var(--ink-3);
}

.mastery-badge.mastery-mid {
  background: rgba(245, 158, 11, .15);
  color: #92400E;
}

.mastery-badge.mastery-high {
  background: rgba(16, 185, 129, .15);
  color: #065F46;
}

.topic-progress-bar {
  display: block;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin-top: 6px;
  overflow: hidden;
}

.topic-progress-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  transition: width .3s ease;
}

/* === Task 2: Exam question navigator === */

.exam-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--line);
  margin-top: 12px;
}

.exam-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.exam-nav-btn:hover {
  border-color: var(--brand);
  color: var(--brand-ink);
}

.exam-nav-btn.answered {
  background: var(--good);
  color: #fff;
  border-color: transparent;
}

/* === Task 3: Markdown code blocks in chat === */

.bubble pre {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: .85rem;
  line-height: 1.5;
}

.bubble pre code {
  background: transparent;
  padding: 0;
  border: none;
  font-size: inherit;
}

.bubble code {
  background: rgba(31, 41, 55, .07);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: .88em;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
}

.bubble ul {
  margin: 6px 0;
  padding-left: 20px;
}

.bubble ul li {
  margin-bottom: 3px;
  line-height: 1.5;
}

.message.user .bubble code {
  background: rgba(255, 255, 255, .18);
}

.message.user .bubble pre {
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .2);
}

/* === Task 4: Typing indicator === */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-3);
  font-size: .92rem;
}

.typing-dots {
  display: inline-flex;
  gap: 1px;
}

.typing-dots span {
  animation: typingBounce 1.4s ease-in-out infinite;
  font-weight: 700;
  font-size: 1.1em;
}

.typing-dots span:nth-child(2) {
  animation-delay: .2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: .4s;
}

@keyframes typingBounce {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── Task 11: Stats mini-charts ── */
.mini-chart {
  width: 100%;
  max-width: 400px;
  height: 60px;
  margin-top: 8px;
  display: block;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.heatmap-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: var(--radius-sm, 8px);
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink-1);
  transition: transform .15s ease;
}

.heatmap-cell:hover {
  transform: scale(1.08);
}

.heatmap-cell span {
  font-size: .68rem;
  font-weight: 500;
  color: var(--ink-3);
}

.heatmap-cell strong {
  font-size: .82rem;
}

/* ── Task 12: Friend profile card ── */
.friend-profile-card {
  border-radius: var(--radius-card, 16px);
  background: var(--surface);
  border: 1px solid rgba(73, 111, 130, .1);
  overflow: hidden;
}

.friend-profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(223, 153, 91, .15) 0%, rgba(73, 111, 130, .10) 100%);
}

.friend-avatar-circle {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  background: var(--accent, #df995b);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .88rem;
  letter-spacing: .02em;
}

.friend-header-info {
  flex: 1;
  min-width: 0;
}

.friend-profile-body {
  padding: 12px 18px 8px;
}

.friend-profile-card .item-actions {
  padding: 8px 18px 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Task 15: Print exam report ── */
.print-report {
  display: none;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.print-table th,
.print-table td {
  border: 1px solid #ccc;
  padding: 6px 10px;
  text-align: left;
  font-size: .85rem;
}

.print-table thead {
  background: #f5f0e8;
}

@media print {
  body * {
    visibility: hidden !important;
  }

  body.printing-report .print-report,
  body.printing-report .print-report * {
    visibility: visible !important;
  }

  body.printing-report .print-report {
    display: block !important;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    padding: 24px;
    background: #fff;
    color: #000;
    font-family: serif;
    font-size: 12pt;
    z-index: 99999;
  }

  body.printing-report .print-report h1 {
    font-size: 18pt;
    margin-bottom: 8px;
  }

  body.printing-report .print-report h2 {
    font-size: 14pt;
    margin-top: 16px;
    margin-bottom: 6px;
  }

  body.printing-report .print-report table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    page-break-inside: auto;
  }

  body.printing-report .print-report th,
  body.printing-report .print-report td {
    border: 1px solid #999;
    padding: 4px 8px;
    font-size: 10pt;
  }

  body.printing-report .print-report ul {
    padding-left: 20px;
  }

  body.printing-report .print-report li {
    margin-bottom: 4px;
  }
}

/* ── Task 19: Tablet responsive (768-1024px) ── */
@media (min-width: 768px) and (max-width: 1024px) {
  .quick-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-main-grid {
    grid-template-columns: 1fr;
  }

  .mode-list-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .achievement-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .content {
    padding-left: 20px;
    padding-right: 20px;
  }

  .workspace {
    padding-left: 8px;
    padding-right: 8px;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  .panel {
    padding: 20px;
  }

  .item-title {
    font-size: .92rem;
  }

  .item-sub {
    font-size: .82rem;
  }
}

/* ── 1. Offline / Online indicator ── */
.offline-badge,
.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: .78rem;
  font-weight: 700;
  color: #fff;
  z-index: 1000;
  animation: badge-pop var(--dur-smooth) var(--ease-bounce) both;
  white-space: nowrap;
}

.offline-badge {
  background: var(--bad);
}

.offline-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fca5a5;
  animation: pulse-dot 1.5s infinite;
}

.online-badge {
  background: var(--good);
}

.online-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6ee7b7;
}

@keyframes badge-pop {
  from { opacity: 0; transform: scale(.85); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ── 2. Share button ── */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-btn);
  font-weight: 700;
  font-size: .9rem;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-bounce), box-shadow var(--dur-fast);
}

.share-btn:hover {
  transform: scale(1.04);
  box-shadow: var(--shadow-md);
}

.share-btn:active {
  transform: scale(.97);
}

/* ── 3. Skeleton loader variants ── */
.skeleton-card {
  height: 200px;
  border-radius: var(--radius-card);
  background: linear-gradient(90deg, var(--surface-2) 25%, rgba(255, 253, 248, .6) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--surface-2) 25%, rgba(255, 253, 248, .6) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  flex-shrink: 0;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.skeleton-grid .skeleton-card {
  height: 200px;
}

@media (min-width: 860px) {
  .skeleton-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ── 4. Table mobile card view ── */
@media (max-width: 760px) {
  .table-shell {
    overflow: visible;
  }

  .table {
    display: block;
    min-width: 0;
  }

  .table thead {
    display: none;
  }

  .table tbody {
    display: block;
  }

  .table tr {
    display: block;
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
  }

  .table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
    text-align: right;
  }

  .table td:last-child {
    border-bottom: none;
  }

  .table td::before {
    content: attr(data-label);
    font-weight: 800;
    font-size: .82rem;
    color: var(--ink-3);
    text-align: left;
    flex-shrink: 0;
  }
}

/* ── 5. Peer review status indicators ── */
.review-status {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.review-status.pending {
  background: var(--bad);
  box-shadow: 0 0 0 3px var(--bad-soft);
}

.review-status.in-progress {
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .2);
}

.review-status.done {
  background: var(--good);
  box-shadow: 0 0 0 3px var(--good-soft);
}

.peer-tab-content {
  animation: peer-fade-in var(--dur-smooth) ease both;
}

@keyframes peer-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 6. Weekly plan calendar grid ── */
.weekly-plan-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.plan-day {
  min-height: 80px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-day.today {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(223, 153, 91, .2);
}

.plan-day-header {
  font-size: .72rem;
  font-weight: 800;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.plan-day-topic {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink-2);
  line-height: 1.3;
}

.plan-day-topic .subj-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

@media (max-width: 560px) {
  .weekly-plan-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ── Task 3: Message slide animation ── */
.bubble {
  animation: msg-appear .3s var(--ease-spring) both;
}

@keyframes msg-appear {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to { opacity: 1; transform: none; }
}

/* ── Task 6: Bottom nav ripple effect ── */
.bottom-nav .nav-item {
  position: relative;
  overflow: hidden;
}

.bottom-nav .nav-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(223, 153, 91, .2) 0%, transparent 60%);
  opacity: 0;
  transition: opacity .3s;
}

.bottom-nav .nav-item:active::after {
  opacity: 1;
}

/* ── Task 2: Chat avatars + message grouping ── */
.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.user-avatar {
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
}

.message {
  grid-template-columns: 32px 1fr;
  column-gap: 8px;
}

.message.user {
  grid-template-columns: 1fr 32px;
}

.message .message-meta {
  grid-column: 2;
}

.message.user .message-meta {
  grid-column: 1;
}

.message.user .bubble {
  grid-column: 1;
  grid-row: 1;
}

.message.user .chat-avatar {
  grid-column: 2;
  grid-row: 1;
}

.bubble.grouped {
  margin-top: -10px;
}

.message.grouped {
  margin-top: -10px;
}

.message.grouped .chat-avatar {
  visibility: hidden;
}

.message.grouped .message-meta {
  display: none;
}

/* ── Task 4: Leaderboard medals ── */
.medal {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: .75rem;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
  margin-right: 6px;
  vertical-align: middle;
}

.medal-gold {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  box-shadow: 0 2px 6px rgba(245, 158, 11, .4);
}

.medal-silver {
  background: linear-gradient(135deg, #9CA3AF, #6B7280);
  box-shadow: 0 2px 6px rgba(107, 114, 128, .4);
}

.medal-bronze {
  background: linear-gradient(135deg, #D97706, #92400E);
  box-shadow: 0 2px 6px rgba(146, 64, 14, .4);
}

.my-rank {
  background: var(--brand-soft);
  border-left: 3px solid var(--brand);
}

/* ── Task 5: Streak calendar today ring + hover ── */
.day-cell.today {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  animation: today-ring 2s ease-in-out infinite;
}

@keyframes today-ring {
  0%, 100% { outline-color: var(--brand); }
  50% { outline-color: rgba(223, 153, 91, .35); }
}

.day-cell:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
  transition: transform .15s var(--ease-spring), box-shadow .15s ease;
}

/* Dark mode removed — requires full audit of 7000+ lines of hardcoded colors.
   Will implement properly with class-based toggle (.theme-dark) in a future pass. */

/* ── Wardrobe Items (Change 1) ── */

.wardrobe-item {
  position: relative;
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 14px 10px;
  min-height: 100px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 900;
  font-size: .85rem;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
}

.wardrobe-item-preview {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.wardrobe-item-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wardrobe-item-label {
  font-weight: 900;
  font-size: .82rem;
}

.wardrobe-item.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(223, 153, 91, .18);
  animation: wardrobe-bounce .4s var(--ease-bounce);
}

@keyframes wardrobe-bounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  70% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.wardrobe-item.locked {
  opacity: .5;
  filter: grayscale(.8);
  cursor: not-allowed;
  pointer-events: none;
}

.wardrobe-item-lock {
  position: absolute;
  top: 8px;
  right: 8px;
  color: var(--ink-3);
}

.wardrobe-item-lock .icon {
  width: 16px;
  height: 16px;
}

.wardrobe-item-unlock {
  font-size: .7rem;
  font-weight: 700;
  color: var(--ink-3);
}

/* ── Mission Steps (Change 2) ── */

.mission-steps {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.mission-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.mission-step-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-3);
}

.mission-step-icon .icon {
  width: 16px;
  height: 16px;
}

.mission-step.done .mission-step-icon {
  background: var(--good-soft);
  color: var(--good);
}

.mission-step-label {
  font-size: .88rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.mission-progress {
  flex: 1;
  height: 4px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  min-width: 60px;
}

.mission-progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width var(--dur-smooth) var(--ease-spring);
}

.mission-step.done .mission-progress-fill {
  background: var(--good);
}

.mission-step-count {
  font-size: .75rem;
  font-weight: 800;
  color: var(--ink-3);
  min-width: 28px;
  text-align: right;
}

.mission-step-check {
  color: var(--good);
  flex-shrink: 0;
}

.mission-step-check .icon {
  width: 18px;
  height: 18px;
}

/* ── Chat Search (Change 3) ── */

.chat-search-wrap {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.chat-search-icon {
  position: absolute;
  left: 10px;
  color: var(--ink-3);
  pointer-events: none;
}

.chat-search-icon .icon {
  width: 16px;
  height: 16px;
}

.chat-search {
  padding-left: 34px !important;
  border-radius: var(--radius-pill) !important;
  font-size: .85rem;
  background: var(--surface-2);
}

/* ── Retry Button (Change 4) ── */

.retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--bad);
  background: transparent;
  color: var(--bad);
  font-size: .8rem;
  font-weight: 800;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.retry-btn .icon {
  width: 14px;
  height: 14px;
}

.retry-btn:hover {
  background: var(--bad-soft);
  color: #8B2F22;
}

.message.error .bubble {
  border-color: var(--bad);
  background: #FFF5F3;
  border-width: 1px;
}

/* ── Mood Cards with Icons (Change 5) ── */

.mood-card.mood-card-icon {
  min-height: 100px;
  padding: 16px 12px;
  gap: 8px;
  background: var(--mood-bg, var(--surface));
  color: var(--mood-color, var(--ink));
  transition: transform var(--dur-fast) var(--ease-bounce), border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.mood-card-ic {
  display: grid;
  place-items: center;
}

.mood-card-ic .icon {
  width: 32px;
  height: 32px;
}

.mood-card-label {
  font-size: .85rem;
  font-weight: 900;
}

.mood-card.mood-card-icon:has(input:checked) {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(223, 153, 91, .18), 0 0 16px rgba(223, 153, 91, .10);
  transform: scale(1.03);
}

/* ── Settings Collapsible Sections (Change 6) ── */

.settings-page {
  display: grid;
  gap: 16px;
}

details.settings-section {
  border-radius: var(--radius-card);
}

details.settings-section summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 900;
  list-style: none;
  padding: 4px 0;
  user-select: none;
}

details.settings-section summary::-webkit-details-marker {
  display: none;
}

details.settings-section summary > span {
  flex: 1;
}

.settings-chevron {
  width: 18px;
  height: 18px;
  transition: transform var(--dur-fast) var(--ease-spring);
  color: var(--ink-3);
}

details[open].settings-section .settings-chevron {
  transform: rotate(90deg);
}

details.settings-section summary .icon:first-child {
  width: 20px;
  height: 20px;
  color: var(--brand);
}

/* ── Leaderboard Filter (Change 7) ── */
/* Uses existing .chip / .chip.active styling — no extra CSS needed */

/* ═══════════════════════════════════════════════════════════════════
   Lab Hub & Interactive Labs
   ═══════════════════════════════════════════════════════════════════ */

.lab-hub-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.lab-hub-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.lab-hub-header .muted {
  margin: 2px 0 0;
}

.lab-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.lab-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  cursor: pointer;
  transition: box-shadow var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
  text-align: left;
  width: 100%;
}

.lab-card:hover {
  border-color: var(--brand-soft);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.lab-card:active {
  transform: scale(0.98);
}

.lab-card-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--bg-warm);
  font-size: 22px;
  flex-shrink: 0;
  color: var(--sec);
}

.lab-card-body {
  flex: 1;
  min-width: 0;
}

.lab-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.lab-card-desc {
  font-size: 0.82rem;
  color: var(--ink-2);
  margin-top: 2px;
  line-height: 1.35;
}

.lab-card-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

.lab-card-badge.done {
  background: var(--good);
  color: #fff;
}

.lab-card-arrow {
  width: 18px;
  height: 18px;
  color: var(--ink-3);
  flex-shrink: 0;
}

/* Lab view (individual lab) */
.lab-view {
  max-width: 960px;
  margin: 0 auto;
}

.lab-view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.lab-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--sec);
}

.lab-view-title {
  margin: 0;
  font-size: 1.25rem;
}

.lab-view-subject {
  margin: 2px 0 0;
}

.lab-view-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Lab panels */
.lab-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 24px;
}

.lab-panel h3 {
  margin: 0 0 16px;
  font-size: 1.05rem;
}

.lab-panel p {
  margin: 0 0 12px;
  line-height: 1.55;
}

.lab-panel p:last-child {
  margin-bottom: 0;
}

/* Lab canvas */
.lab-interactive-canvas {
  width: 100%;
  height: 360px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  display: block;
  touch-action: none;
}

/* Lab sliders */
.lab-slider {
  display: grid;
  grid-template-columns: 120px 1fr 60px;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.lab-slider-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.lab-slider-value {
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  background: var(--bg-warm);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}

/* Lab quiz */
.lab-quiz {
  margin-top: 16px;
}

.lab-quiz-item {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.lab-quiz-question {
  margin: 0 0 12px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.lab-quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lab-quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast);
  font-size: 0.9rem;
}

.lab-quiz-option:hover {
  border-color: var(--brand-soft);
}

.lab-quiz-option.correct {
  border-color: var(--good);
  background: var(--good-soft);
}

.lab-quiz-option.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.lab-quiz-option input[type="radio"] {
  accent-color: var(--brand);
}

.lab-quiz-feedback {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-warm);
  font-size: 0.85rem;
  line-height: 1.4;
}

.lab-quiz-check {
  margin-top: 12px;
}

.lab-quiz-result {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-align: center;
  background: var(--bad-soft);
  color: var(--bad);
}

.lab-quiz-result.all-correct {
  background: var(--good-soft);
  color: var(--good);
}

/* Drag and drop */
.lab-drag-item {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  background: var(--surface);
  border: 2px dashed var(--line-2);
  border-radius: var(--radius-sm);
  cursor: grab;
  font-size: 0.88rem;
  font-weight: 600;
  transition: transform var(--dur-fast), box-shadow var(--dur-fast);
  user-select: none;
  touch-action: none;
}

.lab-drag-item:active,
.lab-drag-item.dragging {
  cursor: grabbing;
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
  opacity: 0.8;
}

.lab-drop-zone {
  min-height: 48px;
  padding: 8px;
  border: 2px dashed var(--line-2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.lab-drop-zone.drag-over {
  border-color: var(--brand);
  background: rgba(223, 153, 91, .08);
}

.lab-drop-zone.filled {
  border-style: solid;
  border-color: var(--good);
  background: var(--good-soft);
}

.lab-drop-zone.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

/* Lab info blocks */
.lab-info {
  padding: 14px 18px;
  background: rgba(73, 111, 130, .06);
  border-left: 3px solid var(--sec);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 16px;
}

.lab-info strong {
  color: var(--sec-ink);
}

/* Lab step indicator */
.lab-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.lab-step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  transition: background var(--dur-fast);
}

.lab-step.active {
  background: var(--brand);
}

.lab-step.done {
  background: var(--good);
}

/* Lab tags */
.lab-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.lab-tag {
  padding: 4px 10px;
  background: var(--bg-warm);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-deep);
}

/* Lab timer */
.lab-timer {
  font-family: "Unbounded", monospace;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  color: var(--sec);
  padding: 12px;
}

/* Lab text input fields */
.lab-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.9rem;
  transition: border-color var(--dur-fast);
}

.lab-input:focus {
  border-color: var(--brand);
  outline: none;
}

.lab-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
}

.lab-textarea:focus {
  border-color: var(--brand);
  outline: none;
}

/* Lab buttons */
.lab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--dur-fast);
  border: none;
}

.lab-btn-primary {
  background: var(--brand);
  color: #fff;
}

.lab-btn-primary:hover {
  background: var(--brand-ink);
}

.lab-btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.lab-btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-2);
}

.lab-btn-secondary:hover {
  background: var(--bg-warm);
}

/* Lab table */
.lab-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
}

.lab-table th {
  background: var(--bg-warm);
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  border-bottom: 2px solid var(--line);
}

.lab-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.lab-table tr:last-child td {
  border-bottom: none;
}

/* Lab clickable spans (for punctuation, morpheme labs) */
.lab-clickable {
  display: inline;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--dur-fast);
}

.lab-clickable:hover {
  background: rgba(223, 153, 91, .15);
}

.lab-clickable.selected {
  background: var(--brand-soft);
  font-weight: 700;
}

.lab-clickable.correct {
  background: var(--good-soft);
}

.lab-clickable.wrong {
  background: var(--bad-soft);
}

/* Lab chips for selecting options */
.lab-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lab-chip {
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast);
}

.lab-chip:hover {
  border-color: var(--brand-soft);
  background: var(--bg-warm);
}

.lab-chip.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.lab-chip.correct {
  background: var(--good);
  color: #fff;
  border-color: var(--good);
}

.lab-chip.wrong {
  background: var(--bad);
  color: #fff;
  border-color: var(--bad);
}

/* Lab split view */
.lab-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .lab-split {
    grid-template-columns: 1fr;
  }
  .lab-hub-grid {
    grid-template-columns: 1fr;
  }
}

/* Lab score display */
.lab-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: var(--bg-warm);
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 1.1rem;
}

.lab-score.good {
  color: var(--good);
}

.lab-score.bad {
  color: var(--bad);
}

/* Lab progress bar */
.lab-progress {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
}

.lab-progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
  transition: width var(--dur-smooth);
}

/* Lab tree (for decision tree labs) */
.lab-tree-node {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--dur-fast);
}

.lab-tree-node:hover {
  border-color: var(--brand-soft);
}

.lab-tree-node.active {
  border-color: var(--brand);
  background: rgba(223, 153, 91, .05);
}

.lab-tree-node.leaf {
  border-color: var(--good);
  background: var(--good-soft);
  cursor: default;
}

.lab-tree-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Sentence lab (punctuation, syntax) */
.lab-sentence {
  font-size: 1.1rem;
  line-height: 2;
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.lab-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 2px dashed var(--line-2);
  border-radius: 4px;
  margin: 0 2px;
  cursor: pointer;
  vertical-align: middle;
  font-weight: 800;
  font-size: 1rem;
  transition: all var(--dur-fast);
}

.lab-slot:hover {
  border-color: var(--brand);
  background: rgba(223, 153, 91, .08);
}

.lab-slot.filled {
  border-style: solid;
  border-color: var(--sec);
  background: var(--sec-soft);
  color: var(--sec-ink);
}

.lab-slot.correct {
  border-color: var(--good);
  background: var(--good-soft);
}

.lab-slot.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

/* Node/graph visualization */
.lab-graph-node {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  background: var(--sec);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform var(--dur-fast);
}

.lab-graph-node:hover {
  transform: scale(1.05);
}

.lab-graph-node.highlight {
  background: var(--brand);
}

/* Lab reset button */
.lab-reset-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Lab explanation popover */
.lab-explanation {
  padding: 14px 18px;
  background: var(--good-soft);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
  margin-top: 12px;
  border-left: 3px solid var(--good);
}

.lab-explanation.wrong {
  background: var(--bad-soft);
  border-left-color: var(--bad);
}

/* ── Retention: Screen Flash ── */
.screen-flash {
  position: fixed; inset: 0; z-index: 9997;
  pointer-events: none;
  animation: screen-flash-anim 0.45s ease-out both;
}
.screen-flash-correct { background: radial-gradient(ellipse at center, rgba(16,185,129,.18), transparent 70%); }
.screen-flash-wrong { background: radial-gradient(ellipse at center, rgba(239,68,68,.14), transparent 70%); }
@keyframes screen-flash-anim {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}
.feedback.shake-wrong { animation: tile-shake 0.4s ease; }
.feedback.good { animation: bounce-in var(--dur-smooth) var(--ease-spring) both; }
.feedback.good, .feedback.bad { display: flex; align-items: flex-start; gap: 12px; }

/* ── Retention: Combo Counter ── */
.combo-counter {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9998; pointer-events: none;
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(48px, 10vw, 72px);
  font-weight: 800;
  color: var(--brand);
  text-shadow: 0 4px 20px rgba(223,153,91,.4);
  animation: combo-pop 0.8s var(--ease-bounce) both;
}
.combo-fire {
  color: #F59E0B;
  text-shadow: 0 0 30px rgba(245,158,11,.5), 0 4px 20px rgba(245,158,11,.3);
}
.combo-mega {
  color: #EF4444;
  text-shadow: 0 0 40px rgba(239,68,68,.5), 0 0 80px rgba(239,68,68,.25);
  font-size: clamp(56px, 12vw, 88px);
}
@keyframes combo-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  40% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  70% { transform: translate(-50%, -50%) scale(0.95); }
  85% { transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* ── Retention: XP Fly ── */
.xp-fly {
  position: fixed; z-index: 9998;
  pointer-events: none;
  font-family: 'Unbounded', sans-serif;
  font-size: 18px; font-weight: 700;
  color: #F59E0B;
  text-shadow: 0 2px 8px rgba(245,158,11,.4);
  transition: all 0.6s var(--ease-spring);
  opacity: 1;
}
.xp-fly-go { /* applied via JS */ }

/* ── Retention: Misha Reactions ── */
.misha-reaction {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  animation: bounce-in 0.3s var(--ease-bounce) both;
}

/* ── Retention: Confetti Canvas ── */
.confetti-canvas {
  position: fixed; inset: 0;
  z-index: 9998;
  pointer-events: none;
}

/* ── Retention: Daily Reward Overlay ── */
.daily-reward-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.daily-reward-overlay.visible { opacity: 1; }
.daily-reward-overlay.visible .daily-reward-card { transform: scale(1); }
.daily-reward-card {
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  transform: scale(0.7);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 340px;
}
.daily-reward-coin {
  font-size: 48px;
  margin-bottom: 8px;
  animation: coin-spin 0.8s var(--ease-bounce) both;
}
.daily-reward-coin svg { width: 48px; height: 48px; color: #F59E0B; }
.daily-reward-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.3rem; font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.daily-reward-amount {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(36px, 8vw, 52px);
  font-weight: 800;
  color: #F59E0B;
  text-shadow: 0 4px 16px rgba(245,158,11,.3);
  animation: scale-bounce 0.5s var(--ease-bounce) 0.3s both;
}
.daily-reward-label {
  font-size: 0.95rem; color: var(--muted);
  margin-top: 4px;
}
.daily-reward-streak {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--brand);
  font-weight: 600;
}
@keyframes coin-spin {
  0% { transform: rotateY(0) scale(0.5); opacity: 0; }
  50% { transform: rotateY(360deg) scale(1.15); opacity: 1; }
  100% { transform: rotateY(720deg) scale(1); opacity: 1; }
}

/* ── Retention: Achievement Unlock Overlay ── */
.achievement-unlock-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.5);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.achievement-unlock-overlay.visible { opacity: 1; }
.achievement-unlock-overlay.visible .achievement-unlock-card { transform: scale(1); }
.achievement-unlock-card {
  background: linear-gradient(135deg, var(--good-soft), var(--surface));
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  transform: scale(0.7);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 340px;
}
.achievement-unlock-card[data-rarity="rare"] {
  background: linear-gradient(135deg, var(--sec-soft), var(--surface));
  box-shadow: 0 24px 64px rgba(59,130,246,.15);
}
.achievement-unlock-card[data-rarity="epic"] {
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  box-shadow: 0 0 40px rgba(139,92,246,.2), 0 24px 64px rgba(0,0,0,.15);
}
.achievement-unlock-card[data-rarity="legendary"] {
  background: linear-gradient(135deg, var(--brand-soft), var(--surface));
  box-shadow: 0 0 60px rgba(245,158,11,.3), 0 24px 64px rgba(0,0,0,.15);
}
.achievement-unlock-icon {
  font-size: 48px;
  margin-bottom: 8px;
  animation: levelup-star 0.6s ease 0.3s both;
}
.achievement-unlock-icon svg { width: 48px; height: 48px; }
.achievement-unlock-rarity {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.achievement-unlock-card[data-rarity="rare"] .achievement-unlock-rarity { color: #3B82F6; }
.achievement-unlock-card[data-rarity="epic"] .achievement-unlock-rarity { color: #8B5CF6; }
.achievement-unlock-card[data-rarity="legendary"] .achievement-unlock-rarity { color: #F59E0B; }
.achievement-unlock-name {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.2rem; font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.achievement-unlock-desc {
  font-size: 0.9rem;
  color: var(--muted);
}

/* ── Retention: Streak Milestone Overlay ── */
.streak-milestone-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.5);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.streak-milestone-overlay.visible { opacity: 1; }
.streak-milestone-overlay.visible .streak-milestone-card { transform: scale(1); }
.streak-milestone-card {
  background: linear-gradient(135deg, var(--brand-soft), var(--surface-2), var(--surface));
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 0 50px rgba(223,153,91,.2), 0 24px 64px rgba(0,0,0,.2);
  transform: scale(0.7);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 360px;
}
.streak-milestone-misha {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 12px;
  animation: levelup-star 0.6s ease 0.2s both;
}
.streak-milestone-days {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(48px, 10vw, 72px);
  font-weight: 800;
  color: var(--brand);
  text-shadow: 0 4px 16px rgba(223,153,91,.3);
  line-height: 1;
}
.streak-milestone-label {
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 12px;
}
.streak-milestone-text {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.5;
}

/* ── Retention: Session Progress Ring ── */
.session-ring-wrap {
  position: relative;
  width: 120px; height: 120px;
  flex-shrink: 0;
}
.session-ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.session-ring-bg { fill: none; stroke: rgba(223,153,91,.15); stroke-width: 8; }
.session-ring-fill {
  fill: none; stroke: var(--brand); stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s var(--ease-spring);
}
.session-ring-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Unbounded', sans-serif;
  font-weight: 700; font-size: 1.5rem;
  color: var(--brand);
  line-height: 1;
}
.session-ring-text small {
  font-family: 'Manrope', sans-serif;
  font-size: 0.7rem; font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Social: Kudos Celebration Overlay ── */
.kudos-celebration-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 100px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.kudos-celebration-overlay.visible { opacity: 1; }
.kudos-celebration-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border-radius: 20px;
  padding: 16px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  transform: translateY(20px) scale(0.9);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: auto;
}
.kudos-celebration-overlay.visible .kudos-celebration-card { transform: translateY(0) scale(1); }
.kudos-celebration-misha {
  width: 52px; height: 52px;
  border-radius: 50%; object-fit: cover;
  flex-shrink: 0;
  animation: bounce-in 0.4s var(--ease-bounce) both;
}
.kudos-celebration-text {
  font-size: 0.95rem; font-weight: 600;
  color: var(--text);
}
.kudos-celebration-text .muted { font-weight: 400; color: var(--muted); }

/* ── Social: Rich Feed Cards ── */
.feed-rich-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background var(--dur-fast) ease;
  animation: slide-up 0.3s var(--ease-spring) both;
}
.feed-rich-card + .feed-rich-card { margin-top: 8px; }
.feed-kind-badge {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.feed-kind-badge svg { width: 18px; height: 18px; }
.feed-rich-body { flex: 1; min-width: 0; }
.feed-rich-text {
  font-size: 0.88rem; font-weight: 500;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.feed-rich-meta { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.feed-kudos-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 10px;
  font-size: 0.8rem; font-weight: 600;
  transition: background var(--dur-fast) ease, transform var(--dur-fast) var(--ease-bounce);
}
.feed-kudos-btn:active { transform: scale(0.9); }
.feed-kudos-active { color: #F59E0B; background: rgba(245,158,11,.1); }
.feed-kudos-active svg { color: #F59E0B; }
.feed-kudos-count {
  font-weight: 700;
  animation: badge-pop 0.3s var(--ease-bounce) both;
}

/* ── Social: Streak Race Widget ── */
.streak-race-panel { margin-top: 16px; }
.streak-race-bars { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.streak-race-row { display: flex; align-items: center; gap: 10px; }
.streak-race-rank {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 800;
  background: var(--bg-soft);
  color: var(--muted);
  flex-shrink: 0;
}
.streak-race-row:first-child .streak-race-rank {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: #fff;
}
.streak-race-name {
  width: 80px; font-size: 0.85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex-shrink: 0;
}
.streak-race-track {
  flex: 1; height: 28px;
  background: var(--bg-soft);
  border-radius: 8px;
  overflow: hidden;
}
.streak-race-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #F59E0B);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 10px;
  transition: width 0.8s var(--ease-spring);
  min-width: 40px;
}
.streak-race-bar span {
  font-size: 0.75rem; font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.streak-race-me .streak-race-name { color: var(--brand); }
.streak-race-me .streak-race-bar {
  background: linear-gradient(90deg, var(--brand), #DF995B);
  box-shadow: 0 2px 8px rgba(223,153,91,.3);
}

/* ── Social: Share Card Button in Overlays ── */
.share-card-btn {
  margin-top: 14px;
  font-size: 0.85rem;
}

/* ── Social: Duel System ── */
.duel-page { max-width: 600px; margin: 0 auto; }
.duel-misha {
  border-radius: 50%; object-fit: cover;
  margin-bottom: 16px;
  animation: bounce-in 0.4s var(--ease-bounce) both;
}
.duel-arena { max-width: 600px; margin: 0 auto; }
.duel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; margin-bottom: 12px;
}
.duel-vs {
  display: flex; align-items: center; gap: 10px;
}
.duel-player {
  font-weight: 700; font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.duel-vs-text {
  font-family: 'Unbounded', sans-serif;
  font-weight: 800; font-size: 0.8rem;
  color: #F59E0B;
}
.duel-timer {
  font-family: 'Unbounded', sans-serif;
  font-weight: 700; font-size: 1.2rem;
  color: var(--text);
  padding: 6px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 2px solid var(--border);
}
.duel-timer-urgent {
  color: #EF4444;
  border-color: rgba(239,68,68,.3);
  animation: timer-pulse 1s ease-in-out infinite;
}
.duel-progress {
  font-weight: 700; font-size: 0.85rem;
  color: var(--muted);
}

/* ── Social: Duel Result Overlay ── */
.duel-result-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.duel-result-overlay.visible { opacity: 1; }
.duel-result-overlay.visible .duel-result-card { transform: scale(1); }
.duel-result-card {
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
  transform: scale(0.7);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 400px;
  width: calc(100vw - 32px);
}
.duel-result-vs {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  margin-bottom: 20px;
}
.duel-result-side { text-align: center; flex: 1; }
.duel-result-score {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(42px, 10vw, 64px);
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.duel-result-winner .duel-result-score {
  color: #10B981;
  text-shadow: 0 4px 16px rgba(16,185,129,.3);
}
.duel-result-name {
  font-size: 0.9rem; font-weight: 600;
  color: var(--muted);
  margin-top: 6px;
}
.duel-result-divider {
  font-family: 'Unbounded', sans-serif;
  font-weight: 800; font-size: 1.1rem;
  color: #F59E0B;
  flex-shrink: 0;
}
.duel-result-verdict {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.3rem; font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.duel-result-xp {
  font-size: 1rem; font-weight: 600;
  color: #F59E0B;
  margin-bottom: 20px;
}

/* ── P0: Critical Hit Popup ── */
.critical-hit-popup {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9998; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  animation: combo-pop 1.1s var(--ease-bounce) both;
}
.critical-hit-label {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 800; color: #EF4444;
  text-shadow: 0 0 20px rgba(239,68,68,.5);
}
.critical-hit-value {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 700; color: #F59E0B;
  text-shadow: 0 0 16px rgba(245,158,11,.4);
}

/* ── P0: Anticipation Pulse ── */
.anticipation-pulse {
  position: fixed; inset: 0; z-index: 9996;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(223,153,91,.06), transparent 60%);
  animation: anticipation-anim 0.45s ease-in-out both;
}
@keyframes anticipation-anim {
  0% { opacity: 0; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.02); }
}

/* ── P0: Session Extension Overlay ── */
.session-extend-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.4);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.session-extend-overlay.visible { opacity: 1; }
.session-extend-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  max-width: 340px;
  transform: scale(0.85);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.session-extend-overlay.visible .session-extend-card { transform: scale(1); }

/* ── P1: Near-miss Hint ── */
.near-miss-hint {
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #F59E0B;
  animation: slide-up 0.3s var(--ease-spring) both;
}

/* ── P1: Focus Timer Bar ── */
.focus-timer-bar {
  position: relative;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 3px;
  margin: 8px 0 16px;
  overflow: hidden;
}
.focus-timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #10B981);
  border-radius: 3px;
  transition: width 1s linear;
}
.focus-timer-text {
  position: absolute; right: 0; top: -20px;
  font-size: 0.75rem; font-weight: 700;
  color: var(--muted);
}
.focus-ritual-screen { max-width: 500px; margin: 0 auto; }
.focus-time-btn { min-width: 80px; }

/* ── P1: Mastery Map ── */
.mastery-panel { margin-top: 16px; }
.mastery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.mastery-cell {
  position: relative;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 8px 8px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.mastery-cell:hover { transform: translateY(-2px); }
.mastery-cell-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--mc);
  opacity: 0.15;
  border-radius: 0 0 12px 12px;
  transition: height 0.6s var(--ease-spring);
}
.mastery-cell-label {
  font-size: 0.7rem; font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  position: relative; z-index: 1;
}
.mastery-cell-level {
  font-size: 0.6rem; font-weight: 700;
  color: var(--mc);
  position: relative; z-index: 1;
}

/* ── P2: Season Widget ── */
.season-panel { margin-top: 16px; }
.season-track {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; margin-top: 12px;
}
.season-node {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
  background: var(--bg-soft);
  color: var(--muted);
  border: 2px solid transparent;
  transition: all var(--dur-fast) ease;
}
.season-node.done { background: var(--brand); color: #fff; }
.season-node.current {
  border-color: var(--brand);
  background: var(--surface);
  color: var(--brand);
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(223,153,91,.3);
}

/* ── Weekly Digest Overlay ── */
.weekly-digest-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .3s ease;
}
.weekly-digest-overlay.visible { opacity: 1; }
.weekly-digest-card {
  background: var(--surface); border-radius: var(--radius-card);
  padding: 32px; max-width: 400px; width: 90%; text-align: center;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(.95); transition: transform .35s var(--ease-spring);
}
.weekly-digest-overlay.visible .weekly-digest-card { transform: none; }
.weekly-digest-header { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; color: var(--brand); display: flex; align-items: center; justify-content: center; gap: 8px; }
.weekly-digest-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.weekly-stat { background: var(--bg-soft); border-radius: var(--radius); padding: 12px; }
.weekly-stat strong { display: block; font-size: 1.4rem; color: var(--ink); }
.weekly-stat small { color: var(--ink-3); font-size: .8rem; }
.weekly-digest-xp { font-weight: 700; color: var(--brand); margin-bottom: 16px; }
.weekly-digest-actions { display: flex; justify-content: center; }

/* ── Daily Challenges ── */
.daily-challenges-panel { }
.daily-challenges-list { display: flex; flex-direction: column; gap: 8px; }
.daily-challenge-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--bg-soft); transition: background var(--dur-fast) ease;
}
.daily-challenge-item.done { background: var(--good-soft); }
.daily-challenge-check { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; color: var(--good); }
.daily-challenge-title { flex: 1; font-weight: 500; }
.daily-challenge-progress { font-size: .85rem; color: var(--ink-3); font-weight: 600; }
.daily-challenge-reward { text-align: center; margin-top: 12px; font-weight: 700; color: var(--brand); }

/* ── Re-engagement Overlay ── */
.reengagement-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .3s ease;
}
.reengagement-overlay.visible { opacity: 1; }
.reengagement-card {
  background: var(--surface); border-radius: var(--radius-card);
  padding: 32px; max-width: 380px; width: 90%; text-align: center;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(.95); transition: transform .35s var(--ease-spring);
}
.reengagement-overlay.visible .reengagement-card { transform: none; }
.reengagement-mascot { width: 80px; height: 80px; margin-bottom: 12px; }
.reengagement-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.reengagement-days { color: var(--ink-3); margin-bottom: 10px; }
.reengagement-streak-lost { color: var(--bad); font-weight: 600; margin-bottom: 8px; }
.reengagement-streak-ok { color: var(--good); font-weight: 600; margin-bottom: 8px; }
.reengagement-quote { color: var(--ink-2); font-style: italic; margin-bottom: 16px; }
.reengagement-actions { display: flex; flex-direction: column; gap: 8px; }

/* ── Streak Warning Banner ── */
.streak-warning-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--bad-soft); border: 1px solid var(--bad);
  color: var(--ink); margin-bottom: 16px;
  animation: pulse-warn 2s ease infinite;
}
.streak-warning-banner .icon { color: var(--bad); flex-shrink: 0; }
.streak-warning-banner span { flex: 1; font-weight: 500; font-size: .9rem; }
.streak-warning-banner .btn { flex-shrink: 0; }
@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.2); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* ── Share Modal ── */
.share-modal-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .3s ease;
}
.share-modal-overlay.visible { opacity: 1; }
.share-modal {
  background: var(--surface); border-radius: var(--radius-card);
  padding: 24px; max-width: 400px; width: 90%;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(.95); transition: transform .35s var(--ease-spring);
}
.share-modal-overlay.visible .share-modal { transform: none; }
.share-modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.share-modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.share-modal-preview { text-align: center; margin-bottom: 16px; }
.share-modal-preview img { max-width: 100%; max-height: 300px; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.share-modal-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-modal-buttons .share-btn { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px; border-radius: var(--radius); font-weight: 600; font-size: .85rem; text-decoration: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; transition: background var(--dur-fast) ease; }
.share-modal-buttons .share-btn:hover { background: var(--bg-soft); }
.share-btn-tg { background: #229ED9; color: #fff; border-color: #229ED9; }
.share-btn-tg:hover { background: #1a8cc2; }
.share-btn-vk { background: #4C75A3; color: #fff; border-color: #4C75A3; }
.share-btn-vk:hover { background: #3d6590; }

/* ── Invite Friend ── */
.invite-friend-btn { margin-top: 12px; }

/* ── Honey Shop ── */
.shop-page { }
.shop-balance { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; margin-top: 12px; }
.shop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px; margin-top: 20px;
}
.shop-item {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 24px 16px; gap: 8px;
}
.shop-item.disabled { opacity: .5; }
.shop-item-icon { font-size: 2rem; color: var(--brand); }
.shop-item-icon .icon { width: 36px; height: 36px; }
.shop-item-name { font-weight: 700; font-size: 1rem; }
.shop-item-desc { font-size: .85rem; color: var(--ink-3); margin-bottom: 8px; }

/* ── XP Multiplier Badge ── */
.xp-mult-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--gold), var(--brand));
  color: #fff; font-weight: 700; font-size: .85rem;
  animation: pulse-mult 2s ease infinite;
  margin-bottom: 12px;
}
@keyframes pulse-mult {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,.3); }
  50% { box-shadow: 0 0 0 8px rgba(245,158,11,0); }
}

/* ── Level Milestone Overlay ── */
.level-milestone-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); backdrop-filter: blur(8px);
  opacity: 0; transition: opacity .3s ease;
}
.level-milestone-overlay.visible { opacity: 1; }
.level-milestone-card {
  background: var(--surface); border-radius: var(--radius-card);
  padding: 40px 32px; max-width: 380px; width: 90%; text-align: center;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(.9); transition: transform .4s var(--ease-spring);
}
.level-milestone-overlay.visible .level-milestone-card { transform: none; }
.level-milestone-icon { font-size: 3rem; margin-bottom: 8px; color: var(--gold); }
.level-milestone-icon .icon { width: 48px; height: 48px; }
.level-milestone-level { font-size: .85rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.level-milestone-title { font-size: 1.6rem; font-weight: 800; margin: 8px 0; color: var(--ink); }
.level-milestone-reward { font-weight: 600; color: var(--brand); margin-bottom: 20px; }

/* ── Study Habits Calendar ── */
.habits-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  gap: 3px; margin-top: 12px;
}
.habits-cell {
  width: 100%; aspect-ratio: 1; border-radius: 3px;
  background: var(--bg-soft); transition: background var(--dur-fast) ease;
}
.habits-cell.level-1 { background: color-mix(in srgb, var(--good) 25%, var(--bg-soft)); }
.habits-cell.level-2 { background: color-mix(in srgb, var(--good) 50%, var(--bg-soft)); }
.habits-cell.level-3 { background: color-mix(in srgb, var(--good) 75%, var(--bg-soft)); }
.habits-cell.level-4 { background: var(--good); }
.habits-legend {
  display: flex; align-items: center; gap: 4px; margin-top: 8px; justify-content: flex-end;
}
.habits-legend small { font-size: .7rem; color: var(--ink-3); }
.habits-legend .habits-cell { width: 14px; height: 14px; aspect-ratio: auto; }

/* ── EGE Countdown Widget ── */
.countdown-panel { text-align: center; }
.countdown-grid {
  display: flex; justify-content: center; gap: 16px; margin-bottom: 12px;
}
.countdown-unit {
  display: flex; flex-direction: column; align-items: center;
  min-width: 70px; padding: 12px 8px;
  background: var(--bg-soft); border-radius: var(--radius);
}
.countdown-unit strong {
  font-size: 2rem; font-weight: 800; color: var(--brand);
  line-height: 1;
}
.countdown-unit small { font-size: .75rem; color: var(--ink-3); margin-top: 4px; }
.countdown-label { font-size: .9rem; color: var(--ink-2); margin-bottom: 8px; }
.countdown-progress { max-width: 320px; margin: 0 auto; }

/* ── Improved Mobile Touch Targets ── */
@media (max-width: 860px) {
  .btn, .item, .choice, .nav-item { min-height: 44px; }
  .bottom-nav { transition: transform var(--dur-smooth) var(--ease-spring); }
  .countdown-unit { min-width: 56px; padding: 10px 6px; }
  .countdown-unit strong { font-size: 1.5rem; }
  .countdown-grid { gap: 10px; }
  .level-milestone-card { padding: 28px 20px; }
}

/* ═══════════════════════════════════════════════════════
   DARK MODE — comprehensive override block
   Placed at end of file for maximum cascade priority.
   Overrides all hardcoded light colors throughout the file.
   ═══════════════════════════════════════════════════════ */

[data-theme="dark"] {
  /* Re-override the secondary :root variables (lines 3702-3713) */
  --surface: #241E17;
  --surface-2: #2E261E;
  --surface-3: #382F26;
  --line: rgba(255,255,255,.1);
  --line-2: rgba(255,255,255,.16);
  --shadow-sm: 0 2px 5px rgba(0,0,0,.3);
  --shadow-md: 0 8px 18px rgba(0,0,0,.4);
  --shadow-glass: 0 18px 48px -36px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06);
  --radius: 10px;
  --radius-lg: 16px;
}

/* ── Rail / Sidebar ── */
[data-theme="dark"] .rail {
  background: #1A1410 !important;
  border-right-color: rgba(245,237,224,.08) !important;
  box-shadow: inset -1px 0 0 rgba(245,237,224,.04) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  color: var(--ink) !important;
}
[data-theme="dark"] .rail-brand {
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3)) !important;
  color: var(--ink);
  border-color: rgba(255,255,255,.08);
  box-shadow: 0 4px 12px -6px rgba(0,0,0,.4);
}
[data-theme="dark"] .rail-brand .brand-mark {
  background: linear-gradient(160deg, var(--surface-3), var(--brand-soft)) !important;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15), 0 4px 12px rgba(0,0,0,.3);
  border-color: rgba(255,255,255,.06);
}
[data-theme="dark"] .nav-item:hover {
  background: rgba(240,168,104,.1);
  color: var(--brand);
}
[data-theme="dark"] .nav-item.active {
  background: var(--surface-2);
  border-color: rgba(240,168,104,.18);
  color: var(--brand);
  box-shadow: 0 2px 8px -3px rgba(0,0,0,.4), inset 3px 0 0 var(--brand);
}

/* ── Topbar ── */
[data-theme="dark"] .topbar {
  background: linear-gradient(180deg, rgba(26,20,16,.95), rgba(32,26,20,.88)) !important;
  border-bottom-color: rgba(255,255,255,.06);
}

/* ── Bottom Nav (mobile) ── */
[data-theme="dark"] .bottom-nav {
  background: linear-gradient(180deg, rgba(32,26,20,.7), rgba(26,20,16,.5)), rgba(32,26,20,.6) !important;
  border-color: rgba(255,255,255,.1) !important;
}

/* ── Panels / Cards — remove white inset shine ── */
[data-theme="dark"] .panel::before {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04) !important;
}
[data-theme="dark"] .panel {
  background: var(--surface);
  border-color: rgba(255,255,255,.06);
  box-shadow: var(--shadow-sm);
}

/* ── Workspace background ── */
[data-theme="dark"] .workspace {
  background:
    radial-gradient(ellipse 50% 30% at 80% 5%, rgba(240,168,104,.03), transparent),
    radial-gradient(ellipse 40% 25% at 15% 90%, rgba(107,154,181,.03), transparent),
    transparent;
}

/* ── Auth panel ── */
[data-theme="dark"] .auth-panel {
  background: rgba(32,26,20,.88);
}

/* ── Auth provider cards ── */
[data-theme="dark"] .auth-provider-card {
  background: rgba(36,30,23,.68);
  border-color: rgba(255,255,255,.08);
  box-shadow: 0 12px 28px -26px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.04);
}
[data-theme="dark"] .auth-provider-card:hover {
  background: rgba(46,38,30,.75);
  border-color: rgba(255,255,255,.12);
}

/* ── Buttons ── */
[data-theme="dark"] .btn {
  background: rgba(36,30,23,.88);
  border-color: rgba(255,255,255,.08);
  box-shadow: 0 2px 4px rgba(0,0,0,.2), 0 12px 24px -22px rgba(0,0,0,.4);
  color: var(--ink);
}
[data-theme="dark"] .btn:hover {
  background: rgba(46,38,30,.95);
  box-shadow: var(--shadow-md);
}
[data-theme="dark"] .btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: rgba(0,0,0,.15);
  box-shadow: 0 16px 28px -22px rgba(0,0,0,.6), inset 0 -3px 0 rgba(0,0,0,.15);
}
[data-theme="dark"] .btn-ghost {
  background: rgba(36,30,23,.4);
  border-color: rgba(255,255,255,.1);
}
[data-theme="dark"] .btn-secondary {
  box-shadow: 0 16px 28px -24px rgba(0,0,0,.6), inset 0 -2px 0 rgba(0,0,0,.15);
}

/* ── Form Fields ── */
[data-theme="dark"] .field,
[data-theme="dark"] .select,
[data-theme="dark"] .textarea {
  background: rgba(26,20,16,.94);
  border-color: rgba(255,255,255,.1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
  color: var(--ink);
}

/* ── Brand mark ── */
[data-theme="dark"] .brand-mark {
  background: var(--surface-3) !important;
  border-color: rgba(255,255,255,.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 10px 22px -18px rgba(0,0,0,.5);
}

/* ── Badges ── */
[data-theme="dark"] .badge {
  background: var(--surface-2);
  color: var(--ink-2);
}
[data-theme="dark"] .badge.good {
  background: var(--good-soft);
  color: var(--good);
}
[data-theme="dark"] .badge.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

/* ── Metric / Stat cards ── */
[data-theme="dark"] .stat-card,
[data-theme="dark"] .metric-card {
  background: var(--surface);
  border-color: rgba(255,255,255,.06);
}

/* ── Quick strip cards ── */
[data-theme="dark"] .quick-card,
[data-theme="dark"] .tile {
  background: var(--surface) !important;
  border-color: rgba(245,237,224,.06) !important;
  color: var(--ink) !important;
}
[data-theme="dark"] .quick-card h3,
[data-theme="dark"] .tile h3 {
  color: var(--ink) !important;
}
[data-theme="dark"] .quick-card p,
[data-theme="dark"] .tile p {
  color: var(--ink-3) !important;
}
[data-theme="dark"] .quick-card:hover,
[data-theme="dark"] .tile:hover {
  background: var(--surface-2) !important;
  border-color: rgba(245,237,224,.1) !important;
}

/* ── Items / List items ── */
[data-theme="dark"] .item {
  border-color: rgba(255,255,255,.04);
}
[data-theme="dark"] .item:hover {
  background: rgba(255,255,255,.03);
}

/* ── Choice / Quiz options ── */
[data-theme="dark"] .choice {
  background: var(--surface);
  border-color: rgba(255,255,255,.08);
}
[data-theme="dark"] .choice:hover {
  background: var(--surface-2);
  border-color: rgba(255,255,255,.14);
}

/* ── Muted text, item-sub, auth-lead ── */
[data-theme="dark"] .muted,
[data-theme="dark"] .item-sub,
[data-theme="dark"] .auth-lead {
  color: var(--ink-3) !important;
}

/* ── Hero app / Hero sections ── */
[data-theme="dark"] .hero-app {
  background: var(--surface);
}

/* ── Flashcard ── */
[data-theme="dark"] .flashcard-face {
  background: var(--surface);
  border-color: rgba(255,255,255,.06);
}

/* ── Lab canvas ── */
[data-theme="dark"] .lab-canvas {
  background: var(--bg-deep) !important;
}

/* ── Tags / chips ── */
[data-theme="dark"] .tag {
  background: var(--surface-2);
  color: var(--ink-2);
}

/* ── Subject buttons ── */
[data-theme="dark"] .subject-btn {
  background: var(--surface);
  border-color: rgba(255,255,255,.06);
}
[data-theme="dark"] .subject-btn.active {
  border-color: var(--brand);
}

/* ── Provider mark yandex ── */
[data-theme="dark"] .provider-mark.yandex {
  background: var(--surface-3) !important;
}

/* ── Partner code card ── */
[data-theme="dark"] .partner-code-card {
  background: var(--surface-2);
  border-color: rgba(255,255,255,.06);
}

/* ── Score prediction ── */
[data-theme="dark"] .prediction-status {
  color: var(--ink-2);
}

/* ── Warning / Error badges ── */
[data-theme="dark"] .warning-badge {
  background: rgba(251,191,36,.15);
  color: var(--gold);
}
[data-theme="dark"] .error-badge {
  background: var(--bad-soft);
  color: var(--bad);
}
[data-theme="dark"] .good-badge {
  background: var(--good-soft);
  color: var(--good);
}

/* ── Swipe labels ── */
[data-theme="dark"] .swipe-label-left { color: var(--bad); }
[data-theme="dark"] .swipe-label-right { color: var(--good); }

/* ── Progress bars ── */
[data-theme="dark"] .progress {
  background: var(--surface-2);
}

/* ── Feedback panels ── */
[data-theme="dark"] .feedback {
  background: var(--surface);
  border-color: rgba(255,255,255,.06);
}
[data-theme="dark"] .feedback.good { background: var(--good-soft); border-color: rgba(52,211,153,.15); }
[data-theme="dark"] .feedback.bad { background: var(--bad-soft); border-color: rgba(248,113,113,.15); }

/* ── Dropdowns / selects ── */
[data-theme="dark"] .custom-select-options,
[data-theme="dark"] .dropdown-menu {
  background: var(--surface-2);
  border-color: rgba(255,255,255,.08);
  box-shadow: var(--shadow-lg);
}

/* ── Toast ── */
[data-theme="dark"] .toast {
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

/* ── Overlays — consistent dark backgrounds ── */
[data-theme="dark"] .daily-reward-card,
[data-theme="dark"] .achievement-unlock-card,
[data-theme="dark"] .achievement-unlock-card[data-rarity="rare"],
[data-theme="dark"] .achievement-unlock-card[data-rarity="epic"],
[data-theme="dark"] .achievement-unlock-card[data-rarity="legendary"],
[data-theme="dark"] .streak-milestone-card,
[data-theme="dark"] .duel-result-card,
[data-theme="dark"] .levelup-card,
[data-theme="dark"] .weekly-digest-card,
[data-theme="dark"] .reengagement-card,
[data-theme="dark"] .level-milestone-card,
[data-theme="dark"] .share-modal {
  background: var(--surface) !important;
  color: var(--ink);
}

/* ── Wrapped / Stories ── */
[data-theme="dark"] .wrapped-card {
  border-color: rgba(255,255,255,.06);
}

/* ── Misha frame ── */
[data-theme="dark"] .misha-frame {
  background: var(--surface-2);
  border-color: rgba(255,255,255,.06);
}

/* ── Score card ── */
[data-theme="dark"] .home-score-card {
  background: var(--surface);
  border-color: rgba(255,255,255,.06);
}

/* ── Session ring ── */
[data-theme="dark"] .session-ring-bg {
  stroke: var(--surface-2);
}

/* ── Spotlight ── */
[data-theme="dark"] .spotlight-overlay {
  background: rgba(0,0,0,.7);
}
[data-theme="dark"] .spotlight-tooltip {
  background: var(--surface);
  color: var(--ink);
  border-color: rgba(255,255,255,.08);
}

/* ── Confirmations / Dialogs ── */
[data-theme="dark"] .confirm-card,
[data-theme="dark"] .dialog-card {
  background: var(--surface);
  color: var(--ink);
}

/* ── Calendar cells ── */
[data-theme="dark"] .calendar-day {
  color: var(--ink);
}

/* ── Empty state ── */
[data-theme="dark"] .empty {
  color: var(--ink-3);
}

/* ── Scrollbar ── */
[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--bg);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--surface-3);
}

/* ── Social feed cards ── */
[data-theme="dark"] .feed-card,
[data-theme="dark"] .friend-card,
[data-theme="dark"] .social-card {
  background: var(--surface);
  border-color: rgba(255,255,255,.06);
}

/* ── Codifier / Map blocks ── */
[data-theme="dark"] .map-block,
[data-theme="dark"] .codifier-block {
  background: var(--surface);
  border-color: rgba(255,255,255,.06);
}

/* ── Exam timer ── */
[data-theme="dark"] .exam-timer {
  background: var(--surface-2);
}

/* ── Settings section ── */
[data-theme="dark"] .settings-section {
  background: var(--surface);
  border-color: rgba(255,255,255,.06);
}

/* ── Onboarding / Consent / Tutorial ── */
[data-theme="dark"] .consent-card,
[data-theme="dark"] .onboarding-card,
[data-theme="dark"] .diagnostic-intro {
  background: var(--surface);
  color: var(--ink);
}

/* ── Mobile-specific dark fixes ── */
@media (max-width: 860px) {
  [data-theme="dark"] .bottom-nav {
    background: linear-gradient(180deg, rgba(32,26,20,.85), rgba(26,20,16,.7)), rgba(32,26,20,.75) !important;
    border-color: rgba(255,255,255,.08) !important;
  }
  [data-theme="dark"] .bottom-nav .nav-item.active {
    background: rgba(240,168,104,.12);
  }
}

/* ── Kill all remaining white inset highlights ── */
[data-theme="dark"] *::before {
  box-shadow: none !important;
}
/* Restore specific ::before that need shadow */
[data-theme="dark"] .progress span::before,
[data-theme="dark"] .session-ring-fill::before {
  box-shadow: unset;
}

/* ── Selection color ── */
[data-theme="dark"] ::selection {
  background: rgba(240,168,104,.3);
  color: #fff;
}

/* ── Links in dark mode ── */
[data-theme="dark"] a {
  color: var(--brand);
}

/* ── Btn-danger text fix ── */
[data-theme="dark"] .btn-danger {
  color: var(--bad);
}

/* ═══════════════════════════════════════════════════════
   DARK MODE — round 2 fixes (missed selectors)
   ═══════════════════════════════════════════════════════ */

/* ── Bottom-nav text: counter !important from base mobile rules ── */
@media (max-width: 860px) {
  [data-theme="dark"] .bottom-nav .nav-item {
    color: var(--ink-3) !important;
  }
  [data-theme="dark"] .bottom-nav .nav-item.active {
    color: var(--brand) !important;
    background: rgba(240,168,104,.12);
  }
  [data-theme="dark"] .bottom-nav .nav-item .icon {
    color: inherit !important;
  }
}

/* ── Chat / Messages ── */
[data-theme="dark"] .messages {
  background: rgba(26,20,16,.38) !important;
}
[data-theme="dark"] .bubble {
  background: var(--surface) !important;
  color: var(--ink);
}
[data-theme="dark"] .message.pending .bubble {
  background: var(--surface-2) !important;
}
[data-theme="dark"] .message.error .bubble {
  background: var(--bad-soft) !important;
  color: var(--ink);
}
[data-theme="dark"] .chat-input {
  background: rgba(32,26,20,.82) !important;
  border-color: rgba(255,255,255,.08);
  color: var(--ink);
}

/* ── Item active / Match tile selected ── */
[data-theme="dark"] .item.active,
[data-theme="dark"] .match-tile.selected {
  background: var(--brand-soft) !important;
}

/* ── Question text ── */
[data-theme="dark"] .question-text {
  background: var(--surface-2) !important;
}

/* ── Next action card ── */
[data-theme="dark"] .next-action-card {
  background: var(--surface-2) !important;
}

/* ── Flashcard, criterion, mood-card, day-cell, table-shell, tutorial-card, diagnostic-card ── */
[data-theme="dark"] .flashcard,
[data-theme="dark"] .criterion,
[data-theme="dark"] .mood-card,
[data-theme="dark"] .day-cell,
[data-theme="dark"] .table-shell,
[data-theme="dark"] .tutorial-card,
[data-theme="dark"] .diagnostic-card {
  background: var(--surface) !important;
  color: var(--ink);
}

/* ── Backend cards ── */
[data-theme="dark"] .backend-card.good {
  background: var(--good-soft) !important;
}
[data-theme="dark"] .backend-card.bad {
  background: var(--bad-soft) !important;
}
[data-theme="dark"] .data-state-panel {
  background: var(--surface) !important;
}

/* ── AI result ── */
[data-theme="dark"] .ai-result {
  background: var(--good-soft) !important;
}

/* ── Timer boxes ── */
[data-theme="dark"] .timer-box.warning {
  background: rgba(251,191,36,.12) !important;
  color: var(--gold) !important;
}
[data-theme="dark"] .timer-box.danger {
  background: var(--bad-soft) !important;
  color: var(--bad) !important;
}

/* ── Avatar ── */
[data-theme="dark"] .avatar-xl {
  background: var(--surface-2) !important;
}

/* ── Achievements / Map / Friends / Feed / Social panels ── */
[data-theme="dark"] .achievements-panel,
[data-theme="dark"] .map-board,
[data-theme="dark"] .friends-panel,
[data-theme="dark"] .feed-panel,
[data-theme="dark"] .social-requests-panel {
  background: var(--surface) !important;
}

/* ── Subject pages ── */
[data-theme="dark"] .subject-command {
  background: var(--surface) !important;
}
[data-theme="dark"] .subject-current-card,
[data-theme="dark"] .subject-choice-card {
  background: var(--surface-2) !important;
  border-color: rgba(255,255,255,.06);
}

/* ── Diagnostic panels ── */
[data-theme="dark"] .diagnostics-panel,
[data-theme="dark"] .app-parity-panel {
  background: var(--surface) !important;
}
[data-theme="dark"] .diagnostic-tile,
[data-theme="dark"] .parity-row {
  background: var(--surface-2) !important;
}

/* ── Chips / Source pills ── */
[data-theme="dark"] .chip,
[data-theme="dark"] .source-pill {
  background: var(--surface-2) !important;
  color: var(--ink-2);
}

/* ── Quota row ── */
[data-theme="dark"] .quota-row span {
  background: var(--surface-2);
}

/* ── Score card progress ── */
[data-theme="dark"] .home-score-card .progress span {
  background: var(--brand);
}

/* ── Table header ── */
[data-theme="dark"] .table th,
[data-theme="dark"] thead {
  background: var(--surface-2) !important;
  color: var(--ink-2) !important;
}

/* ── Dark text colors that are invisible on dark BG ── */
[data-theme="dark"] .tag.good,
[data-theme="dark"] .prediction-status.good {
  color: var(--good) !important;
}
[data-theme="dark"] .tag.bad {
  color: var(--bad) !important;
}
[data-theme="dark"] .mastery-badge.mastery-mid {
  color: var(--gold) !important;
}
[data-theme="dark"] .mastery-badge.mastery-high {
  color: var(--good) !important;
}

/* ── Misc dark text fixes ── */
[data-theme="dark"] .tile p,
[data-theme="dark"] .top-actions .badge,
[data-theme="dark"] .route-copy small,
[data-theme="dark"] .partner-code-card span,
[data-theme="dark"] .partner-code-card small,
[data-theme="dark"] .diagnostic-tile span,
[data-theme="dark"] .diagnostic-tile small {
  color: var(--ink-3) !important;
}

/* ── Fix ::before restore ── */
[data-theme="dark"] .progress span::before,
[data-theme="dark"] .session-ring-fill::before {
  box-shadow: unset !important;
}

/* ═══════════════════════════════════════════════════════
   DARK MODE — round 3 fixes
   ═══════════════════════════════════════════════════════ */

/* ── CRITICAL 1: Hero command panels (every main page header) ── */
[data-theme="dark"] .home-command,
[data-theme="dark"] .practice-command,
[data-theme="dark"] .map-overview,
[data-theme="dark"] .social-command,
[data-theme="dark"] .profile-command,
[data-theme="dark"] .chat-list-command {
  background: var(--surface) !important;
}

/* ── CRITICAL 2: .item, .topic-node, .match-tile, .backend-card base ── */
[data-theme="dark"] .item,
[data-theme="dark"] .topic-node,
[data-theme="dark"] .diagnostic-meter div,
[data-theme="dark"] .tutorial-device,
[data-theme="dark"] .tutorial-checklist div,
[data-theme="dark"] .match-tile,
[data-theme="dark"] .backend-card {
  background: var(--surface) !important;
  color: var(--ink);
}

/* ── CRITICAL 3: Rail nav-item base text color ── */
[data-theme="dark"] .rail .nav-item {
  color: var(--ink-3) !important;
}
[data-theme="dark"] .rail .nav-item span {
  color: inherit !important;
}
[data-theme="dark"] .rail .nav-item .icon {
  color: inherit !important;
}
[data-theme="dark"] .rail .nav-item:hover {
  color: var(--brand) !important;
  background: rgba(223,153,91,.1) !important;
  border-color: transparent !important;
}
[data-theme="dark"] .rail .nav-item.active {
  color: var(--brand) !important;
  background: var(--brand-soft) !important;
  border-color: rgba(223,153,91,.2) !important;
  box-shadow: inset 0 1px 0 rgba(245,237,224,.04), 0 12px 26px -24px rgba(0,0,0,.5) !important;
}
[data-theme="dark"] .rail .nav-item.active::after {
  background: var(--brand) !important;
}

/* ── CRITICAL 4: Mobile nav-active-pill (white glassmorphism blob) ── */
[data-theme="dark"] .nav-active-pill {
  background: rgba(223,153,91,.2) !important;
  border-color: rgba(223,153,91,.25) !important;
  box-shadow: 0 0 16px rgba(223,153,91,.15) !important;
}
[data-theme="dark"] .nav-active-pill::before,
[data-theme="dark"] .nav-active-pill::after {
  background: transparent !important;
  box-shadow: none !important;
}
[data-theme="dark"] .bottom-nav::before {
  background: none !important;
  opacity: 0 !important;
}
[data-theme="dark"] .bottom-nav {
  box-shadow: 0 18px 42px -32px rgba(0,0,0,.6), inset 0 1px 0 rgba(245,237,224,.06), inset 0 -1px 0 rgba(245,237,224,.03) !important;
}

/* ── CRITICAL 5: Selected quiz choice ── */
[data-theme="dark"] .choice:has(input:checked) {
  background: var(--brand-soft) !important;
}

/* ── HIGH 6: activity-panel, profile-routes ── */
[data-theme="dark"] .activity-panel,
[data-theme="dark"] .profile-routes {
  background: var(--surface) !important;
}

/* ── HIGH 7: topbar subtitle ── */
[data-theme="dark"] .top-title p {
  color: var(--ink-3) !important;
}

/* ── HIGH 8: timer-box base ── */
[data-theme="dark"] .timer-box {
  background: var(--surface-2) !important;
  color: var(--brand);
}

/* ── HIGH 9: flashcard-back ── */
[data-theme="dark"] .flashcard-back {
  background: linear-gradient(160deg, var(--surface-2), var(--surface)) !important;
}

/* ── HIGH 10: retry-btn hover ── */
[data-theme="dark"] .retry-btn:hover {
  color: var(--bad) !important;
}

/* ── MEDIUM 11: skeleton shimmer ── */
[data-theme="dark"] .skeleton,
[data-theme="dark"] .skeleton-card,
[data-theme="dark"] .skeleton-avatar {
  background: var(--surface-2) !important;
}
@keyframes dark-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(245,237,224,.06), transparent) !important;
}

/* ── MEDIUM 12: tile-icon ── */
[data-theme="dark"] .tile-icon {
  background: linear-gradient(135deg, var(--brand-soft), rgba(223,153,91,.15)) !important;
  box-shadow: none;
}

/* ── MEDIUM 13: route-icon ── */
[data-theme="dark"] .route-icon {
  color: var(--ink-3) !important;
}

/* ── MEDIUM 14: hero-mascot container ── */
[data-theme="dark"] .hero-mascot {
  background: rgba(36,30,23,.58);
}

/* ── MEDIUM 15: setup-icon ── */
[data-theme="dark"] .setup-icon {
  background: rgba(46,38,30,.62) !important;
}

/* ── MEDIUM 16: subject-mark ── */
[data-theme="dark"] .subject-mark {
  background: rgba(223,153,91,.15) !important;
  color: var(--brand) !important;
}

/* ── MEDIUM 17: subject-choice-card.active ── */
[data-theme="dark"] .subject-choice-card.active {
  background: var(--brand-soft) !important;
}

/* ── MEDIUM 18: parity-row small ── */
[data-theme="dark"] .parity-row small {
  color: var(--ink-3) !important;
}

/* ── MEDIUM 19: source-pill.ok / .bad ── */
[data-theme="dark"] .source-pill.ok {
  background: var(--good-soft) !important;
  color: var(--good);
}
[data-theme="dark"] .source-pill.bad {
  background: var(--bad-soft) !important;
  color: var(--bad);
}

/* ── MEDIUM 20: rarity badge text ── */
[data-theme="dark"] .rarity-legendary {
  color: var(--gold) !important;
}

/* ── MEDIUM 21: no-backdrop-filter fallback ── */
@supports not (backdrop-filter: blur(1px)) {
  [data-theme="dark"] .bottom-nav {
    background: rgba(26,20,16,.96) !important;
  }
}

/* ── MEDIUM 22: next-action-card tile-icon ── */
[data-theme="dark"] .next-action-card {
  background: var(--surface-2) !important;
  border-color: rgba(245,237,224,.06);
}

/* ── Essay Checker ── */
.essay-page { }
.essay-subject-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.essay-task-label { font-size: .85rem; color: var(--ink-3); margin-bottom: 12px; font-weight: 600; }
.essay-textarea { width: 100%; min-height: 240px; resize: vertical; font-size: .95rem; line-height: 1.7; padding: 16px; }
.essay-meta { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 12px; }
.essay-word-count { font-weight: 700; font-size: .9rem; color: var(--brand); }
.essay-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.essay-result { }
.essay-criteria-grid { display: grid; gap: 12px; margin-top: 16px; }
.essay-criterion { padding: 14px; border-radius: var(--radius); background: var(--bg-soft); }
.essay-criterion.full { border-left: 3px solid var(--good); }
.essay-criterion.zero { border-left: 3px solid var(--bad); }
.essay-criterion-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.essay-criterion-name { font-weight: 700; font-size: .9rem; }
.essay-criterion-score { font-weight: 800; color: var(--brand); }
.essay-criterion-comment { font-size: .85rem; color: var(--ink-2); margin-top: 8px; line-height: 1.5; }
.essay-summary { margin-top: 16px; padding: 16px; border-radius: var(--radius); background: var(--good-soft); }
.essay-summary h3 { font-size: .95rem; font-weight: 700; margin-bottom: 8px; }
.essay-summary p { font-size: .9rem; line-height: 1.6; color: var(--ink-2); }

/* ── Referral Panel ── */
.referral-panel { }
.referral-link-row { display: flex; gap: 8px; margin-bottom: 12px; }
.referral-link { flex: 1; font-size: .85rem; }
.referral-share-row { display: flex; gap: 8px; margin-bottom: 12px; }
.referral-bonus { font-weight: 700; color: var(--good); text-align: center; margin-bottom: 8px; }
.referral-milestone { margin-top: 8px; }
.referral-milestone small { display: block; text-align: center; margin-top: 4px; color: var(--ink-3); font-size: .8rem; }

/* ── Plans page (app) ── */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 16px; }
.plan-card { padding: 24px; border-radius: var(--radius-card); border: 2px solid var(--line); background: var(--surface); text-align: center; transition: border-color var(--dur-fast) ease; }
.plan-card.active { border-color: var(--brand); }
.plan-card.premium { border-color: var(--gold); }
.plan-card h3 { font-size: 1.2rem; font-weight: 800; margin-bottom: 4px; }
.plan-card .plan-price { font-size: 2rem; font-weight: 800; color: var(--brand); margin: 12px 0; }
.plan-card .plan-price small { font-size: .9rem; font-weight: 500; color: var(--ink-3); }
.plan-card .plan-features { text-align: left; margin: 16px 0; }
.plan-card .plan-features li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: .9rem; }
.plan-card .plan-features li .icon { color: var(--good); width: 18px; height: 18px; flex-shrink: 0; }
.plan-card .plan-features li.off { color: var(--ink-3); }
.plan-card .plan-features li.off .icon { color: var(--ink-3); }

/* ── League System ── */
.league-page { }
.league-header { text-align: center; }
.league-badge { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.4rem; }
.league-badge .icon { width: 32px; height: 32px; }
.league-badge h2 { font-size: 1.3rem; font-weight: 800; }
.league-my-rank { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; font-size: 1.1rem; }
.league-my-rank strong { font-size: 1.8rem; color: var(--brand); }
.league-list { display: flex; flex-direction: column; gap: 2px; }
.league-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  transition: background var(--dur-fast) ease;
}
.league-row.me { background: var(--brand-soft); font-weight: 700; }
.league-row.top3 { background: rgba(245,158,11,.08); }
.league-row.promote { background: rgba(16,185,129,.06); }
.league-row.demote { background: rgba(239,68,68,.06); }
.league-rank { width: 32px; text-align: center; font-weight: 800; font-size: .9rem; color: var(--ink-3); }
.league-rank.medal-gold { color: #FFD700; background: none; box-shadow: none; }
.league-rank.medal-silver { color: #C0C0C0; background: none; box-shadow: none; }
.league-rank.medal-bronze { color: #CD7F32; background: none; box-shadow: none; }
.league-name { flex: 1; font-size: .9rem; }
.league-xp { font-weight: 700; font-size: .85rem; color: var(--ink-2); }

/* League widget on home */
.league-widget {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  margin-bottom: 12px; transition: background var(--dur-fast) ease;
}
.league-widget:hover { background: var(--surface-2); }
.league-widget-badge {
  padding: 4px 12px; border-radius: var(--radius-pill);
  color: #fff; font-size: .8rem; font-weight: 700;
}
.league-widget-xp { font-weight: 700; font-size: .95rem; }

/* ── Interest Chips ── */
.interests-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.interest-chip {
  padding: 8px 16px; border-radius: var(--radius-pill);
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: .85rem; font-weight: 600; cursor: pointer;
  color: var(--ink-2); transition: all var(--dur-fast) ease;
  font-family: inherit;
}
.interest-chip:hover { border-color: var(--brand); color: var(--brand); }
.interest-chip.active {
  background: var(--brand); color: #fff;
  border-color: var(--brand);
}
.profile-interests {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0;
}
.interest-badge {
  padding: 4px 12px; border-radius: var(--radius-pill);
  background: var(--brand-soft); color: var(--brand-ink);
  font-size: .8rem; font-weight: 600;
}

/* ── Photo Preview in Chat ── */
.chat-photo-preview {
  max-width: 280px; max-height: 200px;
  border-radius: var(--radius-sm); margin-bottom: 8px;
  display: block; object-fit: contain;
}

/* ── Examiner Page ── */
.examiner-page { }
.examiner-modes { display: flex; gap: 8px; flex-wrap: wrap; }
.examiner-subjects { display: flex; gap: 8px; flex-wrap: wrap; }
.examiner-feedback { line-height: 1.7; font-size: .95rem; }
.examiner-feedback h1, .examiner-feedback h2, .examiner-feedback h3 { margin: 16px 0 8px; }

/* Oral examiner */
.oral-examiner { }
.oral-messages { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; max-height: 400px; overflow-y: auto; }
.oral-msg { padding: 12px 16px; border-radius: var(--radius); max-width: 85%; }
.oral-msg.examiner { background: var(--surface-2); align-self: flex-start; }
.oral-msg.student { background: var(--brand-soft); align-self: flex-end; }
.oral-role { font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--ink-3); letter-spacing: .04em; }
.oral-msg p { margin-top: 4px; font-size: .9rem; line-height: 1.6; }
.oral-input-row { display: flex; gap: 8px; align-items: center; }
.oral-answer-input { flex: 1; }

/* ── Explain My Answer ── */
.explain-row { margin-top: 12px; }
.explain-btn { gap: 6px; }
.explain-loading {
  display: flex; align-items: center; gap: 8px;
  font-size: .85rem; color: var(--ink-3); padding: 8px 0;
}
.explain-text {
  font-size: .9rem; line-height: 1.65; color: var(--ink-2);
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--bg-soft); margin-bottom: 8px;
  border-left: 3px solid var(--brand);
  overflow-wrap: break-word;
  animation: explain-in .3s ease;
}
@keyframes explain-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ── Study Plan / Target Score ── */
.plan-page { }
.target-presets {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.target-preset {
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 12px; text-align: center; gap: 4px;
}
.target-preset strong { font-size: 1.3rem; }
.target-preset span { font-weight: 700; font-size: .9rem; }
.target-preset small { font-size: .78rem; color: var(--ink-3); }

.plan-timeline { display: flex; flex-direction: column; gap: 20px; margin-top: 20px; }
.plan-week {
  padding: 20px; border-radius: var(--radius-card);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.plan-week.current { border-color: var(--brand); border-width: 2px; }
.plan-week-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.plan-week-num { font-weight: 800; font-size: 1rem; color: var(--brand); }
.plan-week-topics { display: flex; flex-direction: column; gap: 10px; }
.plan-topic-card {
  padding: 14px; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px solid var(--line);
}
.plan-topic-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.plan-topic-name { font-weight: 700; font-size: .9rem; }
.plan-topic-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; font-size: .82rem; color: var(--ink-3);
}

/* ── Plan Stats ── */
.plan-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin: 16px 0;
}

/* ── Score Trajectory Chart ── */
.plan-trajectory { margin-top: 16px; }
.trajectory-chart {
  display: flex; align-items: flex-end; gap: 8px;
  height: 180px; margin-top: 16px;
  padding: 16px 8px 0;
  border-bottom: 2px solid var(--line);
}
.traj-bar-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; height: 100%;
  justify-content: flex-end;
}
.traj-bar {
  width: 100%; max-width: 48px;
  background: linear-gradient(180deg, var(--brand), var(--brand-soft));
  border-radius: 8px 8px 0 0;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 6px; min-height: 20px;
  transition: height .5s var(--ease-spring);
}
.traj-bar span {
  font-size: .75rem; font-weight: 800; color: #fff;
}
.traj-bar-wrap small {
  margin-top: 6px; font-size: .7rem; color: var(--ink-3);
}

/* ── Plan Topic Completion ── */
.plan-topic-check {
  width: 24px; height: 24px; border-radius: 6px;
  border: 2px solid var(--line-2); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; padding: 0;
  transition: all var(--dur-fast) ease;
  color: transparent;
}
.plan-topic-card.completed .plan-topic-check {
  background: var(--good); border-color: var(--good);
  color: #fff;
}
.plan-topic-card.completed .plan-topic-check .icon {
  width: 14px; height: 14px;
}
.plan-topic-name.done {
  text-decoration: line-through;
  color: var(--ink-3);
}
.plan-topic-card.completed {
  opacity: .7;
}

/* ── Plan Week Progress ── */
.plan-week-progress {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.plan-week-progress .progress { flex: 1; }
.plan-week-progress small {
  font-size: .8rem; font-weight: 600; color: var(--ink-3);
  white-space: nowrap;
}

/* ── Explain Actions Row ── */
.explain-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.explain-counter { margin-left: auto; }

/* ── Anti-stress Companion ── */
.stress-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .3s ease;
}
.stress-overlay.visible { opacity: 1; }
.stress-card {
  background: var(--surface); border-radius: var(--radius-card);
  padding: 32px; max-width: 420px; width: 90%; text-align: center;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(.95); transition: transform .35s var(--ease-spring);
}
.stress-overlay.visible .stress-card { transform: none; }
.stress-mascot { width: 80px; height: 80px; margin: 0 auto 16px; }
.stress-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 4px; }
.stress-subtitle { color: var(--ink-3); font-size: .9rem; margin-bottom: 12px; }
.stress-misha { color: var(--ink-2); font-style: italic; line-height: 1.6; margin-bottom: 16px; font-size: .95rem; }
.stress-actions { display: flex; flex-direction: column; gap: 8px; }

/* ── Pre-exam Banner ── */
.pre-exam-banner {
  display: flex; align-items: center; gap: 20px;
  border: 2px solid var(--brand); position: relative; overflow: hidden;
}
.pre-exam-banner.urgent {
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--surface), var(--brand-soft));
}
.pre-exam-mascot { width: 80px; height: 80px; flex-shrink: 0; }
.pre-exam-content { flex: 1; }
.pre-exam-tip {
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--bg-soft); margin: 12px 0;
  font-size: .9rem; line-height: 1.5;
}
.pre-exam-tip strong { color: var(--brand); }
@media (max-width: 600px) {
  .pre-exam-banner { flex-direction: column; text-align: center; }
  .pre-exam-mascot { width: 60px; height: 60px; }
}

/* ── Breathing Exercise ── */
.breathing-page { }
.breathing-container { text-align: center; }
.breathing-visual {
  display: flex; justify-content: center; padding: 32px 0;
}
.breathing-circle {
  width: 200px; height: 200px; border-radius: 50%;
  border: 4px solid var(--brand);
  display: flex; align-items: center; justify-content: center;
  transition: transform 1s ease, border-color .5s ease;
  background: radial-gradient(circle, rgba(223,153,91,.08) 0%, transparent 70%);
}
.breathing-inner { text-align: center; }
.breathing-phase {
  font-size: 1.3rem; font-weight: 800;
  transition: color .3s ease;
}
.breathing-timer {
  font-size: 2.5rem; font-weight: 800;
  color: var(--ink); margin-top: 4px;
}
.breathing-legend {
  display: flex; justify-content: center; gap: 16px;
  font-size: .85rem; font-weight: 600; margin: 12px 0;
}
.breathing-cycles {
  font-size: .9rem; color: var(--ink-3); margin-bottom: 16px;
}
.breathing-actions {
  display: flex; justify-content: center; gap: 10px;
}

/* ── Topbar Back Button ── */
.topbar-back {
  flex-shrink: 0;
  width: 40px; height: 40px;
  padding: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
}
.topbar-back .icon { width: 20px; height: 20px; }

/* ── Essay & Examiner page spacing ── */
.essay-page > .panel,
.examiner-page > .panel,
.examiner-page > section,
.breathing-page > .panel {
  margin-bottom: 16px;
}
.essay-source-block {
  margin-bottom: 12px;
}
.essay-source-block label {
  display: block; margin-bottom: 6px;
}
.essay-source-textarea {
  width: 100%; min-height: 120px; resize: vertical;
  font-size: .9rem; line-height: 1.6; padding: 14px;
}

/* ── Featured mode tile ── */
.mode-tile-featured {
  position: relative;
  border: 2px solid var(--brand) !important;
  background: linear-gradient(135deg, var(--surface), var(--brand-soft)) !important;
}
.mode-tile-featured .tile-icon {
  background: var(--brand) !important;
  color: #fff !important;
}
.mode-tile-badge {
  position: absolute; top: -8px; right: 12px;
  padding: 2px 10px; border-radius: var(--radius-pill);
  background: var(--brand); color: #fff;
  font-size: .7rem; font-weight: 800; letter-spacing: .03em;
  text-transform: uppercase;
  box-shadow: 0 2px 8px -2px rgba(223,153,91,.4);
}
