:root {
  color-scheme: light;
  --ink: #142334;
  --muted: #526273;
  --paper: #f6f3eb;
  --surface: #fffefd;
  --surface-soft: #eef4f2;
  --navy: #173b57;
  --navy-dark: #0d2b42;
  --blue: #28799c;
  --leaf: #2d765f;
  --leaf-soft: #dcefe6;
  --sun: #f0bd43;
  --sun-soft: #fff1bd;
  --coral: #ce5e52;
  --coral-soft: #f9e2dc;
  --violet: #6b62a8;
  --line: #cbd5d8;
  --line-strong: #a8b8bd;
  --focus: #006fba;
  --shadow: 0 18px 50px rgba(23, 59, 87, 0.12);
  --shadow-small: 0 8px 24px rgba(23, 59, 87, 0.1);
  --radius-large: 24px;
  --radius: 16px;
  --radius-small: 11px;
  font-family: Verdana, "Trebuchet MS", Arial, sans-serif;
  font-size: 16px;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(240, 189, 67, 0.2) 0 7rem, transparent 7.1rem),
    radial-gradient(circle at 96% 24%, rgba(40, 121, 156, 0.12) 0 10rem, transparent 10.1rem),
    var(--paper);
  line-height: 1.55;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--navy);
}

:focus-visible {
  outline: 4px solid #168bd2;
  outline: 4px solid color-mix(in srgb, var(--focus) 78%, white);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar,
.app,
.site-footer {
  width: min(1120px, calc(100% - 28px));
  margin-inline: auto;
}

.topbar {
  min-height: 82px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
}

.home-link {
  display: none;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
}

.home-link:hover {
  color: var(--navy);
}

.home-link-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--navy);
  border-radius: 9px;
  font-size: 1rem;
  line-height: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 42px;
  height: 40px;
  display: inline-block;
  transform: rotate(-3deg);
}

.brand-mark span {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 22px;
  background: var(--sun);
  border: 3px solid var(--navy);
}

.brand-mark span:first-child {
  left: 1px;
  border-radius: 8px 3px 3px 8px;
}

.brand-mark span:last-child {
  right: 1px;
  border-radius: 3px 8px 8px 3px;
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: calc(50% - 1px);
  width: 2px;
  background: var(--navy);
}

.brand-words {
  display: grid;
  line-height: 1.02;
}

