/* =============================================
   デザイントークン (LP の style.css と一貫)
   ============================================= */
:root {
  --color-navy:     #1b3a6b;
  --color-blue:     #2e6db4;
  --color-blue-lt:  #4a9fd4;
  --color-gold:     #f4c542;
  --color-gold-dk:  #d4a820;
  --color-bg:       #fafafa;
  --color-white:    #ffffff;
  --color-text:     #1e293b;
  --color-sub:      #64748b;
  --color-border:   #e2e8f0;
  --color-gray-bg:  #f1f5f9;
  --color-danger:   #d64545;
  --color-success:  #2f9e6b;

  --shadow-sm: 0 1px 4px rgba(0, 0, 0, .06);
  --shadow-md: 0 2px 12px rgba(0, 0, 0, .08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .12);

  --radius:    8px;
  --radius-lg: 16px;

  --font-base: 'Noto Sans JP', sans-serif;
  --transition: 0.2s ease;

  --appbar-h:    56px;
  --bottomnav-h: 64px;
}

/* =============================================
   リセット・ベース
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }

[hidden] { display: none !important; }

/* =============================================
   レイアウト: ヘッダー / メイン / ボトムナビ
   ============================================= */
.appbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-navy);
  color: var(--color-white);
  box-shadow: var(--shadow-sm);
}

.appbar__inner {
  max-width: 960px;
  margin: 0 auto;
  height: var(--appbar-h);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.appbar__brand {
  font-weight: 700;
  font-size: .95rem;
  white-space: nowrap;
}

.appbar__nav {
  display: none;
  flex: 1;
  gap: 1.5rem;
  margin-left: 1rem;
}

.appbar__nav a {
  font-size: .9rem;
  opacity: .85;
  transition: opacity var(--transition);
}

.appbar__nav a:hover,
.appbar__nav a.is-active { opacity: 1; }

.appbar__logout {
  margin-left: auto;
  font-size: .85rem;
  opacity: .8;
  padding: .25rem .75rem;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.appbar__logout:hover { background: rgba(255, 255, 255, .12); }

/* メイン */
.view {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(var(--bottomnav-h) + 1rem);
  min-height: calc(100vh - var(--appbar-h));
}

.loading {
  text-align: center;
  padding: 4rem 0;
  color: var(--color-sub);
  min-height: 8rem; /* スピナー分の高さを確保しレイアウトシフト(CLS)を抑える */
}
/* 既存の <div class="loading">…</div> をHTML無改変でスピナー化 */
.loading::before {
  content: "";
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto .75rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .loading::before { animation: none; }
}

/* ボトムナビ (モバイル) */
.bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottomnav-h);
  background: var(--color-white);
  border-top: 1px solid var(--color-border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 100;
}

.bottomnav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  font-size: .7rem;
  color: var(--color-sub);
  transition: color var(--transition);
}

.bottomnav a.is-active { color: var(--color-blue); }

.bottomnav__icon { font-size: 1.25rem; line-height: 1; }

/* デスクトップでは上部ナビを出してボトムナビを隠す */
@media (min-width: 768px) {
  .appbar__nav { display: flex; }
  .bottomnav   { display: none; }
  .view        { padding-bottom: 2rem; }
}

/* =============================================
   汎用 UI
   ============================================= */
.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}

.card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--color-sub);
  margin-bottom: .5rem;
}

.card__body { font-size: .95rem; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .65rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: .9rem;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--color-blue);
  color: var(--color-white);
  box-shadow: 0 2px 8px rgba(46, 109, 180, .25);
}
.btn--primary:hover:not(:disabled) {
  background: var(--color-navy);
  box-shadow: 0 4px 14px rgba(46, 109, 180, .35);
}

.btn--gold {
  background: var(--color-gold);
  color: var(--color-navy);
}
.btn--gold:hover:not(:disabled) { background: var(--color-gold-dk); }

