:root {
  --paper: #f5f0e5;
  --paper-deep: #ebe3d4;
  --card: #fffdf8;
  --ink: #1e2a25;
  --muted: #69736d;
  --faint: #8a928d;
  --green: #1f5b47;
  --green-deep: #173f33;
  --green-soft: #dce9e2;
  --orange: #ce713a;
  --orange-soft: #f5e2d4;
  --gold: #b68a3d;
  --line: #d9d1c2;
  --line-soft: #e9e2d6;
  --shadow: 0 16px 42px rgba(43, 48, 39, 0.08);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --sans: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --header-height: 72px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 6%, rgba(206, 113, 58, 0.09), transparent 25rem),
    radial-gradient(circle at 90% 18%, rgba(31, 91, 71, 0.08), transparent 30rem),
    var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.26;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

a {
  color: inherit;
  text-decoration: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 8px 12px;
  color: white;
  background: var(--green);
  border-radius: 8px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid rgba(206, 113, 58, 0.56);
  outline-offset: 3px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: var(--header-height);
  padding: 10px max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid rgba(217, 209, 194, 0.82);
  background: rgba(245, 240, 229, 0.9);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
}

.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fffdf7;
  background: var(--green);
  border-radius: 12px 12px 12px 3px;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.04em;
  box-shadow: 0 7px 16px rgba(31, 91, 71, 0.2);
}

.brand-copy {
  display: grid;
  line-height: 1.2;
}

.brand-copy strong {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.02em;
}

