/* ========================================
   カラーパレット & デザイントークン
======================================== */
:root {
    --eval-s: #1abc9c;
    --eval-a: #2ecc71;
    --eval-b: #95c11f;
    --eval-c: #f1c232;
    --eval-d: #ed7d31;
    --eval-e: #e74c3c;
    --primary: #1e3a5f;
    --primary-light: #2c5282;
    --secondary: #4a5568;
    --accent: #4299e1;
    --card-bg: #ffffff;
    --question-bg: #f7fafc;
    --answer-bg: #ebf4ff;
    --border-color: #e2e8f0;
    --text-dark: #1a202c;
    --text-light: #2d3748;
    --bg-surface: #edf2f7;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 25px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --body-bg: linear-gradient(160deg, #dce8f5 0%, #c4d8ed 100%);
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --input-bg: #ffffff;
    --input-border: #d1d5db;
}

/* ========================================
   ダークモード
======================================== */
[data-theme="dark"] {
    --primary: #60a5fa;
    --primary-light: #93c5fd;
    --secondary: #9ca3af;
    --accent: #60a5fa;
    --card-bg: #1e293b;
    --question-bg: #1a2332;
    --answer-bg: #172033;
    --border-color: #334155;
    --text-dark: #e2e8f0;
    --text-light: #e2e8f0;
    --bg-surface: #0f172a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 25px rgba(0,0,0,0.5);
    --body-bg: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
    --modal-overlay: rgba(0, 0, 0, 0.7);
    --input-bg: #1e293b;
    --input-border: #475569;
    --eval-s: #4dd0e1;
    --eval-a: #66bb6a;
    --eval-b: #c5e1a5;
    --eval-c: #ffd54f;
    --eval-d: #ff9966;
    --eval-e: #ef5350;
}

[data-theme="dark"] {
    --text-light: #cbd5e0;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary: #60a5fa;
        --primary-light: #93c5fd;
        --secondary: #9ca3af;
        --accent: #60a5fa;
        --card-bg: #1e293b;
        --question-bg: #1a2332;
        --answer-bg: #172033;
        --border-color: #334155;
        --text-dark: #e2e8f0;
        --text-light: #cbd5e0;
        --bg-surface: #0f172a;
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
        --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
        --shadow-lg: 0 8px 25px rgba(0,0,0,0.5);
        --body-bg: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
        --modal-overlay: rgba(0, 0, 0, 0.7);
        --input-bg: #1e293b;
        --input-border: #475569;
        --eval-s: #4dd0e1;
        --eval-a: #66bb6a;
        --eval-b: #c5e1a5;
        --eval-c: #ffd54f;
        --eval-d: #ff9966;
        --eval-e: #ef5350;
    }
}

/* ========================================
   基本設定
======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Yu Gothic', 'Meiryo', sans-serif;
    background: var(--body-bg);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-left: calc(20px + env(safe-area-inset-left, 0px));
    padding-right: calc(20px + env(safe-area-inset-right, 0px));
    color: var(--text-dark);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease, color 0.3s ease;
}

input, select, textarea {
    background: var(--input-bg);
    color: var(--text-dark);
    border-color: var(--input-border);
    font-size: 16px; /* Prevent iOS auto-zoom */
    -webkit-font-smoothing: antialiased;
}

input::placeholder,
textarea::placeholder {
    color: rgba(45, 55, 72, 0.5);
    opacity: 1;
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder,
:root:not([data-theme="light"]) input::placeholder,
:root:not([data-theme="light"]) textarea::placeholder {
    color: rgba(226, 232, 240, 0.5);
}

code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: 0.88em;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.06);
    color: #c0392b;
}
[data-theme="dark"] code,
:root:not([data-theme="light"]) code {
    background: rgba(96, 165, 250, 0.18);
    color: #ffd54f;
}

button {
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.modal {
    background: var(--modal-overlay);
}

.modal-content {
    background: var(--card-bg);
    color: var(--text-dark);
}

.app-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    position: relative;
}

/* ========================================
   ヘッダー
======================================== */
.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 8px 16px;
    text-align: center;
    position: relative;
}

.app-header h1 {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
    gap: 4px;
}
.header-main {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.header-sub {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.7;
    letter-spacing: 0.04em;
}
@media (max-width: 480px) {
    .header-main { font-size: 1.2rem; }
    .header-sub { font-size: 0.7rem; }
}

/* ========================================
   タブナビゲーション
======================================== */
.tab-nav {
    display: flex;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-button {
    flex: 1;
    min-width: 0;
    padding: 14px 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
    transition: all var(--transition-normal);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

.tab-icon {
    font-size: 1.1rem;
    display: none;
}

.tab-button:hover {
    background: var(--bg-surface);
    color: var(--primary);
}

.tab-button.active {
    color: var(--primary);
    background: var(--card-bg);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
}

/* ========================================
   タブコンテンツ
======================================== */
.tab-content {
    display: none;
    padding: 24px;
    animation: fadeIn 0.25s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-content h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 8px;
    font-weight: 700;
}

/* ========================================
   ダッシュボード
======================================== */
.dashboard {
    margin-bottom: 20px;
}

.dashboard-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: stretch;
}

.dashboard-stat-card {
    flex: 1;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 12px 8px;
    text-align: center;
    transition: transform var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 96px;
}

.dashboard-stat-card:hover {
    transform: translateY(-1px);
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-number.completed { color: var(--eval-a); }
.stat-number.remaining { color: var(--eval-c); }

.stat-label {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* 進捗リング: 数字カードと同じ高さ感に揃える */
.progress-ring-container svg {
    width: 56px;
    height: 56px;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--bg-surface);
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--eval-a);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease;
}

.progress-ring-text {
    font-size: 0.85rem;
    font-weight: 700;
    fill: var(--primary);
}

/* 評価内訳バッジ */
.dashboard-eval-breakdown {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.eval-pill {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

.eval-pill.pill-e { background: var(--eval-e); }
.eval-pill.pill-d { background: var(--eval-d); }
.eval-pill.pill-c { background: var(--eval-c); }
.eval-pill.pill-b { background: var(--eval-b); }
.eval-pill.pill-a { background: var(--eval-a); }
.eval-pill.pill-s { background: var(--eval-s); }
.eval-pill.pill-unlearned { background: #95a5a6; }

.calendar-strip {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.strip-day {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    cursor: default;
    border: 2px solid transparent;
}

.strip-day.today {
    border-color: var(--accent);
    background: #ebf8ff;
    color: #1a202c;
}
.strip-day.today .strip-day-label,
.strip-day.today .strip-day-num,
.strip-day.today .strip-day-count {
    color: #1a202c;
}
[data-theme="dark"] .strip-day.today,
:root:not([data-theme="light"]) .strip-day.today {
    background: rgba(96, 165, 250, 0.20);
    color: var(--text-dark);
}
[data-theme="dark"] .strip-day.today .strip-day-label,
[data-theme="dark"] .strip-day.today .strip-day-num,
[data-theme="dark"] .strip-day.today .strip-day-count,
:root:not([data-theme="light"]) .strip-day.today .strip-day-label,
:root:not([data-theme="light"]) .strip-day.today .strip-day-num,
:root:not([data-theme="light"]) .strip-day.today .strip-day-count {
    color: var(--text-dark);
}

.strip-day-label {
    font-size: 0.65rem;
    color: var(--text-dark);
    font-weight: 600;
}

.strip-day-num {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
}

.strip-day-count {
    font-size: 0.65rem;
    font-weight: 700;
    margin-top: 2px;
    color: var(--text-dark);
}
.strip-day-count.load-none,
.strip-day-count.load-light,
.strip-day-count.load-heavy { color: var(--text-dark); }

/* プログレスバー */
.review-progress {
    position: relative;
    margin-bottom: 16px;
}

.review-progress-track {
    height: 6px;
    background: var(--bg-surface);
    border-radius: 3px;
    overflow: hidden;
}

.review-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--eval-a));
    border-radius: 3px;
    transition: width 0.5s ease;
    width: 0%;
}

.review-progress-text {
    position: absolute;
    right: 0;
    top: -20px;
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 600;
}

/* 科目チップ */
.subject-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.subject-chip {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 2px solid var(--primary);
    background: var(--primary);
    color: white;
}

.subject-chip.inactive {
    background: transparent;
    color: var(--text-light);
    border-color: var(--border-color);
    text-decoration: line-through;
    opacity: 0.6;
}

.subject-chip:hover {
    transform: scale(1.05);
}

/* 復習コントロール */
.review-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    align-items: center;
}

.review-controls .btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 0.8rem;
}

/* 設定パネル */
.settings-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 16px;
    margin-top: 4px;
    min-width: 200px;
}

