/* Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&family=Noto+Sans+JP:wght@300;400;500&display=swap');

/* ══════════════════════════════════════════════
   TOKENS
══════════════════════════════════════════════ */
:root {
    --bg: #0d0f14;
    --surface: #13161e;
    --surface-2: #1a1e28;
    --surface-3: #222737;
    --surface-4: #2a2f42;
    --border: rgba(255, 255, 255, .07);
    --border-hi: rgba(255, 255, 255, .15);
    --accent: #5b8def;
    --accent-glow: rgba(91, 141, 239, .18);
    --accent-2: #e0875c;
    --accent-3: #6edea4;
    --text-1: #e8eaf0;
    --text-2: #8891a8;
    --text-3: #525a6e;
    --secret: #c47de8;
    --secret-bg: rgba(196, 125, 232, .08);
    --dice: #f0c060;
    --dice-bg: rgba(240, 192, 96, .08);
    --red: #ef5050;

    --r: 10px;
    --r-sm: 6px;
    --sidebar-w: 340px;
    /* 後方互換用（廃止予定） */
    --right-w: 340px;
    /* 右側ペイン幅（リサイズで変化） */
    --header-h: 48px;
    /* 初期値: PC で 5:5 比率。JS が読み込まれ次第上書きされる */
    --stage-h: calc(50vh - 51px);
    --mic-bar-h: 48px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: 'DM Sans', 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--text-1);
    font-size: 14px;
}

/* ══════════════════════════════════════════════
   DESKTOP LAYOUT  (>700px)
   header  | header
   main    | rsz | right-pane
              （right-pane内でステージ・縦リサイズ・右下を縦積み）
══════════════════════════════════════════════ */
.app {
    display: grid;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-columns: 1fr 5px var(--right-w);
    grid-template-areas:
        'hdr  hdr   hdr'
        'main rsz   right';
    height: 100vh;
}

/* ── Header ── */
header {
    grid-area: hdr;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.logo {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}


.logo-img {
    height: 22px;
    width: auto;
    display: block;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: .3
    }
}

.sess-title {
    font-size: 12.5px;
    color: var(--text-2);
    border-left: 1px solid var(--border-hi);
    padding-left: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── BCDice ゲームシステム カスタムドロップダウン（sess-title 横）── */
.dice-system-wrap {
    position: relative;
    flex-shrink: 1;
}

.dice-system-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-family: inherit;
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    color: var(--text-2);
    padding: 3px 8px;
    cursor: pointer;
    max-width: 160px;
    min-width: 60px;
    transition: border-color .15s, color .15s;
}

.dice-system-btn:hover,
.dice-system-btn:focus {
    border-color: var(--accent);
    color: var(--text-1);
    outline: none;
}

.dice-system-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.dice-system-arrow {
    font-size: 9px;
    flex-shrink: 0;
    color: var(--text-3);
    transition: transform .15s;
}

.dice-system-wrap.open .dice-system-arrow {
    transform: rotate(180deg);
}

.dice-system-drop {
    position: fixed;
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--r);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
    z-index: 600;
    width: 240px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dice-system-drop.hidden {
    display: none;
}

.dice-system-search-wrap {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.dice-system-search {
    width: 100%;
    background: var(--surface-3);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-size: 12px;
    font-family: inherit;
    padding: 4px 8px;
    outline: none;
    box-sizing: border-box;
}

.dice-system-search:focus {
    border-color: var(--accent);
}

.dice-system-list {
    overflow-y: auto;
    max-height: 240px;
    padding: 4px;
}

.dice-system-list::-webkit-scrollbar {
    width: 3px;
}

.dice-system-list::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 2px;
}

.dice-system-item {
    padding: 5px 8px;
    border-radius: var(--r-sm);
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    transition: background .1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dice-system-item:hover {
    background: var(--surface-3);
    color: var(--text-1);
}

.dice-system-item.active {
    background: var(--accent-glow);
    color: var(--accent);
}

.hdr-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}


.btn {
    padding: 5px 11px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border-hi);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.btn:hover {
    background: var(--surface-3);
    color: var(--text-1);
}

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 500;
}

.btn-accent:hover {
    background: #6e9ef5;
}

/* ══════════════════════════════════════════════
   MAIN COLUMN  (log + bottom panel)
══════════════════════════════════════════════ */
main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Log */
.log-area {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    position: relative;
}

/* ログが少ないときでも下端から積み上げるためのスペーサー */
.log-area::before {
    content: '';
    flex: 1;
}

.log-area::-webkit-scrollbar {
    width: 3px;
}

.log-area::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 2px;
}

/* タブ別ログエリア背景色（微妙に差をつける） */
.log-area[data-active-tab="log"] {
    background: linear-gradient(160deg, rgba(91, 141, 239, .03) 0%, transparent 60%);
}

.log-area[data-active-tab="sublog"] {
    background: linear-gradient(160deg, rgba(110, 222, 164, .03) 0%, transparent 60%);
}

.log-area[data-active-tab="info"] {
    background: linear-gradient(160deg, rgba(240, 192, 96, .03) 0%, transparent 60%);
}

/* Log entries are now rendered via .log-entry (see below) */

/* ── Bottom panel ── */
.bottom-panel {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    position: relative;
}

.tab-row {
    display: flex;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 8px 13px 7px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-3);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all .15s;
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
}

.tab.active {
    color: var(--accent);
    border-color: var(--accent);
}

.tab:hover:not(.active) {
    color: var(--text-2);
}

/* 未読バッジ: アクティブでないタブに新着ログがあるとき */
.tab.has-unread {
    color: var(--text-2);
    position: relative;
}

.tab.has-unread::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef5050;
    box-shadow: 0 0 5px rgba(239, 80, 80, .7);
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    padding: 8px 12px 10px;
}

.textarea-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r);
    transition: border-color .15s;
    overflow: hidden;
    min-width: 0;
}

.textarea-wrap:focus-within {
    border-color: var(--accent);
}

.ta-top {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 3px;
    border-bottom: 1px solid var(--border);
}

.scene-row-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-3);
    white-space: nowrap;
}

.type-sel {
    color: var(--text-3);
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.ta-div {
    width: 1px;
    height: 14px;
    background: var(--border);
}

.msg-textarea {
    width: 100%;
    background: none;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-1);
    padding: 7px 10px;
    line-height: 1.55;
    min-height: 62px;
    white-space: pre-wrap;
}

.msg-textarea::placeholder {
    color: var(--text-3);
}

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--r-sm);
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all .15s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #6e9ef5;
}

/* 送信ボタン列（チェックボックス + 送信ボタン） */
.send-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

/* カスタムタブ時のメインログ残すチェックボックス */
.main-log-check {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    color: var(--text-2);
    font-size: 9px;
    gap: 2px;
    line-height: 1.1;
    white-space: nowrap;
}

.main-log-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
    margin: 0;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all .15s;
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--surface-3);
    color: var(--text-1);
    border-color: var(--border-hi);
}

/* ══════════════════════════════════════════════
   SIDEBAR  (desktop right column)
══════════════════════════════════════════════ */
/* ── 右側ペイン（ステージ・縦リサイズ・右下をまとめる列） ── */
.right-pane {
    grid-area: right;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
}

/* ── 右下エリア（マイク + キャラクター選択） ── */
.bottom-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Resize handle（左右：mainと右ペインの間） ── */
.resize-handle {
    grid-area: rsz;
    background: var(--border);
    cursor: col-resize;
    transition: background .15s;
    z-index: 10;
}

.resize-handle:hover {
    background: var(--border-hi);
}

