/* ===== デザイントークン =====
 * 方針(デザイン仕様 2a「静かな学習ノート」):
 *  1. 使う色は8つだけ。それ以外の色を画面に出さない
 *  2. 分野・タブ・カテゴリで色を変えない。区切りは余白と1pxの罫線で作る
 *  3. アクセント色は1画面に1〜2箇所まで(主要CTAと現在地)
 *  4. 数字・コードは等幅
 *  5. 解説文だけ行間を広げる
 * 既定はライト。ダークは html[data-theme="dark"]。
 */
:root {
  --bg: #FAF8F5;          /* 画面全体の地・タブバーの地 */
  --bg-card: #FFFFFF;     /* カード、リスト行、選択肢 */
  --bg-elev: #F2EFE8;     /* 淡いブロック背景(補足ボックス・入力欄) */
  --track: #ECE8E1;       /* 進捗バーの空きトラック・タグの地 */
  --border: #EAE5DD;      /* 罫線(強): カード枠線・タブバー上端 */
  --border-weak: #F0ECE5; /* 罫線(弱): カード内部の区切り */
  --text: #1C1A17;        /* 見出し・本文 */
  --text-body: #2C2924;   /* 解説本文 */
  --text-sub: #6B665E;    /* 副文 */
  --text-dim: #8A857C;    /* ラベル・キャプション・非アクティブ */
  --icon-off: #C4BFB5;    /* 非アクティブアイコンの線 */
  --accent: #3B6BC4;      /* 主要CTA・進捗・アクティブタブ・選択中 */
  --accent-soft: rgba(59,107,196,.07);  /* 選択中の選択肢の地 */
  --accent-line: rgba(59,107,196,.35);
  --ok: #2C7A57;          /* 正解表示のみ */
  --ng: #B4483A;          /* 不正解・低正答率・破壊的操作 */
  /* 色数を増やさないため、旧トークンはすべて上記に寄せる */
  --accent-2: #3B6BC4;
  --warn: #6B665E;
  --tech: #6B665E;
  --mgmt: #6B665E;
  --strat: #6B665E;
  --card-shadow: 0 12px 30px rgba(28,26,23,.07);
  --on-status: #FFFFFF;   /* 正誤バッジの文字色 */
  --ok-soft: rgba(44,122,87,.08);
  --ng-soft: rgba(180,72,58,.08);
  --radius: 22px;
  --tabbar-h: 64px;
}
@supports (color: oklch(0.5 0.1 255)) {
  :root {
    --accent: oklch(0.52 0.13 255);
    --accent-2: oklch(0.52 0.13 255);
    --accent-soft: oklch(0.52 0.13 255 / .07);
    --accent-line: oklch(0.52 0.13 255 / .35);
    --ok: oklch(0.48 0.11 155);
  }
}

/* ダークテーマ(デザイン仕様 2b)
 * 2aと同じ書体・レイアウト・構造のまま明度だけ反転。純黒/純白は使わず、
 * ライト版と同じ暖色寄りニュートラルで統一。階層は面の明度差＋1px罫線で作り、影は使わない。 */
