:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef6ff;
  --surface-warm: #fff7e7;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ef;
  --green: #44b86a;
  --green-dark: #23864a;
  --blue: #2f7cf6;
  --blue-soft: #e8f1ff;
  --orange: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
  --shadow: 0 16px 42px rgba(31, 44, 71, 0.12);
  --shadow-soft: 0 8px 24px rgba(31, 44, 71, 0.08);
  --radius: 24px;
  --radius-sm: 14px;
  --nav-height: 76px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sidebar-bg: rgba(255, 255, 255, 0.94);
  --topbar-bg: rgba(245, 247, 251, 0.86);
  --card-bg: rgba(255, 255, 255, 0.96);
}

body[data-theme="dark"] {
  --bg: #10151f;
  --surface: #172131;
  --surface-soft: #223249;
  --surface-warm: #352a18;
  --ink: #edf4ff;
  --muted: #c0ccdc;
  --line: #3a4b64;
  --green: #52d273;
  --green-dark: #8df0a4;
  --blue: #6ea8ff;
  --blue-soft: #172f52;
  --orange: #fbbf24;
  --red: #ff6b6b;
  --purple: #a78bfa;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.28);
  --sidebar-bg: rgba(16, 22, 33, 0.96);
  --topbar-bg: rgba(16, 21, 31, 0.9);
  --card-bg: rgba(23, 33, 49, 0.98);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(47, 124, 246, 0.12), transparent 34rem),
    linear-gradient(180deg, #f9fbff 0%, #eef3f8 100%);
}

body[data-theme="dark"] {
  background:
    radial-gradient(circle at top left, rgba(82, 210, 115, 0.12), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(110, 168, 255, 0.12), transparent 30rem),
    linear-gradient(180deg, #0f1724 0%, #101a2b 100%);
}

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

button {
  border: 0;
  cursor: pointer;
}

textarea,
input {
  color: var(--ink);
}

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

.center-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.brand-card,
.auth-panel,
.card,
.lesson-card,
.question-card,
.exam-part,
.modal-panel {
  background: var(--card-bg);
  border: 1px solid rgba(217, 226, 239, 0.9);
  box-shadow: var(--shadow-soft);
}

body[data-theme="dark"] .brand-card,
body[data-theme="dark"] .auth-panel,
body[data-theme="dark"] .card,
body[data-theme="dark"] .lesson-card,
body[data-theme="dark"] .question-card,
body[data-theme="dark"] .exam-part,
body[data-theme="dark"] .modal-panel {
  border-color: var(--line);
}

.brand-card,
.auth-panel {
  width: min(960px, 100%);
  border-radius: 30px;
  padding: clamp(24px, 5vw, 54px);
}

.brand-mark {
  display: grid;
  width: 68px;
  height: 68px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(145deg, var(--green), #7ed957);
  color: white;
  font-size: 2rem;
  font-weight: 900;
  box-shadow: 0 12px 22px rgba(68, 184, 106, 0.28);
}

.auth-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
  align-items: center;
  padding: clamp(18px, 4vw, 44px);
}

.auth-hero {
  padding: clamp(20px, 4vw, 54px);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--green-dark);
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 14px;
  font-size: clamp(2.35rem, 6vw, 5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2.3rem);
  letter-spacing: 0;
}

h3 {
  font-size: 1.05rem;
}

.lead {
  max-width: 680px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.65;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 32px;
}

.auth-stat {
  border-radius: 20px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.auth-stat strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.35rem;
}

.auth-stat span {
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-panel h2 {
  margin-bottom: 8px;
}

.form-row {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.form-row label,
.small-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 88%, white 12%);
  padding: 14px 16px;
  outline: none;
  transition: border 0.18s, box-shadow 0.18s, background 0.18s;
}

body[data-theme="dark"] .input,
body[data-theme="dark"] .textarea,
body[data-theme="dark"] .select {
  background: #101a2b;
  border-color: var(--line);
}

.textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.55;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--blue);
  background: white;
  box-shadow: 0 0 0 4px rgba(47, 124, 246, 0.12);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 0 18px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 850;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px #c8d5e8, var(--shadow-soft);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(180deg, #58cc78, #37a65c);
  color: white;
  box-shadow: 0 8px 0 #23864a;
}

.btn.primary:active {
  box-shadow: 0 3px 0 #23864a;
}

.btn.blue {
  background: var(--blue);
  color: white;
  box-shadow: 0 8px 0 #1f5fc7;
}

.btn.danger {
  background: #fff1f1;
  color: #b42318;
}

.btn.ghost {
  background: transparent;
}

.layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 370px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  backdrop-filter: blur(18px);
  box-shadow: 14px 0 34px rgba(31, 44, 71, 0.06);
}

.side-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  border-radius: 28px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(88, 204, 120, 0.18), rgba(47, 124, 246, 0.1));
  border: 1px solid rgba(88, 204, 120, 0.18);
}

.side-brand .brand-mark {
  width: 58px;
  height: 58px;
  margin: 0;
  border-radius: 20px;
  font-size: 1.65rem;
}

.side-brand strong {
  display: block;
  font-size: 1.18rem;
}

.side-brand span {
  color: var(--muted);
  font-size: 0.9rem;
}

