/* ==========================================================================
   Nihonpo — design system
   Token-based, light/dark via [data-theme]. Mobile-first.
   ========================================================================== */

/* ---- Design tokens ------------------------------------------------------- */
:root {
  --accent: #d6303a;
  --accent-strong: #b3242b;
  --accent-soft: #fdecec;
  --accent-contrast: #ffffff;

  --bg: #faf8f5;
  --bg-elev: #ffffff;
  --bg-sunken: #f2efe9;
  --surface: #ffffff;
  --surface-2: #f7f4ef;

  --text: #1c1b22;
  --text-soft: #55525e;
  --text-faint: #8a8794;
  --border: #e9e4db;
  --border-strong: #d8d2c6;

  --ja: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', Meiryo, sans-serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --n5: #2a9d6f; --n4: #2f8fd0; --n3: #8257d6; --n2: #d6803a; --n1: #d6303a;

  --shadow-sm: 0 1px 2px rgba(28, 27, 34, .06), 0 1px 3px rgba(28, 27, 34, .04);
  --shadow-md: 0 4px 12px rgba(28, 27, 34, .08), 0 2px 4px rgba(28, 27, 34, .04);
  --shadow-lg: 0 12px 32px rgba(28, 27, 34, .14);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;

  --shell: 1080px;
  --step: clamp(.9rem, 2.4vw, 1rem);
  --header-h: 56px;
}

[data-theme="dark"] {
  --accent: #ff5a63;
  --accent-strong: #ff6b73;
  --accent-soft: #34232a;
  --accent-contrast: #1a1118;

  --bg: #141319;
  --bg-elev: #1c1b23;
  --bg-sunken: #100f15;
  --surface: #1f1d27;
  --surface-2: #26232f;

  --text: #ece9f1;
  --text-soft: #b3aec0;
  --text-faint: #807b8e;
  --border: #2e2b38;
  --border-strong: #3a3646;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6);
}

/* ---- Reset / base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--step);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { line-height: 1.25; font-weight: 700; letter-spacing: -.012em; }
h1 { font-size: clamp(1.55rem, 4.5vw, 2.3rem); margin: 0 0 .4em; }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); margin: 1.8em 0 .6em; }
h3 { font-size: 1.05rem; margin: 1.2em 0 .4em; }
p { margin: 0 0 1em; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
:lang(ja) { font-family: var(--ja); }
button { font-family: inherit; cursor: pointer; }
ul, ol { margin: 0; padding: 0; }
li { list-style: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.shell { width: 100%; max-width: var(--shell); margin-inline: auto; padding-inline: clamp(16px, 4vw, 28px); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

main.shell { padding-top: 28px; padding-bottom: 64px; }

/* ---- Header -------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 18px; min-height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text); letter-spacing: -.02em; font-size: 1.12rem; }
.brand:hover { text-decoration: none; }
.brand-logo { border-radius: 6px; }
.main-nav { margin-inline-start: auto; }
.nav-list { display: flex; flex-wrap: wrap; gap: 2px; }
.nav-item { position: relative; }
.nav-top { display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px; border: 0; background: transparent; border-radius: 8px; color: var(--text-soft); font-weight: 600; font-size: .92rem; white-space: nowrap; }
.nav-top:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-top[aria-current="page"], .nav-top.is-active { color: var(--accent-strong); background: var(--accent-soft); }
.nav-caret { font-size: .62em; opacity: .65; }
.nav-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 184px; z-index: 50;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; display: none; flex-direction: column; gap: 1px;
}
/* Invisible bridge across the 6px gap so hover survives moving from button to dropdown. */
.nav-dropdown::before { content: ""; position: absolute; left: 0; right: 0; top: -6px; height: 6px; }
.nav-item.has-dropdown:hover > .nav-dropdown,
.nav-item.has-dropdown:focus-within > .nav-dropdown,
.nav-item.has-dropdown.is-open > .nav-dropdown { display: flex; }
.nav-dropdown a { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-soft); font-size: .9rem; font-weight: 600; white-space: nowrap; }
.nav-dropdown a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-dropdown a.is-current { color: var(--accent-strong); background: var(--accent-soft); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.search-trigger {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface); color: var(--text-soft); font-size: .88rem; font-weight: 600;
}
.search-trigger:hover { border-color: var(--accent); color: var(--accent-strong); }
.theme-toggle {
  padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface); color: var(--text-soft); font-size: .82rem; font-weight: 600; white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent-strong); }