/* ── 縦リサイズハンドル（ステージ ↔ 右下エリア）── */
.v-resize-handle {
    flex: 0 0 5px;
    position: relative;
    /* z-index を有効にしてステージコンテンツより前面に出す */
    background: var(--border);
    cursor: row-resize;
    transition: background .15s;
    z-index: 10;
}

.v-resize-handle:hover {
    background: var(--border-hi);
}

/* ── Novel Stage ── */
.novel-stage {
    flex: 0 0 var(--stage-h);
    position: relative;
    background: #090b10;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.stage-bg {
    position: absolute;
    inset: 0;
    /* 背景画像は比率を保って表示（余白は黒）*/
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #000;
    opacity: 0;
    transition: opacity .5s;
    z-index: 0;
}

.novel-stage::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 100% 50% at 50% 120%, rgba(91, 141, 239, .1) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
}

.stage-toolbar {
    position: relative;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 7px 8px 0;
}

.stage-label {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--text-3);
}

.stage-tools {
    display: flex;
    gap: 4px;
}

.stool {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: rgba(10, 12, 17, .6);
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    backdrop-filter: blur(4px);
}

.stool:hover {
    background: rgba(26, 30, 40, .9);
    color: var(--text-1);
    border-color: var(--border-hi);
}

.stage-chars {
    /* .novel-stage（flex column）内でスペースを占有する */
    flex: 1;
    min-height: 0;
    min-width: 0;
    /* .stage-chara（position:absolute）の基準コンテナ */
    position: relative;
    z-index: 2;
    /* JS で計算した位置を超えた分はここでクリップ */
    overflow: hidden;
}

/* キャラ1体分。JS が left（中心px）を設定して中央グループ配置する */
.stage-chara {
    position: absolute;
    bottom: 0;
    /* left は JS で中心 px を設定。translateX(-50%) で中心基準に揃える */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    height: calc(var(--stage-h) * 0.8);
    min-height: 60px;
    cursor: pointer;
    transition: transform .28s ease, filter .28s ease;
    transform-origin: bottom center;
    overflow: visible;
}

.stage-chara.dim {
    filter: brightness(.35) saturate(.3);
    transform: translateX(-50%) scale(.93);
}

.stage-chara.speaking {
    transform: translateX(-50%) scale(1.05) translateY(-4px);
}

.stage-chara.speaking::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .85);
    box-shadow: 0 0 10px rgba(255, 255, 255, .7), 0 0 20px rgba(255, 255, 255, .3);
}

.char-fig {
    /* 高さを親（stage-char）に合わせて引き伸ばし、縦横比は画像任せ */
    flex: 1;
    min-height: 0;
    /* flexbox で height:100% を子に正しく伝えるために必要 */
    width: auto;
    /* 横幅は中身の画像に合わせる（透過PNG前提のためトリミングしない）*/
    min-width: 40px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-size: 28px;
    position: relative;
    overflow: visible;
    /* トリミングしない */
    background: transparent;
    /* 背景色なし（通常時） */
}

.char-fig-name {
    font-size: 8.5px;
    font-weight: 600;
    color: var(--text-1);
    letter-spacing: .3px;
    padding: 3px 5px;
    text-align: center;
    transition: color .2s;
    background: var(--bg);
}

.stage-chara.speaking .char-fig-name {
    color: #fff;
}

/* Mic bar (右下エリアの上部) */
.mic-bar {
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    height: var(--mic-bar-h);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px 8px;
    border-top: 1px solid var(--border);
    background: rgba(10, 12, 17, .62);
    backdrop-filter: blur(6px);
}

.mic-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-hi);
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    transition: all .2s;
    flex-shrink: 0;
    position: relative;
}

.mic-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* recording = green pulse */
.mic-btn.on {
    background: rgba(110, 222, 164, .1);
    border-color: var(--accent-3);
    color: var(--accent-3);
    animation: mic-rec 1.4s infinite;
}

/* muted / stopped = red static */
.mic-btn.mic-muted {
    background: rgba(239, 80, 80, .08);
    border-color: var(--red);
    color: var(--red);
}

.mic-dot {
    position: absolute;
    top: -1px;
    right: -1px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent-3);
    border: 2px solid var(--bg);
    opacity: 0;
    transition: opacity .2s;
}

.mic-btn.on .mic-dot {
    opacity: 1;
}

.transcript-area {
    flex: 1;
    height: 36px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: rgba(26, 30, 40, .55);
    display: flex;
    align-items: center;
    padding: 0 10px;
    overflow: hidden;
}

.t-placeholder {
    color: var(--text-3);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.t-live {
    color: var(--text-1);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.t-live em {
    color: var(--accent-3);
    font-style: normal;
    margin-right: 4px;
}

/* My character panel */
.my-char-panel {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 10px 10px 12px;
    gap: 8px;
}

.mcp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.panel-label {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--text-3);
}

.mcp-scroll {
    flex: 1;
    min-height: 0;
    /* flex内でスクロール可能にする */
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding-right: 2px;
}

.mcp-scroll::-webkit-scrollbar {
    width: 3px;
}

.mcp-scroll::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 2px;
}

.char-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 9px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
    transition: all .15s;
}

.char-card:hover {
    background: var(--surface-3);
    border-color: var(--border-hi);
}

.char-card.sel {
    border-color: rgba(91, 141, 239, .7);
    background: rgba(91, 141, 239, .15);
    box-shadow: 0 0 0 1px rgba(91, 141, 239, .4), 0 0 10px rgba(91, 141, 239, .25);
}

.cc-thumb {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--border);
    font-size: 16px;
}

.cc-info {
    flex: 1;
    min-width: 0;
}

.cc-name {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cc-sub {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 2px;
}

/* チェックマーク: 非表示（発光エフェクトで選択状態を示すため不要） */
.cc-check {
    display: none;
}

/* Inputs (profile UI generated by app.js) */
input[type='text'],
select {
    appearance: none;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 7px 9px;
    font-size: 12.5px;
    background: var(--surface-2);
    color: var(--text-1);
    font-family: inherit;
    outline: none;
    transition: border-color .15s, background-color .15s;
}

input[type='text']:focus,
select:focus {
    border-color: rgba(91, 141, 239, .5);
}

/* Make the profile UI wrapper blend into panel even if inline styles exist */
#startBtn {
    font-family: inherit;
}

/* Responsive: mobile */
@media (max-width: 700px) {
    :root {
        --stage-h: 180px;
        /* モバイルは固定値（少し小さく） */
    }

    /* モバイルは縦積み: ヘッダー → ステージ → ログ+入力 → マイク
       JS の layoutComponents が novel-stage と mic-bar を .app の直接子に移動する */
    .app {
        grid-template-rows: 44px var(--stage-h) 1fr var(--mic-bar-h);
        grid-template-columns: 1fr;
        grid-template-areas:
            'hdr'
            'stage'
            'main'
            'mic';
    }

    header {
        height: 44px;
        padding: 0 12px;
    }

    main {
        grid-area: main;
    }

    /* JS に移動された後の novel-stage と mic-bar に grid-area を割り当て */
    .novel-stage {
        grid-area: stage;
        height: var(--stage-h);
        flex: none;
    }

    .mic-bar {
        grid-area: mic;
        height: var(--mic-bar-h);
    }

    /* right-pane はモバイルでは非表示（コンテンツを app 直下に移動済み） */
    .right-pane {
        display: none;
    }

    .sidebar {
        display: none;
    }

    .resize-handle {
        display: none;
    }

    /* モバイルでは縦リサイズハンドルを非表示 */
    .v-resize-handle {
        display: none;
    }

    /* ステージ内ツールバーを非表示（背景・BGMはツールメニューFABから操作） */
    .novel-stage .stage-toolbar {
        display: none;
    }

    /* svp ドロワーをスマホで非表示 */
    .svp-drawer {
        display: none;
    }

    /* シーン投稿行を非表示（ツールメニューFABから操作） */
    .scene-row {
        display: none;
    }

    /* タブ行: 横スクロール可能に（タブが多い場合に対応） */
    .tab-row {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .tab-row::-webkit-scrollbar {
        display: none;
    }

    /* ログタブバナーを非表示（スペース確保） */
    .log-tab-banner {
        display: none;
    }

    /* マイクバー: マイクボタンを大きく・タップしやすく */
    .mic-btn {
        width: 56px;
        height: 56px;
        border-radius: 50%;
    }

    /* ヘッダーアバターを非表示（スペース確保） */
    .avatars {
        display: none;
    }

    /* モバイル用ツールFAB（常に非表示→スマホで表示） */
    .mobile-tool-toggle {
        display: flex;
        position: fixed;
        bottom: 140px;
        /* mobile-char-toggle の上 */
        right: 14px;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--surface-3);
        border: 1px solid var(--border-hi);
        color: var(--text-1);
        font-size: 18px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 300;
        box-shadow: 0 4px 16px rgba(0, 0, 0, .45);
        transition: transform .15s, background .15s;
    }

    .mobile-tool-toggle:hover {
        background: var(--surface-4);
        transform: scale(1.07);
    }
}

