:root {
  color-scheme:light;
  --paper:#f8f7f2;
  --white:#fffefa;
  --ink:#193e3a;
  --muted:#66746b;
  --line:#dce2d6;
  --green:#e5eddf;
  --accent:#b9432e;
  --peach:#f8e2d4;
  --shadow:0 16px 36px #253c3010;
  font-family:"Leelawadee UI","Tahoma",sans-serif;
  color:var(--ink);
  background:var(--paper);
  font-synthesis:none
}

* {
  box-sizing:border-box
}

body {
  margin:0;
  font-size:15px;
  line-height:1.7
}

button,input,select {
  font:inherit
}

button,a,input,select {
  touch-action:manipulation
}

button {
  cursor:pointer
}

button:disabled {
  cursor:not-allowed;
  opacity:.55
}

button {
  color:inherit
}

a {
  color:inherit
}

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

h1 {
  font-size:clamp(27px,3vw,38px);
  line-height:1.4;
  font-weight:650;
  letter-spacing:-.6px
}

h2 {
  font-size:22px;
  line-height:1.4;
  font-weight:650
}

h3 {
  font-size:17px;
  font-weight:650
}

button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible {
  outline:3px solid var(--accent);
  outline-offset:4px
}

button {
  border:0
}

button:hover {
  filter:brightness(.97)
}

[hidden] {
  display:none!important
}

.skip-link {
  position:fixed;
  left:18px;
  top:-80px;
  background:var(--ink);
  color:white;
  padding:10px 18px;
  z-index:20
}

.skip-link:focus {
  top:12px
}

.app-shell {
  display:grid;
  grid-template-columns:224px minmax(0,1fr);
  min-height:100vh
}

.sidebar {
  position:sticky;
  top:0;
  height:100vh;
  padding:32px 23px 24px;
  display:flex;
  flex-direction:column;
  border-right:1px solid var(--line);
  background:#f1f3e9
}

.brand {
  display:flex;
  align-items:center;
  gap:12px;
  text-decoration:none
}

.brand-stamp {
  width:43px;
  height:54px;
  background:var(--ink);
  color:#fff7df;
  border-radius:10px 10px 17px 10px;
  font-family:"KaiTi","STKaiti",serif;
  font-size:22px;
  text-align:center;
  line-height:1.05;
  padding-top:5px
}

.brand strong {
  display:block;
  font-size:24px;
  line-height:1.3;
  letter-spacing:-.8px
}

.brand small {
  display:block;
  color:var(--muted);
  font-size:11px;
  margin-top:4px
}

.navigation {
  display:grid;
  gap:9px;
  margin-top:48px
}

.navigation button {
  display:flex;
  align-items:center;
  text-align:left;
  gap:13px;
  padding:12px 13px;
  border-radius:10px;
  background:transparent;
  font-weight:550;
  font-size:14px
}

.navigation button[aria-current=page] {
  background:var(--ink);
  color:#fffdf3
}

.nav-icon {
  font-family:Arial,sans-serif;
  font-size:24px;
  line-height:1;
  width:25px;
  text-align:center
}

.sidebar-note {
  margin:auto 8px 28px;
  padding-top:40px;
  font-size:13px;
  color:#59705c
}

.sprout {
  display:block;
  color:#839c65;
  font-size:47px;
  line-height:1.3
}

.sidebar-footer {
  border-top:1px solid #d6decd;
  padding-top:17px;
  font-size:12px
}

.sidebar-footer small {
  display:block;
  font-size:10px;
  color:var(--muted);
  margin-top:3px
}

.workspace {
  min-width:0;
  max-width:1390px;
  width:100%;
  padding:0 48px;
  margin:0 auto
}

.topbar {
  height:92px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  border-bottom:1px solid var(--line);
  font-size:13px;
  color:var(--muted);
  gap:16px
}

.local-badge {
  display:inline-flex;
  align-items:center;
  gap:8px
}

.local-badge>span {
  width:7px;
  height:7px;
  background:#6d895d;
  border-radius:100%
}

main {
  padding:34px 0 52px;
  min-height:calc(100vh - 160px)
}

main:focus {
  outline:none
}

.page-heading {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:20px;
  margin-bottom:28px
}

.page-heading p {
  color:var(--muted);
  margin-top:9px;
  font-size:14px
}