.btn--ghost {
  background: transparent;
  color: var(--color-sub);
}
.btn--ghost:hover:not(:disabled) { background: var(--color-gray-bg); color: var(--color-text); }

.btn--block { width: 100%; }

.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field__label { font-size: .85rem; font-weight: 700; color: var(--color-sub); }
.field__input,
.field__textarea,
.field__select {
  padding: .65rem .85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-white);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field__input:focus,
.field__textarea:focus,
.field__select:focus {
  outline: none;
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(46, 109, 180, .15);
}
.field__textarea { resize: vertical; min-height: 6rem; }
.field__hint { font-size: .75rem; color: var(--color-sub); }
.field__error { font-size: .8rem; color: var(--color-danger); }

.notice {
  padding: .85rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: 1rem;
}
.notice--info    { background: #e8f1fb; color: var(--color-navy); }
.notice--success { background: #e6f6ee; color: var(--color-success); }
.notice--error   { background: #fbe9e9; color: var(--color-danger); }

.section-heading {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--color-gold);
  color: var(--color-navy);
}

/* コーストラック（証券アナリスト / 簿記・会計 / AI実践） */
.track { margin-bottom: 2.25rem; }
.track__head { margin-bottom: .9rem; }
.track__title {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-navy);
}
.track__title::before {
  content: "";
  display: inline-block;
  width: .3rem;
  height: 1.15rem;
  border-radius: 2px;
  background: var(--color-gold);
}
.track__lead {
  margin-top: .3rem;
  font-size: .82rem;
  line-height: 1.5;
  color: var(--color-sub);
}
/* 単一トラック表示時（CMA編／AI編）のリード文 */
.track__lead--solo {
  margin: -.4rem 0 1.1rem;
  font-size: .88rem;
  line-height: 1.6;
  color: var(--color-sub);
}

.tab-group { display: flex; gap: .5rem; margin-bottom: 1rem; }
.tab-group button {
  flex: 1;
  padding: .55rem .75rem;
  border-radius: var(--radius);
  background: var(--color-gray-bg);
  font-size: .85rem;
  font-weight: 500;
  color: var(--color-sub);
  transition: background var(--transition), color var(--transition);
}
.tab-group button.is-active {
  background: var(--color-navy);
  color: var(--color-white);
}

.empty {
  text-align: center;
  padding: 3rem 0;
  color: var(--color-sub);
  font-size: .9rem;
}

/* リアクションボタン */
.reactions {
  display: flex;
  gap: .35rem;
  margin-top: .75rem;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .65rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-white);
  font-size: .8rem;
  color: var(--color-sub);
  transition: all var(--transition);
}
.reaction:hover { border-color: var(--color-blue-lt); color: var(--color-blue); }
.reaction.is-active {
  border-color: var(--color-blue);
  background: #e8f1fb;
  color: var(--color-blue);
}

/* ログイン画面 */
.auth-screen {
  max-width: 420px;
  margin: 4rem auto 0;
  padding: 0 1rem;
}
.auth-screen__brand {
  text-align: center;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--color-gold-dk);
  margin-bottom: .35rem;
}
.auth-screen__title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: .5rem;
  color: var(--color-navy);
}
.auth-screen__lead {
  text-align: center;
  color: var(--color-sub);
  font-size: .9rem;
  margin-bottom: 2rem;
}
.auth-screen .card { padding: 1.5rem; }

/* マイページの統計 */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.stats__item {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem .5rem;
  text-align: center;
}
.stats__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1.2;
}
.stats__label {
  font-size: .75rem;
  color: var(--color-sub);
  margin-top: .25rem;
}

/* =============================================
   講義一覧 (lessons)
   ============================================= */
