@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800&family=Noto+Sans+JP:wght@300;400;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
    /* ── Hearlix Brand ── */
    --bg: #0B1528;
    --surface: #111D35;
    --surface2: #1A2844;
    --border: rgba(43,107,242,0.12);
    --text: #F0F4FA;
    --text-muted: #9CAFCC;

    /* ── Brand primaries ── */
    --helix-blue: #2B6BF2;
    --helix-cyan: #00D4FF;
    --helix-teal: #0ABFB0;
    --accent: #2B6BF2;

    /* ── Warm accents (emotional moments) ── */
    --coral: #FF6B5A;
    --amber: #FFB347;
    --violet: #A78BFA;
    --emerald: #34D399;

    /* ── Entry types ── */
    --word: #2B6BF2;
    --phrasal: #0ABFB0;
    --structure: #A78BFA;
    --idiom: #FF6B5A;
    --formulaic: #F59E0B;

    /* ── Mastery levels ── */
    --lv0: #FF6B5A;
    --lv1: #FFB347;
    --lv2: #FFD97A;
    --lv3: #34D399;
    --lv4: #0ABFB0;
    --lv5: #0ABFB0;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Navbar */
.navbar {
    background: rgba(11,21,40,0.85) !important;
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
.navbar-brand {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    color: var(--text) !important;
}
.nav-link {
    color: var(--text-muted) !important;
    transition: color 0.2s;
}
.nav-link:hover, .nav-link.active {
    color: var(--text) !important;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

/* Stat cards */
.stat-card {
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}
.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    font-weight: 700;
}
.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Action cards */
.action-card {
    transition: transform 0.2s, border-color 0.2s;
    color: var(--text);
}
.action-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    color: var(--text);
}

/* Form controls */
.form-control, .form-select {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text);
}
.form-control:focus, .form-select:focus {
    background: var(--surface2);
    border-color: var(--helix-blue);
    color: var(--text);
    box-shadow: 0 0 0 0.2rem rgba(43,107,242,0.25);
}
.form-control::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn-primary {
    background: var(--helix-blue);
    border-color: var(--helix-blue);
}
.btn-primary:hover {
    background: #1f5bd6;
    border-color: #1f5bd6;
    box-shadow: 0 4px 16px rgba(43,107,242,0.35);
}

/* Tables */
.table {
    color: var(--text);
}
.table > :not(caption) > * > * {
    background: transparent;
    border-bottom-color: var(--border);
}
.table-hover > tbody > tr:hover > * {
    background: var(--surface2);
}

/* Entry type badges */
.badge-word {
    background: var(--word);
    color: #fff;
}
.badge-phrasal {
    background: var(--phrasal);
    color: #fff;
}
.badge-structure {
    background: var(--structure);
    color: #fff;
}
.badge-idiom {
    background: var(--idiom);
    color: #fff;
}
.badge-formulaic {
    background: var(--formulaic);
    color: #fff;
}

