:root {
  color-scheme: light;
  --text: #1c2640;
  --canvas: #f5f7fc;
  --surface: #fff;
  --border: #e9ebf3;
  --accent-surface: #eeefff;
  --accent-text: #505bd0;
  --muted: #737d98;
  --success-surface: #e7f8f1;
  --success: #239a6b;
  --error: #b34b4b;
  --error-surface: #fff0f0;
  --focus: #b8befb;
  --accent-hover-text: #3945b5;
  --accent-border: #d9dcfb;
  --secondary-text: #58627b;
  --subtle-icon: #a1a9bb;
  --divider: #e7eaf2;
  --selected-surface: #e9eaff;
  --profile-hover: #dfe2fc;
  --accent-hover-surface: #e0e3fc;
  --progress-track: #e9edf4;
  --option-border: #e2e5ef;
  --selected-text: #424cb5;
  --control-border: #bcc3d5;
  --input-border: #d9deeb;
  --backdrop: rgb(28 38 64 / 35%);
  font-family: "Poppins", sans-serif;
  color: var(--text);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root[data-ui-mode="dark"] {
  color-scheme: dark;
  --text: #edf0fa;
  --canvas: #151927;
  --surface: #202637;
  --border: #3b455f;
  --accent-surface: #303954;
  --accent-text: #bcc5ff;
  --muted: #adb7ce;
  --success-surface: #193b32;
  --success: #73d8b1;
  --error: #f6969a;
  --error-surface: #492a35;
  --focus: #adb8ff;
  --accent-hover-text: #d8ddff;
  --accent-border: #505e88;
  --secondary-text: #c2cbe0;
  --subtle-icon: #9ca8c3;
  --divider: #343e56;
  --selected-surface: #38446a;
  --profile-hover: #46537d;
  --accent-hover-surface: #3c486b;
  --progress-track: #38425a;
  --option-border: #404b66;
  --selected-text: #d1d8ff;
  --control-border: #8290af;
  --input-border: #54617f;
  --backdrop: rgb(0 0 0 / 65%);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
}

button {
  font: inherit;
}

dialog {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 16px 48px rgb(35 46 82 / 16%);
}

dialog::backdrop { background: var(--backdrop); }
body:has(dialog[open]) { overflow: hidden; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-header .eyebrow { margin: 0; }
.close-dialog { border: 0; background: var(--accent-surface); color: var(--accent-text); border-radius: 50%; width: 36px; height: 36px; font-size: 24px; cursor: pointer; flex-shrink: 0; }
dialog h2 { font-size: 23px; letter-spacing: -0.4px; }
dialog p, dialog li { font-size: 13px; line-height: 1.7; color: var(--muted); }
.lesson-concept { margin: 0 0 16px; }
.lesson-media { margin-bottom: 20px; }
.lesson-media audio { display: block; width: 100%; max-width: 100%; }
.lesson-youtube { width: 100%; aspect-ratio: 16 / 9; }
.lesson-youtube iframe { display: block; width: 100%; height: 100%; border: 0; }
.lesson-actions { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 12px; }
.lesson-actions p:empty { display: none; }
.answer-list { display: grid; gap: 10px; margin: 20px 0; }
.answer, .dialog-action { width: 100%; padding: 12px 15px; border-radius: 11px; font-size: 13px; cursor: pointer; }
.answer { text-align: left; border: 1px solid var(--border); background: var(--canvas); color: var(--text); }
.answer:hover:not(:disabled) { border-color: #5964dc; background: var(--accent-surface); }
.answer.correct { border-color: var(--success); background: var(--success-surface); }
.answer.incorrect { border-color: var(--error); background: var(--error-surface); }
.answer:disabled { cursor: default; color: var(--text); opacity: 1; }
.dialog-action { border: 0; background: #5964dc; color: #fff; margin-top: 12px; }
.dialog-action:hover { background: #4652ca; }
dialog button:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
dialog .feedback { color: var(--text); min-height: 24px; }
.explanation-help { margin: -4px 0 4px; }
.explain-button { border: 0; border-radius: 4px; padding: 6px 0; background: transparent; color: var(--accent-text); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.explain-button:hover { color: var(--accent-hover-text); }
.explain-button:disabled { cursor: wait; }
dialog .explanation-detail { margin: 8px 0 12px; padding: 12px 14px; border-left: 2px solid var(--accent-border); border-radius: 0 8px 8px 0; background: var(--canvas); color: var(--secondary-text); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 20px 0; }
.stat { padding: 16px; border-radius: 14px; background: var(--canvas); font-size: 12px; color: var(--muted); }
.stat strong { display: block; font-size: 26px; color: var(--accent-text); }
.history-day { margin-top: 24px; }
.history-day h4 { margin: 0 0 10px; color: var(--muted); font-size: 12px; font-weight: 500; }
.history-list { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.history-item { display: grid; grid-template-columns: 20px minmax(0, 1fr) 14px; align-items: center; gap: 12px; width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 11px; background: var(--canvas); color: var(--text); text-align: left; cursor: pointer; }
.history-item:hover { background: var(--accent-surface); border-color: var(--focus); }
.history-details { min-width: 0; }
.history-item strong { display: block; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.history-meta { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.history-icon { width: 20px; height: 20px; color: var(--muted); }
.history-chevron { width: 14px; height: 14px; color: var(--subtle-icon); }
.dialog-header { position: sticky; top: -28px; z-index: 1; background: var(--surface); padding: 8px 0; }

.dashboard {
  width: min(1120px, 100% - 48px);
  margin: 0 auto;
  padding: 32px 0 64px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--divider);
}

.brand-mark,
.profile {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-weight: 700;
}

.brand-mark {
  background: #5b67e8;
  color: #fff;
  font-size: 21px;
}

.page-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

.profile {
  width: 38px;
  height: 38px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--selected-surface);
  color: var(--accent-text);
  font-size: 13px;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.account-control { position: relative; flex: 0 0 auto; margin-left: auto; }
.profile:hover, .profile[aria-expanded="true"] { background: var(--profile-hover); }
.account-menu { position: absolute; top: calc(100% + 10px); right: 0; z-index: 10; min-width: 160px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 8px 24px rgb(35 46 82 / 12%); }
.account-menu button { display: block; width: 100%; padding: 10px 14px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; font-size: 13px; cursor: pointer; }
.account-menu button:hover { background: var(--accent-surface); color: var(--accent-text); }
#ui-mode-button { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#ui-mode-button[aria-pressed="true"] { background: var(--selected-surface); color: var(--accent-text); }
#ui-mode-button[aria-pressed="true"]::after { content: "✓" / ""; }
.account-menu button:disabled { opacity: .45; cursor: wait; }
.account-menu p { margin: 6px 10px; font-size: 12px; color: var(--muted); }

.welcome {
  max-width: 680px;
  padding: 48px 0 34px;
}

.eyebrow,
.card-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
}

.welcome h2 {
  margin: 0 0 10px;
  font-size: clamp(27px, 4vw, 36px);
  font-weight: 600;
  letter-spacing: -1.2px;
}

.welcome > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.learning-card {
  display: flex;
  min-height: 310px;
  flex-direction: column;
  align-items: flex-start;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(35 46 82 / 4%);
}

.card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 24px;
  border-radius: 14px;
  background: var(--accent-surface);
  color: #5964dc;
  font-size: 23px;
}

.progress-card .card-icon {
  background: var(--success-surface);
  color: var(--success);
}

.next-card { border-color: var(--accent-border); }
.next-topic { margin: 4px 0 8px; font-size: 16px; font-weight: 500; }
.streak { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.streak strong { color: var(--success); font-size: 36px; font-weight: 600; }
.learning-card.progress-card button { background: var(--accent-surface); color: var(--accent-text); }
.learning-card.progress-card button:hover { background: var(--accent-hover-surface); }

.learning-card .card-label {
  margin-bottom: 8px;
  font-size: 10px;
  letter-spacing: 1px;
}

.learning-card h2 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

.card-description {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.learning-card button {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding: 0 15px;
  border: 0;
  border-radius: 11px;
  background: #5964dc;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease, transform 150ms ease;
}

.learning-card button:hover {
  transform: translateY(-1px);
  background: #4652ca;
}

.learning-card button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.progress-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  margin: -5px 0 8px;
  border-radius: 99px;
  background: var(--progress-track);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #39b887;
}

.progress-caption {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 800px) {
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .dashboard {
    width: min(100% - 32px, 420px);
    padding: 20px 0 40px;
  }

  .page-header {
    padding-bottom: 20px;
  }

  .welcome {
    padding: 34px 0 25px;
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .learning-card {
    min-height: 0;
    padding: 22px;
  }

  .card-icon {
    margin-bottom: 18px;
  }

  .learning-card button {
    margin-top: 4px;
  }
}

/* Onboarding shares the dashboard's palette, rounded cards and spacing. */
[hidden] { display: none !important; }
.page-header .profile { margin-left: 0; }
.onboarding { max-width: 760px; margin: 40px auto 0; }
.auth-screen { max-width: 600px; margin: 40px auto 0; }
.home-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.setup-progress { display: flex; align-items: center; gap: 20px; margin: 18px 0; color: var(--muted); font-size: 12px; }
.setup-progress progress { flex: 1; width: 100%; height: 7px; border: 0; border-radius: 99px; overflow: hidden; background: var(--divider); accent-color: #5964dc; }
.setup-progress progress::-webkit-progress-bar { background: var(--divider); }
.setup-progress progress::-webkit-progress-value { background: #5964dc; border-radius: 99px; }
.setup-progress progress::-moz-progress-bar { background: #5964dc; }
#step-label { white-space: nowrap; }
.setup-card { padding: 32px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: 0 8px 24px rgb(35 46 82 / 4%); }
.setup-card h2 { margin: 0 0 12px; font-size: clamp(23px, 3.5vw, 30px); line-height: 1.4; letter-spacing: -.7px; font-weight: 600; }
.step-description { color: var(--muted); font-size: 14px; line-height: 1.7; margin: 0 0 24px; }
.step-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.setup-option { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 14px; border: 1px solid var(--option-border); border-radius: 12px; background: var(--surface); color: var(--text); font-size: 13px; text-align: left; cursor: pointer; }
.setup-option::before { content: ''; width: 18px; height: 18px; flex: 0 0 18px; border: 1px solid var(--control-border); border-radius: 50%; }
.step-options.multiple .setup-option::before { border-radius: 5px; }
.setup-option:hover { background: var(--canvas); border-color: #5964dc; }
.setup-option[aria-pressed="true"] { border-color: #5964dc; background: var(--accent-surface); color: var(--selected-text); }
.setup-option[aria-pressed="true"]::before { content: '✓'; display: grid; place-items: center; background: #5964dc; color: #fff; border-color: #5964dc; font-size: 12px; }
.selection-count { min-height: 22px; margin: 16px 0 0; color: var(--accent-text); font-size: 12px; }
.setup-navigation { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid var(--border); margin-top: 24px; padding-top: 22px; }
.setup-primary, .setup-back, .google-button { min-height: 46px; border: 0; border-radius: 11px; padding: 12px 22px; font: inherit; font-size: 13px; cursor: pointer;}
.setup-primary { background: #5964dc; color: #fff; margin-top:20px;}
.setup-primary:hover:not(:disabled) { background: #4652ca; }
.setup-back { background: var(--accent-surface); color: var(--accent-text); }
.setup-card button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
#account-form, #login-form { max-width: 440px; margin: 0 auto; }
#account-form label, #login-form label { display: block; margin: 16px 0 6px; font-size: 12px; }
#account-form input, #login-form input { width: 100%; min-height: 48px; border: 1px solid var(--input-border); border-radius: 11px; padding: 12px; font: inherit; font-size: 16px; color: var(--text); background: var(--canvas); }
#account-form .setup-primary, #login-form .setup-primary { width: 100%; margin-top: 24px; }
.google-button { width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--input-border); }
.account-divider, .prototype-note, #account-status, #login-status, #startup-status { font-size: 12px; line-height: 1.7; color: var(--muted); text-align: center; }

@media (max-width: 560px) {
  .onboarding, .auth-screen { margin-top: 28px; }
  .setup-card { padding: 22px 18px; }
  .step-options { grid-template-columns: 1fr; }
  .page-header { gap: 8px; }
  .page-header .profile { display: grid; }
}





#placement .step-options { display: grid; gap: 12px; margin: 24px 0; }
.placement-recommended { display: block; font-size: .8em; color: var(--accent-text); margin-top: 4px; }
.placement-question audio { max-width: 100%; }

#level-completion-actions .certificate-button { background: transparent; color: var(--accent-text); margin-top: 10px; border: 1px solid var(--accent-border); }
#level-completion-status { font-size: 13px; line-height: 1.6; }
#level-completion-actions { margin-top: auto; }
.next-card button:disabled { opacity: .6; cursor: wait; }

.account-menu a { display:block; padding:10px 14px; color:var(--text); text-decoration:none; font-size:13px; border-radius:8px; }
.account-menu a[hidden] { display:none; }
.account-menu a:hover { background:var(--accent-surface); }
.language-options { display:flex; gap:4px; }
.language-options button { text-align:center; }
.language-options button[aria-pressed="true"] { background:var(--selected-surface); color:var(--accent-text); font-weight:600; }
.account-menu { max-width:calc(100vw - 40px); }

