/* ============ KumaDeck theme ============ */
:root {
    --bg: #f7f5f1;
    --surface: #ffffff;
    --ink: #1d1b26;
    --muted: #6b6878;
    --line: #e6e2da;
    --accent: #d6453d;
    --good: #1f9d55;
    --bad: #d6453d;
    --radius: 14px;

    --radical: #0e8fb0;
    --kanji: #d6336c;
    --vocab: #7048e8;
    --grammar: #2b9348;
    --conjugation: #e07b00;

    /* review stages: 芽 sprout → 苗 sapling → 木 tree → 林 grove → 森 forest */
    --sprout: #5c940d;
    --sapling: #2b8a3e;
    --tree: #9c5a2e;
    --grove: #1b6e5a;
    --forest: #2b3a33;

    /* the page itself is dark; cards on top stay light */
    --page-bg: #262139;
    --on-page: #f4f1fa;
    --on-page-muted: #b9b1cf;
    --on-page-link: #ff9b91;
}

html, body {
    font-family: 'Inter', 'Noto Sans JP', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
}
/* Dark page with a faint chibi pattern (onigiri, daruma, lucky cat, Fuji, sakura). */
body {
    /* footer sits at the bottom even on short pages */
    min-height: 100vh; display: flex; flex-direction: column;
    background: var(--page-bg) url("img/bg-chibi-dark.svg") repeat;
    background-size: 520px 520px;
    background-attachment: fixed;
}
[lang="ja"] { font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: 1rem; }
h1:focus { outline: none; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 .75rem; }
.muted { color: var(--muted); font-weight: 400; }
.center { text-align: center; }

/* ---------- text on the dark page vs. on light cards ---------- */
.page-body { color: var(--on-page); }
.page-body .muted, .page-body .quiz-top, .page-body .legend { color: var(--on-page-muted); }
:where(.page-body) a:not([class]), .page-body .linkbtn { color: var(--on-page-link); }
/* Light surfaces keep dark text and the normal link colour. */
.page-body :is(.panel, .item-card, .tile, .auth-card, .tp-box, .plan-card, .account-nav, .account-body,
    .pace-card, .summary-stats > div, .landing-features > div, .practice-banner, .es-row) { color: var(--ink); }
.page-body :is(.panel, .item-card, .tile, .auth-card, .tp-box, .plan-card, .account-nav, .account-body,
    .pace-card, .summary-stats > div, .landing-features > div, .practice-banner) .muted { color: var(--muted); }
:where(.page-body :is(.panel, .item-card, .auth-card, .plan-card, .account-body, .landing-features > div)) a:not([class]),
.page-body :is(.panel, .item-card, .auth-card, .plan-card, .account-body) .linkbtn { color: var(--accent); }

