/* 支援士ドリル - styles */
:root {
  --bg: #f2f5f8;
  --fg: #16212b;
  --muted: #64748b;
  --card: #ffffff;
  --line: #dde5ec;
  --accent: #12324a;
  --accent-fg: #ffffff;
  --accent-soft: #e6eef5;
  --ok: #1a7f4b;
  --ok-bg: #e3f4ea;
  --ng: #c0392b;
  --ng-bg: #fbe9e7;
  --warn: #b7791f;
  --shadow: 0 2px 10px rgba(16, 38, 56, 0.08);
  --radius: 14px;
  --box0: #d8e0e8;
  --box1: #c0392b;
  --box2: #d98324;
  --box3: #c9a227;
  --box4: #5f9e57;
  --box5: #2f7d5a;
  --box6: #12324a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12171c;
    --fg: #e6edf3;
    --muted: #8b9aa8;
    --card: #1b232b;
    --line: #2b3641;
    --accent: #5fb3e0;
    --accent-fg: #0d1319;
    --accent-soft: #1f2c37;
    --ok: #4ec98a;
    --ok-bg: #163024;
    --ng: #f0786a;
    --ng-bg: #33201d;
    --warn: #e0b055;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    --box0: #2b3641;
    --box1: #a8372a;
    --box2: #b06f21;
    --box3: #a98b22;
    --box4: #4f8a49;
    --box5: #2f7d5a;
    --box6: #5fb3e0;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.7;
  font-size: 16px;
  padding-bottom: env(safe-area-inset-bottom);
}
.app { max-width: 620px; margin: 0 auto; padding: 16px 16px 48px; }
.view.hidden, .hidden { display: none !important; }

/* ---------- 見出し ---------- */
.hero { text-align: center; padding: 18px 0 10px; }
.hero h1 { margin: 0; font-size: 1.7rem; letter-spacing: 0.02em; }
.hero h1 .dr { color: var(--accent); }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 0.82rem; }
h2 { font-size: 0.95rem; margin: 0 0 10px; letter-spacing: 0.02em; }
.view-title { flex: 1; text-align: center; margin: 0; }

