/* ============================================================
   AAIA 問題演習（problem.html）
   CISA 復習アプリ（styles.v24.css）の構成を AAIA 用に移植。
   テーマ: daolin（既定・AAIA 本編と統一） / green
   フォント: システムフォント（外部フォントを読み込まない）
   ============================================================ */

/* === 道林纸 (クリーム黄 × 焦げ茶) — 既定 === */
:root, :root[data-theme="daolin"] {
  --bg: #efe4c4;
  --card: #fbf5dd;
  --ink: #2a1f12;
  --muted: #6b5a45;
  --line: #d4c39a;
  --blue: #1a4f7a;
  --blue-d: #0d3a60;
  --green: #e0d8b0;
  --green-b: #4d6a2e;
  --red: #ead8c8;
  --red-b: #a23a25;
  --orange: #b8561a;
  --secondary-bg: #ece2c0;
  --field-bg: #f3eccc;
  --core-bg: #f0e6c8;
  --weak-row-active: #d8c895;
  --opt-hover: var(--secondary-bg);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* === 護眼グリーン（切替用） === */
:root[data-theme="green"] {
  --bg: #dbe9dd;
  --card: #f1f8f2;
  --ink: #2d5a3a;
  --muted: #5d6f63;
  --line: #c9dccd;
  --blue: #1a73e8;
  --blue-d: #1557b0;
  --green: #d4ecd9;
  --green-b: #2f8f53;
  --red: #f7dcd8;
  --red-b: #d2493c;
  --orange: #e0651a;
  --secondary-bg: #dfeadf;
  --field-bg: #f6fbf7;
  --core-bg: #eaf5ed;
  --weak-row-active: #cfe4d5;
  --opt-hover: var(--secondary-bg);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", "Meiryo UI", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding: calc(var(--safe-t) + 12px) 14px calc(var(--safe-b) + 16px);
}

/* ヘッダー */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 12px;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; }
.topbar .sub { font-size: 12px; color: var(--muted); }
.exam-counter { text-align: right; line-height: 1.35; margin-left: auto; }
.exam-counter .sub { font-size: 12px; color: var(--muted); }
.exam-counter .sub.warn { color: var(--orange); font-weight: 700; }

/* カード */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(32,33,36,.04);
}
.card h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.card h3 { font-size: 14px; margin: 0 0 10px; color: var(--ink); font-weight: 700; }
.sep { border: none; border-top: 1px solid var(--line); margin: 18px 0 14px; }

/* ボタン */
.btn {
  display: block; width: 100%;
  background: var(--blue); color: #fff;
  border: none; border-radius: 14px;
  padding: 15px; font-size: 16px; font-weight: 600;
  cursor: pointer; margin: 8px 0;
  transition: filter .15s;
  font-family: inherit;
}
.btn:active { filter: brightness(.94); }
.btn.secondary { background: var(--secondary-bg); color: var(--blue-d); }
.btn.ghost { background: transparent; color: var(--blue); border: 1px solid var(--line); }
.btn.danger { background: var(--field-bg); color: var(--red-b); border: 1px solid var(--red-b); }
.btn:disabled { opacity: .5; }

/* 入力 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 13px 14px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--field-bg); color: var(--ink);
  font-family: inherit;
}
.field input[type="date"] {
  font-size: 17px; padding: 14px 14px; min-height: 52px;
  -webkit-appearance: none; appearance: none;
}

/* カウントダウン */
.countdown { text-align: center; padding: 40px 10px; }
.countdown .num { font-size: 88px; font-weight: 800; color: var(--blue); line-height: 1; }
.countdown .unit { font-size: 18px; color: var(--muted); margin-top: 4px; }
.countdown .label { font-size: 15px; margin-top: 18px; color: var(--ink); }
.countdown .name { font-size: 22px; font-weight: 700; margin-top: 6px; }

