:root {
  color-scheme: light;
  --page: #f3f6f4;
  --surface: #ffffff;
  --surface-soft: #eaf1ed;
  --text: #182721;
  --muted: #64726b;
  --line: #d6dfda;
  --green: #236c54;
  --green-dark: #174c3b;
  --green-soft: #dceee5;
  --coral: #b74d3e;
  --coral-soft: #fbe8e3;
  --amber: #9a6714;
  --amber-soft: #f7edcf;
  --focus: #d59220;
}

html.dark {
  color-scheme: dark;
  --page: #171f1b;
  --surface: #202b25;
  --surface-soft: #293a31;
  --text: #edf4ef;
  --muted: #aebdb3;
  --line: #3b4c42;
  --green: #8bd1af;
  --green-dark: #b7e6cd;
  --green-soft: #29483a;
  --coral: #ff9a84;
  --coral-soft: #492c27;
  --amber: #e5bc68;
  --amber-soft: #493c25;
  --focus: #f0c876;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}
button, input, select { font: inherit; }
button, select, input { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.topbar {
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 max(24px, calc((100vw - 1160px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; width: fit-content; text-decoration: none; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 6px; background: var(--green); color: white; font-family: Georgia, serif; font-size: 20px; }
.topbar nav { display: flex; align-items: center; gap: 24px; height: 58px; }
.topbar nav a, .account-link { color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar nav a.active { color: var(--green-dark); font-weight: 700; border-bottom: 2px solid var(--green); padding: 18px 2px 16px; }
.account-link { justify-self: end; }
.page { max-width: 1160px; margin: 0 auto; padding: 28px 24px 56px; }
.page-heading, .section-heading, .form-footer, .today-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.page-heading { margin-bottom: 18px; }
.page-heading time { color: var(--muted); font-size: 14px; }
.eyebrow { margin: 0 0 4px; color: var(--green); font-size: 11px; font-weight: 750; letter-spacing: .08em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; line-height: 1.2; }
h2 { margin: 0; font-size: 18px; line-height: 1.3; }
h3 { margin: 0; font-size: 17px; }
.notice { margin: 0 0 14px; padding: 10px 13px; border-left: 3px solid var(--amber); background: var(--amber-soft); color: var(--text); font-size: 14px; }
.notice[data-kind="error"] { border-color: var(--coral); background: var(--coral-soft); }
.retry-row { margin: -6px 0 12px; }
.today-strip { display: grid; grid-template-columns: 1fr 1fr 1.3fr auto; align-items: center; gap: 22px; padding: 15px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.today-strip > div:not(.today-actions) { display: grid; gap: 2px; }
.metric-label, .status-text, .muted { color: var(--muted); font-size: 13px; }
.today-strip strong { font-size: 15px; font-weight: 650; }
.today-actions { justify-content: end; gap: 8px; }
.button { min-height: 38px; padding: 8px 13px; border: 1px solid transparent; border-radius: 5px; cursor: pointer; font-weight: 650; transition: background-color .15s ease, border-color .15s ease; }
.button:disabled { opacity: .48; cursor: not-allowed; }
.button-primary { background: var(--green); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--green-dark); }
.button-secondary { background: var(--amber-soft); color: var(--text); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.button-quiet { background: var(--surface); border-color: var(--line); color: var(--text); }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); cursor: pointer; font-size: 23px; line-height: 1; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); column-gap: 44px; row-gap: 34px; margin-top: 30px; }
.plan-section, .books-section, .learning-section { min-width: 0; }
.section-heading { margin-bottom: 18px; }
.plan-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; padding: 17px 0 20px; border-top: 1px solid var(--line); }
.field { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.field input, .field select { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--text); }
.book-options { display: grid; gap: 16px; }
.book-choice { padding: 12px 0 15px; border: 0; border-top: 1px solid var(--line); min-width: 0; }
.book-choice legend { float: left; width: 100%; padding: 0 0 9px; font-size: 15px; font-weight: 700; }
.book-choice legend + * { clear: both; }
.book-choice-head { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding-top: 2px; }
.book-choice-head label { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; }
.book-choice-head select { min-height: 34px; max-width: 170px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.range-options { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.range-selection-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.range-selection-tools span { margin-right: auto; color: var(--muted); font-size: 12px; }
.range-options label { display: inline-flex; align-items: flex-start; gap: 6px; color: var(--muted); font-size: 13px; }
.range-panel { margin-top: 10px; color: var(--muted); font-size: 13px; }
.entry-options { max-height: 260px; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.book-choice.is-disabled .range-type-field, .book-choice.is-disabled .range-panel { opacity: .55; }
input[type="checkbox"] { accent-color: var(--green); }
.form-footer { margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--line); }
.form-footer .muted { margin: 0; }
.learning-section { grid-column: 1; grid-row: 2; }
.learning-card { min-height: 230px; padding: 22px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.encounter-topline { display: flex; align-items: start; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.encounter-book { color: var(--muted); font-size: 12px; }
.word-title { margin: 10px 0 5px; font-size: clamp(23px, 1.4rem, 28px); overflow-wrap: anywhere; }
.word-prompt { margin: 18px 0; color: var(--muted); font-size: 14px; }
.example-prompt { margin: 16px 0; padding: 12px 14px; border-left: 3px solid var(--amber); background: var(--amber-soft); font-size: 15px; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.option-button { min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); text-align: left; cursor: pointer; }
.option-button:hover { border-color: var(--green); background: var(--green-soft); }
.option-button[data-state="selected"] { border-color: var(--coral); background: var(--coral-soft); color: var(--coral); }
.option-button[data-state="correct"] { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
.choice-actions, .detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.feedback-line { margin: 14px 0 0; padding: 9px 11px; background: var(--surface-soft); color: var(--text); font-size: 14px; }
.detail-block { margin: 3px 0 8px; }
.detail-ipa { margin: 3px 0 12px; color: var(--muted); font-size: 14px; }
.sense-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.sense-list li { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; background: transparent; font-size: 17px; }
.sense-list .sense-priority { color: var(--muted); }
.detail-example { margin: 14px 0; }
.detail-example strong { display: block; margin-bottom: 3px; color: var(--muted); font-size: 12px; }
.extension-group { margin-top: 12px; }
.extension-group h4 { margin: 0 0 4px; font-size: 13px; }
.extension-group p { margin: 0; color: var(--muted); font-size: 13px; }
.audio-state { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.learning-result { display: grid; place-items: center; min-height: 175px; text-align: center; }
.learning-result p { margin: 8px 0 16px; color: var(--muted); }
.books-section { grid-column: 2; grid-row: 1 / span 2; }
.book-progress { display: grid; gap: 12px; }
.progress-book { padding: 13px 0; border-top: 1px solid var(--line); }
.progress-book-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.progress-book-title strong { font-size: 14px; }
.progress-book-title span { color: var(--muted); font-size: 12px; }
.progress-stages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.progress-stages span { display: flex; align-items: center; justify-content: center; min-height: 25px; border-radius: 3px; background: var(--surface-soft); color: var(--muted); font-size: 11px; }
.progress-stages span[data-active="true"] { background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
.progress-details { margin-top: 10px; border-top: 1px solid var(--line); }
.progress-details summary { padding: 9px 0; color: var(--muted); font-size: 13px; cursor: pointer; }
.entry-progress-list { display: grid; gap: 0; }
.progress-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.progress-entry-copy { display: grid; min-width: 0; gap: 2px; }
.progress-entry-copy strong { font-size: 13px; overflow-wrap: anywhere; }
.progress-entry-copy span { color: var(--muted); font-size: 11px; }
.progress-entry-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 5px; }
.progress-entry-actions .button { min-height: 32px; padding: 5px 8px; font-size: 12px; }
.audio-state + audio { display: block; width: min(100%, 360px); margin-top: 7px; }
.retired-list { display: grid; gap: 5px; margin-top: 10px; }
.retired-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.retired-row button { border: 0; background: transparent; color: var(--green); text-decoration: underline; cursor: pointer; }
.empty-state { padding: 14px 0; color: var(--muted); font-size: 14px; }
.book-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .55fr); gap: 10px; margin: 12px 0 18px; }
.book-filters label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.book-filters input, .book-filters select { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--text); }
.progress-entry-actions a { display: inline-flex; align-items: center; text-decoration: none; }
.module-nav a[aria-current="page"] { color: var(--green-dark); font-weight: 700; text-decoration-thickness: 2px; }

@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr auto; padding: 0 16px; }
  .topbar nav { grid-column: 1 / -1; grid-row: 2; justify-content: center; height: 40px; }
  .topbar .account-link { grid-column: 2; grid-row: 1; }
  .topbar nav a.active { padding: 9px 2px 7px; }
  .page { padding: 22px 16px 40px; }
  .today-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
  .today-actions { grid-column: 1 / -1; justify-content: stretch; }
  .today-actions button { flex: 1; }
  .home-plan-card { align-items: flex-start; flex-direction: column; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 28px; margin-top: 24px; }
  .books-section, .learning-section { grid-column: 1; grid-row: auto; }
  .learning-card { padding: 17px; }
  .progress-entry { grid-template-columns: minmax(0, 1fr); }
  .progress-entry-actions { justify-content: start; }
  .sense-list li { gap: 6px; }
  .form-footer { align-items: flex-start; }
}

@media (max-width: 420px) {
  h1 { font-size: 25px; }
  .plan-settings { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; }
  .book-filters { grid-template-columns: 1fr; }
}

.learning-workspace { display: block; max-width: 860px; margin: 0 auto; }
.learning-workspace .learning-section { width: 100%; }

.module-nav, .plan-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.module-nav a { color: var(--green); }
.plan-workspace { display: block; max-width: 1000px; }
.plan-card { padding: 18px; border: 1px solid var(--line); border-radius: 12px; margin: 12px 0; background: var(--surface); }
.plan-card h2 { font-size: 20px; }
.plan-card small { color: var(--muted); font-size: 14px; }
.detail-example > span { display: block; margin-top: 8px; line-height: 1.7; }
.sense-list .sense-meaning { min-width: 0; overflow-wrap: anywhere; }
.sense-priority:empty { display: none; }
.home-workspace { display: block; }
.home-plan-card { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.home-plan-card h2 { margin: 0 0 8px; font-size: 16px; }
.home-plan-card strong { font-size: 18px; }
.home-plan-card p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
button[aria-disabled="true"] { opacity: .6; cursor: default; }
#entry-dialog { width: min(680px, calc(100% - 32px)); max-height: 85vh; overflow: auto; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
