/* =========================================================================
   043BASE デザイントークン
   - そのまま public/static/style.css の先頭に移せる CSS 変数だけで書いています。
   - ライト／ダークの両方を持ちます。OS の設定に合わせ、
     <html data-theme="light|dark"> を付けたときはそちらを優先します。
   - 色の名前は「役目」で付けています（--brand, --surface など）。
     画面側の CSS では生の色（--c-pink-500 など）を直接使わず、役目の変数を使ってください。
   ========================================================================= */

:root {
  /* ---------- 生の色（パレット）：043Production 公式サイトの色から ---------- */
  --c-pink-50: #fff1f8;
  --c-pink-100: #ffdcee;
  --c-pink-300: #ff8cc6;
  --c-pink-500: #ff1d97; /* 公式のボタンの色。白文字だと読みにくいので面には 600 を使う */
  --c-pink-600: #d90f7c; /* 白文字とのコントラスト 4.9:1 */
  --c-pink-700: #b00a64;
  --c-pink-800: #8a0850;

  --c-yellow-100: #fff6d1;
  --c-yellow-300: #ffd955; /* 公式のマーカー（下線）の色 */
  --c-yellow-800: #7a5c00;

  --c-cyan-100: #ddf7f6;
  --c-cyan-300: #55d9d8;
  --c-teal-700: #007173;

  --c-blue-100: #e3f2fd;
  --c-blue-500: #29a2f0;
  --c-blue-700: #0b6aa8;

  --c-red-100: #fde8e8;
  --c-red-700: #c0262d;

  --c-ink-900: #1a1a1f; /* 公式の文字色 */
  --c-ink-700: #3a3b42;
  --c-ink-500: #5c6266;
  --c-ink-300: #a3a6b4;
  --c-ink-200: #dcdde5;
  --c-ink-100: #ececf2;
  --c-ink-50: #f6f6f9;
  --c-white: #ffffff;

  /* ---------- 役目の色（ライト） ---------- */
  --bg: var(--c-ink-50);           /* ページの地 */
  --surface: var(--c-white);       /* カードなどの面 */
  --surface-2: #fafafc;            /* 面の中の一段沈んだところ（入力欄・コード） */
  --surface-sunken: var(--c-ink-100);
  --line: var(--c-ink-200);
  --line-strong: #c9cad4;

  --text: var(--c-ink-900);
  --text-sub: var(--c-ink-500);    /* 補足の文字。白地で 6:1 */
  --text-inverse: var(--c-white);

  --brand: var(--c-pink-600);      /* 主ボタン・リンク・進行中 */
  --brand-hover: var(--c-pink-700);
  --brand-press: var(--c-pink-800);/* 主ボタンの下の段（公式サイト風の立体感） */
  --brand-soft: var(--c-pink-50);  /* 選択中・淡い強調の地 */
  --brand-soft-line: var(--c-pink-100);
  --on-brand: var(--c-white);

  --marker: var(--c-yellow-300);   /* 見出しのマーカー・連続日数 */
  --marker-soft: var(--c-yellow-100);

  --done: var(--c-teal-700);       /* 完了・読了 */
  --done-soft: var(--c-cyan-100);
  --done-accent: var(--c-cyan-300);

  --info: var(--c-blue-700);
  --info-soft: var(--c-blue-100);
  --danger: var(--c-red-700);
  --danger-soft: var(--c-red-100);

  /* バッジ（公開範囲・運営） */
  --badge-043-bg: var(--c-pink-50);
  --badge-043-fg: var(--c-pink-700);
  --badge-043-line: var(--c-pink-100);
  --badge-paid-bg: var(--c-yellow-100);
  --badge-paid-fg: var(--c-yellow-800);
  --badge-paid-line: #f5e39a;
  --badge-free-bg: var(--c-cyan-100);
  --badge-free-fg: var(--c-teal-700);
  --badge-free-line: #b6ecea;
  --badge-staff-bg: var(--c-ink-900);
  --badge-staff-fg: var(--c-white);

  /* 進み具合バー */
  --progress-track: var(--c-ink-100);
  --progress-fill: var(--brand);
  --progress-done: var(--done);

  /* ダミー画像（サムネイル）用のグラデーション */
  --thumb-1: linear-gradient(135deg, #ffd9ec 0%, #ffb3d9 100%);
  --thumb-2: linear-gradient(135deg, #d5f5f4 0%, #9fe6e4 100%);
  --thumb-3: linear-gradient(135deg, #fff3c4 0%, #ffe07a 100%);
  --thumb-4: linear-gradient(135deg, #dcefff 0%, #a8d6fb 100%);
  --thumb-5: linear-gradient(135deg, #ece3ff 0%, #cbb8f5 100%);
  --thumb-ink: rgba(26, 26, 31, 0.78);

  --focus-ring: 0 0 0 3px rgba(41, 162, 240, 0.45);

  /* ---------- 文字 ---------- */
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-head: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", var(--font-body);
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --fs-2xs: 0.6875rem; /* 11px：小さなラベル（英字）だけ */
  --fs-xs: 0.75rem;    /* 12px：バッジ・時間 */
  --fs-sm: 0.875rem;   /* 14px：補足・メタ情報 */
  --fs-md: 1rem;       /* 16px：本文（これより小さくしない） */
  --fs-lg: 1.125rem;   /* 18px：カードの題名 */
  --fs-xl: 1.375rem;   /* 22px：セクション見出し */
  --fs-2xl: clamp(1.5rem, 1.2rem + 1.2vw, 1.875rem);   /* 24→30px：ページ見出し */
  --fs-3xl: clamp(1.75rem, 1.3rem + 1.8vw, 2.375rem);  /* 28→38px：あいさつ */

  --lh-tight: 1.35;  /* 見出し */
  --lh-body: 1.8;    /* 日本語の本文はゆったり */
  --lh-ui: 1.5;      /* ボタン・ラベル */

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-bold: 700;
  --fw-black: 900;

  --tracking-label: 0.08em; /* 英字ラベル（CONTINUE など） */

  /* ---------- 余白（4px 刻み） ---------- */
  --sp-1: 0.25rem;  /* 4 */
  --sp-2: 0.5rem;   /* 8 */
  --sp-3: 0.75rem;  /* 12 */
  --sp-4: 1rem;     /* 16 */
  --sp-5: 1.25rem;  /* 20 */
  --sp-6: 1.5rem;   /* 24 */
  --sp-8: 2rem;     /* 32 */
  --sp-10: 2.5rem;  /* 40 */
  --sp-12: 3rem;    /* 48 */
  --sp-16: 4rem;    /* 64 */

  --gutter: var(--sp-4);          /* 画面の左右の余白（スマホ） */
  --container: 1120px;            /* 中身の最大幅 */
  --container-narrow: 760px;      /* 文章を読む幅 */
  --header-h: 60px;
  --tabbar-h: 64px;               /* スマホ下のタブバー */
  --tap: 44px;                    /* 押せるものの最小の高さ */

  /* ---------- 角丸 ---------- */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* ---------- 影 ---------- */
  --shadow-sm: 0 1px 2px rgba(26, 26, 31, 0.06);
  --shadow-md: 0 2px 4px rgba(26, 26, 31, 0.04), 0 8px 24px rgba(26, 26, 31, 0.06);
  --shadow-lg: 0 12px 40px rgba(26, 26, 31, 0.14);
  --shadow-btn: 0 3px 0 var(--brand-press);   /* 主ボタンの立体感（押すと沈む） */
  --shadow-btn-sub: 0 3px 0 var(--line-strong);

  /* ---------- 動き ---------- */
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --dur-fast: 120ms;
  --dur: 200ms;

  color-scheme: light;
}

/* ---------- 役目の色（ダーク） ----------
   OS がダークのとき（ただし data-theme="light" を明示したときは除く） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131317;
    --surface: #1d1d23;
    --surface-2: #24242b;
    --surface-sunken: #18181d;
    --line: #2f2f38;
    --line-strong: #44444f;

    --text: #ededf2;
    --text-sub: #a9acb9;
    --text-inverse: var(--c-ink-900);

    --brand: #ff5cad;
    --brand-hover: #ff7dbd;
    --brand-press: #b0306f;
    --brand-soft: #34172a;
    --brand-soft-line: #4d2140;
    --on-brand: var(--c-ink-900);

    --marker: #e9c23e;
    --marker-soft: #352d14;

    --done: #5fdcd9;
    --done-soft: #12302f;
    --done-accent: #2aa9a6;

    --info: #7cc4f5;
    --info-soft: #142a3a;
    --danger: #ff8a8f;
    --danger-soft: #3a1a1c;

    --badge-043-bg: #34172a;
    --badge-043-fg: #ff9fcf;
    --badge-043-line: #4d2140;
    --badge-paid-bg: #352d14;
    --badge-paid-fg: #ffd955;
    --badge-paid-line: #4a3f1c;
    --badge-free-bg: #12302f;
    --badge-free-fg: #6fe3e0;
    --badge-free-line: #1d4544;
    --badge-staff-bg: #ededf2;
    --badge-staff-fg: var(--c-ink-900);

    --progress-track: #2c2c35;

    --thumb-1: linear-gradient(135deg, #4a1f38 0%, #7a2a58 100%);
    --thumb-2: linear-gradient(135deg, #123b3a 0%, #1f6362 100%);
    --thumb-3: linear-gradient(135deg, #3d3412 0%, #6b5917 100%);
    --thumb-4: linear-gradient(135deg, #15304a 0%, #22537d 100%);
    --thumb-5: linear-gradient(135deg, #2c2347 0%, #4a3a78 100%);
    --thumb-ink: rgba(255, 255, 255, 0.86);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);

    color-scheme: dark;
  }
}

/* data-theme="dark" を明示したとき（上と同じ値。変えるときは両方そろえる） */
:root[data-theme="dark"] {
  --bg: #131317;
  --surface: #1d1d23;
  --surface-2: #24242b;
  --surface-sunken: #18181d;
  --line: #2f2f38;
  --line-strong: #44444f;

  --text: #ededf2;
  --text-sub: #a9acb9;
  --text-inverse: var(--c-ink-900);

  --brand: #ff5cad;
  --brand-hover: #ff7dbd;
  --brand-press: #b0306f;
  --brand-soft: #34172a;
  --brand-soft-line: #4d2140;
  --on-brand: var(--c-ink-900);

  --marker: #e9c23e;
  --marker-soft: #352d14;

  --done: #5fdcd9;
  --done-soft: #12302f;
  --done-accent: #2aa9a6;

  --info: #7cc4f5;
  --info-soft: #142a3a;
  --danger: #ff8a8f;
  --danger-soft: #3a1a1c;

  --badge-043-bg: #34172a;
  --badge-043-fg: #ff9fcf;
  --badge-043-line: #4d2140;
  --badge-paid-bg: #352d14;
  --badge-paid-fg: #ffd955;
  --badge-paid-line: #4a3f1c;
  --badge-free-bg: #12302f;
  --badge-free-fg: #6fe3e0;
  --badge-free-line: #1d4544;
  --badge-staff-bg: #ededf2;
  --badge-staff-fg: var(--c-ink-900);

  --progress-track: #2c2c35;

  --thumb-1: linear-gradient(135deg, #4a1f38 0%, #7a2a58 100%);
  --thumb-2: linear-gradient(135deg, #123b3a 0%, #1f6362 100%);
  --thumb-3: linear-gradient(135deg, #3d3412 0%, #6b5917 100%);
  --thumb-4: linear-gradient(135deg, #15304a 0%, #22537d 100%);
  --thumb-5: linear-gradient(135deg, #2c2347 0%, #4a3a78 100%);
  --thumb-ink: rgba(255, 255, 255, 0.86);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);

  color-scheme: dark;
}

@media (min-width: 768px) {
  :root {
    --gutter: var(--sp-6);
    --header-h: 64px;
  }
}

:root {
  /* 管理画面・コメント・AIパネルの古い変数名を新しい色に合わせる */
  --fg: var(--text); --muted: var(--text-sub); --card: var(--surface);
  --primary: var(--brand); --primary-fg: var(--on-brand);
  --done-bg: var(--done-soft); --partial: var(--c-yellow-800); --partial-bg: var(--marker-soft);
  --warn: var(--danger); --warn-bg: var(--danger-soft);
}

/* ===== 管理画面などの部品（古い名前） ===== */
* { box-sizing: border-box; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
span.small { display: block; }
.notice { background: var(--done-bg); border-radius: 8px; padding: 10px 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; border: 0; padding: 0; margin: 0; }
fieldset.stack { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.inline-check, .stack label:has(input[type="radio"]) { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
input[type="text"], input[type="number"], textarea, select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--fg); width: 100%;
}
select { width: auto; }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.button, button.button {
  display: inline-block; font: inherit; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); text-decoration: none; cursor: pointer; min-height: 44px;
}
.button.primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.button.small { padding: 6px 10px; min-height: 36px; font-size: 14px; }
.button:disabled { opacity: 0.6; }
.link-button { background: none; border: 0; color: var(--primary); font: inherit; line-height: inherit; cursor: pointer; padding: 0; }
form.inline { display: inline-flex; margin: 0; }
.fake-player { background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.fake-screen { aspect-ratio: 16 / 9; background: #222; color: #ddd; display: grid; place-items: center; border-radius: 8px; }
.fake-bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.fake-fill { height: 100%; width: 0; background: var(--primary); }
.fake-time { font-size: 14px; color: var(--muted); }
.progress-text { font-weight: 600; }
.markdown { overflow-wrap: anywhere; }
.markdown img { max-width: 100%; height: auto; }
.markdown pre { overflow-x: auto; background: var(--card); padding: 12px; border-radius: 8px; border: 1px solid var(--line); }
.read-sentinel { margin: 32px 0 16px; padding: 12px; text-align: center; border-top: 1px dashed var(--line); color: var(--muted); }
.read-sentinel.done { color: var(--done); font-weight: 700; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
.matrix th:not(.sticky) { min-width: 120px; white-space: normal; }
.matrix .sticky { position: sticky; left: 0; background: var(--card); z-index: 1; }
.cell.done { background: var(--done-bg); color: var(--done); font-weight: 700; }
.cell.partial { background: var(--partial-bg); color: var(--partial); }
.cell.none { color: var(--muted); }
.consent-text li { margin-bottom: 8px; }
.member-list { list-style: none; padding: 0; margin: 0; }
.member-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.member-meta { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0 0 12px; font-size: 14px; }
.member-meta dt { color: var(--muted); }
.member-meta dd { margin: 0; overflow-wrap: anywhere; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.preview { margin-top: 8px; padding: 12px; border: 1px dashed var(--line); border-radius: 8px; background: var(--card); }
.card.danger { border-color: var(--warn); }
.button.danger, button.button.danger { background: var(--warn); border-color: var(--warn); color: #fff; }
.post-list > .card { margin: 0; }
/* 「AIに質問」パネル。広い画面ではレッスンの横、スマホでは下 */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ai-panel summary { font-weight: 700; cursor: pointer; }
.ai-log { display: grid; gap: 8px; margin: 8px 0; max-height: 60vh; overflow-y: auto; }
.ai-msg { margin: 0; padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-msg.q { background: var(--bg); justify-self: end; }
.ai-msg.a { border: 1px solid var(--line); }
.ai-msg.wait { color: var(--muted); }
.ai-msg.err { background: var(--warn-bg); color: var(--warn); }
.ai-q, .ai-a { white-space: pre-wrap; overflow-wrap: anywhere; }
.comments { margin-top: 32px; padding-top: 8px; border-top: 1px solid var(--line); }
.comment-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; }
.comment { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.comment.is-hidden { border-style: dashed; opacity: 0.8; }
.comment-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0; }
.comment-replies { margin: 8px 0 0 20px; padding-left: 12px; border-left: 2px solid var(--line); }
.comment-actions { display: grid; gap: 8px; font-size: 14px; }
.comment-reply { margin: 6px 0 0 20px; }
.comments textarea { font-family: inherit; font-size: 16px; }
.small-inline { font-size: 13px; }
.badge.staff { background: var(--primary); color: var(--primary-fg); }

/* 講座の管理画面 */
.grow { flex: 1 1 auto; min-width: 0; }
.section-edit { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0 0 12px; display: grid; gap: 8px; }
.section-edit-head form input[type="text"] { width: auto; flex: 1 1 160px; }
.lesson-edit-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* ===== デザインの部品（design/components.css から） ===== */
/* =========================================================================
   043BASE 共通部品と画面の見本スタイル
   - tokens.css の変数だけを使っています（生の色は書かない）。
   - クラス名は「部品名」と「部品名__部分」「部品名--種類」の形。
     サーバー側 JSX の部品（<Button>, <Badge>, <Progress> …）と 1 対 1 で対応させる想定です。
   ========================================================================= */

/* ---------- 下地 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  font-weight: var(--fw-medium);
  font-feature-settings: "palt" 0;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--brand); text-underline-offset: 0.2em; }
a:hover { color: var(--brand-hover); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-xs); }
h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  margin: 0;
  letter-spacing: 0.01em;
}
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon--fill { fill: currentColor; stroke: none; }

/* ---------- ヘッダー ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  max-width: var(--container); height: 100%; margin: 0 auto; padding: 0 var(--gutter);
  display: flex; align-items: center; gap: var(--sp-4);
}
.brand {
  display: inline-flex; align-items: baseline; gap: 2px;
  font-family: var(--font-head); font-weight: var(--fw-black); font-size: 1.375rem;
  color: var(--text); text-decoration: none; letter-spacing: 0.02em; line-height: 1;
}
.brand:hover { color: var(--text); }
.brand__num { color: var(--brand); }
.brand__word {
  background: linear-gradient(transparent 62%, var(--marker) 62%, var(--marker) 92%, transparent 92%);
  padding: 0 1px;
}
.gnav { display: none; gap: var(--sp-1); margin-left: var(--sp-4); }
.gnav a {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 40px; padding: 0 var(--sp-3); border-radius: var(--r-pill);
  color: var(--text-sub); text-decoration: none; font-weight: var(--fw-bold); font-size: var(--fs-sm);
}
.gnav a:hover { background: var(--surface-sunken); color: var(--text); }
.gnav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.site-header__end { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-pill);
  color: var(--text-sub); background: transparent; border: 0; cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-sunken); color: var(--text); }
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: var(--r-pill);
  background: var(--thumb-1); color: var(--text);
  font-family: var(--font-head); font-weight: var(--fw-bold); font-size: var(--fs-sm);
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
  overflow: hidden;
}
.avatar--sm { width: 32px; height: 32px; font-size: var(--fs-xs); }
.avatar--lg { width: 88px; height: 88px; font-size: 2rem; border-width: 4px; }
.avatar--staff { background: var(--c-ink-900); color: var(--c-white); }
.avatar--ai { background: linear-gradient(135deg, var(--c-pink-500), var(--c-blue-500)); color: var(--c-white); }

@media (min-width: 768px) {
  .gnav { display: flex; }
}

/* ---------- スマホ下のタブバー ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-sub); text-decoration: none; font-size: var(--fs-2xs); font-weight: var(--fw-bold);
}
.tabbar a .icon { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--brand); }
body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
@media (min-width: 768px) {
  .tabbar { display: none; }
  body.has-tabbar { padding-bottom: 0; }
}

/* ---------- ページの骨組み ---------- */
.page { max-width: var(--container); margin: 0 auto; padding: var(--sp-6) var(--gutter) var(--sp-12); }
.page--narrow { max-width: calc(var(--container-narrow) + var(--gutter) * 2); }
.section { margin-top: var(--sp-10); }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.section-head h2 { font-size: var(--fs-xl); }
.section-head__more { font-size: var(--fs-sm); font-weight: var(--fw-bold); text-decoration: none; white-space: nowrap; }
.eyebrow {
  display: block; font-family: var(--font-mono); font-size: var(--fs-2xs); font-weight: 600;
  letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-sub); margin-bottom: var(--sp-1);
}
.text-sub { color: var(--text-sub); }
.text-sm { font-size: var(--fs-sm); }
.marker {
  background: linear-gradient(transparent 60%, var(--marker) 60%, var(--marker) 92%, transparent 92%);
  padding: 0 2px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.breadcrumb { display: flex; flex-wrap: wrap; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--text-sub); margin-bottom: var(--sp-3); list-style: none; }
.breadcrumb li + li::before { content: "›"; margin-right: var(--sp-1); color: var(--line-strong); }
.breadcrumb a { color: var(--text-sub); text-decoration: none; }
.breadcrumb a:hover { color: var(--brand); text-decoration: underline; }

.site-footer {
  max-width: var(--container); margin: 0 auto; padding: var(--sp-6) var(--gutter) var(--sp-10);
  display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); font-size: var(--fs-sm); color: var(--text-sub);
  border-top: 1px solid var(--line);
}
.site-footer a { color: var(--text-sub); }

/* ---------- ボタン ---------- */
.btn {
  --_bg: var(--surface); --_fg: var(--text); --_line: var(--line-strong); --_shadow: var(--shadow-btn-sub);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 var(--sp-5);
  font: inherit; font-weight: var(--fw-bold); font-size: var(--fs-md); line-height: var(--lh-ui);
  color: var(--_fg); background: var(--_bg); border: 1.5px solid var(--_line); border-radius: var(--r-pill);
  box-shadow: var(--_shadow); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast);
}
.btn:hover { color: var(--_fg); background: color-mix(in srgb, var(--_bg) 92%, var(--text)); }
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn .icon { width: 1.15em; height: 1.15em; }
.btn--primary { --_bg: var(--brand); --_fg: var(--on-brand); --_line: var(--brand); --_shadow: var(--shadow-btn); }
.btn--primary:hover { --_bg: var(--brand-hover); background: var(--brand-hover); }
.btn--ghost { --_bg: transparent; --_line: transparent; --_shadow: none; --_fg: var(--text-sub); padding: 0 var(--sp-3); }
.btn--ghost:hover { background: var(--surface-sunken); color: var(--text); }
.btn--done { --_bg: var(--done-soft); --_fg: var(--done); --_line: var(--done-accent); --_shadow: none; }
.btn--sm { min-height: 36px; padding: 0 var(--sp-4); font-size: var(--fs-sm); }
.btn--block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

/* ---------- バッジ ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 var(--sp-2);
  font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 1; white-space: nowrap;
  border-radius: var(--r-pill); border: 1px solid var(--line);
  background: var(--surface-sunken); color: var(--text-sub);
}
.badge .icon { width: 12px; height: 12px; stroke-width: 2.5; }
.badge--043 { background: var(--badge-043-bg); color: var(--badge-043-fg); border-color: var(--badge-043-line); }
.badge--paid { background: var(--badge-paid-bg); color: var(--badge-paid-fg); border-color: var(--badge-paid-line); }
.badge--free { background: var(--badge-free-bg); color: var(--badge-free-fg); border-color: var(--badge-free-line); }
.badge--staff { background: var(--badge-staff-bg); color: var(--badge-staff-fg); border-color: transparent; }
.badge--done { background: var(--done-soft); color: var(--done); border-color: transparent; }
.badge--progress { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.badge--new { background: var(--marker); color: var(--c-ink-900); border-color: transparent; font-family: var(--font-mono); letter-spacing: 0.04em; }
.badges { display: flex; flex-wrap: wrap; gap: var(--sp-1); }

/* ---------- 進み具合バー ----------
   <div class="progress" style="--value: 40%"> の --value だけ変える。
   role="progressbar" と aria-valuenow を必ず付ける。 */
.progress { display: grid; gap: var(--sp-1); }
.progress__track {
  position: relative; height: 8px; border-radius: var(--r-pill);
  background: var(--progress-track); overflow: hidden;
}
.progress__bar {
  position: absolute; inset: 0 auto 0 0; width: var(--value, 0%);
  border-radius: inherit; background: var(--progress-fill);
}
.progress__label { display: flex; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-sub); }
.progress__label strong { color: var(--text); font-family: var(--font-mono); font-weight: 600; }
.progress--done .progress__bar { background: var(--progress-done); }
.progress--done .progress__label strong { color: var(--done); }
.progress--thin .progress__track { height: 4px; }
.progress--lg .progress__track { height: 12px; }

/* ---------- カード ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--sp-5); box-shadow: var(--shadow-sm);
}
.card--flat { box-shadow: none; }
a.card, .card--link { display: block; color: inherit; text-decoration: none; transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur); }
a.card:hover, .card--link:hover { color: inherit; box-shadow: var(--shadow-md); border-color: var(--line-strong); transform: translateY(-2px); }

/* ダミーのサムネイル。実装では Stream のサムネイル <img> をこの中に入れる */
.thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-md); overflow: hidden;
  background: var(--thumb-1); color: var(--thumb-ink);
  display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb--2 { background: var(--thumb-2); }
.thumb--3 { background: var(--thumb-3); }
.thumb--4 { background: var(--thumb-4); }
.thumb--5 { background: var(--thumb-5); }
.thumb__mark { font-family: var(--font-head); font-weight: var(--fw-black); font-size: clamp(1.25rem, 4vw, 1.75rem); opacity: 0.9; letter-spacing: 0.04em; }
.thumb__time {
  position: absolute; right: var(--sp-2); bottom: var(--sp-2);
  padding: 2px 6px; border-radius: var(--r-xs);
  background: rgba(26, 26, 31, 0.78); color: #fff; font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.4;
}
.thumb__kind {
  position: absolute; left: var(--sp-2); top: var(--sp-2);
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.92); color: var(--c-ink-900); font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 1.5;
}
.thumb__kind .icon { width: 12px; height: 12px; }
.thumb__progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(26, 26, 31, 0.25); }
.thumb__progress span { display: block; height: 100%; width: var(--value, 0%); background: var(--brand); }

/* 講座カード */
.course-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; height: 100%; }
.course-card .thumb { border-radius: 0; }
.course-card__body { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4); flex: 1; }
.course-card__title { font-family: var(--font-body); font-size: var(--fs-lg); font-weight: var(--fw-bold); line-height: var(--lh-tight); }
.course-card__meta { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); color: var(--text-sub); }
.course-card__meta span { display: inline-flex; align-items: center; gap: 4px; }
.course-card__meta .icon { width: 14px; height: 14px; }
.course-card .progress { margin-top: auto; padding-top: var(--sp-2); }

.course-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); list-style: none; }

/* スマホでは横にすべらせる列 */
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: 78%; gap: var(--sp-3);
  overflow-x: auto; scroll-snap-type: x mandatory; list-style: none;
  margin: 0 calc(var(--gutter) * -1); padding: var(--sp-1) var(--gutter) var(--sp-3);
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; }
@media (min-width: 560px) { .rail { grid-auto-columns: 44%; } }
@media (min-width: 960px) {
  .rail { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: repeat(3, 1fr); overflow: visible; margin: 0; padding: 0; }
}

/* 「続きから見る」カード（横長） */
.resume {
  display: grid; grid-template-columns: 1fr; gap: var(--sp-4);
  padding: var(--sp-4); border-radius: var(--r-xl);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-md);
}
.resume__thumb { position: relative; }
.resume__body { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.resume__course { font-size: var(--fs-sm); color: var(--text-sub); font-weight: var(--fw-bold); }
.resume__title { font-family: var(--font-body); font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); }
.resume__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
@media (min-width: 720px) {
  .resume { grid-template-columns: minmax(260px, 44%) 1fr; padding: var(--sp-5); align-items: center; gap: var(--sp-6); }
}