/* ══ スマホ用ツールメニューパネル（全解像度で定義、スマホ以外はポインターイベントなし） ══ */

/* デスクトップでは mobile 専用要素を非表示 */
.mobile-tool-toggle {
    display: none;
}

/* ツールメニューオーバーレイ（背景暗幕） */
.mobile-tool-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 320;
}

.mobile-tool-overlay.open {
    display: block;
}

/* ツールメニューパネル（画面下から出るスライドアップ） */
.mobile-tool-panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-2);
    border-top: 1px solid var(--border-hi);
    border-radius: 16px 16px 0 0;
    padding: 0 16px 24px;
    z-index: 330;
    gap: 12px;
    transform: translateY(100%);
    transition: transform .25s ease;
    pointer-events: none;
}

.mobile-tool-panel.open {
    transform: translateY(0);
    pointer-events: auto;
}

/* パネル上部のドラッグハンドル */
.mobile-tool-panel-handle {
    width: 36px;
    height: 4px;
    background: var(--border-hi);
    border-radius: 2px;
    margin: 10px auto 4px;
    flex-shrink: 0;
}

/* ツールボタン群（横並び） */
.mobile-tool-items {
    display: flex;
    gap: 10px;
}

.mobile-tool-item {
    flex: 1;
    padding: 14px 8px;
    background: var(--surface-3);
    border: none;
    border-radius: var(--r);
    color: var(--text-1);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: background .15s;
}

.mobile-tool-item:hover {
    background: var(--surface-4);
}

.mobile-tool-item i {
    font-size: 20px;
    color: var(--accent);
}

/* シーン投稿フォーム */
.mobile-scene-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mobile-scene-wrap .scene-input {
    flex: 1;
}

/* 閉じるボタン */
.mobile-tool-close {
    background: none;
    border: none;
    color: var(--text-2);
    font-size: 13px;
    padding: 6px;
    cursor: pointer;
    align-self: center;
}

@keyframes mic-ring {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 80, 80, .35);
    }

    50% {
        box-shadow: 0 0 0 7px rgba(239, 80, 80, 0);
    }
}

@keyframes mic-rec {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(110, 222, 164, .35);
    }

    50% {
        box-shadow: 0 0 0 7px rgba(110, 222, 164, 0);
    }
}

/* ══════════════════════════════════════════════
   HAMBURGER MENU
══════════════════════════════════════════════ */
.menu-wrap {
    position: relative;
}

.menu-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border-hi);
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all .15s;
}

.menu-btn:hover,
.menu-btn.open {
    background: var(--surface-3);
    color: var(--text-1);
}

.menu-drop {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 200px;
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--r);
    padding: 6px;
    z-index: 200;
    display: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .45);
}

.menu-btn.open+.menu-drop {
    display: block;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    color: var(--text-2);
    font-size: 12.5px;
    cursor: pointer;
    transition: all .15s;
}

.menu-item:hover {
    background: var(--surface-3);
    color: var(--text-1);
}

.menu-item.danger {
    color: var(--red);
}

.menu-item.danger:hover {
    background: rgba(239, 80, 80, .1);
}

.menu-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.mi-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
}

/* ══════════════════════════════════════════════
   SCENE ROW
══════════════════════════════════════════════ */
.scene-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px 6px;
    border-bottom: 1px solid var(--border);
}

.scene-input {
    flex: 1;
    min-width: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-family: inherit;
    font-size: 12px;
    padding: 5px 9px;
    outline: none;
    transition: border-color .15s;
}

.scene-input:focus {
    border-color: var(--accent-3);
}

input::placeholder {
    color: var(--text-3);
}

.scene-post-btn {
    padding: 5px 10px;
    border-radius: var(--r-sm);
    border: 1px solid rgba(110, 222, 164, .3);
    background: rgba(110, 222, 164, .06);
    color: var(--accent-3);
    font-size: 11.5px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
    font-weight: 500;
}

.scene-post-btn:hover {
    background: rgba(110, 222, 164, .14);
    border-color: var(--accent-3);
}

/* ══════════════════════════════════════════════
   LOG ENTRIES
══════════════════════════════════════════════ */
@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.log-entry {
    display: flex;
    gap: 11px;
    animation: slide-in .18s ease;
}

.e-av {
    width: 31px;
    height: 31px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    margin-top: 2px;
}

.e-body {
    flex: 1;
    min-width: 0;
}

.e-meta {
    display: flex;
    align-items: baseline;
    gap: 7px;
    margin-bottom: 3px;
    flex-wrap: wrap;
}

.e-name {
    font-size: 13px;
    font-weight: 500;
}

.e-time {
    font-size: 10.5px;
    color: var(--text-3);
    font-family: 'DM Mono', monospace;
}

.e-tag {
    font-size: 9.5px;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.tag-chat {
    background: var(--accent-glow);
    color: var(--accent);
}

.tag-narr {
    background: rgba(255, 255, 255, .05);
    color: var(--text-3);
}

.tag-dice {
    background: var(--dice-bg);
    color: var(--dice);
}

.tag-sec {
    background: var(--secret-bg);
    color: var(--secret);
}

.tag-info {
    background: rgba(110, 222, 164, 0.15);
    color: var(--accent-3);
}

/* 変数変更ログ: アバター・メタなしのコンパクト1行 */
.stat-entry {
    display: flex;
    align-items: center;
    padding: 1px 10px;
    min-height: 0;
}

.stat-text {
    font-size: 13.5px;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.e-text {
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--text-1);
    white-space: pre-wrap;
}

.log-entry.narr .e-text {
    color: var(--text-2);
    font-style: italic;
}

.log-entry.secret .e-body {
    background: var(--secret-bg);
    border: 1px solid rgba(196, 125, 232, .2);
    border-radius: var(--r-sm);
    padding: 9px 11px;
}

/* ── Scene heading ── */
.scene-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
}

.sh-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.sh-text {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--accent-3);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

.log-info {
    text-align: center;
    font-size: 11.5px;
    color: var(--text-3);
    padding: 3px 0;
}

/* ── Dice chip ── */
.dice-chip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: var(--dice-bg);
    border: 1px solid rgba(240, 192, 96, .2);
    border-radius: var(--r-sm);
    padding: 7px 13px;
    margin-top: 4px;
}

.dc-formula {
    font-family: 'DM Mono', monospace;
    font-size: 11.5px;
    color: var(--text-3);
}

.dc-val {
    font-family: 'DM Mono', monospace;
    font-size: 19px;
    font-weight: 500;
    color: var(--dice);
    letter-spacing: -1px;
}

