/* =====================================================================
   チャットの背景モード（ナイト・ライト・リーフ）
   ---------------------------------------------------------------------
   ・<html> に付く data-chat-place（場所）と data-chat-mode（モード）で色が決まります（assets/js/chat-mode.js が付けます）。
   ・色は下の「色の一覧表」だけで管理します。
       1. モードごとの基本の色（3行）
       2. 場所 × モードの行（14か所 × 3モード）… ここに書いた色だけ、基本の色を上書きします
   ・今までの見た目：舞台＝ナイト、通常チャット・ユーザールーム・秘話・ユニットルーム・ミーティング・台本＝リーフ。
   ・タイトル・ルールブック・お知らせ・お問い合わせ・アイドル活動・管理画面は、もとの色と違うモードにしたときだけ
     この一覧表の色が使われます（もとの色のときは何も付かず、今までと同じ見た目）。
     ページごとの細かい色は chat-modes-pages.css（ページのCSSの色を置きかえたもの）で塗り替えます。
   ===================================================================== */

/* ===== 1. モードごとの基本の色 ===== */
html[data-chat-mode="night"] {
  --m-rehearsal: linear-gradient(rgba(7, 8, 21, 0.82), rgba(7, 8, 21, 0.92)), radial-gradient(circle at 50% 0, rgba(174, 188, 255, 0.28), transparent 45%);
  --m-on-text: #aaf2d1;
  --m-on-line: rgba(142, 224, 189, 0.46);
  --m-pin: rgba(111, 127, 218, 0.22);
  --m-pin-text: #dfe4ff;
  --m-pin-line: rgba(159, 175, 255, 0.55);
  --m-live: rgba(42, 160, 95, 0.32);
  --m-live-text: #e3ffef;
  --m-live-line: #46c985;
  --m-icon-on: #fff;
  --m-shotbar: #070815;
  --m-shotbtn: #11152c;
  --m-logon: rgba(255, 255, 255, 0.08);
  --m-logon-text: #fff;
  --m-logon-line: rgba(255, 255, 255, 0.28);
  --m-danger-line: rgba(255, 141, 155, 0.45);
  --m-column-line: rgba(174, 188, 255, 0.34);
  --m-stage-icon: #fff;
  --m-warn-text: #ffe6b7;
  --m-warn: rgba(192, 133, 40, 0.12);
  --m-warn-line: rgba(241, 202, 129, 0.28);
  --m-error-text: #ffd4d9;
  --m-error: rgba(202, 66, 88, 0.12);
  --m-error-line: rgba(255, 141, 155, 0.3);
  --m-camera: rgba(255, 255, 255, 0.04);
  --m-camera-line: rgba(190, 199, 255, 0.17);
  --m-camera-text: #eef0ff;
  --m-exit: #11131b;
  --m-tab-on: #aebcff;
  --m-tab-on-text: #12172f;
  --m-tab-on-line: rgba(255, 255, 255, 0.4);
  --m-preview-line: rgba(174, 188, 255, 0.24);
  --m-toggle: rgba(255, 255, 255, 0.04);
  --m-toggle-text: #a7abc4;
  --m-scheme: dark;
  --m-bg: #070815;
  --m-bg-glow-a: rgba(113, 128, 219, 0.14);
  --m-bg-glow-b: rgba(116, 69, 178, 0.12);
  --m-dot-a: #fff;
  --m-dot-b: #cad0ff;
  --m-dot-opacity: 0.46;
  --m-header: rgba(7, 8, 21, 0.78);
  --m-header-line: rgba(190, 199, 255, 0.17);
  --m-header-text: #eef0ff;
  --m-panel: rgba(20, 24, 47, 0.82);
  --m-panel-solid: #14182f;
  --m-line: rgba(190, 199, 255, 0.17);
  --m-text: #eef0ff;
  --m-muted: #a7abc4;
  --m-accent: #aebcff;
  --m-accent-strong: #8398ff;
  --m-accent-text: #11152e;
  --m-eyebrow: #aebcff;
  --m-surface: #090b1b;
  --m-surface-line: rgba(174, 188, 255, 0.22);
  --m-surface-text: #eef0ff;
  --m-log: transparent;
  --m-box: rgba(20, 24, 47, 0.9);
  --m-subpanel: rgba(15, 19, 41, 0.72);
  --m-tabs: rgba(7, 8, 21, 0.92);
  --m-form: rgba(4, 6, 18, 0.92);
  --m-field: rgba(2, 4, 14, 0.48);
  --m-field-strong: rgba(7, 8, 21, 0.78);
  --m-soft: rgba(255, 255, 255, 0.04);
  --m-softer: rgba(2, 4, 14, 0.18);
  --m-tint: rgba(174, 188, 255, 0.08);
  --m-pagination: rgba(4, 6, 18, 0.36);
  --m-primary: linear-gradient(135deg, #7288ee, #8d70d2);
  --m-primary-text: #eef0ff;
  --m-primary-shadow: 0 10px 30px rgba(110, 125, 220, 0.24);
  --m-current: rgba(131, 152, 255, 0.3);
  --m-current-text: #fff;
  --m-current-line: rgba(174, 188, 255, 0.6);
  --m-select: #090b1b;
  --m-option: #11152b;
  --m-option-text: #f4f5ff;
  --m-dialog: #12131a;
  --m-popup: #14182f;
  --m-menu: rgba(8, 10, 27, 0.985);
  --m-menu-text: #f4f5ff;
  --m-menu-line: rgba(174, 188, 255, 0.18);
  --m-menu-hover: #aebcff;
  --m-menu-hover-bg: transparent;
  --m-red: #ff7f8b;
  --m-blue: #72bbef;
  --m-action-line: rgba(214, 220, 255, 0.5);
  --m-action-text: #eef0ff;
  --m-action-hover: #eef0ff;
  --m-action-hover-text: #090b1b;
  --m-item-line: rgba(174, 188, 255, 0.32);
  --m-strong: #f0f2ff;
  --m-sub: #cdd4ff;
  --m-badge: rgba(131, 152, 255, 0.5);
  --m-badge-text: #fff;
  --m-danger: #ff8d9b;
  --m-note: rgba(128, 132, 145, 0.08);
}

html[data-chat-mode="light"] {
  --m-rehearsal: linear-gradient(rgba(255, 255, 255, 0.7), rgba(240, 242, 248, 0.92)), radial-gradient(circle at 50% 0, rgba(143, 160, 216, 0.22), transparent 45%);
  --m-on-text: #1f7a52;
  --m-on-line: rgba(31, 122, 82, 0.45);
  --m-pin: rgba(79, 91, 147, 0.14);
  --m-pin-text: #3a4690;
  --m-pin-line: rgba(79, 91, 147, 0.45);
  --m-live: rgba(42, 160, 95, 0.16);
  --m-live-text: #11643b;
  --m-live-line: #2f9a63;
  --m-icon-on: #3b3f55;
  --m-shotbar: rgba(250, 251, 254, 0.97);
  --m-shotbtn: #f1f3f9;
  --m-logon: rgba(79, 91, 147, 0.1);
  --m-logon-text: #3b3f55;
  --m-logon-line: rgba(79, 91, 147, 0.42);
  --m-danger-line: rgba(156, 47, 69, 0.45);
  --m-column-line: rgba(60, 64, 90, 0.2);
  --m-stage-icon: #3b3f55;
  --m-warn-text: #7a5413;
  --m-warn: rgba(241, 202, 129, 0.18);
  --m-warn-line: rgba(192, 133, 40, 0.35);
  --m-error-text: #a32323;
  --m-error: rgba(202, 66, 88, 0.08);
  --m-error-line: rgba(202, 66, 88, 0.35);
  --m-camera: #4f5b93;
  --m-camera-line: #4f5b93;
  --m-camera-text: #fff;
  --m-exit: #4f5b93;
  --m-tab-on: #4f5b93;
  --m-tab-on-text: #fff;
  --m-tab-on-line: #4f5b93;
  --m-preview-line: rgba(60, 64, 90, 0.2);
  --m-toggle: rgba(60, 64, 90, 0.04);
  --m-toggle-text: rgba(60, 64, 90, 0.72);
  --m-scheme: light;
  --m-bg: #eceef4;
  --m-bg-glow-a: rgba(255, 255, 255, 0.9);
  --m-bg-glow-b: rgba(203, 211, 238, 0.6);
  --m-dot-a: #8a90a8;
  --m-dot-b: #c3c9e0;
  --m-dot-opacity: 0.14;
  --m-header: rgba(250, 251, 254, 0.9);
  --m-header-line: rgba(60, 64, 90, 0.14);
  --m-header-text: #3b3f55;
  --m-panel: rgba(255, 255, 255, 0.92);
  --m-panel-solid: #ffffff;
  --m-line: rgba(60, 64, 90, 0.18);
  --m-text: #34374a;
  --m-muted: rgba(60, 64, 90, 0.72);
  --m-accent: #4f5b93;
  --m-accent-strong: #8fa0d8;
  --m-accent-text: #fff;
  --m-eyebrow: #5a68a8;
  --m-surface: rgba(255, 255, 255, 0.94);
  --m-surface-line: rgba(60, 64, 90, 0.14);
  --m-surface-text: #26293a;
  --m-log: rgba(240, 242, 248, 0.5);
  --m-box: rgba(255, 255, 255, 0.92);
  --m-subpanel: rgba(255, 255, 255, 0.86);
  --m-tabs: rgba(255, 255, 255, 0.9);
  --m-form: rgba(250, 251, 254, 0.96);
  --m-field: rgba(244, 246, 251, 0.95);
  --m-field-strong: #f4f6fb;
  --m-soft: rgba(60, 64, 90, 0.05);
  --m-softer: rgba(60, 64, 90, 0.03);
  --m-tint: rgba(79, 91, 147, 0.06);
  --m-pagination: rgba(226, 230, 242, 0.5);
  --m-primary: #4f5b93;
  --m-primary-text: #fff;
  --m-primary-shadow: 0 10px 26px rgba(79, 91, 147, 0.2);
  --m-current: #4f5b93;
  --m-current-text: #fff;
  --m-current-line: #4f5b93;
  --m-select: #f7f8fc;
  --m-option: #ffffff;
  --m-option-text: #2f3245;
  --m-dialog: #ffffff;
  --m-popup: #f7f8fc;
  --m-menu: rgba(252, 252, 255, 0.985);
  --m-menu-text: #3b3f55;
  --m-menu-line: rgba(60, 64, 90, 0.14);
  --m-menu-hover: #4f5b93;
  --m-menu-hover-bg: rgba(79, 91, 147, 0.08);
  --m-red: #c0283b;
  --m-blue: #2348c9;
  --m-action-line: rgba(47, 50, 69, 0.35);
  --m-action-text: #3b3f55;
  --m-action-hover: #4f5b93;
  --m-action-hover-text: #fff;
  --m-item-line: #9aa0b8;
  --m-strong: #26293a;
  --m-sub: #4a4e63;
  --m-badge: #4f5b93;
  --m-badge-text: #fff;
  --m-danger: #9c2f45;
  --m-note: rgba(79, 91, 147, 0.06);
}

html[data-chat-mode="leaf"] {
  --m-rehearsal: linear-gradient(rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.34)), radial-gradient(circle at 50% 0, rgba(148, 181, 178, 0.36), transparent 45%);
  --m-on-text: #2f6e58;
  --m-on-line: rgba(47, 110, 88, 0.45);
  --m-pin: rgba(88, 82, 87, 0.12);
  --m-pin-text: #3a363a;
  --m-pin-line: rgba(88, 82, 87, 0.45);
  --m-live: rgba(42, 160, 95, 0.16);
  --m-live-text: #11643b;
  --m-live-line: #2f9a63;
  --m-icon-on: #51413b;
  --m-shotbar: rgba(211, 220, 216, 0.97);
  --m-shotbtn: rgba(255, 255, 255, 0.4);
  --m-logon: rgba(88, 82, 87, 0.08);
  --m-logon-text: #51413b;
  --m-logon-line: rgba(88, 82, 87, 0.42);
  --m-danger-line: rgba(122, 52, 64, 0.45);
  --m-column-line: rgba(88, 82, 87, 0.28);
  --m-stage-icon: #514c52;
  --m-warn-text: #585257;
  --m-warn: rgba(211, 220, 216, 0.74);
  --m-warn-line: rgba(88, 82, 87, 0.22);
  --m-error-text: #a32323;
  --m-error: rgba(163, 35, 35, 0.11);
  --m-error-line: rgba(163, 35, 35, 0.42);
  --m-camera: #585257;
  --m-camera-line: rgba(88, 82, 87, 0.56);
  --m-camera-text: #fff;
  --m-exit: #585257;
  --m-tab-on: #585257;
  --m-tab-on-text: #fff;
  --m-tab-on-line: #585257;
  --m-preview-line: rgba(174, 188, 255, 0.24);
  --m-toggle: rgba(255, 255, 255, 0.04);
  --m-toggle-text: rgba(88, 82, 87, 0.76);
  --m-scheme: light;
  --m-bg: #b3c8c9;
  --m-bg-glow-a: rgba(211, 220, 216, 0.86);
  --m-bg-glow-b: rgba(148, 181, 178, 0.58);
  --m-dot-a: #585257;
  --m-dot-b: #94b5b2;
  --m-dot-opacity: 0.16;
  --m-header: rgba(211, 220, 216, 0.88);
  --m-header-line: rgba(88, 82, 87, 0.2);
  --m-header-text: #514c52;
  --m-panel: rgba(211, 220, 216, 0.92);
  --m-panel-solid: #d3dcd8;
  --m-line: rgba(88, 82, 87, 0.25);
  --m-text: #464145;
  --m-muted: rgba(88, 82, 87, 0.76);
  --m-accent: #585257;
  --m-accent-strong: #94b5b2;
  --m-accent-text: #fff;
  --m-eyebrow: #567d7c;
  --m-surface: rgba(211, 220, 216, 0.92);
  --m-surface-line: rgba(88, 82, 87, 0.2);
  --m-surface-text: #302d30;
  --m-log: rgba(255, 255, 255, 0.08);
  --m-box: rgba(211, 220, 216, 0.92);
  --m-subpanel: rgba(211, 220, 216, 0.82);
  --m-tabs: rgba(211, 220, 216, 0.88);
  --m-form: rgba(211, 220, 216, 0.94);
  --m-field: rgba(255, 255, 255, 0.48);
  --m-field-strong: rgba(255, 255, 255, 0.58);
  --m-soft: rgba(255, 255, 255, 0.34);
  --m-softer: rgba(255, 255, 255, 0.22);
  --m-tint: rgba(255, 255, 255, 0.2);
  --m-pagination: rgba(179, 200, 201, 0.34);
  --m-primary: #585257;
  --m-primary-text: #fff;
  --m-primary-shadow: 0 10px 28px rgba(88, 82, 87, 0.22);
  --m-current: #585257;
  --m-current-text: #fff;
  --m-current-line: #585257;
  --m-select: rgba(244, 248, 246, 0.82);
  --m-option: #eef4f1;
  --m-option-text: #464145;
  --m-dialog: #d3dcd8;
  --m-popup: #d6dfdb;
  --m-menu: rgba(211, 220, 216, 0.985);
  --m-menu-text: #514c52;
  --m-menu-line: rgba(88, 82, 87, 0.2);
  --m-menu-hover: #365f60;
  --m-menu-hover-bg: rgba(148, 181, 178, 0.2);
  --m-red: #a32323;
  --m-blue: #263db2;
  --m-action-line: rgba(58, 55, 58, 0.45);
  --m-action-text: #3a363a;
  --m-action-hover: #585257;
  --m-action-hover-text: #fff;
  --m-item-line: #3a373a;
  --m-strong: #302d30;
  --m-sub: #4d4a4d;
  --m-badge: #585257;
  --m-badge-text: #fff;
  --m-danger: #7a3440;
  --m-note: rgba(128, 132, 145, 0.08);
}

