:root {
  --paper: #efe4cd;
  --paper-deep: #e2d3b4;
  --card: #fffaf1;
  --ink: #1c1612;
  --ink-soft: #5f564c;
  --line: rgba(28, 22, 18, 0.12);
  --cinnabar: #c4452d;
  --cinnabar-deep: #9c2f1d;
  --pine: #2d5b48;
  --pine-soft: #dce8e1;
  --gold: #a67c2d;
  --shadow: 0 18px 40px rgba(54, 36, 14, 0.16);
  --html-bg: #1c1612;
  --radius: 22px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --bar: 62px;
  --top: 72px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--html-bg); }

body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Avenir Next", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -10%, rgba(196, 69, 45, 0.09), transparent 36%),
    radial-gradient(circle at 100% 0%, rgba(166, 124, 45, 0.08), transparent 28%),
    repeating-linear-gradient(-18deg, transparent, transparent 11px, rgba(28, 22, 18, 0.015) 11px, rgba(28, 22, 18, 0.015) 12px),
    var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; }
a { color: var(--cinnabar-deep); }

#app {
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: calc(var(--safe-t) + 8px);
  padding-bottom: calc(var(--bar) + var(--safe-b) + 10px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 20px 8px;
  flex-shrink: 0;
}

.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--paper);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Source Han Serif", serif;
  font-size: 22px;
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.02em; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }

.hud-side { display: flex; gap: 6px; align-items: center; }
.hud-pill {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  background: rgba(255, 250, 241, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  min-width: 36px;
  text-align: center;
}
.hud-pill.ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.theme-mini {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: rgba(255, 250, 241, 0.8);
}
.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background:
    linear-gradient(90deg, var(--ink) 50%, var(--cinnabar) 50%),
    linear-gradient(90deg, var(--gold) 50%, var(--paper) 50%);
  background-size: 100% 50%;
  background-position: top, bottom;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(28, 22, 18, 0.15);
}
a.coffee-mini {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  text-decoration: none;
  border-radius: 50%;
  border: 1.5px solid var(--cinnabar);
  color: var(--cinnabar-deep);
  background: #fffaf1;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 15px;
}

.quest {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 10px;
  flex-shrink: 0;
}
.quest-kanji {
  width: 36px; height: 36px; flex: 0 0 36px;
  display: grid; place-items: center;
  border: 2px solid var(--cinnabar);
  color: var(--cinnabar-deep);
  border-radius: 50%;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 16px;
  background: #fffaf1;
}
.quest-mid { flex: 1; min-width: 0; }
.quest-mid span {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quest-track {
  height: 7px;
  background: var(--paper-deep);
  border-radius: 999px;
  overflow: hidden;
}
.quest-track i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #c4452d, #d9783a);
  transition: width 0.35s ease;
}
.quest-remain {
  font-size: 11px;
  font-weight: 700;
  color: var(--cinnabar-deep);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

#main { flex: 1; display: flex; min-height: 0; min-width: 0; }
.view { display: none; flex: 1; min-height: 0; min-width: 0; flex-direction: column; padding: 0 18px; }
.view.active { display: flex; }

#view-browse, #view-tags, #view-progress { overflow: auto; padding-bottom: 18px; }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scrollbar-width: none;
  flex-shrink: 0;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.72);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 13px;
  color: var(--ink-soft);
}
.chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.session {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f7e6d8;
  border: 1px solid rgba(196, 69, 45, 0.18);
  color: var(--cinnabar-deep);
  border-radius: 14px;
  padding: 8px 10px 8px 12px;
  font-size: 13px;
  margin-bottom: 10px;
}
.session button {
  min-width: 36px; min-height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.55);
}

.stage {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  perspective: 1200px;
}

.card {
  width: min(100%, 400px);
  height: 100%;
  max-height: 360px;
  min-height: 180px;
  border-radius: var(--radius);
  background: transparent;
  box-shadow: none;
  text-align: left;
}
.card-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(.2,.8,.2,1);
  border-radius: var(--radius);
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.card.toss-left .card-inner { transform: translateX(-28px) rotate(-2deg); }
.card.toss-right .card-inner { transform: translateX(28px) rotate(2deg); }

