:root {
  --bg: #f6f5f1; --card: #fff; --ink: #1f2328; --muted: #6b7280; --line: #e7e5df;
  --accent: #c2410c; --accent-soft: #fff1e8; --blue: #2563eb; --green: #15803d; --red: #dc2626; --amber: #b45309;
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16181c; --card: #1f2227; --ink: #e8e6e3; --muted: #9aa0a6; --line: #2e3238; --accent-soft: #3a2418; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, select, input, .button { font: inherit; color: inherit; }
button, .button { cursor: pointer; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px; }
button:disabled { opacity: .45; cursor: default; }
kbd { font-size: 11px; opacity: .6; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 6px; }

.offline { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 14px; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 10px max(20px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; } .brand span { color: var(--accent); }
nav { display: flex; gap: 4px; }
nav button { border: none; background: none; color: var(--muted); }
nav button.active { color: var(--ink); background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

main { max-width: 760px; margin: 0 auto; padding: 24px 18px calc(80px + env(safe-area-inset-bottom)); }
.view { display: none; } .view.active { display: block; }
h2 { font-size: 15px; margin: 28px 0 10px; color: var(--muted); font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.6; } .center { text-align: center; }

.hero { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 34px 20px 26px; }
.hero-num { font-size: 64px; font-weight: 800; line-height: 1; }
.hero-label { color: var(--muted); margin: 8px 0 16px; }
.pills { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 22px; }
.pill { font-size: 13px; padding: 4px 10px; border-radius: 99px; background: var(--bg); }
.pill.review { color: var(--blue); } .pill.new { color: var(--accent); }
.primary { background: var(--accent); color: #fff; border: none; font-weight: 600; }
.primary.big { font-size: 18px; padding: 14px 48px; border-radius: 14px; }
.primary.wide { width: 100%; padding: 14px; font-size: 16px; border-radius: 14px; }
.grid3, .grid4 { display: grid; gap: 10px; margin-top: 14px; }
.grid3 { grid-template-columns: repeat(3, 1fr); } .grid4 { grid-template-columns: repeat(4, 1fr); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.tile b { display: block; font-size: 26px; } .tile span { color: var(--muted); font-size: 12px; }
.meter { position: relative; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 16px; }
.meter div { position: absolute; inset: 0 auto 0 0; background: #f4b48f; } .meter .m2 { background: var(--green); }

.study-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.link { border: none; background: none; color: var(--muted); padding: 4px 0; }
.progress { flex: 1; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--accent); transition: width .3s; }
.counts { color: var(--muted); font-size: 13px; white-space: nowrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 26px 26px 22px; min-height: 300px; position: relative; cursor: pointer; }
.tag { position: absolute; top: 16px; right: 18px; font-size: 12px; padding: 2px 8px; border-radius: 99px; }
.tag.new { background: var(--accent-soft); color: var(--accent); } .tag.review { background: #e8efff; color: var(--blue); } .tag.again { background: #fde8e8; color: var(--red); }
.mode { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.word { font-size: 44px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 18px; }
.word.small { font-size: 28px; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
.ph { font-size: 15px; font-weight: 400; color: var(--muted); font-family: "Lucida Grande", sans-serif; }
.zh-big { font-size: 30px; font-weight: 700; margin-bottom: 18px; }
.sentence { font-size: 20px; line-height: 1.6; font-family: Georgia, "Times New Roman", serif; }
.sentence mark { background: #ffe4cf; color: inherit; padding: 0 3px; border-radius: 4px; font-weight: 700; }
@media (prefers-color-scheme: dark) { .sentence mark { background: #6b3417; } }
.blank { color: var(--accent); letter-spacing: 2px; font-family: monospace; }
.sentence-zh { color: var(--muted); margin-top: 8px; line-height: 1.6; }
.card-back { border-top: 1px dashed var(--line); margin-top: 22px; padding-top: 18px; cursor: default; }
.meaning { font-size: 22px; font-weight: 600; margin: 4px 0 12px; }
.pos { color: var(--accent); font-style: italic; font-weight: 600; margin-right: 8px; font-size: .85em; }
.source { margin-top: 14px; font-size: 13px; color: var(--muted); }
details { margin-top: 10px; font-size: 14px; } summary { cursor: pointer; color: var(--blue); }
details ul { padding-left: 18px; line-height: 1.8; margin: 8px 0 0; }
.icon { border: none; background: var(--bg); border-radius: 99px; padding: 6px 10px; font-size: 16px; }
#replay-front { margin-top: 18px; }
.hidden { display: none !important; }
.actions { margin-top: 16px; }
#actions-rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate { padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 14px; }
.rate small { color: var(--muted); font-size: 12px; }
.rate.again b { color: var(--red); } .rate.hard b { color: var(--amber); } .rate.good b { color: var(--green); } .rate.easy b { color: var(--blue); }

.toolbar { display: flex; gap: 8px; margin-bottom: 14px; position: sticky; top: 56px; z-index: 2; background: var(--bg); padding: 6px 0; }
.toolbar input { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.toolbar select, .form select { padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.ep { margin-bottom: 18px; }
.ep-title { font-size: 13px; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.row { display: flex; justify-content: space-between; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 6px; cursor: pointer; }
.row-ex { color: var(--muted); font-size: 13px; margin-top: 3px; font-family: Georgia, serif; }
.row-ex mark { background: none; color: var(--ink); font-weight: 700; }
.row-right { text-align: right; white-space: nowrap; } .row-right small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; }
.s-new { background: var(--bg); color: var(--muted); } .s-learning { background: #fde8e8; color: var(--red); }
.s-review { background: #e8efff; color: var(--blue); } .s-mastered { background: #e3f5e8; color: var(--green); }
.basic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; font-size: 14px; }
.basic-grid div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 160px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.bars.small { height: 120px; gap: 3px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; font-size: 11px; color: var(--muted); }
.bar-v { width: 100%; max-width: 46px; background: var(--blue); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bar-v.alt { background: var(--accent); }
.bar-col b { color: var(--ink); margin-top: 4px; }
.bars.small span { writing-mode: vertical-rl; font-size: 9px; margin-top: 4px; }

.form { display: grid; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.form label { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.form .check { justify-content: flex-start; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.danger { color: var(--red); }

@media (max-width: 560px) {
  .topbar { padding: max(8px, env(safe-area-inset-top)) 12px 8px; } .brand span { display: none; }
  nav button { padding: 8px 10px; }
  .word { font-size: 36px; } .sentence { font-size: 18px; }
  .grid4 { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 22px 18px; }
}
