:root {
  color-scheme: light;
  --paper: #f5f7f3;
  --white: #fff;
  --text: #192b24;
  --muted: #596b61;
  --line: #dbe3da;
  --green: #236347;
  --green-dark: #183e2e;
  --green-light: #eaf3e6;
  --focus: #296c55;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  color: var(--text);
  background: var(--paper);
  font-size: 16px;
  letter-spacing: 0;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body { margin: 0; min-width: 0; }
h1, h2, h3, p, dl, dd, dt, ul { margin: 0; }
ul { list-style: none; padding: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
a { color: var(--green); text-underline-offset: 3px; }
button, a, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
svg { display: block; inline-size: 1.13rem; block-size: 1.13rem; flex: none; }
.muted, .empty-state { color: var(--muted); font-size: .82rem; }

.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.header-inner, .shell {
  width: min(100%, 76rem);
  margin-inline: auto;
  padding-inline: max(2rem, env(safe-area-inset-left)) max(2rem, env(safe-area-inset-right));
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 5rem; gap: 1rem; }
.brand, .header-actions { display: flex; align-items: center; gap: .7rem; }
.brand { min-width: 0; }
.brand h1 { font-size: 1.16rem; font-weight: 730; line-height: 1.35; }
.brand span[lang] { display: block; color: var(--muted); font-size: .68rem; font-weight: 700; line-height: 1.35; }
.brand-icon { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: 0 0 2.5rem; background: var(--green-dark); color: #fff; border-radius: 8px; }
.brand-icon svg { width: 1.35rem; height: 1.35rem; }
.utility, .icon-button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .48rem;
  min-height: 44px;
  padding-inline: .85rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: .86rem;
  font-weight: 650;
}
.icon-button { width: 44px; height: 44px; padding: 0; flex: 0 0 44px; }
.secondary { color: var(--green-dark); }
.utility:not(:disabled):hover, .icon-button:not(:disabled):hover, .secondary:not(:disabled):hover { background: var(--green-light); border-color: #a7bfab; }

.shell { padding-block: 1.75rem max(1.4rem, env(safe-area-inset-bottom)); }
.band-label, .section-head, .section-title, .section-actions, .side-heading { display: flex; align-items: center; }
.band-label, .section-head, .side-heading { justify-content: space-between; }
.band-label { margin-bottom: .65rem; }
.band-label h2 { color: var(--muted); font-size: .83rem; }
.books { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; }
.book-tab {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .4rem;
  min-height: 4.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: .65rem 1.05rem;
  text-align: left;
  min-width: 0;
}
.book-tab small { display: block; color: var(--muted); font-size: .72rem; font-weight: 700; line-height: 1.35; }
.book-tab strong { font-size: 1.01rem; line-height: 1.4; }
.book-tab[aria-pressed="true"] { border-color: #548568; background: var(--green-light); box-shadow: inset 0 -2px #548568; color: var(--green-dark); }
.book-tab:not(:disabled):hover { border-color: #548568; }
.book-count { color: var(--muted); font-size: .75rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 24%); column-gap: 2rem; margin-top: 1.55rem; }
.study, .side { min-width: 0; }
.section-head { gap: .4rem; margin-bottom: .65rem; }
.section-title { gap: .7rem; }
.section-title h2 { font-size: 1.05rem; }
.counter { font-size: .76rem; line-height: 1.7; color: var(--green-dark); font-weight: 680; background: #e7eee7; border-radius: 4px; padding-inline: .47rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.section-actions { gap: .4rem; }
.word-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--white); padding: 1.15rem; min-width: 0; }
.word-meta { display: flex; justify-content: space-between; align-items: center; min-height: 1.7rem; gap: .5rem; color: var(--muted); font-weight: 650; font-size: .77rem; }
#deck-label { color: var(--green-dark); background: var(--green-light); padding: .26rem .46rem; border-radius: 4px; }
#word-state[data-tone="warm"] { color: #83501a; }
#word-state[data-tone="strong"] { color: var(--green); }
.word-main { display: grid; align-content: center; justify-items: center; gap: .65rem; min-height: 13rem; padding: 1rem .65rem; text-align: center; min-width: 0; }
#word { max-width: 100%; color: #182b22; font: 600 3.65rem/1.08 Georgia, 'Times New Roman', serif; overflow-wrap: anywhere; letter-spacing: 0; }
#word[data-ready="false"] { font: 660 1.55rem/1.35 system-ui, -apple-system, sans-serif; }
.pronunciation { display: flex; justify-content: center; align-items: center; gap: .58rem; max-width: 100%; }
#phonetic { min-width: 0; color: var(--muted); overflow-wrap: anywhere; font-family: 'Arial Unicode MS', system-ui, sans-serif; }
.sound { background: var(--green-light); color: var(--green-dark); border-color: #dce9dc; }
.meaning { min-height: 4.1rem; border: 1px solid #e1e8df; border-radius: 7px; background: #f6f8f4; }
.reveal { display: flex; align-items: center; justify-content: center; gap: .55rem; width: 100%; min-height: 4rem; background: transparent; border: 0; border-radius: 6px; color: var(--green-dark); font-weight: 650; font-size: .92rem; }
.reveal:not(:disabled):hover { background: #eaf1e7; }
.definition { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: .5rem; align-items: start; padding: .52rem .6rem .52rem .9rem; min-height: 4rem; }
.definition ul { align-self: center; padding-block: .28rem; font-size: .94rem; line-height: 1.55; overflow-wrap: anywhere; }
.definition li + li { margin-top: .3rem; }
.definition .icon-button { background: transparent; }

.feedback { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-top: .75rem; }
.feedback button {
  --rating-bg: #fff;
  --rating-border: var(--line);
  --rating-ink: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 3.6rem;
  padding: .4rem;
  color: var(--rating-ink);
  background: var(--rating-bg);
  border: 1px solid var(--rating-border);
  border-radius: 7px;
  font-size: .97rem;
  font-weight: 700;
}
.feedback button:not(:disabled):hover { border-color: var(--rating-ink); }
.feedback button i { border-radius: 50%; width: .46rem; height: .46rem; background: currentColor; flex: 0 0 .46rem; }
.feedback button[data-grade="again"] { --rating-bg: #f9ebea; --rating-border: #e8cbc6; --rating-ink: #8b3731; }
.feedback button[data-grade="hard"] { --rating-bg: #fbf2df; --rating-border: #eadcba; --rating-ink: #774715; }
.feedback button[data-grade="good"] { --rating-bg: #e8f2ee; --rating-border: #cbe0d5; --rating-ink: #215c46; }
.feedback button[data-grade="easy"] { --rating-bg: #e8eef6; --rating-border: #cddbef; --rating-ink: #32516e; }

.side { border-left: 1px solid var(--line); padding-left: 1.3rem; }
.side-section { padding-block: .83rem 1.1rem; border-bottom: 1px solid var(--line); }
.side-heading { gap: .35rem; margin-bottom: .72rem; }
.side-heading h2 { font-size: .94rem; }
.learned-line { color: var(--muted); font-size: .83rem; }
.learned-line strong { color: var(--text); font-size: 1.8rem; font-weight: 720; font-variant-numeric: tabular-nums; }
progress { display: block; width: 100%; height: .42rem; margin-block: .6rem .95rem; border: 0; border-radius: 4px; background: #dfe8df; overflow: hidden; accent-color: var(--green); }
progress::-webkit-progress-bar { background: #dfe8df; }
progress::-webkit-progress-value { background: var(--green); }
progress::-moz-progress-bar { background: var(--green); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; font-variant-numeric: tabular-nums; }
.stats dt { color: var(--muted); font-size: .73rem; }
.stats dd { margin-top: .15rem; font-size: 1.1rem; font-weight: 700; }
.mini-count { color: var(--green-dark); background: #e7eee7; padding: .1rem .38rem; border-radius: 4px; font-size: .74rem; }
.memorizing-list { max-height: 17.5rem; overflow: auto; }
.memorizing-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .5rem; padding-block: .3rem; }
.memorizing-list li + li { border-top: 1px solid var(--line); }
.word-link { min-height: 44px; background: transparent; border: 0; border-radius: 5px; padding: .3rem .35rem; color: var(--green-dark); font-weight: 650; text-align: left; overflow-wrap: anywhere; }
.word-link:hover { background: var(--green-light); }
.mini-button { min-height: 44px; background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: .25rem .5rem; color: var(--green-dark); font-weight: 650; white-space: nowrap; font-size: .77rem; }
.mini-button:hover { background: var(--green-light); }
.recent-list { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; }
.recent-list .word-link { width: 100%; background: #f1ece0; color: #714a22; }
.recent-list .word-link:hover { background: #eee4ce; }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: 1.6rem; padding-top: .9rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }

dialog {
  width: min(38rem, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: inherit;
}
dialog::backdrop { background: rgb(14 32 24 / 51%); }
.dialog-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: .5rem; background: var(--white); border-bottom: 1px solid var(--line); padding: .65rem 1rem; }
.dialog-head h2 { font-size: 1.08rem; }
.dialog-body { padding: .95rem 1rem 1.05rem; }
.search-box { display: flex; align-items: center; gap: .55rem; border: 1px solid var(--line); border-radius: 7px; min-height: 44px; padding-inline: .7rem; color: var(--muted); background: var(--paper); }
.search-box:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.search-box input { min-width: 0; width: 100%; background: transparent; border: 0; outline: 0; min-height: 44px; color: var(--text); }
.search-box input:focus-visible { outline: 0; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-block: .65rem .5rem; }
.filters button { min-height: 44px; padding: .2rem .66rem; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 650; font-size: .83rem; }
.filters button[aria-pressed="true"] { background: var(--green-light); color: var(--green-dark); border-color: #ceddcb; }
#match-count { margin-inline-start: auto; }
.word-rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: .75rem; padding-block: .68rem; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.word-rows strong { display: inline-block; margin-right: .42rem; font-size: 1rem; }
.word-rows p { color: var(--muted); line-height: 1.45; font-size: .81rem; margin-top: .28rem; }
.list-flag { font-size: .72rem; color: var(--muted); }
.more { width: 100%; margin-top: .65rem; }
#preferences { max-width: 28rem; }
.preference-row { display: flex; justify-content: space-between; align-items: center; gap: .68rem; min-height: 3.25rem; border-bottom: 1px solid var(--line); font-size: .91rem; }
.preference-row input[type="number"] { width: 5.1rem; min-height: 44px; padding-inline: .55rem; border: 1px solid var(--line); border-radius: 6px; }
.preference-row input[type="checkbox"] { width: 44px; height: 26px; accent-color: var(--green); }
.backup { padding-block: .9rem; border-bottom: 1px solid var(--line); }
.backup h3 { font-size: .91rem; margin-bottom: .45rem; }
.backup-actions { display: flex; gap: .5rem; }
.inline-status { color: var(--muted); font-size: .79rem; margin-top: .3rem; overflow-wrap: anywhere; }
.danger-row { border-bottom: 0; }
.danger-button { border-color: #e9c7c3; color: #89352b; }
.danger-button:hover { background: #f9ebea; }
.notice { position: fixed; z-index: 4; left: 50%; bottom: max(1.2rem, env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: min(28rem, calc(100% - 2rem)); border-radius: 7px; background: #18372c; color: #fff; padding: .75rem 1rem; font-size: .86rem; line-height: 1.4; text-align: center; overflow-wrap: anywhere; pointer-events: none; }

@media (max-width: 56rem) {
  .header-inner, .shell { padding-inline: max(1.2rem, env(safe-area-inset-left)) max(1.2rem, env(safe-area-inset-right)); }
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(12.5rem, 30%); column-gap: 1.15rem; }
  .side { padding-left: .85rem; }
  #word { font-size: 3.15rem; }
}
@media (max-width: 44rem) {
  .header-inner, .shell { padding-inline: max(.85rem, env(safe-area-inset-left)) max(.85rem, env(safe-area-inset-right)); }
  .header-inner { min-height: 4rem; }
  .shell { padding-top: .95rem; }
  .workspace { grid-template-columns: minmax(0, 1fr); margin-top: .85rem; }
  .side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; border-left: 0; padding-left: 0; margin-top: .8rem; }
  .side-section.summary { grid-column: 1 / -1; }
  .book-tab { min-height: 3.55rem; padding: .45rem .55rem; }
  .book-tab strong { font-size: .9rem; }
  .book-tab small, .book-count { font-size: .67rem; }
  .word-main { min-height: 9.9rem; }
  .word-panel { padding: .75rem; }
  #word { font-size: 2.9rem; }
  .feedback { gap: .41rem; margin-top: .6rem; }
  .feedback button { min-height: 3rem; gap: .3rem; font-size: .88rem; }
}
@media (max-width: 25rem) {
  .brand h1 { font-size: 1rem; }
  .header-actions { gap: .3rem; }
  .utility { width: 44px; padding: 0; }
  .utility span { display: none; }
  .books { gap: .35rem; }
  .book-count { font-size: .62rem; }
  .book-tab { flex-direction: column; align-items: flex-start; justify-content: center; padding: .38rem .48rem; gap: .12rem; }
  #word { font-size: 2.45rem; }
  .word-main { min-height: 8.3rem; }
  .feedback { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side { display: block; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color .13s ease, border-color .13s ease; }
}