.settings-group {
    margin-bottom: 12px;
}

.settings-group:last-child {
    margin-bottom: 0;
}

.settings-group label,
.settings-group .settings-group-heading {
    font-size: 0.8rem;
    font-weight: 700;
    display: block;
    margin-bottom: 6px;
    color: var(--text-dark);
}

.settings-group .btn-row {
    display: flex;
    gap: 6px;
}

.settings-group {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--border-color);
}
.settings-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.settings-group-desc {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
    font-size: 0.78rem;
    color: var(--text-light);
    line-height: 1.65;
}
.settings-group-desc li {
    padding-left: 14px;
    position: relative;
    margin-bottom: 2px;
}
.settings-group-desc li:last-child { margin-bottom: 0; }
.settings-group-desc li::before {
    content: '・';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 700;
}
.settings-group-desc b {
    color: var(--text-dark);
    font-weight: 700;
}

/* ========================================
   暗記カード
======================================== */
.card-display-area {
    position: relative;
    overflow: hidden;
    min-height: 200px;
}

.theory-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.theory-type-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    vertical-align: middle;
}
.theory-type-tof {
    background: rgba(108, 99, 255, 0.15);
    color: #6c63ff;
}
[data-theme="dark"] .theory-type-tof,
:root:not([data-theme="light"]) .theory-type-tof {
    background: rgba(147, 197, 253, 0.18);
    color: #93c5fd;
}

.tof-answer-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--answer-bg);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent);
}
.tof-answer-section h4 {
    margin: 8px 0 4px;
    font-size: 0.92rem;
    color: var(--primary);
}
.tof-answer-section p {
    margin: 4px 0 0;
    line-height: 1.7;
    color: var(--text-dark);
}
.tof-correct-label {
    margin-left: 6px;
    font-weight: 700;
}
.tof-result-badge {
    display: inline-block;
    margin-bottom: 10px;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1.05rem;
}
.tof-result-correct {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}
.tof-result-wrong {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}
[data-theme="dark"] .tof-result-correct,
:root:not([data-theme="light"]) .tof-result-correct {
    background: rgba(40, 167, 69, 0.25);
    color: #86efac;
}
[data-theme="dark"] .tof-result-wrong,
:root:not([data-theme="light"]) .tof-result-wrong {
    background: rgba(220, 53, 69, 0.25);
    color: #fca5a5;
}

.tof-answer-buttons {
    margin-top: 16px;
    display: flex;
    gap: 10px;
}
.tof-btn {
    padding: 14px 0;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    color: white;
}
.tof-btn-true {
    background: #2ecc71;
}
.tof-btn-true:hover:not(:disabled) {
    background: #27ae60;
    transform: translateY(-1px);
}
.tof-btn-false {
    background: #e74c3c;
}
.tof-btn-false:hover:not(:disabled) {
    background: #c0392b;
    transform: translateY(-1px);
}
.tof-btn-locked {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
}
.tof-btn-correct {
    opacity: 1 !important;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.45);
}
.tof-btn-wrong {
    opacity: 1 !important;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.45);
}

/* 複数文 TOF 表示 */
.tof-statements-section {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tof-statement-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    transition: all var(--transition-fast);
}
.tof-statement-text {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-dark);
    line-height: 1.5;
}
.tof-statement-buttons {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.tof-mini-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-dark);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}
.tof-mini-btn:hover:not(:disabled) {
    transform: scale(1.05);
}
.tof-mini-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}
.tof-mini-true.tof-mini-selected {
    background: #2ecc71;
    border-color: #27ae60;
    color: white;
}
.tof-mini-false.tof-mini-selected {
    background: #e74c3c;
    border-color: #c0392b;
    color: white;
}
.tof-statement-correct {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.10);
}
.tof-statement-wrong {
    border-color: #dc3545;
    background: rgba(220, 53, 69, 0.10);
}
.tof-submit-btn {
    width: 100%;
    margin-top: 14px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 700;
}
.tof-submit-locked {
    opacity: 0.55;
    cursor: not-allowed;
}

/* 登録 UI: TOF/Choice の行 */
.bulk-card-tof-statements,
.bulk-card-choice-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 4px 0 8px;
}
.bulk-card-tof-row,
.bulk-card-choice-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}
.bulk-card-tof-statement-text,
.bulk-card-choice-text {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--input-bg);
    color: var(--text-dark);
}
.bulk-card-tof-row label {
    font-size: 0.85rem;
    color: var(--text-dark);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}
.bulk-card-choice-correct {
    flex-shrink: 0;
    font-size: 0.78rem;
    color: var(--text-dark);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.bulk-card-row-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-light);
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
}
.bulk-card-row-remove:hover {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}
.bulk-card-add-row-btn {
    align-self: flex-start;
    margin-bottom: 8px;
}

/* 学習中／休止中 */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 6px;
}
.status-badge.status-studying {
    background: rgba(46, 204, 113, 0.18);
    color: #1e7e34;
}
.status-badge.status-paused {
    background: rgba(149, 165, 166, 0.18);
    color: #6c757d;
}
.structure-subject-row.paused {
    opacity: 0.7;
}

.theory-type-choice {
    background: rgba(46, 204, 113, 0.15);
    color: #2e7d32;
}
[data-theme="dark"] .theory-type-choice,
:root:not([data-theme="light"]) .theory-type-choice {
    background: rgba(102, 187, 106, 0.18);
    color: #a5d6a7;
}

.theory-type-fillblank {
    background: rgba(241, 194, 50, 0.18);
    color: #c08a00;
}
[data-theme="dark"] .theory-type-fillblank,
:root:not([data-theme="light"]) .theory-type-fillblank {
    background: rgba(255, 213, 79, 0.18);
    color: #ffd54f;
}

.ocr-hint-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.ocr-hint-row .btn {
    flex: 0 0 auto;
}
.ocr-hint-note {
    font-size: 0.78rem;
    color: var(--text-light);
    flex: 1;
    min-width: 200px;
    line-height: 1.5;
}

.ocr-progress {
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
}
.ocr-progress-label {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-dark);
}
.ocr-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--card-bg);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.ocr-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    width: 0%;
    transition: width 0.3s ease;
}
.ocr-progress-text {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 6px;
    text-align: center;
}

.back-to-top-wrapper {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}
.back-to-top-btn {
    min-width: 180px;
    padding: 10px 20px;
    font-size: 0.9rem;
}

.register-subtabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    border-bottom: 2px solid var(--border-color);
}
.register-subtab {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: -2px;
}
.register-subtab:hover {
    color: var(--primary);
}
.register-subtab.active {
    color: var(--primary);
    border-bottom-color: var(--accent);
}

.eval-filter-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.eval-filter-row .form-select {
    min-width: 0;
    padding: 6px 10px;
    font-size: 0.88rem;
}