html[data-theme="dark"] {
  --bg: #131211;
  --bg-card: #1C1B19;
  --bg-elev: #242220;
  --track: #2C2A26;
  --border: #2C2A26;
  --border-weak: #232120;
  --text: #EDEAE4;
  --text-body: #C9C4BA;
  --text-sub: #B6B0A6;
  --text-dim: #8B857B;
  --icon-off: #57524A;
  /* 暗い地では .52 が沈むためアクセントの明度を上げる(.72)。上に載る文字は白ではなく濃紺 */
  --accent: #6FA7EE;
  --accent-soft: rgba(111,167,238,.12);
  --accent-line: rgba(111,167,238,.35);
  --accent-2: #6FA7EE;
  --on-accent: #0F1524;
  --ok: #60BB83;
  --ng: #E17363;
  --ok-soft: rgba(96,187,131,.12);
  --ng-soft: rgba(225,115,99,.12);
  --on-status: #131211;   /* 明るい正誤色の上は暗い字 */
  --warn: #B6B0A6;
  --tech: #B6B0A6;
  --mgmt: #B6B0A6;
  --strat: #B6B0A6;
}
@supports (color: oklch(0.5 0.1 255)) {
  html[data-theme="dark"] {
    --accent: oklch(0.72 0.12 255);
    --accent-2: oklch(0.72 0.12 255);
    --accent-soft: oklch(0.72 0.12 255 / .12);
    --accent-line: oklch(0.72 0.12 255 / .35);
    --ok: oklch(0.72 0.12 155);
    --ng: oklch(0.68 0.14 30);
  }
}
/* ダーク固有: 影を使わず、面の明度差と1px罫線で階層を作る */
html[data-theme="dark"] .panel,
html[data-theme="dark"] .card,
html[data-theme="dark"] .legal-sheet { box-shadow: none; }
html[data-theme="dark"] .fb-input:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
html[data-theme="dark"] .legal-overlay { background: rgba(0, 0, 0, .55); }
/* アクセント面の上に載る文字色(ダークはアクセントが明るいため暗い字) */
:root { --on-accent: #FFFFFF; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- layout ---------- */
#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
.view { padding: 16px 16px 24px; display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }


/* ---------- tab bar ---------- */
nav.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--bg);
  border-top: 1px solid var(--border);
  max-width: 640px; margin: 0 auto;
}
nav.tabbar button {
  flex: 1; background: none; border: none; color: var(--text-dim);
  font-size: 11px; display: flex; flex-direction: column; align-items: center;
  gap: 7px; padding: 12px 0 8px; cursor: pointer; font-family: inherit;
  transition: color .12s ease;
}
nav.tabbar button .ico { display: flex; align-items: center; justify-content: center; }
nav.tabbar button .ico svg { width: 20px; height: 20px; stroke: var(--icon-off); fill: none; stroke-width: 2; }
nav.tabbar button.active .ico svg { stroke: var(--accent); fill: var(--accent); fill-opacity: .16; }
nav.tabbar button.active { color: var(--accent); font-weight: 700; }
nav.tabbar button.active { color: var(--accent); }


/* ---------- 数字・コードは等幅(デザイン仕様4) ---------- */
:root { --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }
.mini-n, .streak-n, .result-rate, .range-count, .fb-count,
.stat .num, .goal-count, .q-progress span:first-child {
  font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
pre.pseudocode, .mono { font-family: var(--mono); }

/* ---------- 解説本文だけ行間を広げる(デザイン仕様5) ---------- */
.feedback .exp { line-height: 2.05; letter-spacing: .015em; color: var(--text-body); font-size: 15px; }
.flash-face .meaning { line-height: 2.0; letter-spacing: .012em; color: var(--text-body); }

/* ---------- cards & common ---------- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; }
.muted { color: var(--text-dim); }
.center { text-align: center; }
.row { display: flex; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

button.btn {
  font-family: inherit; font-size: 15px; font-weight: 600;
  border: none; border-radius: 12px; padding: 13px 18px; cursor: pointer;
  background: var(--accent); color: var(--on-accent); width: 100%; transition: transform .1s, opacity .2s;
}
button.btn:active { transform: scale(.98); }
button.btn.secondary { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); }
button.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
button.btn:disabled { opacity: .5; }
button.btn.small { padding: 9px 12px; font-size: 13px; width: auto; }

.pill {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 6px;
  background: var(--track); color: var(--text-sub); border: none;
}
/* 分野ごとの色分けは廃止(区切りは余白と罫線で作る) */
.pill.tech, .pill.mgmt, .pill.strat { color: var(--text-sub); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  font-size: 13px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-dim);
}
.chip.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ---------- home dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; text-align: center;
}
.stat .num { font-size: 28px; font-weight: 700; }
.stat .lbl { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* greeting header */
.home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 4px 0 20px; }
.greeting h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: .2px; }
.greeting h1 .wave { display: inline-block; }
.greeting .sub { color: var(--text-dim); font-size: 14px; margin-top: 4px; }
.streak { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; padding-top: 4px; }
.streak .flame {
  width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
}
.streak-lbl { font-size: 11px; color: var(--text-dim); }
.streak-n { font-size: 20px; font-weight: 800; line-height: 1.1; }
.streak-n span { font-size: 12px; font-weight: 600; color: var(--text-dim); margin-left: 2px; }

