/* styles.css — Judo Canon. Tokens on :root, dark mode via prefers-color-scheme.
   Palette: paper + ink with a single red accent (the hinomaru); belt colours mark families. */
:root {
  --bg: #f7f5f0; --surface: #ffffff; --surface-2: #efece4; --ink: #1b1a17; --muted: #6b675e;
  --line: #ddd8cc; --accent: #c8102e; --accent-ink: #ffffff; --ok: #1f7a4d; --warn: #a15c00;
  --new: #8a857a; --learning: #b7791f; --mastered: #1f7a4d;
  --radius: 12px; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --surface: #1c1b19; --surface-2: #262522; --ink: #f0ede6; --muted: #a29d92;
    --line: #34322e; --accent: #ff4d5e; --accent-ink: #1b0004; --ok: #4cc38a; --warn: #f0a33a;
    --new: #8a857a; --learning: #e0a13a; --mastered: #4cc38a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --surface: #1c1b19; --surface-2: #262522; --ink: #f0ede6; --muted: #a29d92;
  --line: #34322e; --accent: #ff4d5e; --accent-ink: #1b0004; --ok: #4cc38a; --warn: #f0a33a;
  --new: #8a857a; --learning: #e0a13a; --mastered: #4cc38a; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 Inter, system-ui, sans-serif; }
a { color: inherit; }
.jp { font-family: 'Noto Serif JP', serif; }
button { font: inherit; color: inherit; cursor: pointer; }

.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; font-size: 18px; }
.brand-jp { font-family: 'Noto Serif JP', serif; color: var(--muted); font-weight: 500; font-size: 14px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); }
nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
nav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 500; font-size: 14px; }
nav a[aria-current="page"] { background: var(--ink); color: var(--bg); }

main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 48px; outline: none; }
.foot { max-width: 1080px; margin: 0 auto; padding: 24px 16px 40px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

h1 { font-size: clamp(26px, 5vw, 36px); line-height: 1.15; margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 20px; margin: 32px 0 12px; }
h3 { font-size: 16px; margin: 0 0 4px; }
.lede { color: var(--muted); max-width: 62ch; margin: 0 0 20px; }
.muted { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Stats + bars */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 16px 0 8px; }
.stat b { display: block; font-size: 28px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .m { background: var(--mastered); } .bar .l { background: var(--learning); }

/* Path */
.path { display: grid; gap: 12px; }
.step { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; text-decoration: none; }
.step .num { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: var(--surface-2); border: 2px solid var(--line); }
.step.done .num { background: var(--mastered); border-color: var(--mastered); color: var(--bg); }
.step .meta { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; background: var(--surface); }
.chip[data-s="mastered"] { border-color: var(--mastered); color: var(--mastered); }
.chip[data-s="learning"] { border-color: var(--learning); color: var(--learning); }

/* Browse */
.filters { display: grid; gap: 8px; grid-template-columns: 1fr; margin-bottom: 16px; }
@media (min-width: 720px) { .filters { grid-template-columns: 2fr repeat(3, 1fr); } }
input[type="search"], select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit; }
.tile { display: flex; flex-direction: column; gap: 4px; text-decoration: none; transition: transform .12s, border-color .12s; position: relative; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile .k { font-family: 'Noto Serif JP', serif; font-size: 22px; }
.tile .en { color: var(--muted); font-size: 14px; }
.tile .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.tag.ban { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.status { position: absolute; top: 14px; right: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.status[data-s="learning"] { background: var(--learning); } .status[data-s="mastered"] { background: var(--mastered); }
.group-h { display: flex; align-items: baseline; gap: 10px; margin: 28px 0 10px; }
.group-h .jp { color: var(--muted); }

/* Detail */
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); }
.hero { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .hero { grid-template-columns: 1.4fr 1fr; } }
.big-kanji { font-family: 'Noto Serif JP', serif; font-size: clamp(48px, 12vw, 84px); line-height: 1; margin: 4px 0 12px; }
.decode { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.decode span { display: inline-flex; flex-direction: column; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.decode b { font-size: 15px; }
.cue { border-left: 3px solid var(--accent); padding: 4px 12px; margin: 16px 0; font-style: italic; }
.links { display: grid; gap: 8px; }
.link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  text-decoration: none; background: var(--surface); font-size: 14px; }
.link:hover { border-color: var(--accent); }
.link .play { width: 28px; height: 20px; border-radius: 5px; background: var(--accent); flex: none; position: relative; }
.link .play::after { content: ''; position: absolute; left: 11px; top: 5px; border-left: 8px solid var(--accent-ink); border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.link.bout .play { background: var(--ink); } .link.bout .play::after { border-left-color: var(--bg); }
.pager { display: flex; justify-content: space-between; gap: 8px; margin-top: 28px; }

/* Buttons */
.btn { padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.sel { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg .btn { padding: 6px 12px; font-size: 14px; font-weight: 500; }

/* Flashcards */
.flash { max-width: 640px; margin: 0 auto; }
.fc { min-height: 300px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 8px; padding: 28px 20px; }
.fc .big { font-size: clamp(26px, 6vw, 36px); font-weight: 700; }
.fc .answer { width: 100%; text-align: left; border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.grades .btn { justify-content: center; flex-direction: column; gap: 0; font-size: 14px; padding: 8px 4px; }
.grades small { font-weight: 400; color: var(--muted); font-size: 11px; }
.kbd { font-size: 11px; color: var(--muted); }

/* Quiz */
.q-prompt { font-size: 20px; font-weight: 600; margin: 8px 0 16px; }
.choices { display: grid; gap: 8px; }
.choice { text-align: left; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.choice:hover:not(:disabled) { border-color: var(--ink); }
.choice.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.choice.wrong { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.choice:disabled { cursor: default; }

/* Decoder */
.vocab { display: grid; gap: 6px 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.vocab div { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.vocab b { font-weight: 600; }
table.gl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.gl td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* Lessons */
.points { padding-left: 0; list-style: none; display: grid; gap: 10px; }
.points li { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: baseline; }
.ts { font: 600 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent); background: var(--surface-2); border-radius: 6px; text-align: center; padding: 1px 0; }
.fw { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; }
.mention { margin-bottom: 8px; padding: 12px 14px; }