.dc-note {
    font-family: 'DM Mono', monospace;
    font-size: 10.5px;
    color: var(--text-3);
}

/* ══════════════════════════════════════════════
   CHARACTER PANEL  (sidebar)
══════════════════════════════════════════════ */

/* Color circle button inside char card */
.cc-color-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .18);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color .15s, transform .1s;
    padding: 0;
}

.cc-color-btn:hover {
    border-color: rgba(255, 255, 255, .55);
    transform: scale(1.1);
}

/* キャラカード内の名前表示（span） */
.char-name-input {
    display: block;
    color: var(--text-1);
    font-size: 12.5px;
    font-weight: 500;
    width: 100%;
    font-family: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
}

/* Delete button inside char card */
.cc-del-btn {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-3);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
    opacity: 0;
    transition: opacity .15s, color .15s;
    padding: 0;
}

.char-card:hover .cc-del-btn {
    opacity: 1;
}

.cc-del-btn:hover {
    color: var(--red);
}

/* ══════════════════════════════════════════════
   立ち絵設定ボタン（キャラカード内）
══════════════════════════════════════════════ */
.cc-illust-btn {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-3);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity .15s, color .15s;
    padding: 0;
}

.char-card:hover .cc-illust-btn {
    opacity: 1;
}

.cc-illust-btn:hover {
    color: var(--text-1);
}

/* ── 立ち絵ステージ表示切替ボタン ── */
.cc-stage-btn {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-3);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color .15s;
    padding: 0;
}

/* 立ち絵が設定されていない場合は非表示 */
.cc-stage-btn.hidden {
    display: none;
}

/* 表示ON = アクセントカラー、OFF = グレー */
.cc-stage-btn.stage-on {
    color: var(--accent);
    opacity: 1;
}

.cc-stage-btn:not(.stage-on) {
    color: var(--text-3);
}

.cc-stage-btn:hover {
    color: var(--text-1);
}

/* ── キャラカード内の立ち絵サムネイル ── */
.cc-thumb {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--border);
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

/* クリック可能なサムネイル（立ち絵設定トリガー） */
.cc-thumb-btn {
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.cc-thumb-btn:hover {
    background: rgba(255, 255, 255, .09);
    border-color: var(--border-hi);
}

.cc-thumb-btn i {
    color: var(--text-3);
    transition: color .15s;
}

.cc-thumb-btn:hover i {
    color: var(--text-2);
}

.cc-thumb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    border-radius: 8px;
    display: block;
}

/* ══════════════════════════════════════════════
   カラーパレットモーダル
══════════════════════════════════════════════ */
.color-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    /* 背景クリックで閉じるため透明 */
}

.color-modal {
    position: fixed;
    z-index: 501;
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--r);
    padding: 12px;
    width: 200px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .65);
    animation: pop-in .12s ease;
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: scale(.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.color-modal-title {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--text-3);
    margin-bottom: 10px;
}

/* 3列 × 4行 = 12色 */
.color-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
}

.cp-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 7px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color .13s, transform .1s;
    padding: 0;
    outline: none;
}

.cp-swatch:hover {
    transform: scale(1.12);
}

.cp-swatch.active {
    border-color: rgba(255, 255, 255, .75);
}

/* ══════════════════════════════════════════════
   立ち絵設定モーダル
══════════════════════════════════════════════ */
.illust-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .72);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fade-in .15s ease;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.illust-modal {
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--r);
    width: 100%;
    max-width: 560px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .75);
    animation: pop-in .15s ease;
}

.illust-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.illust-modal-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
}

.illust-modal-close {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    border: none;
    background: transparent;
    color: var(--text-3);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .15s, background .15s;
    padding: 0;
    line-height: 1;
}

.illust-modal-close:hover {
    color: var(--text-1);
    background: var(--surface-3);
}

/* タブバー */
.illust-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.illust-tab {
    padding: 9px 16px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-3);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all .15s;
    white-space: nowrap;
}

.illust-tab.active {
    color: var(--accent);
    border-color: var(--accent);
}

.illust-tab:hover:not(.active) {
    color: var(--text-2);
}

/* アップロードゾーン */
.illust-upload-zone {
    border: 2px dashed var(--border-hi);
    border-radius: var(--r);
    padding: 20px 12px;
    margin: 12px;
    text-align: center;
    color: var(--text-3);
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    flex-shrink: 0;
}

.illust-upload-zone:hover,
.illust-upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--text-2);
}

.illust-upload-icon {
    font-size: 24px;
    margin-bottom: 6px;
    display: block;
}

.illust-upload-sub {
    font-size: 10.5px;
    color: var(--text-3);
    margin-top: 4px;
}

/* 画像グリッド */
.illust-grid-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 4px 12px 12px;
    min-height: 0;
}

.illust-grid-wrap::-webkit-scrollbar {
    width: 3px;
}

.illust-grid-wrap::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 2px;
}

.illust-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 7px;
}

.illust-item {
    aspect-ratio: 1;
    border-radius: var(--r-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color .13s;
    position: relative;
    background: var(--surface-3);
}

.illust-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}

.illust-item.active {
    border-color: var(--accent);
}

.illust-item.active::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.illust-none-msg {
    color: var(--text-3);
    font-size: 13px;
    text-align: center;
    padding: 32px 0;
}

.illust-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    color: var(--text-3);
    font-size: 12px;
}

/* 確定ボタン */
.illust-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* e-av に立ち絵を表示する場合 */
.e-av-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    border-radius: 8px;
    display: block;
}

/* char-fig に立ち絵を表示する場合（全身表示のため contain を使用）*/
.char-fig-img {
    display: block;
    width: auto;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: bottom center;
    cursor: default;
    /* .stage-char の cursor:pointer を上書きして通常カーソルに戻す */
}

/* スマホ対応 */
@media (max-width: 700px) {
    .illust-modal {
        max-height: 90vh;
    }

    .color-modal {
        width: 180px;
    }

    .illust-grid {
        grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    }
}

/* ══════════════════════════════════════════════
   BGM モーダル（立ち絵モーダルと共通スタイル流用）
══════════════════════════════════════════════ */
.bgm-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface-3);
    cursor: pointer;
    transition: border-color .13s, background .13s;
    margin-bottom: 6px;
}

.bgm-item:hover {
    border-color: var(--border-hi);
    background: var(--surface-4);
}

.bgm-item.active {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.bgm-icon {
    font-size: 16px;
    color: var(--text-3);
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.bgm-item.active .bgm-icon {
    color: var(--accent);
}

.bgm-item.playing .bgm-icon {
    color: var(--accent-3);
    animation: bgm-pulse 1.2s infinite;
}

@keyframes bgm-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .4;
    }
}

.bgm-name {
    flex: 1;
    font-size: 12px;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bgm-stop-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s;
    padding: 0;
}

.bgm-stop-btn:hover {
    border-color: var(--red);
    color: var(--red);
}

/* BGM アップロードゾーン */
.bgm-upload-zone {
    border: 2px dashed var(--border-hi);
    border-radius: var(--r);
    padding: 18px 12px;
    margin: 10px 12px;
    text-align: center;
    color: var(--text-3);
    font-size: 12.5px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    flex-shrink: 0;
}

.bgm-upload-zone:hover,
.bgm-upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--text-2);
}

.bgm-list-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
    min-height: 0;
}

.bgm-list-wrap::-webkit-scrollbar {
    width: 3px;
}

.bgm-list-wrap::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 2px;
}