.stats-type-breakdown {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 10px;
}
@media (max-width: 768px) {
    .stats-type-breakdown { grid-template-columns: repeat(2, 1fr); }
}
.type-breakdown-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    min-height: 64px;
    box-sizing: border-box;
}
.type-breakdown-icon {
    font-size: 1.4rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    flex-shrink: 0;
}
.type-breakdown-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.type-breakdown-label {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 600;
}
.type-breakdown-count {
    font-size: 1.1rem;
    color: var(--text-dark);
    font-weight: 700;
}
.type-breakdown-pct {
    font-size: 0.78rem;
    color: var(--text-light);
    font-weight: 500;
    margin-left: 4px;
}
.type-breakdown-explanation .type-breakdown-icon { color: var(--primary); }
.type-breakdown-fillblank .type-breakdown-icon { color: #c08a00; }
.type-breakdown-tof .type-breakdown-icon { color: #6c63ff; }
.type-breakdown-choice .type-breakdown-icon { color: #2e7d32; }

.choice-options-section {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.choice-options-hint {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-bottom: 4px;
}
.choice-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-dark);
    font-size: 0.95rem;
    line-height: 1.5;
}
.choice-option:hover {
    border-color: var(--accent);
    background: var(--question-bg);
}
.choice-option input {
    margin-top: 3px;
    cursor: pointer;
    flex-shrink: 0;
}
.choice-option-text {
    flex: 1;
}
.choice-option:has(input:checked) {
    border-color: var(--primary);
    background: rgba(66, 153, 225, 0.10);
}
.choice-option-correct {
    border-color: #28a745 !important;
    background: rgba(40, 167, 69, 0.12) !important;
}
.choice-option-wrong {
    border-color: #dc3545 !important;
    background: rgba(220, 53, 69, 0.12) !important;
}
[data-theme="dark"] .choice-option-correct,
:root:not([data-theme="light"]) .choice-option-correct {
    background: rgba(102, 187, 106, 0.20) !important;
}
[data-theme="dark"] .choice-option-wrong,
:root:not([data-theme="light"]) .choice-option-wrong {
    background: rgba(239, 83, 80, 0.20) !important;
}

.choice-answer-buttons {
    margin-top: 14px;
    display: flex;
    justify-content: center;
}
.choice-submit-btn {
    min-width: 200px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 700;
}
.choice-submit-locked {
    opacity: 0.55;
    cursor: not-allowed;
}

.choice-answer-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--answer-bg);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent);
}
.choice-answer-section h4 {
    margin: 8px 0 4px;
    font-size: 0.92rem;
    color: var(--primary);
}
.choice-answer-section p {
    margin: 4px 0 0;
    line-height: 1.7;
    color: var(--text-dark);
}
.choice-result-badge {
    display: inline-block;
    margin-bottom: 10px;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1.05rem;
}

.theory-card:hover {
    box-shadow: var(--shadow-md);
}

.theory-card.card-slide-in-right {
    animation: cardSlideInRight 0.3s ease forwards;
}

.theory-card.card-slide-in-left {
    animation: cardSlideInLeft 0.3s ease forwards;
}

@keyframes cardSlideInRight {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes cardSlideInLeft {
    from { transform: translateX(-40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.card-path {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 500;
}

.card-number {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    flex-shrink: 0;
}

.question-section {
    background: var(--question-bg);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border-left: 4px solid var(--primary);
}

.question-section h4 {
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 10px;
    font-weight: 700;
}

.question-section p {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-dark);
}

.answer-section {
    background: var(--answer-bg);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border-left: 4px solid var(--accent);
    transform-origin: top center;
}

.answer-reveal {
    animation: answerReveal 0.35s ease-out;
}

@keyframes answerReveal {
    0% {
        opacity: 0;
        transform: perspective(600px) rotateX(-15deg) translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: perspective(600px) rotateX(0) translateY(0);
    }
}

.answer-section h4 {
    font-size: 0.85rem;
    color: var(--accent);
    margin-bottom: 10px;
    font-weight: 700;
}

.answer-section p {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-dark);
    font-weight: 600;
}

.card-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.current-eval {
    font-size: 0.85rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.eval-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.8rem;
    display: inline-block;
    color: white;
}

.eval-s { background: var(--eval-s); }
.eval-a { background: var(--eval-a); }
.eval-b { background: var(--eval-b); }
.eval-c { background: var(--eval-c); }
.eval-d { background: var(--eval-d); }
.eval-e { background: var(--eval-e); }

.overdue-warning {
    color: var(--eval-c);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
}

.eval-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.eval-btn {
    flex: 1;
    min-width: 40px;
    padding: 12px 4px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: white;
    position: relative;
    overflow: hidden;
}

.eval-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.15);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.eval-btn:hover::after { opacity: 1; }
.eval-btn:active { transform: scale(0.95); }

.eval-btn-large {
    min-width: 80px;
    padding: 16px 12px;
    font-size: 1rem;
}

.eval-btn-s { background: var(--eval-s); }
.eval-btn-a { background: var(--eval-a); }
.eval-btn-b { background: var(--eval-b); }
.eval-btn-c { background: var(--eval-c); }
.eval-btn-d { background: var(--eval-d); }
.eval-btn-e { background: var(--eval-e); }

/* ========================================
   統計表示（レガシー互換）
======================================== */
.review-header {
    margin-bottom: 20px;
}

.review-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.stat-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
}

.stat-total { background: var(--primary); }
.stat-s { background: var(--eval-s); }
.stat-e { background: var(--eval-e); }
.stat-d { background: var(--eval-d); }
.stat-c { background: var(--eval-c); }
.stat-b { background: var(--eval-b); }
.stat-a { background: var(--eval-a); }

/* ========================================
   セレクター・フィルター
======================================== */
.selector-area,
.filter-area {
    background: var(--bg-surface);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.selector-row,
.filter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.selector-row:last-child,
.filter-row:last-child {
    margin-bottom: 0;
}

.selector-row label,
.filter-row label {
    min-width: 80px;
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.form-select {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--input-bg);
    color: var(--text-dark);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.form-select:hover:not(:disabled) { border-color: var(--primary); }

.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(66,153,225,0.15);
}

.form-select:disabled {
    background: var(--bg-surface);
    color: var(--text-light);
    cursor: not-allowed;
    opacity: 0.7;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.filter-btn {
    padding: 6px 14px;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-dark);
    font-weight: 500;
}

.filter-btn:hover {
    border-color: var(--primary);
    background: var(--bg-surface);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ========================================
   理論リスト
======================================== */
.theory-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.theory-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all var(--transition-fast);
}

.theory-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.theory-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.theory-item-path {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 6px;
}

.theory-item-question {
    font-size: 0.95rem;
    color: var(--text-dark);
    font-weight: 500;
    margin-bottom: 8px;
    line-height: 1.6;
}

.theory-item-info {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

.theory-item-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ========================================
   ボタン
======================================== */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:active { transform: scale(0.97); }

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }

.btn-success { background: var(--eval-a); color: white; }
.btn-success:hover { background: #229954; }

.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: var(--text-light); filter: brightness(0.92); }

.btn-warning { background: #6c63ff; color: white; }
.btn-warning:hover { background: #5a52e0; }

.btn-danger { background: #dc3545; color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-width: auto;
}

/* ========================================
   教材構造管理
======================================== */
.structure-item {
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--card-bg);
    transition: box-shadow var(--transition-fast);
}

.structure-item:hover { box-shadow: var(--shadow-sm); }

.structure-subject { border-color: var(--primary); }
.structure-book { border-color: var(--eval-a); margin-left: 16px; }
.structure-chapter { border-color: var(--eval-b); margin-left: 32px; }

.structure-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-surface);
    transition: all var(--transition-fast);
}