/* 統計グリッド */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat .v { font-size: 26px; font-weight: 800; }
.stat .k { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat .v small { font-size: 14px; font-weight: 600; color: var(--muted); }

/* 進捗バー */
.bar { height: 8px; background: var(--secondary-bg); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 99px; }

/* ドメイン行 */
.dom { padding: 12px 0; border-bottom: 1px solid var(--line); }
.dom:last-child { border-bottom: none; }
.dom .row { display: flex; justify-content: space-between; align-items: baseline; }
.dom .dn { font-weight: 700; }
.dom .dn.hot { color: var(--orange); }
.dom .pct { font-weight: 700; }
.dom .meta { font-size: 12px; color: var(--muted); }

/* 問題 */
.qhead { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.tag { display: inline-block; background: var(--secondary-bg); color: var(--blue-d); border-radius: 8px; padding: 2px 8px; font-weight: 600; }
.tag.hot { background: #fff1e6; color: var(--orange); }
.qtext { font-size: 16px; font-weight: 600; line-height: 1.65; margin: 4px 0 18px; color: var(--ink); }

/* ドメインナビ（問題解答画面）：該当ドメインのみ強調 */
.dom-nav { display: flex; flex-direction: row; justify-content: center; gap: 6px; margin: 4px 0 14px; }
.dn-item { min-width: 36px; text-align: center; font-size: 12px; font-weight: 700; padding: 5px 8px; border-radius: 14px; background: var(--line); color: var(--muted); opacity: .4; transition: opacity .15s, background .15s, color .15s; }
.dn-item.active { opacity: 1; background: var(--blue); color: #fff; }
.dn-item.hot.active { background: var(--orange); color: #fff; }

/* 選択肢 */
.opt {
  width: 100%; text-align: left;
  border: 1.5px solid var(--line); border-radius: 12px;
  padding: 11px 14px; margin: 6px 0;
  background: var(--card); font-size: 16px; line-height: 1.55; cursor: pointer;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  display: flex; gap: 10px; align-items: flex-start;
  transition: background .12s, border-color .12s;
  font-family: inherit;
}
.opt .k { font-weight: 800; min-width: 20px; }
.opt.correct { background: #f0fff4; border: 2px solid #22c55e; color: #166534; -webkit-text-fill-color: #166534; }
.opt.wrong   { background: #fff5f5; border: 2px solid #ef4444; color: #991b1b; -webkit-text-fill-color: #991b1b; }
.opt.selected{ background: #eff6ff; border: 2px solid #3b82f6; color: #1e40af; -webkit-text-fill-color: #1e40af; }
.opt:disabled { cursor: default; opacity: 1; }

/* 問題画面下部の Prev / Next */
.bottom-nav {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding-bottom: calc(12px + var(--safe-b));
}
.bottom-nav .btn { flex: 1; }
.bottom-nav .btn:disabled { opacity: .45; cursor: default; }

/* 解説ページ */
.exp .result { font-size: 15px; font-weight: 700; margin: 6px 0 14px; }
.exp .result.ok { color: var(--green-b); }
.exp .result.ng { color: var(--red-b); }
.exp h3 { font-size: 13px; color: var(--muted); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .03em; }
.exp .core { font-size: 15px; background: var(--core-bg); border-radius: 10px; padding: 10px 12px; }
.exp ul { margin: 4px 0; padding-left: 20px; }
.exp ul li { margin: 5px 0; }
.exp .jp { font-size: 14.5px; line-height: 1.7; }

/* テスト結果リスト */
.trow { display: flex; align-items: flex-start; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.trow:last-child { border-bottom: none; }
.mark { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; }
.mark.ok { background: var(--green); color: var(--green-b); }
.mark.ng { background: var(--red); color: var(--red-b); }
.tcontent { flex: 1 1 auto; min-width: 0; }
.tnum { font-size: 12px; color: var(--muted); }
.tkp { font-size: 14px; }
a.tkp-link { display: inline-block; font-size: 14px; color: var(--blue); text-decoration: underline; cursor: pointer; }
a.tkp-link:active { color: var(--blue-d); }

/* 結果 */
.bigscore { text-align: center; padding: 18px 0; }
.bigscore .s { font-size: 46px; font-weight: 800; color: var(--blue); }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 14px; }
.small { font-size: 13px; }
.spacer { height: 8px; }
.row { display: flex; align-items: center; }

/* 学習レポートグラフ */
.chartwrap { width: 100%; overflow-x: auto; }
.chartwrap svg { width: 100%; height: auto; display: block; }

/* テーマ設定 UI */
.theme-picker { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 14px; }
.theme-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.theme-card.active { border-color: var(--blue); border-width: 2px; padding: 11px 13px; }
.theme-card input[type="radio"] { margin: 0; }
.theme-swatch { display: flex; gap: 4px; }
.theme-swatch span { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.08); }
.theme-name { font-weight: 700; color: var(--ink); }
.theme-desc { font-size: 12px; color: var(--muted); }

/* よく間違える問題リスト */
.weak-row { padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.weak-row:last-child { border-bottom: none; }
.weak-row:active { background: var(--weak-row-active); }
.weak-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.weak-acc { font-weight: 800; font-size: 16px; color: var(--red-b); background: var(--red); border-radius: 8px; padding: 2px 8px; }
.weak-meta { font-size: 12px; color: var(--muted); }
.weak-tags { margin-left: auto; }
.weak-q { font-size: 14.5px; line-height: 1.55; }

/* データ未投入・エラー画面 */
.empty { text-align: center; padding: 24px 8px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