/* BGM 変更通知バー（他ユーザーが BGM を変更したとき表示） */
.bgm-notify-bar {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-2, #1e1e2e);
    border: 1px solid var(--accent, #5b8def);
    border-radius: 8px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9999;
    color: var(--text, #e0e0f0);
    font-size: 13px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.bgm-notify-play {
    background: var(--accent, #5b8def);
    border: none;
    border-radius: 4px;
    padding: 4px 12px;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.bgm-notify-play:hover {
    filter: brightness(1.15);
}

.bgm-notify-close {
    background: none;
    border: none;
    color: var(--text-muted, #aaa);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 2px;
}

.bgm-notify-close:hover {
    color: var(--text, #e0e0f0);
}

/* ══════════════════════════════════════════════
   発言キャラサムネイル＋選択パネル（ta-top 内）
══════════════════════════════════════════════ */
.msg-char-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-3);
    color: var(--text-3);
    font-size: 10px;
    font-weight: 600;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
    padding: 0;
    transition: border-color .15s;
}

.msg-char-thumb:hover {
    border-color: var(--accent);
}

.msg-char-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}

/* キャラ選択ドロップダウンパネル（位置は JS の fixed インラインスタイルで設定） */
.msg-char-panel {
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--r);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .35);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 130px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
}

.msg-char-panel-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-2);
    transition: background .1s;
}

.msg-char-panel-item:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.msg-char-panel-item.selected {
    background: var(--accent-glow);
    color: var(--accent);
}

.mcp-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-3);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-3);
    overflow: hidden;
}

.mcp-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    object-position: top center;
}

/* ══════════════════════════════════════════════
   発言キャラ選択セレクタ（ta-top 内）
══════════════════════════════════════════════ */
.msg-char-sel {
    appearance: none;
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    color: var(--text-2);
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    outline: none;
    cursor: text;
    padding: 0 6px;
    flex: 1;
    min-width: 0;
}

.msg-char-sel:focus {
    border-bottom-color: var(--accent-1);
    color: var(--text-1);
}

/* ══════════════════════════════════════════════
   stage-chara: 音声認識中の発光エフェクト
   透過PNG の輪郭に沿って光るよう drop-shadow を使用
══════════════════════════════════════════════ */
.stage-chara.speaking .char-fig-img {
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, .9)) drop-shadow(0 0 24px rgba(255, 255, 255, .45));
}

/* stage が空のとき（「立ち絵がありません」は非表示） */
.stage-chars-empty {
    display: none;
}

/* ══════════════════════════════════════════════
   ログ編集・削除ボタン
══════════════════════════════════════════════ */
.log-entry {
    position: relative;
}

.log-entry-actions {
    display: none;
    position: absolute;
    top: 4px;
    right: 4px;
    gap: 3px;
    align-items: center;
}

.log-entry:hover .log-entry-actions {
    display: flex;
}

.log-act-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface-3);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all .15s;
    flex-shrink: 0;
}

.log-act-btn:hover {
    background: var(--surface-4);
    color: var(--text-1);
    border-color: var(--border-hi);
}

.log-act-btn.del:hover {
    background: rgba(239, 80, 80, .15);
    color: var(--red);
    border-color: rgba(239, 80, 80, .3);
}

/* インライン編集モード */
.log-entry.editing .e-text {
    display: none;
}

.log-edit-input {
    width: 100%;
    background: var(--surface-3);
    border: 1px solid var(--accent);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-family: inherit;
    font-size: 13px;
    padding: 5px 8px;
    resize: vertical;
    min-height: 40px;
    outline: none;
    line-height: 1.55;
}

.log-edit-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.log-edit-ok,
.log-edit-cancel {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all .15s;
}

.log-edit-ok {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.log-edit-ok:hover {
    background: #6e9ef5;
}

.log-edit-cancel {
    background: var(--surface-3);
    color: var(--text-2);
}

.log-edit-cancel:hover {
    background: var(--surface-4);
    color: var(--text-1);
}

/* ══════════════════════════════════════════════
   キャラ詳細モーダル
══════════════════════════════════════════════ */
.char-detail-panel {
    background: var(--surface);
    border: 1px solid var(--border-hi);
    border-radius: var(--r);
    width: min(520px, 95vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .5);
}

.cdp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.cdp-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-1);
}

.cdp-close {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all .15s;
}

.cdp-close:hover {
    background: var(--surface-3);
    color: var(--text-1);
}

.cdp-body {
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cdp-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--text-3);
    margin-bottom: 6px;
}

/* 能力値テーブル */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.stats-table th {
    text-align: left;
    padding: 4px 6px;
    color: var(--text-3);
    font-weight: 500;
    font-size: 10.5px;
    border-bottom: 1px solid var(--border);
}

.stats-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    color: var(--text-1);
}

.stat-label-input,
.stat-val-input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-1);
    font-family: inherit;
    font-size: 12.5px;
    width: 100%;
    padding: 0;
}

.stat-val-input {
    width: 60px;
    text-align: right;
}

.stat-del-btn {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 13px;
    padding: 0 2px;
    transition: color .15s;
}

.stat-del-btn:hover {
    color: var(--red);
}

.cdp-add-btn {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    transition: all .15s;
    margin-top: 4px;
    align-self: flex-start;
}

.cdp-add-btn:hover {
    background: var(--surface-3);
    color: var(--text-1);
}

/* SAN値 */
.san-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.san-input {
    width: 55px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-1);
    font-family: inherit;
    font-size: 13px;
    padding: 3px 6px;
    text-align: center;
    outline: none;
    transition: border-color .15s;
}

.san-input:focus {
    border-color: var(--accent);
}

/* チャットパレット編集テキストエリア（詳細パネル内） */
.palette-edit-note {
    font-size: 10.5px;
    color: var(--text-3);
    margin-bottom: 6px;
}

.palette-edit-textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    padding: 8px 10px;
    resize: vertical;
    outline: none;
    transition: border-color .15s;
}

.palette-edit-textarea:focus {
    border-color: var(--accent);
}

/* チャットパレット */
.palette-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.palette-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px 8px;
}

.palette-label-input,
.palette-cmd-input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-1);
    font-family: inherit;
    font-size: 12px;
}

.palette-label-input {
    width: 100px;
    flex-shrink: 0;
    color: var(--text-2);
    font-size: 11px;
}

.palette-cmd-input {
    flex: 1;
    min-width: 0;
    font-family: 'DM Mono', monospace;
    font-size: 11.5px;
}

.palette-del-btn {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 13px;
    flex-shrink: 0;
    transition: color .15s;
    padding: 0 2px;
}

.palette-del-btn:hover {
    color: var(--red);
}

/* ══════════════════════════════════════════════
   チャットパレットモーダル（発言入力から開く）
══════════════════════════════════════════════ */
.chat-palette-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(3px);
}

.chat-palette-panel {
    background: var(--surface);
    border: 1px solid var(--border-hi);
    border-radius: var(--r) var(--r) 0 0;
    width: min(480px, 100vw);
    max-height: 60vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, .4);
}

.cpp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.cpp-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: .4px;
}

.cpp-close {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.cpp-list {
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cpp-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s;
    border: 1px solid transparent;
}

.cpp-item:hover {
    background: var(--surface-2);
    border-color: var(--border);
}

.cpp-label {
    font-size: 11px;
    color: var(--text-2);
    min-width: 80px;
    flex-shrink: 0;
}

.cpp-cmd {
    font-size: 11.5px;
    color: var(--text-1);
    font-family: 'DM Mono', monospace;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* パレットボタン（発言エリアのツールバー） */
.palette-open-btn {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-3);
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 7px;
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s;
}

.palette-open-btn:hover {
    color: var(--text-2);
    border-color: var(--border-hi);
    background: var(--surface-2);
}

/* ── チャットパレットトグルボタン（ta-top 内） ── */
.palette-toggle-btn {
    background: var(--surface-3);
    border: 1px solid var(--border-hi);
    border-radius: 4px;
    color: var(--text-2);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    transition: all .15s;
    flex-shrink: 0;
    padding: 0;
}

.palette-toggle-btn:hover,
.palette-toggle-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-glow);
}