.structure-subject .structure-header { background: linear-gradient(to right, var(--bg-surface), #e8f4f8); }
.structure-book .structure-header { background: linear-gradient(to right, var(--bg-surface), #e8f5e9); }
.structure-chapter .structure-header { background: linear-gradient(to right, var(--bg-surface), #fff3e0); }
.structure-header:hover { background: var(--bg-surface); filter: brightness(1.05); }

.structure-info { display: flex; align-items: center; gap: 10px; flex: 1; }
.structure-icon { font-size: 1.3rem; }
.structure-name { font-size: 1rem; font-weight: 600; color: var(--text-dark); }

.structure-count {
    padding: 3px 10px;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
}

.structure-book .structure-count { background: var(--eval-a); }
.structure-chapter .structure-count { background: var(--eval-b); }
.structure-actions { display: flex; gap: 6px; }
.structure-children { padding: 12px; background: var(--card-bg); }
.structure-subject > .structure-children { background: var(--card-bg); }
.structure-book > .structure-children { background: var(--card-bg); }

/* ========================================
   バックアップセクション
======================================== */
.backup-section { margin-bottom: 24px; }
.backup-section h4 { font-size: 1.1rem; margin-bottom: 12px; }

.import-options label {
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.import-options label:hover { background: var(--bg-surface); }

.import-options input[type="radio"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* ========================================
   カレンダー
======================================== */
.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-nav-btn {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.calendar-nav-btn:hover { background: var(--primary-light); }

.calendar-title {
    font-size: 1.3rem;
    color: var(--primary);
    font-weight: 700;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 20px;
}

.calendar-header {
    text-align: center;
    font-weight: 700;
    padding: 8px;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    font-size: 0.8rem;
}

.calendar-day {
    aspect-ratio: 1;
    padding: 6px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.calendar-day:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.calendar-day.empty { border: none; cursor: default; }
.calendar-day.empty:hover { box-shadow: none; }

.calendar-day.today {
    background: #fffbeb;
    color: #1a202c;
    border-color: var(--eval-b);
    font-weight: 700;
}
[data-theme="dark"] .calendar-day.today,
:root:not([data-theme="light"]) .calendar-day.today {
    background: rgba(245, 158, 11, 0.18);
    color: var(--text-dark);
    border-color: var(--eval-b);
}

.calendar-day-number { font-size: 1rem; font-weight: 600; margin-bottom: 2px; }

.calendar-day-count {
    font-size: 0.75rem;
    color: var(--text-dark);
    background: var(--bg-surface);
    padding: 1px 6px;
    border-radius: 10px;
}

.calendar-day.has-review .calendar-day-count {
    color: var(--text-dark);
    font-weight: 700;
}

/* Heat map levels */
.calendar-day.heat-light {
    background: rgba(66, 153, 225, 0.1);
    border-color: rgba(66, 153, 225, 0.3);
}
.calendar-day.heat-light .calendar-day-count { background: rgba(66, 153, 225, 0.7); }

.calendar-day.heat-medium {
    background: rgba(66, 153, 225, 0.2);
    border-color: rgba(66, 153, 225, 0.5);
}
.calendar-day.heat-medium .calendar-day-count { background: rgba(245, 158, 11, 0.8); }

.calendar-day.heat-heavy {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.5);
}
.calendar-day.heat-heavy .calendar-day-count { background: rgba(239, 68, 68, 0.8); }

.calendar-day.heat-extreme {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.5);
}
.calendar-day.heat-extreme .calendar-day-count { background: rgba(239, 68, 68, 0.95); }

.calendar-day.was-studied::after {
    content: '';
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--eval-a);
    margin-top: 2px;
}

[data-theme="dark"] .calendar-day.today {
    background: rgba(251, 191, 36, 0.15);
}

.calendar-detail {
    background: var(--bg-surface);
    padding: 16px;
    border-radius: var(--radius-md);
}

/* ========================================
   フォーム
======================================== */
.mode-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.mode-btn {
    flex: 1;
    min-width: 100px;
    padding: 12px 8px;
    background: var(--card-bg);
    color: var(--text-dark);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-btn:hover { border-color: var(--primary); }

.mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* 設定タブ: 一行ずつのメニュー */
.management-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}
.mode-selector-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.management-content-area {
    min-width: 0;
    min-height: 70vh;
}
@media (min-width: 769px) {
    .management-layout {
        grid-template-columns: 220px 1fr;
    }
    .mode-selector-grid {
        position: sticky;
        top: 12px;
    }
}

.mode-btn-row {
    width: 100%;
    padding: 14px 16px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    color: var(--text-dark);
}

.mode-btn-row:hover { border-color: var(--primary); background: var(--question-bg); }

.mode-btn-row.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.management-mode {
    animation: managementFadeIn 0.15s ease;
}
@keyframes managementFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.form-section {
    background: var(--bg-surface);
    padding: 20px;
    border-radius: var(--radius-md);
}

.form-row { margin-bottom: 16px; }

.form-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all var(--transition-normal);
    line-height: 1.6;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(66,153,225,0.15);
}

.form-textarea { resize: vertical; }

.bulk-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    position: relative;
}
.bulk-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.bulk-card-number {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.9rem;
    margin-right: auto;
}
.bulk-card-type-select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-dark);
    font-size: 0.85rem;
    cursor: pointer;
}
.bulk-card-tof-correct {
    display: flex;
    gap: 14px;
    margin: 4px 0 8px;
    padding: 8px 10px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
}
.bulk-card-tof-correct label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 0.92rem;
    color: var(--text-dark);
}
.bulk-card-tof-correct input[type="radio"] {
    cursor: pointer;
}
.bulk-card-remove {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-light);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.bulk-card-remove:hover {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}
.bulk-card-label {
    font-size: 0.78rem;
    color: var(--text-light);
    font-weight: 600;
    margin: 6px 0 3px;
    display: block;
}
.bulk-card-label:first-of-type { margin-top: 0; }
.bulk-card textarea {
    width: 100%;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    background: var(--input-bg);
    color: var(--text-dark);
    font-family: inherit;
    box-sizing: border-box;
    resize: vertical;
}
.bulk-card textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(66,153,225,0.15);
}

.guide-box {
    background: #e8f5e9;
    border-left: 4px solid var(--eval-a);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    color: #1a202c;
}

.guide-box h4 { color: #2e7d32; margin-bottom: 12px; font-size: 0.95rem; }
.guide-box p { margin-bottom: 8px; line-height: 1.6; color: #1a202c; }
.guide-box ul { margin-left: 16px; margin-bottom: 12px; }
.guide-box li { margin-bottom: 6px; line-height: 1.6; color: #1a202c; }

[data-theme="dark"] .guide-box,
:root:not([data-theme="light"]) .guide-box {
    background: rgba(46, 125, 50, 0.15);
    border-left-color: #66bb6a;
    color: var(--text-dark);
}
[data-theme="dark"] .guide-box h4,
:root:not([data-theme="light"]) .guide-box h4 { color: #81c784; }
[data-theme="dark"] .guide-box p,
[data-theme="dark"] .guide-box li,
:root:not([data-theme="light"]) .guide-box p,
:root:not([data-theme="light"]) .guide-box li { color: var(--text-dark); }

.bulk-format-sample {
    background: #ffffff;
    color: #1a202c;
    padding: 12px;
    border-radius: 5px;
    margin: 8px 0;
    font-family: monospace;
    white-space: pre-wrap;
    font-size: 0.85rem;
    border: 1px solid #c8e6c9;
}
[data-theme="dark"] .bulk-format-sample,
:root:not([data-theme="light"]) .bulk-format-sample {
    background: var(--card-bg);
    color: var(--text-dark);
    border-color: var(--border-color);
}

.bulk-format-legend {
    background: #e3f2fd;
    color: #1a202c !important;
    padding: 8px;
    border-radius: 5px;
    margin: 8px 0;
    font-size: 0.85rem;
}
[data-theme="dark"] .bulk-format-legend,
:root:not([data-theme="light"]) .bulk-format-legend {
    background: rgba(96, 165, 250, 0.15);
    color: var(--text-dark) !important;
}
.bulk-format-legend .sep-answer { color: #c0392b; }
.bulk-format-legend .sep-question { color: #1565c0; }
[data-theme="dark"] .bulk-format-legend .sep-answer,
:root:not([data-theme="light"]) .bulk-format-legend .sep-answer { color: #ff8a80; }
[data-theme="dark"] .bulk-format-legend .sep-question,
:root:not([data-theme="light"]) .bulk-format-legend .sep-question { color: #82b1ff; }

.form-hint {
    font-size: 0.78rem;
    color: var(--text-light);
    margin: 4px 0 0;
    line-height: 1.5;
}
.form-hint code {
    background: var(--bg-surface);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
    color: var(--accent);
    font-weight: 700;
}
.bulk-format-legend code {
    background: rgba(255,255,255,0.6);
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 700;
    color: var(--accent);
}


.guide-example {
    background: var(--card-bg);
    color: var(--text-dark);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
}

.guide-note {
    font-size: 0.85rem;
    color: var(--text-light);
    font-style: italic;
}

.form-actions { display: flex; gap: 12px; }

/* ========================================
   モーダル
======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

#legal-modal { z-index: 1100; }

.modal-content {
    background: var(--card-bg, white);
    color: var(--text-dark);
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-light);
    transition: all var(--transition-fast);
    line-height: 1;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}

.modal-close:hover,
.modal-close:focus-visible {
    color: var(--eval-c);
    transform: rotate(90deg);
}

.modal-close:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ========================================
   Toast通知
======================================== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    transform: translateX(120%);
    transition: transform var(--transition-normal);
    pointer-events: auto;
    max-width: 320px;
    box-shadow: var(--shadow-md);
}

.toast-visible { transform: translateX(0); }
.toast-info { background: var(--primary); }
.toast-success { background: var(--eval-a); }
.toast-warning { background: var(--eval-b); }
.toast-error { background: var(--eval-c); }

/* ========================================
   完了セレブレーション
======================================== */
.celebration {
    text-align: center;
    padding: 60px 20px;
    animation: celebrationPop 0.5s ease;
}

@keyframes celebrationPop {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.celebration-emoji {
    font-size: 4rem;
    animation: celebrationBounce 1.5s ease infinite;
}

@keyframes celebrationBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.celebration-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-top: 16px;
}

.celebration-subtitle {
    font-size: 1rem;
    color: var(--text-light);
    margin-top: 8px;
}

.celebration-stats {
    margin-top: 20px;
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ========================================
   空状態
======================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    animation: gentleFloat 3s ease-in-out infinite;
}

@keyframes gentleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.empty-state-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.empty-state-message {
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ========================================
   レスポンシブ + モバイルボトムナビ
======================================== */
@media (max-width: 768px) {
    body {
        padding: 0;
        padding-top: env(safe-area-inset-top, 0px);
        background: #f0f4f8;
    }

    [data-theme="dark"] body,
    :root:not([data-theme="light"]) body {
        background: var(--body-bg);
    }

    .app-container {
        border-radius: 0;
        padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    }

    .app-header {
        padding: 8px 16px;
        padding-top: calc(8px + env(safe-area-inset-top, 0px));
    }
    .app-header h1 { font-size: 1.1rem; }

    .tab-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 999;
        border-top: 1px solid var(--border-color);
        border-bottom: none;
        background: var(--card-bg, white);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
        justify-content: space-around;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }

    .tab-button {
        padding: 8px 4px 6px;
        font-size: 0.6rem;
        min-width: 0;
        flex: 1;
    }

    .tab-icon { display: block; font-size: 1.2rem; }
    .tab-label { font-size: 0.6rem; }

    .tab-button.active::after {
        top: 0;
        bottom: auto;
        border-radius: 0 0 3px 3px;
    }

    .tab-content { padding: 16px; }
    .tab-content h2 { font-size: 1.25rem; }
    .theory-card { padding: 16px; }
    .question-section, .answer-section { padding: 14px; }
    .question-section p, .answer-section p { font-size: 0.95rem; }

    .eval-buttons:not(.eval-buttons-compact) { flex-direction: column; }
    .eval-buttons:not(.eval-buttons-compact) .eval-btn { width: 100%; }

    .selector-row, .filter-row { flex-direction: column; align-items: flex-start; }
    .selector-row label, .filter-row label { min-width: auto; }
    .form-select, .filter-buttons { width: 100%; }

    .calendar-grid { gap: 3px; }
    .calendar-day { padding: 4px; }
    .calendar-day-number { font-size: 0.85rem; }
    .calendar-day-count { font-size: 0.65rem; }

    .form-actions { flex-direction: column; }

    .modal-content {
        width: 95%;
        padding: 20px;
        border-radius: var(--radius-lg);
    }

    .structure-book { margin-left: 8px; }
    .structure-chapter { margin-left: 16px; }
    .structure-name { font-size: 0.9rem; }
    .structure-actions { flex-wrap: wrap; }
    .mode-selector { gap: 6px; }
    .mode-btn { padding: 10px 6px; font-size: 0.8rem; min-width: 0; }
    .mode-selector-grid { gap: 4px; }
    .mode-btn-row { padding: 12px 14px; font-size: 0.85rem; }

    .dashboard-summary { gap: 4px; margin-bottom: 6px; }
    .stat-number { font-size: 1.05rem; line-height: 1; height: auto; min-height: 22px; }
    .stat-label { font-size: 0.62rem; margin-top: 1px; letter-spacing: 0; }
    .dashboard-stat-card { padding: 4px 4px; border-radius: var(--radius-sm); min-height: 56px; gap: 2px; }
    .dashboard-stat-card.progress-ring-container { padding: 2px; min-height: 56px; }
    .progress-ring-container svg { width: 38px; height: 38px; }
    .chapter-review-header { padding: 6px 10px; gap: 8px; flex-wrap: wrap; }
    .chapter-review-path { font-size: 0.75rem; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
    #chapter-review-exit-btn { padding: 4px 10px; font-size: 0.7rem; white-space: nowrap; flex-shrink: 0; }
    .calendar-strip { gap: 2px; margin-bottom: 8px; }
    .strip-day { padding: 4px 2px; }
    .strip-day-label { font-size: 0.6rem; }
    .strip-day-num { font-size: 0.8rem; }
    .strip-day-count { font-size: 0.6rem; }

    #toast-container {
        top: auto;
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
        right: 12px;
        left: 12px;
    }

    .toast { max-width: none; }

    .review-controls .btn {
        font-size: 0.7rem;
        padding: 7px 2px;
    }

    .theory-item-actions { flex-wrap: wrap; }
    .theory-item-actions .btn { flex: 1; min-width: 0; text-align: center; }
}

/* ========================================
   ユーティリティ
======================================== */
.text-center { text-align: center; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }
.hidden { display: none !important; }

.badge-unlearned {
    background: #95a5a6;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    margin-left: 4px;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

/* ========================================
   統計ダッシュボード
======================================== */

.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.stats-summary-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 12px 8px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stats-summary-number {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.1;
}

.stats-summary-label {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 2px;
}

.stats-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}
.stats-grid-2 {
    grid-template-columns: 1fr 1fr;
}
@media (max-width: 768px) {
    .stats-grid-2 { grid-template-columns: 1fr; }
}

.stats-section {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}
.stats-grid > .stats-section {
    margin-bottom: 0;
}

.stats-section h3 {
    font-size: 0.88rem;
    color: var(--secondary);
    margin: 0 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.stats-chart-compact { height: 120px; }
.stats-chart-compact .bar-chart { height: 100px; padding-top: 12px; }
.stats-chart-compact .accuracy-svg { max-height: 120px; }

.stats-empty {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    padding: 20px 0;
}

/* Bar chart */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 140px;
    padding-top: 20px;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    min-width: 0;
}

.bar-value {
    font-size: 0.6rem;
    color: var(--text-light);
    margin-bottom: 2px;
    min-height: 12px;
}

.bar {
    width: 100%;
    max-width: 14px;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
    min-height: 1px;
    transition: height 0.3s ease;
}

.bar-col:hover .bar {
    background: var(--primary);
}

.bar-label {
    font-size: 0.55rem;
    color: var(--text-light);
    margin-top: 4px;
    min-height: 12px;
    white-space: nowrap;
}

/* Accuracy SVG chart */
.accuracy-svg {
    width: 100%;
    height: auto;
    max-height: 200px;
}

/* Evaluation distribution: ドーナツ円グラフ + 凡例 */
.eval-pie-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}
.eval-pie-svg {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
}
.eval-pie-center {
    fill: var(--card-bg);
}
.eval-pie-center-num {
    font-size: 26px;
    font-weight: 800;
    fill: var(--primary);
    dominant-baseline: central;
}
.eval-pie-legend {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
    font-size: 0.72rem;
    line-height: 1.3;
    min-width: 0;
}
.eval-pie-legend-row {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.eval-pie-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.eval-pie-legend-label { color: var(--text-dark); font-weight: 600; }
.eval-pie-legend-count { color: var(--text-light); margin-left: auto; }
.eval-pie-empty {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    padding: 24px 0;
}
@media (max-width: 480px) {
    .eval-pie-svg { width: 100px; height: 100px; }
    .eval-pie-legend { grid-template-columns: 1fr; }
}

/* Subject progress: コンパクト化 */
.subject-progress-row {
    margin-bottom: 8px;
}
.subject-progress-row:last-child {
    margin-bottom: 0;
}

.subject-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
    gap: 8px;
}

.subject-progress-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.subject-progress-detail {
    font-size: 0.7rem;
    color: var(--text-light);
    flex-shrink: 0;
}

.subject-progress-bar {
    height: 12px;
    background: var(--bg-surface);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    position: relative;
}

.subject-progress-mastered {
    background: var(--eval-a);
    transition: width 0.4s ease;
}

.subject-progress-learning {
    background: var(--eval-b);
    transition: width 0.4s ease;
}

.subject-progress-pct {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 2px;
    text-align: right;
}
.subject-progress-pct b { color: var(--eval-a); }

.stats-subject-scroll {
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}
.stats-subject-scroll::-webkit-scrollbar { width: 6px; }
.stats-subject-scroll::-webkit-scrollbar-track { background: var(--bg-surface); border-radius: 3px; }
.stats-subject-scroll::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
.stats-subject-scroll::-webkit-scrollbar-thumb:hover { background: #a0aec0; }
@media (max-width: 768px) {
    .stats-subject-scroll { max-height: 220px; }
}

/* ========================================
   日別学習目標バー
======================================== */

.daily-goal-bar {
    margin: 8px 0 4px;
}

.daily-goal-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 4px;
    text-align: center;
}

.daily-goal-track {
    height: 8px;
    background: var(--bg-surface);
    border-radius: 4px;
    overflow: hidden;
}

.daily-goal-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.daily-goal-fill.goal-achieved {
    background: var(--eval-a);
}

/* ========================================
   ショートカットヘルプ
======================================== */

.shortcut-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay, rgba(0,0,0,0.5));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.shortcut-modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    max-width: 360px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.shortcut-modal h3 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 16px;
    font-size: 1rem;
}

.shortcut-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.shortcut-item kbd {
    display: inline-block;
    min-width: 44px;
    text-align: center;
    padding: 3px 8px;
    font-size: 0.8rem;
    font-family: inherit;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-dark);
    font-weight: 600;
}

.shortcut-item span {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ========================================
   Help Button
======================================== */
.tab-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-heading h2 {
    margin-bottom: 0;
}

.help-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.help-btn:hover {
    background: var(--primary);
    color: white;
}

.help-modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay, rgba(0,0,0,0.5));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.help-modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    max-width: 480px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    color: var(--text-dark);
}

.help-modal-content h3 {
    color: var(--primary);
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.help-modal-body {
    margin-bottom: 16px;
}

.help-modal-body h4 {
    color: var(--primary);
    font-size: 0.95rem;
    margin: 14px 0 8px;
}

.help-modal-body h4:first-child {
    margin-top: 0;
}

.help-modal-content p {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.help-modal-body .help-steps {
    padding-left: 1.3em;
    margin: 0 0 4px;
}

.help-modal-body .help-steps li {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 4px;
    color: var(--text-dark);
}

.help-modal-content .btn {
    width: 100%;
}

/* ========================================
   Test Mode
======================================== */
.test-setup {
    background: var(--bg-surface);
    padding: 20px;
    border-radius: var(--radius-md);
}

.test-setup .form-row {
    margin-bottom: 16px;
}

.test-progress-bar {
    height: 6px;
    background: var(--bg-surface);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 16px;
}

.test-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--eval-a));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.test-card-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
}

.test-answer-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.test-answer-buttons .btn {
    flex: 1;
    padding: 14px;
    font-size: 1rem;
    font-weight: 700;
}

.test-result-score {
    text-align: center;
    padding: 30px 0 20px;
}

.test-result-score .score-number {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.test-result-score .score-label {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 8px;
}

.test-result-score .score-detail {
    font-size: 1rem;
    color: var(--text-dark);
    margin-top: 4px;
}

.test-result-section {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.test-scope-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.test-scope-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.test-scope-cell label {
    font-size: 0.78rem;
    color: var(--text-light);
    font-weight: 600;
    margin: 0;
}
.test-scope-cell .form-select {
    width: 100%;
    min-width: 0;
    padding: 8px 6px;
    font-size: 0.85rem;
}
@media (max-width: 480px) {
    .test-scope-grid { gap: 6px; }
    .test-scope-cell label { font-size: 0.72rem; }
    .test-scope-cell .form-select { padding: 6px 4px; font-size: 0.78rem; }
}

.test-filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--bg-surface);
    padding: 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.test-filter-chk {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-dark);
    user-select: none;
    transition: all var(--transition-fast);
}
.test-filter-chk:has(input:checked) {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.test-filter-chk input { margin: 0; cursor: pointer; }
.test-filter-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.test-timer {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-dark);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
}
.test-timer.warning { background: #fff3cd; color: #856404; }
.test-timer.danger {
    background: #f8d7da; color: #721c24;
    animation: testTimerPulse 1s infinite;
}
@keyframes testTimerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

.test-apply-eval-box {
    margin-top: 16px;
    margin-bottom: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
}
.test-apply-eval-hint {
    font-size: 0.78rem;
    color: var(--text-light);
    margin: 8px 0 0;
    line-height: 1.6;
}

.test-pass-banner {
    margin-top: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}
.test-pass-banner.pass {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 2px solid #28a745;
}
.test-pass-banner.fail {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 2px solid #dc3545;
}

.test-history-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}
.test-history-card h4 {
    margin: 0 0 10px;
    font-size: 0.95rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.test-history-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 80px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
}
.test-history-bar {
    flex: 1;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
    min-width: 6px;
    transition: opacity var(--transition-fast);
    position: relative;
}
.test-history-bar.pass { background: #28a745; }
.test-history-bar.fail { background: #dc3545; }
.test-history-bar:hover { opacity: 0.75; }
.test-history-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 6px;
}
.test-history-empty {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    padding: 12px 0;
}
.test-history-latest {
    font-size: 0.85rem;
    margin-top: 8px;
    color: var(--text-dark);
}
.test-history-trend-up { color: #28a745; font-weight: 700; }
.test-history-trend-down { color: #dc3545; font-weight: 700; }
.test-history-trend-flat { color: var(--text-light); font-weight: 700; }

.test-result-section h3 {
    font-size: 0.9rem;
    color: var(--secondary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.test-eval-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.test-eval-bar-label {
    width: 24px;
    font-weight: 700;
    font-size: 0.85rem;
    text-align: center;
    color: var(--primary);
}

.test-eval-bar-bg {
    flex: 1;
    height: 20px;
    background: var(--bg-surface);
    border-radius: 10px;
    overflow: hidden;
}

.test-eval-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.4s ease;
}

.test-eval-bar-pct {
    width: 50px;
    font-size: 0.8rem;
    text-align: right;
    color: var(--text-light);
}

.test-incorrect-item {
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid var(--border-color);
}

.test-incorrect-item:hover {
    border-color: var(--accent);
}

.test-incorrect-item .incorrect-question {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.test-incorrect-item .incorrect-detail {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.test-incorrect-item.expanded .incorrect-detail {
    display: block;
}

.test-incorrect-item .incorrect-detail .question-section,
.test-incorrect-item .incorrect-detail .answer-section {
    margin-bottom: 8px;
}

.test-result-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.test-result-actions .btn {
    flex: 1;
}

/* ========================================
   Guide Modal
======================================== */
.guide-modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay, rgba(0,0,0,0.5));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.guide-modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 500px;
    width: 92%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-lg);
    color: var(--text-dark);
}

.guide-step {
    display: flex;
    gap: 14px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.guide-step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.guide-step-content h4 {
    font-size: 0.95rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.guide-step-content p {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.6;
}

/* ========================================
   ログイン/登録画面
======================================== */

.auth-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--body-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px 32px;
    animation: authFadeIn 0.4s ease;
}

@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.auth-header p {
    font-size: 0.9rem;
    color: var(--text-light);
}

.auth-form h2 {
    font-size: 1.2rem;
    color: var(--text-dark);
    margin-bottom: 20px;
    text-align: center;
}

.auth-field {
    margin-bottom: 16px;
}

.auth-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.auth-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--input-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-dark);
    transition: border-color var(--transition-fast);
    outline: none;
}

.auth-input:focus {
    border-color: var(--accent);
}

.auth-error {
    background: #fee2e2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    border: 1px solid #fecaca;
}

[data-theme="dark"] .auth-error,
:root:not([data-theme="light"]) .auth-error {
    background: #451a1a;
    color: #fca5a5;
    border-color: #7f1d1d;
}

.auth-success {
    background: #dcfce7;
    color: #166534;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    border: 1px solid #bbf7d0;
}

[data-theme="dark"] .auth-success,
:root:not([data-theme="light"]) .auth-success {
    background: #14321f;
    color: #86efac;
    border-color: #166534;
}

.auth-help {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 16px;
    line-height: 1.6;
    text-align: center;
}

.auth-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 12px;
}

.auth-btn-primary {
    background: var(--primary);
    color: white;
}

.auth-btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.auth-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.auth-btn-offline {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    padding: 10px;
}

.auth-btn-offline:hover {
    background: var(--bg-surface);
}

.auth-switch {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 16px;
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-legal-links {
    text-align: center;
    margin-top: 16px;
    font-size: 0.75rem;
    color: var(--text-light);
}

.auth-legal-links a {
    color: var(--text-light);
    text-decoration: none;
}

.auth-legal-links a:hover {
    text-decoration: underline;
}

/* 法的ページモーダル */
#legal-modal-body h3 {
    font-size: 1rem;
    color: var(--primary);
    margin: 20px 0 8px;
}

#legal-modal-body h4 {
    font-size: 0.9rem;
    color: var(--secondary);
    margin: 12px 0 6px;
}

#legal-modal-body p,
#legal-modal-body li {
    font-size: 0.9rem;
    line-height: 1.85;
    color: var(--text-dark);
    margin-bottom: 10px;
}
#legal-modal-body p + p {
    margin-top: 8px;
}
#legal-modal-body li {
    margin-bottom: 10px;
}