/* 小さな横並びの行（途中の講座・最近見たもの・新着） */
.media-list { list-style: none; display: grid; gap: var(--sp-2); }
.media-row {
  display: grid; grid-template-columns: 112px 1fr; gap: var(--sp-3); align-items: center;
  padding: var(--sp-2); border-radius: var(--r-md); color: inherit; text-decoration: none;
}
a.media-row:hover { background: var(--surface-sunken); color: inherit; }
.media-row .thumb { border-radius: var(--r-sm); }
.media-row .thumb__mark { font-size: 1rem; }
.media-row__body { min-width: 0; display: grid; gap: 2px; }
.media-row__title { font-weight: var(--fw-bold); line-height: var(--lh-tight); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.media-row__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); font-size: var(--fs-sm); color: var(--text-sub); }
.media-row .progress { margin-top: var(--sp-1); }
@media (min-width: 768px) { .media-row { grid-template-columns: 144px 1fr; } }

/* ---------- 空っぽのときの表示 ---------- */
.empty {
  display: grid; justify-items: center; gap: var(--sp-2); text-align: center;
  padding: var(--sp-8) var(--sp-5); border-radius: var(--r-lg);
  border: 1.5px dashed var(--line-strong); background: var(--surface-2); color: var(--text-sub);
}
.empty__icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: var(--r-pill);
  background: var(--marker-soft); color: var(--text); margin-bottom: var(--sp-1);
}
.empty__icon .icon { width: 26px; height: 26px; }
.empty__title { font-family: var(--font-head); font-size: var(--fs-lg); color: var(--text); }
.empty__text { font-size: var(--fs-sm); max-width: 32em; }
.empty .btn { margin-top: var(--sp-2); }
.empty--compact { padding: var(--sp-5) var(--sp-4); grid-template-columns: auto 1fr; justify-items: start; text-align: left; align-items: center; }
.empty--compact .empty__icon { width: 44px; height: 44px; margin: 0; grid-row: span 2; }