.tag {
  display:inline-flex;
  align-items:center;
  border:1px solid #c5d2bd;
  border-radius:30px;
  padding:4px 12px;
  white-space:nowrap;
  font-size:11px;
  font-weight:550
}

.tag.extra {
  background:var(--peach);
  border-color:transparent;
  color:#8f3f29
}

.tag.new {
  color:#2f6546;
  background:#edf4e3;
  border-color:transparent
}

.tag.review {
  background:#edf0f8;
  color:#435778;
  border-color:transparent
}

.button {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  padding:13px 22px;
  border-radius:10px;
  font-weight:600;
  font-size:14px;
  min-height:48px;
  text-decoration:none;
  background:var(--ink);
  color:white
}

.button.secondary {
  background:var(--white);
  color:var(--ink);
  border:1px solid var(--line)
}

.button.light {
  background:#fff8e5;
  color:var(--ink)
}

.button.danger {
  background:#a93529;
  color:white
}

.text-button {
  min-height:44px;
  background:transparent;
  text-decoration:underline;
  text-underline-offset:4px;
  font-size:13px;
  padding:8px;
  color:var(--muted)
}

.dashboard-grid {
  display:grid;
  grid-template-columns:minmax(0,1.75fr) minmax(240px,.9fr);
  gap:24px
}

.daily-panel {
  background:var(--ink);
  color:#fff9e8;
  border-radius:22px;
  padding:30px;
  position:relative;
  overflow:hidden;
  min-height:300px
}

.daily-panel .panel-top {
  display:flex;
  align-items:center;
  gap:9px;
  font-size:12px;
  color:#d5e2c9
}

.daily-panel h2 {
  font-size:28px;
  margin-top:24px;
  position:relative;
  z-index:1;
  max-width:74%
}

.daily-panel p {
  color:#cfddcf;
  font-size:13px;
  max-width:70%;
  margin-top:10px;
  position:relative;
  z-index:1
}

.daily-panel .button {
  margin-top:26px;
  position:relative;
  z-index:1
}

.panel-book {
  position:absolute;
  right:-15px;
  bottom:-35px;
  width:180px;
  height:230px;
  border:1px solid #88a68d;
  border-radius:13px;
  background:#2a5249;
  transform:rotate(15deg);
  display:grid;
  place-items:center;
  color:#e7e5c3;
  font-family:"KaiTi","STKaiti",serif;
  font-size:105px;
  opacity:.65
}

.panel-book:before {
  content:"";
  position:absolute;
  inset:13px;
  border:1px solid #78967b;
  border-radius:6px
}

.today-label {
  display:flex;
  align-items:center;
  gap:8px
}

.small-sun {
  width:17px;
  height:17px;
  border:2px solid #e6cf95;
  border-radius:50%;
  display:inline-block
}

.progress-panel {
  border:1px solid var(--line);
  border-radius:20px;
  background:var(--white);
  padding:24px;
  display:flex;
  flex-direction:column;
  align-items:center;
  text-align:center
}

.progress-panel h3 {
  align-self:flex-start
}

.progress-circle {
  --angle:0deg;
  position:relative;
  display:grid;
  place-items:center;
  width:150px;
  height:150px;
  margin:18px 0 12px;
  background:conic-gradient(#8eab76 var(--angle),#edf0e6 0);
  border-radius:50%
}

.progress-circle:before {
  content:"";
  position:absolute;
  inset:10px;
  background:var(--white);
  border-radius:50%
}

.progress-circle>div {
  position:relative;
  line-height:1.4
}

.progress-circle strong {
  display:block;
  font-size:39px;
  font-weight:500;
  letter-spacing:-1px
}

.progress-circle small {
  font-size:11px;
  color:var(--muted)
}

.progress-panel p {
  font-size:12px;
  color:var(--muted)
}

.daily-counts {
  display:flex;
  gap:0;
  margin-top:26px;
  border-top:1px solid #ffffff2a;
  padding-top:17px;
  position:relative;
  z-index:1;
  max-width:75%
}

.daily-count {
  flex:1;
  display:flex;
  align-items:center;
  gap:10px
}

.daily-count strong {
  font-size:30px;
  font-weight:450;
  line-height:1.4
}

.daily-count span {
  font-size:11px;
  line-height:1.5;
  color:#d5e2c9
}

.daily-count+.daily-count {
  border-left:1px solid #ffffff2a;
  padding-left:20px
}

.section-title {
  margin:32px 0 17px;
  display:flex;
  align-items:center;
  justify-content:space-between
}

.section-title span {
  font-size:12px;
  color:var(--muted)
}

.stats-strip {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:0;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--white);
  padding:24px 0
}

