:root {
  --bg: #fff6eb;
  --paper: #fffdf8;
  --ink: #2b2118;
  --muted: #7a6a5a;
  --line: #ead9c4;
  --accent: #e76f51;
  --accent2: #2a9d8f;
  --gold: #e9c46a;
  --shadow: 0 10px 30px rgba(80, 40, 10, .08);
  --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: "Hiragino Sans", "PingFang SC", "Noto Sans SC", "Noto Sans JP", sans-serif;
  min-height: 100%; }
body { max-width: 780px; margin: 0 auto; }
button { font: inherit; cursor: pointer; }
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,246,235,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px 8px;
}
.top-row { display: flex; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.brand b { font-size: 16px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 12px;
  background: #fff; box-shadow: var(--shadow); font-size: 18px;
}
.search {
  margin-top: 8px; width: 100%; border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; background: #fff; font-size: 15px;
}
.main { flex: 1; padding: 12px 14px 92px; }
.section-title { margin: 6px 0 10px; font-size: 13px; color: var(--muted); letter-spacing: .08em; }
.part-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.part-card, .lesson-card, .phrase, .panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.part-card { padding: 16px 14px; text-align: left; border: 0; }
.part-card .emoji { font-size: 28px; }
.part-card h3 { margin: 8px 0 2px; font-size: 16px; }
.part-card p { margin: 0; color: var(--muted); font-size: 12px; }
.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson-card {
  display: flex; align-items: center; gap: 10px; padding: 12px; text-align: left; width: 100%;
}
.badge {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: #ffe8d6; font-weight: 700; color: #9c4a2b; flex-shrink: 0;
}
.lesson-card h4 { margin: 0; font-size: 15px; }
.lesson-card small { color: var(--muted); }
.audio-dot { margin-left: auto; font-size: 12px; color: var(--accent2); }
.lesson-head { margin-bottom: 12px; }
.lesson-head h2 { margin: 0 0 4px; font-size: 22px; }
.kana { color: var(--muted); margin: 0 0 10px; }
.pattern {
  background: #fff3e4; border: 2px dashed #f0b27a; border-radius: 16px;
  padding: 12px; margin-bottom: 12px; font-size: 18px; font-weight: 700;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.btn {
  border: 0; border-radius: 999px; padding: 10px 14px; background: var(--accent); color: #fff;
  font-weight: 700; box-shadow: var(--shadow);
}
.btn.alt { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ok { background: var(--accent2); }
.btn.warn { background: #d62828; }
.phrase { padding: 12px; margin-bottom: 8px; }
.phrase .zh { color: var(--muted); font-size: 13px; margin-top: 4px; }
.phrase .ro { color: #a08b74; font-size: 12px; margin-top: 2px; letter-spacing: .02em; }
.phrase-row { display: flex; align-items: flex-start; gap: 8px; }
.jp { font-size: 20px; line-height: 1.45; flex: 1; }
.mini { width: 36px; height: 36px; border: 0; border-radius: 10px; background: #ffe8d6; }
.note { background: #eaf6f3; border-radius: 14px; padding: 10px 12px; color: #1d6b61; font-size: 13px; margin-top: 8px; }
.show-mode {
  position: fixed; inset: 0; background: #fffdf8; z-index: 50; padding: 24px 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.show-mode .big { font-size: clamp(28px, 8vw, 48px); line-height: 1.4; font-weight: 800; }
.show-mode .sub { margin-top: 16px; color: var(--muted); font-size: 18px; }
.tabbar {
  position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255,253,248,.95); border-top: 1px solid var(--line); backdrop-filter: blur(10px);
}
.tabbar button {
  border: 0; background: transparent; padding: 10px 4px 14px; color: var(--muted); font-size: 11px;
}
.tabbar button.on { color: var(--accent); font-weight: 700; }
.tabbar span { display: block; font-size: 18px; margin-bottom: 2px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%);
  background: #2b2118; color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .25s;
}
.toast.show { opacity: 1; }
.update-bar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  background: #264653; color: #fff; padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  font-size: 14px; box-shadow: var(--shadow);
}
.update-bar[hidden] { display: none; }
.update-bar span { flex: 1; }
.update-bar button {
  border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 700;
  background: var(--accent); color: #fff;
}
.update-bar #dismissUpdate {
  background: transparent; color: #fff; font-size: 20px; padding: 4px 10px;
}
.modal-bg { position: fixed; inset: 0; background: rgba(40,20,0,.35); z-index: 40; display: grid; place-items: end; }
.sheet { background: #fff; width: 100%; border-radius: 22px 22px 0 0; padding: 16px; max-height: 80vh; overflow: auto; }
.stat { display: flex; gap: 8px; margin: 10px 0 16px; }
.stat div { flex: 1; background: #fff; border-radius: 14px; padding: 10px; text-align: center; border: 1px solid var(--line); }
.stat b { display: block; font-size: 20px; }
.kana-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.kana-table td { border: 1px solid var(--line); padding: 6px 4px; text-align: center; background: #fff; }
.kana-table small { display: block; color: var(--muted); font-size: 10px; }
.back { border: 0; background: transparent; font-size: 15px; color: var(--accent); padding: 0 6px 0 0; }
.fav.on { background: #ffd6d0; }
@media (min-width: 720px) {
  .part-grid { grid-template-columns: repeat(3, 1fr); }
}