#legal-modal-body ul,
#legal-modal-body ol {
    padding-left: 20px;
    margin-bottom: 12px;
}

.announcement-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
    overflow-y: auto;
}
.announcement-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px 22px 22px;
    max-width: 520px;
    width: 100%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border-top: 5px solid var(--accent);
    animation: celebrationPop 0.35s ease;
}
.announcement-date {
    font-size: 0.78rem;
    color: var(--text-light);
    font-weight: 600;
    margin-bottom: 4px;
}
.announcement-title {
    color: var(--primary);
    font-size: 1.15rem;
    margin: 0 0 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent);
}
.announcement-intro {
    font-size: 0.9rem;
    color: var(--text-dark);
    line-height: 1.7;
    margin: 0 0 16px;
}
.announcement-heading {
    color: var(--primary);
    font-size: 0.95rem;
    margin: 16px 0 6px;
    padding-top: 4px;
}
.announcement-list {
    padding-left: 1.3em;
    margin: 6px 0 12px;
}
.announcement-list li {
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-dark);
    margin-bottom: 4px;
}
.announcement-footer {
    font-size: 0.82rem;
    color: var(--text-light);
    margin: 18px 0 14px;
    padding: 10px 12px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    line-height: 1.6;
}
.announcement-close-btn {
    width: 100%;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.announcement-close-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.announcement-close-btn:active { transform: scale(0.98); }

.updates-entry {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.updates-entry > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    user-select: none;
    transition: background var(--transition-fast);
}
.updates-entry > summary::-webkit-details-marker { display: none; }
.updates-entry > summary::after {
    content: '▼';
    margin-left: auto;
    color: var(--text-light);
    font-size: 0.7em;
    transition: transform 0.2s ease;
}
.updates-entry[open] > summary::after { transform: rotate(180deg); }
.updates-entry > summary:hover { background: var(--bg-surface); }
.updates-entry[open] > summary { border-bottom: 1px solid var(--border-color); }
.updates-entry-date {
    font-size: 0.78rem;
    color: var(--text-light);
    font-weight: 700;
    flex-shrink: 0;
    background: var(--bg-surface);
    padding: 3px 8px;
    border-radius: 4px;
}
.updates-entry-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    flex: 1;
    min-width: 0;
}
.updates-entry-body {
    padding: 14px 18px 16px;
    color: var(--text-dark);
}
.updates-intro {
    font-size: 0.9rem;
    line-height: 1.7;
    margin: 0 0 12px;
}
.updates-heading {
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    margin: 14px 0 4px;
}
.updates-list {
    margin: 4px 0 10px;
    padding-left: 1.3em;
}
.updates-list li {
    font-size: 0.88rem;
    line-height: 1.7;
    margin-bottom: 4px;
}
.updates-footer {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
    font-size: 0.82rem;
    color: var(--text-light);
}