.card { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), transparent 28%),
    var(--card);
  border: 1px solid rgba(28, 22, 18, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.face::before {
  content: "";
  position: absolute; left: 0; top: 18px; bottom: 18px; width: 5px;
  background: var(--cinnabar);
  border-radius: 0 4px 4px 0;
}
.back { transform: rotateY(180deg); }

.badge {
  position: absolute; top: 16px; right: 16px;
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--gold);
  border: 1px solid rgba(166, 124, 45, 0.35);
  border-radius: 999px;
  padding: 3px 8px;
}
.mora-word {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 0 3px;
  max-width: 100%;
  margin: 0 0 8px;
}
.mora {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0.95em;
}
.mora b {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Songti SC", "Source Han Serif", serif;
  font-weight: 600;
  font-size: 20px;
  line-height: 1.15;
  color: var(--ink);
}
.mora i {
  font-style: normal;
  font-size: 11px;
  line-height: 1.2;
  color: var(--cinnabar-deep);
  letter-spacing: 0;
  margin-top: 2px;
}
.mora em {
  font-style: normal;
  font-size: 9px;
  line-height: 1.15;
  color: var(--cinnabar-deep);
  font-weight: 700;
  letter-spacing: 0;
}
.mora.special {
  min-width: 1.35em;
  padding: 2px 3px 3px;
  border-radius: 8px;
  background: #f8e3d6;
  box-shadow: inset 0 0 0 1px rgba(196, 69, 45, 0.22);
}
.mora.special i { font-weight: 800; }
.mora-word.large { margin: 0; }
.mora-word.large .mora b { font-size: clamp(30px, 9vw, 50px); }
.mora-word.large .mora i { font-size: 12px; margin-top: 4px; }
.mora-word.large .mora em { font-size: 10px; }
.mora-word.long .mora b { font-size: clamp(22px, 6.2vw, 34px); }
.mora-word.long .mora i { font-size: 10px; }
.mora-word.compact { margin: 0 0 8px; }
.mora-word.compact .mora b { font-size: 18px; color: var(--ink-soft); }
.mora-word.compact .mora.special b { color: var(--ink); }
.hide-romaji .mora i,
.hide-romaji .mora em,
.hide-romaji .sound-note { display: none; }
.hide-romaji .mora.special {
  min-width: 0.95em;
  padding: 0;
  background: none;
  box-shadow: none;
}
.hide-romaji .mora-word.compact { margin: 0 0 4px; }
.sound-note {
  margin: 8px 0 0;
  max-width: 22em;
  text-align: center;
  font-size: 12px;
  line-height: 1.4;
  color: var(--cinnabar-deep);
  background: #f8e3d6;
  border-radius: 10px;
  padding: 6px 10px;
}
.word {
  margin: 0;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Songti SC", "Source Han Serif", serif;
  font-size: clamp(34px, 11vw, 56px);
  line-height: 1.2;
  text-align: center;
  font-weight: 600;
}
.hint { margin: 18px 0 0; font-size: 12px; color: #9a8f80; }
.back-word { font-size: 22px; margin-bottom: 6px; }
.meaning {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
  text-align: center;
  max-width: 20em;
}
.example {
  margin: 16px 0 0;
  padding: 0;
  text-align: center;
  max-width: 22em;
}
.ex-ja { margin: 0; font-size: 15px; }
.ex-en { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); }