.stat {
  padding:0 24px
}

.stat+.stat {
  border-left:1px solid var(--line)
}

.stat label {
  display:block;
  font-size:12px;
  color:var(--muted)
}

.stat strong {
  display:inline-block;
  font-size:30px;
  line-height:1.5;
  font-weight:500;
  margin-top:7px
}

.stat small {
  font-size:12px;
  color:var(--muted);
  margin-left:6px
}

.tip-row {
  display:flex;
  align-items:flex-start;
  gap:13px;
  margin-top:22px;
  background:#eef1e6;
  padding:17px 20px;
  border-radius:12px;
  font-size:12px;
  color:#4b6550
}

.tip-row>span {
  font-size:21px;
  line-height:1.3
}

.tip-row p+p {
  margin-top:5px
}

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

.peek {
  padding:19px 20px;
  text-align:left;
  border:1px solid var(--line);
  border-radius:13px;
  background:transparent;
  min-width:0
}

.peek strong {
  display:block;
  font-size:32px;
  font-weight:500;
  font-family:"Microsoft YaHei","Noto Serif CJK SC",serif;
  line-height:1.5;
  overflow-wrap:anywhere
}

.peek span {
  font-size:12px;
  color:var(--muted);
  display:block
}

.peek .peek-meaning {
  margin-top:6px;
  color:var(--ink);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis
}

.page-footer {
  border-top:1px solid var(--line);
  padding:19px 0 22px;
  display:flex;
  justify-content:space-between;
  gap:15px;
  font-size:10px;
  color:var(--muted)
}

.study-wrap {
  max-width:780px;
  margin:auto
}

.study-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:15px;
  margin:0 0 16px
}

.study-head .text-button {
  padding-left:0
}

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

.study-progress {
  display:flex;
  gap:5px;
  margin-bottom:26px
}

.study-progress span {
  height:5px;
  background:#dee5d6;
  border-radius:6px;
  flex:1
}

.study-progress span.done {
  background:#6a8b57
}

.study-progress span.current {
  background:#c56749
}

.flashcard {
  background:var(--white);
  border:1px solid #d4ddcc;
  border-radius:22px;
  box-shadow:var(--shadow);
  padding:24px 34px 30px;
  position:relative;
  min-height:370px
}

.card-meta {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px
}

.card-meta .tag {
  font-size:10px
}

.card-no {
  font-size:11px;
  color:var(--muted)
}

.hanzi {
  font-family:"Microsoft YaHei","Noto Serif CJK SC","SimSun",serif;
  font-size:clamp(62px,8vw,90px);
  font-weight:400;
  line-height:1.5;
  text-align:center;
  letter-spacing:3px;
  overflow-wrap:anywhere;
  margin:38px 0 10px
}

.hanzi.long {
  font-size:clamp(31px,5vw,52px);
  letter-spacing:1px
}

.card-pinyin {
  color:var(--accent);
  font-size:clamp(36px,5vw,52px);
  font-weight:500;
  line-height:1.5;
  letter-spacing:normal;
  text-align:center;
  overflow-wrap:anywhere;
  margin:38px 0 10px;
}

.flashcard.revealed .card-pinyin {
  font-size:34px;
  margin:20px 0 5px;
}

.thai-pronunciation {
  text-align:center;
  font-size:19px;
  line-height:1.7;
  overflow-wrap:anywhere;
}

.hanzi-reference {
  text-align:center;
  color:var(--muted);
  font-family:"Microsoft YaHei","Noto Serif CJK SC","SimSun",serif;
  font-size:23px;
  line-height:1.6;
  overflow-wrap:anywhere;
  margin-top:8px;
}

.reference-label {
  font-family:"Leelawadee UI","Tahoma",sans-serif;
  font-size:13px;
  margin-right:8px;
}

.recall-hint {
  text-align:center;
  color:var(--muted);
  font-size:15px;
  margin-top:14px
}

.reveal-button {
  display:flex;
  width:100%;
  margin-top:32px;
  border:1px solid #c5d2bd;
  background:#eaf0e2;
  color:var(--ink);
  gap:18px
}

