:root {
    --bg: #0d0b12;
    --surface: rgba(24, 19, 30, 0.78);
    --surface-solid: #17131d;
    --surface-soft: #211925;
    --border: rgba(255, 255, 255, 0.08);
    --text: #f7f1f5;
    --muted: #9f95a3;
    --rose: #cb4a65;
    --rose-bright: #ef6b82;
    --pink: #d7a1c5;
    --lavender: #a893c6;
    --wine: #642337;
    --success: #89c6a5;
    --danger: #eb7a82;
    --shadow: 0 26px 70px rgba(0, 0, 0, 0.34);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 78% 4%, rgba(110, 39, 67, 0.22), transparent 30%),
        linear-gradient(135deg, #0a0910 0%, #110d15 55%, #0b0910 100%);
    font-family: "DM Sans", "Noto Sans JP", sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--rose-bright); outline-offset: 3px; }

.page-glow { position: fixed; pointer-events: none; filter: blur(80px); opacity: .2; z-index: -1; }
.page-glow--one { width: 340px; height: 340px; background: #a53558; top: 8%; right: 8%; }
.page-glow--two { width: 300px; height: 300px; background: #66528d; bottom: 7%; left: 20%; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    padding: 26px 18px;
    border-right: 1px solid var(--border);
    background: rgba(11, 9, 14, 0.78);
    backdrop-filter: blur(22px);
    z-index: 10;
    display: flex;
    flex-direction: column;
}
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; padding: 0 8px 26px; }
.brand-mark {
    width: 42px; height: 42px; display: grid; place-items: center;
    border: 1px solid rgba(240, 127, 154, .28); border-radius: 14px;
    background: linear-gradient(145deg, rgba(132, 39, 65, .8), rgba(44, 28, 51, .9));
    color: #ffe6ed; font-family: "Noto Sans JP"; font-size: 20px; box-shadow: 0 8px 28px rgba(164, 48, 78, .18);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .02em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.nav-list { display: grid; gap: 7px; }
.nav-item {
    border: 0; background: transparent; cursor: pointer; padding: 11px 12px; border-radius: 12px;
    text-align: left; color: #a99fab; transition: .2s ease; display: flex; gap: 12px; align-items: center;
}
.nav-item span { width: 22px; color: #c8bacb; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(161, 54, 84, .22), rgba(255,255,255,.025)); color: #fff; box-shadow: inset 3px 0 0 var(--rose); }
.sidebar-card { margin-top: auto; padding: 16px; border: 1px solid var(--border); border-radius: 18px; background: rgba(255,255,255,.025); }
.streak-row { display: flex; align-items: baseline; gap: 7px; }
.streak-row strong { font-size: 34px; }
.streak-row span { color: var(--muted); font-size: 13px; }
.mini-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 12px; }
.mini-calendar span { aspect-ratio: 1; border-radius: 5px; background: rgba(255,255,255,.06); }
.mini-calendar span.active { background: linear-gradient(145deg, #c64b67, #772b45); box-shadow: 0 0 12px rgba(203,74,101,.3); }

.app-shell { margin-left: 240px; padding: 30px 38px 70px; max-width: 1560px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.topbar h1 { margin: 3px 0 0; font-size: clamp(24px, 3vw, 35px); font-weight: 600; letter-spacing: -.035em; }
.eyebrow { margin: 0; color: #c09bad; text-transform: uppercase; font-size: 10px; letter-spacing: .18em; font-weight: 700; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.xp-chip { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.035); font-size: 13px; }
.xp-chip span { color: var(--rose-bright); }
.icon-button { width: 39px; height: 39px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255,255,255,.035); cursor: pointer; }
.view { display: none; animation: fadeIn .35s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.teacher-hero {
    min-height: 390px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-xl);
    background: linear-gradient(112deg, #23151f 0%, #17101a 48%, #101015 100%); box-shadow: var(--shadow);
    display: grid; grid-template-columns: 1.03fr .97fr; position: relative;
}
.teacher-hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 68% 48%, transparent 0 30%, rgba(13,11,18,.38) 72%); pointer-events: none; }
.hero-copy { padding: 52px; position: relative; z-index: 3; align-self: center; }
.hero-copy h2 { font-size: clamp(36px, 5vw, 62px); line-height: .98; margin: 10px 0 18px; letter-spacing: -.055em; max-width: 650px; font-weight: 600; }
.hero-copy > p:not(.eyebrow) { max-width: 570px; color: #beb1bc; line-height: 1.75; font-size: 15px; }
.hero-actions { display: flex; gap: 10px; margin-top: 26px; }
.teacher-signature { margin-top: 20px; color: #d3aebe; font-family: "Noto Sans JP"; font-size: 13px; }
.hero-art { position: relative; min-height: 390px; overflow: hidden; }
.hero-art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 32%; filter: saturate(.78) contrast(1.04); transform: scale(1.06); }
.hero-fade { position: absolute; inset: 0; background: linear-gradient(90deg, #17101a 0%, rgba(23,16,26,.22) 35%, rgba(13,11,18,.12) 72%); }
.hero-orbit { position: absolute; border: 1px solid rgba(238, 116, 146, .28); border-radius: 50%; z-index: 2; }
.hero-orbit--one { width: 340px; height: 340px; right: 18%; top: 5%; }
.hero-orbit--two { width: 245px; height: 245px; right: 27%; top: 18%; border-color: rgba(194,166,216,.18); }

.button { border: 1px solid var(--border); border-radius: 12px; padding: 11px 16px; cursor: pointer; transition: .2s ease; font-weight: 600; font-size: 13px; }
.button:hover { transform: translateY(-1px); }
.button--primary { border-color: transparent; background: linear-gradient(135deg, #a63151, #d55270); color: white; box-shadow: 0 10px 30px rgba(180,59,91,.22); }
.button--ghost { background: rgba(255,255,255,.04); }
.hidden { display: none !important; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0 40px; }
.stat-card { padding: 18px; border: 1px solid var(--border); background: var(--surface); border-radius: 17px; display: flex; align-items: center; gap: 14px; backdrop-filter: blur(12px); }
.stat-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 38px; line-height: 1; background: rgba(203,74,101,.12); color: #e38ba0; }
.stat-card strong, .stat-card div > span { display: block; }
.stat-card strong { font-size: 22px; }
.stat-card div span { color: var(--muted); font-size: 12px; margin-top: 2px; }

.section-block { margin-top: 24px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 18px; }
.section-heading h2 { margin: 5px 0 0; font-size: 28px; letter-spacing: -.03em; }
.section-heading > p { margin: 0; max-width: 470px; text-align: right; color: var(--muted); line-height: 1.55; font-size: 13px; }
.progress-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.progress-card { padding: 20px; border: 1px solid var(--border); background: var(--surface); border-radius: 18px; }
.progress-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.progress-symbol { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 14px; font-size: 20px; background: linear-gradient(145deg, rgba(170,61,92,.18), rgba(109,83,134,.12)); border: 1px solid rgba(255,255,255,.05); }
.progress-card h3 { margin: 14px 0 4px; font-size: 16px; }
.progress-card p { margin: 0; color: var(--muted); font-size: 12px; }
.progress-number { color: #d5bdca; font-size: 12px; }
.progress-track { height: 6px; margin-top: 16px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8c2f4b, #db5c79); transition: width .35s ease; }

.dashboard-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.panel { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-lg); backdrop-filter: blur(14px); }
.focus-panel { padding: 25px; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; }
.panel-heading h3 { margin: 5px 0 0; font-size: 20px; }
.status-dot { width: 9px; height: 9px; background: var(--rose-bright); border-radius: 50%; box-shadow: 0 0 0 6px rgba(203,74,101,.1); }
.focus-item { margin-top: 22px; display: flex; gap: 17px; align-items: center; }
.focus-character { width: 78px; height: 78px; flex: 0 0 78px; display: grid; place-items: center; border-radius: 18px; font: 600 38px "Noto Sans JP"; background: linear-gradient(145deg, #2b1a24, #17111a); border: 1px solid var(--border); }
.focus-item h4 { margin: 0 0 5px; font-size: 16px; }
.focus-item p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.quote-panel { min-height: 240px; position: relative; overflow: hidden; }
.quote-panel img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; filter: saturate(.75); }
.quote-overlay { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(13,10,14,.9), rgba(13,10,14,.48) 60%, rgba(13,10,14,.18)); }
.quote-copy { position: relative; z-index: 1; padding: 28px; max-width: 440px; }
.quote-copy blockquote { margin: 12px 0 0; font-size: 20px; line-height: 1.55; color: #f2e8ed; }

.study-layout { display: grid; grid-template-columns: minmax(0, 1fr) 315px; gap: 14px; }
.study-main { padding: 28px; min-height: 690px; }
.study-header { display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.study-header h2 { margin: 5px 0 0; font-size: 32px; }
.mode-switch { padding: 4px; background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 12px; display: flex; }
.mode-button { border: 0; background: transparent; border-radius: 9px; padding: 8px 12px; color: var(--muted); cursor: pointer; font-size: 12px; }
.mode-button.active { color: white; background: #3a2430; box-shadow: 0 5px 18px rgba(0,0,0,.18); }
.lesson-progress { height: 5px; background: rgba(255,255,255,.05); border-radius: 99px; overflow: hidden; margin-top: 24px; }
.lesson-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7e2944, #e36180); transition: .3s ease; }
.lesson-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 8px; }
.quiz-card { margin: 35px auto 0; max-width: 720px; text-align: center; }
.quiz-prompt { color: #b8adb6; font-size: 13px; margin-bottom: 18px; }
.symbol-wrap { min-height: 165px; display: grid; place-items: center; }
.quiz-symbol { font-family: "Noto Sans JP"; font-size: clamp(82px, 11vw, 130px); font-weight: 500; line-height: 1; text-shadow: 0 16px 45px rgba(201,78,107,.15); }
.kanji-display { font-family: "Noto Sans JP"; font-size: clamp(70px, 9vw, 110px); }
ruby rt { font-size: .25em; color: #d49cb0; font-weight: 500; letter-spacing: .03em; }
.symbol-note { min-height: 20px; color: var(--muted); font-size: 12px; }
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 24px; }
.choice { border: 1px solid var(--border); border-radius: 14px; background: rgba(255,255,255,.035); padding: 15px; cursor: pointer; transition: .18s ease; }
.choice:hover:not(:disabled) { background: rgba(255,255,255,.065); border-color: rgba(227,139,160,.3); }
.choice.correct { background: rgba(90,160,120,.12); border-color: rgba(125,199,157,.5); color: #b9e4ca; }
.choice.wrong { background: rgba(190,80,90,.12); border-color: rgba(235,122,130,.5); color: #efafb4; }
.input-answer { max-width: 520px; margin: 25px auto 0; text-align: left; }
.input-answer label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; color: white; background: rgba(255,255,255,.045); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.feedback { min-height: 54px; margin-top: 18px; font-size: 13px; }
.feedback strong { display: block; font-size: 14px; margin-bottom: 4px; }
.feedback.correct { color: var(--success); }
.feedback.wrong { color: var(--danger); }
.quiz-actions { display: flex; justify-content: flex-end; gap: 9px; max-width: 720px; margin: 16px auto 0; }
.study-side { display: grid; gap: 14px; align-content: start; }
.teacher-card { overflow: hidden; }
.teacher-card img { width: 100%; height: 250px; object-fit: cover; object-position: center 25%; filter: saturate(.72); }
.teacher-card div { padding: 18px; }
.teacher-card div p:last-child { color: #b9aeb8; font-size: 13px; line-height: 1.65; margin-bottom: 0; }
.session-card { padding: 20px; }
.session-stat { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.055); }
.session-stat:last-child { border-bottom: 0; }
.session-stat span { color: var(--muted); font-size: 12px; }
.session-stat strong { font-size: 15px; }

.content-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.content-card { padding: 21px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); }
.content-card .jp { font: 600 24px "Noto Sans JP"; }
.content-card h3 { margin: 0 0 7px; font-size: 18px; }
.content-card .meaning { color: #decbd4; font-size: 13px; margin-top: 9px; }
.content-card p:last-child { color: var(--muted); font-size: 12px; line-height: 1.6; margin-bottom: 0; }
.grammar-example { margin-top: 15px; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.03); font-family: "Noto Sans JP"; font-size: 13px; line-height: 1.7; }

.achievement-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.achievement { padding: 22px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); position: relative; overflow: hidden; }
.achievement.locked { filter: saturate(.4); opacity: .58; }
.achievement-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: linear-gradient(145deg, rgba(178,61,91,.2), rgba(101,79,128,.16)); border: 1px solid var(--border); font-size: 20px; }
.achievement h3 { margin: 16px 0 6px; font-size: 16px; }
.achievement p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.achievement-badge { position: absolute; top: 18px; right: 18px; color: #d9aabb; font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }

/* Leaderboards */
.leaderboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.leaderboard-panel { overflow: hidden; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); backdrop-filter: blur(12px); }
.leaderboard-title { display: flex; align-items: center; gap: 12px; padding: 20px; border-bottom: 1px solid var(--border); }
.leaderboard-title-icon { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 40px; border-radius: 12px; background: rgba(203,74,101,.12); color: #e38ba0; line-height: 1; }
.leaderboard-title p { margin: 0 0 3px; color: #b48c9e; font-size: 9px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.leaderboard-title h3 { margin: 0; font-size: 18px; }
.leaderboard-list { padding: 8px; }
.leaderboard-row { display: grid; grid-template-columns: 32px 38px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 58px; padding: 8px 11px; border-radius: 13px; }
.leaderboard-row + .leaderboard-row { margin-top: 2px; }
.leaderboard-row:nth-child(-n+3) { background: rgba(255,255,255,.025); }
.leaderboard-row.is-current { background: linear-gradient(90deg, rgba(161,54,84,.18), rgba(255,255,255,.025)); box-shadow: inset 2px 0 0 var(--rose); }
.leaderboard-rank { color: #b5a8b2; font-size: 12px; font-weight: 700; text-align: center; }
.leaderboard-row:nth-child(1) .leaderboard-rank { color: #edc77e; }
.leaderboard-row:nth-child(2) .leaderboard-rank { color: #c9c5d0; }
.leaderboard-row:nth-child(3) .leaderboard-rank { color: #cc967c; }
.leaderboard-avatar { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(227,139,160,.16); border-radius: 10px; background: rgba(203,74,101,.1); color: #e6b5c3; font-weight: 700; }
.leaderboard-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.leaderboard-name small { margin-left: 7px; color: #d792a7; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.leaderboard-row > strong { color: #f2eaf0; font-size: 14px; text-align: right; }
.leaderboard-row > strong small { color: var(--muted); font-size: 9px; font-weight: 600; text-transform: uppercase; }
.leaderboard-loading, .leaderboard-empty { margin: 0; padding: 42px 16px; color: var(--muted); font-size: 12px; text-align: center; }
.leaderboard-empty span { display: block; margin-top: 5px; color: #756c78; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; transform: translateY(18px); opacity: 0; pointer-events: none; transition: .25s ease; padding: 13px 16px; border-radius: 13px; border: 1px solid var(--border); background: #241721; box-shadow: var(--shadow); font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
    .sidebar { width: 82px; padding-inline: 12px; }
    .brand span:last-child, .nav-item:not(.active)::after, .nav-item { font-size: 0; }
    .brand { justify-content: center; padding-inline: 0; }
    .nav-item { justify-content: center; padding: 12px; }
    .nav-item span { font-size: 16px; }
    .sidebar-card { display: none; }
    .app-shell { margin-left: 82px; }
    .teacher-hero { grid-template-columns: 1fr; }
    .hero-art { position: absolute; inset: 0 0 0 45%; opacity: .56; }
    .hero-copy { max-width: 700px; }
    .progress-grid, .content-grid, .achievement-grid { grid-template-columns: repeat(2, 1fr); }
    .study-layout { grid-template-columns: 1fr; }
    .study-side { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
    .sidebar { position: fixed; inset: auto 0 0 0; width: auto; height: 64px; flex-direction: row; padding: 7px 8px; border-right: 0; border-top: 1px solid var(--border); }
    .brand, .sidebar-card { display: none; }
    .nav-list { display: flex; justify-content: space-around; width: 100%; gap: 2px; }
    .nav-item { flex: 1; padding: 10px 4px; border-radius: 10px; }
    .nav-item.active { box-shadow: inset 0 -2px 0 var(--rose); }
    .app-shell { margin: 0; padding: 20px 16px 92px; }
    .topbar { align-items: flex-start; }
    .xp-chip { display: none; }
    .teacher-hero { min-height: 520px; }
    .hero-copy { padding: 30px 24px; align-self: end; }
    .hero-copy h2 { font-size: 43px; }
    .hero-art { inset: 0; opacity: .5; }
    .hero-fade { background: linear-gradient(0deg, #17101a 0%, rgba(23,16,26,.52) 54%, rgba(13,11,18,.15)); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .progress-grid, .dashboard-split, .content-grid, .achievement-grid, .study-side, .leaderboard-grid { grid-template-columns: 1fr; }
    .section-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
    .section-heading > p { text-align: left; }
    .study-main { padding: 20px 16px; }
    .study-header { align-items: flex-start; flex-direction: column; }
    .choice-grid { grid-template-columns: 1fr; }
    .hero-actions { flex-wrap: wrap; }
    .sidebar { overflow-x: auto; }
    .nav-list { min-width: 400px; }
}

/* Detailed progress */
.progress-card--button {
    width: 100%;
    color: inherit;
    text-align: left;
    cursor: pointer;
    font: inherit;
    transition: transform .2s ease, border-color .2s ease, background .2s ease;
}
.progress-card--button:hover {
    transform: translateY(-3px);
    border-color: rgba(227,139,160,.26);
    background: rgba(31,24,36,.92);
}
.progress-open {
    display: inline-block;
    margin-top: 13px;
    color: #d49cb0;
    font-size: 11px;
    font-weight: 700;
}
.mastery-header { margin-bottom: 18px; }
.back-button {
    border: 0;
    background: transparent;
    color: #c9b6c2;
    cursor: pointer;
    padding: 0;
    margin-bottom: 18px;
    font-size: 13px;
}
.back-button:hover { color: white; }
.mastery-heading { margin-bottom: 14px; }
.mastery-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 16px 0;
}
.mastery-summary article {
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
}
.mastery-summary span,
.mastery-summary strong { display: block; }
.mastery-summary span { color: var(--muted); font-size: 11px; }
.mastery-summary strong { margin-top: 4px; font-size: 22px; }
.mastery-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 18px 0 20px;
}
.filter-pills {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}
.filter-pill {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255,255,255,.025);
    color: var(--muted);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 11px;
}
.filter-pill.active {
    color: #fff;
    background: rgba(166,49,81,.22);
    border-color: rgba(227,139,160,.25);
}
.mastery-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}
.mastery-card {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--surface);
    position: relative;
    overflow: hidden;
}
.mastery-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: rgba(255,255,255,.08);
}
.mastery-card--mastered::before { background: var(--success); }
.mastery-card--learning::before { background: #d8a45a; }
.mastery-card--unseen { opacity: .72; }
.mastery-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.mastery-symbol {
    min-height: 54px;
    display: inline-grid;
    place-items: center;
    font: 600 38px "Noto Sans JP";
    line-height: 1;
}
.mastery-symbol--kanji { padding-top: 8px; }
.mastery-symbol rt { font-size: .28em; }
.mastery-status {
    color: #b7a9b3;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .11em;
    padding: 6px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.04);
}
.mastery-card--mastered .mastery-status { color: #bce4cc; background: rgba(89,154,117,.11); }
.mastery-card--learning .mastery-status { color: #efd0a0; background: rgba(216,164,90,.10); }
.mastery-reading {
    min-height: 33px;
    margin-top: 8px;
    color: #d9c7d0;
    font-size: 12px;
    line-height: 1.45;
}
.mastery-accuracy-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
    margin-top: 13px;
}
.mastery-accuracy-row strong { font-size: 11px; }
.mastery-accuracy-row span { color: var(--muted); font-size: 9px; white-space: nowrap; }
.answer-ratio {
    display: flex;
    height: 6px;
    margin-top: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.05);
}
.answer-ratio-correct { background: var(--success); }
.answer-ratio-wrong { background: var(--danger); }
.answer-breakdown {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 9px;
}
.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}
.dot--correct { background: var(--success); }
.dot--wrong { background: var(--danger); }
.mastery-empty,
.content-empty {
    grid-column: 1 / -1;
    padding: 50px 24px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 18px;
    color: var(--muted);
}

/* Larger reference libraries */
.content-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 18px;
    margin-bottom: 18px;
}
.content-search {
    width: min(480px, 100%);
}
.content-search span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 11px;
}
.content-search input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,.035);
    color: white;
    padding: 11px 13px;
}
.content-search input::placeholder { color: #706772; }
.content-count { color: var(--muted); font-size: 11px; }
.content-tag {
    display: inline-flex;
    margin-bottom: 13px;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(203,74,101,.10);
    color: #d7a6b5;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.grammar-card p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.grammar-example span { color: #a99ca7; font-family: "DM Sans"; }

@media (max-width: 1280px) {
    .mastery-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
    .mastery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .mastery-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
    .mastery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mastery-toolbar, .content-toolbar { align-items: stretch; flex-direction: column; }
    .content-count { align-self: flex-start; }
}

@media (max-width: 430px) {
    .mastery-grid { grid-template-columns: 1fr; }
}

/* ---------- Account / authentication ---------- */
body.auth-locked { overflow: hidden; }
body.auth-locked > .sidebar,
body.auth-locked > .app-shell,
body.auth-locked > .install-banner,
body.auth-locked > .modal-backdrop { display: none !important; }
body:not(.auth-locked) .auth-gate { display: none; }

.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: minmax(360px, 1.05fr) minmax(420px, .95fr);
    background: #0b0910;
}
.auth-art { position: relative; min-height: 100vh; overflow: hidden; background: #140d16; }
.auth-art img { width: 100%; height: 100%; object-fit: cover; object-position: center; filter: saturate(.82) contrast(1.04); }
.auth-art-shade {
    position: absolute; inset: 0;
    background: linear-gradient(90deg, rgba(10,8,13,.12), rgba(10,8,13,.18) 44%, rgba(10,8,13,.88)), linear-gradient(0deg, rgba(10,8,13,.84), transparent 58%);
}
.auth-quote { position: absolute; left: clamp(28px, 5vw, 72px); bottom: clamp(34px, 8vh, 82px); max-width: 480px; }
.auth-quote .brand-mark { margin-bottom: 18px; }
.auth-quote p { margin: 0 0 12px; font: 500 clamp(22px, 2.3vw, 34px)/1.35 "DM Sans", sans-serif; letter-spacing: -.02em; }
.auth-quote strong { color: var(--pink); font-size: 14px; }
.auth-panel { display: grid; place-items: center; padding: 42px; background: radial-gradient(circle at 80% 10%, rgba(117,38,65,.16), transparent 34%), #0d0b12; }
.auth-card { width: min(100%, 470px); }
.auth-brand { padding: 0 0 38px; width: fit-content; }
.auth-heading h1 { margin: 8px 0 9px; font-size: clamp(32px, 4vw, 48px); letter-spacing: -.045em; }
.auth-heading > p:last-child { margin: 0; color: var(--muted); }
.auth-tabs { margin: 30px 0 22px; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border: 1px solid var(--border); border-radius: 13px; background: rgba(255,255,255,.025); }
.auth-tab { border: 0; padding: 10px; border-radius: 9px; cursor: pointer; background: transparent; color: var(--muted); font-weight: 700; }
.auth-tab.active { color: #fff; background: rgba(203,74,101,.16); box-shadow: inset 0 0 0 1px rgba(239,107,130,.14); }
.auth-form { display: none; gap: 15px; }
.auth-form.active { display: grid; }
.auth-form label { display: grid; gap: 7px; color: #d5cbd7; font-size: 13px; font-weight: 600; }
.auth-form input {
    width: 100%; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.035); color: #fff; padding: 13px 14px;
}
.auth-form input::placeholder { color: #6f6673; }
.auth-form input:focus { border-color: rgba(239,107,130,.5); background: rgba(255,255,255,.05); }
.auth-submit { width: 100%; justify-content: center; margin-top: 3px; }
.auth-separator { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin: 22px 0; color: #716876; font-size: 12px; }
.auth-separator::before, .auth-separator::after { content: ""; height: 1px; background: var(--border); }
.google-login { min-height: 42px; display: grid; place-items: center; margin-bottom: 10px; }
.google-login.hidden { display: none; }
.button--passkey { width: 100%; justify-content: center; background: rgba(255,255,255,.04); border: 1px solid var(--border); }
.passkey-icon { font-size: 18px; }
.auth-status { min-height: 20px; margin: 12px 0 0; text-align: center; color: var(--danger); font-size: 13px; }
.auth-status.success { color: var(--success); }
.auth-privacy { margin: 16px auto 0; max-width: 410px; color: #6f6673; text-align: center; font-size: 11px; line-height: 1.55; }

/* ---------- Account controls ---------- */
.account-chip, .install-chip {
    min-height: 40px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.035); color: #ddd2df; cursor: pointer;
}
.account-chip { display: flex; align-items: center; gap: 9px; padding: 5px 11px 5px 6px; }
.account-avatar { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: linear-gradient(145deg, #72253e, #2c1b32); color: #ffe5ed; font-family: "Noto Sans JP"; }
.install-chip { display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; font-weight: 700; font-size: 12px; }
.install-chip.hidden { display: none; }

.modal-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 22px; background: rgba(4,3,6,.72); backdrop-filter: blur(12px); }
.modal-backdrop.hidden { display: none; }
.account-modal { position: relative; width: min(100%, 580px); border: 1px solid var(--border); border-radius: 24px; padding: 30px; background: #17131d; box-shadow: var(--shadow); }
.account-modal h2 { margin: 7px 0 8px; font-size: 28px; }
.modal-muted { color: var(--muted); margin: 0 0 24px; }
.modal-close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 10px; background: rgba(255,255,255,.03); cursor: pointer; font-size: 22px; }
.account-profile-row { display: flex; align-items: center; gap: 13px; padding: 15px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255,255,255,.025); }
.account-profile-avatar { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: linear-gradient(145deg, #782842, #302038); color: #fff; font-family: "Noto Sans JP"; font-size: 19px; }
.account-profile-row strong, .account-profile-row span { display: block; }
.account-profile-row span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.display-name-form { margin-top: 14px; }
.display-name-form > label { display: block; margin-bottom: 7px; color: #cfc4ca; font-size: 12px; font-weight: 600; }
.display-name-controls { display: flex; gap: 8px; }
.display-name-controls input { min-width: 0; flex: 1; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: rgba(255,255,255,.035); color: var(--text); }
.display-name-controls input:focus { border-color: rgba(239,107,130,.5); background: rgba(255,255,255,.05); }
.display-name-form p { min-height: 17px; margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.security-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 16px; }
.security-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.passkey-note { min-height: 18px; color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 23px; padding-top: 20px; border-top: 1px solid var(--border); }
.danger-button { color: #ff9da8; }

/* ---------- PWA install ---------- */
.install-banner {
    position: fixed; z-index: 70; right: 24px; bottom: 24px; width: min(430px, calc(100vw - 40px)); display: flex; align-items: center; justify-content: space-between; gap: 18px;
    padding: 16px; border: 1px solid rgba(239,107,130,.22); border-radius: 18px; background: rgba(23,19,29,.96); box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.install-banner.hidden { display: none; }
.install-banner strong { display: block; margin-bottom: 4px; }
.install-banner p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.install-actions { display: flex; flex-shrink: 0; gap: 7px; }
.install-actions .button { padding: 9px 11px; white-space: nowrap; }

@media (max-width: 860px) {
    .auth-gate { grid-template-columns: 1fr; }
    .auth-art { display: none; }
    .auth-panel { min-height: 100dvh; padding: 26px 20px; }
    .auth-card { width: min(100%, 520px); }
    .auth-brand { padding-bottom: 30px; }
    .topbar-actions { gap: 7px; }
    .account-chip #accountName, .install-chip { font-size: 0; }
    .install-chip span { font-size: 18px; }
    .install-chip { width: 40px; padding: 0; justify-content: center; }
    .security-card { align-items: flex-start; flex-direction: column; }
    .security-card .button { width: 100%; justify-content: center; }
    .display-name-controls { align-items: stretch; }
    .install-banner { left: 14px; right: 14px; bottom: 14px; width: auto; flex-direction: column; align-items: stretch; }
    .install-actions { justify-content: flex-end; }
}

/* Study audio */
.symbol-stage { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; width: 100%; }
.pronounce-button {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 34px; padding: 0 11px;
    border: 1px solid rgba(221, 154, 177, .16); border-radius: 10px;
    background: rgba(255,255,255,.025);
    box-shadow: none;
    color: #bfb2ba; cursor: pointer;
    font: inherit; font-size: 11px; font-weight: 600; letter-spacing: .035em;
    transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease, color .18s ease;
}
.pronounce-button:hover {
    transform: translateY(-1px); color: #f4e7ec;
    background: rgba(201,78,107,.08);
    border-color: rgba(225, 132, 164, .3);
}
.pronounce-button:active { transform: translateY(0) scale(.97); }
.pronounce-button:focus-visible { outline: 2px solid rgba(231, 154, 181, .72); outline-offset: 3px; }
.pronounce-button[aria-disabled="true"] { opacity: .42; cursor: not-allowed; transform: none; }
.pronounce-button[aria-disabled="true"]:hover { color: #bfb2ba; background: rgba(255,255,255,.025); border-color: rgba(221,154,177,.16); transform: none; }
.pronounce-button::after {
    content: attr(data-tooltip);
    position: absolute; z-index: 8; left: 50%; bottom: calc(100% + 9px); width: max-content; max-width: min(240px, 72vw);
    padding: 7px 9px; border: 1px solid rgba(255,255,255,.1); border-radius: 8px;
    background: #211923; box-shadow: 0 8px 24px rgba(0,0,0,.3); color: #e6dce2;
    font-size: 10px; font-weight: 500; line-height: 1.35; letter-spacing: 0; text-align: center;
    opacity: 0; pointer-events: none; transform: translate(-50%, 4px); transition: opacity .16s ease, transform .16s ease;
}
.pronounce-button[aria-disabled="true"]:hover::after,
.pronounce-button[aria-disabled="true"]:focus-visible::after,
.pronounce-button.show-tooltip::after { opacity: 1; transform: translate(-50%, 0); }
.pronounce-icon { width: 15px; height: 15px; fill: currentColor; overflow: visible; }
.pronounce-icon .sound-wave { fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; }
.pronounce-button.is-speaking {
    color: #f0cbd7; border-color: rgba(232, 139, 172, .38);
    background: rgba(201,78,107,.1);
}
.pronounce-button.is-speaking .sound-wave--one { animation: sound-wave-pulse .7s ease-in-out infinite alternate; }
.pronounce-button.is-speaking .sound-wave--two { animation: sound-wave-pulse .7s .12s ease-in-out infinite alternate; }
@keyframes sound-wave-pulse { from { opacity: .28; } to { opacity: 1; } }
.settings-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 0; border-top: 1px solid rgba(255,255,255,.08); }
.settings-card p { margin: 5px 0 0; color: #9e939b; font-size: 12px; line-height: 1.5; }
.sound-toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; flex: 0 0 auto; color: #cfc4ca; font-size: 12px; }
.sound-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.sound-toggle-track { width: 42px; height: 23px; padding: 3px; border-radius: 999px; background: rgba(255,255,255,.11); transition: background .2s ease; }
.sound-toggle-track span { display: block; width: 17px; height: 17px; border-radius: 50%; background: #a99da4; transition: transform .2s ease, background .2s ease; }
.sound-toggle input:checked + .sound-toggle-track { background: rgba(201,78,107,.4); }
.sound-toggle input:checked + .sound-toggle-track span { transform: translateX(19px); background: #f4dce4; }
@media (max-width: 620px) { .pronounce-button { height: 34px; padding: 0 10px; } .symbol-stage { width: 100%; } }
