:root {
  color-scheme: light;
  --canvas: #f7f6f1;
  --paper: #ffffff;
  --ink: #24302a;
  --muted: #69766f;
  --line: #d8ded9;
  --green: #23664f;
  --green-soft: #e3eee8;
  --yellow: #f0c94b;
  --red: #ad4e42;
  --red-soft: #f7e4e0;
  --blue: #336b87;
  --shadow: 0 10px 28px rgba(36, 48, 42, 0.07);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100svh;
  font-size: 16px;
  overscroll-behavior-y: none;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(51, 107, 135, 0.34);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100svh;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) calc(104px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.site-footer {
  margin: 28px auto 0;
  padding: 0 8px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--blue);
  text-decoration: underline;
}

.page {
  width: min(100%, 920px);
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 15px;
}

.brand-icon {
  width: 52px;
  height: 52px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--yellow);
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-top: 4px;
  font-size: 30px;
  line-height: 1.18;
}

.section-title {
  margin: 34px 0 14px;
  font-size: 18px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 52px;
  padding: 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 8px;
  font-weight: 750;
}

.primary-button {
  background: var(--green);
  color: #fff;
}

.secondary-button {
  background: var(--paper);
  border: 1px solid #c7d0ca;
}

.danger-button {
  background: var(--paper);
  color: var(--red);
  border: 1px solid #d8aaa4;
}

.icon-button {
  width: 46px;
  height: 46px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 50%;
}