.course-block {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.course-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}
.course-block__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-navy);
}
.course-block__badge {
  font-size: .7rem;
  font-weight: 700;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: var(--color-gold);
  color: var(--color-navy);
}
.course-block__lead {
  font-size: .85rem;
  color: var(--color-sub);
  margin-bottom: 1rem;
  line-height: 1.6;
}
.course-block__note {
  font-size: .75rem;
  color: var(--color-sub);
  margin-top: 1rem;
}
.course-block__error {
  margin-top: .75rem;
  padding: .5rem .75rem;
  background: #fbe9e9;
  color: var(--color-danger);
  border-radius: var(--radius);
  font-size: .8rem;
}
/* 商品（コース）ごとに畳めるアコーディオン */
.course-block--accordion { padding: 0; overflow: hidden; }
.course-block__head--toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin: 0;
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  list-style: none;
}
.course-block__head--toggle::-webkit-details-marker { display: none; }
.course-block__head-main { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.course-block__head-right { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.course-block__meta-count { font-size: .78rem; color: var(--color-sub); white-space: nowrap; }
.course-block__chevron { color: var(--color-sub); transition: transform .2s ease; }
.course-block--accordion[open] .course-block__chevron { transform: rotate(180deg); }
.course-block__head--toggle:hover .course-block__title { color: var(--color-blue); }
.course-block__body { padding: 0 1.25rem 1.25rem; }
.course-block--locked { background: var(--color-gray-bg); }

/* 販売中（数学編）：緑アクセントで強調 */
.course-block--onsale { border-color: #2d6a4f; box-shadow: 0 4px 16px rgba(45, 106, 79, .12); }
.course-block__badge--onsale { background: #2d6a4f; color: #fff; }
.course-block__price {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-navy);
  margin: .25rem 0 .75rem;
}
.course-block__cta {
  display: inline-block;
  background: #2d6a4f;
  color: #fff;
  font-weight: 700;
  font-size: .9rem;
  text-decoration: none;
  padding: .6rem 1.4rem;
  border-radius: 999px;
  transition: background var(--transition), transform var(--transition);
}
.course-block__cta:hover { background: #235541; transform: translateY(-1px); }
.course-block__hint { font-size: .72rem; color: var(--color-sub); margin-top: .5rem; }

/* 近日公開：抑えめのグレー表示 */
.course-block--soon { opacity: .85; }
.course-block__badge--soon { background: var(--color-border); color: var(--color-sub); }

/* カリキュラム見本（販売中の未購入者向け・クリック不可） */
.lecture-list--preview { margin-top: .5rem; }
.lecture-card--preview {
  cursor: default;
  background: var(--color-gray-bg);
  opacity: .9;
}
.lecture-card--preview:hover { border-color: var(--color-border); box-shadow: none; transform: none; }

.lecture-list {
  display: grid;
  gap: .75rem;
}
.lecture-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.lecture-card:hover,
.lecture-card:focus {
  outline: none;
  border-color: var(--color-blue-lt);
  box-shadow: 0 4px 14px rgba(46, 109, 180, .12);
  transform: translateY(-1px);
}
.lecture-card__chapter {
  font-size: .7rem;
  font-weight: 700;
  color: var(--color-blue);
  letter-spacing: .04em;
}
.lecture-card__title {
  font-size: 1rem;
  font-weight: 700;
  margin: .15rem 0 .35rem;
  color: var(--color-text);
}
.lecture-card__desc {
  font-size: .8rem;
  color: var(--color-sub);
  line-height: 1.5;
}
.lecture-card__meta {
  font-size: .7rem;
  color: var(--color-sub);
  margin-top: .5rem;
}

/* =============================================
   講義プレイヤー (lecture)
   ============================================= */
.lecture { position: relative; padding-bottom: 4rem; }
.lecture__back {
  display: inline-block;
  font-size: .8rem;
  color: var(--color-sub);
  margin-bottom: .5rem;
}
.lecture__back:hover { color: var(--color-blue); }
/* 前後の講義ナビ */
.lecture__nav {
  display: flex;
  gap: .75rem;
  margin: 1rem 0 1.5rem;
}
.lecture__nav-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .7rem .9rem;
  border: 1px solid #e2e6ee;
  border-radius: var(--radius);
  background: #fff;
  text-decoration: none;
}
.lecture__nav-btn--next { text-align: right; }
.lecture__nav-btn--empty { border: none; background: none; pointer-events: none; }
.lecture__nav-btn:hover { border-color: var(--color-blue); background: #f6f9ff; }
.lecture__nav-dir { font-size: .75rem; color: var(--color-blue); font-weight: 700; }
.lecture__nav-name {
  font-size: .82rem;
  color: var(--color-navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 480px) { .lecture__nav-name { white-space: normal; } }
.lecture__title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: .25rem;
}
.lecture__subject {
  font-size: .8rem;
  color: var(--color-sub);
  margin-bottom: 1rem;
}
.lecture__player {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
}
.lecture__player video {
  width: 100%;
  height: 100%;
  display: block;
}

/* =============================================
   テキスト記事 (article) ― AI実践編など
   ============================================= */
.article { position: relative; padding-bottom: 3rem; }
.article__back {
  display: inline-block;
  font-size: .8rem;
  color: var(--color-sub);
  margin-bottom: .5rem;
}
.article__back:hover { color: var(--color-blue); }
.article__back--bottom { margin-top: 2rem; }

/* 記事の前後ナビ（← 前の記事 ／ 次の記事 →） */
.article__nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-top: 2.5rem;
}
.article__nav-link {
  display: flex;
  flex-direction: column;
  gap: .22rem;
  padding: .8rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.article__nav-link:hover {
  border-color: var(--color-blue);
  box-shadow: 0 2px 10px rgba(27, 58, 107, .08);
}
.article__nav-link--next { text-align: right; }
.article__nav-link--empty { border: none; background: none; }
.article__nav-dir { font-size: .74rem; font-weight: 700; color: var(--color-blue); }
.article__nav-chapter { font-size: .9rem; font-weight: 700; color: var(--color-navy); }
.article__nav-title {
  font-size: .78rem;
  color: var(--color-sub);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 560px) {
  .article__nav { grid-template-columns: 1fr; }
  .article__nav-link--next { text-align: left; }
  .article__nav-link--empty { display: none; }
}
.article__kicker {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--color-blue);
  margin-bottom: .3rem;
}
.article__title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-navy);
  line-height: 1.4;
  margin-bottom: .35rem;
}
.article__meta { font-size: .78rem; color: var(--color-sub); margin-bottom: 1.2rem; }

.article__body { display: flex; flex-direction: column; gap: .35rem; }

.article__h2 {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--color-navy);
  margin: 1.9rem 0 .8rem;
}
.article__h2:first-child { margin-top: .4rem; }
.article__h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-navy);
  margin: 1.4rem 0 .6rem;
}
.article__p {
  font-size: .92rem;
  line-height: 1.9;
  color: var(--color-text);
  margin-bottom: 1.05rem;
}
.article__p strong, .article__callout strong, .article__bubble strong, .article__list strong {
  color: var(--color-navy);
}
/* ==マーカー== 蛍光ペン風ハイライト（サイト配色の黄） */
.article__p mark, .article__list mark, .article__callout mark, .article__bubble mark,
.article__h2 mark, .article__h3 mark, .article__table mark {
  background: linear-gradient(transparent 58%, #ffe08a 58%);
  color: inherit;
  font-weight: 600;
  padding: 0 .08em;
  border-radius: 2px;
}
.article__p code, .article__list code {
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: .85em;
  background: var(--color-gray-bg);
  border-radius: 4px;
  padding: .1em .35em;
}

.article__list {
  list-style: disc;
  padding-left: 1.3rem;
  margin-bottom: 1rem;
  font-size: .92rem;
  line-height: 1.8;
  color: var(--color-text);
}
.article__list li { margin-bottom: .35rem; }
.article__list--ordered { list-style: decimal; }

.article__code {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.article__code-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .45rem .7rem;
  background: var(--color-gray-bg);
  border-bottom: 1px solid var(--color-border);
}
.article__code-tag {
  font-size: .72rem;
  font-weight: 700;
  color: var(--color-sub);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.article__copy-btn {
  font-size: .76rem;
  font-weight: 700;
  color: #fff;
  background: var(--color-blue);
  border-radius: 999px;
  padding: .25em 0.9em;
}
.article__copy-btn:hover { background: var(--color-navy); }
.article__code-body {
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: .82rem;
  line-height: 1.7;
  color: var(--color-text);
  padding: .8rem .9rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

.article__bubble {
  border-radius: 12px;
  padding: .65rem .9rem;
  margin-bottom: .8rem;
  max-width: 92%;
}
.article__bubble-who {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  color: var(--color-sub);
  margin-bottom: .2rem;
}
.article__bubble-text { font-size: .88rem; line-height: 1.7; }
.article__bubble--assistant {
  background: #f6f8fb;
  border: 1px solid var(--color-border);
}
.article__bubble--user {
  background: #eaf2fb;
  border: 1px solid #cfe0f3;
  margin-left: auto;
}
.article__bubble--user .article__bubble-who { color: var(--color-blue); text-align: right; }

.article__callout {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  border-radius: var(--radius);
  padding: .7rem .9rem;
  margin-bottom: .9rem;
  font-size: .88rem;
  line-height: 1.7;
}
.article__callout-icon { flex: none; font-size: 1rem; line-height: 1.7; }
.article__callout--bad  { background: #fbe9e9; color: #9a2f2f; }
.article__callout--good { background: #e6f6ee; color: #1f6b45; }
.article__callout--info { background: #eef5fc; color: var(--color-navy); }

.article__table-wrap {
  overflow-x: auto;
  margin-bottom: 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.article__table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.article__table th, .article__table td {
  padding: .5rem .7rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}
.article__table th {
  background: var(--color-gray-bg);
  color: var(--color-navy);
  font-weight: 700;
  white-space: nowrap;
}
.article__table tr:last-child td { border-bottom: none; }

.article__divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 1.6rem 0;
}

.article__image-placeholder {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-gray-bg);
  color: var(--color-sub);
  font-size: .8rem;
  text-align: center;
  padding: 1.4rem 1rem;
  margin-bottom: 1rem;
}

.article__image {
  margin: 0 0 1rem;
}

.article__image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.article__image figcaption {
  margin-top: .5rem;
  font-size: .78rem;
  color: var(--color-sub);
  text-align: center;
}

/* =============================================
   チャット FAB (右下フローティングボタン)
   ============================================= */
.chat-fab {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--bottomnav-h) + 1rem);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-navy);
  color: var(--color-white);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  transition: transform var(--transition), background var(--transition);
}
.chat-fab:hover { transform: scale(1.05); background: var(--color-blue); }
.chat-fab__icon { font-size: 1.4rem; line-height: 1; }
.chat-fab__pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--color-gold);
  opacity: 0;
  pointer-events: none;
}
.chat-fab--pulse .chat-fab__pulse {
  animation: chat-fab-pulse 1.4s ease-out infinite;
}
@keyframes chat-fab-pulse {
  0%   { opacity: .65; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.7); }
}