.pager-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  flex-shrink: 0;
  padding: 4px 0 2px;
}
.pager-mid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.pager {
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  font-size: 12px;
  padding: 0;
}
.tool-btn {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.8);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.tool-btn.on {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.combo {
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--cinnabar);
  border-radius: 999px;
  padding: 3px 8px;
  letter-spacing: 0.04em;
}
.card.sealed .card-inner { animation: seal-pop 0.38s ease; }
@keyframes seal-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.035); }
  100% { transform: scale(1); }
}
.float-pop {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar) + var(--safe-b) + 92px);
  transform: translateX(-50%);
  z-index: 30;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  pointer-events: none;
  animation: float-up 0.9s ease forwards;
}
@keyframes float-up {
  0% { opacity: 0; transform: translateX(-50%) translateY(8px); }
  18% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-22px); }
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  width: 100%;
}
.icon-btn {
  min-height: 52px;
  width: 48px;
  flex: 0 0 48px;
  border-radius: 16px;
  background: rgba(255, 250, 241, 0.8);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--ink);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.wide {
  width: auto;
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
}
.icon-btn.memorize {
  width: 56px;
  flex: 0 0 56px;
  color: var(--pine);
}
.icon-btn.memorize.on {
  background: var(--pine);
  color: #f3f8f4;
  border-color: var(--pine);
}
.card-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center;
  min-height: 24px;
  padding: 8px 0 2px;
  flex-shrink: 0;
}
.tag-pill {
  font-size: 12px;
  background: #f7e6d8;
  color: var(--cinnabar-deep);
  border-radius: 999px;
  padding: 4px 9px;
}

.search-wrap { padding: 4px 0 10px; }
#search {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 0 14px;
  font-size: 16px;
  outline: none;
}
#search:focus { border-color: var(--ink); }
.list-meta { margin: 0 0 8px; font-size: 12px; color: var(--ink-soft); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row {
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
}
.row .jp {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 20px;
}
.row .en { grid-column: 1; font-size: 13px; color: var(--ink-soft); }
.row .mark {
  grid-row: 1 / span 2;
  align-self: center;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--line);
}
.row.done .mark { background: var(--pine); border-color: var(--pine); }
.more {
  margin: 12px auto 0;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  background: var(--paper-deep);
}

