:root {
  color-scheme: light;
  --navy: #173d6b;
  --navy-deep: #102d51;
  --blue: #2e4fac;
  --sky: #eaf4fb;
  --yellow: #ffdc31;
  --red: #f44761;
  --coral: #e85c4a;
  --brand-brown: #231916;
  --ink: #19324f;
  --muted: #66768a;
  --paper: #fffdf7;
  --line: #dce7f0;
  --shadow: 0 18px 45px rgba(23, 61, 107, .13);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 220, 49, .22), transparent 28%),
    radial-gradient(circle at 92% 22%, rgba(75, 159, 215, .18), transparent 28%),
    #f4f8f4;
}

button, input { font: inherit; }
button { cursor: pointer; }

.site-header {
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 20px 8px;
}

.site-header .brand-copy { display: grid; gap: 2px; }
.site-header strong { color: var(--brand-brown); font-size: 16px; }
.site-header span { color: var(--muted); font-size: 12px; }

.brand-mark {
  width: 52px;
  height: auto;
  flex: 0 0 auto;
}

.page-shell {
  width: min(100% - 28px, 780px);
  margin: 20px auto 120px;
}

.status-card,
.gate-card,
.login-card {
  width: min(100%, 480px);
  margin: 9vh auto 0;
  padding: 34px 28px;
  text-align: center;
  border: 1px solid rgba(23, 61, 107, .09);
  border-radius: 28px;
  background: rgba(255, 253, 247, .96);
  box-shadow: var(--shadow);
}

.status-card { color: var(--muted); }
.loading-dot {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 4px solid #dce7f0;
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.lock-mark {
  display: grid;
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 22px;
  background: #edf5fb;
  font-size: 31px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .11em;
}

h1, h2, h3, p { margin-top: 0; }
.gate-card h1,
.login-card h1 { margin-bottom: 12px; color: var(--navy); font-size: 28px; }
.gate-copy { margin-bottom: 24px; color: var(--muted); line-height: 1.65; }

.stack-form { display: grid; gap: 11px; text-align: left; }
.stack-form label { color: var(--navy); font-size: 14px; font-weight: 800; }
.stack-form input,
.stack-form select {
  width: 100%;
  padding: 15px 16px;
  border: 2px solid #d4e1eb;
  border-radius: 14px;
  outline: none;
  color: var(--navy-deep);
  background: white;
  font-size: 17px;
}
.stack-form input:focus,
.stack-form select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(46, 79, 172, .1); }
#register-code,
#recover-code {
  letter-spacing: .04em;
  text-transform: uppercase;
}

