/**
 * 英検準1級 スコア詳細（共用）— リザルト画面 / マイページモーダル 両方で読み込む
 * 数値・配色は 2級 assets/grade2/eiken-grade2-score-detail.css に合わせる。
 * すべて .eiken-pre1-score-detail 配下にスコープ。
 */
.eiken-pre1-score-detail {
    --bg: #f4f7f4; --card: #ffffff; --ink: #1f2937; --muted: #6b7280;
    --acc: #16a34a; --acc-deep: #15803d; --acc-soft: #f0fdf4; --acc-line: #bbf7d0;
    --line: #e5e7eb; --blue: #0066cc; --red: #ef4444;
    --good: #15803d; --warn: #d97706; --bad: #dc2626;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
    color: var(--ink);
    line-height: 1.6;
    font-size: 14px;
}
@media (prefers-color-scheme: dark) {
    body:not([data-eiken-theme="light"]) .eiken-pre1-score-detail {
        --bg: #12160f; --card: #1b2118; --ink: #e7ede6; --muted: #9aa79a;
        --acc: #37b24d; --acc-deep: #4ade80; --acc-soft: #182b1c; --acc-line: #2f4a33;
        --line: #2c352b; --blue: #6fb2ff; --red: #f87171;
        --good: #4ade80; --warn: #fbbf24; --bad: #f87171;
    }
}
.eiken-pre1-score-detail * { box-sizing: border-box; }
.eiken-pre1-score-detail h1, .eiken-pre1-score-detail h2,
.eiken-pre1-score-detail h3, .eiken-pre1-score-detail h4, .eiken-pre1-score-detail p { margin: 0; }
.eiken-pre1-score-detail button { font: inherit; cursor: pointer; }

