:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f5f2ed;
  --surface: #ffffff;
  --surface-2: #f3f0eb;
  --surface-3: #e8e4de;
  --text: #1b1a18;
  --muted: #716d68;
  --accent: #cf3030;
  --accent-text: #ffffff;
  --mint: #1b1a18;
  --yellow: #5e5954;
  --red: #cf3030;
  --line: rgba(27, 26, 24, .12);
  --shadow: 0 18px 50px rgba(52, 43, 34, .1);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 8% -10%, rgba(207, 48, 48, .09), transparent 32%),
    radial-gradient(circle at 98% 5%, rgba(255, 255, 255, .8), transparent 28%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  background: rgba(245, 242, 237, .9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  background: var(--accent);
  border-radius: 13px;
  box-shadow: 0 8px 25px rgba(207, 48, 48, .18);
  color: var(--accent-text);
  font-size: 21px;
  font-weight: 900;
}

.brand b,
.brand small {
  display: block;
}

.brand b {
  font-size: 16px;
  letter-spacing: .12em;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .2em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.streak-pill,
.avatar {
  min-height: 40px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .95);
}

.streak-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 13px;
  border-radius: 13px;
}

.avatar {
  width: 40px;
  padding: 0;
  border-radius: 50%;
  color: var(--accent);
  font-weight: 900;
}

main {
  padding: 16px 16px 32px;
}

.view {
  display: none;
  animation: view-in .2s ease both;
}

.view.is-active {
  display: block;
}

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

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 2px 18px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .17em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 7px;
  font-size: clamp(28px, 7vw, 40px);
  line-height: 1.05;
  letter-spacing: -.035em;
}

h2 {
  margin-bottom: 14px;
  font-size: 19px;
  letter-spacing: -.015em;
}

h3 {
  margin-bottom: 5px;
  font-size: 16px;
}

p {
  color: var(--muted);
  line-height: 1.45;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 2px 12px;
}

.section-head h2,
.section-head p {
  margin: 0;
}

.text-button {
  padding: 5px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.panel,
.hero-card,
.lesson-card,
.quiz-card,
.empty-state,
.result-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, #ffffff, #f7f4ef);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
}

.hero-card::after {
  position: absolute;
  top: -45px;
  right: -35px;
  width: 160px;
  height: 160px;
  border: 26px solid rgba(207, 48, 48, .09);
  border-radius: 50%;
  content: "";
}

.hero-top,
.progress-label,
.word-row,
.catalog-row,
.quest-row,
.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero-card h2 {
  max-width: 330px;
  margin: 14px 0 8px;
  font-size: 25px;
  line-height: 1.12;
}

.hero-card p {
  max-width: 390px;
  margin-bottom: 20px;
}

.mini-badge,
.status-badge,
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
}

.mini-badge {
  background: rgba(27, 26, 24, .06);
  color: var(--text);
}

.status-badge {
  background: rgba(207, 48, 48, .1);
  color: var(--accent);
}

.level-badge {
  background: rgba(27, 26, 24, .06);
  color: var(--text);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 15px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 900;
  box-shadow: 0 12px 25px rgba(207, 48, 48, .18);
  cursor: pointer;
}

.button:disabled {
  opacity: .55;
  cursor: wait;
}

.button-secondary {
  background: var(--surface-3);
  box-shadow: none;
  color: var(--text);
}

.button-ghost {
  background: transparent;
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--muted);
}

.button-wide {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}

.stat-card {
  min-width: 0;
  padding: 14px 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  border-radius: 17px;
}

.stat-card span,
.stat-card small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-card b {
  display: block;
  margin: 5px 0 2px;
  font-size: 20px;
}

.plan-list,
.word-list,
.catalog-list,
.quest-list {
  display: grid;
  gap: 9px;
}

.plan-card,
.word-row,
.catalog-row,
.quest-row,
.profile-row {
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  border-radius: 17px;
}