.section-kicker {
  margin: 16px 0 6px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.section-kicker.tight { margin-top: 14px; }
.lede { margin: 0 0 12px; color: var(--ink-soft); font-size: 14px; line-height: 1.45; }

.folder-grid { display: grid; gap: 8px; }
.folder {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 12px 14px 16px;
  text-align: left;
  min-height: 64px;
  width: 100%;
}
.folder > button[data-open-tag] { flex: 1; text-align: left; min-height: 44px; }
.folder strong { display: block; font-size: 16px; }
.folder span { color: var(--ink-soft); font-size: 12px; display: block; }
.folder-x {
  min-width: 40px; min-height: 40px;
  border-radius: 12px;
  color: var(--ink-soft);
}

.progress-hero { display: grid; place-items: center; padding: 12px 0 8px; }
.ring { position: relative; width: 168px; height: 168px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(28,22,18,0.08); stroke-width: 10; }
.ring-fg {
  fill: none; stroke: var(--cinnabar); stroke-width: 10;
  stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327;
  transition: stroke-dashoffset 0.4s ease;
}
.ring-label {
  position: absolute; inset: 0; display: grid; place-items: center; align-content: center;
}
.ring-label strong { font-size: 36px; line-height: 1; }
.ring-label span { font-size: 12px; color: var(--ink-soft); }
.progress-copy { text-align: center; color: var(--ink-soft); max-width: 20em; }
.rank-line { text-align: center; font-weight: 700; margin: 4px 0 0; }
.lede.tight { margin-top: 0; }

.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 18px;
}
.theme-card {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 10px 12px;
  min-height: 118px;
  display: grid;
  gap: 6px;
  align-content: start;
}
.theme-card strong { font-size: 15px; }
.theme-card em {
  font-style: normal;
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink-soft);
}
.theme-card.on {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink);
}
.theme-preview {
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.theme-preview-washi {
  background:
    linear-gradient(180deg, rgba(196, 69, 45, 0.18), transparent 42%),
    repeating-linear-gradient(-18deg, #fffaf1, #fffaf1 6px, #efe4cd 6px, #efe4cd 7px);
}
.theme-preview-pixel {
  background:
    linear-gradient(#ff4d8d 0 8px, transparent 8px),
    linear-gradient(90deg, #3dff9a 50%, #ffd64d 50%),
    repeating-linear-gradient(#2a1850, #2a1850 4px, #1b1238 4px, #1b1238 8px);
  background-size: 100% 8px, 100% 16px, 8px 8px;
  background-position: top, bottom, center;
  background-repeat: no-repeat, no-repeat, repeat;
  image-rendering: pixelated;
}

.seal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.seal {
  aspect-ratio: 1;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  min-height: 0;
}
.seal b {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
}
.seal span { font-size: 9px; color: var(--ink-soft); text-align: center; line-height: 1.2; }
.seal.on {
  background: #fff6ef;
  border-color: rgba(196, 69, 45, 0.35);
  box-shadow: inset 0 0 0 2px rgba(196, 69, 45, 0.12);
}
.seal.on b { color: var(--cinnabar-deep); }
.seal:not(.on) { opacity: 0.42; filter: grayscale(0.4); }

.award { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; }
.award:not([hidden]) { display: grid; }
.award-backdrop { position: absolute; inset: 0; background: rgba(28, 22, 18, 0.55); }
.award-panel {
  position: relative;
  width: min(86vw, 340px);
  background: var(--card);
  border-radius: 24px;
  padding: 28px 22px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: award-in 0.4s cubic-bezier(.2,.8,.2,1);
}
@keyframes award-in {
  from { transform: scale(0.88) translateY(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.award-kicker {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
.award-stamp {
  width: 112px; height: 112px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 6px solid var(--cinnabar);
  color: var(--cinnabar);
  display: grid; place-items: center;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 52px;
  transform: rotate(-8deg);
  background: #fff8f3;
  box-shadow: 0 0 0 4px rgba(196, 69, 45, 0.12);
}
.award-panel h2 { margin: 0 0 6px; font-size: 26px; }
.award-panel p:last-of-type { margin: 0 0 18px; color: var(--ink-soft); }
.award-ok {
  width: 100%;
  min-height: 50px;
  border-radius: 14px;
  background: var(--cinnabar);
  color: #fff;
  font-weight: 800;
}

.stats { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px;
}
.stat-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; }
.bar { height: 7px; background: var(--paper-deep); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--cinnabar); width: 0; }

.tools { display: grid; gap: 8px; margin-top: 16px; }
.tool {
  min-height: 48px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
}
.tool.danger { color: var(--cinnabar-deep); }
.credit { font-size: 12px; color: var(--ink-soft); line-height: 1.5; margin-top: 18px; }

.coffee {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: #fffaf1;
  border: 1px solid rgba(196, 69, 45, 0.22);
  color: var(--ink);
  text-decoration: none;
  box-shadow: inset 0 0 0 1px rgba(255, 250, 241, 0.8);
}
.coffee-mark {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--cinnabar);
  color: var(--cinnabar);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: 18px;
  transform: rotate(-6deg);
  background: #fff8f3;
}
.coffee-copy { display: grid; gap: 2px; min-width: 0; text-align: left; }
.coffee-copy strong { font-size: 15px; font-weight: 700; }
.coffee-copy em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-soft);
}

.about {
  max-width: 40em;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 28px) 22px 48px;
}
.about h1 { font-size: 36px; margin: 0 0 8px; }
.about h2 { font-size: 20px; margin: 28px 0 8px; }
.about h3 { font-size: 16px; margin: 18px 0 6px; }
.about p, .about li { line-height: 1.55; }
.about-back { font-weight: 700; }

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(100%, 480px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 250, 241, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(var(--safe-b) + 6px);
  z-index: 20;
}
.tab {
  min-height: 48px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}
.tab.active { background: var(--ink); color: var(--paper); }

.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(28, 22, 18, 0.42); }
.sheet-panel {
  position: absolute; left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 480px);
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(var(--safe-b) + 18px);
  box-shadow: var(--shadow);
}
.sheet-handle {
  width: 42px; height: 4px; border-radius: 99px;
  background: var(--paper-deep); margin: 6px auto 12px;
}
.sheet-panel h2 { margin: 0; font-size: 20px; }
.sheet-sub { margin: 4px 0 12px; color: var(--ink-soft); font-size: 14px; }
.sheet-chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 8px; }
.sheet-chips .chip { min-height: 40px; }
.sheet-chips .chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tag-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 14px 0 8px; }
.tag-form input {
  min-height: 48px; border-radius: 14px; border: 1px solid var(--line);
  padding: 0 12px; font-size: 16px; background: #fff;
}
.tag-form button {
  min-width: 72px; border-radius: 14px; background: var(--ink); color: var(--paper); font-weight: 600;
}
.sheet-done {
  width: 100%; min-height: 50px; margin-top: 16px;
  border-radius: 14px; background: var(--cinnabar); color: #fff; font-weight: 700;
}