/* Mastery level badges */
.badge-lv0 { background: var(--lv0); color: #fff; }
.badge-lv1 { background: var(--lv1); color: #fff; }
.badge-lv2 { background: var(--lv2); color: #000; }
.badge-lv3 { background: var(--lv3); color: #000; }
.badge-lv4 { background: var(--lv4); color: #000; }
.badge-lv5 { background: var(--lv5); color: #fff; }

/* Weaponized badge — 武器化完了 */
.badge-weaponized {
    background: linear-gradient(135deg, #FFD700, #FF6B00);
    color: #000;
    font-weight: 800;
    border: 2px solid #FFD700;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
    animation: weaponized-glow 2s ease-in-out infinite alternate;
}
@keyframes weaponized-glow {
    from { box-shadow: 0 0 8px rgba(255, 215, 0, 0.3); }
    to   { box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 107, 0, 0.2); }
}

/* Frequency badges */
.badge-freq-high { background: #FF6B5A; color: #fff; }
.badge-freq-medium { background: #FFB347; color: #000; }
.badge-freq-low { background: #8b8fa3; color: #fff; }

/* English-only fields */
.english-only-field.hidden {
    display: none !important;
}

/* Chart cards (matching sample-charts.html) */
.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    position: relative;
    overflow: hidden;
}
.chart-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--word), var(--phrasal), var(--structure));
    opacity: 0.6;
}
.chart-card.diverging::before {
    background: linear-gradient(90deg, var(--lv0), var(--lv2), var(--lv3), var(--lv5));
}
.chart-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}
.summary-stat {
    background: var(--surface2);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}
.summary-stat .val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    font-weight: 600;
}
.summary-stat .lbl {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Review card */
.review-card, .quiz-card {
    border: 2px solid var(--border);
    transition: border-color 0.3s;
}
.review-card.correct, .quiz-card.correct {
    border-color: var(--lv5);
}
.review-card.incorrect, .quiz-card.incorrect {
    border-color: var(--lv0);
}

/* Mic button pulse animation */
.btn-mic-active {
    animation: mic-pulse 1.5s infinite;
}
@keyframes mic-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(255, 193, 7, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); }
}

/* Calendar grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 12px;
    background: var(--surface2);
    color: var(--text-muted);
}
.calendar-day.both { background: #0ABFB0; color: #fff; }
.calendar-day.review { background: #2B6BF2; color: #fff; }
.calendar-day.entry { background: #FFB347; color: #000; }
.calendar-day.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.calendar-day.header {
    background: transparent;
    font-weight: 600;
    font-size: 11px;
    color: var(--text-muted);
}
.calendar-day-sample {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 4px;
}

/* Toast container */
.toast-container {
    z-index: 9999;
}

/* Pagination */
.pagination .page-link {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}
.pagination .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
}

/* 3D map container */
#word-map-container canvas {
    width: 100% !important;
    height: 100% !important;
    border-radius: 12px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Selection */
::selection {
    background: rgba(43,107,242,0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .stat-value { font-size: 1.5rem; }
    .chart-card { padding: 16px; }

    /* Entry detail: example row — stack text + actions vertically on mobile */
    .ex-row {
        flex-direction: column;
        align-items: flex-start !important;
    }
    .ex-sentence {
        width: 100%;
        flex-shrink: 0;
    }
    .ex-actions {
        margin-top: 4px;
    }
    /* Hide voice badge on mobile to save space */
    .example-voice-badge { display: none !important; }
}

/* Example block in form */
.example-block {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}
.example-block h6 {
    color: var(--accent);
    font-weight: 600;
}

/* Dynamic list item */
.dynamic-item {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}
.dynamic-item .form-control {
    flex: 1;
}

/* Mark (highlight) */
mark {
    background: rgba(43,107,242,0.3);
    color: var(--text);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Portfolio mark — adopted entry from user's expression portfolio (used in 英作文アトリエ) */
mark.portfolio-mark {
    background: linear-gradient(180deg, transparent 35%, rgba(255,196,0,0.45) 35%, rgba(255,196,0,0.45) 92%, transparent 92%);
    color: var(--text);
    padding: 1px 2px;
    border-radius: 2px;
}

/* Clickable wrapper for portfolio mark — opens entry detail */
a.portfolio-mark-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border-bottom: 1px dotted rgba(255,196,0,0.5);
}
a.portfolio-mark-link:hover mark.portfolio-mark {
    background: linear-gradient(180deg, transparent 20%, rgba(255,196,0,0.7) 20%, rgba(255,196,0,0.7) 100%);
    box-shadow: 0 0 0 1px rgba(255,196,0,0.6);
}

/* Portfolio note — explains the yellow highlight near the result */
.portfolio-note {
    display: flex;
    width: fit-content;
    max-width: 100%;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: rgba(255,196,0,0.06);
    border: 1px solid rgba(255,196,0,0.2);
    border-radius: 6px;
    padding: 4px 10px;
    margin-bottom: 12px;
}
.portfolio-note .portfolio-note-sample {
    background: linear-gradient(180deg, transparent 35%, rgba(255,196,0,0.45) 35%, rgba(255,196,0,0.45) 92%, transparent 92%);
    padding: 0 4px;
    border-radius: 2px;
    color: var(--text);
}

/* Portfolio badge — matches portfolio-mark for visual coupling */
.badge.portfolio-badge {
    background: linear-gradient(135deg, #FFC400, #FF9D00) !important;
    color: #1a1a1a !important;
    font-weight: 600;
    border: 1px solid rgba(255,196,0,0.6);
}
.badge.portfolio-badge:hover {
    filter: brightness(1.1);
}

/* --- 注目表現（未登録）のハイライト -------------------------------------
   ポートフォリオ採用エントリ（黄色）と色で区別する。
   黄色 = すでに持っている表現 / 紫 = これから覚える表現。
   本文の青系（--accent / --helix-cyan）とも衝突しない色を選んでいる。 */
mark.discovery-mark {
    background: linear-gradient(180deg, transparent 35%, rgba(169,124,248,0.42) 35%, rgba(169,124,248,0.42) 92%, transparent 92%);
    color: var(--text);
    padding: 1px 2px;
    border-radius: 2px;
}

.discovery-note {
    display: flex;
    width: fit-content;
    max-width: 100%;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: rgba(169,124,248,0.06);
    border: 1px solid rgba(169,124,248,0.22);
    border-radius: 6px;
    padding: 4px 10px;
    margin-bottom: 12px;
}
.discovery-note i { color: #C4A2FA; }
.discovery-note .discovery-note-sample {
    background: linear-gradient(180deg, transparent 35%, rgba(169,124,248,0.42) 35%, rgba(169,124,248,0.42) 92%, transparent 92%);
    padding: 0 4px;
    border-radius: 2px;
    color: var(--text);
}

/* Discovery badge — matches discovery-mark for visual coupling */
.badge.discovery-badge {
    background: linear-gradient(135deg, #A97CF8, #7B4FE0) !important;
    color: #FFFFFF !important;
    font-weight: 600;
    border: 1px solid rgba(169,124,248,0.6);
}
.badge.discovery-badge:hover {
    filter: brightness(1.1);
}
.discovery-label { color: #C4A2FA; }

/* Core Image section */
.core-image-section {
    background: linear-gradient(135deg, rgba(43,107,242,0.08), rgba(169,124,248,0.08));
    border: 1px solid rgba(43,107,242,0.2);
    border-radius: 10px;
    padding: 16px;
}
.core-image-section h6 {
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 8px;
}
.core-image-text {
    font-size: 1.05rem;
    line-height: 1.7;
}

/* Syllable stress display (word / phrasal_verb — 4 levels: 0-3) */
.syllable-group {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
}
.syl-3 { color: #2B6BF2; font-weight: 700; font-size: 1.4rem; }
.syl-2 { color: #34D399; font-weight: 600; font-size: 1.15rem; }
.syl-1 { color: rgba(255,255,255,0.55); font-weight: 500; font-size: 1.05rem; }
.syl-0 { color: rgba(255,255,255,0.35); font-weight: 400; font-size: 0.95rem; }
.syl-dot {
    color: rgba(255,255,255,0.2);
    margin: 0 2px;
    font-weight: 300;
}
/* Sentence-level stress display (sentence_structure / idiom — 5 levels: 0-4) */
.stress-sentence {
    font-size: 1.15rem;
    line-height: 1.8;
    letter-spacing: 0.3px;
}
.sw-4 { color: #FF6B35; font-weight: 800; font-size: 1.45rem; }
.sw-3 { color: #2B6BF2; font-weight: 700; font-size: 1.25rem; }
.sw-2 { color: #34D399; font-weight: 600; font-size: 1.1rem; }
.sw-1 { color: rgba(255,255,255,0.55); font-weight: 400; font-size: 0.95rem; }
.sw-0 { color: rgba(255,255,255,0.30); font-weight: 300; font-size: 0.8rem; }
.sw-placeholder {
    color: rgba(255,255,255,0.25);
    font-style: italic;
    font-size: 0.9rem;
}

/* CEFR badges */
.badge-cefr {
    font-weight: 700;
    letter-spacing: 1px;
    padding: 4px 12px;
}
.badge-cefr-a1 { background: #0ABFB0; color: #000; }
.badge-cefr-a2 { background: #0ABFB0; color: #fff; }
.badge-cefr-b1 { background: #2B6BF2; color: #fff; }
.badge-cefr-b2 { background: #6c7ae0; color: #fff; }
.badge-cefr-c1 { background: #A78BFA; color: #fff; }
.badge-cefr-c2 { background: #e056a0; color: #fff; }

/* Related words - bigger display */
.related-words-section {
    padding: 12px;
}
.related-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}
.related-word-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 8px;
    transition: border-color 0.2s;
}
.related-word-card:hover {
    border-color: var(--accent);
}
.synonym-card {
    border-left: 3px solid #2B6BF2;
}
.antonym-card {
    border-left: 3px solid #FF6B5A;
}
.collocation-card {
    border-left: 3px solid #0ABFB0;
}
.chunk-card {
    border-left: 3px solid #B07AF5;
}
.related-word-text {
    font-size: 1.1rem;
    font-weight: 600;
    display: block;
    color: var(--text);
}
.related-word-nuance {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: block;
    margin-top: 4px;
    line-height: 1.5;
}
.related-word-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: transform 0.2s;
}
.related-word-badge:hover {
    transform: scale(1.05);
}
.antonym-badge {
    background: rgba(244,132,95,0.15);
    color: #FF6B5A;
    border: 1px solid rgba(244,132,95,0.3);
}
.collocation-badge {
    background: rgba(34,201,151,0.15);
    color: #0ABFB0;
    border: 1px solid rgba(34,201,151,0.3);
}

/* Synonym item in form */
.synonym-item {
    margin-bottom: 4px;
}
.synonym-item .syn-nuance {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* =====================================================
   Review Setup — Redesigned
   ===================================================== */
.review-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 24px;
}
.review-type-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--surface2);
    color: var(--text-muted);
    white-space: nowrap;
}
.review-type-pill strong { color: #fff; }
.pill-meaning { border-left: 3px solid var(--accent); }
.pill-pronunciation { border-left: 3px solid #ffc107; }
.pill-production { border-left: 3px solid #198754; }
.pill-dictation { border-left: 3px solid #0dcaf0; }

.review-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--surface2);
    gap: 2px;
}
.review-bar-meaning { background: var(--accent); border-radius: 4px; transition: flex 0.6s; }
.review-bar-pronunciation { background: #ffc107; border-radius: 4px; transition: flex 0.6s; }
.review-bar-production { background: #198754; border-radius: 4px; transition: flex 0.6s; }
.review-bar-dictation { background: #0dcaf0; border-radius: 4px; transition: flex 0.6s; }

.review-action-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    height: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* change0519 fix5: ソース選択トグルボタン */
.review-src-toggle { margin: 0; cursor: pointer; user-select: none; }
.review-src-toggle input { display: none; }
.review-src-toggle-label {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.55);
    border: 1px solid rgba(255,255,255,0.12);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.review-src-toggle:hover .review-src-toggle-label {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
}
.review-src-toggle input:checked + .review-src-toggle-label {
    background: rgba(91,156,245,0.22);
    color: #5B9CF5;
    border-color: rgba(91,156,245,0.55);
    font-weight: 600;
}
.review-action-card:hover {
    border-color: rgba(255,255,255,0.15);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.review-action-auto { border-top: 3px solid var(--accent); }
.review-action-production { border-top: 3px solid #198754; }
.review-action-dictation { border-top: 3px solid #00D4FF; }

/* === Review mode CTA buttons: same lift/shadow treatment as 練習 === */
.review-action-card .btn-primary,
.review-action-card .btn-success {
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 10px 16px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.25);
    transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.review-action-card .btn-primary {
    background: linear-gradient(135deg, #4da3ff 0%, #1f7be0 100%);
    box-shadow:
        0 4px 12px rgba(31, 123, 224, 0.35),
        0 1px 0 rgba(255,255,255,0.18) inset,
        0 -2px 0 rgba(0,0,0,0.18) inset;
}
.review-action-card .btn-primary:hover,
.review-action-card .btn-primary:focus {
    background: linear-gradient(135deg, #66b3ff 0%, #2e8bef 100%);
    box-shadow:
        0 6px 18px rgba(31, 123, 224, 0.5),
        0 1px 0 rgba(255,255,255,0.22) inset,
        0 -2px 0 rgba(0,0,0,0.2) inset;
    transform: translateY(-1px);
}
.review-action-card .btn-success {
    background: linear-gradient(135deg, #28a765 0%, #148045 100%);
    box-shadow:
        0 4px 12px rgba(20, 128, 69, 0.35),
        0 1px 0 rgba(255,255,255,0.18) inset,
        0 -2px 0 rgba(0,0,0,0.18) inset;
}
.review-action-card .btn-success:hover,
.review-action-card .btn-success:focus {
    background: linear-gradient(135deg, #33c078 0%, #1a9753 100%);
    box-shadow:
        0 6px 18px rgba(20, 128, 69, 0.5),
        0 1px 0 rgba(255,255,255,0.22) inset,
        0 -2px 0 rgba(0,0,0,0.2) inset;
    transform: translateY(-1px);
}
.review-action-card .btn-primary:active,
.review-action-card .btn-success:active {
    transform: translateY(1px);
    filter: brightness(0.95);
    box-shadow:
        0 2px 6px rgba(0,0,0,0.35),
        0 1px 0 rgba(255,255,255,0.1) inset,
        0 -1px 0 rgba(0,0,0,0.15) inset;
}

/* === Smaller review type buttons: subtle lift === */
#btn-type-meaning,
#btn-type-pronunciation,
#btn-type-dictation {
    transition: transform 0.08s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
#btn-type-meaning:hover,
#btn-type-pronunciation:hover,
#btn-type-dictation:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}
#btn-type-meaning:active,
#btn-type-pronunciation:active,
#btn-type-dictation:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* === Review action cards: hover lift sync with buttons === */
.review-action-card {
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s ease;
}
.review-action-card:hover {
    transform: translateY(-2px);
}

.review-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
}

/* =====================================================
   Practice Mode — visually distinct from Review
   ===================================================== */
.practice-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}
.practice-divider::before,
.practice-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(176,122,245,0.35), transparent);
}
.practice-divider-label {
    font-size: 0.75rem;
    color: rgba(176,122,245,0.9);
    white-space: nowrap;
    letter-spacing: 0.05em;
}

.practice-hero {
    background:
        linear-gradient(135deg, rgba(176,122,245,0.08), rgba(176,122,245,0.02)),
        var(--surface);
    border: 1px dashed rgba(176,122,245,0.45);
    border-radius: 14px;
    padding: 14px 18px;
}
.practice-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(176,122,245,0.18);
    color: #d4b3ff;
    border: 1px solid rgba(176,122,245,0.45);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}

.practice-action-card {
    background:
        linear-gradient(180deg, rgba(176,122,245,0.04), transparent 60%),
        var(--surface);
    border: 1px dashed rgba(176,122,245,0.35);
    border-radius: 14px;
    padding: 20px;
    height: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.practice-action-card {
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s ease;
}
.practice-action-card:hover {
    border-color: rgba(176,122,245,0.65);
    box-shadow: 0 4px 20px rgba(176,122,245,0.15);
    transform: translateY(-2px);
}
.practice-type-btn {
    transition: transform 0.08s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.practice-type-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(176,122,245,0.25);
}
.practice-type-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 3px rgba(176,122,245,0.25);
}
.practice-action-auto { border-top: 3px solid #b07af5; }
.practice-action-types { border-top: 3px solid #6c757d; }
.practice-action-mistakes {
    border-top: 3px solid #f25c54;
    border-color: rgba(242,92,84,0.35);
    background:
        linear-gradient(180deg, rgba(242,92,84,0.05), transparent 70%),
        var(--surface);
}
.practice-action-mistakes:hover {
    border-color: rgba(242,92,84,0.6);
    box-shadow: 0 4px 20px rgba(242,92,84,0.15);
}

.btn-practice {
    background: linear-gradient(135deg, #b07af5 0%, #8b5fd9 100%);
    color: #fff !important;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 10px 16px;
    box-shadow:
        0 4px 12px rgba(139, 95, 217, 0.35),
        0 1px 0 rgba(255,255,255,0.15) inset,
        0 -2px 0 rgba(0,0,0,0.18) inset;
    text-shadow: 0 1px 2px rgba(0,0,0,0.25);
    transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-practice:hover,
.btn-practice:focus {
    background: linear-gradient(135deg, #be8dff 0%, #9670e3 100%);
    color: #fff !important;
    box-shadow:
        0 6px 18px rgba(139, 95, 217, 0.5),
        0 1px 0 rgba(255,255,255,0.2) inset,
        0 -2px 0 rgba(0,0,0,0.2) inset;
    transform: translateY(-1px);
}
.btn-practice:active {
    transform: translateY(1px);
    box-shadow:
        0 2px 6px rgba(139, 95, 217, 0.35),
        0 1px 0 rgba(255,255,255,0.1) inset,
        0 -1px 0 rgba(0,0,0,0.15) inset;
}
.practice-type-btn {
    font-size: 0.78rem;
    padding: 5px 8px;
}

.mode-compare-table {
    color: var(--text);
    margin: 0;
    font-size: 0.8rem;
}
.mode-compare-table th,
.mode-compare-table td {
    border-color: var(--border);
    padding: 8px 12px;
    vertical-align: middle;
}
.mode-compare-table thead th {
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}
.mode-compare-table tbody tr:nth-child(even) td {
    background: rgba(255,255,255,0.015);
}

.review-howto-details summary {
    list-style: none;
    padding: 6px 0;
}
.review-howto-details summary::-webkit-details-marker { display: none; }
.review-howto-details[open] summary i.bi-info-circle::before {
    content: "\F62B"; /* chevron-up */
}

@media (max-width: 576px) {
    .review-hero { padding: 16px; }
    #due-type-pills { flex-direction: column; gap: 4px !important; }
    .review-type-pill { font-size: 0.7rem; padding: 3px 8px; }
}

/* =====================================================
   Review Stepper — Setup Screen (legacy)
   ===================================================== */
.review-stepper {
    padding: 16px 0;
}
.stepper-track {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}
.stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.stepper-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface2);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: all 0.3s;
}
.stepper-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}
.stepper-connector {
    width: 48px;
    height: 2px;
    background: var(--border);
    margin: 0 4px;
    margin-bottom: 28px;
}

/* =====================================================
   Review Stepper — Session (in-progress)
   ===================================================== */
.review-stepper-session {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
}
.stepper-track-session {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
}
.stepper-step-session {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 100px;
    flex: 1;
    max-width: 180px;
}
.stepper-circle-session {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.3s;
}
.stepper-circle-session.stage-locked {
    background: var(--surface2);
    border: 2px solid var(--border);
    color: var(--text-muted);
}
.stepper-circle-session.stage-active {
    background: var(--accent);
    border: 2px solid var(--accent);
    color: #fff;
    box-shadow: 0 0 12px rgba(43, 107, 242, 0.4);
    animation: stage-pulse 2s infinite;
}
.stepper-circle-session.stage-complete {
    background: #0ABFB0;
    border: 2px solid #0ABFB0;
    color: #fff;
}
.stepper-label-session {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}
.stepper-progress-session {
    width: 100%;
    text-align: center;
}
.stepper-progress-session .progress {
    background: var(--surface2);
    border-radius: 3px;
}
.stepper-connector-session {
    width: 40px;
    height: 2px;
    background: var(--border);
    margin-top: 17px;
    flex-shrink: 0;
    transition: background 0.3s;
}
.stepper-connector-session.connector-active {
    background: #0ABFB0;
}

@keyframes stage-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(43, 107, 242, 0.4); }
    50% { box-shadow: 0 0 20px rgba(43, 107, 242, 0.6); }
}

/* Responsive stepper */
@media (max-width: 576px) {
    .stepper-step-session {
        min-width: 70px;
    }
    .stepper-label-session {
        font-size: 0.65rem;
    }
    .stepper-circle-session {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    .stepper-connector-session {
        width: 20px;
    }
    .stepper-circle {
        width: 40px;
        height: 40px;
    }
    .stepper-connector {
        width: 24px;
    }
}

/* API cost display badge */
.api-cost-badge {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 16px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text);
}
.api-cost-badge i.bi-coin {
    color: #FFB347;
}

/* Cheat Book */
.cheatbook-card {
    border: 1px solid var(--border);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.cheatbook-card:hover {
    border-color: rgba(43, 107, 242, 0.4);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}
.cheatbook-examples {
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}
.badge.bg-purple {
    background-color: #7c4dff !important;
}

/* Cross-item credit */
.cross-item-credit {
    background: rgba(34, 201, 151, 0.08);
    border: 1px solid rgba(34, 201, 151, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
}

/* === Sound Change Category Colors (5-family palette) === */
:root {
    /* Family base colors */
    --sc-family-linking: #5B9CF5;
    --sc-family-linking-light: #7BBAF5;
    --sc-family-reduction: #E8A84C;
    --sc-family-modification: #B07AF5;
    --sc-family-flapping: #4CC9B0;
    --sc-family-allophonic: #A89B8C;

    /* Per-category mapping */
    --sc-cv_linking: var(--sc-family-linking);
    --sc-cc_linking: var(--sc-family-linking);
    --sc-vv_r: var(--sc-family-linking-light);
    --sc-vv_w: var(--sc-family-linking-light);
    --sc-vv_y: var(--sc-family-linking-light);
    --sc-flapping: var(--sc-family-flapping);
    --sc-assimilation: var(--sc-family-modification);
    --sc-affrication: var(--sc-family-modification);
    --sc-elision: var(--sc-family-reduction);
    --sc-dark_l: var(--sc-family-allophonic);
    --sc-unreleased_stop: var(--sc-family-allophonic);
    --sc-weak: var(--sc-family-reduction);
}

/* === Interlinear Display === */
/* === Zone-based Interlinear Layout === */
.il-wrap { background: rgba(0,0,0,0.15); border-radius: 10px; padding: 0.8rem; }
.il-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 12px; }
.il-unit { display: flex; flex-direction: column; align-items: center; min-width: 24px; cursor: default; border-radius: 6px; transition: transform 0.15s, filter 0.15s, background 0.2s, box-shadow 0.2s, opacity 0.2s; }

/* Zone A: Beat bar — fixed height */
.il-zone-beat { height: 34px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.beat { width: 100%; border-radius: 3px; }
.beat-4 { height: 26px; background: linear-gradient(180deg, #FF6B35, rgba(255,107,53,0.4)); box-shadow: 0 0 6px rgba(255,107,53,0.25); }
.beat-3 { height: 18px; background: linear-gradient(180deg, #2B6BF2, rgba(43,107,242,0.4)); box-shadow: 0 0 4px rgba(43,107,242,0.2); }
.beat-2 { height: 11px; background: linear-gradient(180deg, #34D399, rgba(52,211,153,0.35)); }
.beat-1 { height: 5px; background: rgba(255,255,255,0.12); }
.beat-0 { height: 3px; background: rgba(255,255,255,0.06); }

/* Zone B: Main content */
.il-zone-main { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 2px 0; }
.il-dot { font-size: 0.5rem; color: rgba(255,255,255,0.45); line-height: 1; }
.il-text { font-size: 0.95rem; padding: 1px 0; line-height: 1.2; }
.t-4 { font-weight: 800; color: #FF6B35; font-size: 1.12em; }
.t-3 { font-weight: 700; color: #2B6BF2; font-size: 1.02em; }
.t-2 { font-weight: 600; color: #34D399; }
.t-1 { color: rgba(255,255,255,0.55); font-size: 0.88em; }
.t-0 { color: rgba(255,255,255,0.35); font-size: 0.8em; }
.il-ipa { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: rgba(255,255,255,0.45); line-height: 1; }
.il-resp { font-family: 'Outfit', sans-serif; font-size: 0.72rem; font-weight: 500; color: rgba(255,255,255,0.55); line-height: 1; }

/* Zone C: Annotations — fixed min-height */
.il-zone-anno { min-height: 2.6em; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px; padding-top: 2px; }
.diff-from { font-family: 'JetBrains Mono', monospace; font-size: 0.58rem; color: rgba(255,255,255,0.22); text-decoration: line-through; line-height: 1; }
.il-cat {
    font-size: 0.56rem; font-weight: 700; padding: 0.12rem 0.35rem; border-radius: 4px;
    cursor: pointer; display: inline-flex; align-items: center; gap: 3px;
    border: none; font-family: inherit; white-space: nowrap; line-height: 1;
    position: relative; transition: background 0.2s;
}
.il-cat::after { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); min-width: 44px; min-height: 44px; }
.il-cat:hover, .il-cat:active { filter: brightness(1.3); }
.il-cat .info { font-size: 0.5rem; opacity: 0.5; }
/* Stage 2 simple label (hidden by default, shown via Stage 2 CSS) */
.il-cat-simple { font-size: 0.56rem; font-weight: 600; padding: 0.1rem 0.3rem; border-radius: 4px; line-height: 1; display: none; }

/* === Color underlines (5 families, pattern-differentiated) === */
/* Linking (Blue) */
.ul-cv   { border-bottom: 3px solid var(--sc-cv_linking); }
.ul-cc   { border-bottom: 3px dashed var(--sc-cc_linking); }
.ul-vv-r { border-bottom: 3px solid var(--sc-vv_r); }
.ul-vv-w { border-bottom: 3px dotted var(--sc-vv_w); }
.ul-vv-y { border-bottom: 3px solid var(--sc-vv_y); }
/* Reduction (Amber) */
.ul-weak    { border-bottom: 3px solid var(--sc-weak); }
.ul-elision { border-bottom: 3px dashed var(--sc-elision); }
/* Modification (Purple) */
.ul-assim  { border-bottom: 3px solid var(--sc-assimilation); }
.ul-affric { border-bottom: 3px dashed var(--sc-affrication); }
/* AmE (Teal / Warm Grey) */
.ul-flap   { border-bottom: 3px solid var(--sc-flapping); }
.ul-darkl  { border-bottom: 3px solid var(--sc-dark_l); }
.ul-unrel  { border-bottom: 3px dashed var(--sc-unreleased_stop); }

/* === Interactive word units === */
.il-unit[data-has-change] { cursor: pointer; }
.il-unit[data-has-change]:hover,
.il-unit[data-has-change].sc-active { transform: translateY(-2px); filter: brightness(1.2); }
.il-unit.sc-highlight { background: rgba(43,107,242,0.12); box-shadow: 0 0 0 2px rgba(43,107,242,0.3); }

/* Focus dimming: non-highlighted words fade */
.pronunciation-block.sc-focus-active .il-unit:not(.sc-highlight) { opacity: 0.35; }
.pronunciation-block.sc-focus-active .il-unit.sc-highlight { opacity: 1; }

/* === Linking Group (CSS-only, no wrapper div) === */
.il-grp {
    background: rgba(43, 107, 242, 0.04);
    border-top: 1px solid rgba(43, 107, 242, 0.12);
    border-bottom: 1px solid rgba(43, 107, 242, 0.12);
    margin-left: 0; margin-right: 0;
}
.il-grp-start { border-left: 1px solid rgba(43, 107, 242, 0.12); border-radius: 8px 0 0 8px; padding-left: 6px; }
.il-grp-end   { border-right: 1px solid rgba(43, 107, 242, 0.12); border-radius: 0 8px 8px 0; padding-right: 6px; }
/* Single pair: start+end on same unit doesn't happen, but mid has no radius */
.il-grp-mid   { border-radius: 0; }
/* Category-specific tints */
.il-grp-cv_linking { border-color: rgba(91, 156, 245, 0.18); background: rgba(91, 156, 245, 0.04); }
.il-grp-cc_linking { border-color: rgba(91, 156, 245, 0.18); background: rgba(91, 156, 245, 0.04); }
.il-grp-vv_r, .il-grp-vv_w, .il-grp-vv_y { border-color: rgba(123, 186, 245, 0.18); background: rgba(123, 186, 245, 0.04); }
/* Close flex gap between grouped units */
.il-grp + .il-grp { margin-left: -12px; }
@media (max-width: 576px) { .il-grp + .il-grp { margin-left: -8px; } }

/* === Syllable Row (Section 5) === */
.syl-row { display:flex; align-items:center; justify-content:center; gap:3px; flex-wrap:wrap; margin-top:0.7rem; padding:0.5rem 0.7rem; background:rgba(0,212,255,0.03); border:1px solid rgba(0,212,255,0.08); border-radius:8px; }
.syl-label { font-size:0.65rem; color:var(--text-muted); font-weight:600; margin-right:4px; }
.syl-block { position:relative; font-family:'JetBrains Mono',monospace; font-size:0.72rem; padding:0.2rem 0.4rem; border-radius:4px; }
.syl-block.normal { background:rgba(255,255,255,0.04); color:rgba(255,255,255,0.5); }
.syl-block.cross { background:rgba(91,156,245,0.1); border:1px solid rgba(91,156,245,0.25); color:#5B9CF5; }
.syl-src { position:absolute; bottom:-0.8rem; left:50%; transform:translateX(-50%); font-size:0.42rem; color:var(--text-muted); white-space:nowrap; }
.syl-dot { font-size:0.45rem; color:rgba(255,255,255,0.2); }

/* === Syllable View (Section 6) === */
.sv-row { display:flex; flex-wrap:wrap; align-items:flex-start; gap:4px 12px; }
.sv-unit { display:flex; flex-direction:column; align-items:center; min-width:28px; border-radius:6px; padding:2px 4px; }
.sv-unit.cross { background:rgba(91,156,245,0.06); border:1px solid rgba(91,156,245,0.15); }
.sv-text { font-family:'JetBrains Mono',monospace; font-size:0.82rem; padding:2px 0; line-height:1.2; }
.sv-src { font-size:0.5rem; color:var(--text-muted); }
.sv-cross-label { font-size:0.48rem; font-weight:600; color:#5B9CF5; background:rgba(91,156,245,0.12); padding:0.05rem 0.2rem; border-radius:3px; margin-top:2px; }

/* === Comparison Diagram (Section 7) === */
.il-compare { display:flex; gap:1.2rem; margin-top:0.8rem; padding:0.6rem 0.8rem; background:rgba(255,255,255,0.02); border:1px solid var(--border); border-radius:8px; }
.compare-side { flex:1; }
.compare-label { font-size:0.62rem; font-weight:600; color:var(--text-muted); margin-bottom:4px; }
.compare-blocks { display:flex; flex-wrap:wrap; gap:3px; margin-bottom:4px; }
.cb { font-size:0.62rem; padding:0.15rem 0.35rem; border-radius:3px; font-family:'JetBrains Mono',monospace; }
.cb-n { background:rgba(255,255,255,0.04); color:rgba(255,255,255,0.5); }
.cb-l { background:rgba(91,156,245,0.1); color:#5B9CF5; border:1px solid rgba(91,156,245,0.2); }
.compare-count { font-size:0.58rem; color:var(--text-muted); }
@media (max-width: 576px) { .il-compare { flex-direction:column; gap:0.6rem; } }

/* === Sound Change Pills === */
.sc-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.sc-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 20px;
    border: 1px solid transparent; background: var(--surface2); color: var(--text);
    font-size: 0.8rem; font-family: 'JetBrains Mono', monospace;
    cursor: pointer; transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.sc-pill:hover, .sc-pill.sc-highlight { transform: scale(1.05); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.sc-pill-cv_linking   { border-color: var(--sc-cv_linking); }
.sc-pill-flapping     { border-color: var(--sc-flapping); }
.sc-pill-cc_linking   { border-color: var(--sc-cc_linking); }
.sc-pill-vv_r         { border-color: var(--sc-vv_r); }
.sc-pill-vv_w         { border-color: var(--sc-vv_w); }
.sc-pill-vv_y         { border-color: var(--sc-vv_y); }
.sc-pill-assimilation { border-color: var(--sc-assimilation); }
.sc-pill-elision      { border-color: var(--sc-elision); }
.sc-pill-dark_l       { border-color: var(--sc-dark_l); }
.sc-pill-affrication  { border-color: var(--sc-affrication); }
.sc-pill-unreleased_stop { border-color: var(--sc-unreleased_stop); }
.sc-pill-weak         { border-color: var(--sc-weak); }
.sc-pill-linking      { border-color: var(--sc-cv_linking); }
/* Stage-linked pill display: only show the variant matching the current stage */
.pill-s1, .pill-s2, .pill-s3 { display: none; }
.pill-s3 { display: inline; }  /* Stage 3 (IPA) is default */
.pronunciation-stage-1 .pill-s1 { display: inline; }
.pronunciation-stage-1 .pill-s2, .pronunciation-stage-1 .pill-s3 { display: none; }
.pronunciation-stage-2 .pill-s2 { display: inline; }
.pronunciation-stage-2 .pill-s1, .pronunciation-stage-2 .pill-s3 { display: none; }

/* === Sound Change Popover === */
.popover { --bs-popover-bg: var(--surface); --bs-popover-border-color: var(--border); --bs-popover-body-color: var(--text); max-width: 320px; }
.sc-pop { text-align: center; padding: 4px 0; }
.sc-pop-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 8px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.sc-cat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sc-pop-before, .sc-pop-after { font-family: 'JetBrains Mono', monospace; font-size: 1.1rem; padding: 4px 0; }
.sc-pop-before { color: var(--text-muted); text-decoration: line-through; text-decoration-color: rgba(255,255,255,0.3); }
.sc-pop-after { color: var(--accent); font-weight: 600; }
.sc-pop-tag { display: block; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 2px; }
.sc-pop-arrow { font-size: 1.2rem; color: var(--text-muted); margin: 2px 0; }
.sc-pop-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; line-height: 1.4; }

/* === Inline Controls (Stage / Notation selects) === */
.il-controls { display: flex; gap: 1rem; margin-bottom: 0.8rem; font-size: 0.75rem; }
.il-control-group { display: flex; align-items: center; gap: 0.4rem; }
.il-control-group label { color: var(--text-muted); font-weight: 600; margin-bottom: 0; }
.il-control-group select { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 0.3rem 0.5rem; font-size: 0.75rem; }

/* === Stage-based Progressive Disclosure === */
/* Stage 1: minimal — hide beats, dots, IPA, resp, underlines, annotations, groups */
.pronunciation-stage-1 .il-zone-beat { height: 0; min-height: 0; overflow: hidden; }
.pronunciation-stage-1 .il-dot { display: none; }
.pronunciation-stage-1 .il-ipa { display: none !important; }
.pronunciation-stage-1 .il-resp { display: none !important; }
.pronunciation-stage-1 [class*="ul-"] { border-bottom: none !important; }
.pronunciation-stage-1 .il-zone-anno { min-height: 0; display: none; }
.pronunciation-stage-1 .il-grp { background: none; border: none; padding: 0; }
.pronunciation-stage-1 .syl-row { display: none; }
.pronunciation-stage-1 .il-syl-view { display: none !important; }
.pronunciation-stage-1 .il-compare { display: none; }
.pronunciation-stage-1 .il-view-toggle { display: none; }
.pronunciation-stage-1 .il-control-group:nth-child(2),
.pronunciation-stage-1 .il-control-group:nth-child(3) { display: none; }
/* Stage 1: 2-level stress (bold vs normal) */
.pronunciation-stage-1 .t-4,
.pronunciation-stage-1 .t-3 { font-weight: 700 !important; font-size: 1.02em !important; color: var(--text) !important; }
.pronunciation-stage-1 .t-2,
.pronunciation-stage-1 .t-1,
.pronunciation-stage-1 .t-0 { font-weight: 400 !important; font-size: 0.88em !important; opacity: 0.65 !important; }

/* Stage 2: intermediate */
.pronunciation-stage-2 .il-zone-beat { height: 0; min-height: 0; overflow: hidden; }
.pronunciation-stage-2 .il-dot { display: none; }
.pronunciation-stage-2 .il-ipa { display: none !important; }
.pronunciation-stage-2 .il-resp { display: block; }
.pronunciation-stage-2 .diff-from { display: none; }
.pronunciation-stage-2 .il-cat { display: none; }
.pronunciation-stage-2 .il-cat-simple { display: inline-block; }
.pronunciation-stage-2 .il-zone-anno { min-height: 1.4em; }
.pronunciation-stage-2 .syl-row { display: none; }
.pronunciation-stage-2 .il-syl-view { display: none !important; }
.pronunciation-stage-2 .il-compare { display: none; }
.pronunciation-stage-2 .il-view-toggle { display: none; }
.pronunciation-stage-2 .il-control-group:nth-child(3) { display: none; }
/* Stage 2: 3-level stress */
.pronunciation-stage-2 .t-4 { font-weight: 700 !important; font-size: 1.05em !important; color: #fff !important; }
.pronunciation-stage-2 .t-3,
.pronunciation-stage-2 .t-2 { font-weight: 500 !important; font-size: 0.95em !important; }
.pronunciation-stage-2 .t-1,
.pronunciation-stage-2 .t-0 { font-weight: 400 !important; font-size: 0.85em !important; opacity: 0.55 !important; }

/* Stage 3: full display — everything visible (default, no overrides needed) */

/* === Notation Toggle === */
.pn-hide .il-ipa, .pn-hide .il-resp { display: none !important; }
.pn-respelling .il-ipa { display: none !important; }
.pn-respelling .il-resp { display: block; }
.pn-ipa .il-resp { display: none !important; }
.pn-ipa .il-ipa { display: block; }
.pn-both .il-ipa, .pn-both .il-resp { display: block; }

/* === Pill audio pulse animation === */
@keyframes sc-pill-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(43,107,242,0.4); }
    50% { box-shadow: 0 0 0 6px rgba(43,107,242,0); }
}
.sc-pill.sc-playing { animation: sc-pill-pulse 1s ease-in-out infinite; }
.sc-pill-play { font-size: 0.75em; opacity: 0.5; margin-left: 2px; }

/* === Pattern Explanation Drawer === */
.pattern-drawer-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1050;
    opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.pattern-drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.pattern-drawer {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1051;
    background: #111D35; border-top: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px 16px 0 0; padding: 0 20px 24px;
    max-height: 70vh; overflow-y: auto;
    transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.pattern-drawer-backdrop.open .pattern-drawer { transform: translateY(0); }

.pattern-drawer-handle {
    display: flex; justify-content: center; padding: 12px 0 8px;
    position: sticky; top: 0; background: #111D35; z-index: 1;
}
.pattern-drawer-handle::before {
    content: ''; width: 36px; height: 4px; border-radius: 2px;
    background: rgba(255,255,255,0.2);
}

.pd-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.pd-cat-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.pd-title { font-size: 1.1rem; font-weight: 700; }
.pd-subtitle { font-size: 0.82rem; color: rgba(255,255,255,0.5); margin-bottom: 16px; }

.pd-section { margin-bottom: 16px; }
.pd-section-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: rgba(255,255,255,0.35); margin-bottom: 6px; }
.pd-rule { font-family: 'JetBrains Mono', monospace; font-size: 1rem; font-weight: 600; padding: 10px 14px; background: rgba(255,255,255,0.04); border-radius: 8px; }
.pd-examples { list-style: none; padding: 0; margin: 0; }
.pd-examples li {
    font-family: 'JetBrains Mono', monospace; font-size: 0.88rem;
    padding: 8px 14px; border-radius: 8px; margin-bottom: 4px;
    background: rgba(255,255,255,0.03); display: flex; align-items: center; gap: 8px;
}
.pd-ex-word { font-weight: 600; color: #fff; }
.pd-ex-arrow { color: rgba(255,255,255,0.25); font-size: 0.8em; }
.pd-ex-ipa { color: var(--accent, #2B6BF2); }
.pd-tip { font-size: 0.82rem; color: rgba(255,255,255,0.55); line-height: 1.5; padding: 10px 14px; background: rgba(43,107,242,0.06); border-radius: 8px; border-left: 3px solid rgba(43,107,242,0.3); }
.pd-close { position: absolute; top: 12px; right: 16px; background: none; border: none; color: rgba(255,255,255,0.4); font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }
.pd-close:hover { color: #fff; }

/* === Mobile responsive === */
@media (max-width: 576px) {
    .il-row { gap: 4px 8px; }
    .sc-pill { font-size: 0.75rem; padding: 3px 8px; }
    .popover { max-width: 280px; }
    .pattern-drawer { max-height: 80vh; padding: 0 16px 20px; }
}

/* === Patterns Guide Page === */
.pg-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: border-color 0.2s;
}
.pg-card:hover {
    border-color: rgba(255,255,255,0.15);
}
.pg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.pg-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.pg-title {
    font-weight: 700;
    font-size: 1rem;
}
.pg-subtitle {
    color: var(--muted);
    font-size: 0.88rem;
    margin-bottom: 12px;
    line-height: 1.5;
}
.pg-section {
    margin-bottom: 10px;
}
.pg-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 4px;
}
.pg-rule {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--accent);
    background: rgba(43,107,242,0.08);
    border-radius: 6px;
    padding: 6px 10px;
}
.pg-examples {
    list-style: none;
    padding: 0;
    margin: 0;
}
.pg-examples li {
    padding: 3px 0;
    font-size: 0.88rem;
}
.pg-ex-word {
    font-weight: 600;
}
.pg-ex-arrow {
    color: var(--muted);
    margin: 0 2px;
}
.pg-ex-ipa {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    color: rgba(255,255,255,0.7);
}
.pg-tip {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.75);
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    padding: 8px 10px;
    line-height: 1.55;
}

/* === Onboarding Modal === */
.ob-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    animation: ob-fade-in 0.3s ease;
    padding: 1rem;
}
.ob-overlay.ob-hiding { animation: ob-fade-out 0.3s ease forwards; }
@keyframes ob-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ob-fade-out { from { opacity: 1; } to { opacity: 0; } }

.ob-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    max-width: 480px; width: 100%; padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: ob-slide-up 0.35s ease;
}
@keyframes ob-slide-up { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.ob-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.ob-step-indicator { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.ob-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 0; }
.ob-close:hover { color: var(--text); }

.ob-title { font-family: 'Outfit', sans-serif; font-size: 1.2rem; font-weight: 700; margin-bottom: 0.8rem; color: var(--text); }
.ob-body { font-size: 0.9rem; line-height: 1.65; color: rgba(255,255,255,0.8); margin-bottom: 1rem; }
.ob-body em { color: var(--accent); font-style: normal; font-weight: 600; }
.ob-body strong { color: var(--helix-cyan); }

.ob-example {
    background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 10px;
    padding: 0.8rem 1rem; margin-bottom: 1rem; text-align: center;
}
.ob-ex-row { display: flex; align-items: center; gap: 0.5rem; justify-content: center; }
.ob-ex-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); font-weight: 700; min-width: 40px; }
.ob-ex-text { font-family: 'JetBrains Mono', monospace; font-size: 1rem; }
.ob-ex-after { color: var(--helix-cyan); font-weight: 600; }
.ob-ex-arrow { color: var(--text-muted); font-size: 1rem; margin: 0.3rem 0; }

.ob-footer { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }

@media (max-width: 576px) {
    .ob-card { padding: 1.2rem; }
    .ob-title { font-size: 1.05rem; }
    .ob-body { font-size: 0.85rem; }
}

/* ── Mobile Touch Target & TWA Optimization ── */
@media (pointer: coarse) {
  .btn, button, a.nav-link, .il-cat, .sc-pill,
  .dropdown-item, .list-group-item-action {
    min-height: 48px;
    min-width: 48px;
  }
  select, input, textarea {
    font-size: 16px !important;
  }
  .il-unit {
    padding: 4px 2px;
  }
}

@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* ═══ Phoneme badges (pronunciation assessment) ═══ */
.ph-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.ph-good { background: rgba(34,201,151,0.2); color: #22c997; }
.ph-fair { background: rgba(255,193,7,0.2); color: #ffc107; }
.ph-poor { background: rgba(220,53,69,0.2); color: #dc3545; }

/* === Feature Crosslink Card (Compose ⇄ Liaison) === */
.feature-crosslink-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1.1rem;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.02);
    transition: all 0.2s ease;
}
.feature-crosslink-card.crosslink-to-liaison {
    border-left: 3px solid #5B9CF5;
    background: linear-gradient(90deg, rgba(91,156,245,0.06) 0%, rgba(255,255,255,0.02) 100%);
}
.feature-crosslink-card.crosslink-to-compose {
    border-left: 3px solid #4CC9B0;
    background: linear-gradient(90deg, rgba(76,201,176,0.06) 0%, rgba(255,255,255,0.02) 100%);
}
.feature-crosslink-card:hover { transform: translateY(-1px); border-color: rgba(0,212,255,0.3); }
.feature-crosslink-card .fc-icon {
    flex: 0 0 auto;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 9px;
    font-size: 1.15rem;
    background: rgba(255,255,255,0.05);
}
.crosslink-to-liaison .fc-icon { color: #5B9CF5; background: rgba(91,156,245,0.15); }
.crosslink-to-compose .fc-icon { color: #4CC9B0; background: rgba(76,201,176,0.15); }
.feature-crosslink-card .fc-body { flex: 1 1 auto; min-width: 0; }
.feature-crosslink-card .fc-title { font-size: 0.92rem; font-weight: 600; color: rgba(255,255,255,0.9); line-height: 1.35; }
.feature-crosslink-card .fc-title strong { color: var(--helix-cyan, #00D4FF); }
.feature-crosslink-card .fc-sub { font-size: 0.76rem; color: rgba(255,255,255,0.55); margin-top: 0.15rem; line-height: 1.4; }
.feature-crosslink-card .fc-cta {
    flex: 0 0 auto;
    padding: 7px 14px;
    border-radius: 8px;
    background: rgba(0,212,255,0.12);
    border: 1px solid rgba(0,212,255,0.3);
    color: var(--helix-cyan, #00D4FF);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.feature-crosslink-card .fc-cta:hover {
    background: rgba(0,212,255,0.2);
    border-color: rgba(0,212,255,0.5);
    color: #fff;
}
@media (max-width: 576px) {
    .feature-crosslink-card { flex-wrap: wrap; padding: 0.75rem 0.9rem; }
    .feature-crosslink-card .fc-cta { width: 100%; text-align: center; margin-top: 0.5rem; }
}

/* ==========================================================================
   Bottom Tab Bar (mobile only, <768px)
   ========================================================================== */
.bottom-tab-bar {
    display: none;
}
@media (max-width: 767.98px) {
    .bottom-tab-bar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1040;
        background: linear-gradient(180deg, rgba(11, 21, 40, 0.92) 0%, rgba(11, 21, 40, 0.98) 100%);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid rgba(43, 107, 242, 0.25);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
        /* always lift at least 8px off the very bottom edge so the corner tabs
           aren't pressed against the browser chrome / home indicator (where
           safe-area-inset is 0, e.g. mobile Safari) and become hard to tap */
        padding-bottom: max(env(safe-area-inset-bottom, 0px), 8px);
        /* inset the first/last tab away from the screen edges so the corner
           tabs (表現ポート / メニュー) aren't clipped by the iPhone's rounded
           display corners */
        padding-left: max(env(safe-area-inset-left, 0px), 14px);
        padding-right: max(env(safe-area-inset-right, 0px), 14px);
    }
    .bottom-tab {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 8px 2px 6px;
        color: #8899aa;
        text-decoration: none;
        font-size: 0.62rem;
        font-weight: 500;
        background: transparent;
        border: 0;
        cursor: pointer;
        transition: color 0.15s ease;
        min-height: 58px;
        -webkit-tap-highlight-color: transparent;
        text-align: center;
        line-height: 1.1;
    }
    .bottom-tab > span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .bottom-tab i {
        font-size: 1.35rem;
        line-height: 1;
    }
    /* 8 タブ（表現ポート/デッキ/アトリエ/ラボ/ジャーナル/チート/修練/メニュー）を
       端が見切れずラベルも省略されずに収めるため、画面幅ごとに段階的に縮める。
       1 タブあたりの実効幅 = (画面幅 - 左右インセット 28px) / 8 なので、
       ラベル最長 5 文字（表現ポート・ジャーナル）が収まる font-size を各段で選ぶ。
       min-height 58px は維持してタップ目標の高さを確保する。 */
    @media (max-width: 480px) {
        .bottom-tab { font-size: 0.58rem; padding: 8px 1px 6px; gap: 2px; }
        .bottom-tab i { font-size: 1.3rem; }
    }
    @media (max-width: 430px) {
        .bottom-tab { font-size: 0.52rem; }
        .bottom-tab i { font-size: 1.22rem; }
    }
    @media (max-width: 390px) {
        .bottom-tab { font-size: 0.48rem; }
        .bottom-tab i { font-size: 1.14rem; }
    }
    /* 320px (iPhone SE 第1世代) だけは最長ラベルが僅かに入らず「表現ポ…」になる。
       アイコンで判別できるため、文字をこれ以上小さくするより省略を許容する。 */
    @media (max-width: 340px) {
        .bottom-tab { font-size: 0.44rem; }
        .bottom-tab i { font-size: 1.05rem; }
    }
    .bottom-tab:active {
        color: var(--helix-cyan, #00D4FF);
    }
    .bottom-tab.active {
        color: var(--helix-cyan, #00D4FF);
    }
    .bottom-tab.active i {
        filter: drop-shadow(0 0 6px rgba(0, 212, 255, 0.4));
    }
    /* push page content above tab bar */
    main.main-with-bottom-tab {
        padding-bottom: calc(84px + env(safe-area-inset-bottom, 0)) !important;
    }
    /* queue status bar / toast: bump above bottom tab when visible */
    #queue-status-bar {
        bottom: calc(76px + env(safe-area-inset-bottom, 0)) !important;
    }
    #toast-container {
        bottom: calc(82px + env(safe-area-inset-bottom, 0)) !important;
    }
}

/* ==========================================================================
   Entry list header actions — 新規登録 only on mobile
   ライブラリ切替・更新・全再生成・表示切替が画面上部を占有して一覧が下へ
   押し出されるため、md 未満では主導線の「新規登録」だけを残す。
   隠す 4 つはいずれも既定値のままで困らない:
     ライブラリ切替 → 既定 マイライブラリ / 表示切替 → 既定 テーブル
     更新・全再生成 → 一覧の再取得と AI 再生成。PC 側でできれば足りる
   JS が click ハンドラを張っている要素なので DOM からは外さず CSS で隠す。
   ========================================================================== */
@media (max-width: 767.98px) {
    .entry-actions {
        flex-wrap: wrap;
        gap: 0.35rem !important;
    }
    .entry-actions > *:not(#btn-new-entry) {
        display: none;
    }
    /* 唯一残る主導線。横幅いっぱいに広げてタップしやすくする */
    .entry-actions #btn-new-entry {
        flex: 1 1 auto;
        min-width: 0;
        white-space: nowrap;
        text-align: center;
    }
}

/* ==========================================================================
   Entry list filters — collapsible on mobile
   The search/filter panel sits above the list, so on phones it is collapsed
   by default and opened via a slim header. Always expanded from md up.
   ========================================================================== */
.entry-filters-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.6rem 0.9rem;
    background: transparent;
    border: 0;
    color: var(--bs-body-color, #dee2e6);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: left;
}
.entry-filters-chevron {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}
.entry-filters-toggle:not(.collapsed) .entry-filters-chevron {
    transform: rotate(180deg);
}
@media (min-width: 768px) {
    /* no toggle on desktop — keep the panel permanently open */
    #entry-filters-body.collapse:not(.show) {
        display: block;
    }
}

/* ==========================================================================
   Word register — 例文から知らない語を登録するフローティングパネル
   例文のボタン直下に浮かせる。中身は static/js/word_register.js が組む。
   ========================================================================== */
.word-register-panel {
    position: absolute;
    z-index: 1080;              /* Bootstrap の modal(1055) より上、tooltip 未満 */
    width: min(320px, calc(100vw - 24px));
    border: 1px solid var(--border, rgba(255,255,255,.15));
    border-radius: 10px;
    background: var(--bs-body-bg, #1b1f24);
}
.word-register-panel .wr-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: .5rem .7rem;
    border-bottom: 1px solid var(--border, rgba(255,255,255,.12));
    font-size: .82rem; font-weight: 600;
}
.word-register-panel .wr-head .btn-close { font-size: .6rem; }
.word-register-panel .wr-body { padding: .6rem .7rem .7rem; }
.word-register-panel .wr-chips {
    display: flex; flex-wrap: wrap; gap: .35rem;
    max-height: 40vh; overflow-y: auto;
}
.word-register-panel .wr-chip {
    padding: .25rem .6rem;
    font-size: .82rem;
    border-radius: 999px;
    border: 1px solid var(--border, rgba(255,255,255,.2));
    background: transparent;
    color: var(--bs-body-color, #dee2e6);
    transition: background .12s, border-color .12s, color .12s;
}
.word-register-panel .wr-chip:hover { border-color: var(--helix-cyan, #00d4ff); }
.word-register-panel .wr-chip.on {
    background: rgba(232,168,76,.18);
    border-color: #E8A84C;
    color: #E8A84C;
    font-weight: 600;
}
/* 機能語（to / of / with …）。単体では登録候補にしないが、
   look forward to のような句を組むのに要るので選べる状態で薄く出す。 */
.word-register-panel .wr-chip--fn {
    font-size: .74rem;
    padding: .18rem .45rem;
    opacity: .5;
    border-style: dashed;
}
.word-register-panel .wr-chip--fn:hover { opacity: .85; }
.word-register-panel .wr-chip--fn.on { opacity: 1; border-style: solid; }

/* 2つ以上選んだときだけ出る「つなげて登録」。句動詞・イディオム用 */
.word-register-panel .wr-join {
    display: flex; align-items: center; gap: .4rem;
    margin-top: .55rem; font-size: .8rem;
    color: var(--bs-secondary-color, #9aa0a6); cursor: pointer;
}
.word-register-panel .wr-join strong { color: #E8A84C; }

/* ＋ボタンは普段は控えめにし、例文にホバーしたときだけ立たせる。
   タッチ端末には hover が無いので、@media (hover: hover) で囲って
   常時はっきり見えるようにしておく。 */
@media (hover: hover) {
    .ex-row .btn-word-register {
        opacity: .4;
        transition: opacity .15s;
    }
    .ex-row:hover .btn-word-register,
    .ex-row .btn-word-register:hover,
    .ex-row .btn-word-register:focus-visible {
        opacity: 1;
    }
}
