:root {
  color-scheme: light;
  --paper: #f5f7f1;
  --white: #fffefb;
  --ink: #20382d;
  --muted: #50665a;
  --brand: #205b45;
  --brand-dark: #174a37;
  --line: #dee6da;
  --light: #e7f0e2;
  --honey: #faeed0;
  --lavender: #ece9f8;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
a { color: inherit; text-decoration: none; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #518a6b; outline-offset: 4px; }
[hidden] { display: none !important; }
.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; }
h1, h2, h3, p, figure { margin: 0; }
p { line-height: 1.65; }

.shell { min-height: 100dvh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.rail {
  display: flex;
  flex-direction: column;
  gap: 45px;
  position: sticky;
  top: 0;
  height: 100dvh;
  background: #fdfdf9;
  border-right: 1px solid var(--line);
  padding: 31px 20px 23px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 5px; min-width: 0; }
.brand img { border-radius: 14px; background: #d5ead4; flex: none; }
.brand strong { display: block; font-size: 1.17rem; letter-spacing: -.035em; white-space: nowrap; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: .82rem; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 13px; font-weight: 650; color: #465e51; }
.nav a[aria-current] { color: var(--brand-dark); background: #e5efdf; }
.nav a:hover:not([aria-current]) { background: #f0f3ed; }
.rail-footer { margin-top: auto; display: flex; align-items: center; gap: 9px; padding: 14px 7px 2px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.local-mark { width: 8px; height: 8px; border-radius: 50%; background: #5e936e; }
.workspace { min-width: 0; }
.topbar { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 clamp(22px, 4.3vw, 59px); border-bottom: 1px solid var(--line); background: var(--paper); }
.breadcrumb { font-size: .95rem; font-weight: 650; color: #52705d; }
.top-actions { display: flex; align-items: center; gap: 10px; }
main { margin-inline: auto; max-width: 1250px; padding: 35px clamp(22px, 4.3vw, 59px) 54px; }
main:focus { outline: none; }
.page-wait { text-align: center; margin: 45px auto; color: var(--muted); }
.page-heading { margin-bottom: 23px; }
.page-heading h1 { font-size: clamp(2rem, 4vw, 2.65rem); letter-spacing: -.065em; line-height: 1.12; }
.page-heading p { color: var(--muted); margin-top: 9px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 45px; padding: 10px 17px; border: 1px solid transparent; border-radius: 12px; font-weight: 700; background: transparent; line-height: 1.28; text-align: center; }
.primary { background: var(--brand); color: #fff; }
.primary:hover:not(:disabled) { background: var(--brand-dark); }
.outline { background: #fffefb; border-color: #cfdccf; color: #24543e; }
.outline:hover:not(:disabled), .quiet:hover:not(:disabled) { background: #edf3e9; }
.quiet { color: var(--brand-dark); }
.danger { color: #984137; }
.danger:hover { background: #f8eae4; }
.text-link { border: 0; background: transparent; color: var(--brand); padding: 4px 0; font-size: .88rem; font-weight: 700; }
.text-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.ico { position: relative; display: inline-block; width: 19px; height: 19px; color: inherit; flex: none; }
.ico::before, .ico::after { box-sizing: border-box; position: absolute; content: ""; }
.ico-plus::before, .ico-plus::after { background: currentColor; border-radius: 2px; top: 50%; left: 50%; transform: translate(-50%, -50%); }
.ico-plus::before { width: 13px; height: 2px; } .ico-plus::after { width: 2px; height: 13px; }
.ico-home::before { width: 12px; height: 12px; border: 1.7px solid currentColor; border-top: 0; border-radius: 2px 2px 4px 4px; left: 4px; top: 6px; }
.ico-home::after { width: 11px; height: 11px; border: 1.7px solid currentColor; border-right: 0; border-bottom: 0; left: 4.5px; top: 2px; transform: rotate(45deg); border-radius: 2px; }
.ico-book::before { inset: 2px 3px; border-radius: 3px; border: 1.7px solid currentColor; border-left-width: 4px; }
.ico-book::after { width: 5px; height: 2px; border-radius: 2px; background: currentColor; left: 9px; top: 7px; }
.ico-box::before { inset: 5px 2px 2px; border: 1.7px solid currentColor; border-radius: 3px; }
.ico-box::after { width: 9px; height: 5px; left: 5px; top: 3px; border-top: 1.7px solid currentColor; border-bottom: 1.7px solid currentColor; }
.ico-check::before { width: 10px; height: 6px; left: 5px; top: 5px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-47deg); }
.ico-check::after { inset: 1px; border: 1.5px solid currentColor; border-radius: 50%; }
.ico-camera::before { inset: 4px 1.5px 2px; border: 1.7px solid currentColor; border-radius: 3px; }
.ico-camera::after { width: 6px; height: 6px; left: 6.5px; top: 7px; border: 1.5px solid currentColor; border-radius: 50%; box-shadow: -3px -5px 0 -2px currentColor; }
.ico-search::before { left: 2px; top: 2px; width: 11px; height: 11px; border: 1.7px solid currentColor; border-radius: 50%; }
.ico-search::after { left: 11px; top: 12px; width: 6px; height: 1.7px; border-radius: 2px; transform: rotate(45deg); background: currentColor; }
.ico-play::before { top: 4px; left: 6px; border-left: 9px solid currentColor; border-top: 5.5px solid transparent; border-bottom: 5.5px solid transparent; }
.ico-download::before { width: 8px; height: 8px; transform: rotate(45deg); border-bottom: 2px solid currentColor; border-right: 2px solid currentColor; top: 3px; left: 5px; }
.ico-download::after { bottom: 2px; left: 3px; right: 3px; border-bottom: 2px solid currentColor; }

.home-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.6fr) minmax(220px, 1fr); align-items: stretch; }
.hero { position: relative; min-height: 290px; border: 1px solid #cde3c6; border-radius: 24px; padding: 27px 29px; background: #d9ecd1; isolation: isolate; overflow: hidden; }
.hero-copy { position: relative; z-index: 1; }
.hero-label { font-weight: 750; color: #244e37; }
.hero-count { display: flex; align-items: baseline; gap: 10px; margin: 7px 0 9px; line-height: 1; }
.hero-count span { font: 760 clamp(4.8rem, 9vw, 6.1rem)/.97 system-ui, sans-serif; letter-spacing: -.09em; }
.hero-count strong { font-size: 1.12rem; }
.hero-hint { color: #365846; max-width: 20ch; min-height: 3.1em; }
.hero .button { margin-top: 13px; }
.hero-art { position: absolute; z-index: 0; top: 0; right: 0; width: 43%; height: 100%; min-width: 170px; pointer-events: none; }
.art-grid { position: absolute; inset: 22px 23px 21px 0; background-image: linear-gradient(#aecda780 1px, transparent 1px), linear-gradient(90deg, #aecda780 1px, transparent 1px); background-size: 23px 23px; mask-image: linear-gradient(125deg, transparent, black 70%, transparent); }
.art-orbit { width: 254px; height: 254px; border: 1px solid #b4d3ae; border-radius: 50%; position: absolute; right: -39px; top: 10px; }
.art-book { position: absolute; left: 16%; top: 21%; width: 110px; height: 139px; padding: 33px 20px; background: #f9fcf0; border-radius: 15px; border-left: 12px solid #87b28a; box-shadow: -7px 7px 0 #73a97a, 0 13px 23px #4b745036; transform: rotate(-14deg); }
.art-book i { display: block; background: #c1d9ba; border-radius: 3px; height: 3px; margin-bottom: 10px; }
.art-book i:nth-child(2) { width: 82%; }
.art-book i:nth-child(3) { width: 64%; }
.art-book span { position: absolute; right: 12px; bottom: 10px; color: #3b7a56; font: 760 23px/1 system-ui, sans-serif; }
.art-pencil { position: absolute; top: 38%; left: 71%; width: 14px; height: 111px; border-radius: 5px 5px 2px 2px; background: #ebbb58; border-top: 15px solid #f4df9b; transform: rotate(26deg); }
.art-pencil::after { content: ""; position: absolute; border-top: 15px solid #8c6a37; border-left: 7px solid transparent; border-right: 7px solid transparent; bottom: -13px; }
.art-spark { position: absolute; top: 14%; right: 15%; color: #7ca77e; font-size: 1.85rem; }
.hero-art b { position: absolute; right: 19%; bottom: 12%; width: 12px; height: 12px; border-radius: 50%; background: #efd590; }
.stats, .panel { border: 1px solid var(--line); border-radius: 22px; background: var(--white); }
.stats { display: grid; align-content: center; padding: 18px 26px; }
.stats > div { display: flex; gap: 16px; align-items: center; padding: 24px 0; }
.stats > div + div { border-top: 1px solid var(--line); }
.stat-mark, .topic-icon, .empty-icon { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 15px; flex: none; }
.grass { background: var(--light); color: #356549; }
.honey { background: var(--honey); color: #916320; }
.lavender { background: var(--lavender); color: #5c5191; }
.neutral { background: #eeefe9; color: #546457; }
.stats small { display: block; font-weight: 650; color: var(--muted); font-size: .88rem; }
.stats strong { display: block; font: 720 2rem/1.15 system-ui, sans-serif; margin-top: 3px; }
.panel { padding: 20px; min-width: 0; }
.panel-head, .problem-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.panel-head h2, .backup-grid h2 { font-size: 1.24rem; letter-spacing: -.033em; }
.rows, .topic-rows { margin-top: 13px; }
.question-row, .topic-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 3px; text-align: left; }
.question-row + .question-row, .topic-row + .topic-row, .history-row + .history-row { border-top: 1px solid #e8ede5; }
.question-row:hover, .topic-row:hover { background: #f6f8f2; }
.topic-icon { width: 39px; height: 39px; border-radius: 11px; font: 700 .96rem/1 system-ui, sans-serif; }
.row-main { flex: 1; min-width: 0; }
.row-main strong { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; line-height: 1.5; font-size: .965rem; }
.row-main small, .history-row small { display: block; margin-top: 5px; color: var(--muted); font-size: .82rem; }
.pill { font-size: .79rem; display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 99px; white-space: nowrap; color: #577062; background: #eff2eb; flex: none; }
.pill-due { background: #e6f2e3; color: #235c42; font-weight: 700; }
.topic-row { border: 0; background: transparent; }
.topic-row > span:nth-child(2) { flex: 1; font-weight: 650; }
.topic-row strong { font-size: .87rem; color: var(--muted); }
.empty-state { min-height: 205px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; text-align: center; padding: 25px 10px 13px; }
.empty-icon { background: #e9f2e5; color: #456d54; }
.empty-state strong { font-size: 1rem; margin-top: 3px; }
.empty-state p, .topic-empty p { font-size: .92rem; color: var(--muted); }
.empty-state .button { margin-top: 5px; min-height: 41px; font-size: .88rem; }
.topic-empty { display: grid; min-height: 185px; place-content: center; justify-items: center; gap: 15px; text-align: center; }
.topic-preview { display: inline-flex; gap: 6px; }
.topic-preview .topic-icon:nth-child(2) { transform: translateY(-6px); }

.filters { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.filter-tabs, .mode-tabs { display: inline-flex; gap: 3px; border-radius: 12px; padding: 4px; background: #edf1eb; flex-wrap: wrap; }
.filter-tabs button, .mode-tabs button { min-height: 37px; padding: 5px 13px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-weight: 650; white-space: nowrap; font-size: .9rem; }
.filter-tabs button[aria-pressed="true"], .mode-tabs button[aria-pressed="true"] { color: #214d36; background: #fffefb; box-shadow: 0 1px 5px #304b2520; }
.searchers { display: flex; gap: 9px; flex-wrap: wrap; min-width: 0; }
.search-field { display: flex; align-items: center; gap: 7px; border: 1px solid #dce4d8; padding: 0 9px; border-radius: 11px; min-width: 0; color: #61796a; }
.search-field input { width: 165px; min-height: 41px; border: 0; outline-offset: 2px; background: none; }
select { appearance: none; min-height: 43px; }
.select-field, .field:has(select) { position: relative; }
.select-field::after, .field:has(select)::after { content: ""; position: absolute; width: 7px; height: 7px; border-right: 1.5px solid #4e6958; border-bottom: 1.5px solid #4e6958; transform: rotate(45deg); right: 13px; bottom: 19px; pointer-events: none; }
.select-field select { border: 1px solid #dce4d8; border-radius: 11px; background: #fffefb; padding: 0 30px 0 10px; font-size: .91rem; }
.library-group { margin-top: 27px; }
.library-group h2 { font-size: 1.13rem; padding: 0 4px; }
.library-group h2 small { color: var(--muted); margin-left: 7px; font-size: .84rem; font-weight: 500; }
.library-group .rows { margin-top: 4px; }
.editor-grid { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 19px; align-items: start; }
.editor-column { display: grid; gap: 16px; min-width: 0; }
.form-panel { display: grid; gap: 15px; }
.subtle, .field small { font-size: .84rem; color: var(--muted); font-weight: 500; }
.form-note { color: var(--muted); font-size: .90rem; }
.field { display: grid; gap: 7px; }
.field span { font-weight: 700; }
.field small { margin-left: 5px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #dbe4d7;
  border-radius: 12px;
  background: #f7faf5;
  line-height: 1.55;
}
.field select { padding-right: 26px; }
.field::placeholder { color: #6c7d72; }
.field textarea { min-height: 105px; resize: vertical; }
.field-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.secondary-row .button { font-size: .88rem; }
.save-row { margin-top: 2px; }
.photo-empty { display: grid; place-items: center; align-content: center; min-height: 155px; gap: 8px; border: 1px dashed #cbdcca; border-radius: 15px; background: #f5faf3; text-align: center; padding: 12px; }
.photo-empty .empty-icon { width: 42px; height: 42px; }
.photo-empty p { font-size: .88rem; color: var(--muted); }
.photo-box { margin: 0; display: grid; gap: 5px; justify-items: start; min-width: 0; }
.photo-box img { display: block; width: 100%; max-height: min(520px, 58dvh); object-fit: contain; object-position: center; background: #f2f5ef; border: 1px solid #e2eae0; border-radius: 12px; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 9px; padding: 10px 0; }
.history-row .button { min-height: 39px; padding: 5px 10px; font-size: .85rem; }
.history-row strong { font-size: .92rem; }
.backup-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.backup-grid .panel { align-content: start; align-items: start; justify-items: start; }
.backup-grid p { color: var(--muted); }

.review-layout { max-width: 820px; display: grid; gap: 17px; margin-inline: auto; }
.problem-head > div { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.problem-text { font-size: clamp(1.28rem, 3vw, 1.8rem); line-height: 1.56; font-weight: 700; white-space: pre-wrap; overflow-wrap: anywhere; letter-spacing: -.018em; margin: 13px 0 2px; }
.problem .photo-box { margin-top: 11px; }
.work-panel { display: grid; gap: 16px; }
.ink-pad { background: #fffefb; border: 1px solid #dce6d9; border-radius: 16px; overflow: hidden; }
.ink-canvas { display: block; width: 100%; aspect-ratio: 2.2; min-height: 185px; max-height: 400px; background: #fffefb; background-image: linear-gradient(#edf0e5 1px, transparent 1px), linear-gradient(90deg, #edf0e5 1px, transparent 1px); background-size: 24px 24px; touch-action: none; cursor: crosshair; }
.ink-tools { display: flex; align-items: center; gap: 5px; padding: 5px 9px; border-top: 1px solid #e8eee3; }
.ink-tools small { flex: 1; min-width: 0; line-height: 1.35; color: var(--muted); font-size: .82rem; }
.ink-tools .button { min-height: 38px; padding: 6px 10px; flex: none; }
.answer { padding: 16px; border-radius: 14px; background: #e9f4e6; }
.answer h3 { margin-bottom: 5px; font-size: .98rem; }
.answer p { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.62; }
.work-panel > h3 { font-size: 1rem; }
.outcome { max-width: 580px; margin: 15px auto 0; text-align: center; padding: 32px 20px; }
.outcome > .ico { width: 46px; height: 46px; color: var(--brand); border: 1px solid #cce1cd; background: #e7f3e4; border-radius: 15px; margin-bottom: 10px; }
.outcome > .ico::before { top: 15px; left: 15px; width: 14px; height: 8px; }
.outcome > .ico::after { display: none; }
.outcome h1 { font-size: clamp(1.55rem, 5vw, 2.5rem); }
.outcome p { color: var(--muted); margin: 9px 0 18px; }
.outcome .outcome-label { margin: 2px 0 6px; }
.centered { justify-content: center; }

dialog { width: min(760px, calc(100% - 28px)); max-height: calc(100dvh - 30px); padding: 17px; border: 1px solid var(--line); border-radius: 19px; background: var(--white); color: var(--ink); overflow: auto; }
dialog::backdrop { background: #172f24a8; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.dialog-head h2 { font-size: 1.18rem; }
.dialog-head p { color: var(--muted); font-size: .86rem; margin-top: 5px; }
.close-button { width: 39px; height: 39px; flex: none; border: 0; border-radius: 11px; background: #eef3eb; font-size: 1.45rem; line-height: 1; }
.crop-stage { display: grid; place-items: center; background: #edf2eb; border-radius: 14px; min-height: 100px; }
.crop-stage canvas { display: block; max-width: 100%; max-height: 60dvh; touch-action: none; cursor: crosshair; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; margin-top: 13px; }
.image-dialog img { display: block; max-width: 100%; max-height: 72dvh; object-fit: contain; margin-inline: auto; }
.toast { position: fixed; z-index: 5; bottom: 24px; left: 50%; transform: translateX(-50%); width: max-content; max-width: min(530px, calc(100vw - 24px)); padding: 12px 18px; box-shadow: 0 5px 15px #20382d38; border-radius: 13px; color: #fff; background: #253f32; font-size: .94rem; line-height: 1.45; text-align: center; }

@media (max-width: 1020px) and (min-width: 761px) {
  .shell { grid-template-columns: 185px minmax(0, 1fr); }
  .rail { padding-inline: 13px; }
  .brand { gap: 7px; }
  .brand strong { font-size: 1.06rem; }
  .home-grid { grid-template-columns: minmax(0, 1.5fr) minmax(150px, .85fr); gap: 12px; }
  .hero { padding-inline: 21px; }
  .stats { padding-inline: 16px; }
  .stats > div { gap: 9px; }
  .panel { padding: 16px; }
  .hero-art { opacity: .84; right: -15px; }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .rail { position: fixed; z-index: 3; top: auto; bottom: 0; left: 0; right: 0; height: auto; padding: 6px max(9px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(9px, env(safe-area-inset-left)); gap: 0; border-right: 0; border-top: 1px solid var(--line); background: #fdfdf9; }
  .rail .brand, .rail-footer { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav a { flex: 1; gap: 4px; min-height: 54px; padding: 4px 3px; flex-direction: column; justify-content: center; font-size: .8rem; }
  .topbar { min-height: 61px; padding: 0 15px; }
  .topbar .button { min-height: 40px; padding: 6px 10px; font-size: .88rem; }
  .top-actions { gap: 3px; }
  main { padding: 19px 14px calc(84px + env(safe-area-inset-bottom)); }
  .home-grid { gap: 12px; grid-template-columns: 1fr minmax(0, .72fr); }
  .hero { grid-column: 1 / -1; min-height: 240px; border-radius: 19px; padding: 18px 20px; }
  .hero-hint { min-height: 0; }
  .stats { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; border-radius: 17px; padding: 0 12px; }
  .stats > div { padding: 13px 7px; gap: 9px; }
  .stats > div + div { border-top: 0; border-left: 1px solid var(--line); padding-left: 15px; }
  .stat-mark { width: 40px; height: 40px; border-radius: 12px; }
  .stats strong { font-size: 1.5rem; }
  .panel { border-radius: 17px; padding: 15px; }
  .editor-grid { gap: 12px; }
  .editor-column { gap: 12px; }
  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }
}

@media (max-width: 525px) {
  .home-grid, .editor-grid, .backup-grid { grid-template-columns: minmax(0, 1fr); }
  .hero-art { right: -1%; min-width: 141px; }
  .art-book { width: 84px; height: 112px; padding: 24px 13px; }
  .art-pencil { left: 73%; height: 84px; }
  .hero-hint { max-width: 17ch; }
  .hero-count span { font-size: 4.15rem; }
  .hero-count strong { font-size: .94rem; }
  .panel-head h2 { font-size: 1.13rem; }
  .panel-head { gap: 7px; }
  .empty-state { min-height: 172px; }
  .searchers, .search-field { flex: 1; }
  .search-field input { width: 100%; }
  .select-field select { max-width: 155px; }
  .review-layout { gap: 12px; }
  .ink-tools .button { padding-inline: 7px; font-size: .86rem; }
}