.review-incorrect-done {
    text-align: center;
    padding: 30px 20px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}
.review-incorrect-done-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

/* ========================================
   タブヒント（使い方ボックス）
======================================== */
.tab-hint {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    padding: 14px 36px 14px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    font-size: 0.85rem;
    line-height: 1.7;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}
.tab-hint:hover { filter: brightness(0.98); }
[data-theme="dark"] .tab-hint:hover,
:root:not([data-theme="light"]) .tab-hint:hover { filter: brightness(1.15); }
.tab-hint .tab-hint-body { display: block; color: inherit; }
.tab-hint .tab-hint-mini {
    display: none;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
    text-align: center;
    padding: 2px 0;
    letter-spacing: 0.02em;
}
.tab-hint .tab-hint-mini::after {
    content: ' ▼';
    font-size: 0.7em;
    color: var(--text-light);
    margin-left: 6px;
    vertical-align: middle;
}
.tab-hint.collapsed { padding: 12px 14px; }
.tab-hint.collapsed .tab-hint-body { display: none; }
.tab-hint.collapsed .tab-hint-mini { display: block; }

.tab-hint .tab-hint-toggle-note {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-light);
    margin-left: 8px;
    letter-spacing: 0;
}

.tab-hint strong {
    color: var(--primary);
    font-size: 1rem;
    font-weight: 700;
    display: block;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--accent);
}
.tab-hint .tab-hint-h {
    color: var(--primary);
    font-size: 0.88rem;
    margin: 14px 0 4px;
    font-weight: 700;
    padding: 0;
    border-left: none;
}
.tab-hint .tab-hint-ul {
    margin: 4px 0 10px;
    padding-left: 1.3em;
    color: var(--text-dark);
}
.tab-hint .tab-hint-ul li {
    margin-bottom: 4px;
    line-height: 1.65;
}
.tab-hint .tab-hint-ul li b {
    color: var(--text-dark);
}
.tab-hint .tab-hint-p {
    margin: 4px 0 8px;
    color: var(--text-dark);
}
.tab-hint .tab-hint-tip {
    margin: 14px 0 0;
    padding: 10px 0 0;
    border-top: 1px dashed var(--border-color);
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.7;
}