.empty {
  text-align: center; color: var(--ink-soft); padding: 28px 12px; line-height: 1.5;
}

/* —— Pixel quest (90s / early-2000s RPG) —— */
html[data-theme="pixel"] {
  --paper: #1b1238;
  --paper-deep: #120c28;
  --card: #fff4c4;
  --ink: #1a1033;
  --ink-soft: #5a3d78;
  --line: #1a1033;
  --cinnabar: #ff4d8d;
  --cinnabar-deep: #d61b6a;
  --pine: #1bb86a;
  --pine-soft: #b8f5d4;
  --gold: #ffd64d;
  --shadow: 6px 6px 0 #0a0618;
  --html-bg: #140e28;
  --radius: 0;
  color-scheme: dark;
}
html[data-theme="pixel"] body {
  color: #efe6ff;
  font-family: "Lucida Console", "Monaco", "Andale Mono", ui-monospace, monospace;
  background-color: #140e28;
  background-image:
    radial-gradient(circle at 14% 16%, #ffd64d 1.2px, transparent 1.6px),
    radial-gradient(circle at 82% 22%, #ff4d8d 1.2px, transparent 1.6px),
    radial-gradient(circle at 64% 78%, #3dff9a 1.2px, transparent 1.6px),
    radial-gradient(circle at 28% 88%, #7ad7ff 1.2px, transparent 1.6px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 8px),
    linear-gradient(180deg, #24184a, #140e28 42%, #0e1a2c);
  -webkit-font-smoothing: none;
}
html[data-theme="pixel"] a { color: #ffd64d; }
html[data-theme="pixel"] .brand h1,
html[data-theme="pixel"] .brand p,
html[data-theme="pixel"] .chip,
html[data-theme="pixel"] .tab,
html[data-theme="pixel"] .tool-btn,
html[data-theme="pixel"] .pager,
html[data-theme="pixel"] .hint,
html[data-theme="pixel"] .badge,
html[data-theme="pixel"] .hud-pill,
html[data-theme="pixel"] .quest-mid span,
html[data-theme="pixel"] .quest-remain,
html[data-theme="pixel"] .combo,
html[data-theme="pixel"] .section-kicker,
html[data-theme="pixel"] .award-kicker,
html[data-theme="pixel"] .award-ok,
html[data-theme="pixel"] .sheet-done,
html[data-theme="pixel"] .tool,
html[data-theme="pixel"] .more,
html[data-theme="pixel"] .icon-btn.wide {
  font-family: "Lucida Console", "Monaco", ui-monospace, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
html[data-theme="pixel"] .word,
html[data-theme="pixel"] .mora b,
html[data-theme="pixel"] .row .jp,
html[data-theme="pixel"] .brand-mark,
html[data-theme="pixel"] .quest-kanji,
html[data-theme="pixel"] .coffee-mini,
html[data-theme="pixel"] .coffee-mark,
html[data-theme="pixel"] .seal b,
html[data-theme="pixel"] .award-stamp,
html[data-theme="pixel"] .meaning {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Source Han Serif", serif;
  text-transform: none;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}
html[data-theme="pixel"] .brand-mark,
html[data-theme="pixel"] .theme-mini,
html[data-theme="pixel"] .coffee-mini,
html[data-theme="pixel"] .hud-pill,
html[data-theme="pixel"] .quest-kanji,
html[data-theme="pixel"] .chip,
html[data-theme="pixel"] .session,
html[data-theme="pixel"] .tool-btn,
html[data-theme="pixel"] .icon-btn,
html[data-theme="pixel"] .tag-pill,
html[data-theme="pixel"] .row,
html[data-theme="pixel"] .folder,
html[data-theme="pixel"] .seal,
html[data-theme="pixel"] .stat,
html[data-theme="pixel"] .tool,
html[data-theme="pixel"] .more,
html[data-theme="pixel"] .coffee,
html[data-theme="pixel"] .theme-card,
html[data-theme="pixel"] .tab,
html[data-theme="pixel"] .search-wrap #search,
html[data-theme="pixel"] .tag-form input,
html[data-theme="pixel"] .tag-form button,
html[data-theme="pixel"] .sheet-done,
html[data-theme="pixel"] .award-ok,
html[data-theme="pixel"] .folder-x,
html[data-theme="pixel"] .session button {
  border-radius: 0;
}
html[data-theme="pixel"] .brand-mark {
  background: #ffd64d;
  color: #1a1033;
  border: 3px solid #1a1033;
  box-shadow: 3px 3px 0 #ff4d8d;
}
html[data-theme="pixel"] .brand h1 { color: #fff4c4; font-size: 16px; }
html[data-theme="pixel"] .brand p { color: #c9b6ff; }
html[data-theme="pixel"] .theme-mini {
  background: #2a1850;
  border: 3px solid #ffd64d;
  box-shadow: 3px 3px 0 #0a0618;
}
html[data-theme="pixel"] .theme-swatch { border-radius: 0; }
html[data-theme="pixel"] .coffee-mini {
  background: #fff4c4;
  border: 3px solid #ff4d8d;
  color: #d61b6a;
  box-shadow: 3px 3px 0 #0a0618;
}
html[data-theme="pixel"] .hud-pill {
  background: #2a1850;
  color: #efe6ff;
  border: 3px solid #6b5cff;
  box-shadow: 3px 3px 0 #0a0618;
}
html[data-theme="pixel"] .hud-pill.ink {
  background: #ffd64d;
  color: #1a1033;
  border-color: #1a1033;
}
html[data-theme="pixel"] .quest-kanji {
  background: #fff4c4;
  border: 3px solid #ff4d8d;
  color: #d61b6a;
  box-shadow: 3px 3px 0 #0a0618;
}
html[data-theme="pixel"] .quest-mid span { color: #c9b6ff; }
html[data-theme="pixel"] .quest-track {
  height: 10px;
  border-radius: 0;
  background: #0a0618;
  box-shadow: inset 0 0 0 2px #6b5cff;
}
html[data-theme="pixel"] .quest-track i {
  background: repeating-linear-gradient(
    90deg,
    #3dff9a 0 6px,
    #1bb86a 6px 8px
  );
  transition: width 0.12s steps(6);
}
html[data-theme="pixel"] .quest-remain { color: #ffd64d; }
html[data-theme="pixel"] .chips { padding-bottom: 14px; }
html[data-theme="pixel"] .actions { padding-bottom: 4px; }
html[data-theme="pixel"] .chip {
  background: #2a1850;
  color: #c9b6ff;
  border: 3px solid #6b5cff;
  box-shadow: 3px 3px 0 #0a0618;
  font-size: 10px;
}
html[data-theme="pixel"] .chip.active {
  background: #ffd64d;
  color: #1a1033;
  border-color: #1a1033;
}
html[data-theme="pixel"] .session {
  background: #fff4c4;
  color: #1a1033;
  border: 3px solid #1a1033;
  box-shadow: 4px 4px 0 #ff4d8d;
}
html[data-theme="pixel"] .session button { background: #ffd64d; }
html[data-theme="pixel"] .face {
  background: #fff4c4;
  border: 4px solid #1a1033;
  box-shadow:
    0 0 0 3px #ffd64d,
    6px 6px 0 #0a0618;
  color: #1a1033;
}
html[data-theme="pixel"] .face::before {
  width: 8px;
  top: 8px;
  bottom: 8px;
  border-radius: 0;
  background: repeating-linear-gradient(
    to bottom,
    #ff4d8d 0 7px,
    #ffd64d 7px 14px,
    #3dff9a 14px 21px
  );
}
html[data-theme="pixel"] .card-inner { transition: transform 0.2s ease; }
html[data-theme="pixel"] .badge {
  border-radius: 0;
  background: #1a1033;
  color: #ffd64d;
  border: 2px solid #ffd64d;
}
html[data-theme="pixel"] .mora { color: #1a1033; }
html[data-theme="pixel"] .mora i,
html[data-theme="pixel"] .mora em { color: #d61b6a; }
html[data-theme="pixel"] .mora.special {
  border-radius: 0;
  background: #ffe08a;
  box-shadow: inset 0 0 0 2px #d61b6a;
}
html[data-theme="pixel"] .sound-note {
  border-radius: 0;
  background: #ffe08a;
  color: #1a1033;
  border: 2px solid #1a1033;
}
html[data-theme="pixel"] .hint { color: #8a6a20; }
html[data-theme="pixel"] .meaning,
html[data-theme="pixel"] .ex-ja { color: #1a1033; }
html[data-theme="pixel"] .ex-en { color: #5a3d78; }
html[data-theme="pixel"] .tool-btn {
  background: #2a1850;
  color: #efe6ff;
  border: 3px solid #6b5cff;
  box-shadow: 3px 3px 0 #0a0618;
  font-size: 10px;
}
html[data-theme="pixel"] .tool-btn.on {
  background: #ffd64d;
  color: #1a1033;
  border-color: #1a1033;
}
html[data-theme="pixel"] .pager { color: #c9b6ff; }
html[data-theme="pixel"] .combo {
  border-radius: 0;
  background: #ff4d8d;
  box-shadow: 3px 3px 0 #0a0618;
}
html[data-theme="pixel"] .icon-btn {
  background: #fff4c4;
  border: 3px solid #1a1033;
  box-shadow: 3px 3px 0 #0a0618;
  color: #1a1033;
}
html[data-theme="pixel"] .icon-btn.memorize { color: #1bb86a; }
html[data-theme="pixel"] .icon-btn.memorize.on {
  background: #3dff9a;
  color: #0a2014;
  border-color: #1a1033;
}
html[data-theme="pixel"] .tag-pill {
  background: #ff4d8d;
  color: #fff4c4;
}
html[data-theme="pixel"] #search,
html[data-theme="pixel"] .row,
html[data-theme="pixel"] .folder,
html[data-theme="pixel"] .stat,
html[data-theme="pixel"] .tool,
html[data-theme="pixel"] .theme-card {
  background: #2a1850;
  color: #efe6ff;
  border: 3px solid #6b5cff;
  box-shadow: 4px 4px 0 #0a0618;
}
html[data-theme="pixel"] #search:focus { border-color: #ffd64d; }
html[data-theme="pixel"] #search::placeholder { color: #c9b6ff; }
html[data-theme="pixel"] .row .en,
html[data-theme="pixel"] .folder span,
html[data-theme="pixel"] .list-meta,
html[data-theme="pixel"] .lede,
html[data-theme="pixel"] .progress-copy,
html[data-theme="pixel"] .credit,
html[data-theme="pixel"] .empty,
html[data-theme="pixel"] .theme-card em { color: #c9b6ff; }
html[data-theme="pixel"] .row .jp { color: #fff4c4; }
html[data-theme="pixel"] .row .mark {
  border-radius: 0;
  border: 3px solid #6b5cff;
  background: #140e28;
}
html[data-theme="pixel"] .row.done .mark {
  background: #3dff9a;
  border-color: #1a1033;
}
html[data-theme="pixel"] .more {
  background: #ffd64d;
  color: #1a1033;
  border: 3px solid #1a1033;
  box-shadow: 3px 3px 0 #0a0618;
}
html[data-theme="pixel"] .section-kicker { color: #ffd64d; }
html[data-theme="pixel"] .rank-line { color: #fff4c4; }
html[data-theme="pixel"] .theme-card.on {
  border-color: #ffd64d;
  box-shadow: 4px 4px 0 #ff4d8d;
}
html[data-theme="pixel"] .theme-preview { border-radius: 0; border-color: #1a1033; }
html[data-theme="pixel"] .ring-bg { stroke: #6b5cff; }
html[data-theme="pixel"] .ring-fg { stroke: #ff4d8d; stroke-linecap: square; }
html[data-theme="pixel"] .ring-label strong { color: #fff4c4; }
html[data-theme="pixel"] .seal {
  background: #2a1850;
  border: 3px solid #6b5cff;
}
html[data-theme="pixel"] .seal.on {
  background: #fff4c4;
  border-color: #1a1033;
  box-shadow: 3px 3px 0 #ff4d8d;
}
html[data-theme="pixel"] .seal.on b { color: #d61b6a; }
html[data-theme="pixel"] .seal span { color: #c9b6ff; }
html[data-theme="pixel"] .seal.on span { color: #5a3d78; }
html[data-theme="pixel"] .bar {
  border-radius: 0;
  background: #0a0618;
  box-shadow: inset 0 0 0 2px #6b5cff;
}
html[data-theme="pixel"] .bar i {
  background: repeating-linear-gradient(90deg, #ff4d8d 0 6px, #d61b6a 6px 8px);
}
html[data-theme="pixel"] .tool.danger { color: #ff9ac4; }
html[data-theme="pixel"] .coffee {
  background: #fff4c4;
  color: #1a1033;
  border: 3px solid #1a1033;
  box-shadow: 4px 4px 0 #ff4d8d;
}
html[data-theme="pixel"] .coffee-mark {
  border-radius: 0;
  background: #ffd64d;
  border: 3px solid #1a1033;
  color: #1a1033;
}
html[data-theme="pixel"] .coffee-copy em { color: #5a3d78; }
html[data-theme="pixel"] .tabbar {
  background: #0a0618;
  border-top: 4px solid #ffd64d;
  backdrop-filter: none;
}
html[data-theme="pixel"] .tab { color: #c9b6ff; font-size: 10px; }
html[data-theme="pixel"] .tab.active {
  background: #ffd64d;
  color: #1a1033;
  box-shadow: inset 0 4px 0 #ff4d8d;
}
html[data-theme="pixel"] .sheet-backdrop,
html[data-theme="pixel"] .award-backdrop { background: rgba(10, 6, 24, 0.72); }
html[data-theme="pixel"] .sheet-panel,
html[data-theme="pixel"] .award-panel {
  background: #fff4c4;
  color: #1a1033;
  border: 4px solid #1a1033;
  border-radius: 0;
  box-shadow: 0 0 0 4px #ffd64d, 8px 8px 0 #0a0618;
}
html[data-theme="pixel"] .sheet-handle {
  border-radius: 0;
  background: #1a1033;
}
html[data-theme="pixel"] .sheet-sub { color: #5a3d78; }
html[data-theme="pixel"] .tag-form input {
  background: #fffdf2;
  border: 3px solid #1a1033;
  color: #1a1033;
}
html[data-theme="pixel"] .tag-form button,
html[data-theme="pixel"] .sheet-done,
html[data-theme="pixel"] .award-ok {
  background: #ff4d8d;
  color: #fff4c4;
  border: 3px solid #1a1033;
  box-shadow: 4px 4px 0 #0a0618;
}
html[data-theme="pixel"] .award-stamp {
  border-radius: 0;
  transform: none;
  background: #ffd64d;
  border: 6px solid #1a1033;
  color: #1a1033;
  box-shadow: 5px 5px 0 #ff4d8d;
}
html[data-theme="pixel"] .award-panel h2 { color: #1a1033; }
html[data-theme="pixel"] .award-panel p:last-of-type { color: #5a3d78; }
html[data-theme="pixel"] .float-pop {
  border-radius: 0;
  background: #ffd64d;
  color: #1a1033;
  border: 3px solid #1a1033;
  box-shadow: 4px 4px 0 #ff4d8d;
  animation: pixel-float 0.9s steps(6) forwards;
}
html[data-theme="pixel"] .card.sealed .card-inner { animation: pixel-seal 0.28s steps(4); }
html[data-theme="pixel"] .about { color: #efe6ff; }
html[data-theme="pixel"] .about h1,
html[data-theme="pixel"] .about h2,
html[data-theme="pixel"] .about h3 { color: #fff4c4; }
@keyframes pixel-seal {
  0% { transform: scale(1); }
  40% { transform: scale(1.06) translate(-2px, -2px); }
  70% { transform: scale(0.98) translate(2px, 2px); }
  100% { transform: scale(1); }
}
@keyframes pixel-float {
  0% { opacity: 0; transform: translateX(-50%) translateY(8px); }
  16% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-18px); }
}