.plan-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.plan-icon,
.mode-icon,
.word-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: rgba(27, 26, 24, .06);
  border-radius: 14px;
  color: var(--accent);
  font-size: 16px;
  font-weight: 900;
  filter: grayscale(1);
}

.plan-main,
.word-main,
.catalog-main {
  min-width: 0;
}

.plan-main b,
.word-main b,
.catalog-main b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-main small,
.word-main small,
.catalog-main small {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meter {
  width: 100%;
  height: 6px;
  margin-top: 9px;
  overflow: hidden;
  background: rgba(27, 26, 24, .09);
  border-radius: 20px;
}

.meter > i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.quick-grid,
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-card,
.mode-card {
  min-height: 126px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  border-radius: 18px;
  text-align: left;
}

.quick-card b,
.mode-card b {
  display: block;
  margin: 14px 0 5px;
}

.quick-card small,
.mode-card small {
  color: var(--muted);
  line-height: 1.35;
}

.quick-card-wide {
  grid-column: 1 / -1;
  min-height: 105px;
}

.mode-card[data-mode="sprint"] .mode-icon {
  background: rgba(27, 26, 24, .06);
  color: var(--text);
}

.mode-card[data-mode="mistakes"] .mode-icon {
  background: rgba(207, 48, 48, .1);
  color: var(--red);
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 2px 1px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chip.is-active {
  border-color: rgba(207, 48, 48, .38);
  background: rgba(207, 48, 48, .09);
  color: var(--accent);
}

.lesson-progress {
  margin-bottom: 13px;
}

.progress-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.lesson-card {
  overflow: hidden;
}

.lesson-image {
  width: 100%;
  max-height: 310px;
  object-fit: contain;
  background: #f4f4f1;
}

.lesson-body {
  padding: 24px 22px 22px;
  text-align: center;
}

.lesson-word {
  margin: 5px 0 6px;
  font-size: clamp(34px, 10vw, 52px);
  line-height: 1;
  letter-spacing: -.045em;
  text-transform: uppercase;
}

.phonetic {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 16px;
}

.reading {
  display: inline-block;
  margin-bottom: 18px;
  padding: 7px 11px;
  border-radius: 10px;
  background: rgba(27, 26, 24, .045);
  color: var(--muted);
  font-size: 13px;
}

.translation-box {
  padding: 9px;
  border: 1px solid rgba(27, 26, 24, .12);
  background: #ffffff;
  border-radius: 15px;
  text-align: left;
}

.translation-head {
  padding: 12px 13px;
  border-left: 4px solid var(--accent);
  background: #fff1f1;
  border-radius: 10px;
}

.translation-head small,
.example-line small {
  display: block;
  margin-bottom: 5px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.translation-head small {
  color: #a62a2a;
}

.translation-head b {
  display: block;
  color: #7f1f1f;
  font-size: 19px;
}

.example-details {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.example-line {
  padding: 11px 13px;
  border-radius: 10px;
}

.example-line p {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.example-line.is-english {
  background: #edf4fb;
  color: #244f70;
}

.example-line.is-translation {
  background: #eef7ed;
  color: #376331;
}

.example-line.is-pronunciation {
  background: #fff4df;
  color: #80561d;
}

.example-line.is-pronunciation p {
  font-style: italic;
}

.lesson-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 12px;
}

.rating-button {
  min-height: 56px;
  padding: 8px 3px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  font-size: 11px;
  font-weight: 800;
}

.rating-button span {
  display: block;
  margin-bottom: 3px;
  font-size: 17px;
}

.quiz-card {
  padding: 22px;
}

.quiz-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.quiz-timer {
  color: var(--yellow);
}

.quiz-prompt {
  margin: 28px 0 8px;
  text-align: center;
  font-size: clamp(30px, 9vw, 48px);
  line-height: 1.12;
  letter-spacing: -.035em;
}

.quiz-reading {
  min-height: 42px;
  color: var(--muted);
  text-align: center;
}

.answer-form {
  display: grid;
  gap: 9px;
  margin-top: 25px;
}

.input,
.search-input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  color: var(--text);
}

.input {
  min-height: 52px;
  padding: 0 15px;
  border-radius: 15px;
  font-size: 16px;
}

.answer-buttons,
.add-word-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
}

.feedback {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  font-weight: 750;
}

.feedback.is-correct {
  border: 1px solid rgba(27, 26, 24, .18);
  background: rgba(27, 26, 24, .045);
  color: var(--text);
}

.feedback.is-wrong {
  border: 1px solid rgba(207, 48, 48, .2);
  background: rgba(207, 48, 48, .08);
  color: #b52323;
}

.search-wrap {
  position: relative;
  margin-bottom: 12px;
}

.search-input {
  min-height: 48px;
  padding: 0 15px 0 42px;
  border-radius: 15px;
}

.search-wrap::before {
  position: absolute;
  top: 13px;
  left: 15px;
  color: var(--muted);
  content: "⌕";
  font-size: 21px;
}

.add-word-form {
  margin-bottom: 14px;
}

.word-row {
  width: 100%;
  border-color: var(--line);
  color: var(--text);
  text-align: left;
}

.word-row > b:last-child {
  color: var(--muted);
  font-size: 12px;
}

.catalog-section {
  margin-top: 24px;
}

.catalog-section > h2 {
  margin-left: 2px;
}

.catalog-actions {
  display: grid;
  flex: 0 0 118px;
  gap: 9px;
}

.catalog-browse-button {
  min-height: 36px;
  padding: 0 9px;
  border-color: rgba(207, 48, 48, .22);
  color: var(--accent);
  font-size: 10px;
  line-height: 1.1;
}

.catalog-plan-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.catalog-plan-toggle small {
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.verb-forms {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 17px;
}

.verb-forms span {
  min-width: 0;
  padding: 10px 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 12px;
}

.verb-forms small,
.verb-forms b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.verb-forms small {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.verb-forms b {
  font-size: 12px;
}

.browse-next-button {
  margin-top: 11px;
}

.book-grid {
  display: grid;
  gap: 12px;
}

.book-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.book-cover {
  position: relative;
  display: flex;
  min-height: 220px;
  padding: 16px 12px;
  overflow: hidden;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(160deg, transparent 0 48%, rgba(229, 61, 61, .82) 48% 57%, transparent 57%),
    #090909;
  border-right: 1px solid var(--line);
}

.book-cover::after {
  position: absolute;
  right: -32px;
  bottom: 22px;
  width: 94px;
  height: 94px;
  border: 18px solid rgba(255, 255, 255, .08);
  border-radius: 50%;
  content: "";
}

.book-cover small,
.book-cover span {
  position: relative;
  z-index: 1;
  color: #b5b5b5;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.book-cover b {
  position: relative;
  z-index: 1;
  max-width: 86px;
  color: var(--text);
  font-size: 22px;
  line-height: .92;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.book-card-body {
  min-width: 0;
  padding: 17px;
}

.book-card-body h2 {
  margin: 11px 0 4px;
  font-size: 18px;
  line-height: 1.15;
}

.book-card-body p {
  margin-bottom: 12px;
  font-size: 11px;
}

.book-card-body .book-original {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 12px;
}

.book-card-body .button {
  min-height: 42px;
  margin-top: 14px;
  padding: 0 12px;
  font-size: 12px;
}

.book-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 8px;
  margin-top: 14px;
}

.book-actions .button {
  margin-top: 0;
}

.book-play-button {
  min-width: 46px;
  padding: 0;
  font-size: 15px;
}

.reader-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 2px 13px;
}

.reader-page {
  max-width: 680px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fffdf9;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.reader-heading {
  padding: 25px 22px 22px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 100% 0, rgba(207, 48, 48, .09), transparent 34%),
    #ffffff;
}

.reader-heading h1 {
  margin-bottom: 5px;
  font-size: 27px;
}

.reader-heading h2 {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
}

.reader-heading p:not(.eyebrow) {
  margin-bottom: 13px;
  font-size: 12px;
}

.reader-audio-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 17px 18px 0;
  padding: 12px;
  border: 1px solid rgba(207, 48, 48, .18);
  background: linear-gradient(135deg, #fff8f7, #f7f3ee);
  border-radius: 15px;
}

.reader-play-button,
.reader-stop-button {
  min-height: 42px;
}

.reader-stop-button:disabled {
  opacity: .35;
}

.reader-audio-status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.reader-hint {
  margin: 17px 18px 0;
  padding: 10px 12px;
  border: 1px solid rgba(207, 48, 48, .16);
  background: rgba(207, 48, 48, .055);
  border-radius: 12px;
  color: #5e5954;
  font-size: 11px;
}

.reader-text {
  padding: 12px 22px 20px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.78;
}

.reader-paragraph {
  margin: 0 0 1.15em;
  color: #292622;
}

.reader-segment {
  padding: 2px 1px;
  border-radius: 5px;
  box-decoration-break: clone;
  transition: background-color .2s ease, box-shadow .2s ease, color .2s ease;
  -webkit-box-decoration-break: clone;
}

.reader-segment.is-speaking {
  background: rgba(207, 48, 48, .14);
  box-shadow: 4px 0 rgba(207, 48, 48, .14), -4px 0 rgba(207, 48, 48, .14);
  color: #201d1a;
}

.reader-word {
  display: inline;
  margin: 0;
  padding: 1px 0;
  border: 0;
  background: transparent;
  border-radius: 4px;
  color: inherit;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
}

.reader-word:active,
.reader-word:focus-visible {
  background: rgba(207, 48, 48, .14);
  color: #ffffff;
  outline: 2px solid rgba(207, 48, 48, .35);
  outline-offset: 1px;
}

.reader-footer {
  padding: 20px 22px 24px;
  border-top: 1px solid var(--line);
  background: #f8f5f0;
  text-align: center;
}

.reader-navigation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.reader-navigation .button:disabled {
  opacity: .25;
  cursor: default;
}

.reader-complete {
  margin: 18px 0 8px;
  color: var(--text);
  font-weight: 800;
}

.source-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--muted);
  font-size: 11px;
  text-decoration: none;
}

.source-link:hover {
  color: var(--accent);
}

.switch {
  position: relative;
  width: 48px;
  height: 28px;
  padding: 0;
  border: 0;
  background: #d6d1ca;
  border-radius: 99px;
  transition: .2s ease;
}

.switch::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  content: "";
  transition: .2s ease;
}