/* ── summary ── */
.eiken-pre1-score-detail .sd-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.eiken-pre1-score-detail .sd-summary > div { background: var(--acc-soft); border: 1px solid var(--acc-line); border-radius: 8px; padding: 8px 4px; text-align: center; }
.eiken-pre1-score-detail .sd-summary .lbl { font-size: 11px; color: var(--acc-deep); }
.eiken-pre1-score-detail .sd-summary .val { font-size: 18px; font-weight: bold; color: var(--acc-deep); font-variant-numeric: tabular-nums; }
.eiken-pre1-score-detail .sd-summary .val small { font-weight: bold; }
.eiken-pre1-score-detail .sd-summary .sd-total { background: var(--acc); border-color: var(--acc-deep); }
.eiken-pre1-score-detail .sd-summary .sd-total .lbl { color: #fff; font-weight: 700; }
.eiken-pre1-score-detail .sd-summary .sd-total .val { color: #fff; font-size: 21px; }
.eiken-pre1-score-detail .sd-note { font-size: 10.5px; color: #9ca3af; text-align: center; margin: -12px 0 16px; }

/* ── phase card ── */
.eiken-pre1-score-detail .sd-phase { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; overflow: hidden; background: var(--card); }
.eiken-pre1-score-detail .sd-phase-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 14px; background: var(--acc); color: #fff; user-select: none; font-size: 14px; cursor: pointer; }
.eiken-pre1-score-detail .sd-phase-h .ttl { display: flex; align-items: center; gap: 8px; font-weight: bold; min-width: 0; }
.eiken-pre1-score-detail .sd-phase-h .arw { font-size: 10px; transition: transform .16s; flex-shrink: 0; }
.eiken-pre1-score-detail .sd-phase:not(.is-collapsed) .sd-phase-h .arw { transform: rotate(90deg); }
.eiken-pre1-score-detail .sd-phase-h .sc { font-weight: bold; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.eiken-pre1-score-detail .sd-phase.is-collapsed .sd-phase-body { display: none; }
.eiken-pre1-score-detail .sd-phase:not(.is-collapsed) .sd-phase-cards { display: none; }
.eiken-pre1-score-detail .sd-phase-cards { padding: 12px 14px; }
.eiken-pre1-score-detail .sd-phase-body { padding: 12px 14px; font-size: 13px; line-height: 1.6; }
.eiken-pre1-score-detail .sd-more { display: block; width: 100%; margin-top: 12px; padding: 8px; background: var(--card); border: 1px solid var(--acc); border-radius: 8px; color: var(--acc-deep); font-size: 12.5px; font-weight: 700; }
.eiken-pre1-score-detail .sd-more:hover { background: var(--acc-soft); }

/* ── per-item ── */
.eiken-pre1-score-detail .sd-item { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 11px; background: var(--card); }
.eiken-pre1-score-detail .sd-item:last-child { margin-bottom: 0; }

/* panel crop */
.eiken-pre1-score-detail .sd-panelclip { position: relative; overflow: hidden; border-radius: 8px; margin: 0 auto 10px; max-width: 250px; line-height: 0; }
.eiken-pre1-score-detail .sd-panelclip img { display: block; }
.eiken-pre1-score-detail .sd-panel-lbl { position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%); font-size: 22px; font-weight: 800; color: #fff; background: rgba(21, 128, 61, .5); border-radius: 12px; padding: 2px 14px; line-height: 1.5; letter-spacing: .02em; }

/* ── stat tiles ── */
.eiken-pre1-score-detail .sd-stats { display: flex; gap: 8px; margin: 8px 0 9px; }
.eiken-pre1-score-detail .sd-stat { flex: 1 1 0; min-width: 0; background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; padding: 7px 6px; text-align: center; position: relative; cursor: pointer; }
.eiken-pre1-score-detail .sd-stat:hover { background: #eff6ff; border-color: #bfdbfe; }
.eiken-pre1-score-detail .sd-stat .k { font-size: 11px; font-weight: 600; color: #6b7280; margin-bottom: 2px; display: flex; align-items: center; justify-content: center; gap: 3px; }
.eiken-pre1-score-detail .sd-stat .k i { width: 13px; height: 13px; border-radius: 50%; background: #d1d5db; color: #fff; font-size: 9px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-style: normal; }
.eiken-pre1-score-detail .sd-stat:hover .k i { background: #3b82f6; }
.eiken-pre1-score-detail .sd-stat .v { font-size: 14px; font-weight: 700; color: var(--blue); font-variant-numeric: tabular-nums; }
.eiken-pre1-score-detail .sd-stat .v small { font-size: 11px; color: #6b7280; font-weight: 600; margin-left: 2px; }
.eiken-pre1-score-detail .sd-stat.neg .v { color: var(--bad); }
.eiken-pre1-score-detail .sd-stat.sd-stat-total { background: var(--acc-soft); border-color: var(--acc-line); }
.eiken-pre1-score-detail .sd-stat.sd-stat-total .k { color: var(--acc-deep); }
.eiken-pre1-score-detail .sd-stat.sd-stat-total .v,
.eiken-pre1-score-detail .sd-stat.sd-stat-total .v small { color: var(--acc-deep); font-weight: 800; }
/* コマ1〜4＋合計 の1行（4コマ折りたたみ） */
.eiken-pre1-score-detail .sd-stats-koma .sd-stat { cursor: default; }
.eiken-pre1-score-detail .sd-stats-koma .sd-stat:hover { background: #f9fafb; border-color: var(--line); }
.eiken-pre1-score-detail .sd-stats-koma .sd-stat.sd-stat-total,
.eiken-pre1-score-detail .sd-stats-koma .sd-stat.sd-stat-total:hover { background: var(--acc); border-color: var(--acc-deep); }
.eiken-pre1-score-detail .sd-stats-koma .sd-stat.sd-stat-total .k,
.eiken-pre1-score-detail .sd-stats-koma .sd-stat.sd-stat-total .v { color: #fff; }
.eiken-pre1-score-detail .sd-stats-koma .sd-stat.sd-stat-total .v small { color: rgba(255, 255, 255, .85); }
/* 「採点対象外」タイル：グレーアウト＋斜線 */
.eiken-pre1-score-detail .sd-stat.is-na,
.eiken-pre1-score-detail .sd-stat.is-na:hover { background: #f3f4f6; border-color: var(--line); overflow: hidden; cursor: default; }
.eiken-pre1-score-detail .sd-stat.is-na .k,
.eiken-pre1-score-detail .sd-stat.is-na .v { color: #9ca3af; position: relative; z-index: 1; }
.eiken-pre1-score-detail .sd-stat.is-na .v { font-size: 10px; font-weight: 700; line-height: 1.25; white-space: nowrap; letter-spacing: 0; }
.eiken-pre1-score-detail .sd-stat.is-na:hover .k i { background: #d1d5db; }
.eiken-pre1-score-detail .sd-stat.is-na::after { content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; background: linear-gradient(to top left, transparent calc(50% - .6px), #c9ccd1 calc(50% - .6px), #c9ccd1 calc(50% + .6px), transparent calc(50% + .6px)); }

/* ── transcript / model / question ── */
.eiken-pre1-score-detail .sd-tr { background: var(--bg); border-radius: 7px; padding: 7px 10px; font-size: 12px; color: var(--ink); margin: 8px 0; }
.eiken-pre1-score-detail .sd-tr b { color: var(--muted); font-weight: 700; font-size: 10px; letter-spacing: .06em; display: block; margin-bottom: 2px; }
.eiken-pre1-score-detail .sd-tp-line { font-size: 12px; color: var(--muted); margin: 6px 0 8px; line-height: 1.7; }
.eiken-pre1-score-detail .sd-tp-line b { color: var(--ink); font-weight: 700; }
.eiken-pre1-score-detail .sd-q { background: color-mix(in srgb, var(--red) 9%, var(--card)); border-left: 3px solid var(--red); border-radius: 0 7px 7px 0; padding: 7px 11px; font-size: 12px; margin-bottom: 8px; text-align: center; }
.eiken-pre1-score-detail .sd-q b { color: var(--muted); font-weight: 800; font-size: 10px; letter-spacing: .06em; }
.eiken-pre1-score-detail .sd-modelbtn { display: inline-block; margin-top: 2px; background: var(--acc); color: #fff; border: 0; border-radius: 6px; padding: 4px 11px; font-size: 11px; font-weight: 800; }
.eiken-pre1-score-detail .sd-model { background: var(--acc-soft); border: 1px solid var(--acc-line); border-radius: 8px; padding: 9px 12px; font-size: 12px; color: var(--acc-deep); line-height: 1.65; margin-top: 8px; }
.eiken-pre1-score-detail .sd-model[hidden] { display: none; }

/* ── audio player（!important でテーマの button/svg/flex 上書きに勝つ） ── */
.eiken-pre1-score-detail .sd-player { display: flex !important; align-items: center !important; gap: 9px !important; margin: 8px 0 3px !important; width: 100% !important; }
.eiken-pre1-score-detail .sd-audio { display: none !important; }
.eiken-pre1-score-detail .sd-play { flex: 0 0 28px !important; width: 28px !important; height: 28px !important; min-width: 28px !important; border: 0 !important; background: none !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; -webkit-appearance: none !important; appearance: none !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; line-height: 0 !important; }
.eiken-pre1-score-detail .sd-play svg { display: block !important; width: 28px !important; height: 28px !important; }
.eiken-pre1-score-detail .sd-play:hover { opacity: .82 !important; }
.eiken-pre1-score-detail .sd-track { position: relative !important; flex: 1 1 auto !important; min-width: 0 !important; height: 24px !important; background: #eceff3 !important; border: 0 !important; border-radius: 0 !important; overflow: hidden !important; cursor: pointer !important; }
.eiken-pre1-score-detail .sd-track-fill { position: absolute !important; left: 0; top: 0; bottom: 0; width: 0; background: rgba(22, 163, 74, .16) !important; pointer-events: none; }
.eiken-pre1-score-detail .sd-track-sil { position: absolute !important; inset: 0; pointer-events: none; }
.eiken-pre1-score-detail .sd-track-sil i { position: absolute !important; top: 0; bottom: 0; background: rgba(220, 38, 38, .42) !important; }
.eiken-pre1-score-detail .sd-track-fil { position: absolute !important; inset: 0; pointer-events: none; }
.eiken-pre1-score-detail .sd-track-fil i { position: absolute !important; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #2563eb !important; }
.eiken-pre1-score-detail .sd-track-head { position: absolute !important; top: 0; bottom: 0; width: 2px; background: var(--acc-deep) !important; left: 0; pointer-events: none; }
.eiken-pre1-score-detail .sd-ptime { flex: 0 0 auto !important; font-size: 10px !important; color: var(--muted) !important; font-variant-numeric: tabular-nums; white-space: nowrap !important; }
.eiken-pre1-score-detail .sd-plegend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 10px; font-weight: 700; color: var(--muted); margin: 0 0 6px 37px; }

/* ── content items ── */
.eiken-pre1-score-detail .sd-ci { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; padding: 5px 8px; border-radius: 6px; margin-bottom: 4px; background: var(--bg); }
.eiken-pre1-score-detail .sd-ci.hit { background: var(--acc-soft); }
.eiken-pre1-score-detail .sd-ci .mk { flex: 0 0 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.eiken-pre1-score-detail .sd-ci.hit .mk { color: var(--good); }
.eiken-pre1-score-detail .sd-ci.miss .mk { color: var(--muted); }
.eiken-pre1-score-detail .sd-ci .tag-speech { flex: 0 0 auto; font-size: 9px; font-weight: 800; color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--blue) 32%, var(--card)); padding: 1px 6px; border-radius: 4px; align-self: center; cursor: help; white-space: nowrap; }
.eiken-pre1-score-detail .sd-ci .tx { flex: 1; min-width: 0; color: var(--ink); }
.eiken-pre1-score-detail .sd-ci .tx.empty { color: var(--muted); font-style: italic; }

/* ── Q2-4 文別コメント ── */
.eiken-pre1-score-detail .sd-qsent { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; margin-bottom: 6px; background: var(--card); }
.eiken-pre1-score-detail .sd-qsent.on { background: var(--acc-soft); border-color: var(--acc-line); }
.eiken-pre1-score-detail .sd-qsent.partial { background: #fffbeb; border-color: #fde68a; }
.eiken-pre1-score-detail .sd-qsent.partial .qs-line .sc,
.eiken-pre1-score-detail .sd-qsent.partial .qs-cm { color: #b45309; }
.eiken-pre1-score-detail .sd-qsent .qs-line { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 1.55; }
.eiken-pre1-score-detail .sd-qsent .qs-line .sc { flex: 0 0 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.eiken-pre1-score-detail .sd-qsent.on .qs-line .sc { color: var(--good); }
.eiken-pre1-score-detail .sd-qsent.off .qs-line .sc { color: var(--muted); }
.eiken-pre1-score-detail .sd-qsent .qs-t { color: var(--ink); }
.eiken-pre1-score-detail .sd-qsent .qs-cm { margin-top: 4px; padding-left: 38px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.eiken-pre1-score-detail .sd-qsent.on .qs-cm { color: var(--acc-deep); }

/* ── corrections / mistakes ── */
.eiken-pre1-score-detail .sd-corr { background: color-mix(in srgb, var(--warn) 9%, var(--card)); border-radius: 7px; padding: 7px 10px; font-size: 11.5px; margin-top: 8px; }
.eiken-pre1-score-detail .sd-corr .ch { font-size: 10px; font-weight: 800; color: var(--muted); letter-spacing: .04em; margin-bottom: 3px; }
.eiken-pre1-score-detail .sd-corr .row { margin-bottom: 2px; }
.eiken-pre1-score-detail .sd-corr del { color: var(--bad); text-decoration: line-through; }
.eiken-pre1-score-detail .sd-corr ins { color: var(--good); text-decoration: none; font-weight: 700; }
.eiken-pre1-score-detail .sd-mistake-hd { font-size: 11px; font-weight: 800; color: var(--muted); margin: 8px 0 2px; }

/* ── attitude table ── */
.eiken-pre1-score-detail .sd-att-fig { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.eiken-pre1-score-detail .sd-att-fig b { font-size: 22px; color: var(--acc-deep); font-weight: 800; font-variant-numeric: tabular-nums; display: block; }
.eiken-pre1-score-detail .sd-mini { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 4px; }
.eiken-pre1-score-detail .sd-mini th, .eiken-pre1-score-detail .sd-mini td { border: 1px solid var(--line); padding: 6px 4px; text-align: center; }
.eiken-pre1-score-detail .sd-mini thead th { background: var(--acc-soft); color: var(--acc-deep); font-weight: 800; }
.eiken-pre1-score-detail .sd-mini tbody th { font-weight: 700; }
.eiken-pre1-score-detail .sd-mini tr.hit td, .eiken-pre1-score-detail .sd-mini tr.hit th { background: var(--acc-soft); font-weight: 800; color: var(--acc-deep); }

/* ── tooltip（body 直下に append される） ── */
.sd-tip { position: fixed; z-index: 100000; width: 250px; max-width: calc(100vw - 20px); background: #fff; color: #1f2937; border: 1px solid #e5e7eb; border-radius: 9px; box-shadow: 0 12px 32px rgba(0, 0, 0, .22); padding: 10px 12px; font-size: 11.5px; line-height: 1.55; }
.sd-tip.is-wide { width: 290px; }
.sd-tip .tt { font-weight: 800; color: #15803d; margin-bottom: 5px; font-size: 12px; }
.sd-tip table { width: 100%; border-collapse: collapse; }
.sd-tip td { border: 1px solid #e5e7eb; padding: 3px 7px; vertical-align: middle; }
.sd-tip td:first-child { background: #f0fdf4; color: #15803d; font-weight: 800; white-space: nowrap; text-align: center; width: 1%; }
.sd-tip tr.tgap td { border: none; background: transparent; padding: 0; height: 7px; }
.sd-tip table.tgrid td { text-align: center; white-space: nowrap; }
.sd-tip table.tgrid td.th { background: #f0fdf4; color: #15803d; font-weight: 800; width: 1%; }
.sd-tip .tnote { margin-top: 6px; color: #6b7280; line-height: 1.6; }
@media (prefers-color-scheme: dark) {
    body:not([data-eiken-theme="light"]) .sd-tip { background: #1b2118; color: #e7ede6; border-color: #2c352b; }
    body:not([data-eiken-theme="light"]) .sd-tip .tt,
    body:not([data-eiken-theme="light"]) .sd-tip td:first-child,
    body:not([data-eiken-theme="light"]) .sd-tip table.tgrid td.th { color: #4ade80; background: #182b1c; }
    body:not([data-eiken-theme="light"]) .sd-tip td { border-color: #2c352b; }
    body:not([data-eiken-theme="light"]) .sd-tip .tnote { color: #9aa79a; }
}

/* ── モバイル（枠幅ではなくビューポート） ── */
@media (max-width: 560px) {
    .eiken-pre1-score-detail .sd-summary { grid-template-columns: repeat(3, 1fr); }
    .eiken-pre1-score-detail .sd-summary .sd-total { grid-column: 1 / -1; order: -1; }
    .eiken-pre1-score-detail .sd-stats { gap: 4px; }
    .eiken-pre1-score-detail .sd-stat { padding: 6px 2px; }
    .eiken-pre1-score-detail .sd-stat .k { font-size: 9.5px; }
    .eiken-pre1-score-detail .sd-stat .v { font-size: 11.5px; white-space: nowrap; letter-spacing: -.02em; }
    .eiken-pre1-score-detail .sd-stat .v small { font-size: 8.5px; margin-left: 1px; }
    .eiken-pre1-score-detail .sd-stat.is-na .v { font-size: 9px; white-space: normal; line-height: 1.2; }
    .eiken-pre1-score-detail .sd-stat .k i { width: 11px; height: 11px; font-size: 8px; }
    .eiken-pre1-score-detail .sd-qsent .qs-cm { padding-left: 0; margin-top: 5px; }
}