/* ---------- お知らせ ---------- */
.notice { display: flex; gap: var(--sp-2); align-items: flex-start; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--done-soft); color: var(--text); font-size: var(--fs-sm); }
.notice .icon { color: var(--done); margin-top: 3px; }
.notice--warn { background: var(--danger-soft); }
.notice--warn .icon { color: var(--danger); }

/* =========================================================================
   トップ
   ========================================================================= */
.hello { display: grid; gap: var(--sp-4); margin-bottom: var(--sp-8); }
.hello__title { font-size: var(--fs-3xl); font-weight: var(--fw-black); }
.hello__sub { color: var(--text-sub); }
.streak-chip {
  display: inline-flex; align-items: center; gap: var(--sp-2); justify-self: start;
  padding: var(--sp-2) var(--sp-4) var(--sp-2) var(--sp-2); border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-size: var(--fs-sm);
}
.streak-chip__num {
  display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 var(--sp-2); border-radius: var(--r-pill);
  background: var(--marker); color: var(--c-ink-900); font-family: var(--font-mono); font-weight: 600;
}
.week-dots { display: inline-flex; gap: 4px; margin-left: var(--sp-1); }
.week-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--progress-track); }
.week-dots i.on { background: var(--brand); }
@media (min-width: 768px) {
  .hello { grid-template-columns: 1fr auto; align-items: end; }
  .streak-chip { justify-self: end; }
}