/* section panel */
.panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 18px; padding: 16px; margin-bottom: 16px;
}
.panel-h { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.panel-note.center { text-align: center; }

/* 結果画面(演習/単語帳の完了) */
.result-hero {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 28px 16px 22px; margin-bottom: 4px;
}
.result-hero .ringwrap { width: 84px; height: 84px; margin-bottom: 10px; }
.result-hero .ringwrap svg { width: 84px; height: 84px; }
.result-emoji { font-size: 30px; }
.result-emoji-lg { font-size: 56px; margin-bottom: 8px; }
.result-rate { font-size: 40px; font-weight: 800; line-height: 1; margin-top: 4px; }
.result-rate span { font-size: 20px; font-weight: 700; margin-left: 2px; }
.result-sub { font-size: 13px; color: var(--text-dim); margin-top: 6px; }

/* mini stat (today) with ring */
.today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 12px;
}
.ringwrap { position: relative; width: 56px; height: 56px; flex: 0 0 auto; }
.ringc {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.ringc svg { width: 22px; height: 22px; }
.mini-txt { min-width: 0; }
.mini-n { font-size: 26px; font-weight: 800; line-height: 1; }
.mini-n span { font-size: 13px; font-weight: 600; color: var(--text-dim); margin-left: 2px; }
.mini-lbl { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* cumulative 2x2 with icon tiles */
.cum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cum {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 12px;
}
.itile {
  width: 46px; height: 46px; flex: 0 0 auto; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  color: var(--c);
  background: var(--bg-card); /* color-mix未対応環境のフォールバック */
  background: color-mix(in srgb, var(--c) 16%, transparent);
  border: 1px solid var(--border);
  border-color: color-mix(in srgb, var(--c) 32%, transparent);
}
.itile svg { width: 24px; height: 24px; }
.itile b { font-size: 22px; font-weight: 800; }

/* motivational banner */
.banner {
  position: relative; overflow: hidden;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 18px; padding: 18px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 12px;
}
.banner-body { flex: 1; min-width: 0; z-index: 1; }
.banner-title { font-size: 16px; font-weight: 700; color: var(--text); }
.banner-sub { font-size: 12.5px; color: var(--text-sub); margin: 3px 0 12px; }
.banner-bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; max-width: 78%; }
.banner-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.banner-goal { position: absolute; left: 18px; bottom: 16px; transform: translateX(0); display: none; }
.banner-trophy { font-size: 40px; line-height: 1; z-index: 1; opacity: .9; }

/* home CTA buttons */
.home-cta {
  width: 100%; display: flex; align-items: center; gap: 12px;
  font-family: inherit; font-size: 15px; font-weight: 700; color: var(--text);
  border: 1px solid var(--border); background: var(--bg-card);
  border-radius: 18px; padding: 16px; cursor: pointer; margin-bottom: 10px;
  transition: transform .1s, filter .2s;
}
.home-cta:active { transform: scale(.99); }
.home-cta.primary {
  background: var(--accent);
  border: none; color: var(--on-accent);
}
.home-cta .cta-ic {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.18);
}
.home-cta .cta-ic svg { width: 18px; height: 18px; }
.home-cta .cta-ic.sec { background: var(--bg-elev); color: var(--accent); border: 1px solid var(--border); }
.home-cta .cta-label { flex: 1; text-align: left; }
.home-cta .cta-chev { flex: 0 0 auto; opacity: .7; display: flex; transition: transform .2s; }
.home-cta .cta-chev svg { width: 20px; height: 20px; }
.home-cta.center { justify-content: center; padding: 16px; }
.home-cta.center .cta-label { flex: 0 0 auto; text-align: center; font-size: 16px; }