.key {
  border:1px solid currentColor;
  padding:0 6px;
  border-radius:4px;
  font-size:10px;
  opacity:.65;
  line-height:1.8
}

.pinyin {
  color:var(--accent);
  font-size:23px;
  line-height:1.55;
  text-align:center;
  overflow-wrap:anywhere
}

.meaning {
  text-align:center;
  font-size:19px;
  margin-top:10px
}

.word-tools {
  display:flex;
  align-items:center;
  justify-content:center;
  margin:9px 0 20px;
  gap:12px
}

.sound {
  min-height:44px;
  background:transparent;
  border:1px solid var(--line);
  padding:5px 13px;
  border-radius:30px;
  font-size:14px;
  display:inline-flex;
  align-items:center;
  gap:8px
}

.sound svg {
  width:16px;
  height:16px
}

.example {
  border-top:1px solid var(--line);
  padding-top:21px;
  margin-top:15px
}

.example-label {
  font-size:11px;
  color:var(--muted);
  margin-bottom:9px
}

.example-hanzi {
  font-size:23px;
  line-height:1.6;
  font-family:"Microsoft YaHei",serif;
  overflow-wrap:anywhere
}

.example-pinyin {
  font-size:15px;
  color:#8c4b37;
  margin-top:5px;
  overflow-wrap:anywhere
}

.example-meaning {
  font-size:15px;
  margin-top:8px
}

.thai-reading {
  font-size:15px;
  color:var(--muted);
  margin-top:19px
}

.thai-reading summary {
  min-height:44px;
  padding:9px 0;
  cursor:pointer;
  display:list-item;
  margin-left:16px
}

.thai-reading p {
  padding:8px 0
}

.rating-label {
  text-align:center;
  margin:24px 0 12px;
  font-size:15px;
  color:var(--muted)
}

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

.rating {
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px 8px;
  background:var(--white);
  font-size:14px;
  font-weight:600;
  min-height:70px
}

.rating small {
  display:block;
  font-size:15px;
  font-weight:400;
  margin-top:2px;
  color:var(--muted)
}

.rating.again {
  border-color:#e7c4b7;
  background:#fdf1eb;
  color:#9c3e2a
}

.rating.hard {
  border-color:#e1d8b7;
  background:#fbf6e6;
  color:#785e24
}

.rating.good {
  border-color:#bacaab;
  background:#edf3e5;
  color:#365e30
}

.study-note {
  text-align:center;
  color:var(--muted);
  font-size:11px;
  margin-top:20px
}

.completion {
  text-align:center;
  background:var(--white);
  border:1px solid var(--line);
  border-radius:22px;
  padding:42px 28px
}

.completion-seal {
  display:grid;
  place-items:center;
  width:85px;
  height:85px;
  border-radius:50%;
  background:#e7efdd;
  color:#547542;
  font-size:39px;
  margin:0 auto 23px
}

.completion p {
  font-size:14px;
  color:var(--muted);
  margin:14px auto;
  max-width:420px
}

.completion .button {
  margin-top:12px
}

.completion-results {
  display:flex;
  justify-content:center;
  gap:32px;
  margin:24px 0
}

.completion-results strong {
  font-size:29px;
  display:block;
  font-weight:500
}

.completion-results span {
  font-size:12px;
  color:var(--muted)
}

.library-toolbar {
  display:flex;
  gap:12px;
  margin-bottom:18px
}

.search-box {
  position:relative;
  flex:1
}

.search-box>span {
  position:absolute;
  left:16px;
  top:10px;
  font-size:21px;
  color:var(--muted)
}

input[type=search] {
  background:var(--white);
  border:1px solid var(--line);
  border-radius:10px;
  padding:13px 16px 13px 45px;
  width:100%;
  color:var(--ink);
  min-height:50px
}

select {
  border:1px solid var(--line);
  background:var(--white);
  border-radius:10px;
  padding:10px 30px 10px 14px;
  color:var(--ink);
  max-width:100%
}

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

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

.word-row {
  display:grid;
  grid-template-columns:85px minmax(0,1fr) 25px;
  align-items:center;
  gap:15px;
  padding:17px 18px;
  border-radius:12px;
  border:1px solid var(--line);
  background:var(--white);
  text-align:left;
  min-width:0
}

.word-row .word-hanzi {
  font-family:"Microsoft YaHei",serif;
  font-size:28px;
  line-height:1.4;
  overflow-wrap:anywhere
}