.primary-button {
  min-height: 50px;
  padding: 12px 18px;
  border: 0;
  border-radius: 14px;
  color: white;
  background: var(--navy);
  box-shadow: 0 8px 18px rgba(23, 61, 107, .18);
  font-weight: 800;
}
.primary-button:hover { background: var(--navy-deep); }
button:disabled { cursor: wait; opacity: .6; }
.form-error { min-height: 20px; margin: 0; color: #b83448; font-size: 13px; text-align: center; }
.privacy-note { margin: 16px 0 0; color: #8491a1; font-size: 12px; }

.demo-banner {
  margin: -12px -6px 24px;
  padding: 10px 12px;
  border-radius: 12px;
  color: #694f00;
  background: #fff3b4;
  font-size: 12px;
  line-height: 1.45;
}
.login-copy { margin-bottom: 22px; color: var(--muted); line-height: 1.6; }
.login-panel { text-align: center; }
.form-switches { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px 14px; margin-top: 5px; }
.secondary-button,
.danger-button {
  min-height: 46px;
  padding: 11px 16px;
  border-radius: 13px;
  font-weight: 800;
}
.secondary-button { border: 1px solid #b9cbe0; color: var(--navy); background: white; }
.danger-button { border: 1px solid #efb9c1; color: #b83448; background: #fff8f9; }
.centered { justify-self: center; }
.sent-note { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.demo-code { margin: 0; padding: 9px 11px; border-radius: 10px; color: #694f00; background: #fff3b4; font-size: 14px; text-align: center; font-weight: 800; }
.signed-account { margin: -8px 0 18px; padding: 10px 12px; border-radius: 12px; color: var(--navy); background: #edf5fb; font-size: 13px; font-weight: 800; }
.account-entry { margin-top: 8px; }

.lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 2px 2px 14px;
}
.lesson-actions { display: flex; gap: 8px; align-items: center; }
.lesson-header h1 { margin: 0; color: var(--navy); font-size: clamp(25px, 7vw, 38px); }
.text-button { border: 0; color: var(--muted); background: transparent; font-size: 13px; }
.account-button {
  min-width: 58px;
  min-height: 40px;
  border: 1px solid #c6d6e4;
  border-radius: 13px;
  color: var(--navy);
  background: rgba(255, 255, 255, .76);
  font-weight: 800;
}
.catalog-button {
  display: grid;
  min-height: 40px;
  padding: 0 13px;
  place-items: center;
  border: 1px solid #c6d6e4;
  border-radius: 13px;
  color: var(--navy);
  background: rgba(255, 255, 255, .76);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.catalog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 24px;
  border-radius: 26px;
  color: white;
  background: var(--navy);
  box-shadow: var(--shadow);
}
.catalog-header .eyebrow { color: var(--yellow); }
.catalog-header h1 { margin-bottom: 7px; font-size: clamp(28px, 7vw, 42px); }
.catalog-header p:last-child { margin-bottom: 0; color: #c9d9e9; line-height: 1.55; }
.catalog-header .account-button { color: var(--navy); background: white; }
.lesson-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.lesson-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 8px 24px rgba(23, 61, 107, .07);
}
.lesson-number {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-weight: 900;
}
.lesson-card.color-0 .lesson-number { background: var(--red); }
.lesson-card.color-1 .lesson-number { color: var(--navy-deep); background: var(--yellow); }
.lesson-card.color-2 .lesson-number { background: var(--blue); }
.lesson-card p { margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.lesson-card h2 { margin-bottom: 12px; color: var(--navy); font-size: 18px; }
.lesson-card-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lesson-card-actions a {
  padding: 10px 8px;
  border-radius: 11px;
  color: white;
  background: var(--navy);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}
.lesson-card-actions a:last-child { color: var(--navy); background: #e7f0f7; }

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
  padding: 6px;
  border-radius: 17px;
  background: #dfeaf2;
}
.mode-tabs button {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  color: #60748a;
  background: transparent;
  font-weight: 800;
}
.mode-tabs button.active { color: white; background: var(--navy); box-shadow: 0 6px 14px rgba(23, 61, 107, .2); }

.review-card {
  overflow: hidden;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.review-card img,
.qa-grid { display: block; width: 100%; height: auto; background: #dbe9f6; }
.review-body { padding: 25px; }
.review-body h2 { margin-bottom: 8px; color: var(--navy); }
.review-body > p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }
.play-large { width: 100%; margin-top: 6px; background: var(--coral); }
.play-large:hover { background: #cb4838; }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 25px 2px 15px;
}
.section-heading h2 { margin: 0; color: var(--navy); }
.section-heading > p { max-width: 250px; margin-bottom: 2px; color: var(--muted); font-size: 13px; text-align: right; }
.qa-grid { margin-bottom: 16px; border-radius: 22px; box-shadow: var(--shadow); }
.picture-list { display: grid; gap: 14px; }

.picture-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 8px 24px rgba(23, 61, 107, .07);
}
.picture-card h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--navy);
  font-size: 15px;
  text-transform: capitalize;
}
.picture-card h3 span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-size: 13px;
}
.color-0 h3 span { background: var(--red); }
.color-1 h3 span { color: var(--navy-deep); background: var(--yellow); }
.color-2 h3 span { background: var(--blue); }

.qa-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 15px 16px;
}
.qa-row + .qa-row { border-top: 1px dashed #dbe5ed; }
.qa-number { color: var(--muted); font-size: 13px; font-weight: 900; }
.qa-copy { min-width: 0; }
.qa-copy p { line-height: 1.45; }
.question-copy { margin-bottom: 7px; color: var(--navy); font-weight: 750; }
.answer-copy { margin-bottom: 0; color: var(--coral); font-size: 14px; }
.qa-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.audio-button {
  min-width: 49px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid;
  border-radius: 11px;
  background: white;
  font-size: 13px;
  font-weight: 900;
}
.audio-q { border-color: #b9cae6; color: var(--navy); }
.audio-a { border-color: #f1c0b9; color: var(--coral); }
.audio-button.is-playing { color: white; background: var(--navy); border-color: var(--navy); }

.account-dialog {
  width: min(calc(100% - 24px), 520px);
  max-height: min(88vh, 760px);
  padding: 24px;
  overflow: auto;
  border: 0;
  border-radius: 24px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 28px 80px rgba(10, 34, 63, .3);
  overflow-y: auto;
}
.account-dialog::backdrop { background: rgba(10, 34, 63, .55); backdrop-filter: blur(4px); }
.dialog-header { display: flex; justify-content: space-between; gap: 18px; }
.dialog-header h2 { margin-bottom: 17px; color: var(--navy); }
.dialog-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: #eaf1f6;
  font-size: 24px;
}
.identity-list { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; }
.identity-row { display: flex; justify-content: space-between; gap: 20px; padding: 13px 15px; font-size: 14px; }
.identity-row + .identity-row { border-top: 1px solid var(--line); }
.identity-row span { color: var(--muted); }
.identity-row strong { color: var(--navy); text-align: right; }
.family-management { margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.family-management h3 { margin-bottom: 10px; color: var(--navy); font-size: 16px; }
.family-list { overflow: hidden; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.family-row { display: flex; justify-content: space-between; gap: 18px; padding: 10px 12px; font-size: 13px; }
.family-row + .family-row { border-top: 1px solid var(--line); }
.family-row strong { color: var(--navy); }
.family-row span { color: var(--muted); }
.compact-form { margin-top: 13px; padding: 13px; border-radius: 13px; background: #edf5fb; }
.session-note { margin: 17px 1px 13px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.account-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.audio-dock {
  position: fixed;
  z-index: 10;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 12px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(210px, 1.5fr);
  gap: 14px;
  align-items: center;
  width: min(calc(100% - 24px), 760px);
  margin: auto;
  padding: 12px 15px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 18px;
  color: white;
  background: rgba(16, 45, 81, .97);
  box-shadow: 0 16px 40px rgba(16, 45, 81, .34);
  backdrop-filter: blur(14px);
}
.audio-dock div { min-width: 0; }
.audio-dock span { display: block; margin-bottom: 3px; color: #bbcee3; font-size: 11px; }
.audio-dock strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.audio-dock audio { width: 100%; height: 38px; }

@media (max-width: 620px) {
  .page-shell { width: min(100% - 20px, 780px); margin-top: 10px; }
  .gate-card,
  .login-card { margin-top: 4vh; padding: 28px 20px; }
  .lesson-header { align-items: start; }
  .lesson-actions { flex-direction: column; align-items: stretch; }
  .catalog-header { padding: 21px 18px; }
  .lesson-list { grid-template-columns: 1fr; }
  .section-heading { display: block; }
  .section-heading > p { max-width: none; text-align: left; }
  .qa-row { grid-template-columns: 20px minmax(0, 1fr); }
  .qa-actions { grid-column: 2; justify-self: start; }
  .audio-dock { grid-template-columns: 1fr; gap: 8px; }
  .account-dialog { padding: 20px; }
  .account-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .loading-dot { animation-duration: 1.6s; }
}