/* ── チャットパレットポップアップ（bottom-panel 内フローティング） ── */
.palette-popup {
    position: absolute;
    bottom: 100%;
    right: 12px;
    width: 260px;
    max-height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--surface);
    border: 1px solid var(--border-hi);
    border-radius: var(--r);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, .45);
    z-index: 100;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-sizing: border-box;
}

.palette-popup-item {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    background: none;
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 5px 10px;
    color: var(--text-1);
    font-family: 'DM Mono', monospace;
    font-size: 11.5px;
    cursor: pointer;
    transition: all .12s;
    white-space: pre-wrap;
    word-break: break-word;
    flex-shrink: 0;
}

.palette-popup-item:hover {
    background: var(--surface-2);
    border-color: var(--border);
}

.palette-popup-empty {
    padding: 10px;
    color: var(--text-3);
    font-size: 11px;
    text-align: center;
}

/* ドラッグドロップゾーン */
.char-drop-zone {
    border: 1.5px dashed var(--border);
    border-radius: var(--r-sm);
    padding: 6px 10px;
    font-size: 10px;
    color: var(--text-3);
    text-align: center;
    cursor: pointer;
    transition: all .15s;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.char-drop-zone.drag-over,
.char-drop-zone:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

/* ══════════════════════════════════════════════
   スマホ用：キャラ設定フローティングボタン
══════════════════════════════════════════════ */
.mobile-char-toggle {
    display: none;
}

/* デスクトップでは非表示（モバイル専用オーバーレイ） */
.mobile-char-overlay {
    display: none;
}

@media (max-width: 700px) {
    .mobile-char-toggle {
        display: flex;
        position: fixed;
        bottom: 80px;
        right: 14px;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--accent);
        border: none;
        color: #fff;
        font-size: 20px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 300;
        box-shadow: 0 4px 16px rgba(0, 0, 0, .45);
        transition: transform .15s, background .15s;
    }

    .mobile-char-toggle:hover {
        background: #6e9ef5;
        transform: scale(1.07);
    }

    /* スマホでサイドバーをオーバーレイ表示 */
    .mobile-char-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .55);
        z-index: 290;
    }

    .mobile-char-overlay.open {
        display: block;
    }

    /* サイドバーをオーバーレイ内に表示 */
    .sidebar.mobile-open {
        display: flex !important;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(340px, 90vw);
        z-index: 295;
        box-shadow: -8px 0 32px rgba(0, 0, 0, .5);
    }
}

/* ══════════════════════════════════════════════
   BGM 音量スライダー
══════════════════════════════════════════════ */
.bgm-volume-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 4px;
    flex-shrink: 0;
}

.bgm-volume-icon,
.bgm-volume-label {
    font-size: 12px;
    color: var(--text-3);
    flex-shrink: 0;
}

.bgm-volume-slider {
    flex: 1;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: var(--surface-4);
    outline: none;
    cursor: pointer;
    border: none;
    padding: 0;
}

.bgm-volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.bgm-volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

/* BGM 名前編集インライン */
.bgm-name-edit {
    background: transparent;
    border: none;
    color: var(--text-2);
    font-size: 12px;
    font-family: inherit;
    flex: 1;
    outline: none;
    min-width: 0;
    cursor: text;
}

.bgm-name-edit:focus {
    color: var(--text-1);
    background: rgba(255, 255, 255, .05);
    border-radius: 3px;
    padding: 0 3px;
}

/* 画像・BGM 削除ボタン（グリッドアイテム内） */
.illust-del-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: rgba(0, 0, 0, .65);
    border: none;
    color: var(--red);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .15s;
    padding: 0;
    z-index: 2;
}

.illust-item:hover .illust-del-btn {
    opacity: 1;
}

.illust-del-btn:hover {
    background: rgba(239, 80, 80, .85);
    color: #fff;
}

/* BGM 名前変更ボタン */
.bgm-ren-btn {
    width: 26px;
    height: 26px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s;
    padding: 0;
    margin-left: auto;
}

.bgm-ren-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* BGM 削除ボタン */
.bgm-del-btn {
    width: 26px;
    height: 26px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s;
    padding: 0;
}

.bgm-del-btn:hover {
    border-color: var(--red);
    color: var(--red);
}

/* ══════════════════════════════════════════════
   ステージ音量スライダー
══════════════════════════════════════════════ */
.stage-vol-row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
}

.stage-vol-icon {
    font-size: 11px;
    color: var(--text-3);
    flex-shrink: 0;
}

.stage-vol-slider {
    flex: 1;
    max-width: 100px;
    appearance: none;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .15);
    outline: none;
    cursor: pointer;
    border: none;
    padding: 0;
}

.stage-vol-slider::-webkit-slider-thumb {
    appearance: none;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.stage-vol-slider::-moz-range-thumb {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

/* ══════════════════════════════════════════════
   ログ編集・削除UI
══════════════════════════════════════════════ */
.e-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.e-actions {
    display: flex;
    /* 常にスペースを確保してレイアウトシフトを防ぐ */
    visibility: hidden;
    gap: 4px;
    margin-left: auto;
}

.log-entry:hover .e-actions,
.log-entry.editing .e-actions {
    visibility: visible;
}

.e-edit-btn,
.e-del-btn {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-3);
    cursor: pointer;
    transition: all .15s;
}

.e-edit-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.e-del-btn:hover {
    border-color: var(--red);
    color: var(--red);
}

.e-edit-textarea {
    width: 100%;
    min-height: 48px;
    background: var(--surface-2);
    border: 1px solid var(--accent);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-size: 13px;
    padding: 4px 8px;
    resize: vertical;
    margin-top: 4px;
}

/* ── ログ編集時のタイプ切り替えUI ── */
.e-type-switch {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}

.e-type-switch.hidden {
    display: none;
}

.e-type-btn {
    padding: 2px 10px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface-3);
    color: var(--text-2);
    font-size: 11px;
    cursor: pointer;
    transition: background .12s;
}

.e-type-btn:hover {
    background: var(--surface-4);
    color: var(--text-1);
}

.e-type-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ── プレイヤー表示名変更モーダル ── */
.display-name-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.display-name-modal {
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--r);
    padding: 24px;
    width: min(90%, 360px);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.display-name-modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
}

.display-name-input {
    width: 100%;
    background: var(--surface-3);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-size: 14px;
    padding: 8px 12px;
    box-sizing: border-box;
}

.display-name-input:focus {
    outline: none;
    border-color: var(--accent);
}

.display-name-modal-btns {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ══════════════════════════════════════════════
   キャラ詳細ボタン
══════════════════════════════════════════════ */
.cc-detail-btn {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s;
    padding: 0;
}

.cc-detail-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ══════════════════════════════════════════════
   汎用モーダルオーバーレイ
══════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
}

.modal-close-btn {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    border: none;
    background: transparent;
    color: var(--text-2);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    background: var(--surface-3);
}

/* ══════════════════════════════════════════════
   キャラ追加モーダル
══════════════════════════════════════════════ */
.add-char-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    width: min(440px, 95vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.add-char-pane {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.add-char-pane.hidden {
    display: none;
}

.add-char-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--text-2);
}

.add-char-name-input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-size: 13px;
    padding: 6px 10px;
    outline: none;
}

.add-char-name-input:focus {
    border-color: var(--accent);
}

.add-char-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* ══════════════════════════════════════════════
   キャラ詳細モーダル