/* ---------- カード ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 0 0 14px;
}
.note { color: var(--muted); font-size: 0.78rem; margin: 10px 0 0; text-align: center; }

/* ---------- 今日のカード ---------- */
.today-head { display: flex; justify-content: space-between; align-items: baseline; }
.today-label { font-weight: 700; font-size: 0.95rem; }
.today-date { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.ring-wrap { display: flex; justify-content: center; padding: 14px 0 16px; }
.ring {
  width: 132px; height: 132px; border-radius: 50%;
  background: conic-gradient(var(--accent) var(--p, 0%), var(--box0) 0);
  display: grid; place-items: center;
  position: relative;
}
.ring::after {
  content: ""; position: absolute; width: 104px; height: 104px;
  border-radius: 50%; background: var(--card);
}
.ring > span {
  position: relative; z-index: 1;
  font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.ring > span small { font-size: 0.95rem; color: var(--muted); font-weight: 600; }

/* ---------- ボタン ---------- */
.btn {
  display: block; width: 100%; padding: 13px 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--fg);
  font-size: 0.95rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.big { padding: 15px; font-size: 1rem; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 8px 12px; font-size: 0.8rem; width: auto; }
.btn.danger { color: var(--ng); border-color: var(--ng); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-col { display: grid; gap: 10px; margin-bottom: 14px; }
.icon-btn {
  width: 38px; height: 38px; flex: 0 0 38px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--muted);
  font-size: 1.1rem; line-height: 1; cursor: pointer; font-family: inherit;
}

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 6px; text-align: center; box-shadow: var(--shadow);
}
.kpi-v { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-l { font-size: 0.7rem; color: var(--muted); margin-top: 2px; }

/* ---------- 習熟度バー ---------- */
.mastery { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--box0); }
.mastery > i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; font-size: 0.72rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- 出題 ---------- */
.quiz-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.progress { flex: 1; height: 7px; background: var(--box0); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.25s; }
.quiz-pos { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.q-card { padding: 18px 16px; }
.q-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.72rem; font-weight: 700;
}
.q-streak { font-size: 0.72rem; color: var(--muted); }
.q-text { margin: 0 0 16px; font-size: 1.04rem; font-weight: 600; line-height: 1.65; }
.choices { display: grid; gap: 9px; }
.choice {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 12px 14px; text-align: left;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--fg);
  font-size: 0.93rem; line-height: 1.55; font-family: inherit;
  cursor: pointer; transition: border-color 0.12s, background 0.12s, transform 0.08s;
}
.choice:active { transform: scale(0.99); }
.choice .num {
  flex: 0 0 22px; height: 22px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.75rem; font-weight: 700;
  display: grid; place-items: center; margin-top: 1px;
}
.choice.correct { background: var(--ok-bg); border-color: var(--ok); }
.choice.correct .num { background: var(--ok); color: #fff; }
.choice.wrong { background: var(--ng-bg); border-color: var(--ng); }
.choice.wrong .num { background: var(--ng); color: #fff; }
.choice.dim { opacity: 0.5; }
.choices.locked .choice { cursor: default; }

/* ---------- フィードバック ---------- */
.feedback { animation: pop 0.18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fb-head { font-weight: 700; font-size: 1rem; margin-bottom: 6px; }
.fb-head.ok { color: var(--ok); }
.fb-head.ng { color: var(--ng); }
.fb-exp { margin: 0 0 14px; font-size: 0.88rem; line-height: 1.7; color: var(--fg); }

/* ---------- 結果 ---------- */
.res-emoji { font-size: 2.6rem; line-height: 1; }
#res-score { font-size: 1.5rem; margin: 8px 0 0; }
.wrong-item { border-top: 1px solid var(--line); padding: 12px 0; }
.wrong-item:first-child { border-top: none; padding-top: 0; }
.wrong-q { font-size: 0.88rem; font-weight: 600; margin: 0 0 6px; }
.wrong-a { font-size: 0.82rem; color: var(--ok); margin: 0 0 4px; }
.wrong-e { font-size: 0.8rem; color: var(--muted); margin: 0; line-height: 1.6; }

/* ---------- 統計 ---------- */
.stat-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.stat-row:first-child { border-top: none; }
.stat-name { flex: 0 0 8.5em; font-size: 0.82rem; font-weight: 600; }
.stat-bar { flex: 1; height: 9px; background: var(--box0); border-radius: 5px; overflow: hidden; }
.stat-bar > i { display: block; height: 100%; background: var(--accent); }
.stat-val { flex: 0 0 5.6em; text-align: right; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.history { display: flex; flex-wrap: wrap; gap: 5px; }
.hist-day {
  width: 30px; padding: 5px 0; text-align: center; border-radius: 7px;
  font-size: 0.68rem; font-variant-numeric: tabular-nums;
  background: var(--box0); color: var(--muted);
}
.hist-day.done { background: var(--accent); color: var(--accent-fg); font-weight: 700; }

/* ---------- その他 ---------- */
.howto { font-size: 0.83rem; }
.howto summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.howto ul { padding-left: 1.2em; margin: 12px 0; color: var(--muted); }
.howto li { margin-bottom: 6px; }
.howto strong { color: var(--fg); }
.howto-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.switch { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--muted); cursor: pointer; margin-right: auto; }
kbd {
  display: inline-block; padding: 0 5px; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 5px; font-size: 0.78em;
  background: var(--bg); font-family: ui-monospace, monospace;
}
code { font-family: ui-monospace, monospace; font-size: 0.88em; }

/* ---------- 自動生成問題の目印と除外 ---------- */
.q-meta { gap: 8px; }
.auto-tag {
  padding: 2px 8px; border-radius: 999px;
  border: 1px dashed var(--muted); color: var(--muted);
  font-size: 0.66rem; font-weight: 700; white-space: nowrap;
}
.q-streak { margin-left: auto; }
.fb-exclude { margin: 10px auto 0; }
.fb-exclude.done { color: var(--ng); border-color: var(--ng); }
