@charset "UTF-8";

:root {
  --bg: #f6f6f8;
  --panel: #ffffff;
  --ink: #1c1c20;
  /* 薄いグレー文字。2026-08-13 に #6b6b76 → 濃いめへ(文字の見やすさ改善。全画面) */
  --muted: #51515c;
  --line: #dcdce4;
  --accent: #d8455f;
  --accent-ink: #ffffff;
  --user-bubble: #2f2f38;
  --char-bubble: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* 背景はユーザーがGPTで生成した淡い画像(2026-08-13。UI改善第3弾 要望2)。
   * 読み込めない環境でも --bg の無地で成立する */
  background: var(--bg) url("bg.jpg") no-repeat center center fixed;
  background-size: cover;
  color: var(--ink);
  /* UD系(BIZ UDPGothic = Win10以降標準)優先。細くかすれがちな Yu Gothic 直行を
   * 避ける(2026-08-13 文字の見やすさ改善。管理側から全画面へ展開) */
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic Medium", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.7;
}

a { color: inherit; }

/* ---------- 枠 ---------- */

/* 画面左端の基本メニュー(kyarapu 風。全画面共通の固定サイドバー) */
:root { --side-w: 200px; }

.side-nav {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--side-w);
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 16px 12px;
  overflow-y: auto; z-index: 100;
  display: flex; flex-direction: column; gap: 4px;
}
.site-title {
  font-weight: bold; font-size: 18px; text-decoration: none;
  padding: 0 8px 12px; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.side-nav nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 8px; border-radius: 6px;
  color: var(--muted); text-decoration: none; font-size: 15px;
}
.side-link:hover { color: var(--ink); background: #f0f0f4; }
.side-link.active { color: var(--ink); font-weight: bold; background: #f0f0f4; }
.side-icon { width: 22px; text-align: center; flex-shrink: 0; }
.side-icon img { width: 22px; height: 22px; display: block; margin: 0 auto; }
.side-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ダミーリンク(準備中)の見せ方: 薄くして「予定」バッジを添える */
.side-badge {
  font-size: 10px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0 6px; flex-shrink: 0;
}
.side-link.dummy { opacity: .65; }

body.has-side { padding-left: var(--side-w); }

/* 画面右上に常時表示するアイコン群(kyarapu 風。履歴レールの左隣に置く) */
.top-actions {
  position: fixed; top: 12px; right: 16px; z-index: 95;
  display: flex; gap: 8px;
}
body.has-rail .top-actions { right: calc(var(--rail-w) + 16px); }
.top-action {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: 17px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  opacity: .85;
}
.top-action:hover { border-color: var(--accent); opacity: 1; }
.top-action img { width: 22px; height: 22px; display: block; }

/* 右上の検索欄(旧「キャラ検索」ダミーアイコンの置き換え。2026-08-13) */
.top-search {
  display: flex; align-items: center; margin: 0;
  height: 40px; padding: 0 4px 0 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
.top-search:focus-within { border-color: var(--accent); }
.top-search input[type="search"] {
  width: 190px; border: none; background: none; padding: 0;
  font-size: 14px; border-radius: 0;
}
.top-search input[type="search"]:focus { outline: none; }
.top-search button {
  width: 32px; height: 32px; border: none; border-radius: 50%;
  background: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.top-search button:hover { background: #f0f0f4; }
.top-search button img { width: 18px; height: 18px; display: block; opacity: .8; }

/* 右上の通知パネル(旧「告知」ダミーアイコンの置き換え。2026-08-13。
 * kyarapu のベル→右上ドロップダウンの簡易版。details ベースでJS無効でも開閉可) */
.notice-menu { position: relative; }
.notice-menu > summary { list-style: none; cursor: pointer; user-select: none; position: relative; }
.notice-menu > summary::-webkit-details-marker { display: none; }
.notice-menu[open] > summary { border-color: var(--accent); opacity: 1; }
/* 未読件数バッジ(2026-08-26。以前は文字なしの赤丸 .notice-dot)。
 * 赤地に白抜きの数字。サイドバーの .side-count と同じ見た目で、
 * アイコンの右上に少しはみ出して乗せる */
.notice-count {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; box-sizing: border-box;
  background: var(--accent); color: var(--accent-ink);
  border: 2px solid #fff;
  font-size: 11px; font-weight: bold; line-height: 14px;
  text-align: center; white-space: nowrap;
}
/* パネル内の未読項目(個人宛て=サーバ側で印付け / 全員宛て=app.js が
 * 付け外し)。タイトルの前に小さな赤点 */
.notice-item.unread .notice-item-title::before {
  content: ''; display: inline-block; vertical-align: middle;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin: 0 6px 2px 0;
}
.notice-panel {
  position: absolute; right: 0; top: 48px; z-index: 96;
  width: 340px; max-width: calc(100vw - 32px);
  max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .14);
  padding: 4px 16px 10px; text-align: left;
}
.notice-panel-title {
  font-weight: bold; font-size: 14px; margin: 0;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.notice-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.notice-item:last-child { border-bottom: none; }
.notice-item-title { font-weight: bold; font-size: 13px; margin: 0 0 2px; }
.notice-item-body {
  font-size: 14px; margin: 0;
  white-space: pre-wrap; word-break: break-word;
}
.notice-item-meta { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.notice-item-meta a { color: var(--accent); }
.notice-empty {
  text-align: center; color: var(--muted); font-size: 14px;
  padding: 56px 0;
}
.notice-empty img {
  width: 44px; height: 44px; opacity: .3;
  display: block; margin: 0 auto 12px;
}

/* 右上のマイページパネル(旧「マイページ」ダミーアイコンの置き換え。2026-08-13。
 * kyarapu のアバター→右上ドロップダウンの簡易版。details ベースでJS無効でも開閉可) */
.mypage-menu { position: relative; }
.mypage-menu > summary { list-style: none; cursor: pointer; user-select: none; }
.mypage-menu > summary::-webkit-details-marker { display: none; }
.mypage-menu[open] > summary { border-color: var(--accent); opacity: 1; }
.mypage-panel {
  position: absolute; right: 0; top: 48px; z-index: 96;
  width: 300px; max-width: calc(100vw - 32px);
  max-height: min(72vh, 640px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .14);
  padding: 14px 16px; text-align: left;
}
.mypage-account {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; color: var(--ink);
}
.mypage-account:hover { border-color: var(--accent); }
.mypage-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: bold;
}
.mypage-account-text { min-width: 0; }
.mypage-name { display: block; font-weight: bold; font-size: 15px; overflow-wrap: anywhere; }
.mypage-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
.mypage-chevron { margin-left: auto; color: var(--muted); font-size: 18px; }
.mypage-gold {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px;
}
.mypage-gold-amount { font-size: 14px; font-weight: bold; }
.mypage-charge {
  background: var(--ink); color: #fff; text-decoration: none;
  font-size: 12px; padding: 5px 14px; border-radius: 15px;
}
.mypage-section {
  color: var(--muted); font-size: 12px; letter-spacing: .06em;
  margin: 14px 0 2px; padding: 0 4px;
}
.mypage-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-size: 14px;
}
/* ダミー項目は button 要素(JS無効対策)。リンク版と見た目を揃える */
button.mypage-link {
  width: 100%; background: none; border: none; cursor: pointer;
  font: inherit; font-size: 14px; text-align: left;
}
.mypage-link:hover { background: #f0f0f4; }
.mypage-link.dummy { opacity: .6; }
.mypage-link-icon { width: 20px; text-align: center; flex-shrink: 0; }
.mypage-logout { margin-top: 12px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; }
.mypage-note { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

/* 課金(チャージ)ページ billing.php(旧「課金」ダミーアイコンの置き換え。2026-08-13。
 * kyarapu のチャージ=前払いゴールド方式を模した仮ページ。購入ボタンはダミー) */
.billing-balance {
  display: flex; align-items: center; justify-content: space-between;
  margin: 16px 0 24px; padding: 14px 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.billing-balance-label { color: var(--muted); font-size: 14px; }
.billing-balance-amount { font-size: 20px; font-weight: bold; }
.plan-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 32px;
}
.plan-card {
  position: relative; text-align: center;
  padding: 22px 16px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
.plan-card.featured { border-color: var(--accent); }
.plan-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff;
  font-size: 11px; padding: 2px 12px; border-radius: 10px; white-space: nowrap;
}
.plan-name { color: var(--muted); font-size: 14px; margin: 0 0 6px; overflow-wrap: anywhere; }
.plan-gold { font-size: 26px; font-weight: bold; margin: 0; }
.plan-gold-unit { font-size: 15px; }
.plan-bonus { color: var(--accent); font-size: 13px; margin: 4px 0 0; }
.plan-desc { color: var(--muted); font-size: 13px; margin: 8px 0 0; overflow-wrap: anywhere; }
/* 購入は button 要素(ダミー操作のJS無効対策)。従来のリンク風の見た目 */
.plan-buy {
  display: block; width: 100%; margin-top: 14px; padding: 9px 0;
  background: var(--ink); color: #fff; text-decoration: none;
  border: none; cursor: pointer; font-family: inherit;
  font-size: 14px; border-radius: 20px;
}
.plan-buy:hover { opacity: .85; }
.billing-usage h2 { font-size: 16px; }
.plan-usage-table { border-collapse: collapse; margin: 8px 0; }
.plan-usage-table th, .plan-usage-table td {
  border: 1px solid var(--line); padding: 8px 16px;
  font-size: 14px; text-align: left; background: var(--panel);
}
.plan-usage-table th { font-weight: normal; color: var(--muted); }

/* 右上アイコンと page-head が重ならないよう本文の上余白を確保 */
main { max-width: 960px; margin: 0 auto; padding: 68px 20px 60px; }

.site-footer {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 20px; border-top: 1px solid var(--line);
}

/* ダミーリンク押下時のトースト(app.js が出す) */
.cp-toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 13px;
  padding: 8px 18px; border-radius: 16px; z-index: 200;
  opacity: 0; transition: opacity .2s;
}
.cp-toast.show { opacity: .92; }

/* ---------- 見出し・共通 ---------- */

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
h1 { font-size: 22px; margin: 0; }
h2 {
  font-size: 16px; margin: 0 0 4px;
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 16px; }

.btn {
  display: inline-block; padding: 8px 16px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); text-decoration: none; font-size: 15px; cursor: pointer;
}
.btn:hover { background: #f0f0f4; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { opacity: .9; background: var(--accent); }
.btn-sm { padding: 4px 10px; font-size: 14px; }
.btn-danger { color: var(--accent); }

.errors {
  background: #fdecef; border: 1px solid #f3b8c2; color: #8c1a2c;
  padding: 12px 16px; border-radius: 6px; margin-bottom: 20px;
}
.errors p { margin: 0 0 6px; font-weight: bold; }
.errors ul { margin: 0; padding-left: 20px; }
.notice {
  background: #eaf6ec; border: 1px solid #b6ddbf; color: #1f5c2e;
  padding: 12px 16px; border-radius: 6px; margin-bottom: 20px;
}
.notice p { margin: 0 0 6px; font-weight: bold; }
.notice ul { margin: 0; padding-left: 20px; }
.empty { color: var(--muted); text-align: center; padding: 60px 20px; }

/* ---------- キャラ一覧 ---------- */

.card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; display: flex; flex-direction: column;
}
.card-thumb {
  aspect-ratio: 2 / 3; background: #e6e6ec;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { padding: 12px 14px; flex: 1; }
.card-name { font-weight: bold; margin: 0 0 4px; }
.card-desc { color: var(--muted); font-size: 14px; margin: 0; }
.card-meta { color: var(--muted); font-size: 13px; margin-top: 8px; }
.card-actions {
  display: flex; gap: 8px; padding: 0 14px 14px;
}
.card-actions .btn { flex: 1; text-align: center; }

/* バナー直下の「＋ 新しいキャラを作る」(2026-08-28 夜 ユーザー要望)。
 * PC は列の中央に幅を絞った大きめのボタン、スマホ(末尾の節)は横幅いっぱい */
.home-create { margin: 0 0 18px; text-align: center; }
.home-create .btn {
  display: inline-block; min-width: 320px; padding: 12px 24px;
  font-size: 16px; font-weight: bold; border-radius: 12px;
  box-shadow: 0 2px 8px rgba(216, 69, 95, .25);
}

/* ---------- ホーム上部のタブ+人気タグチップ(2026-08-14 今後の課題5) ---------- */

.home-tabs {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); margin-bottom: 20px;
}
.home-tab {
  padding: 8px 14px; font-size: 15px; color: var(--muted);
  text-decoration: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.home-tab:hover { color: var(--ink); }
.home-tab.active { color: var(--ink); font-weight: bold; border-bottom-color: var(--accent); }
.home-tab-tag { font-size: 14px; }

/* ランキング表示の順位バッジ(サムネ左上) */
.card-thumb { position: relative; }
.card-rank {
  position: absolute; top: 8px; left: 8px; z-index: 1;
  min-width: 28px; height: 28px; padding: 0 7px; border-radius: 8px;
  background: rgba(20, 20, 24, .62); color: #fff;
  font-weight: bold; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}

/* ハッシュタグのチップ(キャラカード・検索結果共通。2026-08-14 今後の課題2) */
.card-tags { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  background: #fceff2; color: var(--accent);
  font-size: 12px; text-decoration: none; overflow-wrap: anywhere;
}
a.tag-chip:hover { background: #f7dde4; }
.tag-chip.active { background: var(--accent); color: var(--accent-ink); }
.search-result-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 1px; }

/* ---------- 画面右端のチャット履歴レール(kyarapu 風。全画面共通) ---------- */

:root { --rail-w: 84px; }

.history-rail {
  position: fixed; right: 0; bottom: 0; top: 0;
  width: var(--rail-w);
  /* 枠は持たない: kyarapu 風にアイコンが浮いて見せる(UI改善第3弾 要望1) */
  background: transparent;
  padding: 14px 8px 16px;
  overflow-y: auto; z-index: 90; /* 左サイドバー(100)の下 */
  scrollbar-width: none;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.history-rail::-webkit-scrollbar { display: none; }

/* 履歴に出すキャラ単位のアイコン */
.recent-char {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-decoration: none; width: 100%;
}
.recent-char-thumb {
  width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
  background: #e6e6ec; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);   /* 枠なしでも背景から浮いて見えるように */
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.recent-char:hover .recent-char-thumb { border-color: var(--accent); }
.recent-char-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recent-char-initial { font-size: 20px; color: var(--muted); }
.recent-char-name {
  max-width: 100%; font-size: 12px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-char:hover .recent-char-name { color: var(--accent); }

/* レールと本文の重なり回避: 余白が足りない幅のときだけ本文を左へ寄せる。
 * (サイドバー200px を除いた残り幅で中央配置なので、右側余白が
 *  レール84px 以上になるのは 200 + 960 + 84×2 = 1328px 以上のとき) */
@media (max-width: 1328px) {
  body.has-rail main { margin-right: var(--rail-w); }
}
/* 中間幅ではサイドバーをアイコンのみに畳む */
@media (max-width: 1000px) {
  :root { --side-w: 56px; }
  .side-nav { padding: 12px 6px; }
  .site-title { display: none; }
  .side-link { justify-content: center; padding: 9px 4px; }
  .side-label, .side-nav .side-badge { display: none; }
}
/* スマホ幅(800px 以下)の枠は**ファイル末尾の「スマホ表示」節**にまとめてある
 * (SPEC §23。2026-08-28 作り直し。それまでは、ここでサイドバーを上部の横並び
 * バーに畳んでいた)。サイドバー・履歴レールはスマホでは出さない */

/* ---------- フォーム ---------- */

.form-section {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 20px; margin-bottom: 20px;
}

/* キャラ作成フォームのタブ(JS有効時のみ #form-tabs の hidden が外れる) */
.form-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 2px solid var(--line); margin-bottom: 20px;
}
.form-tabs button {
  border: none; background: none; cursor: pointer;
  padding: 10px 16px; font-size: 14px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  font-family: inherit;
}
.form-tabs button:hover { color: var(--ink); }
.form-tabs button.active {
  color: var(--ink); font-weight: bold;
  border-bottom-color: var(--accent);
}
form.tabs-on .form-section { display: none; }
form.tabs-on .form-section.tab-active { display: block; }
.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-weight: bold; font-size: 14px; margin-bottom: 2px; }
.field .desc { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.required { color: var(--accent); font-size: 12px; margin-left: 4px; }

input[type="text"], input[type="number"], textarea, select {
  width: 100%; padding: 8px 10px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 6px;
  font-family: inherit; line-height: 1.6; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid #c9c9d6; outline-offset: -1px; }

/* OS標準の見た目のままだった部品のモダン化(2026-08-13 ユーザー要望):
 * ファイル選択ボタンは ::file-selector-button で丸型ボタン(.btn 相当)に、
 * チェックボックス類は accent-color でテーマ色に */
/* 幅は既定だと狭い固定幅で「選択されていません」が中間省略されるため欄いっぱいに */
input[type="file"] { font-size: 13px; color: var(--muted); width: 100%; }
input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 7px 16px;
  border: 1px solid #f1c5cf; border-radius: 999px;
  background: #fceff2; color: var(--ink);
  font-family: inherit; font-size: 14px; line-height: 1.5; cursor: pointer;
}
input[type="file"]:hover::file-selector-button { background: #f8dee5; }
/* 管理側のファイル選択ボタンは主色の青系の淡色 */
body.admin input[type="file"]::file-selector-button {
  background: #e9f0fd; border-color: #bfd3f7;
}
body.admin input[type="file"]:hover::file-selector-button { background: #dce8fb; }
/* 全体を囲む共通の focus 枠はファイル入力には不釣り合いなので、ボタン側に付け替え */
input[type="file"]:focus { outline: none; }
input[type="file"]:focus-visible::file-selector-button {
  outline: 2px solid #c9c9d6; outline-offset: 1px;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
/* 管理側は主色の青(サイドバー --admin-blue と同色) */
body.admin input[type="checkbox"], body.admin input[type="radio"] { accent-color: #2563eb; }

.counter { text-align: right; color: var(--muted); font-size: 13px; margin-top: 2px; }
.counter.over { color: var(--accent); font-weight: bold; }

.repeat-item {
  border: 1px solid var(--line); border-radius: 6px;
  padding: 14px; margin-bottom: 12px; background: #fafafc;
}
.repeat-item[hidden] { display: none; }   /* 空き枠の段階表示(app.js)。hidden を勝たせる保険 */
.repeat-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: bold; color: var(--muted); margin-bottom: 10px;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-actions {
  display: flex; gap: 12px; align-items: center;
  position: sticky; bottom: 0; background: var(--bg);
  padding: 16px 0; border-top: 1px solid var(--line);
}
.form-actions .spacer { flex: 1; }

/* ---------- チャット ---------- */

/* 枠(ヘッダ・メッセージ欄・入力欄)は**画面いっぱい**に広げる
 * (2026-08-20 第3回 ユーザー要望「まだ窮屈。固定部分を除いた画面全部で
 * スクロールする感じに」。きゃらぷのチャット画面と同じ構え)。
 * 読みやすさは枠の幅ではなく**中の会話1列**で担保する — 吹き出しの行は
 * --chat-col で中央に寄せる(720px だと長めのセリフが1行に収まらないため
 * 900px にした 2026-08-14 課題4 の経緯を引き継ぎ、レール廃止で空いた分を
 * 少し足して 1000px ≈ 全角62字/行)。
 * スクロール領域(=.messages)自体は画面幅いっぱいのままなので、
 * スクロールバーは画面の右端に出る */
.chat-wrap { max-width: none; margin: 0; --chat-col: 1000px; }
.chat-wrap > .messages > * {
  width: 100%; max-width: var(--chat-col); margin-left: auto; margin-right: auto;
}
/* 会話の列に合わせるもの: 入力欄・エラー/完了メッセージ・未回答の注記・
 * 再生成の操作行。ヘッダだけは画面いっぱいのまま(上部バーとして伸ばす) */
.chat-wrap > .chat-input,
.chat-wrap > .errors,
.chat-wrap > .notice,
.chat-wrap > .chat-tools {
  width: 100%; max-width: var(--chat-col); margin-left: auto; margin-right: auto;
}
/* 「このチャットはフィクションです」(メッセージ欄の先頭に流し込む注記) */
.chat-fiction-note {
  text-align: center; color: var(--muted); font-size: 12px; margin: 0;
}
/* 会話中ずっとキャラ名・初期設定・操作が見えるよう上部に貼り付ける
 * (2026-08-20 ユーザー要望)。ページ全体のスクロールはそのままで、
 * ヘッダだけが上端で止まる(sticky)。会話が下を通り抜けるので背景は不透明 */
.chat-head {
  position: sticky; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 14px; margin-bottom: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}
/* キャラ名と初期設定/あなたの名前は**横並びの1行**にする(2026-08-20 第2回。
 * 「チャットの表示部分が狭い」— 固定部分を薄くしてメッセージ欄に高さを回す。
 * きゃらぷのチャット見出しも1行 48px 相当) */
.chat-head-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
/* 幅が足りないときの縮み方: まず meta(初期設定/あなた)が … で縮み、
 * それでも足りなければ名前も縮む。右の操作ボタンや検索欄とぶつかって
 * はみ出すより、切り詰める方を選ぶ(2026-08-20 第5回で同じ行に統合したため) */
.chat-head-title .name,
.chat-head-title .meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-title .name { flex-shrink: 1; min-width: 4em; }
.chat-head-title .meta { flex-shrink: 3; }
/* 止まる位置の変遷(2026-08-20): 右上の固定バー(.top-actions = 検索欄+
 * 通知+マイページ)と重ならないよう 0 → 60px → 46px と下げてきたが、
 * **第5回で上部バーと同じ行に統合した**ため 0 に戻した。ヘッダ自身が
 * 画面上端のバーで、その右端に検索欄・アイコンが乗る(下の統合ブロック)。
 * 800px 以下では .top-actions が静的になり一緒にスクロールするので、
 * この 0 のままで重ならない */
.chat-head { top: 0; }

/* チャット画面の右上バーだけ細身にする(上と対。ここを縮めた分だけ
 * ヘッダ・メッセージ欄が上に上がる。他ページの見え方は変えない) */
body:has(.chat-wrap) .top-actions { top: 6px; }
body:has(.chat-wrap) .top-action { width: 36px; height: 36px; }
body:has(.chat-wrap) .top-search { height: 36px; }

/* ---- チャット画面だけ「アプリ型」の枠にする(2026-08-20 ユーザー要望。
 * 参考: きゃらぷのチャットルーム)。画面全体はスクロールさせず、
 * ヘッダと入力欄を上下に固定して**メッセージ欄だけが内側でスクロール**する。
 * これで会話が右上の検索欄やヘッダの下を通り抜けて見えることがなくなる。
 * 実装はフレックス1本: .chat-wrap を縦フレックスにし、.messages だけ
 * flex:1 + overflow-y:auto。他の要素(ヘッダ・注記・ツール・入力欄)は
 * 内容なりの高さで上下に残る。PHP 側の構造は変えていない ---- */
body:has(.chat-wrap) { overflow: hidden; }          /* 画面全体は動かさない */
body:has(.chat-wrap) .site-footer { display: none; }
main:has(.chat-wrap) {
  display: flex; height: 100vh; height: 100dvh;
  /* 画面いっぱい(左サイドバーの右から画面の右端まで)。右端のチャット履歴
   * レールはチャット画面では出していない(layout.php の $onChat)ので、
   * その 84px もここに回っている */
  max-width: none; padding-left: 16px; padding-right: 16px;
  /* 上余白なし = ヘッダが画面の上端に付く(第5回で上部バーと統合) */
  padding-top: 0; padding-bottom: 10px;
  /* 退避経路(codexレビュー推奨1 2026-08-20): 固定側(エラー表示・ヘッダ・
   * 再送/再生成・入力欄・おすすめ回答)の合計が画面より高くなったら、
   * 枠自体をスクロールできるようにして画面外の操作を拾えなくしない */
  overflow-y: auto;
}
.chat-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-wrap > .messages {
  flex: 1 1 auto; overflow-y: auto;
  /* 0 まで潰れると会話が1行も見えなくなるので下限を置く。ここを割り込む
   * 高さのときは上の overflow-y: auto 側で逃がす(codexレビュー推奨1) */
  min-height: 120px;
  padding-right: 6px;   /* スクロールバーが吹き出しに重ならないように */
}
/* 従来どおり画面全体をスクロールさせる場合(=固定枠を解除する条件):
 *  - PC で高さ 640px 以下: 低いウィンドウ・ブラウザ拡大・大きい文字設定。
 *    固定部分だけで画面が埋まり、会話がほとんど見えなくなる
 *    (codexレビュー推奨1 2026-08-20。幅の分岐だけでは防げない)。
 *    上部バーが固定のままなのでヘッダも画面上端(0)のバーのまま。
 *    本文はその下をスクロールする
 *  - 幅 800px 以下は 2026-08-28 からここでは扱わない(スマホ表示=末尾の節。
 *    固定入力欄+ページスクロール。100dvh 固定はアドレスバーの伸縮で
 *    入力欄が跳ねるので使わない、という方針は同じ) */
@media (min-width: 801px) and (max-height: 640px) {
  .chat-head { top: 0; }
  body:has(.chat-wrap) { overflow: auto; }
  body:has(.chat-wrap) .site-footer { display: block; }
  main:has(.chat-wrap) {
    display: block; height: auto; overflow: visible;
    padding: 0 16px 60px;
  }
  .chat-wrap { display: block; }
  .chat-wrap > .messages { overflow: visible; min-height: 0; padding-right: 0; }
}

/* ---- チャット画面の上部は「1本のバー」にする(2026-08-20 第5回 ユーザー要望
 * 「検索部分と固定部分の間の“背景らしき横長の表示”はいらない」)。
 * 第4回は白帯(body::before)を敷いて2段を白でつないだが、上段は検索欄が
 * 右端にあるだけで**左が丸ごと空きの帯**になり、余計な段に見えていた。
 * そこで帯をやめ、**チャットの見出しと検索欄・アイコンを同じ行**に置く:
 *   ①ヘッダを画面上端(top:0)の高さ48pxのバーにする(カードはやめ、
 *     左右いっぱい=負のマージン -16px は main の左右 padding と対、
 *     下線1本だけ)
 *   ②検索欄・アイコン(.top-actions は position:fixed のまま)から枠と影を
 *     外し、バーの右端に乗っているように見せる
 *   ③その分ヘッダの右に場所を空ける(padding-right)。空ける幅は
 *     .top-actions の実寸 = 検索欄242 + 8 + アイコン36×3 + 8×2 = 374px に
 *     右余白16と間隔16を足した 406 → 410px
 * 狭い画面(800px 以下)では .top-actions が静的になり同じ行に置けないので
 * 掛けない(従来どおりカード表示) ---- */
@media (min-width: 801px) {
  body:has(.chat-wrap) .chat-head {
    min-height: 48px;
    margin: 0 -16px 12px; padding: 6px 20px; padding-right: 410px;
    border: none; border-bottom: 1px solid var(--line);
    border-radius: 0; box-shadow: none;
  }
  body:has(.chat-wrap) .top-search {
    background: #f0f0f4; border-color: transparent; box-shadow: none;
  }
  body:has(.chat-wrap) .top-search:focus-within { border-color: var(--accent); }
  body:has(.chat-wrap) .top-action {
    background: transparent; border-color: transparent; box-shadow: none; opacity: 1;
  }
  body:has(.chat-wrap) .top-action:hover,
  body:has(.chat-wrap) .notice-menu[open] > summary { background: #f0f0f4; }
}
/* 同じ行に検索欄まで並べるには 1200px では足りない(キャラ名+初期設定と
 * 右の操作3つで 700px 前後を使う)。狭いときは検索欄だけ畳んでアイコンを
 * 残す — 検索はサイドバーのホームから辿れる */
@media (min-width: 801px) and (max-width: 1200px) {
  body:has(.chat-wrap) .top-search { display: none; }
  body:has(.chat-wrap) .chat-head { padding-right: 160px; }  /* アイコン3つ分 */
}

/* ---- 立ち絵パネル(課題⑤ 第1段 2026-08-27。きゃらぷの「登場人物の画像」の
 * 第一歩)。プロフィール画像を会話の列の**左**に固定で出す。
 *   ・置き方は position: fixed(.chat-wrap の縦フレックスに手を入れない。
 *     左サイドバーの右隣、ヘッダの下に置く)
 *   ・会話の列(.messages・入力欄・注記・操作行)はパネルぶん右へ寄せる=
 *     .chat-wrap の padding-left。ヘッダだけは画面いっぱいのバーのままに
 *     したいので、その分を負のマージンで戻す(801px 以上の -16px と対)
 *   ・出す条件は **1201px 以上かつ高さ 641px 以上**だけ。1200px 以下は
 *     検索欄を畳む幅で、パネル 280px を引くと会話の列が 700px を切る。
 *     800px 以下・高さ 640px 以下は固定枠自体を解除している(上の退避)ので
 *     一緒に出さない。スマホの見せ方は第2段・スマホアプリ風UIで決める
 *   ・画像は切り抜かない(width:auto + max-width/max-height)。1:1 の画像は
 *     280×280、2:3 なら 280×420 になる。画面が低いときは高さ側で縮む
 *   ・画像が無いキャラでは <aside> 自体を描かない(chat.php)ので、
 *     :has() が効かず列は従来どおり中央に来る ---- */
.chat-wrap { --portrait-w: 280px; }
.chat-portrait { display: none; }
@media (min-width: 1201px) and (min-height: 641px) {
  .chat-portrait {
    display: block; position: fixed; z-index: 30;
    left: calc(var(--side-w) + 16px); top: 64px;
    width: var(--portrait-w);
  }
  .chat-portrait a { display: block; cursor: zoom-in; }
  .chat-portrait img {
    display: block; width: auto; height: auto;
    max-width: 100%; max-height: calc(100vh - 84px); max-height: calc(100dvh - 84px);
    border-radius: 12px; border: 1px solid var(--line);
    background: var(--panel); box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
  }
  /* body.has-chat-portrait はサーバ側(chat.php → cp_header)が付ける。:has() 非対応
   * ブラウザでも列の寄せが効くようにする(codex 推奨4 2026-08-28) */
  body:has(.chat-portrait) .chat-wrap, body.has-chat-portrait .chat-wrap { padding-left: calc(var(--portrait-w) + 20px); }
  body:has(.chat-portrait) .chat-head, body.has-chat-portrait .chat-head { margin-left: calc(-16px - var(--portrait-w) - 20px); }
  /* 第2段(§21-4): いま出ている立ち絵のラベル。画像の下に小さく添える。
   * 画像の max-height はラベル行のぶん(24px)を引く */
  .chat-portrait-label {
    margin: 6px 0 0; text-align: center; font-size: 12px; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .chat-portrait:has(.chat-portrait-label) img {
    max-height: calc(100vh - 108px); max-height: calc(100dvh - 108px);
  }
}

/* ヘッダ内の「応答の質」(2026-08-20。選ぶと即反映するのでボタンは無い) */
.chat-quality { margin: 0; }
.chat-quality select {
  font-size: 13px; padding: 5px 8px; max-width: 190px;
}
.chat-head .name { font-weight: bold; }
.chat-head .meta { color: var(--muted); font-size: 13px; }
.chat-head-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* チャットルーム設定(ヘッダ右の「…」メニュー。kyarapu 相当。UI改善第2弾 要望3)
 * details ベースなのでJS無効でも開閉できる。外側クリックで閉じるのは app.js */
.room-menu { position: relative; }
.room-menu > summary {
  list-style: none; cursor: pointer; user-select: none;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel);
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; line-height: 1; padding-bottom: 6px;
}
.room-menu > summary::-webkit-details-marker { display: none; }
.room-menu > summary:hover,
.room-menu[open] > summary { border-color: var(--accent); }
.room-panel {
  position: absolute; right: 0; top: 38px; z-index: 90;
  width: 320px; max-width: calc(100vw - 48px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .14);
  padding: 4px 16px 8px; text-align: left;
  /* 画面より高くなったらパネル自身をスクロールさせる(2026-08-20。
   * チャット画面は枠を固定したので、はみ出した分は画面スクロールで追えない) */
  max-height: calc(100dvh - 120px); overflow-y: auto;
}
.room-panel-title {
  font-weight: bold; font-size: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.room-section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.room-section:last-child { border-bottom: none; }
.room-section h3 { font-size: 13px; margin: 0 0 2px; }
.room-section .desc { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.room-section select { width: 100%; }
.room-profile { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.room-profile-name { font-weight: bold; }
.room-profile-info { color: var(--muted); font-size: 13px; white-space: pre-wrap; }

/* チャットプロフィールの選択(2026-08-20 ユーザー要望のレイアウト)。
 * 見出しの右にサブリンクを寄せ、操作は見出しの直下に置く。
 * 情報(100字)は常時出すと縦に嵩張るので、選択欄にカーソルを当てている間
 * (キーボードならフォーカス中)だけ出す。position:absolute にしてあるのは
 * 表示のたびにパネル内の他の項目が下へずれるのを避けるため */
.room-section-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 6px; }
.room-section-head h3 { margin: 0; }
.room-section-link { margin-left: auto; font-size: 12px; color: var(--accent); }
.room-profile-pick { position: relative; margin-bottom: 8px; }
.room-profile-tip {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 3;
  margin: 0; padding: 8px 10px; border-radius: 8px;
  background: var(--ink); color: #fff; font-size: 12px; line-height: 1.6;
  white-space: pre-wrap; box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  opacity: 0; visibility: hidden; transition: opacity .12s ease;
}
.room-profile-tip:empty { display: none; }   /* 情報が未入力のプロフィール */
.room-profile-pick:hover .room-profile-tip,
.room-profile-pick:focus-within .room-profile-tip { opacity: 1; visibility: visible; }
.room-profile-note { margin-top: 8px; margin-bottom: 0 !important; font-size: 12px; }

/* おぼえがき(SPEC §24。2026-08-30)。ルーム設定パネルの中の1節。
 * 候補(AI が書いた箇条書き)は薄い色の枠で「まだ本体ではない」ことを見せる */
.memo-scope { color: var(--muted); font-weight: normal; }
.memo-status { margin: 0 0 8px; font-size: 13px; color: var(--accent); }
.memo-draft {
  margin: 0 0 6px; padding: 10px 10px 8px; border-radius: 8px;
  background: #fff7e6; border: 1px dashed #e0b25a;
}
.memo-draft-title { margin: 0 0 6px; font-size: 12px; font-weight: bold; color: #8a5a00; }
.memo-draft textarea { background: #fff; }
.memo-draft-actions { display: flex; gap: 8px; }
.memo-discard { margin: 0 0 12px; }
.memo-draft-start { margin: 0 0 4px; }
.memo-note { font-size: 12px; margin-bottom: 12px !important; }

/* ルーム設定パネルのボタン(2026-08-30 ユーザー要望「白背景に埋もれて目立たない。
 * 淡い暖色を」)。通常ボタンだけ淡い桃色の面に。btn-primary(赤)は従来どおり。
 * 押せないときは薄くして「押せない」を見せる */
.room-panel .btn:not(.btn-primary) {
  background: #fff1e4; border-color: #f0c39a; color: #4a2e14;
}
.room-panel .btn:not(.btn-primary):hover { background: #ffe4cc; border-color: #e6a96e; }
.room-panel .btn[disabled] { opacity: .45; cursor: not-allowed; }
.room-panel .btn[disabled]:hover { background: #fff1e4; border-color: #f0c39a; }

.messages { display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
/* 幅の上限は「行全体」を基準にする(2026-08-14 課題4)。
 * 以前は .bubble に max-width: 90% を置いていたが、これは吹き出しを包む
 * 幅可変の div(shrink-to-fit)に対する 90% になり、どの吹き出しも自然幅の
 * 9割へ切り詰められて文の途中で1〜2文字早く折り返していた。
 * 上限は行幅が確定しているラッパー側(.msg > div)に置き、
 * .bubble 自体は無制限にして内容なりに広がらせる */
.msg > div { min-width: 0; max-width: 100%; }
.msg.user > div { max-width: 85%; }
.bubble {
  padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word;
}
.msg.user .bubble { background: var(--user-bubble); color: #fff; border-color: var(--user-bubble); }
.msg.assistant .bubble { background: var(--char-bubble); width: 100%; }
.msg .speaker { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.bubble em { color: var(--muted); font-style: italic; }
/* 自分の発言の吹き出しは背景が黒(--user-bubble)なので、地の文と同じ
 * --muted(濃いグレー)では背景に沈んで読めない(2026-08-20 ユーザー指摘)。
 * 白を薄めて「セリフより控えめだが読める」明度にする(コントラスト比 約7.7:1) */
.msg.user .bubble em { color: rgba(255, 255, 255, .72); }

/* ストーリーチャット(SPEC §29 2026-09-06。設計=PLAN_story_chat.md §2-4・§2-8)。
 * 1 応答 1 つの .bubble.story の中に、地の文=ナレーターの吹き出し(.story-nar。アイコン+淡色
 * イタリック・名前なし)と、セリフ=話者の吹き出し(.story-line。アイコン/頭文字+名前+本文)を
 * 並べる(Zeta 型)。normal の吹き出し(.bubble のみ)には一切効かない */
.msg.assistant .bubble.story { white-space: normal; padding: 10px 12px; }
.story-nar {
  position: relative; margin: 0 0 8px; padding: 6px 10px 6px 30px; border-radius: 8px;
  background: rgba(0, 0, 0, .04); color: var(--muted); font-style: italic; white-space: pre-wrap;
}
.story-nar .nar-mark { position: absolute; left: 10px; top: 5px; font-style: normal; opacity: .55; }   /* 実要素(aria-hidden)。疑似要素の content は読み上げられうる(codex 推奨4 2026-09-08) */
.story-nar em { color: inherit; }
.story-line { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 8px; }
.story-nar:last-child, .story-line:last-child { margin-bottom: 0; }
.spk-avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  background: #e4e4ea; color: #555; font-size: 13px; font-weight: bold;
  display: inline-flex; align-items: center; justify-content: center;
}
.spk-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.story-line .spk-body { min-width: 0; flex: 1 1 auto; }
.story-line .spk { display: block; font-size: 12px; font-weight: bold; color: var(--muted); margin: 6px 0 2px; }
.story-line.spk-main .spk { color: var(--accent); }
.story-line.spk-user .spk { color: #b7411e; }
.story-line.spk-user .spk .spk-note { font-weight: normal; margin-left: 6px; }   /* 注意文は実要素=読み上げにも渡す(codex 推奨4) */
.story-line .say { display: block; white-space: pre-wrap; }
/* §19 の演出中、まだ到達していないブロックを隠す(app.js が付け外し。.story-line の display:flex に勝たせる) */
.bubble.story .tw-blk-hide { display: none !important; }

/* ストーリーチャットのバッジ(カード・検索・作成・チャット開始。.badge-sensitive と同じ流儀) */
.badge-story {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: normal;
  background: #eef0fd; border: 1px solid #5b62d6; color: #4046b8; vertical-align: 2px; margin-left: 4px;
}

/* シーン画像(2026-08-16。応答ごとのボタンで生成し吹き出しの下に添付) */
.msg .scene-image { display: block; margin-top: 8px; max-width: min(480px, 100%); cursor: zoom-in; }
.msg .scene-image img {
  width: 100%; display: block; border-radius: 12px;
  border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(0,0,0,.10);
}
.scene-form { margin-top: 6px; }
.scene-form .scene-btn { font-size: 13px; color: var(--muted); }

/* AI応答の1文字ずつ表示(SPEC §19 2026-08-25)。演出中は末尾に点滅カーソルを
 * 出し、再生成・シーン画像のボタンは場所を確保したまま隠す(visibility なので
 * レイアウトが動かない)。演出は app.js が担い、ここは見た目だけ */
.bubble.tw-typing::after {
  content: '▍'; margin-left: 1px; color: var(--muted);
  animation: tw-blink 1s steps(1, end) infinite;
}
@keyframes tw-blink { 50% { opacity: 0; } }
.tw-hold { visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
  .bubble.tw-typing::after { animation: none; }
}

/* 送信キーの案内(Enter送信。2026-08-16)。狭い画面では省略 */
.chat-key-hint { font-size: 12px; color: var(--muted); align-self: center; }
@media (max-width: 800px) {
  .chat-key-hint { display: none; }
}

.chat-input { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
/* 入力欄は「1行始まり + 入力に応じて伸びる」(2026-08-20 第2回 ユーザー要望
 * 「入力部分の高さはもう少し縮めて大丈夫」。きゃらぷも 1行 26px 始まり)。
 * 伸縮は app.js の cpAutoGrow が height を書く。min-height が下限、
 * max-height が上限で、超えたぶんは textarea 内スクロールに逃がす。
 * JS 無効のときは height を誰も書かないので HTML の rows=2 のまま
 * (2行ぶん)になる = 操作不能にはならない */
.chat-input textarea {
  border: none; padding: 2px 4px; resize: none; overflow-y: auto;
  line-height: 1.7; min-height: 30px; max-height: 168px;
}
.chat-input textarea:focus { outline: none; }
.chat-tools { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.chat-tools .spacer { flex: 1; }
.suggestions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.suggestions button { text-align: left; }

/* ---------- トップページの項目+カルーセル(SPEC §22。2026-08-27) ----------
 * 運営が管理ツールで作った「おすすめ」等の項目を、「トップ」タブ上部に
 * 横一列で出す。カードは .card をそのまま固定幅で並べる(グリッドと同じ
 * 見た目)。‹ › は列の左右端に重ねる丸ボタンで、はみ出しが無い列では
 * JS が .has-overflow を付けないので出ない。800px 以下はスワイプに任せる */
.home-section { margin: 0 0 28px; }
.home-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.home-section-head h2 { font-size: 18px; margin: 0; }
.home-section-head h2 a { color: var(--ink); text-decoration: none; }
.home-section-head h2 a:hover { color: var(--accent); }
.home-section-more {
  font-size: 14px; color: var(--muted); text-decoration: none; white-space: nowrap;
}
.home-section-more:hover { color: var(--accent); }
.home-sections-end { border-top: 1px solid var(--line); margin: 4px 0 24px; }

.carousel { position: relative; }
.carousel-track {
  display: flex; gap: 16px; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scroll-behavior: smooth;
  padding: 2px 2px 10px; scrollbar-width: thin; outline: none;
  -webkit-overflow-scrolling: touch;
}
.carousel-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* カードの幅は**グリッドと同じ「3枚が収まる幅」**(隙間 16px×2 を除いた 1/3。
 * 2026-08-27 実機確認: 固定 220px では「チャットする」が2段に折れた) */
.carousel-track > .card {
  flex: 0 0 calc((100% - 32px) / 3); width: auto; min-width: 0; scroll-snap-align: start;
}
.carousel-btn {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 40px; height: 40px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .94); color: var(--ink);
  font-size: 26px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
  display: none; align-items: center; justify-content: center;
}
.carousel.has-overflow .carousel-btn { display: flex; }
.carousel-btn.prev { left: -14px; }
.carousel-btn.next { right: -14px; }
.carousel-btn:hover { background: #fff; border-color: var(--accent); color: var(--accent); }
.carousel-btn[disabled] { opacity: .3; cursor: default; }
.carousel-btn[disabled]:hover { border-color: var(--line); color: var(--ink); background: rgba(255, 255, 255, .94); }
@media (max-width: 800px) {
  .carousel .carousel-btn { display: none; }
  /* スマホはグリッドが1列=幅いっぱいなので、横一列も1枚+次の端が
   * 少し見える幅にする(スワイプできることが分かる) */
  .carousel-track > .card { flex-basis: calc(100% - 48px); }
}
@media (prefers-reduced-motion: reduce) {
  .carousel-track { scroll-behavior: auto; }
}

/* ---------- キャンペーンバナー(トップ。管理ツールから登録した飾り) ---------- */

.banner-strip {
  position: relative; aspect-ratio: 4 / 1;
  margin-bottom: 20px; border-radius: 10px; overflow: hidden;
  background: #e6e6ec;
}
.banner-item {
  position: absolute; inset: 0; display: block;
  opacity: 0; transition: opacity .6s; pointer-events: none;
}
.banner-item.active { opacity: 1; pointer-events: auto; }
.banner-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- キャラ検索結果(search.php。kyarapu の /search を参考) ---------- */

.search-page { max-width: 640px; margin: 0 auto; }
.search-tabs {
  display: flex; justify-content: center; gap: 4px;
  border-bottom: 1px solid var(--line); margin-bottom: 24px;
}
.search-tab {
  padding: 10px 28px; font-size: 14px; color: var(--muted);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap; /* 課題メモ⑱: 幅が足りないと日本語は文字単位で折れ「最後の1文字だけ次の行」になる */
}
.search-tab:hover { color: var(--ink); }
.search-tab.active { color: var(--ink); font-weight: bold; border-bottom-color: var(--ink); }
.search-title { font-size: 20px; margin: 0 0 6px; }
.search-meta {
  display: flex; align-items: center; gap: 14px;
  font-size: 14px; margin-bottom: 18px;
}
.search-count { font-weight: bold; }
.search-meta .spacer { flex: 1; }
.search-filter { color: var(--muted); text-decoration: none; font-size: 14px; }
.search-filter:hover { color: var(--ink); }

.search-results { display: flex; flex-direction: column; gap: 22px; }
.search-result { display: flex; gap: 16px; text-decoration: none; }
.search-result-thumb {
  width: 74px; height: 104px; border-radius: 8px; overflow: hidden;
  background: #e6e6ec; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.search-result-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.search-result-initial { font-size: 26px; color: var(--muted); }
.search-result-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.search-result-name { font-weight: bold; font-size: 15px; }
.search-result:hover .search-result-name { color: var(--accent); }
.search-result-desc {
  color: var(--ink); font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-result-meta { color: var(--muted); font-size: 13px; margin-top: auto; }

/* ---------- 管理ツール(admin/。公開画面とは別の枠) ---------- */

/* 文字の見やすさ向上(2026-08-13 ユーザー要望)は当初管理側のみだったが、
 * 同日中に公開側にも展開しベース(:root の --muted / body のフォント /
 * 各コンポーネントのサイズ)へ統合した。管理専用の上書きは不要になった */
/* 左固定のサイドバー(2026-08-28 課題メモ⑧ 第1弾。それまでは上部の横並びバー)。
 * 色は 2026-08-13 のユーザー要望の明るめの青 #2563eb を維持(ログイン画面と同色)。
 * markup は app/admin.php の cp_admin_header() の1か所 */
:root { --admin-side-w: 220px; --admin-blue: #2563eb; }
body.admin { padding-left: var(--admin-side-w); }
body.admin-login { padding-left: 0; }   /* ログイン画面はサイドバー無し */
.admin-side {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  width: var(--admin-side-w);
  display: flex; flex-direction: column;
  background: var(--admin-blue); color: #fff;
  overflow-y: auto; overflow-x: hidden;
}
.admin-brand {
  display: block; padding: 18px 18px 14px; flex-shrink: 0;
  color: #fff; text-decoration: none; font-weight: bold; font-size: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .18);
}
.admin-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 16px; }
.admin-group { display: flex; flex-direction: column; gap: 2px; }
.admin-group-label {
  padding: 0 10px; margin-bottom: 4px;
  font-size: 11px; letter-spacing: .08em; color: rgba(255, 255, 255, .62);
}
.admin-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  color: rgba(255, 255, 255, .88); text-decoration: none;
  font-size: 15px; white-space: nowrap;
}
.admin-link:hover { color: #fff; background: rgba(255, 255, 255, .14); }
.admin-link.active { color: #fff; font-weight: bold; background: rgba(255, 255, 255, .22); }
.admin-icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; opacity: .92; }
.admin-icon svg { width: 18px; height: 18px; }
.admin-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.admin-side-foot {
  flex-shrink: 0; padding: 10px 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, .18);
  display: flex; flex-direction: column; gap: 6px;
}
.admin-side-foot form { margin: 0; padding: 4px 10px 0; }
.admin-logout {
  width: 100%; color: #fff;
  background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .35);
}
.admin-logout:hover { background: rgba(255, 255, 255, .24); }
/* 本文: サイドバーのぶん左が空くので幅上限を 1100 → 1200 に */
body.admin main { max-width: 1200px; padding-top: 28px; }

/* 1000px 以下: サイドバーを上部の横並びバー(横スクロール)に畳む。
 * スマホで FB を読む用途を壊さないため。公開側 .side-nav の 800px 以下と同じ手法 */
@media (max-width: 1000px) {
  body.admin { padding-left: 0; }
  .admin-side {
    position: sticky; top: 0; bottom: auto; width: auto;
    flex-direction: row; align-items: center; gap: 6px;
    padding: 6px 10px; overflow-x: auto; overflow-y: hidden;
  }
  .admin-brand { padding: 4px 10px 4px 0; border-bottom: none; font-size: 15px; }
  .admin-nav { flex-direction: row; gap: 2px; padding: 0; }
  .admin-group { flex-direction: row; }
  .admin-group-label, .admin-icon { display: none; }
  .admin-link { padding: 6px 8px; font-size: 14px; }
  .admin-side-foot { flex-direction: row; align-items: center; gap: 2px; border-top: none; padding: 0; }
  .admin-side-foot form { padding: 0; }
  .admin-logout { width: auto; }
}

.stat-grid {
  display: grid; gap: 12px; margin-bottom: 24px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.stat-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px;
}
.stat-card .label a { color: var(--admin-blue); }

/* ダッシュボードの「要対応」カード(2026-08-28)。0 件は灰色、1 件以上は赤で目立たせる。
 * カード全体がリンク(該当ページへ) */
.h2-sub { font-weight: normal; color: var(--muted); font-size: 13px; margin-left: 10px; }
.todo-grid {
  display: grid; gap: 12px; margin-bottom: 24px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.todo-card {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px;
}
.todo-card .num { font-size: 26px; font-weight: bold; line-height: 1.2; }
.todo-card .label { color: var(--muted); font-size: 13px; }
.todo-card.zero .num { color: #8a8a96; }
.todo-card.alert { border-color: #f0b6c0; background: #fff5f7; }
/* 要対応カードの内訳リンク(失敗・保留=チャット/画像/おぼえがき。2026-08-30) */
.todo-card .todo-by { margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.todo-card .todo-by a { color: var(--muted); text-decoration: none; }
.todo-card .todo-by a.hit { color: var(--accent); font-weight: bold; }
.todo-card .todo-by a:hover { text-decoration: underline; }
.todo-card.alert .num { color: var(--accent); }
.todo-card:hover { border-color: var(--admin-blue); box-shadow: 0 2px 8px rgba(37, 99, 235, .14); }

/* 折りたたみ(累計の統計カード・ログ末尾)。summary 行に要点の数字を出すので閉じたままでも読める */
.admin-fold { margin-bottom: 24px; }
.admin-fold > summary {
  cursor: pointer; list-style: none; font-weight: bold; font-size: 16px;
  padding: 10px 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px;
}
.admin-fold > summary::-webkit-details-marker { display: none; }
.admin-fold > summary::before { content: "▸ "; color: var(--admin-blue); }
.admin-fold[open] > summary::before { content: "▾ "; }
.admin-fold[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.admin-fold > summary .sub { font-weight: normal; color: var(--muted); font-size: 13px; margin-left: 8px; }
.admin-fold > .fold-body {
  padding: 16px 14px 0; border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 8px 8px; background: rgba(255, 255, 255, .5);
}
.stat-card .num { font-size: 24px; font-weight: bold; line-height: 1.3; }
.stat-card .label { color: var(--muted); font-size: 13px; }

/* 一覧テーブル(2026-08-28 課題メモ⑧ 第2弾で定番の仕上げ: 横線のみ・角丸・
 * 行ホバー・見出し行の固定(ページのスクロールに追随)・数値列は .n で右寄せ+等幅数字。
 * 縦線をやめたので、セルの区切りは余白で読む) */
.admin-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--panel); font-size: 14px; margin: 8px 0 24px;
  border: 1px solid var(--line); border-radius: 8px;
}
.admin-table th, .admin-table td {
  border: none; border-bottom: 1px solid var(--line); padding: 7px 10px;
  text-align: left; vertical-align: middle;
}
.admin-table > :last-child > tr:last-child > td { border-bottom: none; }   /* tfoot があれば tbody 末尾の線は残す */
.admin-table th { background: #f0f2f7; font-size: 13px; white-space: nowrap; }
/* 見出し行の固定は <thead> の中だけ(詳細画面の「項目名 | 値」表の行見出しまで
 * 上端に貼り付かないように。codex レビュー推奨 2026-08-28) */
.admin-table thead th { position: sticky; top: 0; z-index: 1; }
.admin-table thead tr:first-child th:first-child { border-top-left-radius: 8px; }
.admin-table thead tr:first-child th:last-child { border-top-right-radius: 8px; }
.admin-table tbody tr:hover > td { background: #f6f8fd; }
.admin-table th.n, .admin-table td.n {
  text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.admin-table tfoot td { font-weight: bold; background: #fafbfe; }
.admin-table time { white-space: nowrap; }
.admin-row-off > td { color: var(--muted); }
.admin-muted { color: var(--muted); }

.admin-pre {
  background: #23232a; color: #e8e8ee; padding: 14px; border-radius: 8px;
  font-size: 13px; line-height: 1.6; overflow-x: auto;
  white-space: pre-wrap; word-break: break-all; margin: 8px 0 24px;
}

.status-pill {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 12px; white-space: nowrap;
}
.status-succeeded { background: #eaf6ec; color: #1f5c2e; }
.status-failed    { background: #fdecef; color: #8c1a2c; }
.status-pending   { background: #fff6e0; color: #7a5b00; }

.banner-thumb-sm {
  width: 240px; max-width: 100%; aspect-ratio: 4 / 1;
  object-fit: cover; border-radius: 4px; display: block;
  border: 1px solid var(--line); background: #e6e6ec;
}
/* トップの項目(admin/home_sections.php)のキャラのチェックリスト(§22)。
 * 管理側は app.js を読まないので、選択中の強調は :has() で CSS だけで行う
 * (非対応ブラウザではサーバが付ける .on=保存時点の状態だけになる) */
.hsec-choice-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px;
}
.hsec-choice {
  display: flex; gap: 10px; align-items: center; padding: 8px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
  cursor: pointer; font-weight: normal;
}
.hsec-choice.on, .hsec-choice:has(input[type="checkbox"]:checked) {
  border-color: #2563eb; background: #f3f7fe;
}
.hsec-choice:has(input[type="checkbox"]:not(:checked)) { border-color: var(--line); background: #fff; }
.hsec-choice input[type="checkbox"] { flex: 0 0 auto; }
.hsec-choice-thumb {
  flex: 0 0 40px; width: 40px; height: 56px; background: #e6e6ec;
  border-radius: 4px; overflow: hidden;
}
.hsec-choice-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hsec-choice-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.hsec-choice-name { font-weight: bold; font-size: 14px; }
.hsec-choice-meta, .hsec-choice-sort { color: var(--muted); }
.hsec-choice-sort input[type="number"] { width: 68px; margin-left: 4px; padding: 2px 6px; }

/* 一覧の絞り込みフォーム(生成ログ・画像生成ログ・モデレーション)。2026-08-28 に項目が増えたので折り返し可 */
.gen-filter {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  margin-bottom: 8px; font-size: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px;
}
.gen-filter label, .gen-filter .gen-filter-range { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.gen-filter input, .gen-filter select { width: auto; font-size: 14px; padding: 4px 8px; }
.gen-filter .btn { margin-left: auto; }
.gen-filter .btn + a, .gen-filter .btn + .btn { margin-left: 0; }
/* 生成ログの区分切替(チャットの応答 / おぼえがき。2026-08-30 SPEC §24-6) */
.gen-kind { margin: 0 0 12px; display: flex; gap: 8px; flex-wrap: wrap; }
/* ページ送り(2026-08-28) */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 4px 0 16px; font-size: 14px; }
.pager .pager-info { color: var(--muted); margin-right: 10px; }
.pager a, .pager .cur, .pager .off, .pager .gap {
  display: inline-block; min-width: 30px; padding: 3px 8px; text-align: center;
  border-radius: 6px; text-decoration: none;
}
.pager a { border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.pager a:hover { border-color: var(--admin-blue); color: var(--admin-blue); }
.pager .cur { background: var(--admin-blue); color: #fff; font-weight: bold; }
.pager .off { color: #b0b0ba; }
.pager .gap { color: var(--muted); min-width: 0; }

/* ログイン画面(2026-08-13 モダン化。管理バーと同じ青 #2563eb を主色に) */
body.admin-login main {
  max-width: none; margin: 0; padding: 24px 16px;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  width: min(420px, 100%);
  background: var(--panel); border: 1px solid rgba(37, 99, 235, .12);
  border-radius: 16px; padding: 36px 32px 32px;
  box-shadow: 0 16px 48px rgba(29, 44, 90, .16), 0 2px 8px rgba(0, 0, 0, .05);
  text-align: center;
}
.login-mark {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 6px 16px rgba(37, 99, 235, .35);
  display: flex; align-items: center; justify-content: center;
}
.login-mark svg { width: 26px; height: 26px; display: block; }
.login-box h1 { font-size: 20px; margin: 0 0 4px; }
.login-box .hint { margin: 0 0 24px; }
.login-box .errors { text-align: left; }
.login-box form { text-align: left; }
.login-box .field > label {
  font-size: 14px; color: var(--muted); margin-bottom: 6px;
}
/* 認証情報の入力欄は共通の input 指定より大きめに(password 型は共通指定の対象外)。
 * text はユーザーログイン(ログインID・表示名・招待コード。SPEC §14)でも使う */
.login-box input[type="password"],
.login-box input[type="text"] {
  width: 100%; padding: 13px 14px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; line-height: 1.5; background: #fff; color: var(--ink);
}
.login-box input[type="password"]:focus,
.login-box input[type="text"]:focus {
  outline: none; border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
}
.login-box .field { margin-bottom: 14px; }
.login-box .login-alt { margin: 18px 0 0; font-size: 14px; text-align: center; }
.login-btn {
  width: 100%; margin-top: 6px; padding: 12px 16px;
  border: none; border-radius: 10px; cursor: pointer;
  background: #2563eb; color: #fff;
  font-family: inherit; font-size: 15px; font-weight: bold; line-height: 1.5;
}
.login-btn:hover { background: #1d4ed8; }
.login-btn:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }

/* ---------- 画像生成ページ(2026-08-13。SPEC §2-2 の除外を方針転換で解除) ---------- */

.ig-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 18px; }
.ig-tab {
  padding: 8px 18px; text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: 15px; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.ig-tab.active { color: var(--ink); border-bottom-color: var(--accent); }

/* フォーム列は 380px — 画像サイズの4択(1:1/16:9/9:16/2:3)が1行に収まる幅
 * (340px では 2:3 だけ2行目に折り返していた。2026-08-14 ユーザー指摘) */
.ig-layout { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }

.ig-form {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; position: sticky; top: 80px;
}
.ig-form textarea { width: 100%; }

.ig-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.ig-pill { cursor: pointer; }
.ig-pill input { position: absolute; opacity: 0; pointer-events: none; }
.ig-pill span {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 52px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); font-size: 14px; font-weight: 600; color: var(--ink);
}
.ig-pill:hover span { border-color: #c5c5d2; }
.ig-pill input:checked + span {
  border-color: var(--accent); color: var(--accent); background: #fdf1f4;
}
.ig-pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ig-aspect-shape {
  display: inline-block; height: 14px; border: 1.5px solid currentColor; border-radius: 2px;
}

.ig-styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ig-style { position: relative; cursor: pointer; border-radius: 10px; overflow: hidden; }
.ig-style input { position: absolute; opacity: 0; pointer-events: none; }
.ig-style img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.ig-style-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 5px; text-align: center;
  color: #fff; font-size: 12px; font-weight: 700;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  text-shadow: 0 0 4px rgba(0,0,0,.5);
}
.ig-style::after {
  content: ""; position: absolute; inset: 0; border-radius: 10px; pointer-events: none;
  border: 2px solid transparent;
}
.ig-style:has(input:checked)::after { border-color: var(--accent); }
.ig-style:has(input:checked)::before {
  content: "✓"; position: absolute; top: 6px; left: 6px; z-index: 1;
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 12px; line-height: 20px; text-align: center;
}
.ig-style:has(input:focus-visible)::after { border-color: var(--accent); }

/* 画像変換: シード画像の選択グリッド(2026-08-16。ig-style と同じ
 * :has(input:checked) 方式。JS無効でも選べるラジオ) */
.ig-seed-lead { margin-top: 10px; }
.ig-seed-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.ig-seed { position: relative; cursor: pointer; border-radius: 8px; overflow: hidden; }
.ig-seed input { position: absolute; opacity: 0; pointer-events: none; }
.ig-seed img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.ig-seed::after {
  content: ""; position: absolute; inset: 0; border-radius: 8px; pointer-events: none;
  border: 2px solid transparent;
}
.ig-seed:has(input:checked)::after { border-color: var(--accent); }
.ig-seed:has(input:checked)::before {
  content: "✓"; position: absolute; top: 4px; left: 4px; z-index: 1;
  width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center;
}
.ig-seed:has(input:focus-visible)::after { border-color: var(--accent); }
.ig-seed-none {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
/* 選択中シードの拡大プレビュー(右パネル) */
.ig-seed-preview { margin-bottom: 20px; }
.ig-seed-preview h2 { font-size: 16px; margin: 0 0 10px; }
.ig-seed-preview a[href] { cursor: zoom-in; }
.ig-seed-preview img {
  display: block; max-width: min(420px, 100%); border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

.ig-submit {
  width: 100%; padding: 12px; font-size: 15px; font-weight: 700;
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.ig-submit:hover { background: var(--accent); opacity: .9; }
.ig-gold { font-weight: 700; }
.ig-note { margin-top: 8px; }
/* 画像生成モデルの選択(テスト段階。SPEC §18 2026-08-25)。フォーム・
 * モーダル・ルーム設定パネルで共用。補足文は select の直下に小さく */
.ig-model-select { width: 100%; max-width: 100%; font-size: 13px; }
.ig-model-desc { margin: 6px 0 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.ig-model-desc:empty { display: none; }

.ig-result {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 24px;
}
.ig-result-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.ig-result-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.ig-result-item img {
  display: block; width: 100%; max-height: 70vh; object-fit: contain;
  border-radius: 10px; border: 1px solid var(--line); background: #fff;
}
/* 背景削除の結果: 透過部分が分かるよう市松模様の下地に載せる */
.ig-result-item.ig-checker img {
  background: repeating-conic-gradient(#e6e6ea 0% 25%, #fff 0% 50%) 0 0 / 24px 24px;
}
.ig-result-meta { margin: 10px 0 0; }

.ig-templates h2 { font-size: 17px; margin: 0 0 4px; }
.ig-template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.ig-template {
  display: flex; flex-direction: column; text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; transition: transform .15s;
}
.ig-template:hover { transform: scale(1.01); }
.ig-template-thumb { position: relative; }
.ig-template-thumb img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.ig-template-badge {
  position: absolute; top: 8px; left: 8px; padding: 2px 10px; border-radius: 999px;
  background: #fff; border: 1px solid var(--accent); color: var(--accent);
  font-size: 12px; font-weight: 700;
}
.ig-template-body { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; }
.ig-template-name { font-weight: 700; font-size: 14px; }
.ig-template-desc {
  color: var(--muted); font-size: 13px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.ig-box-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.ig-box-item {
  margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden;
}
.ig-box-item > a { display: block; }
.ig-box-item img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.ig-box-item figcaption {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px;
}
.ig-box-meta { color: var(--muted); font-size: 12px; }
.ig-box-delete { margin: 0; }

/* 保存一覧のフォルダ(2026-08-16。kyarapu マイボックス「フォルダ」の簡易版) */
.ig-folder-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ig-folder-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
  text-decoration: none; color: var(--ink); font-size: 13px; font-weight: 600;
}
.ig-folder-chip:hover { border-color: #c5c5d2; }
.ig-folder-chip.active { border-color: var(--accent); color: var(--accent); background: #fdf1f4; }
.ig-folder-count { color: var(--muted); font-weight: 600; font-size: 12px; }
.ig-folder-chip.active .ig-folder-count { color: inherit; }
.ig-folder-manage { margin-bottom: 16px; }
.ig-folder-manage summary {
  cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600;
  width: fit-content;
}
.ig-folder-manage-body {
  margin-top: 10px; padding: 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
}
.ig-folder-form { display: flex; gap: 6px; margin: 0; align-items: center; }
.ig-folder-form input[type="text"] { width: 220px; }
.ig-folder-form .btn { white-space: nowrap; }
.ig-folder-row { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.ig-folder-manage-body .hint { margin: 10px 0 0; }
/* 画像カード下段の移動フォーム */
.ig-box-move {
  display: flex; gap: 6px; align-items: center; margin: 0;
  padding: 0 10px 10px; border-top: 0;
}
.ig-box-move select { flex: 1; min-width: 0; font-size: 13px; padding: 4px 6px; }
.ig-box-move .btn { white-space: nowrap; }

@media (max-width: 1100px) {
  .ig-layout { grid-template-columns: 1fr; }
  .ig-form { position: static; }
  .ig-template-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .ig-template-grid { grid-template-columns: 1fr; }
}

/* 管理: 画像生成ログの画像グリッド */
.admin-img-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-img-grid img {
  display: block; width: 180px; height: 180px; object-fit: cover;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}

/* 画像生成ページの追修正(2026-08-13 ユーザー実機確認の指摘) */
/* 作業領域が狭い → このページだけ本文の最大幅を広げる */
main:has(.ig-tabs) { max-width: 1280px; }
/* 保存一覧: カードを横長に(削除ボタンの「削/除」縦割れも幅で解消) */
.ig-box-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.ig-box-item img { aspect-ratio: 4 / 3; }
.ig-box-delete .btn { white-space: nowrap; }
/* 生成中オーバーレイ(app.js が送信時に生成) */
.ig-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex;
  align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .7); backdrop-filter: blur(2px);
}
.ig-overlay-box {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 40px; box-shadow: 0 8px 32px rgba(0,0,0,.12);
  font-weight: 700; font-size: 15px;
}
.ig-overlay-sub { color: var(--muted); font-size: 13px; font-weight: 400; }
.ig-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid #f3d3da; border-top-color: var(--accent);
  animation: ig-spin 1s linear infinite;
}
@keyframes ig-spin { to { transform: rotate(360deg); } }

/* 管理: 削除済み生成画像の表示(半透明+ラベル) */
.admin-img-item { margin: 0; position: relative; }
.admin-img-item.deleted img { opacity: .45; }
.admin-img-item.deleted figcaption {
  position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 999px;
  background: rgba(28,28,32,.75); color: #fff; font-size: 12px;
}

/* ============ キャラ作成: プロフィール画像の画像作成/保存一覧モーダル
   (2026-08-14 ユーザー要望。kyarapu の「画像作成」モーダルの簡易版) ============ */

/* アバター欄のボタン列(JS有効時のみ app.js が hidden を外す) */
.avatar-pick { display: flex; gap: 8px; margin: 4px 0 10px; }
/* display:flex を当てた要素は hidden 属性(UAの display:none)が
 * 上書きされてしまうため、[hidden] を明示的に勝たせる */
.avatar-pick[hidden], .avatar-gen-preview[hidden], .igm-overlay[hidden] { display: none; }

/* チャット中の画像=立ち絵 第2段(§21-4 2026-08-27)。最大6枠のグリッド。
 * 枠ごとに サムネ+ラベル+ファイル選択+モーダルのボタン+削除。モーダルは
 * プロフィール画像と共用で、開いた枠を app.js が覚えて hidden に入れる */
.portrait-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px; margin: 6px 0 10px;
}
.portrait-slot {
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  padding: 10px; display: flex; flex-direction: column; gap: 6px;
}
.portrait-slot.is-deleting { opacity: .45; }
.portrait-slot[hidden], #portrait-add[hidden] { display: none; }   /* display:flex より hidden を勝たせる */
.portrait-slot-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }
.portrait-slot-thumb {
  display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: contain;
  background: #f0f0f4; border-radius: 6px;
}
.portrait-slot-thumb[hidden] { display: none; }
.portrait-slot input[type="text"] { width: 100%; }
.portrait-slot input[type="file"] { font-size: 12px; }
.portrait-slot .avatar-pick { margin: 0; }
.portrait-slot .portrait-pending { font-size: 12px; color: #b35c00; margin: 0; }
.portrait-slot label.portrait-del { font-size: 12px; color: var(--muted); display: flex; gap: 4px; align-items: center; }

/* モーダル: 「プロフィール画像を参考にする」チェック(2026-08-27) */
.igm-ref-label { display: flex; align-items: center; gap: 8px; font-weight: bold; cursor: pointer; }
.igm-ref-label input { width: auto; margin: 0; }

/* 生成画像を選択中のプレビュー */
.avatar-gen-preview {
  display: flex; align-items: center; gap: 12px; margin: 4px 0 10px;
  padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.avatar-gen-preview img {
  display: block; max-height: 120px; max-width: 120px; border-radius: 6px;
}
.avatar-gen-preview .desc { margin: 0 0 6px; }

dialog.ig-modal {
  border: none; border-radius: 16px; padding: 0;
  width: min(720px, calc(100vw - 32px));
  box-shadow: 0 12px 48px rgba(0,0,0,.25);
}
dialog.ig-modal::backdrop { background: rgba(0,0,0,.45); }
.igm-wrap { position: relative; display: flex; flex-direction: column; max-height: calc(100vh - 96px); }
.igm-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 0;
}
.igm-head h3 { margin: 0; font-size: 17px; }
.igm-close {
  border: none; background: none; cursor: pointer; font-size: 20px; line-height: 1;
  color: var(--muted); padding: 4px 8px; border-radius: 8px;
}
.igm-close:hover { background: #f0f0f4; color: var(--ink); }
.igm-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); padding: 0 18px; }
.igm-tab {
  border: none; background: none; cursor: pointer;
  padding: 10px 14px; font-size: 14px; font-weight: 700; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.igm-tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.igm-body { overflow-y: auto; padding: 16px 18px; overscroll-behavior: contain; }
/* モーダルを開いている間は後ろのページをスクロールさせない(2026-08-27 ユーザー要望:
 * ホイールがヘッダ・タブ・フッタの上にあるときや、本文の端まで来たときに後ろの
 * ページが動いていた)。本文側は overscroll-behavior で連鎖も止める */
body:has(dialog.ig-modal[open]), body.modal-open { overflow: hidden; }
.igm-body .field { margin-bottom: 14px; }
/* モーダル内のスタイル見本は小さめ6列(狭い画面では3列) */
.ig-modal .ig-styles { grid-template-columns: repeat(6, 1fr); }
.ig-modal .ig-style img { aspect-ratio: 3 / 4; }
@media (max-width: 640px) {
  .ig-modal .ig-styles { grid-template-columns: repeat(3, 1fr); }
}

/* 選択できる画像グリッド(生成結果・保存一覧の両タブで共用) */
.igm-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px;
}
.igm-item { position: relative; cursor: pointer; border-radius: 10px; overflow: hidden; padding: 0; border: none; background: none; }
.igm-item img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: #f0f0f4; }
.igm-item::after {
  content: ""; position: absolute; inset: 0; border-radius: 10px; pointer-events: none;
  border: 2px solid transparent;
}
.igm-item:hover::after { border-color: #c5c5d2; }
.igm-item.selected::after { border-color: var(--accent); }
.igm-item.selected::before {
  content: "✓"; position: absolute; top: 6px; left: 6px; z-index: 1;
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 12px; line-height: 20px; text-align: center;
}
.igm-item:focus-visible::after { border-color: var(--accent); }

.igm-result-head { font-weight: 700; font-size: 14px; margin: 4px 0 8px; }
.igm-msg { margin: 8px 0 0; }
.igm-msg.error { color: var(--danger, #c0392b); }
.igm-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.igm-foot .spacer { flex: 1; }
.igm-use[disabled] { opacity: .5; cursor: default; }

/* モーダル内の生成中オーバーレイ(dialog はトップレイヤーに描画されるため、
 * ページ全体用の .ig-overlay ではなくモーダル内に absolute で重ねる) */
.igm-overlay {
  position: absolute; inset: 0; z-index: 5; display: flex;
  align-items: center; justify-content: center; border-radius: 16px;
  background: rgba(255, 255, 255, .75); backdrop-filter: blur(2px);
}

/* モーダル内の拡大表示(2026-08-14 ユーザー要望: クリックで選択+大きく表示)。
 * 生成中オーバーレイと同じくモーダル内に absolute で重ねる */
.igm-lightbox {
  position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(20, 20, 24, .82); border-radius: 16px; padding: 20px;
  cursor: zoom-out;   /* 画像の外はどこを押しても閉じる */
}
.igm-lightbox[hidden] { display: none; }
.igm-lightbox img {
  max-width: 100%; max-height: calc(100% - 64px);
  border-radius: 10px; box-shadow: 0 8px 32px rgba(0,0,0,.4);
  cursor: default; background: #fff;
}
.igm-lightbox-actions { display: flex; gap: 10px; }
/* フォーム側の選択中プレビュー: 原寸表示への導線であることを示す */
.avatar-gen-preview a { display: block; cursor: zoom-in; }

/* ---------- キャンペーン詳細の仮ページ(campaign.php。2026-08-16 要望) ---------- */

.campaign-hero { margin: 0 0 18px; }
.campaign-hero img {
  display: block; width: 100%; max-height: 280px; object-fit: cover;
  border-radius: 14px; box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
}
.campaign-body {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 26px; max-width: 760px;
}
.campaign-body section { margin: 0 0 22px; }
.campaign-body section:last-child { margin-bottom: 0; }
.campaign-body h2 {
  font-size: 16px; margin: 0 0 8px; padding-left: 10px;
  border-left: 4px solid var(--accent);
}
.campaign-body p, .campaign-body li { margin: 0 0 6px; color: var(--ink); }
.campaign-body ul, .campaign-body ol { margin: 0; padding-left: 22px; }
.campaign-back { margin: 18px 0 0; }
.campaign-back a { color: var(--muted); text-decoration: none; }
.campaign-back a:hover { text-decoration: underline; }

/* ---------- レーティング(SPEC §13。2026-08-18 マチュアモード第1弾) ---------- */

/* センシティブバッジ(キャラカード・検索結果・chat_start・チャットヘッダ・
 * 履歴レール・表示設定。SPEC §13-5) */
.badge-sensitive {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #fdeef1;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 11px;
  font-weight: bold;
  line-height: 1.6;
  vertical-align: middle;
  white-space: nowrap;
}
.badge-mini { font-size: 10px; padding: 0 6px; }
.history-rail .badge-sensitive { margin-top: 2px; }

/* 年齢確認インタースティシャル(SPEC §13-4) */
.sensitive-gate { max-width: 560px; margin: 40px auto; }
.sensitive-gate-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px 24px;
  text-align: center;
}
.sensitive-gate-box h1 { margin: 8px 0 12px; font-size: 20px; }
.sensitive-gate-badge { margin: 0; }
.sensitive-gate-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
}

/* ============================================================
 * フィードバック(2026-08-19 ユーザー要望。テスター公開に向けて)
 * サイドバーの未読カウント / 一覧の未読強調 / スレッドの吹き出し
 * ============================================================ */

/* サイドバーの未読件数(「予定」バッジと同じ位置に出す赤丸) */
.side-count {
  flex-shrink: 0;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: bold;
  line-height: 18px;
  text-align: center;
}

/* 管理サイドバーのメニューに出す未読件数(横並びに畳んだときも同じ) */
.admin-count {
  display: inline-block;
  margin-left: 6px;
  min-width: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: bold;
  line-height: 16px;
  text-align: center;
}

/* 未読の行・カード(公開側の一覧と管理側のテーブルで共用) */
.fb-unread { background: #fff7f8; }
tr.fb-unread > td { background: #fff7f8; }
.fb-dot { color: var(--accent); font-size: 10px; vertical-align: middle; }
/* 目で見える印(色・形)に読み上げ用の文言を添えるための共通クラス。
 * 画面には出さないがスクリーンリーダーは読む(display:none だと読まれない)。
 * codexレビュー任意3 2026-08-21 */
.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;
}
/* 1文字ずつ表示(§19)が吹き出しの前に挿す読み上げ用の全文。位置を文書の左上に
 * 固定する — 2026-08-27 ユーザー報告: 会話が長いと、この absolute 要素が
 * メッセージ欄(内側スクロール)の外=「本来の位置」に置かれてページの高さを
 * 一時的に伸ばし、演出の末尾追随で window ごと下へ送られて会話と入力欄が
 * 画面外に出ていた(演出終了で要素が消えると戻る)。読み上げ順は DOM 順のまま */
.msg .sr-only { top: 0; left: 0; }

/* 種別タグ */
.fb-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}

/* ステータス。未対応=強め、対応中=中間、対応済み=淡く */
.fb-status {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: bold;
  border: 1px solid transparent;
}
.fb-status-open        { background: #fdeef1; border-color: var(--accent); color: var(--accent); }
.fb-status-in_progress { background: #fff5e6; border-color: #d08a2c;       color: #a2661c; }
.fb-status-resolved    { background: #eef4ee; border-color: #7fa77f;       color: #4f7250; }

/* 一覧のカード全体をクリック領域にする(件名リンクだけでは的が小さい。
 * ユーザー要望 2026-08-20 第6回)。中に他のリンク・ボタンを入れないこと */
/* .card-link は同じ作りの汎用版(チャット開始ページの「これまでのチャット」。
 * 課題メモ③ 2026-08-27)。どちらもカード全体が <a> なので中にリンク・ボタンを置かない */
.fb-card, .card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.fb-card:hover, .card-link:hover { background: #f2f2f7; border-color: #c9c9d6; }
.fb-card.fb-unread:hover { background: #ffeef1; }
.fb-card:focus-visible, .card-link:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
/* 右端の「開く ›」は装飾(ボタンではない)。カード全体が押せることの手がかり */
.card-link-cue { font-size: 12px; font-weight: normal; color: var(--accent); white-space: nowrap; }
/* 件名は本文色で少し大きく(見出しとして読ませる。下線は出さない) */
.fb-card-subject { color: var(--ink); font-size: 15px; }

/* スレッドの発言。ユーザー=左寄せの白、運営=薄い色を敷いて区別する */
.fb-msg {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--panel);
}
.fb-msg-admin { background: #f3f5fb; border-color: #c9d2e8; }
.fb-msg-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 0 0 6px;
  font-size: 13px;
}
.fb-msg-head .desc { margin: 0; font-size: 12px; }
.fb-msg-body { margin: 0; line-height: 1.7; word-break: break-word; }

/* ---------- お知らせページ(notices.php。2026-08-21) ---------- */
/* ベルのパネル(.notice-item)とは別物 — パネルは幅340pxの覗き窓、
 * こちらは本文ページなので1件をカードとして読ませる */
.notice-row {
  border: 1px solid var(--line); border-radius: 6px;
  padding: 14px; margin-bottom: 12px; background: #fafafc;
}
.notice-row-unread { background: #fff6f8; border-color: #f3c2cd; }
.notice-row-title { font-weight: bold; margin: 0 0 6px; }
.notice-row-body {
  margin: 0; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.notice-row-meta { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.notice-row-meta a { color: var(--accent); }
/* ベルのパネル末尾から一覧ページへ渡す導線 */
.notice-panel-more {
  display: block; text-align: center; font-size: 13px;
  padding: 10px 0 2px; border-top: 1px solid var(--line); color: var(--accent);
}

/* システム更新履歴(2026-08-21。notices.php の「更新履歴」タブ)。
   同じ更新日の項目を日付見出しでまとめて出す */
.chlog-date {
  font-weight: bold; font-size: 14px; color: var(--muted);
  margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.chlog-date:first-of-type { margin-top: 4px; }
.chlog-item { margin: 0 0 10px; padding: 0 0 0 2px; }
.chlog-item-title { margin: 0; line-height: 1.7; word-break: break-word; }
.chlog-item-body {
  margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
/* 区分バッジ。文字色で区別し、面は薄く敷くだけに留める */
.chlog-tag {
  display: inline-block; margin-right: 8px; padding: 1px 8px;
  border-radius: 999px; font-size: 12px; font-weight: bold;
  border: 1px solid var(--line); background: #f2f2f6; color: var(--muted);
  vertical-align: 2px;
}
.chlog-tag-added    { background: #fdeef1; border-color: #f3c2cd; color: #b3374d; }
.chlog-tag-improved { background: #eef3fd; border-color: #c2d1f3; color: #37518f; }
.chlog-tag-fixed    { background: #eef8f0; border-color: #bfe0c8; color: #2f6b41; }

/* 設定ハブ(2026-08-21。settings.php)。左に現在の状態、右に移動ボタン。
   狭い画面では縦積みにする */
.set-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.set-item .set-state { flex: 1 1 260px; min-width: 0; }
.set-item .set-state p { margin: 0 0 4px; word-break: break-word; }
.set-item .set-state p:last-child { margin-bottom: 0; }
.set-item form { margin: 0; }

/* ---------- 管理: モデレーション(確認中の画像。SPEC §20 2026-08-26) ---------- */
.mod-review-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-bottom: 24px; }
.mod-review-card {
  display: flex; gap: 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px;
}
.mod-review-card img {
  width: 120px; height: 180px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); background: #e6e6ec; display: block;
}
.mod-review-body { flex: 1; min-width: 0; }
.mod-review-body p { margin: 0 0 4px; }
.mod-review-title { font-weight: bold; }
.mod-review-actions { display: flex; gap: 8px; margin-top: 8px; }
.mod-review-actions form { margin: 0; }
.btn-danger { background: #b42318; border-color: #b42318; color: #fff; }
.btn-danger:hover { background: #8c1a2c; }

/* ==========================================================================
 * スマホ表示(SPEC §23。2026-08-28 作り直し)
 * --------------------------------------------------------------------------
 * 方針(ユーザー決定): PC は従来UIのみ / 800px 以下はこの節の枠のみ / 切替
 * 設定は持たない。801px 以上には一切効かせない(全て max-width: 800px の中)。
 *  ・共通の枠: 上部バー(サイト名+右端にベル)+下部メニュー5つ(いずれも
 *    position: fixed)。本文は通常のページスクロールで、上下の固定分は
 *    main の padding で空ける。iPhone のノッチ/ホームバーは safe-area で逃がす
 *  ・チャット画面(body.on-chat): 上部バー・下部メニューは出さず、ヘッダを
 *    sticky の1本に、入力欄を画面下に固定する。キーボードの高さ(--kb)と
 *    入力欄の実測高(--chat-input-h)は app.js が書く(codex 要修正 2026-08-28:
 *    iOS Safari は bottom:0 だけではキーボードの裏に入る/scroll-padding では
 *    scrollTo の停止位置が変わらないので実体の padding が要る)
 *  ・通知・マイページ・ルーム設定の details パネルはスマホでは「シート」
 *    (画面下から全幅。背景は details 自身の ::before)。閉じるのは ✕ ボタン・
 *    背景タップ・Esc(app.js)。マイページのシートは上部バー右端のアイコン(summary)
 *    から開く(下部メニューにマイページは置かない=二重を避ける。08-28 夜)
 *  ・z の階層: 本文 < 固定バー/入力欄(--z-bar) < シート(--z-sheet=.top-actions
 *    と同じ 95) < 既存モーダル 100 < トースト 200
 * ========================================================================== */
:root {
  --z-bar: 80;
  --z-sheet: 95;
  --m-top-h: 48px;          /* 上部バーの内容高(safe-area は別に足す) */
  --m-tab-h: 56px;          /* 下部メニューの内容高 */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --kb: 0px;                /* キーボードの高さ。app.js が visualViewport から書く */
  --chat-input-h: 96px;     /* 固定入力欄の高さ。app.js が ResizeObserver で実測に置き換える */
}
/* スマホ専用の要素は PC では出さない(markup は常に描画している) */
.tab-bar, .sheet-head, .sheet-close, .chat-back, .m-only, .m-fb, .chat-bg,
.recent-row, .m-icon { display: none; }
/* 第3弾(§23-6 2026-09-06): .top-actions は上部バー .m-topbar の**中**に移した。PC ではヘッダの箱を
 * 作らず(display: contents)中身の .top-actions だけを従来どおり本文右上の fixed に残す。
 * 左側(.m-lead=‹・ページ名・文字タブ)は PC では出さない */
.m-topbar { display: contents; }
.m-topbar > .m-lead { display: none; }

@media (max-width: 800px) {
  /* ---- 共通の枠 ---- */
  .side-nav, .history-rail { display: none; }
  body.has-side { padding-left: 0; }
  body.has-rail main { margin-right: auto; }
  /* アンカーやフォーカス移動で固定バーの下に隠れないように(codex 推奨) */
  html {
    scroll-padding-top: calc(var(--m-top-h) + var(--sat) + 8px);
    scroll-padding-bottom: calc(var(--m-tab-h) + var(--sab) + 8px);
  }
  /* チャットでは下を覆うのは下部メニューではなく可変高の入力欄(codex 推奨3) */
  html:has(body.on-chat) { scroll-padding-bottom: calc(var(--chat-input-h) + var(--kb) + 8px); }
  .m-topbar {
    display: flex; align-items: center;
    position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-bar);
    height: calc(var(--m-top-h) + var(--sat)); padding: var(--sat) 14px 0;
    background: var(--panel); border-bottom: 1px solid var(--line);
  }
  .m-title { font-weight: bold; font-size: 18px; text-decoration: none; color: var(--ink); }
  /* 右上アイコン群(ベル・チャージ・マイページ)は上部バーの右端に重ねて
   * **常に出す**(08-28 実機確認でのユーザー要望。当初はベルだけにして
   * チャージ・マイページをシート/下部メニューへ回していた)。マイページの
   * アイコン(summary)はそのままシートを開く(下部メニューには置かない) */
  .top-actions {
    position: fixed; top: calc(var(--sat) + 4px); right: 4px; z-index: var(--z-sheet);
    gap: 0; padding: 0;
  }
  /* PC の「履歴レールの左隣」の右寄せ量(body.has-rail)はスマホでは打ち消す
   * (08-28 夜 ユーザー指摘「右端に寄せた方が見ばえがよい」= これが 100px 空けていた) */
  body.has-rail .top-actions { right: 4px; }
  .top-actions .top-action { border-color: transparent; box-shadow: none; background: transparent; opacity: 1; }
  /* 検索欄は検索ページ(body.on-search)だけ、上部バーの直下に全幅で出す
   * (他のページは下部メニューの「検索」から。展開/折りたたみの状態を持たない) */
  .top-search { display: none; }
  body.on-search .top-search {
    display: flex; position: fixed; left: 0; right: 0; z-index: var(--z-bar);
    top: calc(var(--m-top-h) + var(--sat)); height: 44px;
    border: none; border-bottom: 1px solid var(--line); border-radius: 0;
    box-shadow: none; padding: 0 8px 0 14px;
  }
  body.on-search .top-search input[type="search"] { width: auto; flex: 1; font-size: 16px; }
  main {
    max-width: none;
    padding: calc(var(--m-top-h) + var(--sat) + 16px) 16px 24px;
  }
  body.on-search main { padding-top: calc(var(--m-top-h) + var(--sat) + 44px + 16px); }
  .site-footer { padding-bottom: calc(20px + var(--m-tab-h) + var(--sab)); }
  /* iOS はフォントが 16px 未満の入力欄にフォーカスすると画面を拡大する */
  input[type="text"], input[type="search"], input[type="password"], input[type="number"],
  select, textarea { font-size: 16px; }
  .cp-toast { bottom: calc(var(--m-tab-h) + var(--sab) + 16px); }

  /* 通知パネル: 上部バー直下の全幅ドロップダウン */
  .notice-panel {
    position: fixed; left: 0; right: 0; top: calc(var(--m-top-h) + var(--sat));
    width: auto; max-width: none; border-radius: 0 0 12px 12px;
    max-height: calc(100vh - var(--m-top-h) - var(--sat) - var(--m-tab-h) - var(--sab) - 16px);
  }

  /* ---- 下部メニュー ---- */
  .tab-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-bar);
    height: calc(var(--m-tab-h) + var(--sab)); padding-bottom: var(--sab);
    background: var(--panel); border-top: 1px solid var(--line);
  }
  .tab-link {
    flex: 1; min-width: 0; position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: 10px; line-height: 1.2;
  }
  /* 5つ並ぶと「フィードバック」が長い。文字は1行で収め、はみ出しは省略 */
  .tab-link span:first-of-type { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* アイコンはマスク方式: 黒一色の線画(assets/icons/tab/)を mask-image に敷き、
   * currentColor で塗る。未選択=文字と同じグレー、選択中=アクセント。
   * mask-image は layout.php が **inline style で直接**渡す(カスタムプロパティ経由は
   * WebKit が url() を style.css 基準で解決して 404 になった。08-28 夜)。ここは
   * ロングハンドだけ書く(ショートハンド mask: は mask-image を none に戻してしまう) */
  .m-icon {
    display: block; width: 26px; height: 26px; background: currentColor;
    -webkit-mask-size: contain; -webkit-mask-position: center; -webkit-mask-repeat: no-repeat;
    mask-size: contain; mask-position: center; mask-repeat: no-repeat;
  }
  .tab-link .m-icon { width: 26px; height: 26px; }
  .tab-link[aria-current="page"] { color: var(--accent); font-weight: bold; }
  /* 上部バーの3つ(ベル・チャージ・マイページ)も同じセットに揃える。PC 用の <img> は消す */
  .top-actions .top-action img { display: none; }
  .top-actions .top-action .m-icon { width: 24px; height: 24px; color: var(--ink); }
  .top-actions .notice-menu[open] > summary .m-icon,
  .top-actions .mypage-menu[open] > summary .m-icon { color: var(--accent); }
  .tab-count {
    position: absolute; top: 4px; left: calc(50% + 6px);
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--accent); color: var(--accent-ink); border: 2px solid #fff;
    font-size: 11px; font-weight: bold; line-height: 14px; text-align: center; white-space: nowrap;
  }

  /* ---- シート(通知以外の details パネル。画面下から全幅) ---- */
  .sheet-head {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 1; background: var(--panel);
    padding: 12px 0; margin-bottom: 8px; border-bottom: 1px solid var(--line);
    font-weight: bold; font-size: 15px;
  }
  .sheet-close {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid var(--line); background: var(--panel); color: var(--ink);
    font-size: 15px; line-height: 1; cursor: pointer; padding: 0;
  }
  .m-only { display: block; }
  .m-fb { display: flex; }
  /* 背景は details 自身の ::before(クリックの target が details になるので
   * app.js が「details そのものを押した=背景」と判定して閉じる) */
  .mypage-menu[open]::before, .room-menu[open]::before {
    content: ''; position: fixed; inset: 0; z-index: 0;
    background: rgba(20, 20, 24, .38);
  }
  .mypage-panel, .room-panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 1;
    width: auto; max-width: none; border-radius: 16px 16px 0 0; border-bottom: none;
    max-height: calc(100vh - var(--m-top-h) - var(--sat));
    max-height: calc(100dvh - var(--m-top-h) - var(--sat));
    padding-bottom: calc(16px + var(--sab));
    animation: sheet-up .2s ease-out;
  }
  .mypage-panel { padding-top: 0; }
  .room-panel-title {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 1; background: var(--panel);
  }

  /* ---- チャット画面 ---- */
  body.on-chat .m-topbar, body.on-chat .tab-bar, body.on-chat .top-actions,
  body.on-chat .site-footer { display: none; }
  body.on-chat { overflow: auto; }
  body.on-chat main {
    display: block; height: auto; overflow: visible; max-width: none;
    /* 下余白は固定入力欄の実測高+キーボード分(codex 要修正: scroll-padding では
     * window.scrollTo の停止位置が変わらない) */
    padding: 0 12px calc(var(--chat-input-h) + var(--kb) + 12px);
  }
  .chat-wrap { display: block; }
  .chat-wrap > .messages { overflow: visible; min-height: 0; padding-right: 0; }
  .chat-head {
    position: sticky; top: 0; z-index: var(--z-sheet);
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px;
    margin: 0 -12px 12px; padding: calc(var(--sat) + 4px) 8px 4px 2px;
    border: none; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none;
  }
  .chat-back {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
    color: var(--ink); text-decoration: none; font-size: 30px; line-height: 1; padding-bottom: 4px;
  }
  .chat-head-title { display: block; min-width: 0; }
  .chat-head-title .name, .chat-head-title .meta { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chat-head-title .name { font-size: 16px; min-width: 0; }
  .chat-head-title .meta { font-size: 12px; }
  .chat-head-actions { gap: 4px; }
  .chat-head-actions > .btn { display: none; }         /* 別のチャット → ルーム設定のシート */
  .chat-quality select { max-width: 120px; padding: 4px 2px; font-size: 16px; }   /* 16px = iOS の自動ズーム回避 */
  .room-menu > summary { width: 34px; height: 34px; }
  .chat-input {
    position: fixed; left: 0; right: 0; bottom: var(--kb); z-index: var(--z-bar);
    border-radius: 0; border-left: none; border-right: none; border-bottom: none;
    padding: 8px 10px calc(8px + var(--sab));
    /* おすすめ回答(初回)で高くなりすぎたら内側でスクロール(codex 要修正) */
    max-height: 60vh; max-height: 60dvh; overflow-y: auto;
  }
  .chat-input .suggestions { max-height: 26vh; overflow-y: auto; }
  .chat-wrap > .chat-tools { flex-wrap: wrap; }
  .msg.user > div { max-width: 90%; }
  .msg .scene-image { max-width: 100%; }
}
@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .mypage-panel, .room-panel { animation: none; }
}

/* ---- スマホ表示 第2弾(SPEC §23-5。2026-08-28 夜。各ページの細部) ---- */
@media (max-width: 800px) {
  /* 検索ページのタブは3等分・中央寄せ(課題メモ⑱。2026-08-30)。
   * PC の padding 28px×2×3 は狭い画面に入りきらず flex の縮小で折れていた */
  .search-tabs { gap: 0; }
  .search-tab { flex: 1 1 0; min-width: 0; padding: 10px 4px; text-align: center; }
  /* トップ・検索結果・項目のカードは2列(1列だと1画面に1体しか入らない) */
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-body { padding: 8px 10px; }
  .card-name { font-size: 14px; }
  .card-desc {
    font-size: 12px; line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .card-meta { font-size: 11px; margin-top: 6px; }
  .card-tags .tag-chip { font-size: 11px; padding: 0 7px; }
  .card-actions { padding: 0 10px 10px; flex-direction: column; gap: 6px; }
  .card-actions .btn { font-size: 13px; padding: 5px 6px; }
  .card-rank { min-width: 24px; height: 24px; font-size: 12px; }
  /* 横一列(カルーセル)も2枚+次の端が少し見える幅 */
  .carousel-track { gap: 10px; }
  .carousel-track > .card { flex-basis: calc((100% - 10px) / 2 - 12px); }
  .home-section-head h2 { font-size: 16px; }
  .home-create { margin-bottom: 14px; }
  .home-create .btn { display: block; min-width: 0; width: 100%; }
  /* 最近のチャット(index.php。PC の右レールの丸を横一列に倒したもの) */
  .recent-row { display: block; margin: 0 -16px 14px; padding: 0 16px; }
  .recent-row-title { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
  .recent-row-track {
    display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none;
    margin: 0 -16px; padding: 2px 16px 6px; -webkit-overflow-scrolling: touch;
  }
  .recent-row-track::-webkit-scrollbar { display: none; }
  .recent-row .recent-char { width: 64px; flex-shrink: 0; }
  .recent-row .recent-char-thumb { width: 56px; height: 56px; }
  .recent-row .recent-char-name { font-size: 11px; max-width: 64px; }
  .recent-row .badge-mini { font-size: 9px; }
  /* バナー下の「トップ」「ランキング」「#タグ」は折り返さず1行で横スライド
   * (08-28 夜 ユーザー要望。下部メニューと同じ手触り) */
  .home-tabs {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin: 0 -16px 16px; padding: 0 16px;
  }
  .home-tabs::-webkit-scrollbar { display: none; }
  .home-tab { flex-shrink: 0; padding: 8px 12px; }

  /* ヘッダの丸い立ち絵は出さない(基底の .chat-portrait { display: none } のまま。
   * 08-28 夜に 64px の丸を試したが「左上+背景でくどい」で背景方式に一本化=
   * codex 任意3 で丸の CSS は削除。履歴は git log) */
  /* 背景方式(08-28 夜 ユーザー決定): 全身の画像を吹き出しの後ろに大きく薄く敷く。
   * 範囲はヘッダの下〜入力欄の上(キーボード分も避ける)。右寄せ・下揃え。
   * z-index: -1 = 本文(通常フロー)の下・body の背景の上。吹き出しは不透明
   * (AI=白・自分=黒)なので本文は読める。濃さは opacity の1か所で調整
   * (薄すぎ/濃すぎは実機で詰める)。pointer-events: none で操作を邪魔しない */
  body.on-chat .chat-bg {
    display: flex; justify-content: flex-end; align-items: flex-end;
    position: fixed; z-index: -1; pointer-events: none;
    top: calc(var(--sat) + 52px); right: 0; left: 0;   /* ヘッダ(名前2段)の下から */
    bottom: calc(var(--chat-input-h) + var(--kb));
    padding: 8px 0 0;
  }
  body.on-chat .chat-bg img {
    display: block; height: 100%; width: auto; max-width: 100%;
    object-fit: contain; object-position: right bottom; opacity: .5;
  }
  /* 吹き出しを半透明にして背景の立ち絵を透かす(08-28 夜 ユーザー要望「吹き出しに
   * 隠れて見づらい」)。数値は読みやすさとの兼ね合い= AI 白 72% / 自分 黒 82% /
   * 立ち絵 50% から。薄い文字(*動作*)は背景に溶けやすいので少し濃くする。
   * PC の吹き出しは不透明のまま */
  body.on-chat .msg.assistant .bubble { background: rgba(255, 255, 255, .72); }
  body.on-chat .msg.user .bubble { background: rgba(47, 47, 56, .82); }
  body.on-chat .msg.assistant .bubble em { color: #3e3e48; }
  body.on-chat .msg .speaker { text-shadow: 0 0 6px rgba(255, 255, 255, .9); }
  body.on-chat .chat-fiction-note { text-shadow: 0 0 6px rgba(255, 255, 255, .9); }

  /* 見出し行: ボタンが名前と並ばないときは折り返す */
  .page-head { flex-wrap: wrap; gap: 8px 12px; margin-bottom: 14px; }
  h1 { font-size: 20px; }

  /* キャラ編集フォーム: タブは折り返さず横スクロール(5つ並ぶと2段に割れる) */
  .form-tabs {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin: 0 -16px 16px; padding: 0 16px;
  }
  .form-tabs::-webkit-scrollbar { display: none; }
  .form-tabs button { white-space: nowrap; flex-shrink: 0; padding: 10px 12px; }
  .form-section { padding: 14px 12px; margin-bottom: 14px; }
  /* チャット中の画像(立ち絵 §21-4)の枠は横スライドで**1枚ずつ**(次の端が少し
   * 見える幅。08-28 夜 ユーザー要望: 3列だと「ファイルを選択」が枠からはみ出た) */
  .portrait-grid {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px;
    margin: 6px -12px 10px; padding: 0 12px 6px; -webkit-overflow-scrolling: touch;
  }
  .portrait-slot { flex: 0 0 84%; scroll-snap-align: start; min-width: 0; }
  .portrait-slot[hidden] { display: none; }
  input[type="file"] { max-width: 100%; min-width: 0; }

  /* 画像生成ページ: タブは横スクロール、フォームは1列(1100px 以下で既に1列)、
   * 保存一覧は2列、モーダルは画面幅いっぱい */
  .ig-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .ig-tabs::-webkit-scrollbar { display: none; }
  .ig-tab { white-space: nowrap; flex-shrink: 0; }
  .ig-form { padding: 12px; }
  .ig-box-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .ig-box-item img { aspect-ratio: 1 / 1; }
  dialog.ig-modal { width: calc(100vw - 16px); max-width: none; }
  .igm-wrap { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
  .igm-foot { flex-wrap: wrap; padding: 10px 12px; }
}

/* ============================================================
 * PWA(SPEC §25。2026-08-30)
 * ホーム画面のアイコンから起動した standalone 表示(display-mode: standalone)では
 * ブラウザの戻るボタンが無いので、下部メニューのルート以外(body.is-sub)の
 * 上部バー左端に ‹ を出す。Safari のタブで開いたときと PC では出さない。
 * 見た目はチャットの .chat-back と揃える。
 * ============================================================ */
.m-back { display: none; }
@media (max-width: 800px) and (display-mode: standalone) {
  body.is-sub .m-back {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; margin: 0 2px 0 -12px; border-radius: 50%;
    color: var(--ink); text-decoration: none; font-size: 30px; line-height: 1; padding-bottom: 4px;
  }
}

/* 設定ページのボタン(2026-08-30 ユーザー要望「設定ページのボタンも分かりやすく」)。
 * ルーム設定パネル(.room-panel)と同じ淡い暖色。btn-primary は従来どおり */
.set-item .btn:not(.btn-primary) {
  background: #fff1e4; border-color: #f0c39a; color: #4a2e14;
}
.set-item .btn:not(.btn-primary):hover { background: #ffe4cc; border-color: #e6a96e; }
.set-item .btn[disabled] { opacity: .45; cursor: not-allowed; }
.set-item .btn[disabled]:hover { background: #fff1e4; border-color: #f0c39a; }

/* ============================================================
 * Google でログイン(SPEC §26。2026-08-30)
 * ログイン/登録画面の白ボタン+G のマーク(Google のブランド指針=白地・枠線)。
 * .login-google-note は standalone(ホーム画面のアイコンから起動)でだけ出す注意書き
 * ============================================================ */
.login-or {
  display: flex; align-items: center; gap: 10px; margin: 18px 0 12px;
  color: var(--muted); font-size: 13px;
}
.login-or::before, .login-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.login-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; box-sizing: border-box; padding: 11px 16px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  color: var(--ink); font-size: 15px; text-decoration: none;
}
.login-google:hover { background: #f7f8fa; border-color: #c7cdd8; }
.login-google svg { width: 20px; height: 20px; flex: none; }
.login-google-note { display: none; margin: 10px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
@media (display-mode: standalone) { .login-google-note { display: block; } }
.login-box .google-id {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: #f3f6ff;
  font-size: 14px; text-align: left; word-break: break-all;
}

/* ---------- 説明文の「詳しく」畳み(課題メモ⑪。2026-09-02) ----------
   長い説明文の続きを畳む共通部品。PC・スマホ共通で既定は閉(ユーザー決定 09-02)。
   markup: <details class="desc-more"><summary>詳しく</summary><p class="desc">…</p></details>
   JS 不要(ブラウザ標準の開閉)。状態・警告系の文言はこの部品に入れないこと */
/* チャットの形(§29)のラジオ行と、説明文の中の書き方の例 */
.radio-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 6px; }
.radio-row .radio-inline { font-weight: normal; display: inline-flex; align-items: center; gap: 4px; margin: 0; }
pre.example-block { white-space: pre-wrap; margin: 6px 0; padding: 8px 10px; background: rgba(0,0,0,.04); border-radius: 6px; font-family: inherit; }
details.desc-more { margin: 0 0 8px; }
details.desc-more > summary {
  display: inline-block; cursor: pointer; user-select: none; list-style: none;
  color: var(--muted); font-size: 12px; padding: 2px 8px 2px 0;
}
details.desc-more > summary::-webkit-details-marker { display: none; }
details.desc-more > summary::before { content: "▸ "; }
details.desc-more[open] > summary::before { content: "▾ "; }
details.desc-more > summary:hover { color: var(--ink); text-decoration: underline; }
details.desc-more > .desc { margin-top: 2px; }

/* ==========================================================================
 * スマホ表示 第3弾=Zeta 型(SPEC §23-6。2026-09-06。設計=docs/PLAN_mobile_zeta.md 第2版)
 * --------------------------------------------------------------------------
 *  ・対象は 800px 以下だけ。PC(801px 以上)は**追加した要素を display:none にする基底の
 *    数行**以外は触らない(直書き色の置換もこの節の @media の中で選択子ごとに上書きする=
 *    :root の既定値は不変。付録 A=PLAN_mobile_zeta.md)
 *  ・上部バー=1 本の flex 行(左 .m-lead=‹+ページ名 or ホーム/ランキングの文字タブ、
 *    右 .top-actions=🔍 🔔 🪙残高)。マイページのドロップダウンはスマホでは出さない
 *  ・下部メニュー 4 つ(ホーム/トーク/作成/マイページ)。作成は ⊕ の丸
 *  ・カード=3:4 カバー+左上 N・💬+名前 1 行+説明 2 行+タグ 1 行(先頭 3 つ)。ボタン・作成者は
 *    出さず、末尾の .card-link-m(スマホ専用の全面リンク)でカード全体タップ
 *  ・配色=黒地+紫(Zeta の実測に寄せた値)。color-scheme: dark はネイティブ部品用。
 *    **管理画面(body.admin)は対象外**=この節の規則は全て body:not(.admin) で限定(codex 要修正4。
 *    管理側は共用 CSS を読むが直書きの明色が多く、変数だけ暗くすると見出しが読めなくなる)
 * ========================================================================== */
/* PC では出さない(スマホ専用の要素。markup は常に描画) */
.card-badges, .card-link-m, .list-tabs, .banner-count, .m-tabs, .top-action.m-only-action,
.m-gold-num { display: none; }

/* ---- 新しいページの基本の見た目(PC・スマホ共通。トーク一覧・作成・マイページ) ---- */
.talk-list { display: flex; flex-direction: column; }
.talk-row {
  display: flex; gap: 12px; align-items: center; padding: 10px 6px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink);
}
.talk-row:hover { background: var(--panel); }
.talk-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.talk-thumb {
  width: 56px; height: 56px; border-radius: 12px; overflow: hidden; flex-shrink: 0;
  background: #e6e6ec; display: flex; align-items: center; justify-content: center;
}
.talk-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.talk-initial { font-size: 22px; color: var(--muted); }
.talk-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.talk-head { display: flex; align-items: baseline; gap: 8px; }
.talk-name { flex: 1; min-width: 0; font-weight: bold; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talk-room { font-weight: normal; font-size: 12px; color: var(--muted); }
.talk-when { flex-shrink: 0; font-size: 12px; color: var(--muted); }
.talk-last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talk-last-empty { font-style: italic; }

.create-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 24px; }
.create-action {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 18px 10px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); text-decoration: none; color: var(--ink); text-align: center;
}
.create-action:hover { border-color: var(--accent); }
.create-action-icon { font-size: 28px; line-height: 1; }
.create-action-label { font-weight: bold; font-size: 15px; }
.create-action-desc { font-size: 12px; color: var(--muted); }
.create-mine-title { border-bottom: none; margin: 0 0 6px; }

.mp-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; margin: 0 0 14px;
}
.mp-account-row { display: flex; align-items: center; gap: 12px; }
.mp-account-text { min-width: 0; display: flex; flex-direction: column; }
.mp-name { font-weight: bold; font-size: 16px; overflow-wrap: anywhere; }
.mp-id { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.mp-stats { color: var(--muted); font-size: 13px; margin: 12px 0; }
.mp-account-actions { display: flex; gap: 8px; }
.mp-account-actions .btn { flex: 1; text-align: center; }
.mp-gold { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mp-gold-text { display: flex; flex-direction: column; }
.mp-gold-label { color: var(--muted); font-size: 13px; }
.mp-gold-amount { font-size: 20px; font-weight: bold; }
.mp-gold-actions { display: flex; gap: 8px; }
.mp-menu { display: flex; flex-direction: column; margin: 0 0 20px; }
.mp-link {
  display: flex; align-items: center; gap: 10px; padding: 12px 6px;
  border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 15px;
}
.mp-link:hover { background: var(--panel); }
button.mp-link {
  width: 100%; background: none; border: none; border-bottom: 1px solid var(--line);
  cursor: pointer; font: inherit; font-size: 15px; text-align: left;
}
.mp-link-label { flex: 1; min-width: 0; }
.mp-logout { margin: 0; }
.mp-footer { color: var(--muted); font-size: 12px; padding: 8px 4px 20px; }
.mp-footer p { margin: 0 0 4px; overflow-wrap: anywhere; }
.mp-footer-site { font-weight: bold; font-size: 16px; color: var(--ink); }
.mp-footer a { color: var(--muted); }

@media (max-width: 800px) {
  /* ---- 配色(Zeta 型の暗色。:root の既定値=PC はこの @media の外で不変) ---- */
  body:not(.admin) {
    --bg: #121214; --panel: #1c1c20; --panel-2: #26262b;
    --ink: #f3f3f5; --muted: #a0a0aa; --line: #2e2e35;
    --accent: #7b5cff; --accent-ink: #ffffff; --tag: #b4a3ff;
    --user-bubble: #7b5cff; --char-bubble: #26262b;
    color-scheme: dark;
  }
  body:not(.admin) { background-image: none; }

  /* ---- 上部バー=1 本の flex 行 ---- */
  body:not(.admin) .m-topbar { display: flex; align-items: center; gap: 6px; padding: var(--sat) 6px 0 14px; }
  body:not(.admin) .m-topbar > .m-lead { display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0; }   /* 基底の > .m-lead {none} と同じ詳細度で勝たせる */
  body:not(.admin) .m-title {
    display: block; flex: 1 1 auto; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-weight: bold; font-size: 18px; color: var(--ink);
  }
  /* 文字タブは切替操作なので欠けさせない: 収まらなければ横スクロール(スクロールバーは出さない)。
   * ページ名(.m-title)の省略とは別扱い(codex 要修正3) */
  body:not(.admin) .m-tabs { display: flex; gap: 14px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  body:not(.admin) .m-tabs::-webkit-scrollbar { display: none; }
  body:not(.admin) .m-tab { font-size: 18px; font-weight: bold; color: var(--muted); text-decoration: none; white-space: nowrap; }
  body:not(.admin) .m-tab[aria-current="page"] { color: var(--ink); }
  body:not(.admin) .top-actions { position: static; flex: none; display: flex; align-items: center; gap: 0; }
  body:not(.admin).has-rail .top-actions { right: auto; }
  body:not(.admin) .top-action.m-only-action { display: flex; }
  body:not(.admin) .top-action.m-gold { width: auto; padding: 0 8px 0 4px; gap: 2px; text-decoration: none; }
  body:not(.admin) .top-actions .top-action.m-gold .m-icon { width: 20px; height: 20px; flex: none; }   /* 既存の .top-actions .top-action .m-icon(24px)に詳細度で勝たせる */
  body:not(.admin) .m-gold-num {
    display: inline; font-size: 13px; font-weight: bold; color: var(--ink);
    font-variant-numeric: tabular-nums; white-space: nowrap;
  }
  /* マイページのドロップダウン(details ごと)はスマホでは出さない=下部タブが mypage.php を開く
   * (summary だけ隠すと PC で開いたまま幅を縮めたときパネルが残る。codex 推奨4) */
  body:not(.admin) .top-actions .mypage-menu { display: none; }
  /* ‹ は standalone のときだけ(既存 .m-back の規則)。左詰めの余白だけ合わせる */
  body:not(.admin).is-sub .m-back { margin-left: -10px; }

  /* ---- 下部メニュー 4 つ ---- */
  body:not(.admin) .tab-link { font-size: 11px; }
  body:not(.admin) .tab-link.tab-create { position: relative; }
  body:not(.admin) .tab-link.tab-create .m-icon { width: 22px; height: 22px; position: relative; z-index: 1; margin-bottom: 4px; }
  body:not(.admin) .tab-link.tab-create::before {
    content: ''; position: absolute; top: 5px; left: 50%; transform: translateX(-50%);
    width: 34px; height: 34px; border-radius: 50%; background: var(--panel-2);
  }
  body:not(.admin) .tab-link.tab-create[aria-current="page"]::before { background: rgba(123, 92, 255, .22); }
  body:not(.admin) .tab-count { border-color: var(--panel); }

  /* ---- トップ ---- */
  /* 二段目・最近のチャット・作成ボタン・「キャラ一覧」の見出し行はスマホでは出さない。
   * **運営の項目の横一列(§22)はスマホでも出す**(09-06 深夜 ユーザー決定=一度外したが「管理ツールの項目をスマホにも
   * 反映」で戻した。Zeta 型のリストタブ「おすすめ」のピルは重複するので index.php 側で出さない) */
  body:not(.admin) .home-tabs, body:not(.admin) .recent-row, body:not(.admin) .home-create, body:not(.admin) .home-sections-end,
  body:not(.admin) .page-head.home-plain { display: none; }
  /* 横一列の ‹ › はスマホでは出さない(設計どおり。既存の `.carousel .carousel-btn {none}` が `.has-overflow` の
   * `display:flex` に詳細度で負けて出ていた=09-06 深夜に発見・修正) */
  body:not(.admin) .carousel.has-overflow .carousel-btn { display: none; }
  body:not(.admin) .list-tabs { display: flex; gap: 6px; margin: 0 0 14px; }
  body:not(.admin) .list-tab {
    padding: 6px 14px; border-radius: 999px; font-size: 14px;
    color: var(--muted); text-decoration: none; white-space: nowrap;
  }
  body:not(.admin) .list-tab.active { background: var(--accent); color: #fff; font-weight: bold; }
  body:not(.admin) .banner-strip { border-radius: 14px; margin-bottom: 14px; }
  body:not(.admin) .banner-count {
    display: block; position: absolute; right: 10px; bottom: 8px; z-index: 2;
    padding: 1px 8px; border-radius: 999px; font-size: 11px;
    color: rgba(255, 255, 255, .9); background: rgba(0, 0, 0, .45);
  }
  body:not(.admin) .page-head h1 { font-size: 18px; }
  body:not(.admin) .home-section-head h2 { font-size: 17px; }

  /* ---- カード(Zeta 型) ---- */
  body:not(.admin) .card { position: relative; border: none; background: transparent; border-radius: 12px; overflow: visible; }
  body:not(.admin) .card-thumb { aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: var(--panel-2); }
  body:not(.admin) .card-body { padding: 8px 2px 2px; }
  body:not(.admin) .card-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
  body:not(.admin) .card-name .badge-sensitive { vertical-align: 1px; }
  body:not(.admin) .card-desc { font-size: 12px; }
  /* タグ行: 親は pointer-events:none(余白のタップは全面リンクへ)・<a> だけ auto。各チップは縮んで自分で省略する
   * (隠れたリンクを作らない。codex 要修正1・2) */
  body:not(.admin) .card-tags { flex-wrap: nowrap; overflow: hidden; gap: 6px; margin-top: 4px; position: relative; z-index: 2; pointer-events: none; }
  body:not(.admin) .card-tags .tag-chip {
    background: none; padding: 0; color: var(--tag); font-size: 12px; white-space: nowrap; pointer-events: auto;
    flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  }
  body:not(.admin) .card-tags .tag-chip.active { background: none; color: #fff; text-decoration: underline; }
  body:not(.admin) .card-tags .tag-more { display: none; }
  body:not(.admin) .card-meta, body:not(.admin) .card-actions { display: none; }
  /* バッジ・順位は飾り=タップは下の全面リンクへ通す(codex 要修正1) */
  body:not(.admin) .card-badges { display: flex; gap: 4px; position: absolute; top: 8px; left: 8px; z-index: 2; pointer-events: none; }
  body:not(.admin) .card-chats, body:not(.admin) .card-new {
    display: inline-block; height: 22px; line-height: 22px; padding: 0 8px; border-radius: 999px;
    font-size: 12px; font-weight: bold; color: #fff; white-space: nowrap;
  }
  body:not(.admin) .card-chats { background: rgba(0, 0, 0, .55); }
  body:not(.admin) .card-new { background: var(--accent); padding: 0 7px; }
  body:not(.admin) .card.has-rank .card-badges { left: auto; right: 8px; }
  body:not(.admin) .card-rank { z-index: 2; border-radius: 999px; pointer-events: none; }
  body:not(.admin) .card-link-m { display: block; position: absolute; inset: 0; z-index: 1; border-radius: 12px; }
  body:not(.admin) .card:has(.card-link-m:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
  body:not(.admin) .carousel-track > .card { flex-basis: calc((100% - 10px) / 2 - 12px); }

  /* ---- チャット画面: 吹き出しの色だけ暗色に合わせる(形・入力欄・メニューは B4) ---- */
  body:not(.admin).on-chat .msg.assistant .bubble { background: rgba(38, 38, 43, .88); color: var(--ink); }
  body:not(.admin).on-chat .msg.user .bubble { background: rgba(123, 92, 255, .9); }
  body:not(.admin).on-chat .msg.assistant .bubble em { color: #c9bfff; }
  body:not(.admin).on-chat .msg .speaker { text-shadow: 0 0 6px rgba(0, 0, 0, .9); }
  /* ストーリーチャット(§29)の暗色。基底の色は触らない(選択子の上書きだけ) */
  body:not(.admin).on-chat .story-nar { background: rgba(255, 255, 255, .06); color: #c9bfff; }
  body:not(.admin).on-chat .spk-avatar { background: #3a3a44; color: #ddd; }
  body:not(.admin).on-chat .story-line .spk { color: #b9b9c6; }
  body:not(.admin).on-chat .story-line.spk-main .spk { color: #c9bfff; }
  body:not(.admin).on-chat .story-line.spk-user .spk { color: #ff9f7a; }
  body:not(.admin) .badge-story { background: rgba(123, 92, 255, .16); border-color: #9b8bff; color: #c9bfff; }
  body:not(.admin).on-chat .chat-fiction-note { text-shadow: 0 0 6px rgba(0, 0, 0, .9); }
  body:not(.admin).on-chat .chat-bg img { opacity: .35; }

  /* ---- 直書き色の上書き(付録 A。PC の値は基底のまま) ---- */
  .side-link:hover, .side-link.active, .top-search button:hover, .mypage-link:hover, .btn:hover,
  body:not(.admin) .igm-close:hover { background: var(--panel-2); }
  body:not(.admin) .btn-primary:hover { background: var(--accent); }
  body:not(.admin) .notice-count, body:not(.admin) .recent-char-thumb { border-color: var(--panel); }
  body:not(.admin) .mypage-charge, body:not(.admin) .plan-buy, body:not(.admin) .cp-toast, body:not(.admin) .room-profile-tip { background: var(--accent); color: #fff; }
  body:not(.admin) .errors { background: #3a1d24; border-color: #7a2f42; color: #ffb3c0; }
  body:not(.admin) .notice { background: #1c3323; border-color: #2f6b41; color: #b7e5c3; }
  .search-result-thumb, .recent-char-thumb, .talk-thumb, .portrait-slot-thumb, .igm-item img,
  body:not(.admin) .mod-review-card img { background: var(--panel-2); }
  body:not(.admin) .tag-chip { background: rgba(123, 92, 255, .16); color: var(--tag); }
  body:not(.admin) a.tag-chip:hover { background: rgba(123, 92, 255, .28); }
  body:not(.admin) .badge-sensitive { background: rgba(123, 92, 255, .16); }
  input[type="text"], input[type="number"], input[type="password"], input[type="search"], textarea, select,
  body:not(.admin) .login-box input[type="password"], body:not(.admin) .login-box input[type="text"], body:not(.admin) .memo-draft textarea {
    background: var(--panel-2); color: var(--ink); border-color: var(--line);
  }
  body:not(.admin) input:focus, body:not(.admin) textarea:focus, body:not(.admin) select:focus { outline-color: #5a5a66; }
  body:not(.admin) input[type="file"]::file-selector-button {
    background: rgba(123, 92, 255, .16); border-color: rgba(123, 92, 255, .45); color: var(--ink);
  }
  body:not(.admin) input[type="file"]:hover::file-selector-button { background: rgba(123, 92, 255, .28); }
  body:not(.admin) input[type="file"]:focus-visible::file-selector-button { outline-color: #5a5a66; }
  body:not(.admin) .repeat-item, body:not(.admin) .notice-row { background: var(--panel); }
  body:not(.admin) .memo-draft { background: #2b2416; border-color: #8a6a2a; }
  body:not(.admin) .memo-draft-title { color: #e0b25a; }
  .room-panel .btn:not(.btn-primary), .room-panel .btn[disabled]:hover,
  body:not(.admin) .set-item .btn:not(.btn-primary), body:not(.admin) .set-item .btn[disabled]:hover {
    background: #2f2a3f; border-color: #5b4d8c; color: #e8e2ff;
  }
  body:not(.admin) .room-panel .btn:not(.btn-primary):hover, body:not(.admin) .set-item .btn:not(.btn-primary):hover {
    background: #3b3450; border-color: var(--accent);
  }
  body:not(.admin) .bubble em { color: #c9bfff; }
  body:not(.admin) .msg.user .bubble em { color: rgba(255, 255, 255, .8); }
  body:not(.admin) .carousel-btn, body:not(.admin) .carousel-btn:hover, body:not(.admin) .carousel-btn[disabled]:hover { background: rgba(28, 28, 32, .94); }
  body:not(.admin) .ig-overlay, body:not(.admin) .igm-overlay { background: rgba(18, 18, 20, .75); }
  body:not(.admin) .ig-spinner { border-color: #3b3450; border-top-color: var(--accent); }
  body:not(.admin) .igm-item:hover::after { border-color: #5a5a66; }
  body:not(.admin) .igm-lightbox img { background: var(--panel); }
  body:not(.admin) .portrait-slot .portrait-pending { color: #f0b45a; }
  body:not(.admin) .fb-unread, body:not(.admin) tr.fb-unread > td { background: #2a2030; }
  body:not(.admin) .fb-tag { background: var(--panel-2); }
  body:not(.admin) .fb-status-open { background: rgba(123, 92, 255, .16); }
  body:not(.admin) .fb-status-in_progress { background: #3a2c14; border-color: #d08a2c; color: #f0b45a; }
  body:not(.admin) .fb-status-resolved { background: #1c3323; border-color: #4f7250; color: #9fd3ab; }
  body:not(.admin) .fb-card:hover, body:not(.admin) .card-link:hover { background: var(--panel-2); border-color: #4a4a55; }
  body:not(.admin) .fb-card.fb-unread:hover { background: #342a3d; }
  body:not(.admin) .fb-msg-admin { background: #22263a; border-color: #3c4670; }
  body:not(.admin) .notice-row-unread { background: #2a2030; border-color: #5b4d8c; }
  body:not(.admin) .chlog-tag { background: var(--panel-2); }
  body:not(.admin) .chlog-tag-added { background: rgba(123, 92, 255, .16); border-color: #5b4d8c; color: #c9bfff; }
  body:not(.admin) .chlog-tag-improved { background: #1e2740; border-color: #3c4670; color: #a9bdf5; }
  body:not(.admin) .chlog-tag-fixed { background: #1c3323; border-color: #2f6b41; color: #9fd3ab; }
  body:not(.admin) .login-google { background: #fff; color: #1c1c20; }            /* Google の指針=白地。文字も固定 */
  body:not(.admin) .login-google:hover { background: #f7f8fa; }
  body:not(.admin) .login-box .google-id { background: #22263a; }
  body:not(.admin) .login-box { border-color: rgba(123, 92, 255, .25); }
  body:not(.admin) .mypage-menu[open]::before, body:not(.admin) .room-menu[open]::before { background: rgba(0, 0, 0, .55); }
  body:not(.admin) .sheet-close { background: var(--panel-2); }
  body:not(.admin) .search-tab.active { border-bottom-color: var(--accent); }
  body:not(.admin) .ig-pill input:checked + span, body:not(.admin) .ig-folder-chip.active {
    background: rgba(123, 92, 255, .18); border-color: var(--accent); color: var(--tag);
  }
  body:not(.admin) .ig-pill:hover span, body:not(.admin) .ig-folder-chip:hover { border-color: #5a5a66; }
  body:not(.admin) .home-section-head h2 a:hover, body:not(.admin) .home-section-more:hover { color: var(--tag); }
}
/* 小さい画面(360px 以下。iPhone SE 等)の上部バー: タブの文字とアイコンを一段詰める(codex 要修正3。
 * 320px で「ホーム ランキング」+🔍🔔+残高 5 桁が収まる寸法) */
@media (max-width: 360px) {
  body:not(.admin) .m-topbar { padding-left: 10px; padding-right: 4px; }
  body:not(.admin) .m-tabs { gap: 10px; }
  body:not(.admin) .m-tab { font-size: 16px; }
  body:not(.admin) .top-actions .top-action:not(.m-gold) { width: 36px; }   /* 残高リンクは内容幅のまま(36px に固定するとアイコンが潰れる) */
  body:not(.admin) .top-actions .top-action.m-gold { padding: 0 6px 0 2px; }
  body:not(.admin) .m-gold-num { font-size: 12px; }
}