.word-row .word-hanzi.long {
  font-size:20px
}

.word-row .word-pinyin {
  font-size:13px;
  color:var(--accent);
  overflow-wrap:anywhere
}

.word-row .word-meaning {
  display:block;
  font-size:12px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  color:var(--muted);
  margin-top:3px
}

.word-row .word-group {
  font-size:9px;
  display:block;
  margin-top:4px;
  color:var(--muted)
}

.word-status {
  width:23px;
  height:23px;
  border-radius:50%;
  background:#eff2e9;
  color:#5d7c4a;
  text-align:center;
  font-size:12px
}

.pagination {
  display:flex;
  align-items:center;
  justify-content:center;
  gap:22px;
  margin-top:24px;
  font-size:12px
}

.pagination .button {
  min-height:44px;
  padding:8px 18px;
  font-size:12px
}

.empty {
  padding:45px 25px;
  text-align:center;
  color:var(--muted);
  grid-column:1/-1
}

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

.backup-panel {
  border:1px solid var(--line);
  border-radius:17px;
  padding:28px;
  background:var(--white)
}

.backup-symbol {
  font-size:28px;
  color:#6f895d;
  margin-bottom:18px
}

.backup-panel p {
  color:var(--muted);
  font-size:13px;
  margin:12px 0 22px
}

.backup-panel input {
  font-size:12px;
  max-width:100%;
  display:block;
  margin-bottom:15px
}

.backup-panel input::file-selector-button {
  background:#eaf0e2;
  border:0;
  border-radius:7px;
  padding:10px 14px;
  margin-right:10px;
  color:var(--ink);
  cursor:pointer
}

.data-summary {
  margin-bottom:23px;
  padding:17px 20px;
  border-radius:12px;
  background:#ebf0e3;
  font-size:13px
}

.notice {
  margin:20px 0 0;
  padding:14px 18px;
  background:#fff0d7;
  border:1px solid #dfc6a0;
  border-radius:10px;
  color:#684b1d;
  font-size:12px
}

.notice button {
  margin-left:10px
}

.toast {
  position:fixed;
  bottom:25px;
  left:50%;
  transform:translateX(-50%);
  border-radius:10px;
  padding:13px 22px;
  background:var(--ink);
  color:white;
  z-index:30;
  box-shadow:var(--shadow);
  font-size:13px;
  max-width:90vw;
  width:max-content
}

.loading {
  text-align:center;
  padding:80px 20px;
  color:var(--muted)
}

.loading-seal {
  display:block;
  font-family:serif;
  font-size:50px;
  color:#6c875a;
  margin-bottom:10px
}

.error-panel {
  border:1px solid #e6c9ba;
  background:#fff5ee;
  padding:30px;
  border-radius:16px;
  max-width:700px;
  margin:25px auto
}

.error-panel p {
  margin:12px 0 20px;
  font-size:14px;
  color:#755643
}

.error-actions {
  display:flex;
  gap:12px;
  flex-wrap:wrap
}

.subtle {
  color:var(--muted);
  font-size:12px
}

.modal-actions {
  display:flex;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
  margin-top:25px
}

dialog {
  max-width:600px;
  width:calc(100% - 32px);
  max-height:90vh;
  border:1px solid var(--line);
  border-radius:22px;
  padding:28px;
  background:var(--white);
  color:var(--ink);
  box-shadow:0 22px 70px #15342b33
}

dialog::backdrop {
  background:#15342b70;
  backdrop-filter:blur(3px)
}

.modal-header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:15px
}

.close-modal {
  border-radius:50%;
  min-width:44px;
  width:44px;
  height:44px;
  background:#edf0e6;
  font-size:24px;
  line-height:1
}

.modal-copy {
  font-size:14px;
  color:var(--muted);
  margin:18px 0
}

.modal-error {
  color:#a12d24;
  font-size:13px;
  margin-top:14px
}

dialog .hanzi {
  font-size:53px;
  margin-top:20px
}

dialog .hanzi.long {
  font-size:33px
}

.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:1500px) {
  .workspace {
    padding:0 68px
  }
  .daily-panel {
    padding:34px
  }
  .dashboard-grid {
    grid-template-columns:minmax(0,1.9fr) minmax(270px,1fr)
  }
}