.switch.is-active {
  background: rgba(207, 48, 48, .36);
}

.switch.is-active::after {
  left: 24px;
  background: var(--accent);
}

.profile-hero {
  padding: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  border-radius: var(--radius);
  text-align: center;
}

.profile-avatar {
  display: grid;
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  place-items: center;
  border: 1px solid rgba(207, 48, 48, .24);
  background: rgba(207, 48, 48, .09);
  border-radius: 24px;
  color: var(--accent);
  font-size: 28px;
  font-weight: 900;
}

.profile-hero h1 {
  margin-bottom: 5px;
  font-size: 28px;
}

.profile-hero p {
  margin-bottom: 17px;
}

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.achievement {
  padding: 13px 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  border-radius: 15px;
  color: var(--muted);
  text-align: center;
}

.achievement.is-unlocked {
  border-color: rgba(207, 48, 48, .24);
  color: var(--text);
}

.achievement span,
.achievement b {
  display: block;
}

.achievement span {
  margin-bottom: 7px;
  font-size: 22px;
  filter: grayscale(1);
  opacity: .45;
}

.achievement.is-unlocked span {
  filter: grayscale(1);
  opacity: 1;
}

.achievement b {
  font-size: 11px;
}

.calendar-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(38px, 1fr));
  gap: 6px;
  overflow: hidden;
}

