/* ===== 医療 × 教育 × AI : 清潔感のあるシンプルなデザイン ===== */
:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --border: #dde4ea;
  --text: #17242e;
  --text-dim: #5d6c7a;
  --text-faint: #8b98a5;
  --primary: #0f766e;
  --primary-soft: #e2f2f0;
  --primary-strong: #0b5a54;
  --accent: #2563eb;
  --warn: #d97706;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 38, 51, .05), 0 8px 24px rgba(16, 38, 51, .06);
  --shadow-lg: 0 10px 30px rgba(16, 38, 51, .12);
  --nav-h: 62px;
  --track: #e6ecf0;
  /* 習熟度の順序尺度（同一色相・薄→濃）。検証済み：光端 2.39:1、隣接 ΔL ≥ .06 */
  --m0: #94a3b8; --m1: #4fb8aa; --m2: #2a9f92; --m3: #158a80; --m4: #0e6f66; --m5: #0a554f;
  /* 科目の識別色（検証済み：隣接 CVD ΔE ≥ 13.8、全て 3:1 以上） */
  --s1: #1d4ed8; --s2: #ea580c; --s3: #0d9488; --s4: #9333ea; --s5: #e11d48; --s6: #0891b2;
  /* 暗記／理解 */
  --memo: #1d4ed8; --und: #0d9488;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1417;
    --surface: #171e23;
    --surface-2: #1f272d;
    --border: #2b353d;
    --text: #e6edf3;
    --text-dim: #9fb0bd;
    --text-faint: #7c8b98;
    --primary: #2dd4bf;
    --primary-soft: #123833;
    --primary-strong: #5eead4;
    --accent: #60a5fa;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
    --track: #26313a;
    /* ダーク面向けに段階を選び直したもの（検証済み） */
    --m0: #5b6b78; --m1: #1a5f58; --m2: #1f7d73; --m3: #26a094; --m4: #3dc2b3; --m5: #7ee0d3;
    --s1: #3574e6; --s2: #e8641f; --s3: #10a396; --s4: #b03bd6; --s5: #a8850a; --s6: #0a97b8;
    --memo: #3574e6; --und: #10a396;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", system-ui, -apple-system, sans-serif;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

.app-loading { padding: 3rem; text-align: center; color: var(--text-dim); }

/* ===== レイアウト ===== */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.1rem .8rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.02rem; padding: .3rem .5rem 1rem; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; font-size: 1rem;
}
.brand small { display: block; font-weight: 400; font-size: .68rem; color: var(--text-faint); letter-spacing: .04em; }

.nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .65rem; border-radius: var(--radius-sm);
  color: var(--text-dim); text-decoration: none; font-size: .89rem; margin-bottom: 2px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav .nav-group { font-size: .68rem; color: var(--text-faint); padding: .9rem .65rem .3rem; letter-spacing: .08em; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1.2rem; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.02rem; margin: 0; font-weight: 650; }
.topbar .user { display: flex; align-items: center; gap: .6rem; font-size: .82rem; color: var(--text-dim); }
.content { padding: 1.2rem; max-width: 1120px; width: 100%; margin: 0 auto; flex: 1; }

.mobile-nav { display: none; }

.mobile-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-faint); text-decoration: none; font-size: .64rem;
}
.mobile-nav a .ic { font-size: 1.2rem; line-height: 1; }
.mobile-nav a.active { color: var(--primary); }

/* =====================================================================
   学生画面：スマートフォン・タブレット向け
   PCで開いても、片手で操作できるアプリのような1カラムのまま表示する。
   ===================================================================== */
.role-student { --nav-h: 64px; }

.role-student .sidebar { display: none; }

.role-student .mobile-nav {
  display: grid; grid-template-columns: repeat(5, 1fr);
  position: fixed; bottom: 0; left: 0; right: 0;
  /* ホームバーのある端末では、その分だけ高くする（高さ固定だと押せる部分が削られる） */
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--border); z-index: 40;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.role-student .mobile-nav a { font-size: .7rem; }

.role-student .content {
  padding: .9rem .8rem calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 1.4rem);
  max-width: 560px;                 /* スマートフォンの読みやすい幅に合わせる */
}