/* デスクトップでは bottomnav が消えるので位置調整 */
@media (min-width: 768px) {
  .chat-fab { bottom: 1.5rem; }
}

/* =============================================
   チャットパネル
   ============================================= */
.chat-panel {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--bottomnav-h) + 5rem);
  width: min(360px, calc(100vw - 2rem));
  max-height: calc(100vh - var(--appbar-h) - var(--bottomnav-h) - 6rem);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 95;
  overflow: hidden;
}
@media (min-width: 768px) {
  .chat-panel {
    bottom: 5.5rem;
    width: 380px;
    max-height: calc(100vh - var(--appbar-h) - 7rem);
  }
}

.chat-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
  padding: .75rem 1rem;
  background: var(--color-gray-bg);
  border-bottom: 1px solid var(--color-border);
}
.chat-panel__slide-meta {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}
.chat-panel__badge {
  font-size: .65rem;
  font-weight: 700;
  color: var(--color-blue);
  letter-spacing: .04em;
}
.chat-panel__slide-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-panel__close {
  font-size: 1.3rem;
  color: var(--color-sub);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chat-panel__close:hover { background: var(--color-border); color: var(--color-text); }

.chat-panel__hint {
  padding: .5rem 1rem;
  font-size: .72rem;
  color: var(--color-sub);
  background: #fffaed;
  border-bottom: 1px solid var(--color-border);
  line-height: 1.5;
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--color-border);
}
.chat-chip {
  font-size: .75rem;
  padding: .35rem .7rem;
  border: 1px solid var(--color-blue-lt);
  border-radius: 999px;
  background: var(--color-white);
  color: var(--color-blue);
  transition: all var(--transition);
}
.chat-chip:hover:not(:disabled) {
  background: var(--color-blue);
  color: var(--color-white);
}
.chat-chip:disabled { opacity: .5; cursor: not-allowed; }

