:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-2: #efebe2;
  --text: #1d1d1f;
  --muted: #6b6a66;
  --line: #e2ddd2;
  --accent: #1f4e8c;      /* judogi blue */
  --accent-ink: #ffffff;
  --red: #b3261e;
  --good: #2e7d32;
  --star: #c98a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --belt-white: #f4f4f4;
  --belt-yellow: #f2c400;
  --belt-orange: #f08a00;
  --belt-green: #2f9e44;
  --belt-blue: #1c64c8;
  --belt-brown: #7a4a22;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181c; --surface: #1f2228; --surface-2: #2a2e35; --text: #ececec; --muted: #a0a3a8;
    --line: #33373f; --accent: #7fb0ff; --accent-ink: #0d1626; --red: #ff8a80; --good: #81c784; --star: #ffcc4d;
    --shadow: none; --belt-white: #d9d9d9; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16181c; --surface: #1f2228; --surface-2: #2a2e35; --text: #ececec; --muted: #a0a3a8;
  --line: #33373f; --accent: #7fb0ff; --accent-ink: #0d1626; --red: #ff8a80; --good: #81c784; --star: #ffcc4d;
  --shadow: none; --belt-white: #d9d9d9; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans CJK JP", sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
.ja { font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", "Noto Serif CJK SC", serif; }

/* top bar */
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.bar h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back, .bar-search { border: 0; background: none; font-size: 28px; line-height: 1; padding: 0 6px 2px 0; color: var(--accent); cursor: pointer; }
.bar-search { font-size: 24px; padding: 0 0 0 6px; }

main { padding: 12px 16px 24px; max-width: 720px; margin: 0 auto; outline: none; }

/* tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 0 6px; font-size: 11px; color: var(--muted); }
.tabs a span { font-size: 20px; line-height: 1.1; font-family: "Hiragino Mincho ProN", "Noto Serif CJK JP", serif; }
.tabs a.on { color: var(--accent); }

.offline { position: fixed; left: 16px; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg);
  border-radius: 10px; padding: 8px 12px; font-size: 14px; text-align: center; z-index: 6; }

/* generic */
h2 { font-size: 22px; margin: 18px 0 8px; }
h3 { font-size: 17px; margin: 18px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin: 10px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 9px 14px; font-size: 15px; cursor: pointer; min-height: 40px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.on { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.btn.star.on { color: var(--star); border-color: var(--star); background: color-mix(in srgb, var(--star) 12%, var(--surface)); }
.btn.good.on { color: var(--good); border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; color: var(--text); min-height: 52px; }
.list .n { width: 22px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; flex: none; }
.list .nm { flex: 1; min-width: 0; }
.list .nm b { font-weight: 600; display: block; }
.list .nm .ja { color: var(--muted); font-size: 14px; }
.list .ic { color: var(--muted); font-size: 13px; white-space: nowrap; }
.list .ic .st { color: var(--star); }
.list .ic .ok { color: var(--good); }
.list .chev { color: var(--muted); }

/* home */
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--text); box-shadow: var(--shadow); min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; }
.tile .big { font-size: 26px; }
.tile b { font-size: 16px; }
.tile.wide { grid-column: 1 / -1; }
.search { width: 100%; font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }

/* technique page */
.tq-head { margin: 4px 0 10px; }
.tq-head .ja { font-size: 40px; line-height: 1.15; display: block; }
.tq-head h2 { margin: 2px 0 6px; font-size: 26px; }
.def { font-size: 17px; }
.def::before { content: "Kodokan definition"; display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; margin: 10px 0; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video button { position: absolute; inset: 0; width: 100%; border: 0; background: radial-gradient(circle at center, #2a2f38, #0e1014); color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.video button .play { width: 64px; height: 64px; border-radius: 50%; background: #c4302b; display: grid; place-items: center; font-size: 26px; padding-left: 4px; }
.novideo { padding: 14px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 15px; }
.photo img, .fig img { max-width: 100%; height: auto; border-radius: 10px; display: block; background: #fff; }
.fig { margin: 10px 0; text-align: center; }
.fig img { margin: 0 auto; min-width: 154px; image-rendering: auto; }
.fig figcaption { font-size: 13px; color: var(--muted); }
.detail p { margin: 8px 0; }
.detail h4 { margin: 16px 0 4px; font-size: 16px; }
details.card > summary { font-weight: 600; cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "＋"; float: right; color: var(--muted); }
details[open].card > summary::after { content: "－"; }
.src { font-size: 13px; color: var(--muted); margin-top: 18px; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; }
.pager a { flex: 1; }

/* belts */
.belt { display: flex; align-items: center; gap: 10px; }
.belt .stripe { width: 46px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.bar-prog { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar-prog i { display: block; height: 100%; background: var(--good); }
.note { font-size: 14px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }

/* quiz */
.q-prompt { font-size: 18px; }
.q-prompt .ja { font-size: 46px; display: block; text-align: center; padding: 8px 0; }
.opts { display: grid; gap: 8px; margin-top: 12px; }
.opt { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; font-size: 16px; cursor: pointer; min-height: 48px; }
.opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.opt.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 12%, var(--surface)); }
.score { font-variant-numeric: tabular-nums; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }

/* check page */
.check-item { margin: 14px 0; }
.check-item .video { margin: 6px 0; }

@media (min-width: 560px) { .hero { grid-template-columns: repeat(3, 1fr); } }