/* ===== 2. 場所 × モードの行（ここに書いた色だけ上書き。空の行は基本の色のまま） ===== */
/* 舞台 */
html[data-chat-place="stage"][data-chat-mode="night"] { --m-box: rgba(15, 18, 39, 0.88); --m-form: rgba(7, 8, 21, 0.46); --m-field: rgba(2, 4, 14, 0.48); }
html[data-chat-place="stage"][data-chat-mode="light"] { }
html[data-chat-place="stage"][data-chat-mode="leaf"]  { }
/* 通常チャット */
html[data-chat-place="chat"][data-chat-mode="night"] { }
html[data-chat-place="chat"][data-chat-mode="light"] { }
html[data-chat-place="chat"][data-chat-mode="leaf"]  { --m-eyebrow: #585257; }
/* ミーティング */
html[data-chat-place="meeting"][data-chat-mode="night"] { --m-header: rgba(7, 8, 21, 0.92); --m-box: rgba(12, 15, 36, 0.76); --m-meeting-on-text: #11162d; --m-meeting-on-line: rgba(255, 255, 255, 0.42); }
html[data-chat-place="meeting"][data-chat-mode="light"] { }
html[data-chat-place="meeting"][data-chat-mode="leaf"]  { --m-header: rgba(211, 220, 216, 0.94); }
/* ユーザールーム */
html[data-chat-place="room"][data-chat-mode="night"] { }
html[data-chat-place="room"][data-chat-mode="light"] { }
html[data-chat-place="room"][data-chat-mode="leaf"]  { --m-eyebrow: #585257; }
/* 秘話 */
html[data-chat-place="whisper"][data-chat-mode="night"] { }
html[data-chat-place="whisper"][data-chat-mode="light"] { }
html[data-chat-place="whisper"][data-chat-mode="leaf"]  { --m-eyebrow: #585257; }
/* ユニットルーム */
html[data-chat-place="unit"][data-chat-mode="night"] { --m-header: rgba(7, 8, 21, 0.92); }
html[data-chat-place="unit"][data-chat-mode="light"] { }
html[data-chat-place="unit"][data-chat-mode="leaf"]  { --m-header: rgba(211, 220, 216, 0.94); --m-tab-text: #716c72; --m-tabs-line: rgba(88, 82, 87, 0.15); --m-toggle: rgba(255, 255, 255, 0.4); --m-toggle-text: #716c72; }
/* 台本（自分の台本・共通台本・リハーサル） */
html[data-chat-place="script"][data-chat-mode="night"] { --m-header: rgba(7, 8, 21, 0.92); }
html[data-chat-place="script"][data-chat-mode="light"] { }
html[data-chat-place="script"][data-chat-mode="leaf"]  { --m-header: rgba(211, 220, 216, 0.94); }
/* フォロー発言・返信ログ一覧 */
html[data-chat-place="followlog"][data-chat-mode="night"] { }
html[data-chat-place="followlog"][data-chat-mode="light"] { }
html[data-chat-place="followlog"][data-chat-mode="leaf"]  { --m-eyebrow: #585257; --m-header-text: #464145; --m-menu-toggle-line: rgba(88, 82, 87, 0.25); --m-ghost: rgba(255, 255, 255, 0.28); }
/* タイトル（もとはナイト） */
html[data-chat-place="title"][data-chat-mode="night"] { }
html[data-chat-place="title"][data-chat-mode="light"] { }
html[data-chat-place="title"][data-chat-mode="leaf"]  { }
/* ルールブック（もとはナイト） */
html[data-chat-place="rules"][data-chat-mode="night"] { }
html[data-chat-place="rules"][data-chat-mode="light"] { }
html[data-chat-place="rules"][data-chat-mode="leaf"]  { }
/* お知らせ（もとはナイト） */
html[data-chat-place="news"][data-chat-mode="night"] { }
html[data-chat-place="news"][data-chat-mode="light"] { }
html[data-chat-place="news"][data-chat-mode="leaf"]  { }
/* お問い合わせ（もとはナイト） */
html[data-chat-place="contact"][data-chat-mode="night"] { }
html[data-chat-place="contact"][data-chat-mode="light"] { }
html[data-chat-place="contact"][data-chat-mode="leaf"]  { }
/* アイドル活動（もとはリーフ） */
html[data-chat-place="activity"][data-chat-mode="night"] { }
html[data-chat-place="activity"][data-chat-mode="light"] { }
html[data-chat-place="activity"][data-chat-mode="leaf"]  { }
/* 管理画面（管理者・モデレーター。もとはナイト、お問い合わせ対応の画面だけリーフ） */
html[data-chat-place="admin"][data-chat-mode="night"] { }
html[data-chat-place="admin"][data-chat-mode="light"] { }
html[data-chat-place="admin"][data-chat-mode="leaf"]  { }

/* =====================================================================
   ここから下は、一覧表の色を画面の各部分に当てる指定（色はここで直接書かない）
   ※ もとのCSS（chat.css・unit.css・stage.css など）より強く効かせるため、頭に :not(.cm1):not(.cm2):not(.cm3) を付けています
   ===================================================================== */
html[data-chat-mode] { color-scheme: var(--m-scheme); background: var(--m-bg); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body {
  color-scheme: var(--m-scheme);
  --bg: var(--m-bg);
  --panel: var(--m-panel);
  --panel-solid: var(--m-panel-solid);
  --line: var(--m-line);
  --text: var(--m-text);
  --muted: var(--m-muted);
  --accent: var(--m-accent);
  --accent-strong: var(--m-accent-strong);
  --chat-surface-background: var(--m-surface);
  --chat-surface-border: var(--m-surface-line);
  --chat-surface-text: var(--m-surface-text);
  --chat-log-background: var(--m-log);
  color: var(--m-text);
  background:
    radial-gradient(circle at 18% 18%, var(--m-bg-glow-a), transparent 31rem),
    radial-gradient(circle at 84% 10%, var(--m-bg-glow-b), transparent 28rem),
    var(--m-bg);
}
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body.stage-chat-page { background: var(--m-bg) !important; }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body::before {
  opacity: var(--m-dot-opacity);
  background-image: radial-gradient(circle, var(--m-dot-a) 0 1px, transparent 1.3px), radial-gradient(circle, var(--m-dot-b) 0 1px, transparent 1.2px);
}
@media (max-width: 640px) {
  html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body { background: var(--m-bg); }
}

/* ヘッダーとメニュー */
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .site-header { border-color: var(--m-header-line); background: var(--m-header); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .site-header .brand,
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .site-header .menu-toggle-button,
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .site-header .header-actions > .button:not(.mode-camera-button):not(#unit-screenshot-button) { color: var(--m-header-text); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .site-header .menu-toggle-button { border-color: var(--m-menu-toggle-line, var(--m-header-line)); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .header-menu-panel { border-color: var(--m-menu-line); background: var(--m-menu); color: var(--m-menu-text); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .header-menu-panel .menu-user-name { border-color: var(--m-menu-line); color: var(--m-menu-text); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .header-menu-panel .menu-link { border-bottom-color: var(--m-menu-line); color: var(--m-menu-text); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .header-menu-panel .menu-link:hover,
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .header-menu-panel .menu-link:focus-visible { color: var(--m-menu-hover); background: var(--m-menu-hover-bg); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .site-header .mode-camera-button,
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .site-header #unit-screenshot-button { color: var(--m-camera-text); border-color: var(--m-camera-line); background: var(--m-camera); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .exit-screenshot-button { color: #fff; border-color: var(--m-exit); background: var(--m-exit); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .layout-switcher,
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .unit-layout-switcher { border-color: var(--m-line); background: var(--m-soft); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .layout-switcher button,
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .unit-layout-switcher button { color: var(--m-muted); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .layout-switcher button.is-current,
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .unit-layout-switcher button.is-current { color: var(--m-current-text); background: var(--m-current); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-header-button:not(.is-stage-live):not([aria-pressed="true"]) { color: var(--m-header-text); border-color: var(--m-header-line); background: var(--m-soft); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-refresh-switcher button { color: var(--m-muted); border-color: var(--m-header-line); background: var(--m-soft); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-refresh-switcher button[aria-pressed="true"] { color: var(--m-current-text); background: var(--m-current); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-header-button.mode-camera-button:not([aria-pressed="true"]) .mode-action-icon-on { color: var(--m-stage-icon); }

/* 右上のモードボタン（今のモードのアイコンだけ） */
.chat-mode-button {
  display: inline-flex;
  order: -10;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--m-header-line, var(--line));
  border-radius: 50%;
  color: var(--m-header-text, var(--text));
  background: var(--m-soft, transparent);
  cursor: pointer;
}
.chat-mode-button:hover,
.chat-mode-button:focus-visible { border-color: var(--m-accent, var(--accent)); }
.chat-mode-icon { width: 18px; height: 18px; }
.has-site-menu .header-actions > .chat-mode-button,
.stage-chat-page .stage-site-header .header-actions > .chat-mode-button { display: inline-flex !important; }
/* スクショモード中は出さない */
body.has-site-menu:is(.chat-screenshot-mode, .unit-screenshot-mode, .stage-screenshot-mode) .header-actions > .chat-mode-button { display: none !important; }

/* 大きな枠（部屋・ユニット・台本・舞台の枠） */
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.conversation-panel, .stage-conversation, #unit-panel-chat) { border-color: var(--m-surface-line); background: var(--m-surface); color: var(--m-surface-text); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.message-list, .stage-feed, .unit-message-list) { background: var(--m-log); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.unit-gate-panel, .unit-invitations-panel, .unit-summary-panel, .unit-settings-panel, .unit-schedule-panel, .unit-mode-panel, .unit-meeting-panel, .stage-control-card) { border-color: var(--m-line); background: var(--m-box); color: var(--m-text); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .unit-mode-panel#unit-panel-chat { background: var(--m-surface); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .compact-room-panel { background: var(--m-subpanel); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .unit-mode-tabs { border-color: var(--m-tabs-line, var(--m-line)); background: var(--m-tabs); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .unit-mode-tabs button { color: var(--m-tab-text, var(--m-muted)); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .unit-mode-tabs button[aria-selected="true"] { color: var(--m-tab-on-text); border-color: var(--m-tab-on-line); background: var(--m-tab-on); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.eyebrow) { color: var(--m-eyebrow); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.unit-members, .unit-panel-heading p:last-child, .status-chip) { color: var(--m-muted); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .status-chip { border-color: var(--m-line); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.unit-gate-panel h1, .unit-gate-panel p:not(.eyebrow), .unit-gate-panel .unit-setup-form label) { color: var(--m-text); }

/* 入力欄・発言フォーム */
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.message-form, .unit-meeting-form) { background: var(--m-form); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-message-form { background: var(--m-form); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.message-label textarea, .new-room-form input, .page-jump-form input, .speaker-name-label input, .stage-message-label textarea, #unit-meeting-input, .whisper-inline-form input) { color: var(--m-text); background: var(--m-field); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.unit-setup-form input, .unit-settings-panel input, .cue-form input, .cue-form textarea, .cue-form select, .unit-summary-actions select, .unit-schedule-selects select, .script-number-controls input, .rehearsal-number-control input, .script-option-row input, .script-option-row select, .script-folder-builder input, .script-folder-builder select, .script-performance-row select, .script-performance-row input, .stage-schedule-form select, .stage-schedule-form input, .icon-url-row input, .content-image-url-label input) { color: var(--m-text); border-color: var(--m-line); background: var(--m-field-strong); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body select { color-scheme: var(--m-scheme); color: var(--m-text); border-color: var(--m-line); background-color: var(--m-select); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body select option,
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body select optgroup { color: var(--m-option-text); background-color: var(--m-option); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body select option:checked { color: var(--m-current-text); background-color: var(--m-accent); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.chat-preview-panel, .stage-live-preview) { border-color: var(--m-preview-line); background: var(--m-softer); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.composer-settings-panel, .unified-chat-settings-panel) { border-color: var(--m-line); background: var(--m-softer); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.current-icon-button, .chat-toolbar button, .stage-toolbar button, .stage-align-controls button, .unit-meeting-toolbar button, .pagination-buttons button, .page-number-list button, .page-jump-form button, .name-icon-toggle-button, .current-name-icon-button, .name-icon-disable-button) { color: var(--m-text); border-color: var(--m-line); background: var(--m-soft); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .composer-decoration-toggle { color: var(--m-toggle-text); border-color: var(--m-line); background: var(--m-toggle); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.page-number-list button.is-current, .stage-align-controls button[aria-pressed="true"]) { color: var(--m-current-text); border-color: var(--m-current-line); background: var(--m-current); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.message-pagination, .unit-message-pagination) { background: var(--m-pagination); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.stage-composer-guide, .unified-chat-current-status) { color: var(--m-muted); }

/* ボタン・お知らせ */
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .button-primary:not(.is-posting-closed) { color: var(--m-primary-text); border-color: transparent; background: var(--m-primary); box-shadow: var(--m-primary-shadow); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .button-ghost { color: var(--m-text); border-color: var(--m-line); background: var(--m-ghost, var(--m-soft)); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .button-secondary { color: var(--m-text); border-color: var(--m-line); background: var(--m-panel-solid); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .conversation-actions .button.room-move-button { color: var(--m-primary-text); background: var(--m-primary); box-shadow: var(--m-primary-shadow); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .unit-summary-actions #open-unit-meeting.is-active { color: var(--m-meeting-on-text, var(--m-tab-on-text)); border-color: var(--m-meeting-on-line, var(--m-tab-on-line)); background: var(--m-tab-on); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.decor-red, .chat-toolbar .tool-red, .stage-toolbar .tool-red) { color: var(--m-red); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.decor-blue, .chat-toolbar .tool-blue, .stage-toolbar .tool-blue) { color: var(--m-blue); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .chat-login-required { color: var(--m-accent); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .notice-warning { color: var(--m-warn-text); border-color: var(--m-warn-line); background: var(--m-warn); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .notice-error { color: var(--m-error-text); border-color: var(--m-error-line); background: var(--m-error); }

/* 発言 */
/* 発言ごとの横線（1px）の区切りは付けない（どのモードでも） */
html[data-chat-place] body .chat-message { border-bottom: 0; }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .message-actions button { color: var(--m-action-text); border-color: var(--m-action-line); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .message-actions button:hover { color: var(--m-action-hover-text); background: var(--m-action-hover); border-color: var(--m-action-hover); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .chat-message.item-use-note { background: var(--m-note); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .message-layout-columns .message-list::after { background: var(--m-column-line); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-message-name { color: var(--m-strong); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.stage-message.is-system, .stage-cue-system-log) { color: var(--m-sub); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-cue-system-log { border-top-color: var(--m-line); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.stage-message-reaction-chip:not(.is-active), .stage-message-reaction-add) { color: var(--m-text); border-color: var(--m-line); background: var(--m-tint); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.stage-lineup-panel) { background: var(--m-softer); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.stage-lineup-item, .stage-live-summary) { color: var(--m-text); background: var(--m-field-strong); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-live-summary strong { color: var(--m-strong); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-live-summary .stage-show-members { color: var(--m-sub); }

/* 部屋選択・秘話・ログ一覧の横の枠・確認の画面 */
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.room-picker-panel, .chat-confirm-panel, .unit-confirm-panel) { border-color: var(--m-surface-line); color: var(--m-surface-text); background: var(--m-popup); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.room-picker-current, .room-picker-description, .room-picker-times, .chat-confirm-panel p, .unit-confirm-panel p) { color: var(--m-sub); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .room-picker-times .room-time-mine { color: var(--m-strong); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .room-picker-item { border-color: var(--m-item-line); background: var(--m-soft); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .room-picker-item:hover { background: var(--m-tint); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .room-picker-item.is-selected { border-color: var(--m-strong); background: var(--m-tint); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.room-picker-here, .whisper-invited-badge, .whisper-member-more[aria-expanded="true"]) { color: var(--m-badge-text); background: var(--m-badge); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .whisper-member-more { border-color: var(--m-item-line); color: var(--m-strong); background: var(--m-soft); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .whisper-member.has-name { border-color: var(--m-line); background: var(--m-soft); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.whisper-tools, .follow-log-tabs-row) { border-color: var(--m-surface-line); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .whisper-tool-buttons .whisper-leave-button { color: var(--m-danger); border-color: var(--m-danger-line); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .whisper-tool-buttons .whisper-leave-button:hover { color: #fff; background: var(--m-danger); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .follow-feed-panel { border-color: var(--m-line); color: var(--m-surface-text); background: var(--m-dialog); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.follow-feed-header, .follow-feed-footer, .follow-feed-item) { border-color: var(--m-line); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.follow-feed-tabs button, .follow-feed-jump, .follow-feed-more) { border-color: var(--m-item-line); color: var(--m-strong); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.follow-feed-tabs button[aria-selected="true"], .follow-feed-jump:hover, .follow-feed-more:hover) { color: var(--m-badge-text); border-color: var(--m-badge); background: var(--m-badge); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.follow-feed-eno, .follow-feed-time, .follow-feed-room, .follow-feed-empty, .follow-feed-loading, .follow-feed-footer) { color: var(--m-sub); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.icon-picker-dialog, .content-image-dialog) { color: var(--m-text); border-color: var(--m-line); background: var(--m-dialog); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.content-image-size-guide, .content-image-preview) { background-color: var(--m-softer); }

/* 台本・ミーティング */
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .script-compose-dock { background: var(--m-form); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.cue-form, .unit-invitation-card, .unit-meeting-message) { border-color: var(--m-line); background: var(--m-softer); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.script-bulk-actions, .shared-copy-guide, .script-drag-handle) { background: var(--m-tint); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.script-bulk-actions button, .script-selected-insert-toggle, .script-entry-actions button, .script-entry-actions select, .script-folder-builder button) { color: var(--m-text); border-color: var(--m-line); background: var(--m-soft); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .script-entry { border-bottom-color: var(--m-line); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.script-system-log-preview, .rehearsal-system-log) { color: var(--m-muted); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .unit-meeting-pno { color: var(--m-accent); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .meeting-inline-reply { color: var(--m-blue); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .unit-meeting-reply-summary { border-top-color: var(--m-line); }
@media (max-width: 640px) {
  html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .script-compose-sticky-bar { background: var(--m-form); }
}

/* 舞台ヘッダーのボタンの「ON」「固定」「開演中」の色 */
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-header-button[aria-pressed="true"]:not(.stage-pin-button):not(.mode-camera-button):not(.is-stage-live) { color: var(--m-on-text); border-color: var(--m-on-line); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-pin-button[aria-pressed="true"]:not(.is-stage-live) { color: var(--m-pin-text); border-color: var(--m-pin-line); background: var(--m-pin); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body :is(.stage-header-button, .stage-compact-control).is-stage-live { color: var(--m-live-text); border-color: var(--m-live-line); background: var(--m-live); }
/* スクショモードの上の帯（舞台）とログ公開ボタン */
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-screenshot-topbar { color: var(--m-header-text); background: var(--m-shotbar); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-screenshot-topbar button:not(.is-stage-live) { color: var(--m-text); border-color: var(--m-line); background: var(--m-shotbtn); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-screenshot-topbar .mode-action-icon-on,
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-screenshot-topbar .mode-camera-button .mode-action-icon-off { color: var(--m-stage-icon); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .log-public-mode-button[aria-pressed="true"],
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .stage-screenshot-topbar .stage-log-public-mode-button[aria-pressed="true"] { color: var(--m-logon-text); border-color: var(--m-logon-line); background: var(--m-logon); }
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .mode-action-button:not(.mode-camera-button) .mode-action-icon-on { color: var(--m-icon-on); }
/* リハーサルルームの台本再生（舞台の絵の部分は暗いまま） */
html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .rehearsal-stage { background: var(--m-rehearsal); }
@media (max-width: 640px) {
  html[data-chat-mode]:not(.cm1):not(.cm2):not(.cm3) body .rehearsal-stage { background: var(--m-rehearsal); }
}

/* ===== ヘッダーのボタンが右にはみ出すときは、ボタンを小さくして収める（chat-mode.js が段階を付ける） ===== */
.site-header.header-fit-1 .header-actions { gap: 4px; }
.site-header.header-fit-1 .header-actions > :is(.button, .stage-header-button, .layout-switcher, .unit-layout-switcher, .stage-refresh-switcher) { padding-inline: 7px; font-size: 0.72rem; }
.site-header.header-fit-1 .header-actions > .menu-toggle-button { width: 38px !important; height: 38px !important; min-width: 38px !important; flex: 0 0 38px !important; }
.site-header.header-fit-2 .header-actions { gap: 3px; }
.site-header.header-fit-2 .header-actions > :is(.button, .stage-header-button) { min-height: 28px; padding: 2px 5px; font-size: 0.64rem; }
.site-header.header-fit-2 .header-actions .stage-refresh-switcher button,
.site-header.header-fit-2 .header-actions :is(.layout-switcher, .unit-layout-switcher) button { min-width: 0; padding-inline: 4px; font-size: 0.64rem; }
.site-header.header-fit-2 .header-actions > .chat-mode-button { width: 28px; height: 28px; flex-basis: 28px; }
.site-header.header-fit-2 .header-actions > .menu-toggle-button { width: 34px !important; height: 34px !important; min-width: 34px !important; flex: 0 0 34px !important; }
.site-header.header-fit-2 .chat-mode-icon { width: 15px; height: 15px; }
.site-header.header-fit-2 { gap: 6px; padding-inline: 8px; }
.site-header.header-fit-3 .header-actions { min-width: 0; flex: 1 1 auto; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
.site-header.header-fit-3 .header-actions > :first-child { margin-left: auto; }
.site-header.header-fit-3 > .brand { flex: 0 0 auto; }
.site-header.header-fit-3 .header-actions::-webkit-scrollbar { display: none; }
.site-header.header-fit-3 .header-actions > * { flex-shrink: 0; }
/* お問い合わせなど、上の見出しの右にモードボタンを置く画面 */
.control-header > .chat-mode-button { order: 0; margin-left: auto; }
/* お問い合わせ（位相観測所の control.css）はボタンに min-height:42px があり、縦長の楕円になっていたので、丸のままにする */
.chat-mode-button { min-width: 0; min-height: 0; aspect-ratio: 1 / 1; }