/* 深夜や電車内でも読める大きさに（11px 台の補足文字は小さすぎる） */
.role-student .tiny { font-size: .78rem; }
.role-student .muted { font-size: .88rem; }
.role-student .list-item .meta { font-size: .78rem; }
.role-student .course-cap { font-size: .68rem; }
.role-student .hero-label { font-size: .74rem; }
.role-student .topbar { padding: .7rem .9rem; }
.role-student .topbar h1 { font-size: .98rem; }

/* 指で押しやすい大きさを確保する（44px 以上） */
.role-student button,
.role-student .btn { min-height: 44px; padding: .6rem 1rem; font-size: .92rem; }
.role-student .choice { min-height: 52px; padding: .85rem 1rem; font-size: .95rem; }
.role-student .list-item { min-height: 52px; padding: .75rem .85rem; }
.role-student .q-text { font-size: 1.1rem; }
.role-student input, .role-student select, .role-student textarea {
  min-height: 44px; font-size: 16px;  /* 16px 未満だと iOS で拡大されてしまう */
}
.role-student .diag-opts button { min-height: 52px; }

/* タブレットは少し広く使う */
@media (min-width: 700px) {
  .role-student .content { max-width: 720px; padding: 1.1rem 1rem calc(var(--nav-h) + 1.4rem); }
  .role-student .grid-2 { grid-template-columns: repeat(2, 1fr); }
}

/* 学生画面の表は、狭い幅ではカード状に積み直す */
@media (max-width: 700px) {
  .role-student table, .role-student thead, .role-student tbody,
  .role-student tr, .role-student td { display: block; width: 100%; }
  .role-student thead { display: none; }
  .role-student tr {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: .5rem .7rem; margin-bottom: .5rem;
  }
  .role-student td {
    border: none; padding: .18rem 0; white-space: normal;
    display: flex; justify-content: space-between; gap: .8rem; font-size: .85rem;
  }
  .role-student td::before {
    content: attr(data-label); color: var(--text-faint);
    font-size: .74rem; flex: 0 0 auto;
  }
  .role-student td:empty { display: none; }
}

/* =====================================================================
   教員画面：パソコン向け
   一覧性を優先し、サイドバーと広い表を常に使えるようにする。
   ===================================================================== */
.role-teacher { font-size: 15px; }
.role-teacher .content { max-width: 1400px; padding: 1.2rem 1.4rem; }
.role-teacher .grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.role-teacher .grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.role-teacher table { font-size: .82rem; }
.role-teacher th, .role-teacher td { padding: .45rem .6rem; }

/* 画面が狭いときだけ下部タブに切り替える（PC推奨の案内も出す） */
@media (max-width: 1000px) {
  .role-teacher .sidebar { display: none; }
  .role-teacher .content { padding: .9rem .8rem calc(var(--nav-h) + 1.2rem); }
  .role-teacher .mobile-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
    background: var(--surface); border-top: 1px solid var(--border); z-index: 40;
    padding-bottom: env(safe-area-inset-bottom);
  }
}
.pc-recommended { display: none; }
@media (max-width: 1000px) {
  .role-teacher .pc-recommended {
    display: block; margin-bottom: .9rem; padding: .7rem .85rem;
    border: 1px solid var(--warn); border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--warn) 10%, var(--surface));
    font-size: .82rem;
  }
}