@media(max-width:1100px) {
  .app-shell {
    grid-template-columns:190px minmax(0,1fr)
  }
  .sidebar {
    padding:27px 15px
  }
  .workspace {
    padding:0 28px
  }
  .dashboard-grid {
    gap:18px;
    grid-template-columns:minmax(0,1.4fr) minmax(210px,1fr)
  }
  .daily-panel {
    padding:25px
  }
  .daily-panel h2 {
    font-size:24px
  }
  .panel-book {
    right:-42px;
    opacity:.42
  }
  .daily-counts {
    max-width:90%
  }
  .word-row {
    grid-template-columns:65px minmax(0,1fr) 22px;
    padding:14px;
    gap:10px
  }
  .library-toolbar {
    flex-wrap:wrap
  }
  .search-box {
    min-width:200px
  }
  .word-peek {
    gap:10px
  }
  .peek {
    padding:16px
  }
  .stat {
    padding:0 18px
  }
}

@media(max-width:800px) {
  .app-shell {
    display:block
  }
  .sidebar {
    position:relative;
    height:auto;
    display:flex;
    flex-direction:row;
    align-items:center;
    justify-content:space-between;
    padding:12px max(18px,env(safe-area-inset-right)) 12px max(18px,env(safe-area-inset-left));
    border-right:0;
    border-bottom:1px solid var(--line)
  }
  .brand-stamp {
    height:36px;
    width:31px;
    font-size:15px
  }
  .brand strong {
    font-size:21px
  }
  .brand small {
    font-size:11px
  }
  .navigation {
    position:fixed;
    bottom:0;
    left:0;
    right:0;
    z-index:10;
    margin:0;
    background:#f7f8f1;
    border-top:1px solid var(--line);
    display:grid;
    grid-template-columns:repeat(4,1fr);
    gap:4px;
    padding:7px 10px max(7px,env(safe-area-inset-bottom))
  }
  .navigation button {
    flex-direction:column;
    gap:3px;
    justify-content:center;
    padding:8px 3px;
    border-radius:9px;
    font-size:12px;
    line-height:1.4
  }
  .navigation .nav-icon {
    font-size:21px
  }
  .sidebar-note {
    display:none
  }
  .sidebar-footer {
    border:0;
    padding:0;
    text-align:right;
    font-size:11px
  }
  .sidebar-footer small {
    font-size:9px
  }
  .workspace {
    padding:0 max(18px,env(safe-area-inset-right)) 0 max(18px,env(safe-area-inset-left))
  }
  .topbar {
    height:40px;
    font-size:12px
  }
  .local-badge {
    font-size:10px
  }
  main {
    padding:18px 0 28px;
    min-height:calc(100vh - 260px)
  }
  .page-heading {
    margin-bottom:18px
  }
  .page-heading h1 {
    font-size:26px
  }
  .page-heading p {
    font-size:15px
  }
  .page-heading>.tag {
    display:none
  }
  .dashboard-grid {
    grid-template-columns:minmax(0,1.55fr) minmax(190px,1fr)
  }
  .daily-panel h2 {
    font-size:25px
  }
  .daily-panel p {
    max-width:85%
  }
  .daily-counts {
    max-width:90%
  }
  .progress-panel {
    padding:21px
  }
  .progress-panel h3 {
    font-size:15px
  }
  .progress-circle {
    width:135px;
    height:135px
  }
  .page-footer {
    padding-bottom:110px;
    font-size:9px
  }
  .flashcard {
    padding:22px 25px
  }
  .library-list {
    gap:10px
  }
  .backup-panel {
    padding:23px
  }
  .toast {
    bottom:90px
  }
  .hanzi {
    margin-top:40px
  }
}