.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.today-panel {
  margin-top: 28px;
  padding: 26px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.today-topline,
.library-line,
.setting-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.panel-label,
.muted,
.stat-label,
.setting-note {
  color: var(--muted);
  font-size: 13px;
}

.panel-title {
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.4;
  font-weight: 800;
}

.due-count {
  flex: 0 0 58px;
  height: 58px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 50%;
  font-size: 22px;
  font-weight: 850;
}

.panel-note {
  margin: 18px 0 22px;
  color: #536059;
  font-size: 14px;
}

.wide-button {
  width: 100%;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
}

.stat-block {
  padding: 22px 10px;
  text-align: center;
  border-right: 1px solid var(--line);
}

.stat-block:last-child {
  border-right: 0;
}

.stat-number {
  font-size: 25px;
  font-weight: 850;
}

.stat-label {
  margin-top: 5px;
}

.progress-track {
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
  background: #dce1dc;
  border-radius: 4px;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  transition: width 250ms ease;
}

.quick-grid {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.quick-action {
  min-height: 86px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 15px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.quick-symbol {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 8px;
}

.quick-title {
  display: block;
  font-weight: 800;
}

.quick-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 76px;
  padding: 6px max(12px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid #dde2de;
  backdrop-filter: blur(14px);
}

.nav-item {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  color: #748078;
  font-size: 11px;
}

.nav-item.active {
  color: var(--green);
  font-weight: 800;
}

.nav-item .icon {
  width: 21px;
  height: 21px;
}

.search-box {
  height: 52px;
  margin-top: 24px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-box input {
  min-width: 0;
  flex: 1;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.category-row {
  margin-top: 16px;
  padding-bottom: 5px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-row::-webkit-scrollbar {
  display: none;
}

.category-button,
.segment {
  min-height: 38px;
  padding: 0 16px;
  flex: 0 0 auto;
  background: transparent;
  color: #5d6962;
  border: 1px solid #c9d1cc;
  border-radius: 8px;
  font-size: 13px;
}

.category-button.selected,
.segment.selected {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.result-count {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.word-list,
.mistake-list {
  margin-top: 6px;
}

.word-row,
.mistake-row {
  min-height: 92px;
  padding: 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border-bottom: 1px solid var(--line);
}

.word-main {
  min-width: 0;
}

.word-title,
.mistake-word {
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 800;
}

.phonetic {
  margin-top: 5px;
  color: var(--blue);
  font-family: "Arial Unicode MS", Arial, sans-serif;
  font-size: 14px;
}

.word-meaning,
.mistake-meaning {
  margin-top: 5px;
  line-height: 1.45;
  font-size: 15px;
}

.word-meta {
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
}

.word-actions {
  flex: 0 0 82px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.mastery-badge {
  width: 38px;
  color: #8a5b2c;
  text-align: right;
  font-size: 11px;
  font-weight: 800;
}

.mastery-badge.known {
  color: var(--green);
}

.load-more {
  width: 100%;
  margin-top: 22px;
}

.empty-state {
  padding: 70px 22px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.practice-shell {
  min-height: 100svh;
  padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.practice-page {
  width: min(100%, 760px);
  margin: 0 auto;
}

.practice-topbar {
  height: 52px;
  display: grid;
  grid-template-columns: 48px 1fr 56px;
  align-items: center;
  gap: 16px;
}

.close-button {
  background: transparent;
  color: var(--muted);
}

.top-progress {
  height: 8px;
  overflow: hidden;
  background: #dce1dc;
  border-radius: 4px;
}

.counter {
  color: var(--muted);
  text-align: right;
  font-size: 13px;
}

.practice-content {
  margin: 38px auto 0;
  padding-bottom: 128px;
  text-align: center;
}

.mode-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.word-large,
.question-word {
  margin-top: 34px;
  overflow-wrap: anywhere;
  font-size: 44px;
  line-height: 1.2;
  font-weight: 850;
}

.question-word {
  font-size: 36px;
}

.audio-button {
  margin-top: 24px;
}

.meaning-large,
.meaning-prompt {
  margin-top: 34px;
  font-size: 25px;
  line-height: 1.5;
  font-weight: 800;
}

.category-line,
.related {
  margin-top: 13px;
  color: var(--muted);
  font-size: 13px;
}

.answer-button {
  width: 100%;
  margin-top: 40px;
}

.prompt {
  color: var(--muted);
  font-size: 15px;
}

.round-audio {
  width: 88px;
  height: 88px;
  margin-top: 30px;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
}

.round-audio .icon {
  width: 36px;
  height: 36px;
}

.option-list {
  margin-top: 34px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.option {
  min-height: 64px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: var(--paper);
  border: 1px solid #d0d7d2;
  border-radius: 8px;
  text-align: left;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.option.correct,
.spelling-input.correct {
  background: #e0f0e7;
  border-color: #3a805f;
}

.option.wrong,
.spelling-input.wrong {
  background: var(--red-soft);
  border-color: #bd5b4f;
}

.spelling-input {
  width: 100%;
  height: 66px;
  margin-top: 34px;
  padding: 0 18px;
  background: var(--paper);
  border: 2px solid #9eaaa3;
  border-radius: 8px;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
}

.feedback-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px max(24px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: #dcefe4;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.feedback-bar.needs-work {
  background: var(--red-soft);
}

.feedback-inner {
  width: min(100%, 760px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 180px;
  align-items: center;
  gap: 20px;
}

.feedback-title {
  font-size: 19px;
  font-weight: 850;
}

.feedback-answer {
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: #6b514c;
  font-size: 14px;
}

.complete-stage {
  margin: 100px auto 0;
  text-align: center;
}

.complete-mark,
.empty-mark {
  width: 86px;
  height: 86px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
}

.complete-mark .icon,
.empty-mark .icon {
  width: 40px;
  height: 40px;
}

.complete-title {
  margin-top: 30px;
  font-size: 28px;
}

.complete-note {
  margin-top: 10px;
  color: var(--muted);
}

.result-line {
  margin-top: 36px;
  padding: 24px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-block: 1px solid var(--line);
}

.result-number,
.result-label {
  display: block;
}

.result-number {
  font-size: 30px;
  font-weight: 850;
}

.result-label {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.finish-button {
  width: min(100%, 420px);
  margin-top: 32px;
}

.mistake-summary {
  margin-top: 26px;
  padding: 24px 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  border-block: 1px solid var(--line);
}

.summary-number {
  color: var(--red);
  font-size: 38px;
  font-weight: 850;
}

.mistake-score {
  flex: 0 0 86px;
  color: var(--red);
  text-align: right;
  font-size: 13px;
  font-weight: 800;
}

.mistake-score span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.setting-section {
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}

.setting-title {
  font-size: 17px;
  font-weight: 800;
}

.setting-note {
  margin-top: 5px;
}

.segmented {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid #c9d1cc;
  border-radius: 8px;
  overflow: hidden;
}

.segmented.two {
  grid-template-columns: 1fr 1fr;
}

.segment {
  min-height: 46px;
  border: 0;
  border-right: 1px solid #c9d1cc;
  border-radius: 0;
}

.segment:last-child {
  border-right: 0;
}

.category-input,
.import-textarea,
.pin-input {
  width: 100%;
  background: var(--paper);
  border: 1px solid #cbd3ce;
  border-radius: 8px;
}

.category-input,
.pin-input {
  height: 50px;
  margin-top: 16px;
  padding: 0 15px;
}

.import-textarea {
  min-height: 180px;
  margin-top: 10px;
  padding: 14px 15px;
  resize: vertical;
  line-height: 1.6;
}

.button-row {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.text-button {
  padding: 8px 0;
  background: transparent;
  color: var(--red);
  font-size: 13px;
}

.lock-panel {
  width: min(100%, 440px);
  margin: 80px auto 0;
  text-align: center;
}

.lock-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 24px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 8px;
}

.pin-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.pin-row .pin-input {
  margin: 0;
}

.dialog-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  padding: 24px;
  display: grid;
  place-items: center;
  background: rgba(20, 29, 24, 0.48);
}

.dialog {
  width: min(100%, 470px);
  max-height: calc(100svh - 48px);
  overflow: auto;
  padding: 26px;
  background: var(--paper);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.2);
}

.dialog h2 {
  font-size: 22px;
}

.dialog p,
.dialog li {
  color: #4f5c55;
  line-height: 1.65;
}

.dialog ol {
  margin: 18px 0 24px;
  padding-left: 24px;
}

.toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  max-width: calc(100% - 48px);
  padding: 12px 18px;
  transform: translateX(-50%);
  background: #24302a;
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 14px;
}

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

@media (min-width: 900px) {
  .home-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 28px;
    align-items: start;
  }

  .home-grid .today-panel {
    grid-row: span 2;
  }

  .home-grid .section-title {
    margin-top: 0;
  }

  .words-page .word-list,
  .mistake-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 30px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding-inline: 18px;
  }

  .brand-icon {
    width: 46px;
    height: 46px;
  }

  h1 {
    font-size: 27px;
  }

  .quick-grid,
  .option-list {
    grid-template-columns: 1fr;
  }

  .word-large,
  .question-word {
    font-size: 34px;
  }

  .feedback-inner {
    grid-template-columns: 1fr 128px;
  }

  .mistake-summary {
    grid-template-columns: auto 1fr;
  }

  .mistake-summary .primary-button {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