.home-grid { display: grid; gap: var(--sp-10); }
@media (min-width: 1024px) {
  .home-grid { grid-template-columns: 1fr 340px; gap: var(--sp-8); align-items: start; }
  .home-grid > aside { position: sticky; top: calc(var(--header-h) + var(--sp-6)); }
}

/* =========================================================================
   講座ページ
   ========================================================================= */
.course-hero { display: grid; gap: var(--sp-5); margin-bottom: var(--sp-8); }
.course-hero__title { font-size: var(--fs-2xl); font-weight: var(--fw-black); }
.course-hero__lead { color: var(--text); max-width: 40em; }
.course-hero__facts { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); font-size: var(--fs-sm); color: var(--text-sub); list-style: none; }
.course-hero__facts li { display: inline-flex; align-items: center; gap: 6px; }
.course-hero__facts .icon { width: 16px; height: 16px; }
.course-status { display: grid; gap: var(--sp-4); }
.course-status__next { font-size: var(--fs-sm); color: var(--text-sub); }
.course-status__next strong { display: block; color: var(--text); font-size: var(--fs-md); line-height: var(--lh-tight); margin-top: 2px; }
@media (min-width: 900px) {
  .course-hero { grid-template-columns: 1fr 360px; align-items: start; gap: var(--sp-8); }
  .course-status { position: sticky; top: calc(var(--header-h) + var(--sp-6)); }
}