@media(max-width:580px) {
  .local-badge {
    display:none
  }
  .dashboard-grid {
    grid-template-columns:1fr
  }
  .daily-panel {
    padding:20px;
    min-height:250px
  }
  .daily-panel h2 {
    font-size:24px;
    max-width:75%;
    margin-top:14px
  }
  .daily-panel p {
    max-width:76%;
    font-size:15px
  }
  .panel-book {
    right:0;
    bottom:-37px;
    width:130px;
    height:190px;
    opacity:.45
  }
  .daily-panel .button {
    margin-top:18px
  }
  .daily-counts {
    max-width:75%;
    margin-top:22px;
    padding-top:14px
  }
  .daily-count strong {
    font-size:28px
  }
  .daily-count+.daily-count {
    padding-left:16px
  }
  .progress-panel {
    display:grid;
    grid-template-columns:1fr 86px;
    text-align:left;
    padding:19px 22px;
    gap:5px 16px;
    align-items:center
  }
  .progress-panel h3 {
    grid-column:1;
    align-self:end;
    font-size:16px
  }
  .progress-panel p {
    grid-column:1;
    align-self:start;
    font-size:15px
  }
  .progress-circle {
    width:86px;
    height:86px;
    margin:0;
    grid-column:2;
    grid-row:1/3
  }
  .progress-circle:before {
    inset:7px
  }
  .progress-circle strong {
    font-size:26px;
    text-align:center
  }
  .progress-circle small {
    font-size:8px
  }
  .section-title {
    margin-top:27px
  }
  .section-title h2 {
    font-size:19px
  }
  .section-title span {
    font-size:10px
  }
  .stats-strip {
    padding:18px 0
  }
  .stat {
    padding:0 13px
  }
  .stat label {
    font-size:12px
  }
  .stat strong {
    font-size:25px
  }
  .stat small {
    font-size:10px;
    margin-left:3px
  }
  .word-peek {
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:8px
  }
  .peek {
    padding:12px 10px
  }
  .peek strong {
    font-size:26px
  }
  .peek span {
    font-size:12px
  }
  .peek-meaning {
    font-size:10px
  }
  .tip-row {
    padding:15px;
    font-size:15px
  }
  .page-footer {
    display:block
  }
  .page-footer span {
    display:block;
    margin-bottom:4px
  }
  .flashcard {
    padding:19px 21px 24px;
    border-radius:18px;
    min-height:340px
  }
  .hanzi {
    font-size:70px
  }
  .pinyin {
    font-size:21px
  }
  .meaning {
    font-size:18px
  }
  .example-hanzi {
    font-size:21px
  }
  .example-pinyin,.example-meaning {
    font-size:15px
  }
  .ratings {
    gap:8px
  }
  .rating {
    font-size:15px;
    padding:11px 4px;
    min-height:66px
  }
  .rating small {
    font-size:15px
  }
  .key {
    display:none
  }
  .study-head span {
    font-size:13px
  }
  .study-progress {
    margin-bottom:19px;
    gap:4px
  }
  .library-toolbar {
    gap:9px
  }
  .search-box {
    flex-basis:100%
  }
  select {
    flex:1;
    font-size:16px
  }
  .library-list {
    grid-template-columns:1fr
  }
  .word-row {
    grid-template-columns:85px minmax(0,1fr) 25px;
    padding:17px
  }
  .word-row .word-hanzi {
    font-size:29px
  }
  .word-row .word-hanzi.long {
    font-size:19px
  }
  .backup-grid {
    grid-template-columns:1fr
  }
  .backup-panel p {
    font-size:15px
  }
  .completion {
    padding:33px 20px
  }
  .completion h2 {
    font-size:24px
  }
  .completion-results {
    gap:24px
  }
  .modal-header h2 {
    font-size:19px
  }
  dialog {
    padding:22px
  }
  .modal-actions {
    justify-content:stretch
  }
  .modal-actions .button {
    flex:1
  }
  .error-panel {
    padding:24px
  }
  .data-summary {
    font-size:15px
  }
  .button {
    padding:12px 18px
  }
}

