:root {
    /* Color Palette - Vibrant & Readable */
    --color-main: #2e7d32;
    --color-main-soft: #a5d6a7;
    --color-consult: #ef6c00;
    --color-meeting: #7e57c2;

    --bg-layer-main: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    --bg-layer-consult: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    --bg-layer-meeting: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);

    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow-soft: 0 8px 32px 0 rgba(31, 38, 135, 0.07);

    /*
     * Android WebView(Chromium)のenv(safe-area-inset-*)はディスプレイカットアウトにしか
     * 連動せず、ステータスバー/ジェスチャーナビゲーションバーの領域は反映されない。
     * そのためMainActivity.ktが実測したシステムインセットを--native-safe-*としてJS経由で
     * 注入し、env()との大きい方を採用することで両方のケースを確実にカバーする。
     */
    --safe-top: max(env(safe-area-inset-top, 0px), var(--native-safe-top, 0px));
    --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--native-safe-bottom, 0px));
    --safe-bottom-comfortable: max(var(--safe-bottom), 20px);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: #f0f2f5;
    color: #2c3e50;
    display: flex;
    flex-direction: column;
}

.layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; }
#back-layer { z-index: 1; background: var(--bg-layer-main); transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
#mid-layer { z-index: 10; display: flex; flex-direction: column; height: 100%; background-color: transparent; overflow: hidden; }
#front-layer { z-index: 100; pointer-events: none; }

.enable-pointer { pointer-events: auto !important; }

header {
    flex-shrink: 0;
    background-color: var(--color-main);
    color: white;
    padding: 0.6rem 1rem;
    padding-top: calc(0.4rem + var(--safe-top));
    display: flex;
    flex-direction: row;
    align-items: center;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: background-color 0.3s;
}

.header-content {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

#main-header.mode-top #header-layout-room { display: none; }
#main-header.mode-room #header-layout-top { display: none; }

/* ロビーはルーム内画面と違って戻る操作や検索/設定ボタンを持たないので、
   その分のゆとりをロゴを大きく中央に見せることに使う。 */
#main-header.mode-top {
    padding-top: calc(1.1rem + var(--safe-top));
    padding-bottom: 1.1rem;
}

#header-layout-top { justify-content: center; }
#header-layout-top h1 {
    flex: none;
    margin: 0;
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

#header-title-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#header-room-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

header h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.header-status {
    font-size: 0.7rem;
    opacity: 0.85;
    font-weight: 500;
    margin-top: 2px;
}

/* 表現統一: 稼働時間の状態(OPEN/CLOSED)を示す丸印 */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    margin-right: 4px;
    vertical-align: middle;
}
.status-dot-open { background-color: #43a047; }
.status-dot-closed { background-color: #e53935; }

.avatar-wrapper {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
}
.avatar-wrapper:active { transform: scale(0.92); }

/* emoji文字をtextContentで出していた箇所をimgに差し替えるための共通サイズ指定。
   1emにしておくことで、親要素のfont-sizeに合わせて絵文字と同じ見た目のスケールになる。 */
.emoji-icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

.moderator-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    font-size: 0.75rem;
    background: white;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    border: 1px solid #ddd;
}

.header-settings-button {
    background: transparent;
    border: none;
    color: white;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
}
.header-settings-button:active { transform: scale(0.9); }


/* Main Container */
main {
    flex: 1;
    min-height: 0;
    margin: 0;
    margin-bottom: var(--safe-bottom);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 0 0 24px 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#setup-view, #chat-view, #entrance-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0;
    min-height: 0;
}

#setup-view { padding: 8px; }

#entrance-view {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

#room-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    text-align: center;
    color: #b0b8bd;
}
#room-empty-state h2 { margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
#room-empty-state p { margin: 0; font-size: 0.9rem; }

/* PC/横幅の広い画面: ロビー(部屋一覧)をサイドバーとして常時表示し、
   会話(#chat-view/#entrance-view)またはプレースホルダー(#room-empty-state)を
   右側に同時表示する。#setup-view/#chat-view/#entrance-viewの表示・非表示切り替え自体は
   モバイル向けロジック(roooom-ui-lobby.js/roooom-ui-chat.jsのshow*)のままで、
   PC幅では View.syncDesktopLayout() が#setup-viewの非表示を上書きして両方見せる。 */
@media (min-width: 900px) {
    /* サイドバーを画面の上端から下端まで通しで見せ、ヘッダーは右側の会話ペインの
       上だけを覆う形にする。header/mainは元々兄弟要素で、#setup-viewはmainの
       子要素なので、CSSのネストだけではこの配置を作れない。mainをdisplay:contents
       で箱を消し、子要素(#setup-view/#chat-view/#entrance-view/#room-empty-state)を
       直接#mid-layerのグリッドに参加させることで、HTML/JS側の構造
       (show*系がmain配下の3〜4画面を切り替える、という前提)は変えずに実現する。 */
    #mid-layer {
        display: grid;
        grid-template-columns: clamp(420px, 33vw, 600px) 1fr;
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "sidebar header"
            "sidebar content";
    }
    main { display: contents; }
    #main-header { grid-area: header; }

    /* mainが担っていたガラスパネルの見た目(背景/ぼかし)は、display:contentsで
       箱が無くなる分、サイドバーと会話ペイン側にそれぞれ持たせ直す。 */
    /* 右の会話ペイン(var(--glass-bg) = 白65%)とはっきり区別がつくよう、
       サイドバーだけ黒を薄く重ねて濃くする。 */
    #setup-view {
        grid-area: sidebar;
        min-width: 0;
        background: rgba(255, 255, 255, 0.8);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-right: 1px solid var(--glass-border);
    }

    #chat-view, #entrance-view, #room-empty-state {
        grid-area: content;
        min-width: 0;
        min-height: 0;
        background: var(--glass-bg);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

}

/* #room-empty-stateはPC幅専用の概念なので、モバイル幅ではJSの表示状態に関わらず
   確実に隠す(リサイズでPC→モバイルへ戻る際の取りこぼし対策)。 */
@media (max-width: 899px) {
    #room-empty-state { display: none !important; }
}

.room-prepare-container {
    width: 100%;
    max-width: 400px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeInEntrance 0.5s ease-out;
}