══════════════════════════════════════════════ */
.char-detail-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    width: min(500px, 95vw);
    height: 75vh;
    /* タブ切り替えで高さが変わらないよう固定 */
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── 入室時の BGM 許可オーバーレイ（全画面） ── */
.audio-permit-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-permit-card {
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--r);
    padding: 40px 48px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.audio-permit-icon {
    font-size: 40px;
    color: var(--accent);
    margin-bottom: 16px;
}

.audio-permit-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 10px;
}

.audio-permit-desc {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.6;
    margin-bottom: 24px;
}

.audio-permit-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.audio-permit-allow {
    background: var(--accent);
    border: none;
    border-radius: var(--r-sm);
    padding: 9px 24px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
}

.audio-permit-allow:hover {
    filter: brightness(1.15);
}

.audio-permit-skip {
    background: transparent;
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    padding: 9px 18px;
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
}

.audio-permit-skip:hover {
    background: var(--surface-3);
}

/* ── キャラ詳細モーダル：名前編集行 ── */
.char-detail-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px 6px;
    border-bottom: 1px solid var(--border);
}

.char-detail-name-label {
    font-size: 11px;
    color: var(--text-3);
    white-space: nowrap;
    flex-shrink: 0;
}

.char-detail-name-input {
    flex: 1;
    background: var(--surface-3);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    padding: 4px 8px;
    color: var(--text-1);
    font-size: 14px;
    font-family: inherit;
}

.char-detail-name-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* .char-name-input[readonly] は span 化により不要になったため削除 */

/* ══════════════════════════════════════════════
   BCDice ダイス結果エントリ装飾
══════════════════════════════════════════════ */

/* ダイスエントリの共通ベーススタイル */
.dice-entry {
    border-left: 3px solid var(--dice);
    background: rgba(240, 192, 96, 0.04);
}

/* コマンドテキスト（例: CCB<=75 【アイデア】）は通常色で表示 */
.dice-entry .e-text {
    font-size: 13px;
}

/* ダイスタグ（.e-tag のベーススタイルを継承） */
.tag-dice {
    background: rgba(240, 192, 96, 0.15);
    color: var(--dice);
}

/* BCDice の結果ブロック */
.dice-result {
    display: inline-flex;
    align-items: center;
    background: var(--dice-bg);
    border: 1px solid rgba(240, 192, 96, 0.25);
    border-radius: 6px;
    padding: 5px 12px;
    margin-top: 5px;
}

.dice-result .dice-text {
    font-family: 'DM Mono', monospace;
    font-size: 12.5px;
    color: var(--dice);
}

/* 成功: グリーン系 */
.dice-entry.dice-success {
    border-left-color: #4caf74;
    background: rgba(76, 175, 116, 0.06);
}

.dice-entry.dice-success .dice-result {
    border-color: rgba(76, 175, 116, 0.3);
    background: rgba(76, 175, 116, 0.06);
}

.dice-entry.dice-success .dice-result .dice-text {
    color: #4caf74;
}

/* 失敗: レッド系 */
.dice-entry.dice-failure {
    border-left-color: var(--red);
    background: rgba(239, 80, 80, 0.06);
}

.dice-entry.dice-failure .dice-result .dice-text {
    color: var(--red);
}

/* クリティカル: ゴールド＋グロー（派手） */
.dice-entry.dice-critical {
    border-left-color: #f5c842;
    background: rgba(245, 200, 66, 0.10);
    box-shadow: inset 0 0 12px rgba(245, 200, 66, 0.12);
}

.dice-entry.dice-critical .dice-result {
    border-color: rgba(245, 200, 66, 0.4);
    background: rgba(245, 200, 66, 0.08);
}

.dice-entry.dice-critical .dice-result .dice-text {
    color: #f5c842;
    font-weight: 600;
    text-shadow: 0 0 8px rgba(245, 200, 66, 0.7);
}

/* ファンブル: パープル系 */
.dice-entry.dice-fumble {
    border-left-color: #c47de8;
    background: rgba(196, 125, 232, 0.06);
}

.dice-entry.dice-fumble .dice-result .dice-text {
    color: #c47de8;
    text-decoration: line-through;
    text-decoration-color: rgba(196, 125, 232, 0.5);
}

/* ══════════════════════════════════════════════
   キャラ詳細モーダル：タブ
══════════════════════════════════════════════ */

/* タブ行 */
.cdm-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.cdm-tab {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-2);
    font-size: 13px;
    padding: 8px 0;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.cdm-tab:hover {
    color: var(--text-1);
}

.cdm-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* タブペイン共通 */
.cdm-tab-pane {
    flex: 1;
    min-height: 0;
    /* フレックス子要素がコンテンツ高さを無視して縮小できるよう必須 */
    overflow-y: auto;
}

.cdm-tab-pane.hidden {
    display: none;
}

/* ══════════════════════════════════════════════
   キャラ詳細モーダル：変数タブ
══════════════════════════════════════════════ */

/* 変数リスト */
.char-var-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
}

/* 変数1行 */
.char-var-row {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-3);
    border-radius: var(--r-sm);
    padding: 6px 8px;
}

/* ラベル入力 */
.char-var-label-input {
    flex: 1;
    background: var(--surface-4);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-size: 13px;
    padding: 3px 6px;
    min-width: 0;
}

.char-var-label-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* 数値入力 */
.char-var-val-input {
    width: 60px;
    background: var(--surface-4);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-size: 13px;
    padding: 3px 6px;
    text-align: center;
}

.char-var-val-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* 数値の増減ボタン（デクリメント・インクリメント） */
.char-var-dec,
.char-var-inc {
    background: var(--surface-4);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-size: 14px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.char-var-dec:hover,
.char-var-inc:hover {
    background: var(--surface-3);
    border-color: var(--border-hi);
}

/* 表示/非表示ボタン */
.char-var-vis-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-3);
    font-size: 12px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s, border-color 0.15s;
}

.char-var-vis-btn.active {
    color: var(--accent);
    border-color: var(--accent);
}

.char-var-vis-btn:hover {
    border-color: var(--border-hi);
    color: var(--text-1);
}

/* 削除ボタン */
.char-var-del-btn {
    background: transparent;
    border: none;
    color: var(--text-3);
    font-size: 14px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--r-sm);
}

.char-var-del-btn:hover {
    color: var(--red);
    background: rgba(239, 80, 80, 0.1);
}

/* 変数追加ボタン */
.char-var-add-btn {
    margin-top: 8px;
    background: var(--surface-3);
    border: 1px dashed var(--border-hi);
    border-radius: var(--r-sm);
    color: var(--text-2);
    font-size: 13px;
    padding: 6px 12px;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}

.char-var-add-btn:hover {
    background: var(--surface-4);
    color: var(--text-1);
}

/* ══════════════════════════════════════════════
   ステージ：キャラ変数パネル（右上オーバーレイ）
══════════════════════════════════════════════ */

/* ステージ右上に絶対配置されるパネルコンテナ */
/* ── SVP ドロワー: ステージ右端に縦長トグルバー付きパネル ── */
.svp-drawer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    height: 100%;
    z-index: 5;
    display: flex;
    align-items: stretch;
    pointer-events: none;
}

/* 縦長トグルバー（◀/▶） */
.svp-toggle-bar {
    pointer-events: auto;
    flex-shrink: 0;
    align-self: stretch;
    width: 14px;
    height: auto;
    background: rgba(13, 15, 20, .82);
    border: 1px solid rgba(255, 255, 255, .09);
    border-right: none;
    border-radius: 6px 0 0 6px;
    color: var(--text-2);
    font-size: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background .15s;
    backdrop-filter: blur(6px);
}

.svp-toggle-bar:hover {
    background: rgba(40, 45, 60, .9);
    color: var(--text-1);
}