/* アプリ内アップデート案内バナー */
.update-note {
  display: flex; align-items: center; gap: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 14px; padding: 10px 12px; margin-bottom: 14px;
}
.update-note .upd-txt { flex: 1; font-size: 12.5px; font-weight: 700; }
.update-note .upd-go {
  font-family: inherit; font-size: 12px; font-weight: 700; color: var(--on-accent);
  background: var(--accent); border: none; border-radius: 999px; padding: 7px 14px; cursor: pointer;
}
.update-note .upd-close {
  font-family: inherit; font-size: 13px; color: var(--text-dim);
  background: none; border: none; cursor: pointer; padding: 4px 6px;
}


/* ---------- フィードバックフォーム ----------
   入力欄の幅はブラウザ既定(textareaのcols相当≒150px)に落ちると破綻するため、
   width:100% と box-sizing:border-box を必ずセットで指定する。 */
.fb-sheet { height: auto; max-height: 92%; }
.fb-body { padding-top: 4px; }
.fb-title { font-size: 19px; font-weight: 800; margin: 0 0 6px; }
.fb-lead { font-size: 13px; color: var(--text-dim); line-height: 1.75; margin: 0 0 18px; }

.fb-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; margin-bottom: 7px;
}
.fb-req, .fb-opt {
  font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 2px 8px;
}
/* color-mix()は古いiOS(15〜16.1)で未対応。先にrgbaを書いて背景が消えないようにする */
.fb-req { background: rgba(248,113,113,.16); color: var(--ng); }
.fb-req { background: color-mix(in srgb, var(--ng) 16%, transparent); }
.fb-opt { background: var(--bg-elev); color: var(--text-dim); }

.fb-input {
  display: block; width: 100%; box-sizing: border-box;
  font-family: inherit; font-size: 15px; line-height: 1.7; color: var(--text);
  background: var(--bg-elev); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 13px 14px;
  -webkit-appearance: none; appearance: none;
}
.fb-input::placeholder { color: var(--text-dim); opacity: .8; }
.fb-input:focus {
  outline: none; border-color: var(--accent);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(79,157,255,.22);   /* 古いiOS向けフォールバック */
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.fb-textarea { min-height: 150px; resize: vertical; }
.fb-count {
  font-size: 11px; color: var(--text-dim); text-align: right;
  font-variant-numeric: tabular-nums; margin: 6px 0 18px;
}

.fb-privacy {
  font-size: 12px; color: var(--text-dim); line-height: 1.7;
  background: var(--bg-elev); border-radius: 10px; padding: 10px 12px; margin: 18px 0;
}
.fb-send { margin-top: 2px; }
.fb-send:disabled { opacity: .6; }
.fb-alt {
  display: block; width: 100%; margin-top: 12px;
  font-family: inherit; font-size: 13px; color: var(--text-dim);
  background: none; border: none; text-decoration: underline; cursor: pointer;
}

/* 誤答選択肢の正体(表示順に整列) */
.exp-choices { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.exp-choices-h { font-size: 11.5px; font-weight: 700; color: var(--text-dim); margin-bottom: 6px; }
.exp-choice-line { font-size: 12.5px; line-height: 1.7; }
.exp-choice-line b { color: var(--accent); margin-right: 4px; }

/* テーマ切替セグメント(3分割ピル) */
.seg {
  display: flex; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px; padding: 3px; gap: 3px;
}
.seg button {
  flex: 1; font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-sub); background: none; border: none; border-radius: 9px;
  padding: 9px 4px; cursor: pointer; transition: background .12s, color .12s;
}
.seg button.active { background: var(--bg-card); color: var(--text); font-weight: 700; box-shadow: 0 1px 2px rgba(28,26,23,.06); }
html[data-theme="dark"] .seg button.active { box-shadow: none; border: 1px solid var(--border); }

/* ---------- quiz start screen ---------- */
.back-btn {
  width: 40px; height: 40px; border-radius: 50%; margin: 2px 0 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text); cursor: pointer;
}
.back-btn svg { width: 20px; height: 20px; }
.qstart-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.qstart-title h1 { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.25; }
.qstart-title .sub { color: var(--text-dim); font-size: 13px; margin-top: 6px; }
.goal-chip {
  flex: 0 0 auto; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 10px 14px; text-align: left;
}
.goal-chip .goal-lbl { font-size: 11px; color: var(--text-dim); }
.goal-chip .goal-val { font-size: 15px; font-weight: 800; margin-top: 2px; }