.chapter { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.chapter + .chapter { margin-top: var(--sp-3); }
.chapter__head {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4); cursor: pointer; list-style: none;
}
.chapter__head::-webkit-details-marker { display: none; }
.chapter__no {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--surface-sunken); font-family: var(--font-mono); font-weight: 600; font-size: var(--fs-sm);
}
.chapter--done .chapter__no { background: var(--done-soft); color: var(--done); }
.chapter__title { font-size: var(--fs-lg); font-family: var(--font-body); font-weight: var(--fw-bold); line-height: var(--lh-tight); }
.chapter__count { display: block; font-size: var(--fs-sm); color: var(--text-sub); font-weight: var(--fw-medium); margin-top: 2px; }
.chapter__chev { color: var(--text-sub); transition: transform var(--dur) var(--ease); }
.chapter[open] .chapter__chev { transform: rotate(180deg); }

.lesson-list { list-style: none; border-top: 1px solid var(--line); }
.lesson-item + .lesson-item { border-top: 1px solid var(--line); }
.lesson-item > a, .lesson-item > .lesson-item__inner {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-3);
  min-height: 60px; padding: var(--sp-3) var(--sp-4); color: inherit; text-decoration: none;
}
.lesson-item > a:hover { background: var(--surface-2); color: inherit; }
.lesson-item__title { font-weight: var(--fw-bold); line-height: var(--lh-tight); }
.lesson-item__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); font-size: var(--fs-sm); color: var(--text-sub); margin-top: 2px; }
.lesson-item__meta .icon { width: 14px; height: 14px; }
.lesson-item__end { font-size: var(--fs-sm); color: var(--text-sub); font-family: var(--font-mono); }
.lesson-item--current > a { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.lesson-item--locked { color: var(--text-sub); }

/* 完了チェック（丸） */
.check {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none;
  border: 2px solid var(--line-strong); color: transparent; background: var(--surface);
}
.check .icon { width: 16px; height: 16px; stroke-width: 3; }
.check--done { background: var(--done); border-color: var(--done); color: var(--surface); }
.check--current { border-color: var(--brand); color: var(--brand); }
.check--current .icon { stroke-width: 0; fill: currentColor; width: 12px; height: 12px; }
.check--locked { border-style: dashed; color: var(--text-sub); }
.check--locked .icon { stroke-width: 2; width: 14px; height: 14px; }

/* =========================================================================
   レッスンページ
   ========================================================================= */
.lesson-layout { display: grid; gap: var(--sp-6); }
.lesson-main { min-width: 0; }
@media (min-width: 1024px) {
  .lesson-layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
  .lesson-layout:has(> .ai-panel:not([open])) { grid-template-columns: minmax(0, 1fr) 220px; }
  .ai-panel { position: sticky; top: calc(var(--header-h) + var(--sp-4)); }
}

.player {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-lg); overflow: hidden;
  background: #0f0f13; color: #fff; display: grid; place-items: center;
  margin: 0 calc(var(--gutter) * -1);
}
@media (min-width: 640px) { .player { margin: 0; } }
@media (max-width: 639px) { .player { border-radius: 0; } }
.player__bg { position: absolute; inset: 0; background: var(--thumb-1); opacity: 0.35; }
.player__play {
  position: relative; display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.95); color: var(--c-pink-600); box-shadow: var(--shadow-lg);
}
.player__play .icon { width: 30px; height: 30px; margin-left: 4px; }
.player__bar { position: absolute; left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-3); display: grid; grid-template-columns: 1fr auto; gap: var(--sp-3); align-items: center; font-family: var(--font-mono); font-size: var(--fs-xs); }
.player__bar .progress__track { background: rgba(255, 255, 255, 0.25); height: 4px; }
.player__bar .progress__bar { background: var(--c-pink-500); }