@media(max-width:800px), (pointer:coarse) and (max-height:500px) {
  input[type=search],
  input[type=file],
  .backup-panel input,
  select {
    font-size:16px;
    min-height:48px;
    max-width:100%;
  }
  input[type=file]::file-selector-button {
    min-height:44px;
    font:inherit;
  }
  .text-button {
    font-size:15px;
  }
  .word-row .word-meaning,
  .modal-copy,
  .modal-error,
  .completion p,
  .error-panel p,
  .notice {
    font-size:15px;
  }
  dialog {
    max-height:calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    width:calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }
  body[data-view=study] {
    overflow:hidden;
  }
  body[data-view=study] .app-shell {
    display:block;
    height:100dvh;
    min-height:0;
  }
  body[data-view=study] .sidebar,
  body[data-view=study] .topbar,
  body[data-view=study] .page-footer {
    display:none;
  }
  body[data-view=study] .workspace {
    display:flex;
    flex-direction:column;
    height:100%;
    padding:max(6px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
  }
  body[data-view=study] .notice {
    flex:0 0 auto;
    max-height:25dvh;
    overflow:auto;
    margin:4px 0;
  }
  body[data-view=study] main {
    display:flex;
    flex-direction:column;
    flex:1 1 0;
    min-height:0;
    padding:0;
    overflow:hidden;
  }
  body[data-view=study] .study-wrap {
    display:flex;
    flex-direction:column;
    flex:1 1 0;
    min-height:0;
    width:100%;
    margin:0 auto;
  }
  body[data-view=study] .study-head {
    flex:0 0 auto;
    min-height:44px;
    margin:0;
    gap:8px;
  }
  body[data-view=study] .study-head .text-button {
    min-height:44px;
    padding:8px 6px;
    text-decoration:none;
  }
  body[data-view=study] .study-head span {
    font-size:13px;
  }
  body[data-view=study] .study-progress {
    flex:0 0 auto;
    margin:5px 0 10px;
    gap:4px;
  }
  body[data-view=study] .flashcard {
    flex:1 1 0;
    min-height:0;
    padding:15px 18px;
    border-radius:17px;
    overflow:auto;
    overscroll-behavior:contain;
    box-shadow:0 5px 16px #253c3009;
  }
  body[data-view=study] .flashcard:focus-visible {
    outline:3px solid var(--accent);
    outline-offset:-3px;
  }
  body[data-view=study] .flashcard:not(.revealed) {
    display:flex;
    flex-direction:column;
  }
  body[data-view=study] .flashcard:not(.revealed) .card-pinyin {
    margin:auto 0 10px;
    padding-top:16px;
    font-size:clamp(34px,10vw,48px);
  }
  body[data-view=study] .recall-hint {
    margin:18px 0 auto;
    padding-bottom:20px;
  }
  body[data-view=study] .card-meta {
    flex:0 0 auto;
  }
  body[data-view=study] .card-meta .tag,
  body[data-view=study] .card-no {
    font-size:12px;
  }
  body[data-view=study] .flashcard.revealed .card-pinyin {
    margin:8px 0 3px;
    font-size:30px;
    line-height:1.5;
  }
  body[data-view=study] .thai-pronunciation {
    font-size:18px;
  }
  body[data-view=study] .flashcard.revealed .thai-pronunciation {
    font-size:16px;
  }
  body[data-view=study] .hanzi-reference {
    font-size:21px;
    margin-top:5px;
  }
  body[data-view=study] .meaning {
    margin-top:5px;
    font-size:18px;
    line-height:1.6;
  }
  body[data-view=study] .word-tools {
    margin:8px 0;
  }
  body[data-view=study] .example {
    margin-top:0;
    padding-top:12px;
  }
  body[data-view=study] .example-label {
    font-size:13px;
    margin-bottom:5px;
  }
  body[data-view=study] .example-hanzi {
    font-size:22px;
    line-height:1.55;
  }
  body[data-view=study] .example-pinyin,
  body[data-view=study] .example-meaning {
    font-size:15px;
    line-height:1.6;
    margin-top:5px;
  }
  body[data-view=study] .thai-reading {
    margin-top:10px;
  }
  body[data-view=study] .study-note {
    flex:0 0 auto;
    margin-top:12px;
    font-size:13px;
  }
  body[data-view=study] .study-actions {
    flex:0 0 auto;
    padding-top:10px;
  }
  body[data-view=study] .reveal-button {
    margin:0;
    min-height:54px;
    font-size:16px;
  }
  body[data-view=study] .rating-label {
    margin:0 0 6px;
  }
  body[data-view=study] .ratings {
    gap:8px;
  }
  body[data-view=study] .rating {
    min-height:76px;
    padding:9px 4px;
    font-size:15px;
  }
  body[data-view=study] .rating small {
    font-size:15px;
    line-height:1.5;
    margin-top:3px;
  }
  body[data-view=study] .completion {
    flex:1 1 0;
    min-height:0;
    overflow:auto;
    padding:25px 20px;
    overscroll-behavior:contain;
  }
  body[data-view=study] .toast {
    top:calc(max(6px,env(safe-area-inset-top)) + 54px);
    bottom:auto;
  }
}

@media(prefers-reduced-motion:no-preference) {
  .flashcard.revealed .example {
    animation:reveal .2s ease-out
  }
  @keyframes reveal {
    from {
      opacity:0;
      transform:translateY(5px)
    }
    to {
      opacity:1;
      transform:translateY(0)
    }
  }
}