/* ===== 部品 ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: .9rem;
}
.card.tight { padding: .75rem .85rem; }
.card-title { font-size: .95rem; font-weight: 700; margin: 0 0 .75rem; display: flex; align-items: center; gap: .45rem; justify-content: space-between; letter-spacing: .01em; }
.card-title > span:first-child::before { content: ''; display: inline-block; width: 4px; height: 14px; border-radius: 2px; background: var(--primary); margin-right: .55rem; vertical-align: -2px; }
.card-title > span:first-child { flex: 1 1 auto; min-width: 0; }
.card-title .sub { white-space: nowrap; }
.card-title .sub { font-weight: 400; font-size: .76rem; color: var(--text-faint); }

.grid { display: grid; gap: .9rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem .9rem; }
.stat .label { font-size: .72rem; color: var(--text-faint); letter-spacing: .02em; }
.stat .value { font-size: 1.55rem; font-weight: 750; line-height: 1.2; letter-spacing: -.01em; }
.stat .value small { font-size: .8rem; font-weight: 500; color: var(--text-dim); }

button, .btn {
  font: inherit; font-size: .87rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .5rem .9rem; border-radius: var(--radius-sm); text-decoration: none;
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
}
button:hover, .btn:hover { background: var(--surface-2); }
.btn-primary, button.primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.btn-primary:hover, button.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; }
.btn-lg { padding: .75rem 1.3rem; font-size: .95rem; width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
button.danger { color: var(--danger); border-color: var(--border); }

input, select, textarea {
  font: inherit; font-size: .9rem; width: 100%;
  padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
label { display: block; font-size: .78rem; color: var(--text-dim); margin: .7rem 0 .25rem; font-weight: 600; }

.row { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .7rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim); white-space: nowrap;
}
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.ok { background: #dcfce7; color: #166534; }
@media (prefers-color-scheme: dark) {
  .badge.warn { background: #3b2f10; color: #fcd34d; }
  .badge.danger { background: #3d1b1b; color: #fca5a5; }
  .badge.ok { background: #12331f; color: #86efac; }
}

.progress { height: 7px; background: var(--track); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 0 4px 4px 0; transition: width .5s cubic-bezier(.2,.7,.2,1); }

.list { display: flex; flex-direction: column; gap: .5rem; }
.list-item {
  display: flex; align-items: center; gap: .7rem; padding: .65rem .8rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  text-decoration: none; color: inherit;
}
.list-item { transition: border-color .15s, transform .15s, box-shadow .15s; }
.list-item:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow); }
.list-item .title { font-weight: 600; font-size: .89rem; }
.list-item .meta { font-size: .74rem; color: var(--text-faint); }

.muted { color: var(--text-dim); font-size: .84rem; }
.tiny { font-size: .72rem; color: var(--text-faint); }
.empty { text-align: center; color: var(--text-faint); padding: 2rem 1rem; font-size: .87rem; }
.src { font-size: .72rem; color: var(--text-faint); border-left: 3px solid var(--border); padding-left: .55rem; margin-top: .5rem; }

hr { border: none; border-top: 1px solid var(--border); margin: .9rem 0; }

/* ===== 学習画面 ===== */
.q-shell { max-width: 720px; margin: 0 auto; }
.q-progress { display: flex; gap: 4px; margin-bottom: 1rem; }
.q-progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-2); }
.q-progress span.done { background: var(--ok); }
.q-progress span.wrong { background: var(--danger); }
.q-progress span.current { background: var(--primary); }