.lesson-head { display: grid; gap: var(--sp-2); margin: var(--sp-5) 0 var(--sp-4); }
.lesson-head__title { font-size: var(--fs-2xl); font-weight: var(--fw-black); }
.lesson-head__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); color: var(--text-sub); }

.lesson-actions {
  display: grid; gap: var(--sp-3); padding: var(--sp-4); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line);
}
.lesson-actions__status { font-size: var(--fs-sm); color: var(--text-sub); }
@media (min-width: 640px) {
  .lesson-actions { grid-template-columns: 1fr auto; align-items: center; }
}

.lesson-nav { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-top: var(--sp-4); }
.lesson-nav a {
  display: grid; gap: 2px; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none; min-width: 0;
}
.lesson-nav a:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); color: inherit; }
.lesson-nav__dir { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--text-sub); font-weight: var(--fw-bold); }
.lesson-nav__dir .icon { width: 14px; height: 14px; }
.lesson-nav__title { font-weight: var(--fw-bold); font-size: var(--fs-sm); line-height: var(--lh-tight); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lesson-nav__next { text-align: right; justify-items: end; }

.prose { margin-top: var(--sp-8); }
.prose > * + * { margin-top: var(--sp-4); }
.prose h2 { font-size: var(--fs-xl); margin-top: var(--sp-8); padding-left: var(--sp-3); border-left: 4px solid var(--marker); }
.prose ul { padding-left: 1.4em; }
.prose li + li { margin-top: var(--sp-1); }
.prose blockquote { margin: 0; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--marker-soft); }

/* 講座の目次（レッスンページ内） */
.toc { margin-top: var(--sp-6); }
.toc > summary { list-style: none; cursor: pointer; }
.toc > summary::-webkit-details-marker { display: none; }
.toc__summary { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); }
.toc__summary .progress { flex: 1; }


/* =========================================================================
   マイページ
   ========================================================================= */
.profile { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-4); align-items: center; }
.profile__name { font-size: var(--fs-2xl); font-weight: var(--fw-black); }
.profile__meta { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); color: var(--text-sub); margin-top: var(--sp-1); align-items: center; }
.profile__actions { grid-column: 1 / -1; display: flex; gap: var(--sp-2); }
@media (min-width: 720px) {
  .profile { grid-template-columns: auto 1fr auto; }
  .profile__actions { grid-column: auto; }
}

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); list-style: none; }
.stat { padding: var(--sp-4); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.stat__label { font-size: var(--fs-sm); color: var(--text-sub); font-weight: var(--fw-bold); }
.stat__value { font-family: var(--font-head); font-weight: var(--fw-black); font-size: 2rem; line-height: 1.2; margin-top: var(--sp-1); }
.stat__value small { font-family: var(--font-body); font-size: var(--fs-sm); font-weight: var(--fw-bold); margin-left: 2px; color: var(--text-sub); }
.stat--hot { background: var(--marker-soft); border-color: transparent; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, 1fr); } }

/* 学習日カレンダー（直近5週） */
.study-cal { display: grid; gap: var(--sp-3); }
.study-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; list-style: none; max-width: 420px; }
.study-cal__grid li { aspect-ratio: 1; border-radius: var(--r-xs); background: var(--progress-track); }
.study-cal__grid li.l1 { background: color-mix(in srgb, var(--brand) 35%, var(--progress-track)); }
.study-cal__grid li.l2 { background: color-mix(in srgb, var(--brand) 65%, var(--progress-track)); }
.study-cal__grid li.l3 { background: var(--brand); }
.study-cal__grid li.today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--marker); }
.study-cal__week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; max-width: 420px; font-size: var(--fs-xs); color: var(--text-sub); text-align: center; }
.study-cal__legend { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--text-sub); }
.study-cal__legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--progress-track); }
.study-cal__legend i.l1 { background: color-mix(in srgb, var(--brand) 35%, var(--progress-track)); }
.study-cal__legend i.l2 { background: color-mix(in srgb, var(--brand) 65%, var(--progress-track)); }
.study-cal__legend i.l3 { background: var(--brand); }

.mypage-grid { display: grid; gap: var(--sp-10); }
@media (min-width: 1024px) {
  .mypage-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-8); }
  .mypage-grid > .section { margin-top: 0; }
}

.done-course { display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-3); align-items: center; padding: var(--sp-3) var(--sp-4); }
.done-course__medal {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--done-soft); color: var(--done);
}
.done-course__title { font-weight: var(--fw-bold); line-height: var(--lh-tight); }
.done-course__date { font-size: var(--fs-sm); color: var(--text-sub); }