.calendar-day {
  padding: 10px 3px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  border-radius: 13px;
  text-align: center;
}

.calendar-day small,
.calendar-day b {
  display: block;
}

.calendar-day small {
  color: var(--muted);
  font-size: 9px;
}

.calendar-day b {
  margin-top: 5px;
  font-size: 14px;
}

.empty-state,
.result-card,
.loading-card {
  padding: 34px 22px;
  text-align: center;
}

.empty-actions {
  display: grid;
  gap: 9px;
  max-width: 330px;
  margin: 22px auto 0;
}

.empty-actions .button {
  width: 100%;
}

.lesson-countdown {
  display: block;
  width: fit-content;
  margin: 18px auto 0;
  padding: 10px 14px;
  border: 1px solid rgba(207, 48, 48, .18);
  background: rgba(207, 48, 48, .07);
  border-radius: 13px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.result-guidance {
  color: var(--muted);
}

.resume-note {
  margin: 0 0 12px;
  padding: 11px 13px;
  border: 1px solid rgba(207, 48, 48, .18);
  background: rgba(207, 48, 48, .06);
  border-radius: 14px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.empty-icon,
.result-icon {
  display: grid;
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  place-items: center;
  background: rgba(207, 48, 48, .09);
  border-radius: 20px;
  font-size: 27px;
  filter: grayscale(1);
}

.loading-card {
  min-height: 230px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .76);
  border-radius: var(--radius);
}

.loader {
  display: block;
  width: 34px;
  height: 34px;
  margin: 48px auto 16px;
  border: 3px solid rgba(27, 26, 24, .12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(760px, 100%);
  min-height: 72px;
  margin: auto;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(250, 248, 244, .95);
  backdrop-filter: blur(18px);
}

.nav-button {
  display: grid;
  min-width: 0;
  min-height: 54px;
  padding: 5px 2px;
  place-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  border-radius: 14px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.nav-button.is-active {
  color: var(--accent);
}

.nav-icon {
  display: block;
  font-size: 21px;
  line-height: 1;
  filter: grayscale(1);
}

.nav-primary .nav-icon {
  display: grid;
  width: 34px;
  height: 34px;
  margin: -13px auto 0;
  place-items: center;
  background: var(--accent);
  border: 5px solid #f5f2ed;
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(207, 48, 48, .22);
  color: var(--accent-text);
  font-size: 15px;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 16px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: 500px;
  margin: auto;
  padding: 13px 16px;
  transform: translateY(18px);
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.modal-backdrop {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  align-items: end;
  padding: 16px;
  background: rgba(28, 24, 20, .38);
  backdrop-filter: blur(6px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 80vh;
  margin: 0 auto;
  padding: 25px;
  overflow-y: auto;
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 24px 24px 18px 18px;
  box-shadow: var(--shadow);
  animation: modal-in .22s ease both;
}

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

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  background: rgba(27, 26, 24, .05);
  border-radius: 12px;
  color: var(--muted);
  font-size: 24px;
}

.modal-word {
  padding-right: 38px;
}

.modal-word h2 {
  margin: 5px 0;
  font-size: 32px;
}

.reader-context-label {
  margin: 16px 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.modal-actions {
  display: flex;
  gap: 9px;
  margin-top: 20px;
}

.modal-actions-wrap {
  flex-wrap: wrap;
}

@media (max-width: 470px) {
  .reader-audio-bar {
    grid-template-columns: 1fr;
  }

  .reader-audio-status {
    grid-column: 1;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .lesson-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .calendar-strip {
    grid-template-columns: repeat(7, 42px);
    overflow-x: auto;
  }

  .catalog-row {
    align-items: flex-start;
  }

  .catalog-actions {
    flex-basis: 102px;
  }

  .catalog-plan-toggle small {
    display: none;
  }
}

@media (min-width: 680px) {
  main {
    padding-right: 24px;
    padding-left: 24px;
  }

  .hero-card,
  .quiz-card,
  .lesson-body {
    padding: 28px;
  }

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

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

  .book-card {
    display: block;
  }

  .book-cover {
    min-height: 160px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .book-cover b {
    max-width: 240px;
    font-size: 32px;
  }

  .modal-backdrop {
    align-items: center;
  }

  .modal-card {
    border-radius: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