.side-focus {
  display: grid;
  gap: 5px;
  margin-bottom: 18px;
  border-radius: 30px;
  padding: 20px;
  background:
    radial-gradient(circle at 92% 12%, rgba(255, 255, 255, 0.3), transparent 4rem),
    linear-gradient(135deg, #58cc78, #2f7cf6);
  color: white;
  box-shadow: 0 16px 0 rgba(35, 134, 74, 0.18), var(--shadow-soft);
}

.side-focus span {
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-focus strong {
  font-size: 1.2rem;
}

.side-focus small {
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.45;
}

.side-focus-bars {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.7fr;
  gap: 7px;
  margin-top: 12px;
}

.side-focus-bars i {
  display: block;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.nav-list {
  display: grid;
  gap: 12px;
}

.nav-btn {
  display: grid;
  width: 100%;
  min-height: 74px;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-radius: 24px;
  padding: 10px 13px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 850;
  box-shadow: inset 0 0 0 1px transparent;
  position: relative;
  overflow: hidden;
}

.nav-btn:hover,
.nav-btn.active {
  background: #ecfff2;
  color: #17472b;
  box-shadow: inset 0 0 0 2px rgba(88, 204, 120, 0.7), 0 9px 18px rgba(68, 184, 106, 0.12);
}

body[data-theme="dark"] .nav-btn:hover,
body[data-theme="dark"] .nav-btn.active {
  background: #183622;
  color: #eaffef;
  box-shadow: inset 0 0 0 2px rgba(82, 210, 115, 0.72), 0 12px 22px rgba(0, 0, 0, 0.22);
}

.nav-icon,
.module-icon {
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #eef3fb;
  color: var(--blue);
  font-weight: 950;
}

.nav-icon {
  width: 54px;
  height: 54px;
  border-radius: 19px;
  font-size: 1.18rem;
  background: linear-gradient(145deg, #eef7ff, #e9fff0);
  color: #267a47;
  box-shadow: inset 0 -3px 0 rgba(31, 44, 71, 0.07);
}

body[data-theme="dark"] .nav-icon {
  background: linear-gradient(145deg, #21314a, #1b3c2a);
  color: #a9f5bb;
}

.nav-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.nav-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.02rem;
}

.nav-text small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-btn.active .nav-text small,
.nav-btn:hover .nav-text small {
  color: currentColor;
  opacity: 0.75;
}

.nav-progress {
  display: inline-grid;
  min-width: 48px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 950;
  box-shadow: inset 0 0 0 1px var(--line);
}

.profile-mini {
  position: absolute;
  right: 22px;
  bottom: 22px;
  left: 22px;
  border-radius: 28px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.profile-mini strong,
.profile-mini span {
  display: block;
}

.profile-mini span {
  color: var(--muted);
  font-size: 0.84rem;
}

.main {
  min-width: 0;
  padding: 34px 42px 48px;
}

.topbar {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 20;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -34px -42px 34px;
  padding: 22px 42px;
  border-bottom: 1px solid rgba(217, 226, 239, 0.84);
  background: var(--topbar-bg);
  backdrop-filter: blur(18px);
}

.topbar strong {
  font-size: 1.18rem;
}

.mobile-menu {
  display: none;
}

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

.pill {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 850;
  box-shadow: inset 0 0 0 1px var(--line);
}

.pill.green {
  background: #ebfff2;
  color: var(--green-dark);
}

.pill.orange {
  background: #fff7e7;
  color: #9a5b00;
}

.pill.blue {
  background: var(--blue-soft);
  color: #174ea6;
}

.page-head {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-head p {
  max-width: 820px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

.hero-panel {
  overflow: hidden;
  border-radius: 34px;
  background:
    linear-gradient(135deg, rgba(47, 124, 246, 0.92), rgba(68, 184, 106, 0.92)),
    linear-gradient(90deg, #2f7cf6, #44b86a);
  color: white;
  padding: clamp(24px, 5vw, 42px);
  box-shadow: var(--shadow);
}

.hero-panel h2 {
  margin-bottom: 12px;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 1.05;
}

.hero-panel p {
  max-width: 660px;
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.65;
}

.hero-actions {
  margin-top: 22px;
}

.card {
  border-radius: var(--radius);
  padding: 18px;
}

.card h3 {
  margin-bottom: 12px;
}

.stat-grid,
.module-grid,
.mode-grid,
.exam-grid,
.vocab-grid {
  display: grid;
  gap: 14px;
}

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

.stat-card {
  border-radius: 20px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.stat-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.6rem;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.lesson-card {
  display: grid;
  gap: 14px;
  border-radius: var(--radius);
  padding: 22px;
  text-align: left;
  transition: transform 0.16s, box-shadow 0.16s;
  border-bottom: 5px solid rgba(31, 44, 71, 0.08);
}

.lesson-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.lesson-card p {
  color: var(--muted);
  line-height: 1.5;
}

.module-icon {
  width: 50px;
  height: 50px;
  font-size: 1.1rem;
}

.progress-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e7edf6;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 14px;
}

.mode-grid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  margin-bottom: 18px;
}

.mode-btn {
  display: grid;
  min-height: 96px;
  gap: 8px;
  justify-items: start;
  border-radius: 20px;
  padding: 16px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: inset 0 0 0 1px var(--line);
}

.mode-btn.active {
  background: #ebfff2;
  box-shadow: inset 0 0 0 2px var(--green);
}

.mode-btn strong {
  font-size: 0.98rem;
}

.mode-btn span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.question-card {
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 26px);
}

.task-text {
  border-radius: 18px;
  padding: 18px;
  background: #f8fbff;
  color: #344054;
  line-height: 1.7;
}

.chip-box {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.chip {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  border-radius: 999px;
  padding: 0 13px;
  background: #eef3fb;
  color: #344054;
  font-weight: 750;
  box-shadow: inset 0 0 0 1px #d9e2ef;
}

.chip.selectable {
  cursor: pointer;
}

.chip.selected,
.answer-option.selected {
  background: #e8fff0;
  color: var(--green-dark);
  box-shadow: inset 0 0 0 2px var(--green);
}

.chip.wrong {
  background: #fff1f1;
  color: #b42318;
}

.answer-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.answer-option {
  width: 100%;
  min-height: 52px;
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font-weight: 750;
  box-shadow: inset 0 0 0 1px var(--line);
}

.answer-option.correct {
  background: #ebfff2;
  color: var(--green-dark);
  box-shadow: inset 0 0 0 2px var(--green);
}

.answer-option.incorrect {
  background: #fff1f1;
  color: #b42318;
  box-shadow: inset 0 0 0 2px var(--red);
}

.feedback {
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--blue-soft);
  color: #174ea6;
  line-height: 1.55;
}

.feedback.success {
  background: #ebfff2;
  color: var(--green-dark);
}

.feedback.warning {
  background: #fff7e7;
  color: #9a5b00;
}

.feedback.error {
  background: #fff1f1;
  color: #b42318;
}

.checklist {
  display: grid;
  gap: 9px;
}

.check-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  color: #344054;
  line-height: 1.45;
}

.check-item input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.builder-board {
  display: grid;
  gap: 12px;
}

.drop-zone {
  min-height: 130px;
  border: 2px dashed #c8d5e8;
  border-radius: 20px;
  padding: 14px;
  background: #f8fbff;
}

.drop-zone .chip {
  margin: 4px;
}

.word-count {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
}

.writing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  align-items: start;
}

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

.argument-card {
  border-radius: 16px;
  padding: 12px;
  background: #f8fbff;
  color: #344054;
  line-height: 1.45;
}

.argument-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-btn {
  min-height: 38px;
  border-radius: 999px;
  padding: 0 13px;
  background: #eef3fb;
  color: #344054;
  font-weight: 850;
}

.tab-btn.active {
  background: var(--ink);
  color: white;
}

.exam-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.timer {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  border-radius: 999px;
  padding: 0 18px;
  background: var(--ink);
  color: white;
  font-weight: 950;
}

.exam-grid {
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
}

.exam-nav {
  position: sticky;
  top: 96px;
}

.exam-part {
  border-radius: var(--radius);
  padding: 18px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.score-row:last-child {
  border-bottom: 0;
}

.matching-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
}

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

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 1180px) {
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .dashboard-grid,
  .split,
  .writing-layout,
  .exam-grid {
    grid-template-columns: 1fr;
  }

  .exam-nav {
    position: static;
  }
}

@media (max-width: 860px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    padding-bottom: 0;
  }

  .auth-grid,
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .layout {
    display: block;
    padding-bottom: var(--nav-height);
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 18px 16px 28px;
  }

  .topbar {
    margin: -18px -16px 18px;
    padding: 14px 16px;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .xp-strip {
    gap: 6px;
  }

  .pill {
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.86rem;
  }

  .page-head {
    display: block;
  }

  .mobile-bottom-nav {
    display: grid;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.95);
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    backdrop-filter: blur(18px);
  }

  .mobile-bottom-nav button {
    display: grid;
    min-height: 54px;
    place-items: center;
    border-radius: 15px;
    background: transparent;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 850;
  }

  .mobile-bottom-nav button.active {
    background: var(--blue-soft);
    color: #174ea6;
  }
}

@media (max-width: 620px) {
  .auth-grid,
  .stat-grid,
  .module-grid,
  .mode-grid,
  .matching-grid {
    grid-template-columns: 1fr;
  }

  .auth-layout {
    padding: 14px;
  }

  .auth-panel,
  .brand-card {
    border-radius: 24px;
  }

  .button-row {
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  .topbar {
    display: grid;
  }

  .xp-strip {
    justify-content: flex-start;
  }
}

body[data-theme="dark"] .task-text {
  background: #101a2b;
  color: #d7e2f2;
}

body[data-theme="dark"] .chip {
  background: #22324a;
  color: #e6eefb;
  box-shadow: inset 0 0 0 1px var(--line);
}

body[data-theme="dark"] .answer-option {
  background: #132035;
  box-shadow: inset 0 0 0 1px var(--line);
}

body[data-theme="dark"] .feedback {
  background: #172f52;
  color: #d7e8ff;
}

body[data-theme="dark"] .feedback.success {
  background: #12351f;
  color: #a9f5bb;
}

body[data-theme="dark"] .feedback.warning {
  background: #332612;
  color: #ffd98a;
}

body[data-theme="dark"] .feedback.error {
  background: #3a171a;
  color: #ffb4b4;
}

body[data-theme="dark"] .argument-card {
  background: #101a2b;
  color: #d7e2f2;
}

body[data-theme="dark"] .tab-btn {
  background: #22324a;
  color: #d7e2f2;
}

body[data-theme="dark"] .drop-zone {
  background: #101a2b;
  border-color: var(--line);
}

body[data-theme="dark"] .auth-stat,
body[data-theme="dark"] .stat-card {
  background: var(--surface);
}

body[data-theme="dark"] .btn {
  background: #18263b;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

body[data-theme="dark"] .btn.primary {
  background: linear-gradient(180deg, #58cc78, #37a65c);
  color: white;
  box-shadow: 0 8px 0 #1d6f3b;
}

body[data-theme="dark"] .btn.blue {
  background: #3f83f8;
  color: white;
  box-shadow: 0 8px 0 #1f5fc7;
}

body[data-theme="dark"] .btn.danger {
  background: #351b22;
  color: #ffb4b4;
}

.theme-toggle {
  min-width: 86px;
}

body[data-theme="dark"] .lead,
body[data-theme="dark"] .small-label,
body[data-theme="dark"] .form-row label,
body[data-theme="dark"] .check-item,
body[data-theme="dark"] .word-count,
body[data-theme="dark"] .lesson-card p,
body[data-theme="dark"] .page-head p,
body[data-theme="dark"] .auth-stat span,
body[data-theme="dark"] .stat-card span,
body[data-theme="dark"] .profile-mini span,
body[data-theme="dark"] .side-brand span {
  color: #c8d4e5;
}

body[data-theme="dark"] h1,
body[data-theme="dark"] h2,
body[data-theme="dark"] h3,
body[data-theme="dark"] strong {
  color: #f4f8ff;
}

body[data-theme="dark"] .pill {
  background: #17243a;
  color: #f4f8ff;
  box-shadow: inset 0 0 0 1px var(--line);
}

body[data-theme="dark"] .pill.green {
  background: #12351f;
  color: #a9f5bb;
}

body[data-theme="dark"] .pill.blue {
  background: #172f52;
  color: #d7e8ff;
}

body[data-theme="dark"] .pill.orange {
  background: #332612;
  color: #ffd98a;
}

body[data-theme="dark"] .lesson-card {
  border-bottom-color: rgba(82, 210, 115, 0.22);
}

body[data-theme="dark"] .progress-track {
  background: #26364d;
}

body[data-theme="dark"] .hero-panel .btn:not(.primary) {
  background: rgba(255, 255, 255, 0.14);
  color: white;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26);
}

body[data-theme="dark"] .tab-btn.active {
  background: #f4f8ff;
  color: #10151f;
}

body[data-theme="dark"] .answer-option.correct,
body[data-theme="dark"] .chip.selected {
  background: #12351f;
  color: #a9f5bb;
}

body[data-theme="dark"] .answer-option.incorrect,
body[data-theme="dark"] .chip.wrong {
  background: #3a171a;
  color: #ffb4b4;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .nav-btn {
    min-height: 68px;
    grid-template-columns: 48px minmax(0, 1fr) auto;
  }

  .nav-icon {
    width: 48px;
    height: 48px;
  }
}

/* Cloudflare responsive design patch: cleaner Duolingo-inspired app shell */
:root {
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-soft: #f0f7ff;
  --ink: #162033;
  --muted: #607089;
  --line: #dde7f3;
  --green: #58cc78;
  --green-dark: #2d8b4b;
  --blue: #1cb0f6;
  --blue-soft: #e8f6ff;
  --orange: #ffb020;
  --red: #ff4b4b;
  --shadow: 0 14px 34px rgba(37, 56, 88, 0.12);
  --shadow-soft: 0 8px 18px rgba(37, 56, 88, 0.08);
  --sidebar-bg: #ffffff;
  --topbar-bg: rgba(243, 247, 251, 0.94);
  --card-bg: #ffffff;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #111c2e;
  --surface-soft: #17263c;
  --surface-warm: #2c2414;
  --ink: #f6f9ff;
  --muted: #d2dbea;
  --line: #30445f;
  --green: #58cc78;
  --green-dark: #9bf3b0;
  --blue: #58c7ff;
  --blue-soft: #132a42;
  --orange: #ffd166;
  --red: #ff7b7b;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.34);
  --sidebar-bg: #0f1929;
  --topbar-bg: rgba(11, 18, 32, 0.94);
  --card-bg: #111c2e;
}

html {
  font-size: 17px;
}

body,
body[data-theme="dark"] {
  overflow-x: hidden;
}

.layout {
  grid-template-columns: minmax(286px, 318px) minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
  padding: 20px 18px;
  background: var(--sidebar-bg);
}

.side-brand,
.side-focus,
.profile-mini,
.nav-btn,
.lesson-card,
.card,
.question-card,
.exam-part,
.auth-panel,
.brand-card {
  border-color: var(--line);
}

.side-brand {
  flex: 0 0 auto;
  margin-bottom: 0;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(88, 204, 120, 0.16), rgba(28, 176, 246, 0.11));
}

.side-brand .brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
}

.side-brand strong {
  color: var(--ink);
}

.side-brand span,
.nav-text small,
.profile-mini span,
.small-label,
.lead,
.page-head p,
.lesson-card p,
.check-item,
.word-count,
.form-row label,
.auth-stat span,
.stat-card span {
  color: var(--muted);
}

.side-focus {
  flex: 0 0 auto;
  margin-bottom: 0;
  border: 0;
  border-radius: 24px;
  padding: 18px;
  background:
    radial-gradient(circle at 88% 8%, rgba(255, 255, 255, 0.36), transparent 70px),
    linear-gradient(135deg, #58cc78 0%, #1cb0f6 100%);
  box-shadow: 0 8px 0 rgba(45, 139, 75, 0.2), var(--shadow-soft);
}

.side-focus strong {
  color: white;
}

.nav-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 2px 2px 8px;
  scrollbar-width: thin;
}

.nav-btn {
  min-height: 66px;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  border-radius: 20px;
  background: transparent;
}

.nav-btn:hover,
.nav-btn.active {
  background: #effdf4;
  color: #175c34;
  box-shadow: inset 0 0 0 2px rgba(88, 204, 120, 0.72), 0 6px 14px rgba(88, 204, 120, 0.11);
}

body[data-theme="dark"] .nav-btn:hover,
body[data-theme="dark"] .nav-btn.active {
  background: #183523;
  color: #f6fff8;
  box-shadow: inset 0 0 0 2px rgba(88, 204, 120, 0.78), 0 8px 18px rgba(0, 0, 0, 0.28);
}

.nav-icon {
  width: 48px;
  height: 48px;
  border-radius: 17px;
  background: #eff7ff;
  color: #1779aa;
}

.nav-btn.active .nav-icon,
.nav-btn:hover .nav-icon {
  background: #58cc78;
  color: white;
}

body[data-theme="dark"] .nav-icon {
  background: #17263c;
  color: #d8f2ff;
}

body[data-theme="dark"] .nav-btn.active .nav-icon,
body[data-theme="dark"] .nav-btn:hover .nav-icon {
  background: #58cc78;
  color: #082012;
}

.nav-text strong {
  color: var(--ink);
  font-size: 0.98rem;
}

.nav-btn.active .nav-text strong,
.nav-btn:hover .nav-text strong {
  color: currentColor;
}

.nav-text small {
  font-size: 0.76rem;
}

.nav-progress {
  min-width: 44px;
  height: 30px;
  background: var(--surface);
  color: var(--muted);
}

.profile-mini {
  position: static;
  flex: 0 0 auto;
  border-radius: 22px;
  background: var(--surface);
}

.profile-mini .button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.profile-mini .btn {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.main {
  min-width: 0;
  padding: 24px clamp(18px, 3vw, 40px) 42px;
}

.topbar {
  margin: -24px calc(clamp(18px, 3vw, 40px) * -1) 26px;
  padding: 16px clamp(18px, 3vw, 40px);
  background: var(--topbar-bg);
}

.topbar > div:first-of-type {
  min-width: 0;
}

.topbar strong,
h1,
h2,
h3,
.card strong,
.stat-card strong,
.auth-stat strong {
  color: var(--ink);
}

.xp-strip {
  min-width: 0;
}

.pill {
  white-space: nowrap;
}

.hero-panel {
  border-radius: 28px;
  background:
    radial-gradient(circle at 92% 8%, rgba(255, 255, 255, 0.34), transparent 92px),
    linear-gradient(135deg, #58cc78 0%, #1cb0f6 100%);
}

.hero-panel h2,
.hero-panel p,
.hero-panel .eyebrow {
  color: white;
}

.dashboard-grid,
.split,
.writing-layout,
.exam-grid {
  align-items: start;
}

.module-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.lesson-card,
.card,
.question-card,
.exam-part,
.stat-card,
.auth-stat {
  background: var(--card-bg);
  overflow-wrap: anywhere;
}

.lesson-card {
  min-height: 210px;
  border-radius: 24px;
  border-bottom: 6px solid rgba(88, 204, 120, 0.2);
}

.module-icon {
  width: 58px;
  height: 58px;
  border-radius: 20px;
  background: #effdf4;
  color: #2d8b4b;
}

body[data-theme="dark"] .module-icon {
  background: #183523;
  color: #9bf3b0;
}

.btn {
  min-height: 48px;
}

.btn.primary {
  background: linear-gradient(180deg, #58cc78, #35a95b);
}

.input,
.textarea,
.select,
body[data-theme="dark"] .input,
body[data-theme="dark"] .textarea,
body[data-theme="dark"] .select {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.input::placeholder,
.textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 78%, transparent);
}

.task-text,
.argument-card,
.drop-zone,
body[data-theme="dark"] .task-text,
body[data-theme="dark"] .argument-card,
body[data-theme="dark"] .drop-zone {
  background: var(--surface-soft);
  color: var(--ink);
  border-color: var(--line);
}

.chip,
.tab-btn,
body[data-theme="dark"] .chip,
body[data-theme="dark"] .tab-btn {
  background: var(--surface-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.feedback,
body[data-theme="dark"] .feedback {
  background: var(--blue-soft);
  color: var(--ink);
}

.answer-option,
body[data-theme="dark"] .answer-option {
  background: var(--surface);
  color: var(--ink);
}

.exam-grid {
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
}

pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
}

@media (max-width: 1180px) {
  html {
    font-size: 16px;
  }

  .layout {
    grid-template-columns: 292px minmax(0, 1fr);
  }

  .side-focus {
    padding: 16px;
  }

  .nav-btn {
    min-height: 62px;
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .nav-icon {
    width: 44px;
    height: 44px;
  }

  .nav-progress {
    display: none;
  }

  .dashboard-grid,
  .split,
  .writing-layout,
  .exam-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  body {
    background:
      linear-gradient(180deg, rgba(88, 204, 120, 0.12), transparent 260px),
      var(--bg);
  }

  body[data-theme="dark"] {
    background:
      linear-gradient(180deg, rgba(88, 204, 120, 0.1), transparent 260px),
      var(--bg);
  }

  .layout {
    display: block;
    padding-bottom: calc(var(--nav-height) + 18px);
  }

  .sidebar {
    display: none;
  }

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

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: -16px -14px 18px;
    padding: 14px;
    border-bottom: 1px solid var(--line);
  }

  .topbar .mobile-menu {
    display: none;
  }

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

  .pill,
  .theme-toggle {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    justify-content: center;
    padding: 0 8px;
    font-size: 0.78rem;
  }

  .page-head {
    margin-bottom: 16px;
  }

  .hero-panel {
    border-radius: 24px;
    padding: 22px;
  }

  .hero-panel h2 {
    font-size: clamp(1.8rem, 10vw, 2.7rem);
  }

  .stat-grid,
  .module-grid,
  .mode-grid,
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .lesson-card {
    min-height: auto;
  }

  .question-card,
  .card,
  .exam-part,
  .lesson-card {
    border-radius: 20px;
    padding: 16px;
  }

  .mode-btn {
    min-height: 82px;
  }

  .mobile-bottom-nav {
    height: auto;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
  }

  body[data-theme="dark"] .mobile-bottom-nav {
    background: rgba(17, 28, 46, 0.96);
  }

  .mobile-bottom-nav button {
    min-width: 0;
    min-height: 58px;
    border-radius: 16px;
    color: var(--muted);
    font-size: 0.68rem;
  }

  .mobile-bottom-nav button span:first-child {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--ink);
    font-size: 0.82rem;
  }

  .mobile-bottom-nav button.active {
    background: #effdf4;
    color: #175c34;
  }

  body[data-theme="dark"] .mobile-bottom-nav button.active {
    background: #183523;
    color: #dfffe7;
  }
}

@media (max-width: 520px) {
  html {
    font-size: 15.5px;
  }

  h1 {
    font-size: clamp(2rem, 13vw, 3rem);
  }

  h2 {
    font-size: clamp(1.35rem, 8vw, 2rem);
  }

  .auth-layout {
    padding: 12px;
  }

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

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

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

  .textarea {
    min-height: 150px;
  }

  .mobile-bottom-nav {
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
  }

  .mobile-bottom-nav button {
    font-size: 0.62rem;
  }
}

.learning-path {
  overflow: hidden;
}

.path-steps {
  display: grid;
  gap: 12px;
}

.path-step {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border-radius: 18px;
  padding: 12px;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}

.path-step span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 15px;
  background: var(--surface);
  color: var(--green-dark);
  font-weight: 950;
  box-shadow: inset 0 0 0 1px var(--line);
}

.path-step strong,
.path-step small {
  display: block;
}

.path-step small {
  color: var(--muted);
  line-height: 1.35;
}

.path-step.focus {
  background: #effdf4;
  box-shadow: inset 0 0 0 2px rgba(88, 204, 120, 0.68);
}

body[data-theme="dark"] .path-step.focus {
  background: #183523;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 10px;
}

.badge {
  display: grid;
  gap: 8px;
  justify-items: center;
  border-radius: 18px;
  padding: 12px 8px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  box-shadow: inset 0 0 0 1px var(--line);
}

.badge span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 15px;
  background: var(--surface);
  font-weight: 950;
}

.badge strong {
  font-size: 0.78rem;
}

.badge.earned {
  background: #fff7d8;
  color: #7a4c00;
  box-shadow: inset 0 0 0 2px rgba(255, 176, 32, 0.56);
}

.badge.earned span {
  background: #ffb020;
  color: white;
}

body[data-theme="dark"] .badge.earned {
  background: #332612;
  color: #ffe2a0;
}

.lesson-flow {
  max-width: 920px;
  margin-inline: auto;
}

.lesson-flow .progress-track {
  height: 14px;
  margin-bottom: 22px;
}

.onboarding .answer-option {
  min-height: 58px;
}

body[data-theme="dark"] .score-row span {
  color: var(--muted);
}