.brand-words strong {
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.brand-words small {
  margin-top: 4px;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.mode-button {
  min-height: 48px;
  padding: 8px 14px;
  color: var(--navy);
  background: rgba(255, 254, 253, 0.9);
  border: 2px solid var(--navy);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 800;
}

.mode-button:hover {
  color: white;
  background: var(--navy);
}

.mode-button.is-parent {
  color: #fff;
  background: var(--navy);
}

.mode-button.is-parent:hover {
  background: var(--navy-dark);
}

.app {
  display: block;
  padding: 28px 0 64px;
}

.site-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 24px 0 30px;
  color: var(--muted);
  border-top: 1px solid rgba(168, 184, 189, 0.7);
  font-size: 0.78rem;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.hero {
  display: grid;
  gap: 22px;
  margin-bottom: 34px;
}

.hero-copy {
  max-width: 760px;
}

.hero h1,
.view-header h1,
.session-heading h1,
.summary-card h1 {
  margin: 0;
  color: var(--navy-dark);
  font-size: clamp(2rem, 9vw, 4.25rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.hero p:not(.eyebrow),
.view-header p,
.session-heading p,
.summary-card > p {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 3.5vw, 1.15rem);
  line-height: 1.65;
}

.hero-actions,
.toolbar,
.dialog-actions,
.session-actions,
.speech-actions,
.voice-actions,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  color: var(--navy);
  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: 13px;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  transition: transform 130ms ease, box-shadow 130ms ease, background 130ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-small);
}

.button-primary {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.button-primary:hover:not(:disabled) {
  background: var(--navy-dark);
  border-color: var(--navy-dark);
}

.button-sun {
  color: var(--navy-dark);
  background: var(--sun);
  border-color: #d49c16;
}

.button-gentle {
  color: #174f3f;
  background: var(--leaf-soft);
  border-color: #77a994;
}

.button-danger {
  color: #8c2d28;
  background: #fff8f6;
  border-color: #d98f87;
}

.button-danger:hover:not(:disabled) {
  color: #fff;
  background: #a63d35;
  border-color: #a63d35;
}

.button-quiet {
  min-height: 46px;
  padding: 8px 13px;
  background: transparent;
  border-color: transparent;
  font-size: 0.91rem;
}

.button-small {
  min-height: 44px;
  padding: 8px 13px;
  font-size: 0.9rem;
}

.button-wide {
  width: 100%;
}

.button:disabled {
  color: #67747c;
  background: #e4e8e7;
  border-color: #c5cdcf;
  opacity: 0.76;
  box-shadow: none;
  transform: none;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 16px;
}

.section-heading h2,
.panel h2,
.card-list-heading h2 {
  margin: 0;
  color: var(--navy-dark);
  font-size: clamp(1.35rem, 5vw, 1.8rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.section-heading p,
.panel-heading-copy,
.card-list-heading p {
  margin: 5px 0 0;
  color: var(--muted);
}

.deck-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.deck-tile {
  --deck-accent: var(--blue);
  position: relative;
  min-width: 0;
  display: grid;
  gap: 20px;
  padding: 24px;
  overflow: hidden;
  background: rgba(255, 254, 253, 0.96);
  border: 2px solid var(--line);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-small);
}

.deck-tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
  background: var(--deck-accent);
}

.theme-sky { --deck-accent: #247da0; }
.theme-leaf { --deck-accent: #2d765f; }
.theme-sun { --deck-accent: #c98b0b; }
.theme-coral { --deck-accent: #c4554b; }
.theme-violet { --deck-accent: #6b62a8; }

.deck-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.deck-title {
  min-width: 0;
}

.deck-title h3 {
  margin: 0;
  color: var(--navy-dark);
  font-size: clamp(1.25rem, 5vw, 1.55rem);
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.deck-title p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.mastery-badge {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 64px;
  display: grid;
  place-items: center;
  padding: 8px;
  color: var(--navy-dark);
  background: var(--sun-soft);
  border: 2px solid #e4bd59;
  border-radius: 50%;
  font-size: 0.93rem;
  font-weight: 900;
}

.progress-block {
  display: grid;
  gap: 8px;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
}

.progress-track {
  height: 13px;
  overflow: hidden;
  background: #e2e8e7;
  border: 1px solid #ccd6d6;
  border-radius: 999px;
}

.progress-fill {
  height: 100%;
  width: var(--progress, 0%);
  background: var(--deck-accent, var(--leaf));
  border-radius: inherit;
  transition: width 220ms ease;
}

.deck-stats,
.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px;
  color: #344657;
  background: #edf2f2;
  border: 1px solid #d5dede;
  border-radius: 999px;
  font-size: 0.79rem;
  font-weight: 700;
}

.stat-chip.needs-review {
  color: #74342e;
  background: var(--coral-soft);
  border-color: #ebb0a8;
}

.deck-action {
  align-self: end;
}

.empty-state {
  padding: clamp(28px, 8vw, 52px);
  text-align: center;
  background: rgba(255, 254, 253, 0.85);
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-large);
}

.empty-state-mark {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  color: var(--navy-dark);
  background: var(--sun-soft);
  border: 2px solid #e4bd59;
  border-radius: 22px;
  font-size: 2rem;
  font-weight: 900;
}

.empty-state h2,
.empty-state h3 {
  margin: 0;
  color: var(--navy-dark);
  font-size: 1.45rem;
}

.empty-state p {
  max-width: 560px;
  margin: 10px auto 20px;
  color: var(--muted);
}

.parent-tools {
  margin: 0 0 30px;
  padding: 20px;
  background: rgba(255, 254, 253, 0.82);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}

.parent-tools .toolbar {
  margin-top: 14px;
}

.parent-note,
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 13px 15px;
  color: #3f5363;
  background: #e9f2f6;
  border: 1px solid #bdd5e0;
  border-radius: 12px;
  font-size: 0.88rem;
}

.notice-warning {
  color: #694b16;
  background: #fff4cc;
  border-color: #e7c96c;
}

.notice-success {
  color: #215c49;
  background: var(--leaf-soft);
  border-color: #9cc7b6;
}

.notice-danger {
  color: #773832;
  background: var(--coral-soft);
  border-color: #e7a49d;
}

.back-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 20px;
  padding: 7px 11px;
  color: var(--navy);
  background: transparent;
  border: 0;
  border-radius: 10px;
  font-weight: 800;
}

.back-button::before {
  content: "←";
  font-size: 1.25rem;
}

.back-button:hover {
  background: rgba(255, 255, 255, 0.76);
}

.view-header {
  display: grid;
  gap: 20px;
  margin-bottom: 28px;
  padding: clamp(22px, 6vw, 38px);
  background: rgba(255, 254, 253, 0.92);
  border: 2px solid var(--line);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-small);
}

.view-header h1 {
  font-size: clamp(2rem, 8vw, 3.6rem);
  overflow-wrap: anywhere;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.summary-stat {
  min-width: 0;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid #cedbd7;
  border-radius: 13px;
}

.summary-stat strong {
  display: block;
  color: var(--navy-dark);
  font-size: 1.45rem;
  line-height: 1.1;
}

.summary-stat span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.study-mode-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.study-mode-card {
  position: relative;
  min-height: 180px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding: 22px;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-small);
  text-align: left;
}

.study-mode-card:hover:not(:disabled) {
  border-color: var(--blue);
  transform: translateY(-2px);
}

.study-mode-card:disabled {
  color: #667279;
  background: #ecefee;
  box-shadow: none;
}

.study-mode-number {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--navy);
  border-radius: 13px;
  font-size: 1.05rem;
  font-weight: 900;
}

.study-mode-card:nth-child(2) .study-mode-number { background: var(--leaf); }
.study-mode-card:nth-child(3) .study-mode-number { background: var(--violet); }
.study-mode-card:nth-child(4) .study-mode-number { background: var(--coral); }

.study-mode-title {
  display: block;
  margin: 0;
  color: var(--navy-dark);
  font-size: 1.25rem;
  font-weight: 800;
}

.study-mode-description {
  display: block;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.study-mode-card strong:last-child {
  color: var(--navy);
  font-size: 0.88rem;
}

.manage-toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 28px;
  padding: 18px;
  background: rgba(255, 254, 253, 0.9);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}

.manage-toolbar .toolbar .button {
  flex: 1 1 150px;
}

.card-list-heading {
  margin-bottom: 15px;
}

.card-list {
  display: grid;
  gap: 14px;
}

.manage-card {
  padding: 20px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-small);
}

.manage-card-main {
  display: grid;
  gap: 16px;
}

.card-side {
  display: grid;
  gap: 6px;
}

.card-side-label {
  color: var(--blue);
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.card-side p {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.card-divider {
  height: 2px;
  background: #e2e8e7;
  border: 0;
}

.card-progress {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.card-mastery-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.card-mastery-row .progress-track {
  height: 10px;
}

.card-actions {
  margin-top: 16px;
}

.session-shell {
  max-width: 900px;
  margin-inline: auto;
}

.session-topbar {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.session-heading {
  margin-bottom: 16px;
}

.session-heading h1 {
  font-size: clamp(1.8rem, 7vw, 3rem);
}

.session-count {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.session-card {
  min-height: 390px;
  display: grid;
  align-content: center;
  gap: 22px;
  padding: clamp(22px, 7vw, 54px);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: clamp(20px, 5vw, 32px);
  box-shadow: var(--shadow);
}

.question-label,
.answer-label {
  margin: 0;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.question-text,
.answer-text {
  margin: 7px 0 0;
  color: var(--navy-dark);
  font-size: clamp(1.55rem, 7vw, 2.8rem);
  font-weight: 800;
  line-height: 1.27;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.answer-text {
  color: #1f624f;
  font-size: clamp(1.4rem, 6vw, 2.35rem);
}

.flashcard-button {
  width: 100%;
  min-height: 315px;
  display: grid;
  align-content: center;
  gap: 24px;
  padding: clamp(20px, 6vw, 44px);
  color: var(--ink);
  background: linear-gradient(145deg, #fffefd, #f5f9f7);
  border: 3px solid var(--navy);
  border-radius: 22px;
  text-align: left;
}

.flashcard-button:hover {
  background: #fff;
  box-shadow: var(--shadow-small);
}

.tap-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  justify-self: start;
  padding: 8px 14px;
  color: var(--navy);
  background: var(--sun-soft);
  border: 1px solid #e5c66b;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
}

.answer-panel,
.response-panel {
  padding: 20px;
  background: var(--leaf-soft);
  border: 2px solid #8ebca9;
  border-radius: 16px;
}

.response-panel {
  background: #eef3f6;
  border-color: #bfd0d8;
}

.response-panel p:last-child {
  margin: 8px 0 0;
  font-size: 1.13rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.speech-actions {
  gap: 8px;
}

.speech-actions .button {
  flex: 1 1 135px;
}

.self-mark {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.self-mark > p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.self-mark .session-actions {
  display: grid;
  grid-template-columns: 1fr;
}

.typed-form {
  display: grid;
  gap: 13px;
}

.typed-form label {
  color: var(--navy-dark);
  font-size: 1rem;
  font-weight: 800;
}

.typed-answer {
  width: 100%;
  min-height: 120px;
  padding: 16px;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--line-strong);
  border-radius: 14px;
  font-size: 1.2rem;
  line-height: 1.55;
  resize: vertical;
}

.typed-answer:focus {
  border-color: var(--focus);
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.choice-button {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--line-strong);
  border-radius: 15px;
  font-size: 1.05rem;
  font-weight: 800;
  text-align: left;
}

.choice-button:hover:not(:disabled) {
  border-color: var(--blue);
  background: #f3f8fa;
}

.choice-letter {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--navy);
  border-radius: 10px;
  font-size: 0.9rem;
}

.choice-button.is-correct {
  color: #174f3f;
  background: var(--leaf-soft);
  border-color: var(--leaf);
}

.choice-button.is-correct .choice-letter {
  background: var(--leaf);
}

.choice-button.is-wrong {
  color: #74342e;
  background: var(--coral-soft);
  border-color: var(--coral);
}

.choice-button.is-wrong .choice-letter {
  background: var(--coral);
}

.choice-button:disabled {
  opacity: 1;
  cursor: default;
}

.feedback {
  padding: 17px;
  border: 2px solid;
  border-radius: 15px;
}

.feedback h2 {
  margin: 0;
  font-size: 1.25rem;
}

.feedback p {
  margin: 7px 0 0;
}

.feedback-correct {
  color: #174f3f;
  background: var(--leaf-soft);
  border-color: var(--leaf);
}

.feedback-missed {
  color: #74342e;
  background: var(--coral-soft);
  border-color: var(--coral);
}

.summary-card {
  max-width: 760px;
  margin: 28px auto;
  padding: clamp(26px, 8vw, 56px);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.summary-mark {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  color: var(--navy-dark);
  background: var(--sun);
  border: 3px solid var(--navy);
  border-radius: 26px;
  font-size: 2.3rem;
  font-weight: 900;
  transform: rotate(-3deg);
}

.summary-card h1 {
  font-size: clamp(2rem, 8vw, 3.6rem);
}

.session-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 26px 0;
}

.result-stat {
  padding: 16px 8px;
  background: var(--surface-soft);
  border: 1px solid #cedbd7;
  border-radius: 14px;
}

.result-stat strong {
  display: block;
  color: var(--navy-dark);
  font-size: clamp(1.4rem, 6vw, 2.15rem);
  line-height: 1.1;
}

.result-stat span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
}

.summary-card .session-actions {
  justify-content: center;
}

.app-dialog {
  width: min(690px, calc(100% - 22px));
  max-height: min(88vh, 900px);
  margin: auto;
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-radius: 22px;
  box-shadow: 0 28px 90px rgba(10, 33, 51, 0.35);
}

.app-dialog::backdrop {
  background: rgba(10, 33, 51, 0.7);
  backdrop-filter: blur(3px);
}

.dialog-shell {
  padding: clamp(22px, 6vw, 36px);
}

.dialog-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
  margin-bottom: 22px;
}

.dialog-header h2 {
  margin: 0;
  color: var(--navy-dark);
  font-size: clamp(1.55rem, 6vw, 2rem);
  line-height: 1.18;
  letter-spacing: -0.03em;
}

.dialog-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.dialog-close {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--navy);
  background: #edf2f2;
  border: 2px solid var(--line);
  border-radius: 13px;
  font-size: 1.35rem;
  font-weight: 900;
}

.dialog-form {
  display: grid;
  gap: 20px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.field-label {
  color: var(--navy-dark);
  font-size: 0.95rem;
  font-weight: 900;
}

.field-help {
  margin: -3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.text-input,
.text-area,
.pin-input {
  width: 100%;
  min-height: 56px;
  padding: 13px 15px;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--line-strong);
  border-radius: 13px;
  font-size: 1.05rem;
  line-height: 1.45;
}

.text-input:focus,
.text-area:focus,
.pin-input:focus {
  border-color: var(--focus);
}

.text-area {
  min-height: 120px;
  resize: vertical;
}

.pin-input {
  max-width: 250px;
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-align: center;
}

.field-error {
  min-height: 1.4em;
  margin: 0;
  color: #9b332c;
  font-size: 0.85rem;
  font-weight: 800;
}

.color-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-option {
  position: relative;
}

.color-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.color-swatch {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 4px solid #fff;
  border-radius: 15px;
  box-shadow: 0 0 0 2px var(--line-strong);
}

.color-option input:checked + .color-swatch {
  box-shadow: 0 0 0 4px var(--navy);
}

.color-option input:focus-visible + .color-swatch {
  outline: 4px solid var(--focus);
  outline-offset: 4px;
}

.swatch-sky { background: #247da0; }
.swatch-leaf { background: #2d765f; }
.swatch-sun { background: #c98b0b; }
.swatch-coral { background: #c4554b; }
.swatch-violet { background: #6b62a8; }

.voice-helper {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: #edf4f7;
  border: 2px solid #bfd3dc;
  border-radius: 16px;
}

.voice-helper h3 {
  margin: 0;
  color: var(--navy-dark);
  font-size: 1.1rem;
}

.voice-helper p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.voice-status {
  min-height: 66px;
  padding: 12px;
  color: #354a59;
  background: #fff;
  border: 2px dashed #9eb5bf;
  border-radius: 12px;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.voice-status.is-listening {
  color: #8b2f29;
  background: #fff6f4;
  border-color: var(--coral);
}

.voice-status strong {
  display: block;
  margin-bottom: 3px;
  color: inherit;
}

.voice-actions .button {
  flex: 1 1 170px;
}

.voice-review-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dialog-actions {
  justify-content: flex-end;
  padding-top: 4px;
}

.dialog-actions .button {
  flex: 1 1 150px;
}

.danger-copy {
  padding: 15px;
  color: #6c332e;
  background: var(--coral-soft);
  border: 1px solid #e5a19a;
  border-radius: 12px;
}

.danger-copy p {
  margin: 0;
}

.toast {
  position: fixed;
  z-index: 1000;
  right: 14px;
  bottom: 14px;
  left: 14px;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 13px 18px;
  color: #fff;
  background: var(--navy-dark);
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(10, 33, 51, 0.32);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  background: #8f342e;
}

.noscript {
  position: fixed;
  z-index: 2000;
  inset: 18px;
  display: grid;
  place-content: center;
  padding: 30px;
  color: var(--ink);
  background: var(--surface);
  border: 3px solid var(--navy);
  border-radius: 20px;
  text-align: center;
}

.noscript h1 {
  margin: 0;
}

.noscript p {
  max-width: 540px;
}

@media (min-width: 540px) {
  .topbar {
    grid-template-columns: 1fr auto 1fr;
  }

  .home-link {
    display: inline-flex;
    justify-self: start;
  }

  .brand {
    justify-self: center;
  }

  .mode-button {
    justify-self: end;
  }

  .site-footer {
    flex-direction: row;
    justify-content: space-between;
  }

  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .self-mark .session-actions {
    grid-template-columns: 1fr 1fr;
  }

  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toast {
    right: 24px;
    bottom: 24px;
    left: auto;
    width: min(390px, calc(100% - 48px));
  }
}

@media (min-width: 720px) {
  .topbar,
  .app,
  .site-footer {
    width: min(1120px, calc(100% - 52px));
  }

  .app {
    padding-top: 48px;
  }

  .hero {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .deck-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .view-header {
    grid-template-columns: 1fr minmax(310px, 0.65fr);
    align-items: center;
  }

  .study-mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .manage-toolbar {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .manage-toolbar .toolbar .button {
    flex: 0 1 auto;
  }

  .manage-card-main {
    grid-template-columns: 1fr 1fr;
  }

  .card-divider {
    width: 2px;
    height: auto;
    display: none;
  }

  .session-topbar {
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  .session-topbar .back-button {
    margin: 0;
  }
}

@media (min-width: 980px) {
  .deck-grid.deck-grid-wide {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .study-mode-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  .topbar,
  .site-footer,
  .mode-button,
  .button,
  .back-button {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .app {
    width: 100%;
  }
}