[data-theme="dark"] .tab-hint strong,
:root:not([data-theme="light"]) .tab-hint strong { color: #93c5fd; border-bottom-color: #60a5fa; }
[data-theme="dark"] .tab-hint .tab-hint-h,
:root:not([data-theme="light"]) .tab-hint .tab-hint-h { color: #93c5fd; }
[data-theme="dark"] .tab-hint .tab-hint-mini,
:root:not([data-theme="light"]) .tab-hint .tab-hint-mini { color: #93c5fd; }

/* ========================================
   復習モードセレクタ
======================================== */
.review-mode-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    background: var(--bg-surface);
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.review-mode-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 64px;
    padding: 10px 6px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-light);
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;
}
.review-mode-btn .review-mode-icon {
    font-size: 1.4rem;
    line-height: 1;
}
.review-mode-btn .review-mode-label {
    font-size: 0.85rem;
    white-space: nowrap;
}
.review-mode-btn:hover { background: rgba(66,153,225,0.10); color: var(--text-primary); }
.review-mode-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.review-mode-btn.active:hover { background: var(--primary); color: #fff; }
@media (max-width: 480px) {
    .review-mode-selector { gap: 6px; padding: 5px; }
    .review-mode-btn { min-height: 60px; padding: 8px 4px; }
    .review-mode-btn .review-mode-icon { font-size: 1.3rem; }
    .review-mode-btn .review-mode-label { font-size: 0.78rem; }
}

.chapter-review-setup {
    background: var(--card-bg);
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}
.chapter-review-count {
    margin: 8px 0 12px;
    font-size: 0.85rem;
    color: var(--text-light);
}
.chapter-review-chapter-toolbar {
    display: flex;
    gap: 8px;
    margin: 6px 0 8px;
    flex-wrap: wrap;
}
.chapter-review-chapter-list {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px;
    background: var(--bg-color);
}
.chapter-review-chapter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.1s;
    min-height: 40px;
}
.chapter-review-chapter-item:hover {
    background: var(--hover-bg, rgba(0,0,0,0.04));
}
.chapter-review-chapter-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin: 0;
}
.chapter-review-chapter-name {
    flex: 1 1 auto;
    font-size: 0.9rem;
    color: var(--text-dark);
    word-break: break-word;
}
.chapter-review-chapter-count {
    font-size: 0.78rem;
    color: var(--text-light);
    flex-shrink: 0;
}
@media (max-width: 480px) {
    .chapter-review-chapter-list { max-height: 220px; }
    .chapter-review-chapter-item { padding: 10px 8px; min-height: 44px; }
    .chapter-review-chapter-name { font-size: 0.85rem; }
}
.chapter-review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}
.chapter-review-path {
    font-size: 0.85rem;
    color: var(--text-dark);
    font-weight: 600;
}