/* ---- Breadcrumbs --------------------------------------------------------- */
.breadcrumbs { border-bottom: 1px solid var(--border); background: var(--bg); }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 6px; padding-block: 10px; font-size: .84rem; color: var(--text-faint); }
.breadcrumbs li { display: flex; align-items: center; gap: 6px; }
.breadcrumbs li:not(:last-child)::after { content: "›"; color: var(--text-faint); }
.breadcrumbs a { color: var(--text-soft); }
.breadcrumbs li[aria-current] { color: var(--text); font-weight: 600; }

/* ---- Page head / prose --------------------------------------------------- */
.page-head { margin-bottom: 22px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .76rem; font-weight: 700; color: var(--accent-strong); margin: 0 0 .5em; }
.lede { font-size: clamp(1rem, 2.4vw, 1.12rem); color: var(--text-soft); max-width: 70ch; }
.block-head { margin-bottom: 16px; }
.block-head h2 { margin-top: 0; }
.block-head p { color: var(--text-soft); margin: 0; }
.hub-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hub-links a { padding: 6px 13px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft); font-size: .86rem; font-weight: 600; }
.hub-links a:hover { border-color: var(--accent); color: var(--accent-strong); text-decoration: none; }

/* ---- Buttons ------------------------------------------------------------- */
.btn-primary, .btn-ghost { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 999px; font-weight: 700; font-size: .96rem; border: 1px solid transparent; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-strong); text-decoration: none; }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }

/* ---- Hero ---------------------------------------------------------------- */
.hero { padding: 28px 0 8px; }
.hero h1 { max-width: 16ch; }
.hero .lede { margin-bottom: 24px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.home-block { margin-top: 44px; }

/* ---- Cards: level / section --------------------------------------------- */
.level-card-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); }
.level-card {
  display: flex; gap: 14px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: var(--text);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.level-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.level-card-tag {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 11px; display: grid; place-items: center;
  font-weight: 800; font-size: 1.05rem; background: var(--accent-soft); color: var(--accent-strong);
}
.level-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.level-card-body strong { font-size: 1.02rem; }
.level-card-meta { font-size: .82rem; color: var(--accent-strong); font-weight: 600; }
.level-card-blurb { font-size: .86rem; color: var(--text-soft); }

.section-card-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.section-card { padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: var(--text); transition: transform .12s ease, box-shadow .12s ease; }
.section-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.section-card h3 { margin: 0 0 4px; }
.section-card-count { color: var(--accent-strong); font-weight: 700; font-size: .9rem; margin: 0 0 6px; }
.section-card-desc { color: var(--text-soft); font-size: .9rem; margin: 0; }

/* ---- Study path (level hub) --------------------------------------------- */
.study-step-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.study-step { display: flex; gap: 14px; align-items: flex-start; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: var(--text); transition: transform .12s ease, box-shadow .12s ease; }
.study-step:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.study-step.is-disabled { opacity: .55; pointer-events: none; }
.step-num { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-contrast); font-weight: 800; }
.step-body { display: flex; flex-direction: column; gap: 2px; }
.step-body strong { font-size: 1.06rem; }
.step-count { color: var(--accent-strong); font-weight: 700; font-size: .88rem; }
.step-sub { color: var(--text-soft); font-size: .85rem; }
.step-progress { margin-top: 6px; font-size: .78rem; color: var(--text-faint); }
.level-adjacent { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
.level-adjacent a { font-weight: 600; }

/* ---- Grammar list -------------------------------------------------------- */
.grammar-group { margin-top: 26px; }
.grammar-group-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 1.15rem; }
.grammar-group-count { font-size: .8rem; font-weight: 700; color: var(--text-faint); background: var(--surface-2); padding: 2px 9px; border-radius: 999px; }
.grammar-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grammar-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.grammar-row:hover { border-color: var(--accent); }
.grammar-row > a { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-width: 0; color: var(--text); }
.grammar-row > a:hover { text-decoration: none; }
.grammar-row-form { font-family: var(--ja); font-size: 1.1rem; font-weight: 700; }
.grammar-row-gloss { font-size: .82rem; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grammar-row-meta { flex: 0 0 auto; font-size: .74rem; color: var(--text-faint); font-weight: 600; }

/* ---- Grammar / kanji detail --------------------------------------------- */
.grammar-detail, .kanji-detail { max-width: 760px; }
.detail-head { padding-bottom: 18px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.detail-eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: .82rem; font-weight: 600; }
.detail-head h1 { font-family: var(--ja); font-size: clamp(2rem, 7vw, 3rem); margin: 0; }
.detail-gloss { font-size: 1.15rem; color: var(--text-soft); margin: 6px 0 0; }
.detail-romaji { font-size: .9rem; color: var(--text-faint); margin: 8px 0 0; }
.detail-romaji em { color: var(--text-soft); font-style: normal; }
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: var(--surface-2); color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }
.badge-basic { background: rgba(42, 157, 111, .14); color: var(--n5); }
.badge-intermediate { background: rgba(130, 87, 214, .14); color: var(--n3); }
.badge-advanced { background: rgba(214, 48, 58, .14); color: var(--n1); }
.learn-toggle { display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: .88rem; font-weight: 600; color: var(--text-soft); cursor: pointer; }
.learn-toggle:hover { border-color: var(--accent); }
.learn-toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.learn-toggle.is-learned { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }

.detail-section { margin-top: 26px; }
.detail-section h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.count-chip { font-size: .78rem; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft); padding: 2px 10px; border-radius: 999px; }
.detail-notes { margin-top: 14px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.detail-notes h3 { margin: 0 0 6px; font-size: .92rem; }

/* ---- Examples ------------------------------------------------------------ */
.example-list { display: flex; flex-direction: column; gap: 10px; }
.example { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.example-ja-row { display: flex; align-items: flex-start; gap: 12px; }
.example-ja { font-family: var(--ja); font-size: 1.18rem; line-height: 1.7; margin: 0; }
.example-en { color: var(--text-soft); margin: 8px 0 0; padding-inline-start: 40px; font-size: .94rem; }

/* ---- Audio button -------------------------------------------------------- */
.audio-btn {
  flex: 0 0 auto; width: 30px; height: 30px; margin-top: 4px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--accent-strong);
  display: inline-grid; place-items: center; transition: background .12s ease, transform .1s ease;
}
.audio-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.audio-btn.is-playing { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.audio-btn svg { width: 13px; height: 13px; }
.audio-btn:active { transform: scale(.92); }

/* ---- Furigana ------------------------------------------------------------ */
ruby rt { font-size: .56em; color: var(--text-faint); font-weight: 400; transition: opacity .15s ease; }
ruby.furigana-hidden rt { opacity: 0; }

/* ---- prev/next + related ------------------------------------------------- */
.detail-pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
.detail-pager a { display: flex; flex-direction: column; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.detail-pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager-next { text-align: right; align-items: flex-end; }
.detail-pager span { font-size: .74rem; color: var(--text-faint); }
.detail-pager strong { font-family: var(--ja); font-size: 1.05rem; }
.pager-up { justify-content: center; align-items: center; font-size: .82rem; font-weight: 600; color: var(--text-soft); }
.related { margin-top: 34px; }
.related-list { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.related-list a { display: flex; flex-direction: column; gap: 1px; padding: 10px 13px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.related-list a:hover { border-color: var(--accent); text-decoration: none; }
.related-list a span:first-child { font-family: var(--ja); font-weight: 700; }
.related-list a span:last-child { font-size: .78rem; color: var(--text-soft); }

/* ---- Vocab cards --------------------------------------------------------- */
.vocab-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.vocab-card { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.vocab-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vocab-word { font-family: var(--ja); font-size: 1.5rem; font-weight: 700; margin: 0; }
.vocab-reading { font-family: var(--ja); color: var(--text-soft); font-size: .95rem; }
.vocab-head-end { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 10px; }
.vocab-head-end .audio-btn { margin-top: 0; }
.vocab-pos { font-size: .72rem; font-weight: 600; color: var(--text-faint); background: var(--surface-2); padding: 2px 9px; border-radius: 999px; text-transform: lowercase; }
.vocab-meaning { margin: 8px 0 0; }
.vocab-examples { display: flex; flex-direction: column; }
.vocab-example { display: flex; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.vocab-example-ja { font-family: var(--ja); margin: 0; font-size: 1rem; }
.vocab-example-en { margin: 4px 0 0; color: var(--text-soft); font-size: .86rem; }

/* ---- Sentence cards ------------------------------------------------------ */
.sentence-list { display: flex; flex-direction: column; gap: 12px; }
.sentence-card { padding: 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.sentence-ja-row { display: flex; align-items: flex-start; gap: 12px; }
.sentence-ja { font-family: var(--ja); font-size: 1.22rem; line-height: 1.75; margin: 0; }
.sentence-reveal { margin-inline-start: auto; flex: 0 0 auto; align-self: center; font-size: .76rem; font-weight: 600; color: var(--accent-strong); background: var(--surface-2); border: 1px solid var(--border); padding: 4px 12px; border-radius: 999px; cursor: pointer; transition: background .12s ease, border-color .12s ease; }
.sentence-reveal:hover { background: var(--accent-soft); border-color: var(--accent); }
.sentence-reveal[aria-expanded="true"] { color: var(--text-soft); }
.sentence-details { margin-top: 8px; }
.sentence-reading { font-family: var(--ja); font-size: 1rem; line-height: 1.6; color: var(--text-soft); margin: 0; padding-inline-start: 42px; }
.sentence-en { color: var(--text-soft); margin: 8px 0 0; padding-inline-start: 42px; }
.sentence-vocab { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.sentence-vocab li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; background: var(--surface-2); font-size: .8rem; }
.sv-word { font-family: var(--ja); font-weight: 700; }
.sv-reading { font-family: var(--ja); color: var(--text-faint); }
.sv-meaning { color: var(--text-soft); }
.sv-level { font-size: .66rem; font-weight: 700; color: var(--accent-strong); }

/* ---- Kanji --------------------------------------------------------------- */
.kanji-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.kanji-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); color: var(--text); text-align: center; transition: transform .12s ease, border-color .12s ease; }
.kanji-cell:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.kanji-cell-glyph { font-family: var(--ja); font-size: 2rem; font-weight: 700; }
.kanji-cell-meaning { font-size: .72rem; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.kanji-detail-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.kanji-glyph { font-family: var(--ja); font-size: clamp(4rem, 18vw, 6.5rem); font-weight: 700; line-height: 1; }
.kanji-detail-meta h1 { font-size: clamp(1.3rem, 4vw, 1.8rem); }
.kanji-stat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.kanji-stat-chips li { font-size: .78rem; font-weight: 600; color: var(--text-soft); background: var(--surface-2); border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px; }
.kanji-cats { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.kanji-cats span { font-size: .74rem; color: var(--accent-strong); background: var(--accent-soft); padding: 3px 10px; border-radius: 999px; }
.kanji-readings { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.kanji-reading-row { display: flex; gap: 14px; }
.kanji-reading-row dt { flex: 0 0 90px; font-weight: 700; color: var(--text-soft); }
.kanji-reading-row dd { margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.kanji-reading-row dd span { font-family: var(--ja); padding: 3px 11px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.kanji-examples { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.kanji-examples li { display: flex; align-items: baseline; gap: 8px; padding: 10px 13px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.ke-word { font-family: var(--ja); font-weight: 700; font-size: 1.1rem; }
.ke-reading { font-family: var(--ja); color: var(--text-faint); font-size: .85rem; }
.ke-meaning { color: var(--text-soft); font-size: .85rem; margin-inline-start: auto; }

/* ---- Study / practice hub ----------------------------------------------- */
.study-tools { display: flex; flex-direction: column; gap: 10px; }
.study-tool-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.study-tool-level { display: flex; flex-direction: column; min-width: 96px; }
.study-tool-level strong { font-size: 1.15rem; }
.study-tool-level span { font-size: .78rem; color: var(--text-faint); }
.study-tool-links { display: flex; flex-wrap: wrap; gap: 8px; margin-inline-start: auto; }
.study-tool-links a { padding: 7px 13px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: .88rem; font-weight: 600; }
.study-tool-links a:hover { border-color: var(--accent); color: var(--accent-strong); text-decoration: none; }

/* ---- Pagination ---------------------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 32px; }
.pagination a, .pagination span { padding: 7px 12px; border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; }
.page-prev, .page-next { border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.page-prev:hover, .page-next:hover { border-color: var(--accent); text-decoration: none; }
.page-prev.is-disabled, .page-next.is-disabled { opacity: .4; pointer-events: none; }
.page-nums { display: flex; gap: 4px; align-items: center; }
.page-num { color: var(--text-soft); }
.page-num:hover { background: var(--surface-2); text-decoration: none; }
.page-num.is-current { background: var(--accent); color: var(--accent-contrast); }
.page-gap { color: var(--text-faint); }

/* ---- Search overlay ------------------------------------------------------ */
.search-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(12, 11, 17, .5); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: clamp(20px, 8vh, 90px) 16px 16px; }
.search-overlay[hidden] { display: none; }
.search-panel { width: 100%; max-width: 600px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 76vh; }
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.search-input-row input { flex: 1; border: 0; background: transparent; font-size: 1.1rem; color: var(--text); outline: none; }
.search-close { font-size: .72rem; font-weight: 700; color: var(--text-faint); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; background: var(--surface); }
.search-scope { padding: 8px 16px; font-size: .78rem; color: var(--text-faint); }
.search-results { overflow-y: auto; padding: 4px 8px 10px; }
.search-result { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text); }
.search-result:hover, .search-result.is-active { background: var(--surface-2); text-decoration: none; }
.search-result-kind { flex: 0 0 auto; font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong); }
.search-result-term { font-family: var(--ja); font-weight: 700; font-size: 1.05rem; }
.search-result-reading { font-family: var(--ja); color: var(--text-faint); font-size: .82rem; margin-inline-start: 6px; }
.search-result-meaning { color: var(--text-soft); font-size: .86rem; margin-inline-start: auto; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%; }
.search-empty { padding: 26px 16px; text-align: center; color: var(--text-faint); }

/* ---- Footer -------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-elev); margin-top: 40px; }
.footer-grid { display: grid; gap: 24px; grid-template-columns: 1.6fr 1fr 1fr; padding-block: 36px; }
.footer-brand p { color: var(--text-soft); font-size: .9rem; max-width: 38ch; margin-top: 10px; }
.footer-col { display: flex; flex-direction: column; gap: 8px; }
.footer-col h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin: 0 0 4px; }
.footer-col a { color: var(--text-soft); font-size: .9rem; }
.footer-col a:hover { color: var(--accent-strong); }
.footer-note { padding-block: 18px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: .82rem; }

/* ---- Scroll-top ---------------------------------------------------------- */
.scroll-top { position: fixed; right: 18px; bottom: 18px; z-index: 30; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-md); font-size: 1.1rem; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; transform: translateY(8px); }
.scroll-top.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.scroll-top:hover { border-color: var(--accent); color: var(--accent-strong); }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 720px) {
  :root { --header-h: 52px; }
  .brand span, .search-trigger span { display: none; }
  .main-nav { margin-inline-start: 0; order: 3; width: 100%; }
  .nav-top { padding: 6px 10px; font-size: .88rem; }
  .header-inner { flex-wrap: wrap; gap: 10px; padding-top: 8px; }
  .header-actions { margin-inline-start: auto; }
  .detail-pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; align-items: flex-start; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
  .sentence-en, .example-en { padding-inline-start: 0; }
}
/* ── Practice hub feature callout ───────────────────────── */
.study-feature { display: flex; align-items: center; gap: 16px; padding: 16px 18px; margin-bottom: 18px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--border); color: var(--text); }
.study-feature:hover { border-color: var(--accent); text-decoration: none; }
.study-feature-icon { font-size: 1.8rem; line-height: 1; }
.study-feature-body { display: flex; flex-direction: column; gap: 3px; }
.study-feature-body strong { font-size: 1.02rem; }
.study-feature-body span:last-child { color: var(--text-soft); font-size: .9rem; }
.study-feature-go { margin-inline-start: auto; font-weight: 700; color: var(--accent-strong); white-space: nowrap; }

/* ── Cloze Sprint game ──────────────────────────────────── */
.cz-game { --cz-ok: #1f9d57; --cz-no: var(--accent); max-width: 640px; margin: 8px auto 0; }
.cz-game[data-empty="true"]::after { content: "No questions available for this level yet."; display: block; color: var(--text-faint); text-align: center; padding: 40px 0; }
[data-theme="dark"] .cz-game { --cz-ok: #3fd081; }
.cz-bar { display: flex; justify-content: space-between; align-items: baseline; font-size: .86rem; color: var(--text-soft); margin-bottom: 8px; }
.cz-stat { font-variant-numeric: tabular-nums; font-weight: 600; }
.cz-track { height: 5px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin-bottom: 18px; }
.cz-track-fill { display: block; height: 100%; background: var(--accent); transition: width .25s ease; }
.cz-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px 22px; box-shadow: 0 18px 44px rgba(0,0,0,.06); }
.cz-prompt { font-size: clamp(1.25rem, 3.4vw, 1.7rem); line-height: 1.75; margin: 0 0 22px; }
.cz-blank { display: inline-block; min-width: 3.2em; text-align: center; padding: 0 .3em; margin: 0 .1em; border-bottom: 2px dashed var(--accent); color: var(--text-faint); font-weight: 700; }
.cz-blank.is-right { color: var(--cz-ok); border-bottom-color: var(--cz-ok); }
.cz-blank.is-wrong { color: var(--cz-no); border-bottom-color: var(--cz-no); }
.cz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cz-choice { display: flex; align-items: center; gap: 10px; padding: 13px 15px; font-size: 1.08rem; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); cursor: pointer; transition: border-color .14s ease, background .14s ease, transform .08s ease; }
.cz-choice:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.cz-choice:disabled { cursor: default; }
.cz-choice.is-right { border-color: var(--cz-ok); background: color-mix(in srgb, var(--cz-ok) 14%, var(--surface)); }
.cz-choice.is-wrong { border-color: var(--cz-no); background: color-mix(in srgb, var(--cz-no) 12%, var(--surface)); }
.cz-key { flex: 0 0 auto; width: 22px; height: 22px; display: grid; place-items: center; font-size: .72rem; font-weight: 700; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); color: var(--text-faint); }
.cz-reveal { display: none; margin-top: 16px; padding: 16px 18px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.cz-reveal.is-shown { display: block; }
.cz-verdict { font-size: .76rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
.cz-verdict.ok { color: var(--cz-ok); }
.cz-verdict.no { color: var(--cz-no); }
.cz-answer { font-size: 1.05rem; margin-bottom: 6px; }
.cz-answer strong { font-size: 1.15rem; }
.cz-reading { color: var(--text-faint); font-size: .92em; }
.cz-ex { font-size: 1.05rem; line-height: 1.7; margin: 10px 0 2px; }
.cz-prompt-q { text-align: center; }
.cz-en { display: flex; align-items: center; gap: 8px; color: var(--text-soft); margin: 8px 0 0; }
.cz-audio { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: .9rem; }
.cz-audio:hover { border-color: var(--accent); }
.cz-next { margin-top: 14px; padding: 11px 20px; font-size: .95rem; font-weight: 700; border: none; border-radius: 999px; background: var(--accent); color: var(--accent-contrast); cursor: pointer; }
.cz-next:hover { background: var(--accent-strong); }
.cz-result { text-align: center; }
.cz-result-score { font-size: 2.6rem; font-weight: 800; margin: 4px 0; }
.cz-result-pct { font-size: 1.1rem; color: var(--text-soft); margin: 0 0 6px; }
.cz-result-meta { color: var(--text-faint); font-size: .9rem; margin: 0 0 18px; font-variant-numeric: tabular-nums; }
.cz-noscript { text-align: center; color: var(--text-faint); padding: 40px 0; }
@media (max-width: 520px) { .cz-choices { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
