/* 受講者UI — モバイル優先 */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
    font-size: 19px;
    font-weight: 500;
    line-height: 1.7;
    color: #1f2937;
    background: #f8fafc;
}
a { color: #1d4ed8; text-decoration: none; }

.topbar { background: #0f766e; color: #fff; }
.topbar-inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.topbar .brand { font-weight: 600; }
.topbar .btn-text { color: #d1fae5; }

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px;
}
h1 { font-size: 24px; margin: 0 0 10px; }
h2 { font-size: 19px; margin: 20px 0 8px; }
h3 { font-size: 19px; margin: 0 0 8px; }
.muted { color: #111827; }
.section { margin-top: 16px; }

/* === 認証画面 === */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: #ecfdf5;
}
.auth-card {
    background: #fff;
    border: 1px solid #d1fae5;
    border-radius: 12px;
    padding: 28px 22px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.auth-card h1 { margin: 0 0 4px; font-size: 18px; color: #064e3b; }
.auth-subtitle { margin: 0 0 20px; color: #111827; font-size: 16px; }

/* === フォーム共通 === */
form label { display: block; margin-bottom: 14px; }
form label > span { display: block; font-size: 15px; color: #111827; margin-bottom: 4px; }
form input[type="text"],
form input[type="password"],
form input[type="email"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
}
form input:focus,
form textarea:focus {
    outline: 2px solid #0d9488;
    outline-offset: 1px;
    border-color: #0d9488;
}
form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    min-height: 140px;
}
form small.muted { display: block; margin-top: 4px; font-size: 14px; }

/* === ボタン === */
.btn {
    display: inline-block;
    padding: 12px 18px;
    font-size: 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: center;
}
.btn-primary  { background: #0d9488; color: #fff; width: 100%; margin-top: 8px; }
.btn-primary:hover  { background: #0f766e; }
.btn-secondary { background: #fff; color: #0f766e; border-color: #0d9488; }
.btn-secondary:hover { background: #f0fdfa; }
.btn-inline { width: auto; margin-top: 0; padding: 10px 14px; font-size: 14px; }
.btn-text { color: #0f766e; text-decoration: underline; font-size: 14px; }
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 20px; flex-wrap: wrap; }

/* === アラート === */
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; font-size: 16px; }
.alert-error   { background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* === セットリスト（ダッシュボード・履歴）=== */
.set-list { list-style: none; padding: 0; margin: 0; }
.set-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    background: #fff;
    border: 1px solid #d1fae5;
    border-radius: 10px;
    margin-bottom: 10px;
}
.set-name { flex: 1; font-weight: 600; min-width: 0; word-break: break-word; }
.set-name .muted { font-weight: 400; font-size: 16px; color: #111827; }
.set-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

/* === クイックアクション（復習・分析・サポート）=== */
.quick-actions { margin-top: 16px; }
.quick-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.quick-card {
    display: block;
    background: #fff;
    border: 1px solid #d1fae5;
    border-radius: 10px;
    padding: 12px 10px;
    color: #064e3b;
    transition: background .1s;
}
.quick-card:hover { background: #f0fdfa; }
.quick-card.disabled { opacity: 0.45; pointer-events: none; }
.quick-card .quick-title { font-weight: 700; font-size: 17px; }
.quick-card .quick-sub   { font-size: 14px; color: #111827; margin-top: 3px; }

/* === 問題カード === */
.q-card {
    background: #fff;
    border: 1px solid #d1fae5;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}
.q-card h3 { color: #064e3b; }
.q-text { white-space: pre-wrap; line-height: 1.7; margin: 0 0 12px; font-weight: 500; }

.q-choice {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 14px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
}
.q-choice:hover { background: #f0fdfa; }
.q-choice input[type="radio"] { margin-top: 4px; transform: scale(1.3); flex-shrink: 0; }
.q-choice.readonly { cursor: default; }
.q-choice.readonly:hover { background: transparent; }
.q-choice .choice-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #e5e7eb;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}
.q-choice.choice-correct { background: #ecfdf5; border-color: #6ee7b7; }
.q-choice.choice-wrong   { background: #fef2f2; border-color: #fca5a5; }
.q-choice .badge {
    margin-left: auto;
    font-size: 13px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #111827;
    white-space: nowrap;
    flex-shrink: 0;
}
.q-choice .badge-correct { background: #10b981; color: #fff; }
.mark-ok { color: #047857; font-size: 16px; margin-left: 8px; }
.mark-ng { color: #b91c1c; font-size: 16px; margin-left: 8px; }

/* === 結果サマリー === */
.result-summary {
    background: #fff;
    border: 2px solid #d1fae5;
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    margin-bottom: 20px;
}
.result-summary.pass { border-color: #10b981; background: #ecfdf5; }
.result-summary.fail { border-color: #f59e0b; background: #fffbeb; }
.result-summary .score   { font-size: 19px; }
.result-summary .percent { font-size: 38px; font-weight: 700; margin: 4px 0; color: #064e3b; }
.result-summary .judge   { font-size: 17px; color: #111827; }

.explanation, .source {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f9fafb;
    border-left: 3px solid #0d9488;
    border-radius: 4px;
    font-size: 17px;
    font-weight: 500;
    line-height: 1.7;
    color: #111827;
}
.source { border-left-color: #374151; }

/* === タイマー === */
body.has-timer { padding-top: 52px; }
.timer-bar {
    position: fixed; top: 0; left: 0; right: 0;
    background: #0d9488; color: #fff;
    text-align: center; font-weight: 600; font-size: 15px;
    padding: 12px;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.timer-bar #timer-display {
    font-variant-numeric: tabular-nums;
    font-size: 20px;
    margin-left: 6px;
}
.timer-bar.timer-warn   { background: #d97706; }
.timer-bar.timer-danger { background: #dc2626; animation: timer-blink 1s infinite; }
@keyframes timer-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.7; }
}

/* === 復習 章見出し === */
.chapter-divider {
    margin: 24px 0 10px;
    padding: 8px 12px;
    background: #ecfdf5;
    border-left: 4px solid #0d9488;
    color: #064e3b;
    font-size: 17px;
    font-weight: 600;
    border-radius: 4px;
}

/* === 成績分析 バー === */
.bar-list { list-style: none; padding: 0; margin: 0; }
.bar-row {
    display: grid;
    grid-template-columns: 150px 1fr 90px;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}
.bar-label { font-size: 16px; }
.bar-track {
    background: #e5e7eb;
    border-radius: 999px;
    height: 14px;
    overflow: hidden;
}
.bar-fill {
    background: linear-gradient(90deg, #0d9488, #10b981);
    height: 100%;
    transition: width .4s;
}
.bar-value { font-size: 16px; color: #111827; text-align: right; }

/* === 誤答一覧 === */
.wrong-list { list-style: none; padding: 0; margin: 0; }
.wrong-item {
    background: #fff;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
}
.wrong-meta { font-size: 16px; color: #111827; font-weight: 500; margin-bottom: 6px; }
.wrong-q    { font-size: 17px; font-weight: 500; line-height: 1.6; margin-bottom: 8px; }
.wrong-ans  { display: flex; gap: 8px; flex-wrap: wrap; }
.wrong-ans .badge      { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: #e5e7eb; color: #111827; }
.wrong-ans .badge.bad  { background: #fee2e2; color: #991b1b; }
.wrong-ans .badge.good { background: #d1fae5; color: #065f46; }

/* ============================================
   レスポンシブ — 640px以下（大型スマホ含む）
   ============================================ */
@media (max-width: 640px) {
    .set-item { flex-direction: column; align-items: stretch; }
    .set-actions { flex-direction: row; flex-wrap: wrap; }
    .set-actions .btn-inline { flex: 1; text-align: center; min-width: 120px; }

    .quick-grid { grid-template-columns: repeat(2, 1fr); }

    .bar-row { grid-template-columns: 1fr 70px; }
    .bar-label { grid-column: 1 / -1; margin-bottom: 0; }
}

/* ============================================
   レスポンシブ — 480px以下（標準スマホ）
   ============================================ */
@media (max-width: 480px) {
    .container { padding: 16px 12px; }

    .quick-grid { grid-template-columns: 1fr; gap: 6px; }
    .quick-card { padding: 10px 12px; }

    .bar-row { grid-template-columns: 1fr; gap: 3px; }
    .bar-value { text-align: left; }

    .set-actions { flex-direction: column; }
    .set-actions .btn-inline { width: 100%; }

    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions .btn-inline { width: 100%; text-align: center; }

    .q-choice { padding: 12px 10px; }
}

/* ============================================
   漢字の勉強画面（kanji.php）
   ============================================ */
.container-wide { max-width: 1080px; }

.kanji-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 16px;
    margin-bottom: 24px;
}
.kanji-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
}
.kanji-card .term {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 4px;
    text-align: center;
    color: #111827;
    line-height: 1.2;
}
.kanji-card .reading {
    font-size: 15px;
    color: #374151;
    margin: 0 0 14px;
    text-align: center;
}
.kanji-card .en {
    font-size: 17px;
    font-weight: 700;
    color: #2563eb;
    margin: 0 0 12px;
    text-align: center;
    line-height: 1.4;
}
.kanji-card .ja {
    font-size: 16px;
    font-weight: 500;
    color: #111827;
    line-height: 1.7;
    margin: 0;
}

@media (max-width: 720px) {
    .kanji-grid { grid-template-columns: 1fr; gap: 12px; }
    .kanji-card { padding: 16px 14px; }
    .kanji-card .term { font-size: 26px; }
}

/* ============================================
   成績分析の成績一覧テーブル
   ============================================ */
.table-wrap { overflow-x: auto; }
.score-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    font-size: 16px;
}
.score-table thead th {
    background: #f3f4f6;
    color: #111827;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
}
.score-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
    color: #111827;
}
.score-table tbody tr:last-child td { border-bottom: none; }
.score-table tbody tr:hover { background: #fafbfc; }