@keyframes fadeInEntrance {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#entrance-status {
    color: #7f8c8d;
    margin-bottom: 24px;
    font-size: 0.95rem;
    font-weight: 500;
}

/* 同期状態インジケーター：待機中はリング+グロー、完了時はチェックマークの描画に切り替わる */
.sync-loader-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
    margin: 12px auto 6px; /* 下部余白を約1/3（16px -> 6px）に狭めて一体感を出す */
    display: flex;
    align-items: center;
    justify-content: center;
}

.sync-loader-glow {
    position: absolute;
    inset: -12px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(46, 125, 50, 0.28) 0%, rgba(46, 125, 50, 0) 70%);
    transition: opacity 0.4s ease-out;
}

.sync-loader-circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2.5px solid rgba(46, 125, 50, 0.15); /* 線も少し細くして繊細に */
    border-top: 2.5px solid var(--color-main);
    border-radius: 50%;
    animation: spinSyncLoader 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    transition: opacity 0.3s ease-out;
}

@keyframes spinSyncLoader {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.sync-loader-check {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sync-loader-check svg { width: 26px; height: 26px; }
.sync-loader-check path {
    fill: none;
    stroke: var(--color-main);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
}

/* 同期完了：リングとグローを消し、チェックマークを描画する */
.sync-loader-wrapper.sync-completed .sync-loader-glow { opacity: 0; }
.sync-loader-wrapper.sync-completed .sync-loader-circle { opacity: 0; animation: none; }
.sync-loader-wrapper.sync-completed .sync-loader-check {
    opacity: 1;
    transform: scale(1);
}
.sync-loader-wrapper.sync-completed .sync-loader-check path {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.5s ease 0.1s;
}

/* 台帳カード：オフライン中の大きな変化(ホスト権限の異動など)を入室前に知らせる。
   相談スレッドに使っている紫(--color-meeting)を、統治的な出来事の色として転用。
   角は意図的に丸めず左のカラーラインを一直線に見せ、他の丸いカードと区別する。 */
.entrance-notice-card {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    background: #fff;
    border-left: 3px solid var(--color-meeting);
    border-radius: 0;
    padding: 14px 16px;
    margin-bottom: 20px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}
.entrance-notice-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(126, 87, 194, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.entrance-notice-icon svg { width: 18px; height: 18px; stroke: var(--color-meeting); }
.entrance-notice-body h4 { margin: 0 0 3px; font-size: 0.85rem; font-weight: 700; color: #2c3e50; }
.entrance-notice-body p { margin: 0; font-size: 0.78rem; line-height: 1.55; color: #7f8c8d; }

/* モダンな未読メッセージカウンターバナー。ロビーで既に件数が見えるようになったため、
   0件の時は目立たせず(is-empty)、実際に新着がある時だけオレンジで注意を引く。 */
.unread-banner-modern {
    background: linear-gradient(135deg, rgba(230, 126, 34, 0.12) 0%, rgba(211, 84, 0, 0.05) 100%);
    border: 1px solid rgba(230, 126, 34, 0.25);
    padding: 10px 18px;
    border-radius: 14px;
    margin-bottom: 28px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #d35400;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(230, 126, 34, 0.03);
    animation: popBanner 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.15);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.unread-banner-modern.is-empty {
    background: rgba(120, 120, 120, 0.08);
    border-color: rgba(120, 120, 120, 0.18);
    color: #8a8f93;
    box-shadow: none;
}

@keyframes popBanner {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.unread-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.entrance-action-btn {
    width: 100%;
    height: 48px !important;
    font-size: 1rem !important;
    border-radius: 24px !important;
    box-shadow: 0 4px 15px rgba(46, 125, 50, 0.2) !important;
    margin-bottom: 48px; /* 間隔を4倍（12px -> 48px）に拡大し、誤操作を防止。この余白は変えない */
}

/* 平常時(通知なし)だけ表示される自動遷移の案内。ボタンの余白(誤操作防止)を保ったまま、
   その帯の下寄りに重ねて置く。文の下に経過バーが来るよう縦積みにする。 */
.entrance-autoline {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    margin: -38px auto 10px;
    font-size: 0.72rem;
    font-weight: 500;
    color: #95a1a6;
}
.entrance-autoline-bar {
    width: 110px;
    height: 3px;
    border-radius: 2px;
    background: rgba(46, 125, 50, 0.18);
    overflow: hidden;
}
#entrance-autoline-bar-fill {
    display: block;
    height: 100%;
    width: 0%;
    background: var(--color-main);
}

.entrance-back-btn {
    border: none !important;
    background: transparent !important;
    color: #95a5a6 !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    height: 36px !important;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.entrance-back-btn:active {
    opacity: 1;
    transform: scale(0.98);
    background: rgba(0,0,0,0.03) !important;
}

/* Typography & Cards */
h2 { font-size: 1.2rem; margin: 1.5rem 0.5rem 1rem; color: #2c3e50; font-weight: 700; }
.hint { font-size: 0.8rem; color: #7f8c8d; line-height: 1.4; margin-bottom: 8px; }

.card {
    background: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    border: 1px solid #f0f0f0;
    margin-bottom: 12px;
    margin-left: 4px;
    margin-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* History List */
.history-item {
    background: white; padding: 16px 88px 16px 16px; border-radius: 18px; margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02); cursor: pointer;
    position: relative;
}
.history-name-row { display: flex; align-items: center; gap: 6px; }
.history-name { font-weight: 700; color: #2c3e50; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.history-role, .member-detail-role { font-size: 0.75rem; font-weight: 600; color: var(--color-main); background: rgba(104, 159, 56, 0.1); padding: 4px 10px; border-radius: 10px; }
.history-role { flex-shrink: 0; }
.history-last-line { display: flex; align-items: baseline; gap: 4px; margin-top: 4px; overflow: hidden; }
.history-meta { flex-shrink: 0; font-size: 0.8rem; color: #7f8c8d; white-space: nowrap; }
.history-preview { font-size: 0.8rem; color: #7f8c8d; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-unread-badge {
    position: absolute; top: 14px; right: 14px;
    padding: 4px 10px; border-radius: 12px; white-space: nowrap;
    font-size: 0.8rem; font-weight: 700;
}
.history-unread-badge.has-unread { background: #e67e22; color: white; }
.history-unread-badge.zero { background: rgba(127, 140, 141, 0.14); color: #7f8c8d; }

/* PC2ペイン表示で今開いているルームを一覧内でハイライトする(history-item.active) */
.history-item.active { box-shadow: 0 0 0 2px var(--color-main), 0 2px 8px rgba(0,0,0,0.02); }

/* Lobby profile card (低優先度: ルーム一覧より控えめな見た目にする) */
.lobby-profile-card {
    display: flex; align-items: center; gap: 12px;
    background: white; padding: 12px 16px; border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    margin: 24px 4px 16px;
    cursor: pointer;
}
.lobby-profile-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lobby-profile-label { font-size: 0.7rem; color: #95a5a6; font-weight: 600; }
.lobby-profile-name {
    font-size: 0.95rem; font-weight: 700; color: #2c3e50;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lobby-profile-chevron { color: #bbb; flex-shrink: 0; display: flex; }

/* Room prepare (最も優先度が低いので見出しも小さく、1カードあたり1行に収める) */
.room-prepare-label {
    font-size: 0.72rem; font-weight: 600; color: #95a5a6;
    margin: 0 8px 6px;
}
.room-prepare-compact { display: flex; flex-direction: column; gap: 8px; margin: 0 4px 16px; }
.prepare-row { display: flex; gap: 8px; }
.prepare-row input { flex: 1; min-width: 0; }
.prepare-row button { flex-shrink: 0; }
.prepare-section-hint { margin: 0 4px 2px; }
.busy-note { margin: 6px 4px 0; }
/* 情報のまとまりの区切りは横線にする(ユーザー方針)。ルームが無い最初の画面では、
   先に置いた「その人が最初にすること」と、2つ目のまとまりを横線で分ける。 */
.room-prepare-section + .room-prepare-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(0,0,0,0.08); }

/* ルームが1件以上ある時は、上の2行フォームの代わりにこの2つのリンク風ボタンだけを見せる
   (タップで#room-prepare-modalが開き、同じ入力欄がボトムシートの中に現れる)。 */
.room-prepare-buttons { display: flex; flex-direction: column; gap: 12px; margin: 0 4px 16px; }
.room-add-link { width: 100%; height: 40px; font-size: 0.85rem; }

/* リカバリコードの促し。以前は下マージンの指定が無く、直後の.room-prepare-buttons(上マージン0)と
   隙間なく密着して見えていた(2026-09-23、実機確認で発見)。他のロビーのカード間隔(16px)に揃える。 */
/* 促しは「あなたの鍵」の話なので、下の「ルームの話」とは横線で分ける(2026-09-24)。 */
.recovery-nudge { margin: 0 4px 16px; padding-bottom: 16px; border-bottom: 1px solid rgba(0,0,0,0.08); }

/* Avatars & Presence */
.avatar {
    width: 40px; height: 40px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: white; flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.avatar.small { width: 28px; height: 28px; font-size: 0.9rem; border-radius: 10px; }
.avatar.active { filter: none; opacity: 1; }
@keyframes pulse-active {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(104, 159, 56, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(104, 159, 56, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(104, 159, 56, 0); }
}
.avatar.resting { filter: grayscale(0.6) opacity(0.5); transform: scale(0.9); box-shadow: none; }

/* Header Info */
#header-user-info { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.header-back-button { background: transparent; border: none; color: white; padding: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* Pickers */
.profile-setup-preview { display: flex; flex-direction: row; align-items: center; gap: 16px; padding: 0 8px; }
#setup-avatar-preview { width: 60px; height: 60px; font-size: 2rem; border-radius: 18px; }
.selection-group { display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
.selection-group label { font-size: 0.85rem; font-weight: 600; color: #5d6d7e; }
.picker { display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px; width: 100%; }
.color-chip, .icon-chip {
    width: 38px; height: 38px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; border: 2px solid transparent; background: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.color-chip.selected, .icon-chip.selected {
    border-color: var(--color-main);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
}

.color-chip.selected::after {
    content: '✓';
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    text-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.color-chip.readonly { cursor: default; }
.color-chip.readonly:not(.selected) {
    opacity: 0.4;
    filter: saturate(0.5);
    transform: scale(0.9);
}
.color-chip.readonly.selected {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: scale(1.05);
    border-color: var(--color-main);
}

.time-inputs.disabled-group { opacity: 0.5; pointer-events: none; filter: grayscale(0.5); }
.time-inputs.disabled-group input { background-color: #f5f7f9; }


/* Chat Messages */
#message-list { flex: 1; padding: 1rem; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.message { display: flex; gap: 10px; align-items: flex-start; max-width: 90%; animation: bubble-up 0.3s ease-out; }

.date-divider {
    align-self: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: #7f8c8d;
    background: rgba(0, 0, 0, 0.06);
    padding: 4px 14px;
    border-radius: 12px;
    margin: 4px 0;
}

/* 「ここから新着メッセージ」の目印。本人だけに見える位置情報であり、既読/未読を
   他人に見せる機能ではないため、通知的な赤色ではなくルームのテーマカラーで
   控えめに(見守りアプリの落ち着いたトーンに合わせる)。 */
.unread-divider {
    align-self: stretch;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--color-main);
}
.unread-divider::before, .unread-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-main);
    opacity: 0.4;
}

/* 2.5: 履歴のページ分割同期中、まだ届いていない古いページがあることを示す一覧先頭の表示 */
.history-loading-indicator {
    align-self: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: #7f8c8d;
    background: rgba(0, 0, 0, 0.06);
    padding: 4px 14px;
    border-radius: 12px;
    margin: 4px 0;
}

/* ルームの歴史(参加/退室/キック/ホスト任命/剥奪)の通知。発言ではないので吹き出しにはせず、
   .date-dividerと同じ「中央寄せの控えめなラベル」の見た目にするが、日付見出しと混同しないよう
   斜体・やや薄い色にして区別する。 */
.system-notice {
    align-self: center;
    max-width: 85%;
    text-align: center;
    font-size: 0.72rem;
    font-style: italic;
    color: #95a1a6;
    margin: 2px 0;
    word-break: break-word;
}

@keyframes bubble-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.message.consecutive { margin-top: -6px; }
.message.consecutive .avatar { visibility: hidden; }
.message.consecutive .msg-info { display: none; }
.message.consecutive .msg-content { border-radius: 18px 18px 18px 18px; }
.message.me.consecutive .msg-content { border-radius: 18px 18px 18px 18px; }

.msg-bubble {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    position: relative;
    align-items: flex-start;
}
.message.me .msg-bubble {
    align-items: flex-end;
}
.msg-info { font-size: 0.72rem; color: #7f8c8d; margin-bottom: 2px; padding: 0 4px; display: flex; flex-direction: row; align-items: center; gap: 8px; opacity: 0.8; }
.msg-nickname { font-weight: 600; color: #5d6d7e; }
/* 2.2: 稼働時間外に送られたメッセージであることを一目でわかるようにする */
.msg-time-offhours { font-weight: 700; color: #e53935; opacity: 1; }

.msg-content {
    background: white; padding: 10px 16px; border-radius: 4px 18px 18px 18px;
    font-size: 0.95rem; box-shadow: 0 2px 6px rgba(0,0,0,0.04); word-break: break-word;
    user-select: none; -webkit-user-select: none;
    /* iOS系WebViewでの長押し時のネイティブな選択/共有コールアウトも抑止する
       (自前の長押し判定でコンテキストメニューを出すため、競合を避ける) */
    -webkit-touch-callout: none;
    position: relative; line-height: 1.5;
    /* 複数行入力で送られた改行をそのまま表示する(デフォルトのnormalは
       改行を空白扱いで詰めてしまう)。連続空白を保持しつつ折り返しもする。 */
    white-space: pre-wrap;
}
.message.me { align-self: flex-end; flex-direction: row-reverse; }
.message.me .avatar, .message.me .msg-nickname { display: none; }
.message.me .msg-info { justify-content: flex-end; }
.message.me .msg-content {
    background: var(--color-main-soft); color: #333333;
    border-radius: 18px 4px 18px 18px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.message.deleted .msg-content {
    background: transparent;
    color: #aab2bd;
    font-style: italic;
    box-shadow: none;
    border: 1px dashed #d1d8e0;
    font-size: 0.85rem;
    padding: 6px 12px;
}
.message.deleted .reaction-container { display: none; }

/* Interaction Menus */
.msg-context-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    background: rgba(44, 62, 80, 0.98);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 4px;
    display: flex;
    gap: 2px;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    white-space: nowrap;
}

.reaction-picker-mini {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    background: white;
    border-radius: 24px;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1001;
    font-size: 1.3rem;
    border: 1px solid #eee;
    white-space: nowrap;
    max-width: 85vw;
}

.reaction-picker-mini hr {
    width: 1px;
    height: 24px;
    background-color: #eee;
    border: none;
    margin: 0 4px;
}

.msg-context-menu.align-right, .reaction-picker-mini.align-right { left: auto; right: 0; }
.msg-context-menu.align-left, .reaction-picker-mini.align-left { left: 0; right: auto; }
.msg-context-menu.show-below, .reaction-picker-mini.show-below { bottom: auto; top: 100%; margin-bottom: 0; margin-top: 4px; }

/* 長押しで開くメッセージ操作メニュー(コピー/返信/削除・復元)。reaction-picker-mini
   (横並び・タップでリアクション)とは役割を分けているため、項目数が増えても
   横幅を気にしなくて良い縦積みのカードにしている。 */
.msg-context-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    background: white;
    border-radius: 14px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    min-width: 120px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1001;
    border: 1px solid #eee;
}

.menu-item {
    color: #5d6d7e;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 10px;
    white-space: nowrap;
    transition: all 0.2s;
}
.menu-item + .menu-item { border-top: 1px solid #f0f2f5; }
.menu-item.danger { color: #ff4d4f; }
.menu-item:active { background: #f0f2f5; color: var(--color-main); }
.menu-item.danger:active { background: #fff0f0; color: #ff4d4f; }

/* Inputs & Forms */
.form-group { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: #5d6d7e; }
input[type="text"], input[type="time"], input[type="password"] {
    width: 100%; padding: 12px 16px; border: 1.5px solid #aab2bd; border-radius: 24px;
    background: white; font-size: 0.95rem; outline: none; transition: all 0.3s;
}
input:disabled { background-color: #f5f7f9; color: #7f8c8d; border-color: #d1d8e0; cursor: not-allowed; }
input:focus { border-color: var(--color-main); box-shadow: 0 0 0 3px rgba(104, 159, 56, 0.15); }

.time-inputs { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.time-input-wrapper { position: relative; flex: 1; }
.time-input-wrapper input { appearance: none; -webkit-appearance: none; padding-right: 32px !important; }
.time-input-wrapper::after {
    content: ''; position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    width: 12px; height: 12px; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6d7e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: center;
}

/* 招待画面: QRコードは白地のまま出す(暗い配色でも読み取れるように)。招待コードは大きく、区切りが見えるように。 */
.invite-qr { width: 200px; max-width: 70%; margin: 12px auto 4px; background: #fff; border-radius: 12px; padding: 6px; }
.invite-qr svg { display: block; width: 100%; height: auto; }
#invite-id-display { text-align: center; font-size: 1.35rem; letter-spacing: 0.08em; font-weight: 600; }
/* 通信を待つ間の小さな回る印(入室画面の回転リングと同じ色・動き)。動きを減らす設定の端末では、ゆっくり回す(止めると、止まっているように見えてしまうため)。 */
.inline-spinner { display: inline-block; width: 22px; height: 22px; vertical-align: middle; border: 2.5px solid rgba(46, 125, 50, 0.15); border-top-color: var(--color-main); border-radius: 50%; animation: spinSyncLoader 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite; }
@media (prefers-reduced-motion: reduce) { .inline-spinner { animation-duration: 3s; } }
.id-card { background: #f8f9fa; padding: 12px; border-radius: 12px; border: 1px solid #e9ecef; font-family: monospace; font-size: 0.7rem; word-break: break-all; color: #2c3e50; }

/* Buttons */
button {
    padding: 0 24px; height: 44px; background-color: var(--color-main); color: white;
    border: none; border-radius: 22px; font-weight: 600; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; white-space: nowrap;
}
button:active { transform: scale(0.96); opacity: 0.9; }
button:disabled { background-color: #bdc3c7; cursor: not-allowed; }

.ghost-button { background-color: transparent !important; color: #5d6d7e !important; border: 1px solid #d1d8e0 !important; }
.danger-button { background-color: #ff8a80 !important; }
.small-button { height: 32px !important; padding: 0 16px !important; font-size: 0.75rem !important; border-radius: 16px !important; }
/* 「次に進む手順」のボタン(リカバリコードを控える・識別コードを見る等)。その画面で今やることなので
   通常の大きさにするが、押すと実際に何かが起きる「実行」(塗りの緑。作成・参加など)とは区別して、
   緑の枠線と緑の文字にする。幅は文字に合わせる(2026-09-24、ユーザー決定)。 */
.step-button { background-color: transparent; color: var(--color-main); border: 1.5px solid var(--color-main); }
.step-button:active { background-color: rgba(46, 125, 50, 0.08); }
/* 説明文のすぐ下に置くときは、文とボタンの間を12pxあける(説明の続きに見えて窮屈だったため)。 */
.hint + .step-button { margin-top: 12px; }

/* パスフレーズの入力欄。最初から見える状態で始め(伏せ字だとスマホで日本語が打てないため)、
   欄の右端に「隠す/表示」を置き、確認欄の下に一致しているかを出す(2026-09-24)。 */
.passphrase-field { position: relative; margin-bottom: 8px; }
.passphrase-field input { padding-right: 72px; }
/* 「隠す」を押したときの伏せ字。欄の種類は変えないので、キーボードは日本語入力のまま(roooom-core.js参照)。 */
.passphrase-field input.is-masked { -webkit-text-security: disc; }
.passphrase-toggle {
    position: absolute; top: 6px; bottom: 6px; right: 6px; height: auto; padding: 0 12px;
    background: transparent; color: #5d6d7e; border: none; border-radius: 16px; font-size: 0.75rem;
}
.passphrase-toggle:active { transform: none; background: rgba(0, 0, 0, 0.05); }
.passphrase-guide { margin: 4px 0 10px; }
.passphrase-match { font-size: 0.8rem; font-weight: 600; margin: 0 4px; min-height: 1.2em; }
.passphrase-match.is-match { color: var(--color-main); }
.passphrase-match.is-mismatch { color: #c0392b; }

/* リカバリコードを発行したあとの欄。控え方のボタンを先に並べ、長いコードの文字は畳んでおく(2026-09-24)。 */
.recovery-result { margin-top: 4px; }
.recovery-result-hint { margin: 4px 0 12px; }
.recovery-save-actions { display: flex; flex-direction: column; gap: 10px; }
.recovery-code-details { margin-top: 14px; }
.recovery-code-details summary { cursor: pointer; font-size: 0.8rem; color: #5d6d7e; padding: 6px 4px; }
.recovery-code-details .id-card { margin-top: 6px; font-size: 0.72rem; }
/* 重要な注意・危険な操作への注意喚起の共通の見た目(オレンジの枠。ユーザー方針 2026-09-24)。
   取り返しのつかないこと(アカウントの置き換え、退室、データの消去、追放、全ログの共有など)を伝える文にだけ使う。
   画面の中の注意書きは .warning-note を付け、確認ダイアログは Dialog.confirm(..., { warning: true }) で同じ見た目になる。 */
.warning-note { margin: 4px 0 10px; padding: 10px 12px; border-radius: 12px; background: #fff4e5; color: #8a4b00; }
#confirm-message.warning-note { margin: 0 0 4px; text-align: left; }
/* 「控えました」の申告は、チェックを入れてから「完了」を押す2段階にする(押し間違い防止。2026-09-24) */
.recovery-saved-check { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; font-size: 0.85rem; color: #2c3e50; line-height: 1.5; cursor: pointer; }
.recovery-saved-check.hidden { display: none; }
.recovery-saved-check input { width: 20px; height: 20px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--color-main); }
.recovery-saved-check + button { margin-top: 12px; }

.icon-button {
    background: transparent !important; border: none !important; padding: 0 !important;
    width: 40px !important; height: 40px !important; color: #5d6d7e !important;
    display: flex !important; align-items: center; justify-content: center; cursor: pointer;
    box-shadow: none !important; flex-shrink: 0;
}

/* Chat UI Specifics */
#chat-header {
    margin: 8px; background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--glass-border); border-radius: 18px;
    padding: 6px 12px; display: flex; justify-content: space-between;
    align-items: center; box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    flex-shrink: 0; position: relative; z-index: 50;
}
#chat-header-left { flex: 1; min-width: 0; display: flex; align-items: center; cursor: pointer; }
#member-list-icons { display: flex; flex-direction: row; align-items: center; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; padding: 4px 0; padding-right: 12px; }
#member-list-icons::-webkit-scrollbar { display: none; }
/* コンテナの余白はコンパクトに保ったまま(padding: 4px 0)、はみ出す装飾だけを
   その余白に収まるサイズへ抑える(影を小さく、王冠をアバター内側寄りに)。 */
#member-list-icons .avatar { margin-right: -12px; border: 2px solid white; position: relative; transition: all 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
#member-list-icons .avatar:hover { transform: translateY(-3px); z-index: 10; }
/* 王冠バッジ: 重なりは常に「後ろのアイコンが前のアイコンの右側に乗る」向きなので、
   左上に置けば隣に隠れる心配がない(z-index調整も不要)。左端は0、上端は既存の
   4pxパディング内に収まる値にして、コンテナのサイズは一切変えない。 */
#member-list-icons .avatar .moderator-badge { top: -3px; left: 0; right: auto; bottom: auto; width: 14px; height: 14px; font-size: 0.6rem; }
#chat-header-right { display: flex !important; flex-direction: row !important; align-items: center; gap: 4px; flex-shrink: 0; }
#input-area { padding: 12px 16px 18px; display: flex; flex-direction: row; align-items: flex-end; gap: 10px; background: rgba(255, 255, 255, 0.5); border-top: 1px solid var(--glass-border); flex-shrink: 0; }
#input-area input { flex: 1; }

/* 角丸・枠線・背景はこのラッパーに持たせ、textarea自体は枠無しにする。
   textareaにoverflow-yのスクロールバーを直接出すと、角丸のカーブに
   食い込んで見える上、paddingを増やしても文字とスクロールバーの間の
   余白が増えるだけでスクロールバー自体の位置は動かない(paddingは
   ネイティブのスクロールバー位置には影響しない)。ラッパー側に
   paddingを持たせることで、スクロールバーが実際に内側へ引っ込む。 */
#input-msg-wrapper {
    flex: 1; display: flex; background: white; border: 1.5px solid #aab2bd;
    border-radius: 24px; padding-right: 10px; transition: all 0.3s;
}
#input-msg-wrapper:focus-within { border-color: var(--color-main); box-shadow: 0 0 0 3px rgba(104, 159, 56, 0.15); }
#input-msg-wrapper:has(#input-msg:disabled) { background-color: #f5f7f9; border-color: #d1d8e0; }

#input-msg {
    flex: 1;
    resize: none;
    /* 複数行入力に対応するtextarea。1行分の高さから、入力に合わせてJS側
       (roooom-ui-chat.js)で最大高さまで自動的に伸ばす。それ以上は
       スクロールにする(入力欄が画面を占有しすぎないように)。スクロールバーは、
       最大高さを超えたときだけJS側でoverflow-y:autoにして出す(既定は出さない。
       1行の高さの端数で、1行でもスクロールバーが出ていたため)。 */
    max-height: 120px;
    overflow-y: hidden;
    line-height: 1.4;
    font-family: inherit;
    border: none; background: transparent; outline: none;
    padding: 12px 6px 12px 16px;
    font-size: 0.95rem;
    color: inherit;
    scrollbar-width: thin;
    scrollbar-color: #c7ccd1 transparent;
}
#input-msg:disabled { color: #7f8c8d; cursor: not-allowed; }
#input-msg::-webkit-scrollbar { width: 6px; }
#input-msg::-webkit-scrollbar-track { background: transparent; margin: 8px 0; }
#input-msg::-webkit-scrollbar-thumb { background-color: #c7ccd1; border-radius: 3px; }

/* Reply (quote) composer preview */
#reply-preview-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.6);
    border-top: 1px solid var(--glass-border);
    flex-shrink: 0;
}
#reply-preview-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #5d6d7e;
}
#reply-preview-content .avatar-tiny { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; flex-shrink: 0; }
.reply-preview-name { font-weight: 700; color: #2c3e50; flex-shrink: 0; }
.reply-preview-snippet { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#btn-cancel-reply { flex-shrink: 0; }

/* Reply (quote) block inside a sent message bubble */
.reply-quote {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid var(--color-main);
    /* border-leftの直線とborder-radiusの丸みが左角でぶつかり、アクセントバーが
       角丸に切り取られて不自然に見えるため、左側は直角のままにして
       右側だけ丸める(アクセントバー付きの引用ブロックの定番パターン)。 */
    border-radius: 0 8px 8px 0;
    padding: 4px 8px;
    margin: 0 0 4px;
    cursor: pointer;
    /* .msg-bubbleはflexカラムでalign-items:flex-start/flex-end(自分の発言は右寄せ)。
       reply-quoteは他の子要素(msg-info/msg-content)より内容が短いことが多く、
       align-itemsのままだと右寄せの自分の発言側でだけ左端がmsg-contentとズレて
       宙に浮いたように見えてしまう。stretchで常にバブルの幅いっぱいに揃える。 */
    align-self: stretch;
}
.reply-quote-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.reply-quote-head .avatar-tiny { width: 16px; height: 16px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.6rem; flex-shrink: 0; }
.reply-quote-name { font-size: 0.7rem; font-weight: 700; color: #5d6d7e; }
.reply-quote-body {
    font-size: 0.75rem;
    color: #5d6d7e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.reply-quote.expanded .reply-quote-body { white-space: normal; overflow: visible; }
.reply-quote-date { display: none; font-size: 0.65rem; color: #7f8c8d; margin-top: 2px; }
.reply-quote.expanded .reply-quote-date { display: block; }
.reply-quote.quote-deleted { font-style: italic; }
/* 相談: 入口はヘッダー右のピル。相談スペースの間だけ、通常のヘッダーを相談用のヘッダーに
   差し替える(body.space-consultationはswitchSpace()が付ける)。 */
#btn-open-consult { gap: 4px; position: relative; padding: 0 12px !important; }
.consult-dot { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: #e53935; border: 2px solid white; box-sizing: content-box; }
.consult-dot.has-count { top: -6px; right: -6px; width: auto; min-width: 12px; height: 12px; padding: 0 3px; border-radius: 10px; color: white; font-size: 0.65rem; line-height: 12px; text-align: center; }
#consult-header { display: none; margin: 8px; padding: 6px 8px; align-items: center; gap: 4px; background: rgba(255, 243, 224, 0.95); border: 1px solid rgba(239, 108, 0, 0.25); border-radius: 18px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); flex-shrink: 0; }
body.space-consultation #consult-header { display: flex; }
body.space-consultation #chat-header { display: none; }
#consult-header-text { flex: 1; min-width: 0; }
#consult-header-title-row { display: flex; align-items: center; gap: 2px; }
#consult-header-title { font-size: 0.9rem; font-weight: 700; color: #e65100; }
.icon-button.consult-info-btn { width: 24px !important; height: 24px !important; color: #e65100 !important; }
#consult-header-sub { font-size: 0.7rem; color: #8d6e63; }
#consult-recipients { display: flex; flex-direction: row; align-items: center; flex-shrink: 0; padding-left: 8px; padding-right: 8px; }
#consult-recipients .avatar { width: 28px; height: 28px; font-size: 0.9rem; border-radius: 10px; margin-left: -8px; border: 2px solid white; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
#consult-notice { display: none; margin: 8px 12px 0; padding: 8px 12px; font-size: 0.75rem; line-height: 1.5; color: #8d6e63; background: rgba(255, 224, 178, 0.5); border-radius: 12px; flex-shrink: 0; }
body.space-consultation #consult-notice { display: block; }

/* 相談の受信シート(リーダー用): メンバーごとの最新の一言と未読を並べる。
   旧「相談者を選択」の横並びチップ列は、この一覧に置き換えた。 */
#consult-inbox-modal .bottom-sheet { height: 62dvh; }
.consult-inbox-list { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.consult-inbox-heading { font-size: 0.75rem; font-weight: 700; color: #8d6e63; margin: 10px 4px 0; }
.consult-inbox-empty { padding: 24px 8px; text-align: center; font-size: 0.85rem; color: #7f8c8d; }
.consult-inbox-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #f8f9fa; cursor: pointer; }
.consult-inbox-item:active { background: #eef1f4; }
.consult-inbox-item.unread { background: #fff3e0; }
.consult-inbox-item .avatar-tiny { width: 28px; height: 28px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 0.9rem; flex-shrink: 0; }
.consult-inbox-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.consult-inbox-name { font-size: 0.85rem; font-weight: 700; color: #2c3e50; }
.consult-inbox-snippet { font-size: 0.75rem; color: #7f8c8d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.consult-inbox-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.consult-inbox-time { font-size: 0.65rem; color: #95a5a6; }
/* 相談の説明シート(初回と「ⓘ」)。宛先のリーダーのアイコンを見せ、要点を並べる。 */
#consult-intro-modal .bottom-sheet { height: 80dvh; }
.consult-intro-body { display: flex; flex-direction: column; gap: 14px; font-size: 0.85rem; line-height: 1.6; color: #2c3e50; }
.consult-intro-lead { font-size: 0.95rem; font-weight: 700; color: #e65100; margin: 0; }
.consult-intro-recipients { display: flex; flex-direction: row; align-items: center; gap: 6px; flex-wrap: wrap; }
.consult-intro-recipient { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 16px; background: #fff3e0; font-size: 0.8rem; font-weight: 600; color: #8d6e63; }
.consult-intro-recipient .avatar { width: 26px; height: 26px; font-size: 0.85rem; border-radius: 9px; box-shadow: none; }
.consult-intro-points { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 8px; }
.consult-intro-help { margin: 0; padding: 10px 12px; border-radius: 12px; background: #f8f9fa; font-size: 0.8rem; color: #5d6d7e; }
.consult-inbox-badge { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #e53935; color: white; font-size: 0.65rem; line-height: 16px; text-align: center; box-sizing: border-box; }

.modal-actions { display: flex !important; flex-direction: row !important; justify-content: flex-end !important; gap: 12px !important; margin-top: 20px !important; width: auto !important; align-self: flex-end !important; }
.modal-actions button { width: auto !important; min-width: 100px !important; flex: none !important; }

/* Icons */
.icon { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex-shrink: 0; pointer-events: none; }
.icon svg { width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* Host Absence */
header { transition: background-color 0.3s; }



/* Modals & Overlays */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000; pointer-events: auto;
}
.modal-content {
    background: white; padding: 24px; border-radius: 24px;
    width: 90%; max-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    display: flex; flex-direction: column; gap: 16px;
    max-height: 92dvh;
}

/* Bottom Sheet (中央に浮く角丸カードではなく、画面下からせり上がるシートにすることで、
   ネイティブアプリのシート/設定画面に近い見た目にする)。
   高さは中身に合わせて自動で伸び縮みさせず、モーダルごとに固定値で指定する
   (ドリルダウンなど画面内で表示が切り替わるものは、切り替えるたびにシートの高さが
   変わって視線が上下に揺れる問題があったため)。 */
.bottom-sheet-modal { align-items: flex-end; }
.bottom-sheet {
    width: 100%; max-width: 480px; margin: 0 auto;
    border-radius: 24px 24px 0 0;
    overflow: hidden;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    animation: bottom-sheet-slide-up 0.25s ease-out;
}
#search-modal .bottom-sheet { height: 75dvh; }
#member-list-modal .bottom-sheet { height: 65dvh; }
/* プロフィール設定・ルーム設定は項目が多く(プロフィール: ニックネーム+カラー16色+
   アイコン20種。ルーム設定: 名前+カラー+時間をドリルダウン解除して一覧に直置きした)、
   ソフトキーボード表示時でも.modal-scroll-bodyのスクロール領域を十分に確保できるよう
   他のボトムシートより高さの余裕を大きく取る。 */
#profile-modal .bottom-sheet, #room-settings-modal .bottom-sheet { height: 88dvh; }
#create-room-modal .bottom-sheet, #join-room-modal .bottom-sheet { height: 42dvh; }
/* 招待は、QRコード・招待コード・2つのボタンまで一度に見える高さにする(中身は約540px。準備中の回る印の間も同じ高さのまま)。
   それより低い画面では、シートの中をスクロールして下のボタンまで届くようにする。 */
#invite-modal .bottom-sheet { height: min(620px, 90dvh); overflow-y: auto; }
@keyframes bottom-sheet-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.bottom-sheet.closing {
    animation: bottom-sheet-slide-down 0.2s ease-in forwards;
}
@keyframes bottom-sheet-slide-down {
    from { transform: translateY(0); }
    to { transform: translateY(100%); }
}

/* Modal header (戻る/タイトル/閉じる)。ボトムシート全体で見た目を揃えるための共通ヘッダー。
   スワイプで閉じる機能は実装していないため、それを連想させる最上部のハンドルバーは置かず、
   閉じる操作は常にヘッダーの「閉じる」ボタンで明示する。 */
/* 戻るボタン(40px)の有無でヘッダーの行の高さ自体が変わると、タイトルや閉じるボタンの
   縦位置がドリルダウンのたびにずれて見えるため、min-heightで高さを固定する。
   横方向は戻るボタンをdisplay:noneで完全に消し、ルート画面(戻るボタンが無い状態)では
   タイトルが左端に来るようにする(場所を確保すると、戻るボタンが要らない画面でも
   タイトルが常に右にずれてしまうため)。 */
.modal-header { display: flex; align-items: center; gap: 4px; flex-shrink: 0; min-height: 40px; }
.modal-header h2, .modal-header h3 { flex: 1; margin: 0; font-size: 1.05rem; }
.modal-header .btn-sheet-close { margin-left: auto; }

/* Settings List + Drilldown */
.settings-view { display: flex; flex-direction: column; gap: 12px; }
.settings-row {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px;
    border-radius: 16px; background: #f8f9fa; border: 1px solid #eee; cursor: pointer;
}
.settings-row:active { background: #eef1f4; }
.settings-row-label { flex: 1; font-weight: 600; color: #2c3e50; font-size: 0.9rem; }
.settings-row-label.danger-text { color: #ff4d4f; }
.settings-row-chevron { color: #bfc7d1; flex-shrink: 0; }
.settings-separator { height: 1px; background: #eee; margin: 4px 2px; }
/* .modal-actionsのwidth:auto/align-self:flex-endは「幅を内容にフィットさせて右寄せ」
   なので、ここに引いた区切り線もボタン幅ぶんしかない短い線になってしまう。
   幅いっぱいに広げ、ボタン自体は引き続きjustify-content:flex-endで右寄せにする。 */
#settings-list-footer { flex-shrink: 0; align-self: stretch !important; width: 100% !important; border-top: 1px solid #eee; padding-top: 16px; }

/* 中身が縦に長いモーダル(ルーム設定など)では、外側の角丸コンテナに直接
   overflow-y:autoを付けるとスクロールバーが角丸の内側で境界線と重なって
   見えるため、スクロールは内側のこのラッパーだけに持たせる。 */
.modal-scroll-body {
    display: flex; flex-direction: column; gap: 16px;
    overflow-y: auto; padding-right: 4px;
    min-height: 0; flex: 1 1 auto;
}

/* 確認/通知ダイアログ(#confirm-modal)は、任命・剥奪・退室してもらう等のように
   他のモーダル(メンバー一覧など)を開いた状態から呼ばれることがある。他の.modalと
   z-indexが同じだと、同値時はDOM順が後のものが上に来てしまい、確認ダイアログより後に
   書かれたモーダルの背景がクリックを奪ってOKが押せなくなる(実際に発生していた不具合)。
   常に最前面に来るよう明示的に高いz-indexを与える。 */
#confirm-modal { z-index: 2100; }

/* Member Detail List in Modal (スクロールは親の.modal-scroll-bodyが担当) */
.member-detail-list { display: flex; flex-direction: column; gap: 12px; }
.member-detail-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; background: #f8f9fa; border: 1px solid #eee; }
.member-detail-item.clickable { cursor: pointer; }
.member-detail-item.clickable:active { background: #eef1f4; }
.member-detail-info { flex: 1; display: flex; flex-direction: column; }
.member-detail-name { font-weight: 700; color: #2c3e50; font-size: 0.95rem; }
/* ロビーの.history-role(部屋一覧の「ホスト/メンバー」チップ)と表記だけでなく見た目も揃える。
   ここは縦積みのflexカラムの中にあるため、align-self:flex-startが無いと横幅いっぱいに
   伸びてしまう(.history-roleは横並びflexの中にあるため元々その心配が無い)。 */
.member-detail-role { align-self: flex-start; margin-top: 2px; }

/* Message Search (スクロールは親の.modal-scroll-bodyが担当) */
.search-result-list { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.search-result-item {
    display: flex; align-items: flex-start; gap: 10px; padding: 10px;
    border-radius: 16px; background: #f8f9fa; border: 1px solid #eee; cursor: pointer;
}
.search-result-item:active { background: #eef1f4; }
.search-result-item .avatar-tiny { flex-shrink: 0; margin-top: 2px; }
.search-result-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.search-result-name { font-weight: 700; color: #2c3e50; font-size: 0.85rem; }
.search-result-snippet {
    font-size: 0.85rem; color: #333; overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.search-result-date { font-size: 0.7rem; color: #7f8c8d; }
.search-empty { text-align: center; color: #7f8c8d; font-size: 0.85rem; padding: 20px 0; }

/* 検索結果から発言までジャンプした際、一時的にハイライトして分かりやすくする */
.message.highlight-flash .msg-content { animation: highlight-flash-anim 1.5s ease-out; }
@keyframes highlight-flash-anim {
    0% { box-shadow: 0 0 0 4px rgba(104, 159, 56, 0.5); }
    100% { box-shadow: 0 2px 6px rgba(0,0,0,0.04); }
}

/* Toast Notifications */
#notification-area { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; z-index: 3000; pointer-events: none; }
.toast {
    background: rgba(44, 62, 80, 0.9); color: white; padding: 12px 24px;
    border-radius: 20px; font-size: 0.85rem; font-weight: 500;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    animation: toast-in 0.3s ease-out;
    pointer-events: auto;
}

/* リアクション関連のデザインを復元 */
.reaction-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: -2px;
    padding: 0 4px;
    margin-bottom: 4px;
    z-index: 10;
}

.reaction-badge {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1.5px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    animation: reaction-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.reaction-badge.mine {
    background: rgba(255, 255, 255, 1);
    border-color: var(--color-main);
    box-shadow: 0 2px 8px rgba(104, 159, 56, 0.2);
}

.reaction-badge:active { transform: scale(0.9); }

.reaction-avatars { display: flex; align-items: center; }

.reaction-badge .avatar-tiny {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    flex-shrink: 0;
    border: 1.5px solid rgba(255, 255, 255, 0.9);
}

.reaction-badge .avatar-tiny:not(:first-child) { margin-left: -6px; }

.reaction-more-count {
    font-size: 0.65rem;
    font-weight: 600;
    color: #5d6d7e;
    margin-left: 2px;
}

@keyframes reaction-pop { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }


/* 役割の印: 円の中に、モデレーター=ハート(緑)、キーメーカー=鍵(金)。色だけでなく中の絵でも区別する。王冠は使わない。 */
.moderator-badge.role-badge-moderator { border: 2px solid #2E9E63; padding: 2px; box-sizing: border-box; }
.moderator-badge.role-badge-keymaker { border: 2px solid #C99A1B; padding: 2px; box-sizing: border-box; }
.moderator-badge svg { display: block; }
#header-avatar-top { position: relative; }
#header-avatar-top .moderator-badge { bottom: -3px; right: -3px; }
#member-list-icons .avatar .moderator-badge { padding: 1px; }