/* 変数パネル本体（初期は非表示） */
#stageVarsPanel {
    height: 100%;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 4px 6px 4px 0;
    pointer-events: none;
    background: var(--bg);
}

/* open 状態で変数パネルを表示 */
.svp-drawer.open #stageVarsPanel {
    display: flex;
}

/* キャラごとのセクション */
.svp-section {
    background: rgba(13, 15, 20, .82);
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 7px;
    padding: 5px 7px 6px;
    min-width: 120px;
    pointer-events: auto;
    /* ボタン操作を受け付ける */
    backdrop-filter: blur(6px);
}

/* キャラ名ヘッダー行 */
.svp-char-header {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: var(--text-2);
    margin-bottom: 4px;
}

/* キャラカラードット */
.svp-color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* 変数1行 */
.svp-var-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 1px 0;
}

/* 変数ラベル */
.svp-label {
    color: var(--text-2);
    font-size: 11px;
    min-width: 1.8em;
    text-align: right;
    flex-shrink: 0;
}

/* 変数値 */
.svp-val {
    color: var(--text-1);
    font-size: 13px;
    font-weight: 600;
    min-width: 2em;
    text-align: center;
}

/* 増減ボタン */
.svp-btn {
    background: rgba(255, 255, 255, .1);
    border: none;
    border-radius: 3px;
    color: var(--text-1);
    font-size: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .1s;
}

.svp-btn:hover {
    background: rgba(255, 255, 255, .22);
}

/* スマホではパネルを小さくする */
@media (max-width: 700px) {
    .svp-section {
        min-width: 100px;
        padding: 4px 6px 5px;
    }
}

/* ── 立ち絵なしキャラのステージ表示（FAアイコン） ── */
.char-fig-icon {
    width: 80px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}

/* ══════════════════════════════════════════════
   ゲスト入室モーダル
══════════════════════════════════════════════ */
.guest-login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guest-login-modal {
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--r);
    padding: 32px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.guest-login-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 20px;
    text-align: center;
}

.guest-login-section {
    margin-bottom: 16px;
}

.guest-login-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.guest-login-name-row {
    margin-bottom: 12px;
}

.guest-login-label {
    display: block;
    font-size: 12px;
    color: var(--text-2);
    margin-bottom: 5px;
}

.guest-login-required {
    color: var(--red);
    margin-left: 4px;
    font-size: 11px;
}

.guest-login-name-input {
    width: 100%;
    box-sizing: border-box;
    background: var(--surface-3);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    padding: 8px 10px;
    color: var(--text-1);
    font-size: 14px;
}

.guest-login-name-input:focus {
    outline: none;
    border-color: var(--accent);
}

.guest-login-enter-btn {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    font-weight: 500;
}

.guest-login-divider {
    text-align: center;
    color: var(--text-3);
    font-size: 12px;
    margin: 16px 0;
    position: relative;
}

.guest-login-divider::before,
.guest-login-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 42%;
    height: 1px;
    background: var(--border);
}

.guest-login-divider::before {
    left: 0;
}

.guest-login-divider::after {
    right: 0;
}

.guest-login-login-btn {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    text-align: center;
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    color: var(--text-1);
    font-size: 14px;
    text-decoration: none;
    background: var(--surface-3);
}

.guest-login-login-btn:hover {
    background: var(--surface-4);
    border-color: var(--accent);
}

/* ══════════════════════════════════════════════
   タブ追加・カスタムタブ
══════════════════════════════════════════════ */

/* タブ追加「＋」ボタン */
.tab-add-btn {
    background: transparent;
    border: 1px dashed var(--border-hi);
    color: var(--text-2);
    padding: 0 10px;
    height: 28px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--r-sm);
    margin-left: 4px;
}

.tab-add-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* カスタムタブ（編集・削除ボタン付き） */
.tab-custom {
    position: relative;
}

/* log-area 右上のタブ操作（歯車ボタン＋ドロップダウン） */
.log-tab-actions {
    position: absolute;
    top: 8px;
    right: 14px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 歯車アイコンボタン */
.tab-gear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-2);
    cursor: pointer;
    font-size: 13px;
}

.tab-gear-btn:hover {
    background: var(--surface-4);
    color: var(--text-1);
}

/* ドロップダウンメニュー */
.tab-gear-drop {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 110px;
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    z-index: 20;
}

.tab-gear-drop.open {
    display: block;
}

.tab-gear-item {
    display: block;
    width: 100%;
    padding: 7px 12px;
    background: none;
    border: none;
    text-align: left;
    font-size: 12px;
    color: var(--text-1);
    cursor: pointer;
    white-space: nowrap;
}

.tab-gear-item:hover {
    background: var(--surface-3);
}

.tab-gear-del:hover {
    color: var(--red);
}

/* タブ作成モーダル */
.tab-create-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 500;
}

.tab-create-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface-2);
    border: 1px solid var(--border-hi);
    border-radius: var(--r);
    padding: 24px;
    width: 360px;
    max-width: 90vw;
    z-index: 501;
    max-height: 80vh;
    overflow-y: auto;
}

.tab-create-label {
    display: block;
    font-size: 12px;
    color: var(--text-2);
    margin-bottom: 6px;
    margin-top: 14px;
}

.tab-create-input,
.tab-create-select {
    width: 100%;
    box-sizing: border-box;
    background: var(--surface-3);
    border: 1px solid var(--border-hi);
    border-radius: var(--r-sm);
    padding: 7px 10px;
    color: var(--text-1);
    font-size: 13px;
}

.tab-create-input:focus,
.tab-create-select:focus {
    outline: none;
    border-color: var(--accent);
}

.tab-create-radio-row {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-1);
}

.tab-create-radio-row label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.tab-create-target-section {
    margin-top: 4px;
}

.tab-create-submit {
    width: 100%;
    margin-top: 20px;
    padding: 9px;
}

/* ══════════════════════════════════════════════
   プライベートメッセージバッジ
══════════════════════════════════════════════ */
/* プライベートバッジ: デフォルト非表示、メインログタブでのみ表示（private-in-log クラスで制御） */
.private-badge {
    display: none;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--secret);
    opacity: 0.85;
    margin-top: 4px;
}

.private-badge::before {
    content: '🔒';
    font-size: 10px;
}

/* メインログタブに表示されるプライベートメッセージの強調スタイル */
.log-entry.private-in-log {
    border-left: 2px solid rgba(142, 36, 170, .7);
    background: rgba(142, 36, 170, .07);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    padding-left: 10px;
    margin-left: -12px;
}

.log-entry.private-in-log .private-badge {
    display: inline-flex;
}


/* ══════════════════════════════════════════════
   ログタブ説明バナー（ログエリア上部・黒背景）
══════════════════════════════════════════════ */
.log-tab-banner {
    flex-shrink: 0;
    padding: 6px 16px;
    font-size: 11px;
    color: var(--text-2);
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1px solid var(--border);
    min-height: 28px;
    display: flex;
    align-items: center;
    line-height: 1.4;
    letter-spacing: .2px;
}

/* 対象者指定タブのバナー */
.log-tab-banner--target {
    color: var(--secret);
    background: rgba(142, 36, 170, .12);
    border-bottom-color: rgba(142, 36, 170, .3);
}

/* ══════════════════════════════════════════════
   対象者指定タブの「ここは○○と○○のチャットです」ラベル
══════════════════════════════════════════════ */

/* ══════════════════════════════════════════════
   PL発言キャラカード
══════════════════════════════════════════════ */
.pl-char-card {
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
    background: rgba(136, 145, 168, .06);
}

.cc-pl-thumb {
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
    background: var(--surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-2);
    flex-shrink: 0;
}

.pl-char-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-3);
    background: var(--surface-3);
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 5px;
    vertical-align: middle;
}