.brand-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.topbar-tools {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.search-field {
  position: relative;
  display: flex;
  width: min(320px, 32vw);
  height: 42px;
  align-items: center;
  padding: 0 10px 0 38px;
  background: rgba(255, 253, 248, 0.74);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.search-field:focus-within {
  background: var(--card);
  border-color: rgba(31, 91, 71, 0.58);
  box-shadow: 0 0 0 4px rgba(31, 91, 71, 0.08);
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.search-field input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
}

.search-field input::placeholder {
  color: #7d857f;
}

.search-field input::-webkit-search-cancel-button,
.search-field input::-webkit-search-decoration {
  display: none;
  -webkit-appearance: none;
  appearance: none;
}

kbd {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  place-items: center;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: var(--sans);
  font-size: 10px;
  line-height: 1;
}

.clear-search {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  margin-left: 4px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  background: var(--paper-deep);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}

.clear-search .icon {
  width: 14px;
  height: 14px;
}

.search-cancel {
  display: none;
  min-width: 44px;
  height: 44px;
  padding: 0 4px;
  color: var(--green);
  background: var(--card);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.tool-button {
  display: inline-flex;
  min-width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tool-button .tool-icon {
  width: 19px;
  height: 19px;
}

.mode-book {
  display: none;
}

.study-toggle[aria-pressed="true"] .mode-eye {
  display: none;
}

.study-toggle[aria-pressed="true"] .mode-book {
  display: block;
}

.mobile-label,
.mode-short-label {
  display: none;
}

.tool-button:hover,
.quiet-action:hover {
  background: rgba(255, 253, 248, 0.72);
  border-color: #bfb5a3;
}

.tool-button:active,
.quiet-action:active,
.primary-action:active {
  transform: translateY(1px);
}

.study-toggle[aria-pressed="true"] {
  color: #fffdf7;
  background: var(--green);
  border-color: var(--green);
}

#main {
  width: min(1240px, calc(100% - 48px));
  margin: 0 auto;
}

.hero {
  padding: 28px 4px 24px;
}

.progress-panel {
  display: flex;
  width: min(100%, 560px);
  min-width: 310px;
  align-items: center;
  gap: 18px;
  padding: 17px 20px;
  background: rgba(255, 253, 248, 0.58);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.progress-ring {
  --progress: 0;
  display: grid;
  width: 76px;
  height: 76px;
  flex: 0 0 auto;
  place-items: center;
  background: conic-gradient(var(--green) calc(var(--progress) * 1%), var(--line-soft) 0);
  border-radius: 50%;
}

.progress-ring-inner {
  display: flex;
  width: 62px;
  height: 62px;
  align-items: baseline;
  justify-content: center;
  padding-top: 18px;
  background: var(--card);
  border-radius: 50%;
}

.progress-ring strong {
  font-family: var(--serif);
  font-size: 25px;
  line-height: 1;
}

.progress-ring span {
  color: var(--faint);
  font-size: 10px;
}

.progress-copy {
  display: grid;
  flex: 1;
  gap: 4px;
}

.progress-copy > span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.progress-copy > strong {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
}

.daily-goals {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.daily-goals > span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.72);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-size: 10px;
  line-height: 1;
}

.daily-goals strong {
  color: var(--green);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.daily-goal-edit {
  min-height: 28px;
  padding: 0 8px;
  color: var(--green);
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(31, 91, 71, 0.28);
  cursor: pointer;
  font-size: 10px;
  font-weight: 650;
  line-height: 1;
}

.daily-goal-edit:active {
  opacity: 0.68;
}

.progress-track {
  height: 3px;
  margin-top: 3px;
  overflow: hidden;
  background: var(--line-soft);
  border-radius: 10px;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
  transition: width 300ms ease;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 4px 28px;
}

.primary-action,
.quiet-action {
  min-height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
}

.primary-action {
  display: inline-flex;
  max-width: 360px;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  overflow: hidden;
  color: #fffdf7;
  background: var(--green);
  border: 1px solid var(--green);
  white-space: nowrap;
}

.primary-action span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.daily-new-action {
  background: var(--green);
}

.primary-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.resume-action {
  display: inline-flex;
  max-width: 280px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  color: var(--green);
  white-space: nowrap;
}

.resume-action span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.resume-icon {
  width: 18px;
  height: 18px;
}

.quiet-action {
  padding: 0 14px;
  background: rgba(255, 253, 248, 0.36);
  border: 1px solid var(--line);
}

.shortcut-hint {
  margin: 0 0 0 auto;
  color: var(--faint);
  font-size: 10px;
}

.shortcut-hint span {
  margin: 0 4px;
}

.review-center {
  display: grid;
  gap: 16px;
  margin-bottom: 40px;
  padding: 0 4px;
}

.review-center-heading,
.mastery-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.review-center-heading > div,
.mastery-heading > div {
  display: grid;
  gap: 3px;
}

.section-kicker {
  color: var(--orange);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.review-center-heading h2,
.mastery-heading h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.review-center-heading > p,
.mastery-heading > div > p,
.mastery-heading > span {
  margin: 0;
  color: var(--faint);
  font-size: 9px;
  text-align: right;
}

.review-dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.review-stat {
  position: relative;
  display: grid;
  min-height: 146px;
  align-content: start;
  gap: 3px;
  padding: 18px 20px;
  overflow: hidden;
  text-align: left;
  background: rgba(255, 253, 248, 0.78);
  border: 1px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.review-stat::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  content: "";
  background: var(--green);
}

.review-stat.weak::before {
  background: var(--orange);
}

.review-stat:hover {
  border-color: #c7bdac;
  box-shadow: 0 10px 28px rgba(43, 48, 39, 0.07);
  transform: translateY(-1px);
}

.review-stat.is-empty {
  background: rgba(255, 253, 248, 0.48);
}

.review-stat-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.review-stat strong {
  color: var(--green);
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 650;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.review-stat.weak strong {
  color: var(--orange);
}

.review-stat small {
  min-height: 32px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.65;
}

.review-stat-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  padding-top: 7px;
  color: var(--green);
  font-size: 10px;
  font-weight: 650;
}

.review-stat.weak .review-stat-action {
  color: #9b562e;
}

.mastery-panel {
  padding: 17px 18px 13px;
  background: rgba(255, 253, 248, 0.62);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.mastery-heading {
  padding: 0 2px 11px;
  border-bottom: 1px solid var(--line-soft);
}

.mastery-heading h3 {
  font-size: 16px;
}

.mastery-heading p {
  margin: 0;
  color: var(--faint);
  font-size: 8px;
  text-align: left;
}

.mastery-list {
  display: grid;
}

.mastery-row {
  display: grid;
  grid-template-columns: 26px minmax(150px, 1fr) minmax(90px, 180px) 42px;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 9px 4px;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}

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

.mastery-row:hover {
  background: rgba(245, 240, 229, 0.5);
}

.mastery-index {
  color: var(--orange);
  font-family: var(--serif);
  font-size: 10px;
}

.mastery-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.mastery-copy strong {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 12.5px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mastery-copy small {
  color: var(--faint);
  font-size: 8.5px;
}

.mastery-meter {
  height: 5px;
  overflow: hidden;
  background: var(--line-soft);
  border-radius: 999px;
}

.mastery-meter i {
  display: block;
  width: var(--mastery);
  height: 100%;
  background: var(--green);
  border-radius: inherit;
  transition: width 300ms ease;
}

.mastery-label {
  color: var(--faint);
  font-size: 9px;
  font-weight: 650;
  text-align: right;
}

.mastery-row.tone-empty .mastery-label {
  color: var(--faint);
}

.mastery-row.tone-strong .mastery-label {
  color: var(--green);
}

.mastery-row.tone-steady .mastery-label {
  color: #52735f;
}

.mastery-row.tone-fuzzy .mastery-label {
  color: #9b7427;
}

.mastery-row.tone-fuzzy .mastery-meter i {
  background: var(--gold);
}

.mastery-row.tone-weak .mastery-label {
  color: #9a5146;
}

.mastery-row.tone-weak .mastery-meter i {
  background: #a8584c;
}

.workspace {
  display: grid;
  grid-template-columns: 222px minmax(0, 1fr);
  gap: 46px;
  align-items: start;
  padding-bottom: 80px;
}

body.is-searching .hero,
body.is-searching .hero-actions,
body.is-searching .review-center {
  display: none;
}

body.is-searching .workspace {
  padding-top: 24px;
}

.chapter-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 22px);
  display: grid;
  gap: 16px;
}

.sidebar-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 6px;
  border-bottom: 1px solid var(--line);
}

.sidebar-heading span {
  padding-bottom: 10px;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 650;
}

.sidebar-heading small {
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.16em;
}

.chapter-nav {
  display: grid;
  gap: 3px;
}

.chapter-link {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 8px 9px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 160ms ease;
}

.chapter-link:hover {
  background: rgba(255, 253, 248, 0.58);
}

.chapter-link.is-active {
  background: rgba(255, 253, 248, 0.9);
  box-shadow: inset 3px 0 var(--green);
}

.chapter-number {
  color: var(--orange);
  font-family: var(--serif);
  font-size: 12px;
}

.chapter-label {
  display: grid;
  line-height: 1.3;
}

.chapter-label strong {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 650;
}

.chapter-label small {
  margin-top: 4px;
  color: var(--faint);
  font-size: 9px;
}

.chapter-progress {
  color: var(--faint);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.chapter-progress.is-complete {
  color: var(--green);
}

.sidebar-note {
  margin: 4px 5px 0;
  padding: 13px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.44);
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 10px;
  line-height: 1.6;
}

.sidebar-note p {
  margin: 0;
}

.sidebar-note button {
  margin-top: 8px;
  padding: 0;
  color: var(--orange);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 10px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.study-column {
  min-width: 0;
}

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

.search-status {
  margin-bottom: 20px;
  padding: 12px 15px;
  color: var(--muted);
  background: var(--orange-soft);
  border: 1px solid rgba(206, 113, 58, 0.2);
  border-radius: 10px;
  font-size: 12px;
}

.search-status strong {
  color: var(--ink);
}

.search-result-copy {
  display: grid;
  gap: 3px;
  line-height: 1.6;
}

.search-result-copy small {
  color: var(--faint);
  font-size: 10.5px;
}

.search-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.search-filter {
  min-width: 62px;
  min-height: 38px;
  padding: 0 12px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.66);
  border: 1px solid rgba(206, 113, 58, 0.2);
  border-radius: 9px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

.search-filter.is-active {
  color: #fffdf7;
  background: var(--green);
  border-color: var(--green);
}

.search-highlight {
  padding: 0 2px;
  color: var(--ink);
  background: rgba(242, 207, 169, 0.78);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(206, 113, 58, 0.08);
}

.chapter-section {
  margin-bottom: 52px;
  scroll-margin-top: calc(var(--header-height) + 24px);
}

.chapter-section[hidden],
.part-section[hidden],
.kp-card[hidden] {
  display: none;
}

.chapter-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.chapter-heading-copy {
  display: flex;
  align-items: baseline;
  gap: 15px;
}

.chapter-heading .big-number {
  color: var(--orange);
  font-family: var(--serif);
  font-size: 13px;
}

.chapter-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.chapter-heading-meta {
  color: var(--faint);
  font-size: 10px;
  text-align: right;
}

.long-divider {
  height: 1px;
  margin: 22px 0 26px;
  background: linear-gradient(90deg, var(--green), var(--line) 35%, transparent);
}

.parts {
  display: grid;
  gap: 32px;
}

.part-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.part-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.part-title::before {
  width: 16px;
  height: 1px;
  flex: 0 0 auto;
  content: "";
  background: var(--orange);
}

.part-title h3 {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.part-toggle {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  flex: 0 0 auto;
  padding: 4px 2px 4px 12px;
  color: var(--green);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 10px;
}

.card-list {
  display: grid;
  gap: 9px;
}

.kp-card {
  overflow: hidden;
  background: rgba(255, 253, 248, 0.82);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  box-shadow: 0 2px 0 rgba(30, 42, 37, 0.025);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.kp-card:hover {
  border-color: #cfc5b5;
}

.kp-card.is-open {
  border-color: #cfc5b5;
  box-shadow: var(--shadow);
}

.kp-card.has-recall {
  border-color: rgba(31, 91, 71, 0.32);
}

.kp-card.has-recall::after {
  display: block;
  height: 2px;
  content: "";
  background: linear-gradient(90deg, var(--green), rgba(31, 91, 71, 0.18));
}

.kp-card.last-fuzzy {
  border-color: rgba(182, 138, 61, 0.35);
}

.kp-card.last-fuzzy::after {
  background: linear-gradient(90deg, var(--gold), rgba(182, 138, 61, 0.16));
}

.kp-card.last-forgotten {
  border-color: rgba(168, 88, 76, 0.3);
}

.kp-card.last-forgotten::after {
  background: linear-gradient(90deg, #a8584c, rgba(168, 88, 76, 0.14));
}

.kp-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
}

.kp-toggle {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 22px;
  gap: 9px;
  align-items: center;
  min-width: 0;
  padding: 16px 13px 16px 16px;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.kp-index {
  color: var(--orange);
  font-family: var(--serif);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.kp-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.chevron {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  justify-self: end;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: transform 180ms ease, background 180ms ease;
}

.chevron .icon {
  width: 13px;
  height: 13px;
}

.kp-toggle[aria-expanded="true"] .chevron {
  background: var(--green-soft);
  transform: rotate(180deg);
}

.recall-total {
  display: grid;
  min-width: 42px;
  align-items: center;
  justify-content: center;
  align-content: center;
  margin: 8px 9px 8px 0;
  padding: 0 7px;
  color: var(--muted);
  background: rgba(245, 240, 229, 0.62);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  line-height: 1.05;
  text-align: center;
}

.has-recall .recall-total {
  color: var(--green);
  background: var(--green-soft);
  border-color: rgba(31, 91, 71, 0.18);
}

.recall-total strong {
  font-family: var(--serif);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.recall-total span {
  margin-top: 2px;
  color: var(--faint);
  font-size: 8px;
}

.recall-total strong:empty::before {
  content: "0";
}

.kp-body {
  display: none;
  border-top: 1px solid var(--line-soft);
}

.kp-card.is-open .kp-body {
  display: block;
  animation: reveal 220ms ease both;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.answer {
  position: relative;
  padding: 22px 24px 24px 58px;
}

.answer::before {
  position: absolute;
  top: 24px;
  bottom: 24px;
  left: 30px;
  width: 1px;
  content: "";
  background: var(--line);
}

.answer-block {
  margin: 0 0 10px;
  color: #35433c;
  font-size: 13px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.answer-block:last-child {
  margin-bottom: 0;
}

.answer-block.label {
  color: var(--ink);
  font-weight: 650;
}

.answer-block.mnemonic {
  margin: 14px 0;
  padding: 11px 13px;
  color: #704b16;
  background: #f4ead5;
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  line-height: 1.7;
}

.answer-block.pro {
  margin: 7px 0;
  padding: 9px 12px;
  color: #245f49;
  background: #e1eee7;
  border-radius: 8px;
  font-size: 12px;
}

.answer-block.con {
  margin: 7px 0;
  padding: 9px 12px;
  color: #805046;
  background: #f4e6e1;
  border-radius: 8px;
  font-size: 12px;
}

.subnode {
  position: relative;
  margin: 14px 0 0;
  padding: 11px 14px 12px;
  background: rgba(245, 240, 229, 0.56);
  border: 1px solid rgba(217, 209, 194, 0.62);
  border-radius: 9px;
}

.subnode .subnode {
  margin-top: 9px;
  background: rgba(255, 253, 248, 0.62);
}

.subnode-title {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.7;
}

.subnode > .answer-block {
  font-size: 12.5px;
}

.rating-panel {
  margin: 0 22px 22px 22px;
  padding: 15px;
  background: rgba(245, 240, 229, 0.56);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.rating-panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.rating-panel-heading strong {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 650;
}

.rating-panel-heading span {
  color: var(--faint);
  font-size: 9px;
}

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

.rating-button {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.rating-button .icon {
  width: 17px;
  height: 17px;
}

.rating-button:active {
  transform: scale(0.97);
}

.rating-button.skilled {
  color: var(--green);
  border-color: rgba(31, 91, 71, 0.26);
}

.rating-button.skilled:active,
.rating-button.skilled:hover {
  background: var(--green-soft);
}

.rating-button.fuzzy {
  color: #87621e;
  border-color: rgba(182, 138, 61, 0.3);
}

.rating-button.fuzzy:active,
.rating-button.fuzzy:hover {
  background: #f4ead5;
}

.rating-button.forgotten {
  color: #9a5146;
  border-color: rgba(168, 88, 76, 0.25);
}

.rating-button.forgotten:active,
.rating-button.forgotten:hover {
  background: #f4e6e1;
}

.rating-button:disabled {
  opacity: 0.46;
  cursor: default;
  transform: none;
}

.rating-button.skilled.is-selected {
  color: #fffdf7;
  background: var(--green);
  border-color: var(--green);
}

.rating-button.fuzzy.is-selected {
  color: #fffdf7;
  background: var(--gold);
  border-color: var(--gold);
}

.rating-button.forgotten.is-selected {
  color: #fffdf7;
  background: #a8584c;
  border-color: #a8584c;
}

.rating-button:disabled.is-selected {
  opacity: 1;
  box-shadow: 0 4px 12px rgba(30, 42, 37, 0.12);
}

.recall-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.rating-panel .recall-summary {
  margin-top: 10px;
}

.recall-chip {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.78);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  font-size: 9px;
  line-height: 1;
}

.recall-chip strong {
  color: var(--ink);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.recall-chip.skilled strong {
  color: var(--green);
}

.recall-chip.fuzzy strong {
  color: #87621e;
}

.recall-chip.forgotten strong {
  color: #9a5146;
}

.recall-due {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 2px 7px;
  color: var(--muted);
  background: rgba(245, 240, 229, 0.72);
  border: 1px dashed var(--line);
  border-radius: 999px;
  font-size: 9px;
  line-height: 1;
}

.rating-panel .recall-due {
  margin-left: auto;
}

.recall-due.is-due {
  color: #9a5146;
  background: #f4e6e1;
  border-color: rgba(168, 88, 76, 0.24);
}

.study-cover {
  display: none;
  min-height: 126px;
  place-items: center;
  padding: 25px;
  text-align: center;
  background:
    linear-gradient(rgba(255, 253, 248, 0.7), rgba(255, 253, 248, 0.7)),
    repeating-linear-gradient(0deg, transparent 0 24px, rgba(31, 91, 71, 0.08) 24px 25px);
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
}

.study-cover-inner {
  display: grid;
  gap: 5px;
}

.study-cover strong {
  color: var(--green);
  font-family: var(--serif);
  font-size: 15px;
}

.study-cover span {
  color: var(--muted);
  font-size: 10px;
}

body.study-mode .kp-card.is-open:not(.is-revealed) .study-cover {
  display: grid;
}

body.study-mode .kp-card.is-open:not(.is-revealed) .answer,
body.study-mode .kp-card.is-open.is-revealed .study-cover {
  display: none;
}

body.is-searching .study-cover {
  display: none !important;
}

body.is-searching .answer {
  display: block !important;
}

.search-status mark {
  padding: 0 3px;
  color: var(--ink);
  background: #f2cfa9;
  border-radius: 3px;
}

.no-results {
  padding: 52px 24px;
  text-align: center;
  background: rgba(255, 253, 248, 0.52);
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.no-results strong {
  display: block;
  margin-bottom: 7px;
  font-family: var(--serif);
  font-size: 20px;
}

.no-results p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  padding: 28px 2px 0;
  color: var(--faint);
  border-top: 1px solid var(--line);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #fffdf7;
  background: var(--green);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 10px 24px rgba(31, 91, 71, 0.22);
  cursor: pointer;
}

.back-to-top .icon {
  width: 20px;
  height: 20px;
}

.jump-to-rating {
  position: fixed;
  right: 22px;
  bottom: 78px;
  z-index: 79;
  min-width: 88px;
  min-height: 44px;
  padding: 0 15px;
  color: var(--orange);
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid rgba(206, 113, 58, 0.35);
  border-radius: 999px;
  box-shadow: 0 9px 24px rgba(43, 48, 39, 0.13);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.rating-undo {
  position: fixed;
  right: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 90;
  display: flex;
  width: min(390px, calc(100vw - 24px));
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 10px 9px 16px;
  color: #fffdf7;
  background: rgba(23, 63, 51, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 13px;
  box-shadow: 0 16px 36px rgba(18, 35, 28, 0.24);
  font-size: 12px;
  transform: translateX(50%);
}

.rating-undo span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rating-undo button {
  min-width: 58px;
  min-height: 36px;
  flex: 0 0 auto;
  padding: 0 12px;
  color: var(--green-deep);
  background: #fffdf7;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.random-rating-undo {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 7px 8px 7px 13px;
  color: #fffdf7;
  background: var(--green-deep);
  border-radius: 10px;
  font-size: 11px;
}

.random-rating-undo span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.random-rating-undo button {
  min-width: 56px;
  min-height: 34px;
  flex: 0 0 auto;
  padding: 0 11px;
  color: var(--green-deep);
  background: #fffdf7;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.random-dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: min(82dvh, 760px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(18, 35, 28, 0.28);
}

.random-dialog::backdrop {
  background: rgba(20, 34, 28, 0.54);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.random-dialog[open] {
  animation: dialog-in 220ms ease both;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.goal-dialog {
  width: min(500px, calc(100vw - 32px));
}

.goal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.goal-header > div {
  display: grid;
  gap: 5px;
}

.goal-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.25;
}

.goal-main {
  display: grid;
  gap: 12px;
  padding: 20px 24px 24px;
}

.goal-intro {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.goal-setting-row {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 14px 13px 16px;
  background: rgba(245, 240, 229, 0.58);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
}

.goal-setting-copy {
  display: grid;
  gap: 2px;
}

.goal-setting-copy strong {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 650;
}

.goal-setting-copy small {
  color: var(--faint);
  font-size: 10.5px;
}

.goal-stepper {
  display: grid;
  grid-template-columns: 42px minmax(42px, 1fr) 42px;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
  padding: 3px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.goal-stepper button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  color: var(--green);
  background: var(--green-soft);
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}

.goal-stepper button:disabled {
  color: var(--faint);
  background: rgba(245, 240, 229, 0.7);
  cursor: default;
}

.goal-stepper output {
  min-width: 42px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  text-align: center;
}

.goal-footer {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 9px;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--line-soft);
}

.goal-footer button {
  min-height: 46px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.goal-cancel {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}

.goal-save {
  color: #fffdf7;
  background: var(--green);
  border: 1px solid var(--green);
}

.random-sheet {
  display: flex;
  max-height: inherit;
  flex-direction: column;
}

.sheet-handle {
  display: none;
  width: 38px;
  height: 5px;
  flex: 0 0 auto;
  margin: 8px auto 0;
  background: rgba(105, 115, 109, 0.28);
  border-radius: 999px;
}

.random-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.random-header > div {
  display: grid;
  gap: 5px;
}

.random-kicker {
  color: var(--orange);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.random-context {
  color: var(--muted);
  font-size: 10px;
}

.random-close {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.random-close .icon {
  width: 18px;
  height: 18px;
}

.random-main {
  padding: 28px 28px 22px;
  overflow-y: auto;
}

.random-prompt {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.random-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(23px, 4vw, 34px);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.random-answer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  animation: reveal 200ms ease both;
}

.random-answer .answer {
  padding: 0 0 0 23px;
}

.random-answer .answer::before {
  top: 2px;
  bottom: 2px;
  left: 6px;
}

.random-footer {
  padding: 16px 24px max(20px, env(safe-area-inset-bottom));
  background: rgba(245, 240, 229, 0.68);
  border-top: 1px solid var(--line-soft);
}

.random-primary {
  display: inline-flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  color: #fffdf7;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 11px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.random-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
}

.random-result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
}

.random-result-heading > span {
  flex: 0 0 auto;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 650;
}

.random-result-heading .recall-summary {
  justify-content: flex-end;
}

.random-next {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  color: var(--green);
  background: var(--card);
  border: 1px solid rgba(31, 91, 71, 0.3);
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.random-next .icon {
  width: 17px;
  height: 17px;
}

body.random-open {
  overflow: hidden;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 200;
  max-width: min(440px, calc(100vw - 40px));
  padding: 11px 17px;
  color: #fffdf7;
  background: var(--green-deep);
  border-radius: 10px;
  box-shadow: 0 14px 36px rgba(30, 42, 37, 0.22);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1040px) {
  :root {
    --header-height: 66px;
  }

  .topbar {
    gap: 14px;
    padding-right: 20px;
    padding-left: 20px;
  }

  .brand-copy small,
  .desktop-label,
  .shortcut-hint {
    display: none;
  }

  .tool-button {
    width: 42px;
    padding: 0;
  }

  #main {
    width: min(100% - 40px, 900px);
  }

  .hero {
    padding-top: 26px;
  }

  .progress-panel {
    width: min(100%, 390px);
  }

  .workspace {
    display: block;
  }

  .chapter-sidebar {
    display: none;
  }

  .mobile-chapter-nav {
    position: sticky;
    top: var(--header-height);
    z-index: 70;
    display: flex;
    gap: 5px;
    margin: 0 -20px 26px;
    padding: 9px 20px;
    overflow-x: auto;
    background: var(--paper);
    border-top: 1px solid rgba(217, 209, 194, 0.46);
    border-bottom: 1px solid rgba(217, 209, 194, 0.76);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .mobile-chapter-nav::-webkit-scrollbar {
    display: none;
  }

  .mobile-chapter-link {
    display: inline-flex;
    flex: 0 0 auto;
    min-height: 44px;
    align-items: center;
    gap: 6px;
    padding: 0 11px;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    font-size: 10px;
  }

  .mobile-chapter-link.is-active {
    color: #fffdf7;
    background: var(--green);
    border-color: var(--green);
  }
}

@media (max-width: 680px) {
  :root {
    --header-height: 64px;
  }

  body {
    font-size: 14px;
    overscroll-behavior-y: none;
  }

  .topbar {
    gap: 8px;
    min-height: var(--header-height);
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
    background: var(--paper);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 11px 11px 11px 3px;
    font-size: 14px;
  }

  .brand-copy strong {
    max-width: 104px;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
  }

  .topbar-tools {
    gap: 4px;
  }

  .search-field {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
  }

  .search-field kbd {
    display: none;
  }

  .search-field:focus-within,
  body.search-open .search-field,
  body.is-searching .search-field {
    position: absolute;
    top: max(8px, env(safe-area-inset-top));
    right: 62px;
    left: 12px;
    z-index: 7;
    width: auto;
    height: 44px;
    padding: 0 10px 0 38px;
    border-radius: 12px;
    background: var(--card);
    border-color: rgba(31, 91, 71, 0.46);
    box-shadow: 0 5px 18px rgba(30, 42, 37, 0.1);
  }

  .search-field:focus-within kbd,
  body.search-open .search-field kbd,
  body.is-searching .search-field kbd {
    display: none;
  }

  .search-field input {
    opacity: 0;
  }

  .search-field:focus-within input,
  body.search-open .search-field input,
  body.is-searching .search-field input {
    opacity: 1;
  }

  .search-field:focus-within .clear-search:not([hidden]),
  body.search-open .search-field .clear-search:not([hidden]),
  body.is-searching .search-field .clear-search:not([hidden]) {
    display: grid;
  }

  .search-icon {
    left: 13px;
    z-index: 1;
  }

  .search-field:focus-within + .search-cancel,
  body.search-open .search-cancel,
  body.is-searching .search-cancel {
    position: absolute;
    top: max(8px, env(safe-area-inset-top));
    right: 9px;
    z-index: 8;
    display: block;
    width: 48px;
    height: 44px;
  }

  body.is-searching .topbar-tools .tool-button,
  body.search-open .topbar-tools .tool-button,
  .search-field:focus-within ~ .tool-button {
    visibility: hidden;
  }

  .tool-button {
    width: 48px;
    height: 46px;
    flex-direction: column;
    gap: 1px;
    border-radius: 12px;
  }

  .tool-button .tool-icon {
    width: 20px;
    height: 20px;
  }

  .mobile-label {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.15;
  }

  .study-toggle[aria-pressed="true"] .mobile-label {
    color: rgba(255, 253, 247, 0.82);
  }

  #main {
    width: calc(100% - 24px);
  }

  .hero {
    padding: 14px 2px 16px;
  }

  .progress-panel {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    border-radius: 14px;
  }

  .progress-ring {
    width: 64px;
    height: 64px;
  }

  .progress-ring-inner {
    width: 52px;
    height: 52px;
    padding-top: 14px;
  }

  .progress-ring strong {
    font-size: 21px;
  }

  .progress-copy > strong {
    font-size: 13px;
  }

  .daily-goal-edit {
    min-height: 44px;
    padding: 0 7px;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding-bottom: 18px;
  }

  .hero-actions > button {
    width: 100%;
    min-width: 0;
  }

  .primary-action {
    max-width: none;
    min-height: 44px;
    padding: 0 12px;
  }

  .resume-action {
    max-width: none;
  }

  .quiet-action {
    min-height: 44px;
    padding: 0 10px;
  }

  .review-center {
    gap: 13px;
    margin-bottom: 26px;
    padding: 0;
  }

  .review-center-heading {
    align-items: flex-end;
  }

  .review-center-heading h2 {
    font-size: 20px;
  }

  .review-center-heading > p {
    max-width: 145px;
    font-size: 10.5px;
  }

  .review-dashboard {
    gap: 8px;
  }

  .review-stat {
    min-height: 151px;
    padding: 14px 13px 13px 15px;
    border-radius: 14px;
  }

  .review-stat-label {
    font-size: 10.5px;
    letter-spacing: 0.04em;
  }

  .review-stat strong {
    font-size: 36px;
  }

  .review-stat small {
    min-height: 36px;
    font-size: 10.5px;
    line-height: 1.55;
  }

  .review-stat-action {
    padding-top: 4px;
    font-size: 10.5px;
  }

  .mastery-panel {
    padding: 14px 12px 8px;
    border-radius: 14px;
  }

  .mastery-heading {
    padding: 0 2px 10px;
  }

  .mastery-heading h3 {
    font-size: 15px;
  }

  .mastery-heading > span {
    max-width: 150px;
    font-size: 10px;
  }

  .mastery-row {
    grid-template-columns: 22px minmax(0, 1fr) 40px;
    gap: 4px 8px;
    min-height: 65px;
    padding: 9px 2px;
  }

  .mastery-copy {
    gap: 2px;
  }

  .mastery-copy strong {
    font-size: 11.5px;
  }

  .mastery-copy small {
    font-size: 9.5px;
  }

  .mastery-meter {
    grid-column: 2 / 3;
    width: 100%;
  }

  .mastery-label {
    grid-row: 1 / 3;
    grid-column: 3;
    align-self: center;
    font-size: 10px;
  }

  .mobile-chapter-nav {
    margin: 0 -12px 18px;
    padding: 7px 12px;
  }

  .mobile-chapter-link {
    min-height: 44px;
    padding: 0 13px;
    font-size: 11px;
  }

  .search-status {
    padding: 12px;
    font-size: 12px;
  }

  .search-filter {
    min-width: 66px;
    min-height: 42px;
  }

  .chapter-section {
    margin-bottom: 42px;
  }

  .chapter-heading {
    align-items: flex-start;
    padding-bottom: 12px;
  }

  .chapter-heading-copy {
    gap: 10px;
  }

  .chapter-heading h2 {
    font-size: 26px;
  }

  .chapter-heading-meta {
    padding-top: 6px;
    font-size: 9px;
  }

  .long-divider {
    margin: 18px 0 20px;
  }

  .parts {
    gap: 26px;
  }

  .part-title h3 {
    max-width: calc(100vw - 130px);
  }

  .part-toggle {
    min-height: 44px;
    padding: 0 2px 0 12px;
    font-size: 11.5px;
  }

  .kp-toggle {
    grid-template-columns: 27px minmax(0, 1fr) 18px;
    gap: 6px;
    min-height: 58px;
    padding: 12px 7px 12px 12px;
  }

  .kp-title {
    font-size: 13px;
    line-height: 1.55;
  }

  .recall-total {
    min-width: 40px;
    margin: 8px 8px 8px 0;
  }

  .chevron {
    width: 20px;
    height: 20px;
  }

  .answer {
    padding: 17px 14px 18px 29px;
  }

  .answer::before {
    left: 16px;
  }

  .answer-block,
  .subnode > .answer-block {
    font-size: 12.5px;
    line-height: 1.8;
  }

  .subnode {
    margin-top: 10px;
    padding: 9px 10px 10px;
  }

  .subnode-title {
    font-size: 12px;
  }

  .rating-panel {
    margin: 0 12px 14px;
    padding: 12px;
    border-radius: 11px;
  }

  .rating-panel-heading {
    margin-bottom: 9px;
  }

  .rating-panel-heading span {
    font-size: 10px;
  }

  .rating-grid {
    gap: 6px;
  }

  .rating-button {
    min-height: 46px;
    gap: 5px;
    padding: 0 6px;
    font-size: 11.5px;
  }

  .rating-button .icon {
    width: 16px;
    height: 16px;
  }

  .page-footer {
    display: grid;
    gap: 3px;
    font-size: 10px;
  }

  .back-to-top {
    right: 12px;
    bottom: max(76px, calc(env(safe-area-inset-bottom) + 68px));
  }

  .jump-to-rating {
    right: auto;
    bottom: max(76px, calc(env(safe-area-inset-bottom) + 68px));
    left: 12px;
    min-width: 92px;
    min-height: 44px;
  }

  .rating-undo {
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .toast {
    bottom: max(136px, calc(env(safe-area-inset-bottom) + 128px));
  }

  .random-dialog {
    width: min(calc(100vw - 24px), 640px);
    max-width: 640px;
    max-height: min(82dvh, 720px);
    margin: auto;
    border-width: 1px;
    border-radius: 24px;
  }

  .goal-dialog {
    width: min(calc(100vw - 24px), 500px);
  }

  .goal-header {
    padding: 15px 16px 13px;
  }

  .goal-header h2 {
    font-size: 22px;
  }

  .goal-main {
    gap: 10px;
    padding: 16px;
  }

  .goal-setting-row {
    min-height: 78px;
    gap: 10px;
    padding: 12px;
  }

  .goal-stepper {
    grid-template-columns: 44px 40px 44px;
  }

  .goal-stepper button {
    width: 44px;
    height: 44px;
  }

  .goal-footer {
    padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  }

  .sheet-handle {
    display: none;
  }

  .random-sheet {
    min-height: 0;
  }

  .random-header {
    padding: 13px 16px 12px;
  }

  .random-close {
    width: 44px;
    height: 44px;
  }

  .random-main {
    min-height: 0;
    flex: 1;
    padding: 20px 18px 16px;
  }

  .random-title {
    font-size: 24px;
  }

  .random-answer {
    margin-top: 20px;
    padding-top: 17px;
  }

  .random-answer .answer {
    padding-left: 20px;
  }

  .random-answer .answer::before {
    left: 4px;
  }

  .random-footer {
    padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  }

  .random-primary {
    min-height: 48px;
    padding: 0 14px;
    font-size: 12px;
  }

  .random-result-heading {
    gap: 7px;
  }

  .random-result-heading .recall-chip {
    padding-inline: 6px;
  }

  .random-next {
    min-height: 46px;
  }
}

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

@media print {
  .topbar,
  .hero-actions,
  .chapter-sidebar,
  .mobile-chapter-nav,
  .recall-total,
  .rating-panel,
  .study-cover,
  .back-to-top,
  .toast,
  .page-footer {
    display: none !important;
  }

  body {
    background: white;
  }

  #main {
    width: 100%;
  }

  .workspace {
    display: block;
  }

  .kp-body {
    display: block !important;
  }

  .kp-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