.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.itile.sm { width: 38px; height: 38px; border-radius: 11px; }
.itile.sm svg { width: 20px; height: 20px; }
.panel-head .panel-h { margin: 0; font-size: 17px; }

.subj-pills { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.subj-pill {
  font-family: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
  padding: 11px 18px; border-radius: 999px; color: var(--text-dim);
  background: var(--bg-elev); border: 1px solid var(--border);
}
.subj-pill.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.panel-note { color: var(--text-dim); font-size: 13px; margin: 0; }

.range-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.range-tile {
  display: flex; align-items: center; gap: 11px; text-align: left; cursor: pointer;
  font-family: inherit; color: var(--text);
  background: var(--bg-elev); border: 1.5px solid var(--border);
  border-radius: 14px; padding: 12px 11px;
}
.range-tile.active { border-color: var(--accent); background: rgba(79,157,255,.12); }
.range-txt { flex: 1; min-width: 0; }
.range-name { font-size: 12px; color: var(--text-dim); }
.range-count { font-size: 18px; font-weight: 800; line-height: 1.1; }
.range-count span { font-size: 12px; font-weight: 600; color: var(--text-dim); margin-left: 1px; }
.range-chev { flex: 0 0 auto; opacity: .5; display: flex; }
.range-chev svg { width: 18px; height: 18px; }

.qopts { background: var(--bg-card); border: 1px solid var(--border); border-radius: 15px; padding: 14px 16px; margin: -2px 0 10px; }
.qopts-h { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.qopts .chips { margin-bottom: 0; }

/* ---------- quiz (question mode) ---------- */
/* 問題表示中は縦フレックスにして、前/次のナビを下部に固定配置する */
#view-quiz.qmode.active { display: flex; flex-direction: column; min-height: calc(100dvh - var(--tabbar-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 40px); }
.quiz-scroll { flex: 1 1 auto; }
.quiz-nav { display: flex; gap: 12px; padding-top: 14px; }
.qnav { font-family: inherit; font-weight: 700; font-size: 15px; border-radius: 14px; padding: 15px; cursor: pointer; }
.qnav.prev { flex: 0 0 auto; padding: 15px 18px; background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.qnav.prev:disabled { opacity: .4; }
.qnav.next { flex: 1; background: var(--accent); border: none; color: var(--on-accent); }

/* ---------- quiz ---------- */
.q-progress { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.quiz-top { display: flex; margin-bottom: 14px; }
.quiz-quit {
  font-family: inherit; font-size: 14px; font-weight: 700; color: var(--text);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 18px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.quiz-quit .x { font-size: 16px; line-height: 1; color: var(--text-dim); }
.quiz-quit:active { opacity: .6; }
.q-text { font-size: 19px; font-weight: 500; line-height: 1.85; letter-spacing: .01em; margin: 8px 0 20px; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  text-align: left; background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: 18px; padding: 19px 20px; min-height: 56px; color: var(--text);
  font-family: inherit; font-size: 15px; cursor: pointer; display: flex; gap: 12px;
  align-items: center; transition: border-color .15s;
}
.choice .mark {
  width: 22px; height: 22px; flex: 0 0 auto; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; background: var(--track); color: var(--text-sub);
}
.choice .ctext { white-space: pre-line; flex: 1; }
.choice:hover, .choice:active { border-color: var(--icon-off); }
.qbody { font-size: 13.5px; margin-bottom: 14px; color: var(--text); }
.qbody p { margin: 8px 0; }
.qbody p.note { font-size: 12px; color: var(--text-dim); margin: 10px 0 4px; }
.qbody ul { padding-left: 1.2em; margin: 6px 0; }
.qbody li { margin: 4px 0; }
.qbody table { border-collapse: collapse; width: 100%; margin: 4px 0 10px; font-size: 12px; display: block; overflow-x: auto; }
.qbody th, .qbody td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.qbody th { background: var(--bg-elev); color: var(--text-dim); font-weight: 600; white-space: nowrap; }
pre.pseudocode {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; margin: 0 0 16px; overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px; line-height: 1.7; color: var(--text-body); white-space: pre; tab-size: 2;
}
.choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.correct .mark { background: var(--ok); color: var(--on-status); }
.choice.wrong { border-color: var(--ng); background: var(--ng-soft); }
.choice.wrong .mark { background: var(--ng); color: var(--on-status); }
.choice.disabled { pointer-events: none; }
.feedback { margin-top: 16px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg-elev); }
.feedback .verdict { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.feedback.ok .verdict { color: var(--ok); }
.feedback.ng .verdict { color: var(--ng); }
.feedback.skip .verdict { color: var(--accent-2); }
.feedback .exp { font-size: 14px; color: var(--text); }
.feedback .added { font-size: 13px; color: var(--warn); margin-top: 10px; cursor: pointer; text-decoration: underline; }
.giveup-row { text-align: center; margin-top: 4px; }
.progress-bar { height: 6px; background: var(--track); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.progress-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }

/* ---------- flashcard ---------- */
.flash-wrap { perspective: 1400px; margin: 8px 0 16px; }
.flash {
  position: relative; width: 100%; min-height: 300px; cursor: pointer;
  transform-style: preserve-3d; transition: transform .5s; text-align: center;
}
.flash.flipped { transform: rotateY(180deg); }
.flash-face {
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 18px; border: 1px solid var(--border); background: var(--bg-card);
  padding: 26px 22px; display: flex; flex-direction: column; justify-content: center; align-items: center;
}
/* 表面は絶対配置でオーバーレイ、裏面は通常フローで高さを決める(裏面の全文が隠れずに表示される) */
.flash-face.front { position: absolute; inset: 0; }
.flash-face.back { position: relative; min-height: 300px; transform: rotateY(180deg); background: var(--bg-elev); justify-content: flex-start; }
.flash-face .word { font-size: 30px; font-weight: 700; }
.flash-face .reading { color: var(--text-dim); font-size: 13px; margin-top: 8px; }
.flash-face .hint { color: var(--text-dim); font-size: 12px; margin-top: 20px; }
.flash-face .meaning { font-size: 15px; margin: 6px 0 14px; text-align: left; }
.flash-face .analogy-lbl { font-size: 12px; color: var(--accent); font-weight: 700; align-self: flex-start; margin-top: 8px; }
.flash-face .analogy { font-size: 14px; text-align: left; color: var(--text); background: rgba(79,157,255,.08); border-radius: 10px; padding: 10px 12px; margin-top: 4px; }
.flash-face .exam-lbl { font-size: 12px; color: var(--warn); font-weight: 700; align-self: flex-start; margin-top: 12px; }
.flash-face .exam-note { font-size: 13px; text-align: left; color: var(--text); background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.18); border-radius: 10px; padding: 10px 12px; margin-top: 4px; }
.flash-face .wrongcount { font-size: 12px; color: var(--ng); align-self: flex-start; margin-top: 12px; }
.flash-face .word-cat { margin-top: 12px; }

/* ---------- ranking ---------- */
.rank-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.rank-item:last-child { border-bottom: none; }
.rank-item .no { font-weight: 700; color: var(--text-dim); width: 22px; }
.rank-item .w { flex: 1; }
.rank-item .cnt { color: var(--ng); font-weight: 700; }

/* ---------- charts ---------- */
.chart-box { width: 100%; }
.chart-box svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--text-dim); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

/* ---------- settings ---------- */
label.field { display: block; font-size: 13px; color: var(--text-dim); margin: 12px 0 6px; }
.empty { text-align: center; color: var(--text-dim); padding: 40px 10px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
/* ---------- settings: support rows & about ---------- */
.setting-row {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  font-family: inherit; font-size: 14.5px; font-weight: 600; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 15px; cursor: pointer; margin-bottom: 8px; text-align: left;
}
.setting-row .cta-chev { opacity: .55; display: flex; }
.setting-row .cta-chev svg { width: 18px; height: 18px; }
.about-rows { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.about-row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 13.5px; padding: 11px 14px; background: var(--bg-elev);
}
.about-row + .about-row { border-top: 1px solid var(--border); }
.about-row span:first-child { color: var(--text-dim); flex: 0 0 auto; }
.about-row span:last-child { font-weight: 600; text-align: right; }

/* ---------- legal viewer (利用規約・プライバシーポリシー) ---------- */
.legal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 8, 14, .72); display: flex; align-items: flex-end; justify-content: center;
}
.legal-sheet {
  width: 100%; max-width: 640px; height: 88%;
  background: var(--bg); border: 1px solid var(--border); border-bottom: none;
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column; overflow: hidden;
}
.legal-head {
  flex: 0 0 auto; display: flex; justify-content: flex-end;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg-elev);
}
.legal-close {
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  color: var(--text); background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 14px;
}
.legal-body { flex: 1; overflow-y: auto; padding: 18px 20px calc(30px + env(safe-area-inset-bottom)); }

/* paywall(プレミアム購入モーダル。legal-sheetの器を流用) */
.legal-sheet.paywall { height: auto; max-height: 88%; }
.paywall-hero { font-size: 44px; text-align: center; margin-top: 4px; }
.paywall-title { font-size: 20px; font-weight: 800; text-align: center; margin: 8px 0 4px; }
.paywall-reason { font-size: 13px; color: var(--text-dim); text-align: center; margin: 0 0 6px; }
.paywall-list { list-style: none; padding: 0; margin: 14px 0; }
.paywall-list li { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; font-size: 14px; }
.paywall-note { font-size: 12px; color: var(--text-dim); text-align: center; margin: 0 0 14px; }
.lock-note { font-family: inherit; display: block; width: 100%; text-align: left; margin-top: 10px; background: color-mix(in srgb, var(--warn) 10%, transparent); border: 1px dashed var(--warn); color: var(--text); border-radius: 12px; padding: 10px 12px; font-size: 12.5px; cursor: pointer; }
.lock-panel { text-align: center; padding-top: 26px; padding-bottom: 24px; }
.lock-panel .lock-emoji { font-size: 40px; margin-bottom: 8px; }
.legal-body h1 { font-size: 20px; margin: 0 0 2px; }
.legal-body h2 { font-size: 15px; margin: 22px 0 6px; color: var(--accent); }
.legal-body p, .legal-body li { font-size: 13.5px; line-height: 1.8; }
.legal-body p.date { color: var(--text-dim); font-size: 12px; margin: 0 0 18px; }
.legal-body ol { padding-left: 1.4em; }
.legal-body li { margin: 5px 0; }
.legal-body .mono { font-family: Consolas, monospace; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: 12.5px; }

.toast {
  position: fixed; bottom: calc(var(--tabbar-h) + 20px); left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 50; opacity: 0;
  transition: opacity .3s; pointer-events: none; max-width: 90%;
}
.toast.show { opacity: 1; }