/* ---------- 小さな調整 ---------- */
.resume__thumb, .avatar, .brand { text-decoration: none; }
.home-grid > * { margin-top: 0; }
.resume__actions .btn { flex: 1 1 auto; }
@media (min-width: 720px) { .resume__actions .btn { flex: 0 0 auto; } }
@media (min-width: 1024px) {
  .lesson-top { grid-column: 1; grid-row: 1; }
  .lesson-bottom { grid-column: 1; grid-row: 2; }
  .lesson-ai { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
}
.lesson-layout { row-gap: 0; }
.lesson-ai { margin-top: var(--sp-6); }
@media (min-width: 1024px) { .lesson-ai { margin-top: 0; } }
.toc__summary > .icon { color: var(--text-sub); }
.toc__summary strong { white-space: nowrap; }
.toc[open] .chapter__chev { transform: rotate(180deg); }
a.card.done-course { display: grid; }
.lesson-head__meta > span { display: inline-flex; align-items: center; gap: 4px; }
.lesson-head__meta .icon { width: 16px; height: 16px; }
.study-cal__grid, .study-cal__week { max-width: 320px; }
.brand__word { background: linear-gradient(transparent 78%, var(--marker) 78%, var(--marker) 96%, transparent 96%); }
.course-status { padding: 0; overflow: hidden; }
.course-status .thumb { border-radius: 0; }
.course-status__inner { display: grid; gap: var(--sp-4); padding: var(--sp-5); }

/* 進み具合：CSP で style 属性が使えないので、--value はクラス（pv-0〜pv-100）で渡す */
.pv-0{--value:0%}
.pv-1{--value:1%}
.pv-2{--value:2%}
.pv-3{--value:3%}
.pv-4{--value:4%}
.pv-5{--value:5%}
.pv-6{--value:6%}
.pv-7{--value:7%}
.pv-8{--value:8%}
.pv-9{--value:9%}
.pv-10{--value:10%}
.pv-11{--value:11%}
.pv-12{--value:12%}
.pv-13{--value:13%}
.pv-14{--value:14%}
.pv-15{--value:15%}
.pv-16{--value:16%}
.pv-17{--value:17%}
.pv-18{--value:18%}
.pv-19{--value:19%}
.pv-20{--value:20%}
.pv-21{--value:21%}
.pv-22{--value:22%}
.pv-23{--value:23%}
.pv-24{--value:24%}
.pv-25{--value:25%}
.pv-26{--value:26%}
.pv-27{--value:27%}
.pv-28{--value:28%}
.pv-29{--value:29%}
.pv-30{--value:30%}
.pv-31{--value:31%}
.pv-32{--value:32%}
.pv-33{--value:33%}
.pv-34{--value:34%}
.pv-35{--value:35%}
.pv-36{--value:36%}
.pv-37{--value:37%}
.pv-38{--value:38%}
.pv-39{--value:39%}
.pv-40{--value:40%}
.pv-41{--value:41%}
.pv-42{--value:42%}
.pv-43{--value:43%}
.pv-44{--value:44%}
.pv-45{--value:45%}
.pv-46{--value:46%}
.pv-47{--value:47%}
.pv-48{--value:48%}
.pv-49{--value:49%}
.pv-50{--value:50%}
.pv-51{--value:51%}
.pv-52{--value:52%}
.pv-53{--value:53%}
.pv-54{--value:54%}
.pv-55{--value:55%}
.pv-56{--value:56%}
.pv-57{--value:57%}
.pv-58{--value:58%}
.pv-59{--value:59%}
.pv-60{--value:60%}
.pv-61{--value:61%}
.pv-62{--value:62%}
.pv-63{--value:63%}
.pv-64{--value:64%}
.pv-65{--value:65%}
.pv-66{--value:66%}
.pv-67{--value:67%}
.pv-68{--value:68%}
.pv-69{--value:69%}
.pv-70{--value:70%}
.pv-71{--value:71%}
.pv-72{--value:72%}
.pv-73{--value:73%}
.pv-74{--value:74%}
.pv-75{--value:75%}
.pv-76{--value:76%}
.pv-77{--value:77%}
.pv-78{--value:78%}
.pv-79{--value:79%}
.pv-80{--value:80%}
.pv-81{--value:81%}
.pv-82{--value:82%}
.pv-83{--value:83%}
.pv-84{--value:84%}
.pv-85{--value:85%}
.pv-86{--value:86%}
.pv-87{--value:87%}
.pv-88{--value:88%}
.pv-89{--value:89%}
.pv-90{--value:90%}
.pv-91{--value:91%}
.pv-92{--value:92%}
.pv-93{--value:93%}
.pv-94{--value:94%}
.pv-95{--value:95%}
.pv-96{--value:96%}
.pv-97{--value:97%}
.pv-98{--value:98%}
.pv-99{--value:99%}
.pv-100{--value:100%}

/* ===== 実装で足したもの ===== */
.sprite { display: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.mt-3 { margin-top: var(--sp-3); }
.mt-auto { margin-top: auto; padding-top: var(--sp-2); }
.stack-4 { display: grid; gap: var(--sp-4); }
.stack-2 { display: grid; gap: var(--sp-2); }
.inline-icon { display: inline-flex; gap: 4px; align-items: center; }
.course-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.study-cal__grid li.pad { visibility: hidden; }
.done-course__date { display: block; }
.lesson-video { margin: 0 0 var(--sp-4); }
.lesson-video .video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-lg); overflow: hidden; background: #000; }
.lesson-video .video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
@media (max-width: 639px) { .lesson-video .video-frame { border-radius: 0; margin: 0 calc(var(--sp-4) * -1); } }
.lesson-ai .ai-panel { margin: 0; }
.admin-page .card { margin: var(--sp-3) 0; }
/* ログイン前のトップ */
.landing { display: grid; gap: var(--sp-10); padding: var(--sp-8) 0 var(--sp-6); }
.landing__hero { display: grid; gap: var(--sp-4); max-width: 640px; }
.landing__title { font-family: var(--font-head); font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: var(--lh-tight); margin: 0; }
.landing__lead { font-size: var(--fs-md); color: var(--text-sub); margin: 0; }
.landing__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.btn--lg { min-height: 52px; padding: 0 var(--sp-6); font-size: var(--fs-md); }
.landing__features { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-4); }
@media (min-width: 768px) { .landing__features { grid-template-columns: repeat(3, 1fr); } }
.landing__features h2 { font-family: var(--font-head); font-size: var(--fs-md); margin: var(--sp-3) 0 var(--sp-1); }
.landing__features p { margin: 0; color: var(--text-sub); font-size: var(--fs-sm); }
.landing__icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-pill); background: var(--brand-soft); color: var(--brand); }
.landing__icon .icon { width: 22px; height: 22px; }
.card--tight { padding: var(--sp-2); }
.card--bare { padding: 0; }
.page-title { font-family: var(--font-head); margin: var(--sp-2) 0 var(--sp-6); }
.lead { font-size: var(--fs-md); color: var(--text-sub); }
.read-sentinel { margin: var(--sp-8) 0 var(--sp-4); padding: var(--sp-3); text-align: center; border-top: 1px dashed var(--line); color: var(--text-sub); }
.read-sentinel.done { color: var(--done); font-weight: var(--fw-bold); }
.badge--warn { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.section-edit-head form { flex-wrap: wrap; }
.section-edit select { max-width: 100%; }
.lesson-edit-list li { flex-wrap: wrap; }

/* =========================================================================
   v2：アプリの外枠（左のメニュー＋上の検索）とダッシュボード
   Google の学習サイトのような「アプリ」っぽさ：白地・大きな角丸・はっきりした色の図形
   ========================================================================= */
:root {
  --font-body: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-head: "Outfit", "Noto Sans JP", var(--font-body);
  --font-num: "Outfit", var(--font-body);
  --r-lg: 20px;
  --r-xl: 28px;
  --rail-w: 88px;
  --topbar-h: 64px;
  --shape-pink: #ff4fa3;
  --shape-yellow: #ffcf33;
  --shape-blue: #3d7bff;
  --shape-teal: #19b8a6;
  --shape-purple: #a77bff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #111216; --surface: #1b1c22; }
}
body.app { background: var(--bg); }
body.app .site-header, body.app .site-footer { display: none; }

/* 上の帯：ロゴ・検索・アカウント */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-4); padding: 0 var(--sp-4);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: inline-flex; align-items: baseline; gap: 2px; text-decoration: none; color: var(--text); font-family: var(--font-num); font-weight: 800; font-size: 1.35rem; letter-spacing: -0.02em; min-width: calc(var(--rail-w) - var(--sp-4)); }
.topbar__brand b { color: var(--brand); font-weight: 800; }
.topbar__search { flex: 1; max-width: 640px; margin: 0 auto; position: relative; }
.topbar__search input {
  width: 100%; height: 44px; border-radius: var(--r-pill); border: 1px solid transparent;
  background: var(--surface-sunken); padding: 0 var(--sp-4) 0 44px; font: inherit; color: var(--text);
}
.topbar__search input:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-soft); }
.topbar__search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-sub); pointer-events: none; }
.topbar__end { display: flex; align-items: center; gap: var(--sp-2); }
@media (max-width: 767px) { .topbar__search { display: none; } .topbar__brand { min-width: 0; } .topbar__end { margin-left: auto; } }