/* ---------- layout ---------- */
.topbar {
    display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
    padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.15rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
    background: var(--accent); color: #fff; font-family: 'Noto Sans JP', sans-serif; font-size: 1.1rem;
}
.mainnav { display: flex; gap: .25rem; flex-wrap: nowrap; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a { white-space: nowrap; }
@media (max-width: 1000px) {
    .mainnav a { padding: .45rem .6rem; }
    .top-search input { width: 130px; }
    .top-search input:focus { width: 170px; }
}
.mainnav a { padding: .45rem .8rem; border-radius: 999px; color: var(--muted); font-weight: 500; }
.mainnav a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.mainnav a.active { background: var(--ink); color: #fff; }
.account { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
.account form { margin: 0; }
.account-name { color: var(--muted); font-size: .9rem; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.page-body { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }

/* ---------- account menu ---------- */
.user-menu { position: relative; margin-left: auto; }
.user-menu summary {
    list-style: none; display: flex; align-items: center; gap: .55rem; cursor: pointer;
    padding: .3rem .6rem .3rem .3rem; border-radius: 999px; user-select: none;
    /* soft brand-red pill, always visible */
    background: #fff0ee; border: 1px solid #f3c7c4;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover, .user-menu[open] summary, .user-menu summary.active { background: #ffe1dc; border-color: #eba59e; }
.user-menu .caret { color: var(--accent); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
    color: #fff; font-weight: 700; font-size: .95rem; object-fit: cover;
}
.user-name { font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--muted); font-size: .75rem; }
.user-dropdown {
    position: absolute; right: 0; top: calc(100% + .4rem); min-width: 260px; z-index: 20;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 12px 30px -12px rgba(29, 27, 38, .35); padding: .4rem;
}
.user-dropdown-head { display: flex; align-items: center; gap: .75rem; padding: .6rem .7rem .75rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
.avatar.big { width: 46px; height: 46px; font-size: 1.25rem; }
.user-dropdown-id { display: flex; flex-direction: column; min-width: 0; }
.user-meta { font-size: .82rem; font-weight: 600; color: var(--accent); }
.dot-sep { color: var(--muted); margin: 0 .35rem; }
.user-dropdown-head .muted { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-group { border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .3rem; }
.menu-label { display: block; padding: .35rem .7rem .15rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.menu-group a { padding-left: 1.4rem; }
.user-dropdown a, .user-dropdown button {
    display: block; width: 100%; text-align: left; padding: .5rem .7rem; border-radius: 8px;
    color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg); text-decoration: none; }
.user-dropdown form { margin: 0; border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .3rem; }
.user-dropdown button { color: var(--bad); }

/* ---------- buttons ---------- */
.btn-solid, .btn-ghost, .btn-pill {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .65rem 1.2rem; border-radius: 10px; font: inherit; font-weight: 600;
    cursor: pointer; border: 1px solid transparent; transition: background .15s;
}
.btn-solid { background: var(--ink); color: #fff; }
.btn-solid:hover { background: #33303f; color: #fff; text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.btn-ghost:disabled { opacity: .4; cursor: default; }
.btn-pill { padding: .45rem 1rem; border-radius: 999px; background: var(--accent); color: #fff; }
.btn-pill:hover { color: #fff; text-decoration: none; filter: brightness(1.05); }
.btn-solid.danger { background: var(--bad); }
.btn-ghost.danger { color: var(--bad); }
.btn-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }
.btn-row.center { justify-content: center; }

/* ---------- panels / chips ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip-row.center { justify-content: center; }
.chip {
    display: inline-flex; align-items: baseline; gap: .45rem; padding: .3rem .7rem; border-radius: 8px;
    color: #fff; background: var(--c, var(--ink)); font-size: .95rem;
}
.chip:hover { text-decoration: none; color: #fff; filter: brightness(1.08); }
.chip-chars { font-size: 1.1rem; font-weight: 500; }
.chip-meaning { font-size: .8rem; opacity: .9; }
.t-radical { --c: var(--radical); }
.t-kanji { --c: var(--kanji); }
.t-vocabulary { --c: var(--vocab); }
.t-grammar { --c: var(--grammar); }
.t-conjugation { --c: var(--conjugation); }
.type-dot { display: inline-flex; align-items: center; gap: .3rem; margin-left: .75rem; color: var(--ink); }
.type-dot::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: var(--c); }

/* ---------- landing ---------- */
.landing-hero { text-align: center; padding: 3rem 0 2.5rem; }
.landing-glyphs { font-size: 3.2rem; font-weight: 700; letter-spacing: .05em; color: var(--accent); }
.landing-glyphs span { color: rgba(255, 255, 255, .25); }
.landing-hero h1 { font-size: 2.4rem; margin: .5rem 0 1rem; }
/* lighter red so it stays readable on the dark button */
.landing-hero .btn-solid .nihon { color: #ff7a6e; }
.landing-hero p { color: var(--on-page-muted); max-width: 560px; margin: 0 auto; font-size: 1.1rem; }
.landing-hero .btn-row { justify-content: center; }
.landing-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.landing-features div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; }
.landing-features h3 { font-size: 1rem; font-weight: 700; }
.landing-features p { color: var(--muted); margin: 0; font-size: .95rem; }

/* ---------- dashboard ---------- */
.dash-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
.action-card {
    display: flex; flex-direction: column; padding: 1.4rem 1.6rem; border-radius: var(--radius); color: #fff;
    background: var(--c); box-shadow: 0 6px 20px -10px var(--c); transition: transform .1s;
}
.action-card:hover { text-decoration: none; color: #fff; transform: translateY(-2px); }
.action-card.lessons { --c: var(--kanji); }
.action-card.reviews { --c: var(--vocab); }
.action-card.is-empty { --c: #a9a5b3; box-shadow: none; }
.action-label { font-weight: 600; opacity: .9; }
.action-count { font-size: 3.2rem; font-weight: 700; line-height: 1.1; }
.action-sub { font-size: .9rem; opacity: .9; }
.dash-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.dash-col { display: flex; flex-direction: column; }
.pace-badge { font-size: .8rem; padding: .2rem .6rem; border-radius: 999px; background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.level-bar { position: relative; height: 14px; border-radius: 999px; background: var(--bg); margin: .5rem 0 .75rem; }
.level-bar .fill { height: 100%; border-radius: 999px; background: var(--kanji); transition: width .3s; }
.level-bar .goal { position: absolute; top: -4px; bottom: -4px; width: 3px; background: var(--ink); border-radius: 2px; }
/* level progress card */
.level-nav { display: flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .95rem; }
.level-nav a, .level-nav .disabled {
    width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px;
    border: 1px solid var(--line); color: var(--ink); font-size: 1.1rem; line-height: 1;
}
.level-nav a:hover { background: var(--bg); text-decoration: none; }
.level-nav .disabled { opacity: .35; }
.lp-intro { margin: -.25rem 0 .9rem; font-size: .9rem; }
.type-progress { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.tp-box {
    display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px;
    overflow: hidden; color: var(--ink); background: var(--surface);
}
.tp-box:hover { text-decoration: none; color: var(--ink); border-color: var(--c); }
.tp-head { display: flex; align-items: center; gap: .5rem; padding: .6rem .7rem; font-weight: 600; font-size: .92rem; }
.tp-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--c); color: #fff; font-size: .85rem; }
.tp-bar { height: 4px; background: var(--line); }
.tp-bar span { display: block; height: 100%; background: var(--c); }
.tp-foot { display: flex; justify-content: space-between; align-items: center; padding: .5rem .7rem; font-size: .85rem; }
.tp-foot span { color: var(--muted); font-size: .78rem; }
.lp-goal { margin: 1rem 0 .5rem; font-size: .92rem; }
.kanji-segments { display: flex; gap: 3px; }
.kanji-segments span { flex: 1; height: 9px; border-radius: 3px; background: var(--line); position: relative; }
.kanji-segments span.on { background: var(--sapling); }
.kanji-segments span.goal::after { content: ""; position: absolute; right: -3px; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 1px; }

/* forecast + extra study cards */
.card-flush { padding: 0; overflow: hidden; }
.card-hero { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: 1rem 1.2rem .8rem; }
.card-hero.sky { background: #e6f1fb; }
.card-hero.blossom { background: #fff0f3; }
.card-hero .mascot { flex-shrink: 0; filter: drop-shadow(0 4px 6px rgba(29, 27, 38, .12)); }
.hero-label { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; }
.hero-value { display: block; font-size: 1.7rem; font-weight: 700; line-height: 1.15; }
.hero-sub { display: block; font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.extra-study .hero-label { font-size: 1.25rem; color: var(--ink); font-weight: 700; }
.fc-days { list-style: none; margin: 0; padding: .6rem 1.2rem 1rem; }
.fc-days li { display: grid; grid-template-columns: 3.4rem 1fr 2.6rem 2.6rem; align-items: center; gap: .6rem; padding: .28rem 0; font-size: .9rem; }
.fc-day { color: var(--muted); }
.fc-track { height: 14px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.fc-track span { display: block; height: 100%; background: var(--sapling); border-radius: 4px; }
.fc-plus { color: var(--muted); text-align: right; font-size: .82rem; }
.fc-days li.has .fc-plus { color: var(--sapling); font-weight: 700; }
.fc-total { text-align: right; font-weight: 600; }
.es-list { display: flex; flex-direction: column; gap: .45rem; padding: .8rem 1rem 1rem; }
.es-row {
    display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 10px;
    border: 1px solid var(--line); color: var(--ink); background: var(--surface); font-weight: 600; font-size: .92rem;
}
a.es-row:hover { text-decoration: none; color: var(--ink); border-color: var(--accent); background: #fff8f7; }
.es-row.is-empty { color: var(--muted); background: var(--bg); font-weight: 500; }
.es-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); font-size: .8rem; }
.es-label { flex: 1; }
.es-count { min-width: 28px; text-align: center; padding: .05rem .5rem; border-radius: 999px; border: 1px solid var(--line); font-size: .8rem; }
.es-chev { color: var(--muted); }
.practice-banner {
    max-width: 720px; margin: 0 auto 1rem; padding: .6rem 1rem; border-radius: 10px;
    background: #fff0f3; border: 1px solid #f6c9d4; display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .9rem;
}
.practice-banner span { color: var(--muted); }
.empty-state .mascot { margin-bottom: .5rem; }
.srs-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: .6rem; }
.srs-tile { border-radius: 10px; padding: .8rem; color: #fff; background: var(--c); display: flex; flex-direction: column; }
.srs-tile strong { font-size: 1.6rem; line-height: 1.1; }
.srs-tile span { font-size: .8rem; opacity: .9; }
.s-sprout { --c: var(--sprout); }
.s-sapling { --c: var(--sapling); }
.s-tree { --c: var(--tree); }
.s-grove { --c: var(--grove); }
.s-forest { --c: var(--forest); }
.s-lesson { --c: #c9c5d1; }
.s-locked { --c: #e6e2da; }
.waiting { margin: 1rem 0 0; }

/* ---------- item card ---------- */
.item-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.25rem; }
.item-hero { background: var(--c); color: #fff; text-align: center; padding: 1.75rem 1rem 1.25rem; }
.item-chars { font-size: 5rem; line-height: 1.15; font-weight: 500; }
.item-chars.long { font-size: 2.6rem; padding: .8rem 0; }
.item-sub { display: flex; justify-content: center; gap: .9rem; flex-wrap: wrap; font-size: .85rem; opacity: .95; margin-top: .5rem; }
.type-tag { background: rgba(255,255,255,.2); padding: .05rem .55rem; border-radius: 999px; }
.item-body { padding: .5rem 1.5rem 1rem; }
.item-body section { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.item-body section:last-child { border-bottom: 0; }
.item-body h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: .5rem; }
.item-body .primary { font-size: 1.35rem; font-weight: 600; margin: 0 0 .25rem; text-transform: capitalize; }
.mnemonic { background: #fff8e6; border-left: 3px solid #f0b429; padding: .6rem .9rem; border-radius: 0 8px 8px 0; margin: .6rem 0 0; }
.explanation { font-size: 1.02rem; line-height: 1.65; margin: 0; }
.readings { display: flex; gap: 2rem; font-size: 1.2rem; flex-wrap: wrap; }
.readings .muted { font-size: .8rem; margin-right: .4rem; font-family: 'Inter', sans-serif; }
.examples { list-style: none; padding: 0; margin: 0; }
.examples li { display: flex; flex-direction: column; padding: .45rem 0; }
.examples li span[lang] { font-size: 1.15rem; }.examples mark { background: #e3f4e8; color: var(--grammar); font-weight: 700; padding: 0 .1em; border-radius: 4px; }
.conj-table { font-size: 1.1rem; border-collapse: collapse; }
.conj-table td { padding: .3rem .6rem .3rem 0; }
.conj-table .muted { font-size: .8rem; font-family: 'Inter', sans-serif; }
.conj-table .arrow { color: var(--muted); }
.progress-facts { display: flex; gap: 2rem; flex-wrap: wrap; }
.progress-facts .muted { display: block; font-size: .8rem; }
.stage-pill { display: inline-block; padding: .1rem .6rem; border-radius: 999px; background: var(--c); color: #fff; font-size: .9rem; }

/* ---------- lessons ---------- */
.lesson-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.lesson-head h1 { margin: 0; }
.lesson-tabs { display: flex; gap: .4rem; flex-wrap: wrap; }
.tab-chip {
    border: 2px solid var(--c); background: var(--surface); color: var(--c);
    border-radius: 8px; padding: .2rem .65rem; font-size: 1.05rem; cursor: pointer;
}
.tab-chip.active { background: var(--c); color: #fff; }
.lesson-nav { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }

/* ---------- lesson card (tabs, audio, prompts) ---------- */
.lesson-card { position: relative; }
.lesson-card .item-hero { position: relative; padding-bottom: 1rem; }
.hero-meaning { font-size: 1.35rem; opacity: .95; margin-top: -.2rem; text-transform: capitalize; }
.speak-btn {
    position: absolute; right: 1rem; top: 1rem; width: 42px; height: 42px; border-radius: 50%;
    border: 0; background: rgba(255, 255, 255, .22); color: #fff; font-size: 1.15rem; cursor: pointer;
}
.speak-btn:hover { background: rgba(255, 255, 255, .35); }
.speak-inline { border: 0; background: none; cursor: pointer; font-size: .95rem; padding: 0 .2rem; vertical-align: middle; opacity: .7; }
.speak-inline:hover { opacity: 1; }
.lesson-sections { display: flex; justify-content: center; flex-wrap: wrap; gap: .2rem; background: #2a2635; padding: .35rem; }
.lesson-sections button {
    border: 0; background: none; color: #b9b1cf; font: inherit; font-weight: 600; padding: .55rem 1rem;
    border-radius: 8px; cursor: pointer;
}
.lesson-sections button:hover { color: #fff; }
.lesson-sections button.active { color: #fff; background: rgba(255, 255, 255, .12); }
.lesson-body { min-height: 190px; padding: 1.4rem 1.6rem 1.6rem; }
.lesson-body .primary { font-size: 1.6rem; }
.parts-row { margin: .5rem 0 1rem; }
.parts-row .chip { font-size: 1.05rem; padding: .45rem .9rem; }
.lesson-prompts { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.lesson-prompts li { padding: .2rem 0; }
.small { font-size: .85rem; }
.lesson-dock {
    display: flex; align-items: center; gap: .5rem; margin-top: 1rem; padding: .6rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.dock-arrow { padding: .5rem .8rem; }
.lesson-strip { display: flex; gap: .35rem; flex: 1; overflow-x: auto; padding: .15rem; }
.strip-chip {
    border: 2px solid var(--c); background: var(--surface); color: var(--c); border-radius: 8px;
    padding: .2rem .6rem; font-size: 1.05rem; cursor: pointer; white-space: nowrap; position: relative;
}
.strip-chip.seen { background: color-mix(in srgb, var(--c) 14%, white); }
.strip-chip.active { background: var(--c); color: #fff; }
.quiz-btn { background: var(--good); }
.quiz-btn:hover { background: #18834a; }
.lesson-extras { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; font-size: .88rem; }
.shortcut-hint { color: var(--on-page-muted); }
kbd { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); border-radius: 5px; padding: .05rem .35rem; font-size: .78rem; color: inherit; margin-right: .15rem; }

/* lesson picker */
.pick-group h2 { display: flex; align-items: center; gap: .5rem; }
.pick-group .type-dot { margin: 0; }
.pick-grid { display: flex; flex-wrap: wrap; gap: .4rem; }
.pick-chip {
    border: 2px solid var(--c); background: var(--surface); color: var(--c); border-radius: 8px;
    padding: .25rem .7rem; font-size: 1.05rem; cursor: pointer;
}
.pick-chip.on { background: var(--c); color: #fff; }
.pick-bar {
    position: sticky; bottom: 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .75rem 1rem; box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .5);
}
.pick-bar .btn-solid { margin-left: auto; }
.pick-bar .muted { color: var(--muted); }

/* ---------- quiz ---------- */
.quiz-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.quiz { max-width: 720px; margin: 0 auto; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; color: var(--muted); margin-bottom: .4rem; }
.quiz-stats { display: flex; gap: 1rem; }
.quiz-bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 1rem; }
.quiz-bar div { height: 100%; background: var(--good); transition: width .3s; }
.prompt {
    background: var(--c); color: #fff; border-radius: var(--radius) var(--radius) 0 0;
    text-align: center; padding: 2.5rem 1rem 2rem; min-height: 220px;
    display: flex; flex-direction: column; justify-content: center; gap: .5rem;
}
.prompt-chars { font-size: 6rem; line-height: 1.1; }
.prompt-chars.long { font-size: 3.5rem; }
.prompt-pattern { font-size: 1rem; opacity: .85; }
.prompt-cloze { font-size: 2.2rem; line-height: 1.5; }
.prompt-cloze .blank { display: inline-block; min-width: 3em; border-bottom: 3px solid #fff; margin: 0 .15em; opacity: .9; }
.prompt-hint { font-size: 1.05rem; opacity: .92; }
.q-label { text-align: center; padding: .55rem; font-weight: 600; letter-spacing: .02em; }
.q-label.english { background: #ece9f2; color: var(--ink); }
.q-label.kana { background: #2a2733; color: #fff; }
.answer-wrap { display: flex; border: 2px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; background: var(--surface); }
.answer-input {
    flex: 1; min-width: 0; border: 0; outline: 0; font-size: 1.6rem; text-align: center; padding: .8rem 1rem;
    background: transparent; color: var(--ink); font-family: 'Noto Sans JP', 'Inter', sans-serif;
}
.answer-go { border: 0; background: var(--bg); width: 64px; font-size: 1.4rem; cursor: pointer; color: var(--muted); }
.answer-wrap.is-correct { border-color: var(--good); background: var(--good); }
.answer-wrap.is-wrong { border-color: var(--bad); background: var(--bad); }
.answer-wrap.is-correct .answer-input, .answer-wrap.is-wrong .answer-input { color: #fff; }
.answer-wrap.is-correct .answer-go, .answer-wrap.is-wrong .answer-go { background: rgba(255,255,255,.15); color: #fff; }
.answer-msg { text-align: center; margin-top: .75rem; font-weight: 600; }
.answer-reveal { text-align: center; margin-top: .5rem; font-size: 1.1rem; }
.answer-reveal strong { font-size: 1.35rem; }
.quiz-actions { display: flex; justify-content: center; gap: .6rem; margin: 1rem 0; flex-wrap: wrap; }

/* ---------- empty / summary ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-glyph { font-size: 5rem; color: rgba(255, 255, 255, .3); line-height: 1; margin-bottom: .5rem; }
.summary-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1.5rem; }
.summary-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; }
.summary-stats strong { font-size: 1.8rem; }
.summary-stats span { color: var(--muted); font-size: .85rem; }
.summary h2 { margin-top: 1.25rem; }

/* ---------- levels ---------- */
.levels-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.level-pills { display: flex; gap: .35rem; flex-wrap: wrap; }
.level-pills a { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-weight: 600; }
.level-pills a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.level-pills a.future { color: var(--muted); border-style: dashed; }
.level-pills a:hover { text-decoration: none; }
.level-section { margin: 1.5rem 0; }
.level-section h2 { color: var(--on-page); display: flex; align-items: center; gap: .5rem; }
.level-section h2::before { content: ""; width: .75rem; height: .75rem; border-radius: 3px; background: var(--c); }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem; }
.tile-grid.wide { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tile {
    position: relative; display: flex; flex-direction: column; align-items: center; text-align: center;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .4rem 1rem;
    color: var(--ink); overflow: hidden;
}
.tile:hover { text-decoration: none; color: var(--ink); border-color: var(--ink); }
.tile .tile-chars { font-size: 1.9rem; line-height: 1.3; }
.tile-grid.wide .tile-chars { font-size: 1.15rem; padding: .3rem 0; }
.tile-reading { font-size: .85rem; }
.tile-meaning { font-size: .78rem; color: var(--muted); }
.tile-stage { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; }
/* locked: solid (not see-through on the dark page) but greyed out */
.tile.s-locked { background: #e9e6ef; border-color: #d6d1df; }
.tile.s-locked > span { opacity: .55; }
.tile.s-lesson .tile-stage { background: #c9c5d1; }
.tile.s-sprout .tile-stage { background: var(--sprout); }
.tile.s-sapling .tile-stage { background: var(--sapling); }
.tile.s-tree .tile-stage { background: var(--tree); }
.tile.s-grove .tile-stage { background: var(--grove); }
.tile.s-forest .tile-stage { background: var(--forest); }
.tile.t-radical .tile-chars { color: var(--radical); }
.tile.t-kanji .tile-chars { color: var(--kanji); }
.tile.t-vocabulary .tile-chars { color: var(--vocab); }
.tile.t-grammar .tile-chars { color: var(--grammar); }
.tile.t-conjugation .tile-chars { color: var(--conjugation); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 2rem; }
.legend span::before { content: ""; display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; background: var(--c); margin-right: .35rem; vertical-align: -1px; }

/* ---------- settings ---------- */
.pace-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: 1.25rem; }
.pace-card {
    display: flex; flex-direction: column; text-align: left; gap: .25rem; padding: .9rem; border-radius: 10px;
    border: 2px solid var(--line); background: var(--surface); cursor: pointer; font: inherit; color: var(--ink);
}
.pace-card span { font-size: .82rem; color: var(--muted); }
.pace-card.active { border-color: var(--accent); background: #fff3f2; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; }
.field-grid label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
.field-grid input[type=number], .field-grid select {
    padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--surface);
}
.field-grid small { color: var(--muted); font-weight: 400; }
.toggle { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem 0; cursor: pointer; }
.toggle input { margin-top: .3rem; width: 1.1rem; height: 1.1rem; accent-color: var(--accent); flex-shrink: 0; }
.save-bar { display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem; }
.saved { color: var(--good); font-weight: 600; margin-left: .5rem; }
.panel.danger { border-color: #f3c7c4; }

/* Solid full-width band; the content lines up with the 960px page column. */
.site-footer {
    background: #14111f; border-top: 1px solid rgba(255, 255, 255, .08); color: #c9c5d4; font-size: .8rem; line-height: 1.6;
    padding: 1.75rem max(1.25rem, calc((100% - 960px) / 2 + 1.25rem)) 2.25rem;
}
.site-footer a { color: #ffffff; text-decoration: underline; text-decoration-color: rgba(255, 255, 255, .35); }
.site-footer a:hover { text-decoration-color: #ffffff; }
.site-footer { display: flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: center; }
.footer-sep { color: #6f6a7d; }
.credits, .legal { max-width: 760px; margin: 0 auto; }
.legal .panel h2 { margin-top: 1.4rem; }
.legal .panel h2:first-of-type { margin-top: .8rem; }
.legal .panel li { padding: .15rem 0; }
.credits .panel p:last-child, .credits .panel ul { margin-bottom: 0; }
.credits .panel li { padding: .2rem 0; }

/* ---------- settings tabs ---------- */
.settings-title { margin-bottom: .75rem; }
.settings-tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid rgba(255, 255, 255, .15); margin-bottom: 1.5rem; }
.settings-tabs a {
    padding: .65rem 1rem; color: var(--on-page-muted); font-weight: 600; border-bottom: 2px solid transparent;
    margin-bottom: -1px; white-space: nowrap;
}
.settings-tabs a:hover { color: var(--on-page); text-decoration: none; }
.settings-tabs a.active { color: var(--on-page); border-bottom-color: var(--accent); }

.account-settings { display: grid; grid-template-columns: 200px 1fr; gap: 1.5rem; align-items: start; }
.account-nav { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; }
.account-nav .nav-link { color: var(--muted); border-radius: 8px; padding: .5rem .8rem; }
.account-nav .nav-link:hover { background: var(--bg); color: var(--ink); }
.account-nav .nav-link.active { background: var(--ink); color: #fff; }
.account-body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; }
.account-body h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 1rem; }
.account-body .btn-primary { background: var(--ink); border-color: var(--ink); }

.plan-badge { font-size: .8rem; font-weight: 600; padding: .2rem .7rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.plan-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; display: flex; flex-direction: column; }
.plan-card.premium { border: 2px solid var(--accent); }
.plan-card h3 { font-size: 1.3rem; font-weight: 700; margin: 0; }
.plan-levels { color: var(--muted); margin: .2rem 0 1rem; }
.plan-card ul { padding-left: 1.1rem; margin-bottom: 1.25rem; flex: 1; }
.plan-card li { padding: .2rem 0; }
.plan-current { color: var(--muted); font-weight: 600; }
.plan-card .btn-solid:disabled { opacity: .55; cursor: default; }

/* ---------- log in / register cards ---------- */
.auth-card {
    max-width: 440px; margin: 1rem auto 2rem; background: var(--surface);
    border: 1px solid var(--line); border-radius: 18px; padding: 2rem 2rem 1.5rem;
    box-shadow: 0 18px 40px -24px rgba(29, 27, 38, .35);
}
.auth-head { text-align: center; margin-bottom: 1.5rem; }
.brand-mark.big { width: 54px; height: 54px; font-size: 1.6rem; border-radius: 15px; margin: 0 auto .9rem; }
.auth-head h1 { font-size: 1.6rem; margin: 0 0 .3rem; }
.auth-head p { margin: 0; }
.auth-card .form-control { border-radius: 10px; border-color: var(--line); }
.auth-card .form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(214, 69, 61, .15); }
.auth-submit { width: 100%; padding: .8rem; font-size: 1.05rem; background: var(--accent); }
.auth-submit:hover { background: #c23a33; }
.auth-row { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; margin-bottom: 1.1rem; }
.auth-remember { display: flex; align-items: center; gap: .45rem; margin: 0; cursor: pointer; }
.auth-remember .form-check-input { margin: 0; }
.auth-passkey { text-align: center; margin-top: .5rem; }
.auth-passkey .btn-link { font-size: .9rem; color: var(--accent); }
.auth-switch { text-align: center; margin: 1.25rem 0 0; font-size: .95rem; }
.auth-small { text-align: center; margin: .4rem 0 0; font-size: .8rem; }
.auth-small a { color: var(--muted); }
/* "or" divider above the Google button inside the cards */
.auth-card .external-logins hr { display: none; }
.auth-card .external-logins h3 {
    display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0 1rem;
    font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em;
}
.auth-card .external-logins h3::before, .auth-card .external-logins h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- your synonyms & notes ---------- */
.notes-editor { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.notes-editor h3 { margin-top: .4rem; }
.notes-editor h3 + .muted { margin: -.3rem 0 .5rem; }
.syn-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.syn-chip {
    display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .35rem .25rem .7rem;
    border-radius: 999px; background: #efeaf8; color: var(--ink); font-size: .9rem;
}
.syn-chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0 .25rem; border-radius: 50%; }
.syn-chip button:hover { color: var(--bad); }
.syn-add { display: inline-flex; gap: .35rem; }
.syn-add input, .note-field textarea {
    border: 1px solid var(--line); border-radius: 8px; padding: .4rem .6rem; font: inherit; background: var(--surface); color: var(--ink);
}
.syn-add input { width: 180px; }
.syn-add .btn-ghost, .note-actions .btn-ghost { padding: .4rem .8rem; }
.note-field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .6rem; font-weight: 500; font-size: .9rem; }
.note-field textarea { resize: vertical; min-height: 2.6rem; }
.note-actions { display: flex; align-items: center; gap: .5rem; }

/* ---------- notices, upgrade prompts, plan buttons ---------- */
.notice {
    background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--vocab);
    border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem;
}
.notice.good { border-left-color: var(--good); }
.notice.warn { border-left-color: #f0b429; }
.notice a { color: var(--accent); }
.upgrade-banner { display: flex; align-items: center; gap: 1rem; border: 2px solid var(--accent); }
.upgrade-banner h2 { margin: 0 0 .2rem; }
.upgrade-banner p { margin: 0; }
.upgrade-banner .btn-solid { margin-left: auto; background: var(--accent); white-space: nowrap; }
.plan-badge.premium { background: var(--accent); color: #fff; border-color: var(--accent); }
.plan-buttons { display: flex; flex-wrap: wrap; gap: .5rem; }
.plan-buttons .btn-solid { background: var(--accent); }
.plan-buttons .btn-solid.alt { background: var(--ink); }

/* ---------- sign-in providers ---------- */
.external-logins h3 { font-size: 1.1rem; font-weight: 600; margin-top: 1rem; }
.btn-provider {
    display: flex; align-items: center; justify-content: center; gap: .65rem; width: 100%;
    padding: .7rem 1rem; margin-bottom: .6rem; border-radius: 10px; font: inherit; font-weight: 600;
    background: var(--surface); color: var(--ink); border: 1px solid var(--line); cursor: pointer;
}
.btn-provider:hover { background: var(--bg); }

/* ---------- search ---------- */
.top-search { margin: 0; }
.top-search input {
    width: 170px; padding: .4rem .8rem .4rem 2rem; border-radius: 999px; border: 1px solid var(--line);
    background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6878' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat .7rem center;
    font: inherit; font-size: .9rem; color: var(--ink); transition: width .15s;
}
.top-search input:focus { width: 230px; outline: 2px solid var(--accent); outline-offset: 1px; background-color: var(--surface); }
.search-form { display: flex; gap: .6rem; padding: .8rem; margin-bottom: 1rem; }
.search-form input {
    flex: 1; min-width: 0; padding: .65rem .9rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 1.05rem;
}
.search-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.tile-level { position: absolute; top: .3rem; left: .45rem; font-size: .68rem; color: var(--muted); }

/* ---------- stats ---------- */
.stats-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.1rem 1.5rem; margin-top: .75rem; }
.stats-type { display: flex; flex-direction: column; gap: .35rem; }
.stats-type-head { display: flex; justify-content: space-between; align-items: baseline; }
.stats-type-head strong { display: flex; align-items: center; gap: .45rem; }
.stats-type-head strong::before { content: ""; width: .7rem; height: .7rem; border-radius: 3px; background: var(--c); }
.stack-bar { display: flex; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.stack-bar span { display: block; height: 100%; background: var(--c); }
.stats-legend { margin-top: 1rem; }
.leech-list { list-style: none; padding: 0; margin: .75rem 0 0; display: flex; flex-direction: column; }
.leech-list li { display: flex; align-items: center; gap: .75rem; padding: .5rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.leech-list li:first-child { border-top: 0; }
.leech-reading { color: var(--muted); min-width: 5rem; }
.leech-list .stage-pill { font-size: .78rem; }
.leech-count { margin-left: auto; font-size: .85rem; color: var(--muted); }
.leech-count strong { color: var(--bad); }

/* ---------- vacation ---------- */
.vacation-banner { display: flex; align-items: center; gap: 1rem; border-left: 5px solid #4dabf7; }
.vacation-banner h2 { margin: 0 0 .2rem; }
.vacation-banner p { margin: 0; }
.vacation-banner form { margin: 0 0 0 auto; }
.vacation-banner .btn-solid { white-space: nowrap; }
.vacation-glyph {
    flex-shrink: 0; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px;
    background: #e7f5ff; color: #1c7ed6; font-size: 1.6rem; font-family: 'Noto Sans JP', sans-serif;
}

/* ---------- notes inside lesson cards ---------- */
.lesson-notes { border-top: 1px solid var(--line); }
.lesson-notes summary {
    cursor: pointer; list-style: none; padding: .7rem 1.4rem; font-size: .9rem; font-weight: 600; color: var(--muted);
}
.lesson-notes summary::-webkit-details-marker { display: none; }
.lesson-notes summary:hover, .lesson-notes[open] summary { color: var(--ink); }
.lesson-notes .notes-editor { padding: 0 1.4rem 1.1rem; margin: 0; border: 0; }
.lesson-notes .notes-editor h3 { font-size: 1rem; font-weight: 700; margin: .6rem 0 .3rem; }

/* ---------- reports & admin ---------- */
.report-page { max-width: 640px; margin: 0 auto; }
.report-about { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.report-field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; font-weight: 600; font-size: .92rem; }
.report-field select, .report-field textarea {
    font: inherit; font-weight: 400; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.report-field textarea { resize: vertical; min-height: 110px; }
.report-field small { font-weight: 400; align-self: flex-end; }
.form-error { color: var(--bad); }
.report-link { margin: .5rem 0 0; font-size: .85rem; }
.report-link a { color: var(--muted); }
.report-link a:hover { color: var(--accent); }
.admin-tabs { display: flex; gap: .4rem; margin-bottom: 1rem; }
.admin-tabs button {
    border: 1px solid transparent; background: transparent; color: var(--on-page-muted); padding: .45rem 1rem; border-radius: 999px;
    font: inherit; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: .4rem;
}
.admin-tabs button.active { background: var(--surface); color: var(--ink); }
.count-badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; }
.report-list { list-style: none; padding: 0; margin: 0; }
.report-list li { padding: 1rem 0; border-top: 1px solid var(--line); }
.report-list li:first-child { border-top: 0; padding-top: .25rem; }
.report-meta { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.report-kind { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--bg); padding: .15rem .5rem; border-radius: 6px; }
.report-when { margin-left: auto; }
.report-message { white-space: pre-wrap; margin: .6rem 0; }
.search-form.inline { padding: 0; margin: .5rem 0 1rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th { text-align: left; font-size: .78rem; color: var(--muted); font-weight: 600; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
.admin-table td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table .btn-ghost { font-size: .8rem; padding: .3rem .7rem; white-space: nowrap; }
.level-cell { min-width: 150px; }
.level-warn { display: block; max-width: 190px; margin-top: .3rem; font-size: .78rem; line-height: 1.3; color: var(--bad); }
.level-set { display: flex; gap: .35rem; align-items: center; }
.level-set input { width: 4.2rem; font: inherit; padding: .3rem .45rem; border: 1px solid var(--line); border-radius: 8px; }
.level-cell .toggle { padding: .3rem 0 0; font-size: .8rem; }
.level-cell .toggle input { margin-top: .1rem; }
.level-cell .muted.small { display: block; max-width: 190px; margin-top: .25rem; line-height: 1.3; }

/* ---------- first-run tour (CSS-only steps) ---------- */
.welcome-tour { position: relative; overflow: hidden; }
.welcome-tour > input[type=radio] { display: none; }  /* labels still switch them; no focus jump */
.tour-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.tour-head form { margin: 0; }
.tour-kicker { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.tour-skip { color: var(--muted); font-size: .85rem; }
.tour-placement { font-size: .85rem; margin-left: auto; }
.tour-slide { display: none; align-items: center; gap: 1.4rem; min-height: 150px; }
.tour-slide h2 { margin: 0 0 .4rem; font-size: 1.25rem; }
.tour-slide p { margin: 0; line-height: 1.55; color: #3d3a48; }
#tour-1:checked ~ .tour-slides .s1, #tour-2:checked ~ .tour-slides .s2,
#tour-3:checked ~ .tour-slides .s3, #tour-4:checked ~ .tour-slides .s4 { display: flex; animation: tour-in .25s ease; }
@keyframes tour-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.tour-stages { display: grid; grid-template-columns: repeat(5, 30px); gap: 4px; flex-shrink: 0; }
.tour-stages span { display: grid; place-items: center; height: 40px; border-radius: 8px; background: var(--c); color: #fff; font-size: 1rem; }
.tour-go { margin: 1rem 0 0; }
.tour-dots { display: flex; gap: .4rem; justify-content: center; margin-top: 1rem; }
.tour-dots label { width: 9px; height: 9px; border-radius: 50%; background: var(--line); cursor: pointer; }
#tour-1:checked ~ .tour-dots label[for=tour-1], #tour-2:checked ~ .tour-dots label[for=tour-2],
#tour-3:checked ~ .tour-dots label[for=tour-3], #tour-4:checked ~ .tour-dots label[for=tour-4] { background: var(--accent); width: 22px; border-radius: 999px; }
.tour-nav { display: flex; justify-content: flex-end; gap: .5rem; margin-top: -1.6rem; }
.tour-nav label { display: none; cursor: pointer; font-size: .85rem; padding: .35rem .9rem; border-radius: 999px; border: 1px solid var(--line); }
#tour-1:checked ~ .tour-nav .n1, #tour-2:checked ~ .tour-nav .p2, #tour-2:checked ~ .tour-nav .n2,
#tour-3:checked ~ .tour-nav .p3, #tour-3:checked ~ .tour-nav .n3, #tour-4:checked ~ .tour-nav .p4 { display: inline-block; }
@media (max-width: 700px) {
    .tour-slide { flex-direction: column; text-align: center; }
    .tour-nav { justify-content: center; margin-top: .75rem; }
}

/* ---------- placement test ---------- */
.placement { max-width: 560px; margin: 0 auto; }
.placement-progress { display: flex; justify-content: space-between; align-items: baseline; color: var(--on-page); margin-bottom: .6rem; }
.placement-progress .muted { color: var(--on-page-muted); font-size: .9rem; }
.placement-card { text-align: center; padding: 2rem 1.5rem; }
.placement-chars { font-size: 4.5rem; line-height: 1.2; color: var(--c, var(--ink)); }
.placement-input {
    width: 100%; max-width: 360px; font: inherit; font-size: 1.2rem; text-align: center; padding: .7rem 1rem;
    border: 2px solid var(--line); border-radius: 12px; margin: .3rem 0 .8rem;
}
.placement-input:focus { outline: none; border-color: var(--ink); }
.placement-input.right { animation: flash-good .5s; }
.placement-input.wrong { animation: flash-bad .5s; }
@keyframes flash-good { from { background: #d3f9d8; } to { background: #fff; } }
@keyframes flash-bad { from { background: #ffe3e3; } to { background: #fff; } }
.placement-feedback { color: var(--muted); font-size: .9rem; margin: 0 0 .8rem; }
.placement .linkbtn { color: var(--on-page-link); }
.skip-ahead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.skip-ahead p { margin: 0; }

/* ---------- stories ---------- */
.page-lead { color: var(--on-page-muted); margin: -.5rem 0 1.25rem; }
.story-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .9rem; }
.story-card {
    display: flex; flex-direction: column; gap: .3rem; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.1rem 1.2rem; color: var(--ink);
}
a.story-card:hover { text-decoration: none; color: var(--ink); border-color: var(--accent); transform: translateY(-2px); transition: transform .12s; }
.story-card.locked { background: #e9e6ef; color: var(--muted); }
.story-level { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.story-card.locked .story-level { color: var(--muted); }
.story-title { font-size: 1.25rem; }
.story-title-en { color: var(--muted); font-size: .9rem; }
.story-summary { font-size: .9rem; line-height: 1.45; }
.story-meta { margin-top: auto; padding-top: .4rem; font-size: .78rem; color: var(--muted); }
.story-reader { max-width: 760px; margin: 0 auto; }
.back-link { color: var(--on-page-link); display: inline-block; margin-bottom: .8rem; }
.story-head h1 { margin: .3rem 0 0; font-size: 2rem; }
.story-tools { display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: .4rem; }
.story-tools .toggle { padding: .2rem 0; }
.story-sentence { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: .3rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.story-sentence:first-of-type { border-top: 0; }
.story-jp {
    text-align: left; background: none; border: 0; padding: .1rem .2rem; font: inherit; font-size: 1.3rem; line-height: 1.7;
    color: var(--ink); cursor: pointer; border-radius: 6px;
}
.story-jp:hover { background: #fff7e6; }
.story-kana { display: block; font-size: .85rem; color: var(--muted); line-height: 1.4; }
.story-en { grid-column: 1 / -1; margin: 0 .2rem .2rem; color: #4a4658; font-size: .95rem; }
.story-sentence.open .story-jp { background: #fff7e6; }
.story-q { border: 0; padding: 0; margin: 0 0 1rem; }
.story-q legend { font-weight: 600; margin-bottom: .5rem; }
.story-option {
    display: block; width: 100%; text-align: left; margin: .3rem 0; padding: .55rem .8rem; font: inherit;
    border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer;
}
.story-option:hover:not(:disabled) { border-color: var(--ink); }
.story-option.right { background: #d3f9d8; border-color: var(--good); }
.story-option.wrong { background: #ffe3e3; border-color: var(--bad); }
.story-option:disabled { cursor: default; color: var(--ink); }
.story-score { font-weight: 600; }

/* ---------- API ---------- */
.token-create { display: flex; gap: .6rem; margin: 1rem 0; }
.token-create input { flex: 1; min-width: 0; font: inherit; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 10px; }
.token-once { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.token-value { flex: 1 1 100%; display: block; padding: .6rem .8rem; background: var(--bg); border-radius: 8px; word-break: break-all; font-size: .9rem; }
.token-table code { font-size: .85rem; }
.api-docs pre { background: #1d1b26; color: #f4f1fa; padding: 1rem; border-radius: 10px; overflow-x: auto; font-size: .85rem; }
.api-docs h3 { font-size: 1rem; margin-top: 1.3rem; }
.api-docs code { font-size: .88em; }

/* ---------- study calendar ---------- */
.streaks { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: .8rem 0 1rem; }
.streaks div { background: var(--bg); border-radius: 10px; padding: .7rem .9rem; display: flex; flex-direction: column; }
.streaks strong { font-size: 1.5rem; }
.streaks span { font-size: .8rem; color: var(--muted); }
.heatmap-scroll { overflow-x: auto; padding-bottom: .3rem; direction: rtl; }   /* start scrolled to today */
.heatmap { display: inline-flex; gap: 3px; direction: ltr; }
.hm-week { display: grid; grid-template-rows: repeat(7, 11px); gap: 3px; }
.hm-day { display: inline-block; width: 11px; height: 11px; border-radius: 2px; background: #ebe8f0; }
.hm-day.empty { background: transparent; }
.hm-day.l1 { background: #c6e9c8; }
.hm-day.l2 { background: #7cc785; }
.hm-day.l3 { background: #3a9d4f; }
.hm-day.l4 { background: #1e6b31; }
.hm-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; font-size: .75rem; color: var(--muted); margin-top: .4rem; }
.hm-legend span { margin: 0 .3rem; }
.streak-chip:hover { text-decoration: none; color: var(--on-page); background: rgba(255,255,255,.14); }
.today-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.goal-ring { display: inline-flex; align-items: center; gap: .5rem; color: var(--on-page); font-weight: 600; font-size: .85rem;
    background: rgba(255,255,255,.08); padding: .2rem .75rem .2rem .25rem; border-radius: 999px; }
.goal-ring:hover { text-decoration: none; color: var(--on-page); background: rgba(255,255,255,.14); }
.goal-ring svg { width: 28px; height: 28px; transform: rotate(-90deg); }
.goal-ring circle { fill: none; stroke-width: 4; }
.goal-ring .track { stroke: rgba(255,255,255,.18); }
.goal-ring .fill { stroke: #ffb347; stroke-linecap: round; transition: stroke-dasharray .4s; }
.goal-ring.met .fill { stroke: #69db7c; }
.streak-chip { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; font-size: .85rem; color: var(--on-page); background: rgba(255,255,255,.08); padding: .25rem .7rem; border-radius: 999px; }

/* ---------- self-study ---------- */
.self-study h3 { font-size: .95rem; margin: 1.1rem 0 .5rem; }
.pick-row { display: flex; flex-wrap: wrap; gap: .45rem; }
.pick {
    font: inherit; font-size: .88rem; padding: .4rem .85rem; border-radius: 999px; cursor: pointer;
    border: 1.5px solid var(--c, var(--line)); background: var(--surface); color: var(--ink);
}
.pick.on { background: var(--c, var(--ink)); color: #fff; }
.self-study-go { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- stroke order ---------- */
.strokes { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.strokes-svg { width: 150px; height: 150px; background: #fffdf8; border: 1px solid var(--line); border-radius: 12px; }
.strokes-svg path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.strokes-svg .grid { stroke: #ece6dc; stroke-width: .6; stroke-dasharray: 2 2; }
.strokes-svg .ghost { stroke: #e9e4ee; stroke-width: 3; }
.strokes-svg .live { stroke: var(--ink); stroke-width: 3.2; }
.strokes-svg .num { font-size: 8px; fill: var(--accent); transition: opacity .2s; }
.strokes-replay { font-size: .8rem; padding: .3rem .8rem; }

.item-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .8rem; }

.export-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.export-panel h2 { margin-bottom: .2rem; }
.export-panel p { margin: 0; max-width: 460px; }

.landing-kana { margin-top: 1rem; font-size: .92rem; color: var(--on-page-muted); }
.landing-kana a { color: var(--on-page-link); font-weight: 600; }

/* ---------- kana trainer ---------- */
.kana-page { max-width: 820px; margin: 0 auto; }
.kana-switch { display: inline-flex; background: rgba(255,255,255,.08); border-radius: 999px; padding: 4px; margin-bottom: 1rem; }
.kana-switch button { border: 0; background: transparent; color: var(--on-page-muted); font: inherit; font-weight: 600; padding: .45rem 1rem; border-radius: 999px; cursor: pointer; }
.kana-switch button.active { background: var(--surface); color: var(--ink); }
.kana-rows { display: flex; flex-direction: column; gap: .35rem; margin-top: .6rem; }
.kana-row { display: flex; align-items: center; gap: .35rem; opacity: .55; transition: opacity .15s; }
.kana-row.on { opacity: 1; }
.kana-row-pick { display: grid; place-items: center; width: 28px; }
.kana-row-pick input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.kana-cell {
    display: flex; flex-direction: column; align-items: center; justify-content: center; width: 58px; height: 58px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font: inherit; color: var(--ink);
}
.kana-cell:hover { border-color: var(--accent); }
.kana-cell span { font-size: 1.45rem; line-height: 1.1; }
.kana-cell small { font-size: .7rem; color: var(--muted); }
.kana-start { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; position: sticky; bottom: .75rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.kana-start .muted { display: block; }
.kana-progress { display: flex; justify-content: space-between; color: var(--on-page); margin-bottom: .6rem; }
.kana-progress .linkbtn { color: var(--on-page-link); }
.kana-quiz { text-align: center; padding: 2rem 1.2rem; }
.kana-big { font-size: 5rem; line-height: 1.15; margin-bottom: .6rem; font-family: 'Noto Sans JP', sans-serif; }
.kana-big.romaji { font-family: inherit; font-size: 3.4rem; font-weight: 700; }
.kana-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; max-width: 420px; margin: 0 auto; }
.kana-choice { font: inherit; font-size: 2rem; padding: .6rem 0; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.kana-choice:hover { border-color: var(--ink); }
.kana-missed { font-size: 1.4rem; letter-spacing: .2em; }
@media (max-width: 520px) {
    .kana-start { position: static; box-shadow: none; }
    .kana-start .btn-row { width: 100%; }
    .kana-start .btn-row > * { flex: 1 1 100%; text-align: center; }
    .kana-cell { width: 48px; height: 50px; }
    .kana-cell span { font-size: 1.2rem; }
    .kana-choices { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- achievements ---------- */
.stats-title { align-items: center; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; }
.badge {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: .3rem; padding: 1.1rem .9rem;
    background: #ece9f2; border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted);
}
.badge.earned { background: var(--surface); color: var(--ink); border-color: #f1c87b; box-shadow: 0 0 0 3px rgba(255, 200, 90, .18); }
.badge-icon {
    display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; font-size: 1.6rem;
    background: #d9d4e2; color: #fff; font-family: 'Noto Sans JP', sans-serif;
}
.badge.earned .badge-icon { background: linear-gradient(135deg, #ffb347, #d6453d); }
.badge-desc { font-size: .8rem; line-height: 1.35; }
.badge-bar { width: 100%; height: 6px; background: #d9d4e2; border-radius: 999px; overflow: hidden; margin-top: .3rem; }
.badge-bar span { display: block; height: 100%; background: var(--accent); }
.badge-count { font-size: .75rem; font-weight: 600; }

/* ---------- keyboard shortcut sheet ---------- */
.kbd-sheet { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(20, 16, 32, .6); padding: 1rem; }
.kbd-card { background: var(--surface); color: var(--ink); border-radius: var(--radius); padding: 1.2rem 1.4rem; width: min(420px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.kbd-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.kbd-close { border: 0; background: none; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); }
.kbd-card h4 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .4rem; }
.kbd-card dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem .9rem; margin: 0; font-size: .9rem; }
.kbd-card dt { text-align: right; white-space: nowrap; }
.kbd-card dd { margin: 0; }
kbd { display: inline-block; min-width: 1.6em; padding: .05rem .4rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--bg); font: inherit; font-size: .8rem; text-align: center; }

/* ---------- listening & sentence drills ---------- */
.drill-card { max-width: 620px; margin: 0 auto; text-align: center; padding: 2rem 1.3rem; }
.drill-play { font-size: 2.6rem; width: 96px; height: 96px; border-radius: 50%; border: 0; cursor: pointer; background: #fff0ee; box-shadow: 0 0 0 6px #ffe1dc; margin-bottom: .8rem; }
.drill-play:hover { background: #ffe1dc; }
.drill-sentence { font-size: 1.7rem; line-height: 1.8; margin: 0 0 .6rem; }
.drill-sentence mark { background: none; color: var(--accent); border-bottom: 3px solid var(--accent); padding: 0 .1em; }
.drill-reveal { display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .9rem; border-radius: 12px; margin-bottom: 1rem; }
.drill-reveal.right { background: #ebfbee; }
.drill-reveal.wrong { background: #fff0ee; }
.drill-word { font-size: 2.2rem; color: var(--ink); }
.drill-word:hover { text-decoration: none; color: var(--accent); }

/* ---------- leaderboard ---------- */
.leaderboard { max-width: 640px; }
.lb-join { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.lb-join span { display: block; color: var(--muted); font-size: .88rem; }
.lb-list { list-style: none; padding: 0; margin: 0; }
.lb-list li { display: grid; grid-template-columns: 2.4rem 34px 1fr auto auto; align-items: center; gap: .7rem; padding: .55rem .4rem; border-top: 1px solid var(--line); }
.lb-list li:first-child { border-top: 0; }
.lb-list li.me { background: #fff7e6; border-radius: 10px; }
.lb-list .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; }
.lb-rank { text-align: center; font-weight: 700; color: var(--muted); }
.lb-list li.top .lb-rank { font-size: 1.3rem; }
.lb-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-level { font-size: .78rem; color: var(--muted); }
.lb-points { font-weight: 700; min-width: 3.5rem; text-align: right; }
.lb-leave { margin: 1rem 0 0; font-size: .85rem; color: var(--muted); }

.item-history { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin-top: .7rem; }
.ih { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font-size: .75rem; font-weight: 700; color: #fff; }
.ih.ok { background: var(--good); }
.ih.miss { background: var(--bad); }
.ih.lesson { background: #8c86a0; }

.plan-buttons .btn-solid.lifetime { background: linear-gradient(135deg, #ffb347, #d6453d); }

/* ---------- small screens ---------- */
@media (max-width: 700px) {
    .dash-actions, .dash-main, .field-grid, .account-settings, .plan-grid { grid-template-columns: 1fr; }
    .srs-row { grid-template-columns: repeat(3, 1fr); }
    .pace-grid, .summary-stats { grid-template-columns: 1fr 1fr; }
    .prompt-chars { font-size: 4.5rem; }
    .prompt-cloze { font-size: 1.6rem; }
    .topbar { padding: .6rem 1rem; gap: .6rem; }
    /* logo + account menu on the first row, nav as one scrollable row underneath */
    .mainnav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .mainnav::-webkit-scrollbar { display: none; }
    .mainnav a { white-space: nowrap; }
    .lesson-dock { flex-wrap: wrap; }
    .upgrade-banner, .vacation-banner { flex-wrap: wrap; }
    .vacation-banner form { margin-left: 0; width: 100%; }
    .vacation-banner .btn-solid { width: 100%; }
    .upgrade-banner > div { flex: 1 1 180px; }
    .upgrade-banner .btn-solid { margin-left: 0; width: 100%; }
    .lesson-strip { order: -1; flex-basis: 100%; }
    .quiz-btn { margin-left: auto; }
    .account { margin-left: 0; }
    .user-name { display: none; }
    .streaks { grid-template-columns: 1fr 1fr 1fr; gap: .4rem; }
    .streaks strong { font-size: 1.2rem; }
    .settings-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .settings-tabs a { white-space: nowrap; }
    .admin-table { display: block; overflow-x: auto; }
    .token-table th:nth-child(3), .token-table td:nth-child(3) { display: none; }
    .top-search { margin-left: auto; }
    .top-search input, .top-search input:focus { width: 96px; }
    .top-search + .user-menu { margin-left: 0; }
}

/* very small phones: search shrinks to its icon and opens when tapped */
@media (max-width: 420px) {
    .brand { font-size: 1.05rem; }
    .top-search input { width: 34px; padding-right: 0; color: transparent; cursor: pointer; }
    .top-search input::placeholder { color: transparent; }
    .top-search input:focus { width: 150px; color: var(--ink); cursor: text; }
    .top-search input:focus::placeholder { color: var(--muted); }
}

/* ---------- framework / template bits ---------- */
#blazor-error-ui {
    background: #fff4d6; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none;
    left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }
.darker-border-checkbox.form-check-input { border-color: #929292; }
.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder { color: var(--bs-secondary-color); text-align: end; }
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder { text-align: start; }
