: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;
}

* {
  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); }
}

/* 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 */