/* 左のメニュー（PC）。スマホでは下のタブ */
.app-body { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.rail {
  position: sticky; top: var(--topbar-h); align-self: start; height: calc(100vh - var(--topbar-h));
  display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-4) var(--sp-2);
  border-right: 1px solid var(--line); background: var(--surface);
}
.rail a {
  display: grid; justify-items: center; gap: 4px; padding: 8px 0 6px; text-decoration: none;
  color: var(--text-sub); font-size: 11px; font-weight: 700; border-radius: var(--r-md);
}
.rail a .rail__pill { display: grid; place-items: center; width: 56px; height: 32px; border-radius: var(--r-pill); transition: background var(--dur) var(--ease); }
.rail a .icon { width: 22px; height: 22px; }
.rail a:hover .rail__pill { background: var(--surface-sunken); }
.rail a[aria-current="page"] { color: var(--text); }
.rail a[aria-current="page"] .rail__pill { background: var(--brand-soft); color: var(--brand); }
.rail__spacer { flex: 1; }
@media (max-width: 767px) { .app-body { grid-template-columns: 1fr; } .rail { display: none; } }
.app-main { min-width: 0; }
.app-main .page { max-width: 1200px; padding-top: var(--sp-8); }
.app-footer { padding: var(--sp-6) var(--gutter) var(--sp-10); font-size: var(--fs-xs); color: var(--text-sub); display: flex; flex-wrap: wrap; gap: var(--sp-4); max-width: 1200px; margin: 0 auto; }
.app-footer a { color: inherit; }

/* カードを Google 風に（影は弱く、角は大きく） */
body.app .card { border-radius: var(--r-lg); box-shadow: none; }
body.app a.card:hover { box-shadow: var(--shadow-md); }
body.app h1, body.app h2, body.app h3 { font-family: var(--font-head); letter-spacing: -0.01em; }
body.app .btn--primary { box-shadow: none; border-radius: var(--r-pill); }
body.app .btn { border-radius: var(--r-pill); }

/* ---- ダッシュボード ---- */
.dash-hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl); padding: var(--sp-8) var(--sp-6);
  background: var(--surface); border: 1px solid var(--line); display: grid; gap: var(--sp-4); min-height: 220px;
}
.dash-hero__text { position: relative; z-index: 1; max-width: 560px; display: grid; gap: var(--sp-3); }
.dash-hero__title { font-size: clamp(1.7rem, 1.1rem + 2.2vw, 2.6rem); line-height: 1.2; margin: 0; font-weight: 800; }
.dash-hero__sub { color: var(--text-sub); margin: 0; }
.dash-hero__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.dash-hero__shapes { position: absolute; right: -40px; top: -30px; width: 380px; height: 300px; pointer-events: none; }
@media (max-width: 767px) { .dash-hero__shapes { opacity: 0.35; right: -120px; } }

.dash-stats { list-style: none; padding: 0; margin: var(--sp-6) 0 0; display: grid; gap: var(--sp-3); grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) { .dash-stats { grid-template-columns: repeat(4, 1fr); } }
.dash-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-4); display: grid; grid-template-columns: auto 1fr; gap: 2px var(--sp-3); align-items: center; }
.dash-stat__icon { grid-row: span 2; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; color: #fff; }
.dash-stat__icon .icon { width: 22px; height: 22px; }
.dash-stat--pink .dash-stat__icon { background: var(--shape-pink); }
.dash-stat--yellow .dash-stat__icon { background: var(--shape-yellow); color: #1a1a1f; }
.dash-stat--blue .dash-stat__icon { background: var(--shape-blue); }
.dash-stat--teal .dash-stat__icon { background: var(--shape-teal); }
.dash-stat__value { font-family: var(--font-num); font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.dash-stat__value small { font-size: 0.8rem; font-weight: 700; color: var(--text-sub); margin-left: 2px; }
.dash-stat__label { font-size: var(--fs-xs); color: var(--text-sub); font-weight: 700; }

.dash-grid { display: grid; gap: var(--sp-8); margin-top: var(--sp-10); }
@media (min-width: 1100px) { .dash-grid { grid-template-columns: minmax(0, 1fr) 340px; } }
.dash-side { display: grid; gap: var(--sp-6); align-content: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-5); }
.panel__title { font-size: var(--fs-md); margin: 0 0 var(--sp-3); display: flex; align-items: center; gap: var(--sp-2); }
.panel__title .icon { color: var(--brand); }

/* 学習途中のカード（横にならぶ） */
.cont-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cont-card { display: grid; gap: var(--sp-3); padding: var(--sp-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); text-decoration: none; color: inherit; height: 100%; transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.cont-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); color: inherit; }
.cont-card .thumb { border-radius: 14px; }
.cont-card__course { font-size: var(--fs-xs); color: var(--text-sub); font-weight: 700; }
.cont-card__title { font-weight: 800; line-height: 1.4; }

/* 今週 */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.week span { font-size: 11px; color: var(--text-sub); font-weight: 700; }
.week i { display: block; aspect-ratio: 1; border-radius: 10px; background: var(--surface-sunken); }
.week i.on { background: var(--shape-pink); }
.week i.today { outline: 2px solid var(--text); outline-offset: 1px; }

/* 検索 */
.search-form { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-6); }
.search-form input { flex: 1; height: 48px; border-radius: var(--r-pill); border: 1px solid var(--line); padding: 0 var(--sp-5); font: inherit; background: var(--surface); color: var(--text); }
.hit-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-2); }
.s-pink { fill: var(--shape-pink); } .s-yellow { fill: var(--shape-yellow); } .s-blue { fill: var(--shape-blue); }
.s-teal { fill: var(--shape-teal); } .s-purple { fill: var(--shape-purple); }
.dash-hero .btn--primary { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 画像がないときのサムネイル：左下に題名（2行まで）、右上に丸い飾り */
.thumb { container-type: inline-size; }
.thumb:not(:has(img)) { place-items: end start; padding: 6% 6%; }
.thumb:not(:has(img))::before {
  content: ""; position: absolute; right: -12cqi; top: -18cqi; width: 55cqi; height: 55cqi; border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
}
.thumb:not(:has(img))::after {
  content: ""; position: absolute; right: 18cqi; top: 22cqi; width: 14cqi; height: 14cqi; border-radius: 4cqi; transform: rotate(18deg);
  background: rgba(255, 255, 255, 0.6);
}
.thumb__mark {
  position: relative; z-index: 1; font-size: clamp(0.8rem, 8.5cqi, 1.6rem); line-height: 1.3; letter-spacing: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 78%;
}
.thumb__time, .thumb__kind, .thumb__progress { z-index: 2; }
.dash-hero { grid-template-columns: minmax(0, 1fr); }
.dash-hero__text { min-width: 0; }
.dash-hero__actions .btn { max-width: 100%; }
@media (max-width: 767px) { .dash-hero { padding: var(--sp-6) var(--sp-5); } }
.dash-hero__text { grid-template-columns: minmax(0, 1fr); }
.dash-hero__actions { min-width: 0; }