.q-text { font-size: 1.06rem; font-weight: 600; line-height: 1.7; white-space: pre-wrap; margin: .3rem 0 1rem; }
.choices { display: flex; flex-direction: column; gap: .5rem; }
.choice {
  text-align: left; padding: .7rem .85rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); font-weight: 500; font-size: .92rem;
  line-height: 1.55; white-space: pre-wrap; justify-content: flex-start;
}
.choice:hover { border-color: var(--primary); }
.choice.selected { border-color: var(--primary); background: var(--primary-soft); }
.choice.correct { border-color: var(--ok); background: #dcfce7; color: #14532d; }
.choice.incorrect { border-color: var(--danger); background: #fee2e2; color: #7f1d1d; }
@media (prefers-color-scheme: dark) {
  .choice.correct { background: #12331f; color: #86efac; }
  .choice.incorrect { background: #3d1b1b; color: #fca5a5; }
}

.feedback { border-radius: var(--radius-sm); padding: .85rem; margin-top: 1rem; border: 1px solid var(--border); }
.feedback.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.feedback.ng { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.feedback h4 { margin: 0 0 .4rem; font-size: .95rem; }

.tutor { border: 1px dashed var(--primary); border-radius: var(--radius-sm); padding: .75rem .85rem; margin-top: .8rem; background: var(--primary-soft); }
.tutor .stage { font-size: .7rem; font-weight: 700; color: var(--primary); letter-spacing: .04em; }
.tutor p { margin: .3rem 0 0; font-size: .88rem; white-space: pre-wrap; }

.flashcard {
  min-height: 190px; display: grid; place-items: center; text-align: center;
  padding: 1.4rem; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 1.05rem; line-height: 1.7;
}
.flashcard .side { font-size: .68rem; color: var(--text-faint); letter-spacing: .1em; margin-bottom: .5rem; }

/* ===== 学習項目マップ ===== */
.map-wrap { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.map-wrap svg { display: block; width: 100%; height: 62vh; min-height: 380px; touch-action: none; cursor: grab; }
.map-legend { display: flex; flex-wrap: wrap; gap: .6rem; padding: .6rem .8rem; border-top: 1px solid var(--border); font-size: .74rem; color: var(--text-dim); }
.map-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: .25rem; }
.node-label { font-size: 10px; fill: var(--text); pointer-events: none; }
.map-detail { position: absolute; right: 10px; top: 10px; width: min(310px, 76%); max-height: 84%; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem; box-shadow: var(--shadow); }

/* ===== 表 ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-faint); font-size: .74rem; font-weight: 600; }
tbody tr:hover { background: var(--surface-2); }

/* ===== ログイン・診断 ===== */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.auth-card { width: min(420px, 100%); }
.auth-card .brand { justify-content: center; padding-top: 0; }
.tabs { display: flex; gap: .3rem; background: var(--surface-2); padding: 3px; border-radius: var(--radius-sm); margin-bottom: .9rem; }
.tabs button { flex: 1; border: none; background: transparent; padding: .45rem; font-size: .84rem; }
.tabs button.active { background: var(--surface); box-shadow: var(--shadow); }

.diag-q { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem; margin-bottom: .7rem; }
.diag-q .qtext { font-weight: 600; font-size: .9rem; margin-bottom: .55rem; }
.diag-opts { display: grid; gap: .45rem; }
.diag-opts button { text-align: left; justify-content: flex-start; font-weight: 500; }
.diag-opts button.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* ===== トースト ===== */
#toast-host { position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px); transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .4rem; }
.toast {
  background: var(--text); color: var(--bg); padding: .5rem .9rem; border-radius: 999px;
  font-size: .82rem; box-shadow: var(--shadow); animation: pop .2s ease;
}
.toast.err { background: var(--danger); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); gap: 3px; overflow-x: auto; padding-bottom: .3rem; }
.heat i { width: 11px; height: 11px; border-radius: 2px; background: var(--surface-2); display: block; }

/* ---------------------------------------------------------------
   SVG 内の見た目。
   CSP（style-src 'self'）は style 属性を拒否するため、
   JavaScript から style 文字列を渡さずクラスで指定する。
   --------------------------------------------------------------- */
.map-node { cursor: pointer; }
.sparkline { width: 100%; height: 70px; }

/* =====================================================================
   可視化の部品（ヒーロー・リング・帯・二本バー・タイムライン）
   ===================================================================== */

/* ---- ヒーロー：画面の先頭で「いまの状態」を示す帯 ---- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius); padding: 1.1rem 1.15rem; margin-bottom: 1rem;
  color: #fff; box-shadow: var(--shadow-lg);
  background: linear-gradient(135deg, #0f766e 0%, #0b5a54 55%, #123a5e 100%);
}
.hero::after {
  content: ''; position: absolute; inset: auto -20% -60% auto; width: 70%; aspect-ratio: 1;
  border-radius: 50%; background: radial-gradient(closest-side, rgba(255,255,255,.14), transparent 70%);
  pointer-events: none;
}
.hero-title { font-size: .78rem; opacity: .85; letter-spacing: .06em; margin: 0 0 .5rem; }
.hero-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; position: relative; }
.hero-stats { display: flex; gap: 1.1rem; flex-wrap: wrap; flex: 1; min-width: 180px; }
.hero-stat { min-width: 64px; }
.hero-value { font-size: 1.5rem; font-weight: 750; line-height: 1.1; letter-spacing: -.01em; }
.hero-value small { font-size: .74rem; font-weight: 600; opacity: .85; margin-left: .1rem; }
.hero-label { font-size: .7rem; opacity: .8; margin-top: .1rem; }
.hero .ring text, .hero .ring tspan { fill: #fff; }
.hero .ring tspan { fill: rgba(255,255,255,.85); }
.hero .ring circle:first-of-type { stroke: rgba(255,255,255,.22); }
.hero .ring-arc { stroke: #fff; }
.hero .ring-label { color: rgba(255,255,255,.85); }
.hero-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; position: relative; }
.hero-actions .btn { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.28); color: #fff; backdrop-filter: blur(6px); }
.hero-actions .btn:hover { background: rgba(255,255,255,.24); }
.hero-actions .btn.solid { background: #fff; color: #0b5a54; border-color: #fff; }
.hero-actions .btn.solid:hover { background: #e8f3f1; }
.hero-note { font-size: .74rem; opacity: .85; margin: .6rem 0 0; position: relative; }

/* ---- 習熟度リング ---- */
.ring { display: block; }
.ring-wrap { display: inline-flex; flex-direction: column; align-items: center; gap: .25rem; }
.ring-value { font-size: 15px; font-weight: 750; fill: var(--text); letter-spacing: -.02em; }
.ring-value.big { font-size: 22px; }
.ring-unit { font-size: 9px; font-weight: 600; fill: var(--text-dim); }
.ring-label { font-size: .68rem; color: var(--text-faint); }
.ring-arc { transition: stroke-dasharray .6s cubic-bezier(.2,.7,.2,1); }

/* ---- コースの帯（講義回ごと）---- */
.course-strip { display: flex; gap: 4px; align-items: flex-end; margin: .6rem 0 .2rem; }
.course-seg { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.course-bar { height: 10px; background: var(--track); border-radius: 4px; overflow: hidden; }
.course-fill { height: 100%; border-radius: 0 4px 4px 0; transition: width .5s cubic-bezier(.2,.7,.2,1); }
.course-cap { font-size: .62rem; color: var(--text-faint); text-align: center; margin-top: .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course-seg.ahead .course-bar { background: repeating-linear-gradient(135deg, var(--track) 0 4px, var(--surface) 4px 7px); }
.course-seg.ahead .course-cap { opacity: .7; }
.course-seg.current .course-bar { outline: 2px solid var(--primary); outline-offset: 1px; }
.course-seg.current .course-cap { color: var(--primary); font-weight: 700; }
.hero .course-bar { background: rgba(255,255,255,.2); }
.hero .course-cap { color: rgba(255,255,255,.8); }
.hero .course-seg.ahead .course-bar { background: repeating-linear-gradient(135deg, rgba(255,255,255,.2) 0 4px, transparent 4px 7px); }
.hero .course-seg.current .course-bar { outline-color: #fff; }
.hero .course-seg.current .course-cap { color: #fff; }

/* ---- 暗記／理解の二本バー ---- */
.split-bar { display: grid; gap: .4rem; }
.split-row { display: grid; grid-template-columns: 3.4rem 1fr 3rem auto; align-items: center; gap: .5rem; font-size: .78rem; }
.split-bar.compact .split-row { grid-template-columns: 3rem 1fr 2.6rem; }
.split-label { display: inline-flex; align-items: center; gap: .35rem; color: var(--text-dim); font-weight: 600; }
.split-key { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.split-key.memo, .split-fill.memo { background: var(--memo); }
.split-key.und,  .split-fill.und  { background: var(--und); }
.split-track { height: 7px; background: var(--track); border-radius: 999px; overflow: hidden; }
.split-fill { height: 100%; border-radius: 0 4px 4px 0; transition: width .5s cubic-bezier(.2,.7,.2,1); }
.split-value { font-variant-numeric: tabular-nums; text-align: right; font-weight: 650; }
.split-n { font-size: .68rem; color: var(--text-faint); white-space: nowrap; }

/* ---- 復習タイムライン ---- */
.timeline { margin-top: .6rem; }
.timeline-track { position: relative; height: 6px; background: var(--track); border-radius: 999px; margin: .6rem .5rem; }
.timeline-fill { position: absolute; left: 0; top: 0; height: 100%; background: var(--primary); border-radius: 999px; opacity: .55; }
.timeline-dot { position: absolute; top: 50%; width: 10px; height: 10px; border-radius: 50%; transform: translate(-50%, -50%); background: var(--surface); border: 2px solid var(--primary); }
.timeline-dot.start { left: 0; background: var(--primary); }
.timeline-dot.now { width: 14px; height: 14px; border-color: var(--surface); background: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.timeline-dot.end { left: 100%; }
.timeline.overdue .timeline-fill, .timeline.overdue .timeline-dot.now { background: var(--warn); box-shadow: 0 0 0 2px var(--warn); }
.timeline.overdue .timeline-dot.end { border-color: var(--warn); }
.timeline-labels { display: flex; justify-content: space-between; font-size: .7rem; color: var(--text-faint); }
.timeline-labels b { color: var(--text-dim); font-weight: 600; }
.timeline-now { color: var(--primary); font-weight: 700; }

/* ---- 講義回の見出し ---- */
.lecture-head {
  display: flex; align-items: center; gap: .8rem; margin: 1.3rem 0 .6rem;
  padding: .55rem .2rem .55rem .7rem; border-left: 4px solid var(--primary);
}
.lecture-head.ahead { border-left-color: var(--border); }
.lecture-head h2 { margin: 0; font-size: 1.02rem; }
.lecture-head .meta { font-size: .72rem; color: var(--text-faint); margin-top: .1rem; }
.lecture-head .grow { flex: 1; min-width: 0; }
.lecture-head .split-bar { min-width: 150px; max-width: 220px; }

/* ---- 科目カード ---- */
.subject-card { display: block; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
.subject-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.subject-card .head { display: flex; align-items: center; gap: .9rem; }
.subject-card .name { font-weight: 750; font-size: 1.02rem; margin: 0; letter-spacing: -.005em; }
.subject-card .desc { font-size: .78rem; color: var(--text-dim); margin: .15rem 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.subject-card .counts { display: flex; gap: .8rem; font-size: .72rem; color: var(--text-faint); margin-top: .5rem; }
.subject-card .counts b { color: var(--text); font-weight: 700; }
.subject-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; display: inline-block; }

/* ---- 学習項目の行：習熟度の小さなバー ---- */
.item-row .mini { height: 4px; background: var(--track); border-radius: 999px; overflow: hidden; margin-top: .3rem; max-width: 160px; }
.item-row .mini > div { height: 100%; border-radius: 0 3px 3px 0; }

/* ---- 演習の問題カード ---- */
.q-card { border-top: 4px solid var(--primary); }
.q-card.und { border-top-color: var(--und); }
.q-card.memo { border-top-color: var(--memo); }
.q-kind { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 750; padding: .18rem .6rem; border-radius: 999px; }
.q-kind.memo { background: color-mix(in srgb, var(--memo) 12%, var(--surface)); color: var(--memo); }
.q-kind.und  { background: color-mix(in srgb, var(--und) 12%, var(--surface)); color: var(--und); }

/* ---- 解答・次へ：画面の下端に張り付く（スクロールせずに親指で押せる）---- */
.q-actions {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + .5rem);
  background: var(--surface); padding-top: .7rem; margin-top: .5rem; z-index: 5;
  /* 下に流れる本文との境目を柔らかく */
  box-shadow: 0 -10px 10px -8px rgba(16, 38, 51, .12);
}
.q-actions:empty { display: none; }
.q-actions > div:empty { display: none; }
@media (prefers-color-scheme: dark) { .q-actions { box-shadow: 0 -10px 10px -8px rgba(0,0,0,.5); } }

/* ---- 誤答理由：小さなチップで、上位4つ＋「その他…」 ---- */
.q-reasons { margin-top: .5rem; gap: .35rem; }
.role-student .q-reasons .reason { min-height: 38px; padding: .35rem .7rem; font-size: .8rem; }
.q-reasons .reason.ghost { border-style: dashed; color: var(--text-dim); }

/* ---- タッチ端末では hover の見た目が指を離しても残るので、無効にする ---- */
@media (hover: none) {
  .choice:hover { border-color: var(--border); }
  .choice.selected:hover { border-color: var(--primary); }
  .list-item:hover { border-color: var(--border); transform: none; box-shadow: none; }
  .subject-card:hover { transform: none; box-shadow: var(--shadow); }
  button:hover, .btn:hover { background: var(--surface); }
  .btn-primary:hover, button.primary:hover { background: var(--primary); border-color: var(--primary); }
}

/* ---- パスワード欄の「表示」切り替え ---- */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 3.8rem; }
.auth-card .pw-wrap .pw-toggle {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  min-height: 32px; padding: .2rem .6rem; font-size: .76rem; color: var(--text-dim);
}

/* ---- まとめ画面 ---- */
.result-hero { text-align: center; padding: .4rem 0 .2rem; }
.result-hero .headline { font-size: 1.15rem; font-weight: 750; margin: .5rem 0 .1rem; }

/* ---- 小さな画面では二本バーの補足を省く ---- */
@media (max-width: 480px) {
  .split-row { grid-template-columns: 2.9rem 1fr 2.6rem auto; }
  .lecture-head { flex-wrap: wrap; }
  .lecture-head .split-bar { min-width: 100%; max-width: none; }
}

/* ---- 学習特性診断（読解形式）---- */
.diag-notice {
  border-left: 4px solid var(--warn); background: color-mix(in srgb, var(--warn) 7%, var(--surface));
  border-radius: var(--radius-sm); padding: .7rem .85rem; margin: .8rem 0 .6rem; font-size: .82rem;
}
.diag-notice strong { font-size: .84rem; }
.diag-notice li { margin-bottom: .2rem; }
.passage { font-size: 1rem; line-height: 1.95; }
.passage p { margin: 0 0 .9rem; text-indent: 1em; }
.passage p:last-child { margin-bottom: 0; }
.diag-result { display: grid; gap: .5rem; }
.diag-result .split-row { grid-template-columns: 9.5rem 1fr 3rem; }
@media (max-width: 480px) {
  .diag-result .split-row { grid-template-columns: 8rem 1fr 2.8rem; }
}

/* ---- 到達した理解の深さ（解答後の表示）---- */
.reach { margin-top: .6rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.reach-badge { display: inline-flex; align-items: center; font-size: .8rem; font-weight: 750; padding: .2rem .65rem; border-radius: 999px; color: #fff; white-space: nowrap; }
.reach-badge.lv0 { background: var(--m0); }
.reach-badge.lv1 { background: var(--m2); }
.reach-badge.lv2 { background: var(--m3); }
.reach-badge.lv3 { background: var(--m4); }
.reach-badge.lv4 { background: var(--m5); }

/* ---- 積み上げ横棒 ---- */
.stacked { display: flex; gap: 2px; background: var(--track); border-radius: 4px; overflow: hidden; }
.stacked-seg { min-width: 2px; }

.rubric td:first-child { white-space: nowrap; }
.rubric td { white-space: normal; }

/* ---- 知識の深さ：はしご（Lv.1〜4）---- */
.ladder { display: flex; gap: 5px; align-items: flex-end; }
.ladder-step { flex: 1; min-width: 0; }
.ladder-bar { height: 12px; border-radius: 4px; background: var(--track); }
.ladder-step:nth-child(1).done .ladder-bar { background: var(--m2); }
.ladder-step:nth-child(2).done .ladder-bar { background: var(--m3); }
.ladder-step:nth-child(3).done .ladder-bar { background: var(--m4); }
.ladder-step:nth-child(4).done .ladder-bar { background: var(--m5); }
.ladder-step.open .ladder-bar { background: repeating-linear-gradient(135deg, var(--track) 0 4px, var(--surface) 4px 7px); border: 1px solid var(--border); }
.ladder-step.none .ladder-bar { opacity: .45; }
.ladder-step.next .ladder-bar { outline: 2px solid var(--primary); outline-offset: 1px; }
.ladder-cap { font-size: .68rem; color: var(--text-faint); margin-top: .3rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ladder-cap b { display: block; font-size: .7rem; }
.ladder-step.done .ladder-cap { color: var(--text); }
.ladder-step.next .ladder-cap { color: var(--primary); font-weight: 700; }
.ladder.compact .ladder-bar { height: 8px; }

/* ---- 知識の深さ：小さな4つの目盛り（一覧用）---- */
.pips { display: inline-flex; gap: 2px; vertical-align: middle; }
.pips i { width: 9px; height: 9px; border-radius: 2px; background: var(--track); display: inline-block; }
.pips i.on { background: var(--m4); }
.pips i.open { background: transparent; border: 1px solid var(--m3); box-sizing: border-box; }

/* ---- 二段階形式：理由の選択 ---- */
.reason-tier { margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed var(--border); }
.reason-tier .tier-label { font-weight: 700; font-size: .95rem; margin-bottom: .5rem; }
.reason-tier .tier-label::before { content: '②'; margin-right: .35rem; color: var(--primary); }
.choice.reason { font-size: .9rem; }

/* ---- 問題に添える図表 ---- */
.q-figure { margin: .4rem 0 .9rem; text-align: center; }
.q-figure-frame { position: relative; display: inline-block; max-width: 100%; }
.q-figure-frame .spinner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.q-figure img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; display: block; }
.q-figure figcaption { font-size: .72rem; color: var(--text-faint); margin-top: .3rem; }

/* ---- ロゴマーク（重なった2つの円＝暗記と理解の二軸）---- */
.brand .logo .logo-mark { display: block; }