.chat-log {
  flex: 1;
  min-height: 8rem;
  max-height: 16rem;
  overflow-y: auto;
  padding: .65rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.chat-bubble {
  font-size: .85rem;
  line-height: 1.55;
  padding: .55rem .75rem;
  border-radius: 12px;
  max-width: 85%;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble--user {
  align-self: flex-end;
  background: var(--color-blue);
  color: var(--color-white);
  border-bottom-right-radius: 4px;
}
.chat-bubble--ai {
  align-self: flex-start;
  background: var(--color-gray-bg);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}

.chat-input {
  display: flex;
  gap: .5rem;
  padding: .65rem 1rem .85rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-white);
}
.chat-input input {
  flex: 1;
  min-width: 0;
  padding: .5rem .75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .85rem;
  background: var(--color-white);
}
.chat-input input:focus {
  outline: none;
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(46, 109, 180, .15);
}
.chat-input input:disabled { background: var(--color-gray-bg); }
.chat-input button {
  padding: .5rem 1rem;
  background: var(--color-navy);
  color: var(--color-white);
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 700;
  transition: background var(--transition);
}
.chat-input button:hover:not(:disabled) { background: var(--color-blue); }
.chat-input button:disabled { opacity: .5; cursor: not-allowed; }

/* =============================================
   決済完了バナー（?purchased=1）
   未ログインでも見えるよう最上部に表示する
   ============================================= */
.purchase-banner {
  background: var(--color-success);
  color: var(--color-white);
  box-shadow: var(--shadow-md);
}
.purchase-banner__inner {
  max-width: 720px;
  margin: 0 auto;
  padding: .85rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  font-size: .9rem;
  line-height: 1.6;
}
.purchase-banner__inner strong { font-weight: 700; }
.purchase-banner__close {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--color-white);
  opacity: .85;
}
.purchase-banner__close:hover { opacity: 1; }

/* =============================================
   トースト通知（画面下・控えめ・数秒で消滅）
   ============================================= */
#toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + 1rem);
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: max-content;
  max-width: calc(100% - 2rem);
  pointer-events: none;
}
.toast {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  line-height: 1.5;
  color: var(--color-white);
  background: var(--color-navy);
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
}
.toast--error   { background: var(--color-danger); }
.toast--success { background: var(--color-success); }
.toast--info    { background: var(--color-navy); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}

/* キーボード操作時のみ可視化するフォーカス枠（マウス操作では出ない） */
:focus-visible {
  outline: 2px solid var(--color-blue);
  outline-offset: 2px;
}