/* ========================================
   統計：教材・単元別の詳細ツリー
======================================== */
.stats-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 10px;
}

#stats-detailed-tree details {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    overflow: hidden;
}

#stats-detailed-tree summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.88rem;
    color: var(--text-dark);
    background: var(--bg-surface);
    user-select: none;
}
#stats-detailed-tree summary::-webkit-details-marker { display: none; }
#stats-detailed-tree summary::before {
    content: '▶';
    font-size: 0.65rem;
    color: var(--text-light);
    margin-right: 4px;
    transition: transform var(--transition-fast);
}
#stats-detailed-tree details[open] > summary::before {
    transform: rotate(90deg);
}
#stats-detailed-tree summary:hover {
    background: var(--question-bg);
}

.stats-node-name {
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-node-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.stats-node-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--bg-surface);
    color: var(--text-light);
    border: 1px solid var(--border-color);
    white-space: nowrap;
}
.stats-badge-total { background: rgba(66,153,225,0.12); color: var(--primary); border-color: rgba(66,153,225,0.3); }
.stats-badge-mastered { background: rgba(39,174,96,0.12); color: var(--eval-a); border-color: rgba(39,174,96,0.3); }
.stats-badge-acc-high { background: rgba(39,174,96,0.15); color: var(--eval-a); border-color: rgba(39,174,96,0.35); }
.stats-badge-acc-mid { background: rgba(243,156,18,0.15); color: var(--eval-b); border-color: rgba(243,156,18,0.35); }
.stats-badge-acc-low { background: rgba(231,76,60,0.15); color: var(--eval-c); border-color: rgba(231,76,60,0.35); }
.stats-badge-unlearned { background: rgba(148,163,184,0.15); color: var(--text-light); }

.stats-tree-subject-body {
    padding: 10px 14px 12px;
}
.stats-tree-book-body {
    padding: 8px 10px 10px;
}

.stats-tree-book {
    margin-top: 8px;
    background: var(--question-bg);
    border: 1px solid var(--border-color);
}
.stats-tree-book > summary {
    background: transparent;
    padding: 8px 12px;
    font-size: 0.83rem;
}

.stats-tree-chapter {
    padding: 8px 10px;
    margin-top: 6px;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}
.stats-chapter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.stats-mini-bar {
    display: flex;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-surface);
    margin-top: 6px;
}
.stats-mini-bar-empty {
    font-size: 0.7rem;
    color: var(--text-light);
    height: auto;
    padding: 4px 8px;
    background: transparent;
}
.stats-mini-seg { height: 100%; }
.stats-mini-seg.seg-s { background: var(--eval-s); }
.stats-mini-seg.seg-a { background: var(--eval-a); }
.stats-mini-seg.seg-b { background: var(--eval-b); }
.stats-mini-seg.seg-c { background: var(--eval-c); }
.stats-mini-seg.seg-d { background: var(--eval-d); }
.stats-mini-seg.seg-e { background: var(--eval-e); }

@media (max-width: 480px) {
    .stats-node-badge { font-size: 0.65rem; padding: 1px 5px; }
    .stats-node-name { font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        transition-delay: 0ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========================================
   使い方タブ
======================================== */
.usage-guide {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 4px 40px;
}

.usage-toc {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.usage-toc h3 {
    color: var(--primary);
    font-size: 1rem;
    margin-bottom: 10px;
}

.usage-toc ol {
    padding-left: 1.4em;
    margin: 0;
}

.usage-toc li {
    margin: 6px 0;
    line-height: 1.5;
}

.usage-toc a {
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
}

.usage-toc a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.usage-section {
    margin-bottom: 14px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    scroll-margin-top: 12px;
    overflow: hidden;
}

details.usage-section > summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 18px;
    color: var(--primary);
    font-size: 1rem;
    font-weight: 700;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background var(--transition-fast);
}
details.usage-section > summary::-webkit-details-marker { display: none; }
details.usage-section > summary::after {
    content: '▼';
    font-size: 0.7em;
    color: var(--text-light);
    transition: transform 0.2s ease;
    margin-left: 8px;
    flex-shrink: 0;
}
details.usage-section[open] > summary::after { transform: rotate(180deg); }
details.usage-section > summary:hover { background: var(--bg-surface); }
details.usage-section[open] > summary {
    border-bottom: 1px solid var(--border-color);
}

.usage-section-body {
    padding: 14px 18px 18px;
}

.usage-section-body h4 {
    color: var(--primary);
    font-size: 0.95rem;
    margin: 18px 0 6px;
    padding-top: 2px;
}

.usage-section-body > *:first-child {
    margin-top: 0;
}

.usage-section-body p {
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--text-dark);
    margin: 8px 0;
}

.usage-section-body p + p {
    margin-top: 12px;
}

.usage-section-body ul,
.usage-section-body ol {
    padding-left: 1.4em;
    margin: 8px 0 12px;
}

.usage-section-body li {
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.usage-section-body li:last-child {
    margin-bottom: 0;
}

.usage-tip {
    background: var(--bg-surface);
    border-left: 3px solid var(--accent);
    padding: 12px 14px;
    margin: 16px 0;
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text-dark);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ========================================
   初回オンボーディング
======================================== */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay, rgba(0,0,0,0.6));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    animation: fadeIn 0.25s ease;
    backdrop-filter: blur(6px);
    padding: 20px;
}

.onboarding-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 32px 28px 24px;
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    position: relative;
    color: var(--text-dark);
}

.onboarding-skip {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    text-decoration: underline;
}

.onboarding-skip:hover {
    color: var(--primary);
}

.onboarding-slides {
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.onboarding-slide {
    text-align: center;
    padding: 10px 4px;
    animation: fadeIn 0.3s ease;
}

.onboarding-emoji {
    font-size: 3.5rem;
    margin-bottom: 12px;
    line-height: 1;
}

.onboarding-slide h2 {
    color: var(--primary);
    font-size: 1.15rem;
    margin-bottom: 12px;
    line-height: 1.4;
}

.onboarding-slide p {
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-dark);
    margin: 0 auto;
    max-width: 32em;
    text-align: left;
    word-break: normal;
    overflow-wrap: anywhere;
    line-break: strict;
}

.onboarding-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 20px 0 16px;
}

.onboarding-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-color);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background var(--transition-normal);
}

.onboarding-dot.active {
    background: var(--accent);
}

.onboarding-nav {
    display: flex;
    gap: 10px;
}

.onboarding-nav .btn {
    flex: 1;
}

.onboarding-nav .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
