:root {
  --bg: #1b1d21;
  --panel: #212226;
  --panel2: #2b2d33;
  --line: #3a3d45;
  --text: #e8e8ea;
  --muted: #8f939c;
  --accent: #e0245e;
  --accent2: #2196f3;
  --ok: #4fc3f7;
  --ng: #ff6e6e;
  --danger: #d9534f;
  --secret: #e8b14a;
  --header: #7a0d2a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; font-size: 14px; }
button, .btn, select, input, textarea { font: inherit; color: var(--text); }
button, .btn {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--accent2); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
input, select, textarea { background: #15161a; border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; }
input[type=color] { padding: 0; width: 40px; height: 28px; vertical-align: middle; }
input[type=range] { padding: 0; vertical-align: middle; accent-color: var(--accent2); }
input[type=checkbox] { accent-color: var(--accent2); }
textarea { resize: vertical; }
label { display: block; margin: 6px 0; }
label.check { display: flex; gap: 6px; align-items: center; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row label { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { background: #15161a; padding: 0 4px; border-radius: 3px; }
h3 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
h3:first-child { margin-top: 0; }
[hidden] { display: none !important; }
body:not(.is-gm) .gm { display: none !important; }
svg.ic { width: 22px; height: 22px; display: block; }

/* アイコンボタン */
.ibtn { background: transparent; border: none; padding: 5px; border-radius: 50%; color: inherit; display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.ibtn:hover { background: rgba(255,255,255,.12); }
.ibtn.on { color: var(--accent2); }

/* 入室・部屋一覧 */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 100; overflow-y: auto; padding: 16px; }
.card { background: var(--panel); padding: 24px 28px; border-radius: 12px; width: min(360px, 92vw); border: 1px solid var(--line); margin: auto; }
.card.wide { width: min(760px, 96vw); }
.card h1 { margin: 0 0 8px; font-size: 22px; }
#joinForm input:not([type=color]) { width: 100%; }
#joinForm button { width: 100%; margin-top: 12px; }
.roomrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; }
.roomrow .rname { flex: 1; min-width: 160px; font-weight: bold; font-size: 15px; }
.roomrow .rname small { display: block; font-weight: normal; color: var(--muted); font-size: 12px; }

/* レイアウト */
#app { display: flex; height: 100vh; }
#chatPanel { width: 400px; min-width: 260px; display: flex; flex-direction: column; background: var(--panel); flex: none; }
#splitter { width: 5px; flex: none; cursor: col-resize; background: var(--line); }
#splitter:hover, #splitter.drag { background: var(--accent2); }
#boardWrap { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
body.popmode #splitter, body.popmode #boardWrap { display: none; }
body.popmode #chatPanel { width: 100% !important; }
@media (max-width: 800px) {
  #app { flex-direction: column; }
  #splitter { display: none; }
  #chatPanel { width: 100% !important; height: 50vh; }
  #boardWrap { flex: 1; min-height: 0; }
}

/* 上部メニュー */
#topbar { flex: none; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 4px 8px; background: var(--header); position: relative; z-index: 20; }
.tleft { display: flex; gap: 8px; align-items: center; min-width: 0; padding-top: 3px; }
#roomName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
#sceneSel { background: rgba(0,0,0,.3); border-color: rgba(255,255,255,.2); max-width: 180px; }
.tright { display: flex; flex-direction: column; align-items: flex-end; gap: 0; }
.ticons { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ibtn.users { border-radius: 14px; padding: 4px 8px; gap: 4px; line-height: 1; font-size: 13px; }
.ibtn.users svg.ic { width: 18px; height: 18px; }
.taudio { display: flex; gap: 4px; align-items: center; }
.taudio input[type=range] { width: 90px; }
.taudio .ibtn svg.ic { width: 20px; height: 20px; }
.bgmch { background: transparent; border: none; font-weight: bold; font-size: 13px; padding: 3px 6px; color: #fff; }
.bgmch.on { color: #5ab4ff; }

/* 盤面 */
#boardArea { position: relative; flex: 1; overflow: hidden; background: #111 center / cover no-repeat; cursor: grab; touch-action: none; min-height: 0; }
#boardArea.panning { cursor: grabbing; }
#board { position: absolute; left: 0; top: 0; transform-origin: 0 0; background-size: 100% 100%; background-repeat: no-repeat; box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 4px 30px rgba(0,0,0,.6); }
#grid { position: absolute; inset: 0; pointer-events: none; }
#pieces { position: absolute; inset: 0; }
.piece { position: absolute; cursor: move; user-select: none; touch-action: none; }
.piece .pimg { width: 100%; height: 100%; border-radius: 4px; background-size: contain; background-position: center bottom; background-repeat: no-repeat; }
.piece .pimg.noimg { border-radius: 50%; border: 2px solid rgba(0,0,0,.5); }
.piece .plabel { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); text-align: center; pointer-events: none; }
.piece .pname { white-space: nowrap; font-size: 12px; background: rgba(0,0,0,.65); padding: 0 5px; border-radius: 3px; display: inline-block; }
.piece .pstat { white-space: nowrap; font-size: 10px; background: rgba(0,0,0,.55); padding: 0 4px; border-radius: 3px; margin-top: 1px; }
.piece.locked { cursor: inherit; }
.piece.dragging { opacity: .8; z-index: 1000 !important; filter: drop-shadow(0 4px 8px rgba(0,0,0,.6)); }
.piece:hover .pimg { outline: 2px solid var(--accent2); outline-offset: 1px; }
#zoomBox { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 4px; align-items: center; background: rgba(20,20,24,.85); padding: 4px 6px; border-radius: 8px; cursor: default; z-index: 5; }
#zoomBox button { padding: 1px 8px; font-size: 12px; }
#zoomLabel { min-width: 40px; text-align: center; font-size: 12px; }

/* 立ち絵 */
#stage { position: absolute; left: 0; right: 0; bottom: 0; height: 60%; display: flex; justify-content: center; align-items: flex-end; gap: 2%; pointer-events: none; }
#stage .stand { height: 100%; max-width: 30%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; transition: filter .3s; animation: standIn .35s ease-out; }
#stage .stand img { max-height: 100%; max-width: 100%; object-fit: contain; filter: drop-shadow(0 0 6px rgba(0,0,0,.7)); }
#stage .stand.old { filter: brightness(.6); }
#stage.gm .stand { pointer-events: auto; cursor: pointer; }
@keyframes standIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

/* チャット */
#log, #log2 { flex: 1; overflow-y: auto; padding: 6px 12px; min-height: 0; }
.msg { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.05); display: flex; gap: 10px; position: relative; }
.msg .face { width: 40px; height: 40px; flex: none; border-radius: 4px; background-size: cover; background-position: center top; background-color: #000; }
.msg .face.none { background: #333; display: flex; align-items: center; justify-content: center; color: #999; font-weight: bold; }
.msg .body { flex: 1; min-width: 0; }
.msg .name { font-weight: bold; }
.msg .time { color: var(--muted); font-size: 11px; margin-left: 6px; }
.msg .text { white-space: pre-wrap; word-break: break-word; }
.msg .dice { white-space: pre-wrap; font-weight: bold; color: #c8d6ff; }
.msg .dice.ok { color: var(--ok); }
.msg .dice.ng { color: var(--ng); }
.msg .ops { position: absolute; right: 0; top: 4px; display: none; gap: 4px; }
.msg:hover .ops { display: flex; }
.msg .ops button { padding: 0 6px; font-size: 11px; }

:is(#chatTabs, #chatTabs2) { display: flex; align-items: stretch; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; scrollbar-width: thin; }
:is(#chatTabs, #chatTabs2) .ctab { background: transparent; border: none; border-radius: 0; padding: 9px 12px 7px; font-size: 13px; font-weight: bold; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; position: relative; display: inline-flex; gap: 3px; align-items: center; }
:is(#chatTabs, #chatTabs2) .ctab:hover { color: var(--text); background: rgba(255,255,255,.04); }
:is(#chatTabs, #chatTabs2) .ctab.active { color: #fff; border-bottom-color: var(--accent); }
:is(#chatTabs, #chatTabs2) .ctab .badge { background: var(--accent); color: #fff; font-size: 10px; border-radius: 8px; padding: 0 5px; line-height: 15px; margin-left: 2px; }
:is(#chatTabs, #chatTabs2) .ctab svg.ic { width: 14px; height: 14px; }
:is(#chatTabs, #chatTabs2) .tool { background: transparent; border: none; color: var(--muted); padding: 4px 10px; font-size: 18px; line-height: 1; }
:is(#chatTabs, #chatTabs2) .tool:hover { color: #fff; }
:is(#chatTabs, #chatTabs2) .spacer { flex: 1; }
:is(#chatTabs, #chatTabs2) .tool svg.ic { width: 16px; height: 16px; }

#chatForm { padding: 8px 10px 10px; flex: none; }
.crow { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.facebtn { width: 40px; height: 40px; flex: none; padding: 0; border-radius: 4px; background: #333 center top / cover no-repeat; border: 1px solid var(--line); color: #999; font-weight: bold; }
#chatName { flex: 1; min-width: 60px; font-weight: bold; padding: 8px; }
#chatTo { max-width: 110px; flex: none; }
.colorbtn { position: relative; margin: 0; cursor: pointer; }
.colorbtn input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
#diceBtns { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
#diceBtns button { background: transparent; border: none; padding: 3px; border-radius: 4px; color: #ddd; line-height: 0; }
#diceBtns button:hover { background: rgba(255,255,255,.1); color: #fff; }
#diceBtns svg { width: 26px; height: 26px; }
#sendBtn { background: transparent; border: none; font-weight: bold; padding: 4px 10px; }
#sendBtn:hover { color: var(--accent2); }
#chatText { width: 100%; background: transparent; border: none; border-top: 1px solid var(--line); border-radius: 0; resize: none; padding: 8px 2px; outline: none; }

/* ポップアップメニュー */
.popmenu { position: fixed; z-index: 150; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 0; min-width: 180px; box-shadow: 0 6px 24px rgba(0,0,0,.6); max-height: 70vh; overflow-y: auto; }
.popmenu .mi { display: block; width: 100%; text-align: left; background: transparent; border: none; border-radius: 0; padding: 7px 14px; white-space: nowrap; }
.popmenu .mi:hover { background: rgba(255,255,255,.08); }
.popmenu .mi.danger { color: var(--ng); }
.popmenu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.popmenu .mh { padding: 4px 14px; color: var(--muted); font-size: 12px; }
.facegrid { display: grid; grid-template-columns: repeat(4, 72px); gap: 6px; padding: 6px 10px; }
.facegrid .fc { background: transparent; border: 2px solid transparent; padding: 0; border-radius: 6px; text-align: center; font-size: 11px; }
.facegrid .fc div { width: 68px; height: 68px; background: #111 center top / cover no-repeat; border-radius: 4px; }
.facegrid .fc.sel { border-color: var(--accent2); }
.facegrid .fc span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px; }

/* フローティングウィンドウ */
.fwin { position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.6); display: flex; flex-direction: column; resize: both; overflow: hidden; min-width: 260px; min-height: 160px; }
.fwin .whead { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; background: var(--panel2); cursor: move; user-select: none; flex: none; }
.fwin .whead b { flex: 1; font-size: 13px; }
.fwin .whead .ibtn svg.ic { width: 18px; height: 18px; }
.fwin .wbody, #popRoot { flex: 1; overflow-y: auto; padding: 10px 12px; min-height: 0; }
#popRoot { position: fixed; inset: 0; background: var(--panel); }

/* リスト */
.item { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 6px 0; }
.item .head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item .head .title { flex: 1; font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 80px; }
.item .head .title small { font-weight: normal; color: var(--muted); }
.item.current { border-color: var(--accent2); }
.item.inactive { opacity: .6; }
.item .ico { width: 40px; height: 40px; background-size: cover; background-repeat: no-repeat; background-position: center top; background-color: #111; border-radius: 4px; flex: none; }
.item button { padding: 2px 8px; font-size: 12px; }
.item label.check { margin: 0; font-size: 12px; }
.track { display: flex; gap: 4px; align-items: center; padding: 6px; border-bottom: 1px solid var(--line); }
.track .tname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track.playing { background: rgba(33,150,243,.15); }
.track button { padding: 2px 6px; font-size: 12px; }
.nowbox { background: var(--panel2); border-radius: 8px; padding: 8px; margin: 6px 0; }
.nowbox.on { box-shadow: inset 3px 0 0 var(--accent2); }
.palline { padding: 5px 8px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: pre-wrap; word-break: break-all; }
.palline:hover { background: rgba(255,255,255,.06); }
.statrow { display: grid; grid-template-columns: 1fr 70px 70px 28px; gap: 4px; margin: 3px 0; }
.paramrow { display: grid; grid-template-columns: 1fr 1fr 28px; gap: 4px; margin: 3px 0; }
.statrow input, .paramrow input { min-width: 0; width: auto !important; }
.statrow button, .paramrow button { padding: 0; }
.faces { display: flex; flex-wrap: wrap; gap: 6px; }
.faces .pt { width: 72px; text-align: center; font-size: 11px; position: relative; }
.faces .pt div { width: 72px; height: 72px; background: #111 center top / cover no-repeat; border-radius: 4px; }
.faces .pt input { width: 72px !important; padding: 2px !important; font-size: 11px; }
.faces .pt button { position: absolute; top: 0; right: 0; padding: 0 4px; font-size: 10px; }
.iconpick { width: 96px; height: 96px; flex: none; background: #111 center top / cover no-repeat; border: 1px dashed var(--line); border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }

.preview { min-height: 0; margin: 6px 0; }
.preview img { max-width: 100%; max-height: 110px; border-radius: 4px; display: block; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.thumb { position: relative; aspect-ratio: 1; background-size: contain; background-repeat: no-repeat; background-position: center; background-color: #111; border-radius: 4px; border: 2px solid transparent; cursor: pointer; }
.thumb:hover { border-color: var(--accent2); }
.thumb span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; background: rgba(0,0,0,.6); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 3px; }
.thumb button { position: absolute; top: 0; padding: 0 4px; font-size: 10px; }
.thumb button.del { right: 0; }
.thumb button.ren { left: 0; }

/* ダイアログ */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 16px; width: min(600px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 10px; font-size: 16px; }
dialog input:not([type=color]):not([type=checkbox]):not([type=range]), dialog textarea, dialog select { width: 100%; }
dialog .actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; position: sticky; bottom: -16px; background: var(--panel); padding: 8px 0; }
dialog .thumbs { max-height: 50vh; overflow-y: auto; }
.members { max-height: 200px; overflow-y: auto; background: #15161a; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.help table { border-collapse: collapse; width: 100%; }
.help td { border-bottom: 1px solid var(--line); padding: 4px 6px; vertical-align: top; }

/* カットイン */
#cutin { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(0,0,0,.55); pointer-events: none; }
#cutin img { max-width: 90vw; max-height: 75vh; object-fit: contain; filter: drop-shadow(0 0 20px rgba(0,0,0,.8)); }
#cutin .ctext { margin-top: 16px; font-size: clamp(20px, 4vw, 44px); font-weight: bold; text-shadow: 0 0 8px #000, 0 0 16px #000; text-align: center; padding: 0 20px; white-space: pre-wrap; }
#cutin.fade { animation: cFade .4s ease-out; }
#cutin.slide > * { animation: cSlide .45s cubic-bezier(.2,.9,.3,1.2); }
#cutin.zoom > * { animation: cZoom .4s cubic-bezier(.2,.9,.3,1.3); }
#cutin.out { opacity: 0; transition: opacity .4s; }
@keyframes cFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cSlide { from { transform: translateX(-100vw); } to { transform: none; } }
@keyframes cZoom { from { transform: scale(.2); opacity: 0; } to { transform: none; opacity: 1; } }

/* トースト */
#toast { position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%); background: #000c; padding: 8px 14px; border-radius: 6px; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 200; }
#toast.show { opacity: 1; }

/* 画像パネル */
.piece.panel .pimg { border-radius: 0; background-size: 100% 100%; background-position: center; }
.piece.panel .pimg.noimg { border-radius: 0; border: 1px dashed rgba(255,255,255,.4); background: rgba(255,255,255,.08) !important; }
.piece.panel:hover .pimg { outline-width: 1px; }

/* チャットパレット（Tekey準拠） */
.paltabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: -4px -4px 6px; scrollbar-width: thin; }
.ptab { background: transparent; border: none; border-radius: 0; padding: 6px 10px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 13px; font-weight: bold; }
.ptab.active { color: #fff; border-bottom-color: var(--accent); }
.ptab.tool { font-size: 16px; padding: 4px 10px; }
.palset .row { margin: 4px 0; flex-wrap: nowrap; }
.palset select, .palset input { padding: 4px 6px; font-size: 13px; }
.paltext { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.pallist { border: 1px solid var(--line); border-radius: 6px; margin: 6px 0; max-height: none; }
.palline:last-child { border-bottom: none; }
.palinput { flex-wrap: nowrap !important; position: sticky; bottom: -10px; background: var(--panel); padding: 6px 0; margin: 0; }
#popRoot .palinput { bottom: -10px; }

/* BGM・SE（コンパクト表示） */
.chrow { display: flex; gap: 6px; align-items: center; padding: 3px 6px; border-radius: 6px; background: var(--panel2); margin: 3px 0; font-size: 13px; }
.chrow.on { box-shadow: inset 3px 0 0 var(--accent2); }
.chrow b { flex: none; width: 46px; font-size: 12px; }
.chrow .cname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chrow input[type=range] { width: 80px; flex: none; }
.chrow label.check { margin: 0; gap: 2px; }
.chrow button { padding: 0 7px; font-size: 12px; }
.sndtabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 8px 0 4px; }
.stab { background: transparent; border: none; border-radius: 0; padding: 5px 9px; color: var(--muted); border-bottom: 2px solid transparent; font-size: 12px; font-weight: bold; }
.stab.active { color: #fff; border-bottom-color: var(--accent2); }
.stab.tool { font-size: 15px; padding: 2px 9px; }
.tracks .track { padding: 3px 4px; gap: 3px; }
.tracks .track .tname { font-size: 13px; }
.tracks .track button { padding: 0 6px; font-size: 11px; line-height: 20px; }

/* ローカルフォルダ参照 */
dialog.browse { width: min(760px, 96vw); }
.crumbs { margin: 6px 0; font-size: 13px; }
.crumbs a { color: var(--accent2); text-decoration: none; }
.blist { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
.blist.thumbs .bdir { grid-column: 1 / -1; }
.bdir { padding: 5px 8px; cursor: pointer; border-radius: 4px; }
.bdir:hover, .bfile:hover { background: rgba(255,255,255,.06); }
.bfile { display: flex; gap: 6px; align-items: center; padding: 3px 6px; border-radius: 4px; }
.bfile span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bfile button { padding: 0 8px; font-size: 12px; }

/* BGM 2階層タブ */
.sndtabs.sub { margin-top: 0; background: rgba(255,255,255,.03); }
.sndtabs.sub .stab { font-weight: normal; }
/* ローカルフォルダの複数選択 */
.thumb .selbox { position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; }
.thumb.sel { border-color: var(--accent2); }
label.bfile { margin: 0; cursor: pointer; }
/* 発言キャラ選択 */
.facegrid .fc .noface { background: #333 !important; display: flex; align-items: center; justify-content: center; font-weight: bold; color: #aaa; font-size: 22px; }
#chatFace { max-width: 120px; flex: none; }

/* 左上のキャラクター一覧（イニシアチブ順） */
#initList { position: absolute; left: 8px; top: 8px; z-index: 6; display: flex; flex-direction: column; gap: 4px; max-height: calc(100% - 60px); overflow-y: auto; cursor: default; scrollbar-width: thin; }
.irow { display: flex; gap: 6px; align-items: flex-start; background: rgba(15,15,18,.85); border-radius: 6px; padding: 4px 6px 4px 4px; cursor: pointer; }
.irow:hover { background: rgba(30,30,36,.95); }
.iicon { width: 44px; height: 44px; flex: none; border-radius: 4px; background: #222 center top / cover no-repeat; position: relative; }
.ibadge { position: absolute; top: -4px; left: -4px; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px; background: #e8e8ea; color: #222; font-size: 11px; font-weight: bold; display: flex; align-items: center; justify-content: center; }
.istats { display: grid; grid-template-columns: repeat(2, 104px); gap: 3px 4px; }
.ibar { position: relative; height: 19px; background: #3a3a40; border-radius: 2px; overflow: hidden; font-size: 12px; display: flex; align-items: center; justify-content: space-between; padding: 0 5px; }
.ibar i { position: absolute; left: 0; top: 0; bottom: 0; background: #8c1d3a; }
.ibar span { position: relative; white-space: nowrap; font-weight: bold; }
.ibar .iv { font-weight: normal; }
.iname { font-size: 12px; padding-top: 12px; white-space: nowrap; }
/* 入力行：幅が狭くてもはみ出さないように縮める */
.crow { gap: 4px; }
#chatName { flex: 1 1 70px; min-width: 50px; }
#chatFace, #chatTo { flex: 0 1 auto; min-width: 54px; max-width: 110px; padding: 5px 4px; }
.crow .ibtn { padding: 3px; flex: none; }
.crow .ibtn svg.ic { width: 20px; height: 20px; }

/* 背景（ぼかし可） */
#bgLayer { position: absolute; inset: 0; background: center / cover no-repeat; pointer-events: none; }
#bgLayer.blur { inset: -30px; filter: blur(12px) brightness(.85); }

/* 前景の切り抜き位置 */
.fgcrop { width: 100%; max-height: 220px; background-color: #111; background-repeat: no-repeat; border: 1px solid var(--line); border-radius: 4px; cursor: crosshair; margin: 4px 0; touch-action: none; }
/* シーン一覧（コンパクト） */
.scenelist { display: flex; flex-direction: column; gap: 2px; }
.srow { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.srow:hover { background: rgba(255,255,255,.06); }
.srow.current { border-color: var(--accent2); background: rgba(33,150,243,.12); }
.sthumb { width: 40px; height: 26px; flex: none; border-radius: 3px; background: #111 center / cover no-repeat; }
.sname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.ssize { color: var(--muted); font-size: 11px; flex: none; }
.srow .ibtn { padding: 2px 4px; border-radius: 4px; font-size: 14px; line-height: 1; }
.srow .ibtn svg.ic { width: 16px; height: 16px; }
.popmenu .mi:disabled { opacity: .4; }
.track.pick { cursor: pointer; }

/* シーン（保存した盤面） */
.savebar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; background: var(--panel2); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.savebar span { flex: 1; min-width: 140px; }
.savebar button { padding: 3px 9px; font-size: 12px; }
.dirty { color: #ffb74d; font-size: 11px; font-weight: bold; }
.srow .sinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.srow .sinfo .sname { flex: none; }
.srow .sbgm { font-size: 11px; color: #8fc3ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow.dropbefore { box-shadow: inset 0 2px 0 var(--accent2); }
.srow.dropafter { box-shadow: inset 0 -2px 0 var(--accent2); }
.srow .sthumb { height: 30px; }
/* イニシアチブ非公開 */
.ibadge.hidden { background: #777; color: #fff; }

/* 上部メニュー：盤面に重ねて半透明の黒 */
#boardWrap { position: relative; }
#topbar { position: absolute; top: 0; left: 0; right: 0; background: rgba(0, 0, 0, .3); }
#initList { top: calc(var(--tbh, 64px) + 8px); max-height: calc(100% - var(--tbh, 64px) - 60px); }

/* メッセージウインドウ（立ち絵は左） */
#msgwin { position: absolute; left: 2%; right: 2%; bottom: 14px; z-index: 7; display: flex; align-items: flex-end; gap: 0; pointer-events: none; }
#msgwin.in { animation: mwIn .25s ease-out; }
@keyframes mwIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
#msgwin .mw-stand { flex: none; height: 0; width: min(26%, 300px); position: relative; }
#msgwin .mw-stand img { position: absolute; left: 0; bottom: -14px; max-width: 100%; max-height: min(62vh, 560px); object-fit: contain; object-position: left bottom; filter: drop-shadow(0 0 6px rgba(0,0,0,.7)); }
#msgwin .mw-box { flex: 1; min-width: 0; min-height: 110px; max-height: 40vh; overflow-y: auto; background: rgba(10, 10, 14, .82); border: 1px solid rgba(255,255,255,.25); border-radius: 10px; padding: 10px 16px 12px; pointer-events: auto; position: relative; box-shadow: 0 4px 20px rgba(0,0,0,.5); }
#msgwin .mw-name { font-weight: bold; font-size: 15px; margin-bottom: 4px; border-bottom: 1px solid rgba(255,255,255,.15); padding-bottom: 3px; padding-right: 24px; }
#msgwin .mw-text { white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.6; }
#msgwin .mw-dice { white-space: pre-wrap; font-weight: bold; color: #c8d6ff; }
#msgwin .mw-dice.ok { color: var(--ok); }
#msgwin .mw-dice.ng { color: var(--ng); }
#msgwin .mw-close { position: absolute; top: 4px; right: 6px; background: transparent; border: none; color: #aaa; font-size: 16px; padding: 0 6px; }
#msgwin .mw-close:hover { color: #fff; }
/* 選択・検索 */
.selbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.selbar input[data-q], .selbar input[data-cq] { flex: 1; min-width: 120px; padding: 4px 8px; }
.selbar button { padding: 2px 8px; font-size: 12px; }
.selops { display: inline-flex; gap: 4px; align-items: center; }
.track.sel { background: rgba(33,150,243,.18); }
.track input[data-pick] { margin: 0 2px; }
.item.sel { border-color: var(--accent2); }
.item input[data-cpick] { margin: 0; }
.stab.drop { background: rgba(33,150,243,.35); color: #fff; }
/* 拡大縮小はメッセージウインドウと重ならないよう右上（上部メニューの下）へ */
#zoomBox { top: calc(var(--tbh, 64px) + 8px); bottom: auto; }
/* 立ち絵はメッセージウインドウの左上（ウインドウの上辺に乗せる） */
#msgwin { display: block; }
#msgwin .mw-box { width: 100%; }
#msgwin .mw-stand { position: absolute; left: 12px; bottom: 100%; width: auto; height: auto; pointer-events: none; }
#msgwin .mw-stand img { position: static; display: block; max-width: min(30vw, 340px); max-height: min(48vh, 460px); object-fit: contain; object-position: left bottom; }

/* イニシアチブ表：背景なし（アイコンとバーだけ）＋ラウンド */
.irow { background: transparent; padding: 2px 4px 2px 4px; border-radius: 6px; text-shadow: 0 0 3px #000, 0 0 2px #000; }
.irow:hover { background: rgba(0,0,0,.25); }
.irow.cur .iicon { box-shadow: 0 0 0 2px #ffd54f, 0 0 8px #ffd54f; }
.iround { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; background: rgba(0,0,0,.55); border-radius: 12px; padding: 2px 8px; align-self: flex-start; text-shadow: none; }
.iround b { font-size: 14px; }
.iround button { padding: 0 6px; font-size: 11px; line-height: 18px; background: rgba(255,255,255,.12); border: none; }
.iname { text-shadow: 0 0 3px #000, 0 0 2px #000; }
/* イニシアチブからのステータス変更 */
.spop { padding: 2px 10px 6px; min-width: 280px; }
.sphead { display: flex; align-items: center; gap: 2px; padding: 4px 0 6px; }
.sphead .ibtn svg.ic { width: 18px; height: 18px; }
.sprow { display: grid; grid-template-columns: 44px 1fr 54px 44px 24px 24px; align-items: center; gap: 4px; padding: 3px 0; }
.spl { font-weight: bold; font-size: 13px; }
.spbar { height: 10px; background: #444; border-radius: 2px; overflow: hidden; }
.spbar i { display: block; height: 100%; background: #e0e0e0; }
.sprow input { width: 54px; padding: 2px 4px; text-align: right; }
.spmax { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sprow .ibtn { padding: 0; font-size: 11px; width: 24px; height: 22px; border-radius: 4px; }
/* 拡大縮小は右下（メッセージウインドウの下） */
#zoomBox { top: auto !important; bottom: 8px !important; }
#msgwin { bottom: 46px; }
/* 立ち絵表示の切り替えボタン */
.standbtn { color: #777; }
.standbtn.on { color: var(--accent2); }
/* 切り抜き範囲 */
.cropdlg { width: auto; max-width: 96vw; }
.cropwrap { position: relative; display: inline-block; user-select: none; background: #111; line-height: 0; }
.cropwrap img { display: block; }
.cropbox { position: absolute; border: 2px solid #ffd54f; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); cursor: move; touch-action: none; }
.cropgrip { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; background: #ffd54f; border-radius: 3px; cursor: nwse-resize; }
.cropprev { width: 64px; height: 64px; border-radius: 6px; background-color: #222; background-repeat: no-repeat; border: 1px solid var(--line); }
.croprow { gap: 6px; }
.cropthumb { width: 40px; height: 40px; border-radius: 4px; background: #111 center / contain no-repeat; border: 1px solid var(--line); flex: none; }
.faces .pt .fcrop { position: static; padding: 0 4px; font-size: 10px; margin-top: 2px; }
/* ルビ */
ruby rt { font-size: .55em; }

/* ステータス変更・ラウンドの1行表示 */
.msg.system { padding: 3px 0; }
.msg.system .systext { color: #bbb; font-size: 13px; white-space: pre-wrap; padding-left: 2px; }
/* イニシアチブの数字：影を付けずにくっきり表示 */
.ibadge { text-shadow: none; font-size: 12px; font-weight: 800; color: #111; background: #f2f2f2; box-shadow: 0 0 0 1px rgba(0,0,0,.6); }
.ibadge.hidden { color: #fff; background: #666; }
/* 固定したパネル（PL）はマウスを乗せても枠を出さない */
body:not(.is-gm) .piece.panel.locked:hover .pimg { outline: none; }
/* イニシアチブのステータスバーは白。文字は白い部分では黒、暗い部分では白に見えるよう反転表示 */
.ibar { text-shadow: none; background: #3a3a40; }
.ibar i { background: #f2f2f2; }
.ibar span { color: #fff; mix-blend-mode: difference; }

/* タブの帯は1行。はみ出した分は左右スクロール（ホイールでも可） */
.sndtabs, .paltabs { flex-wrap: nowrap !important; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.sndtabs .stab, .paltabs .ptab { flex: none; white-space: nowrap; }

/* イニシアチブ表：減った部分は薄い白、文字は黒 */
.ibar { background: rgba(255, 255, 255, .45); }
.ibar i { background: #f4f4f4; }
.ibar span { color: #111; mix-blend-mode: normal; }
.ibar b { font-weight: inherit; }
.ibar b.indef { color: #e00; font-weight: bold; }   /* 不定（SANが最大値の80%以下） */
/* キャラクター一覧のアイコンで編集 */
.item .ico.clickable { cursor: pointer; }
.item .ico.clickable:hover { outline: 2px solid var(--accent2); }
/* 入力中 */
#typing { min-height: 16px; font-size: 11px; color: var(--muted); padding: 2px 2px 0; }
/* 発言キャラ選択の見出し */
.popmenu .mh.grouph { padding-top: 6px; font-weight: bold; color: #ccc; }
/* イニシアチブのステータス：文字と数字を白で縁取り、太い数字で表示 */
.ibar span {
  font-family: "Segoe UI", "Helvetica Neue", Arial, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em;
  text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, 0 -1px 0 #fff, 0 1px 0 #fff, -1px 0 0 #fff, 1px 0 0 #fff, 0 0 3px #fff;
}
.ibar .iv { font-weight: 800; }
.ibar b.indef { font-weight: 900; }
.item .head label.check { white-space: nowrap; gap: 3px; font-size: 12px; }
/* 1回だけのダイスは発言と同じ行に続けて表示 */
.msg .dice.inline, #msgwin .mw-dice.inline { display: inline; white-space: pre-wrap; }

/* ===== チャットの発言ごとの余白（参考画像に合わせて広め） ===== */
.msg { padding: 12px 0 13px; gap: 12px; line-height: 1.6; }
.msg .face { width: 44px; height: 44px; }
.msg .body .name { margin-right: 2px; }
.msg .text { margin-top: 2px; }
.msg.system { padding: 8px 0; }

/* ===== キャラクター一覧：1段目に名前（左）、2段目にチェック（右） ===== */
.item .head .cinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .head .cinfo .title { color: var(--text); font-weight: bold; text-align: left; }
.item .head .cchecks { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ===== ライトモード（≡メニューで切り替え。各自の画面だけ） ===== */
body.light {
  --bg: #eef0f3;
  --panel: #ffffff;
  --panel2: #f1f3f6;
  --line: #d3d7de;
  --text: #1f2328;
  --muted: #6a717c;
  --ok: #0b72c4;
  --ng: #d32f2f;
  --header: #f5f6f8;
}
body.light input, body.light select, body.light textarea, body.light code, body.light .members { background: #fff; color: var(--text); }
body.light .ibtn:hover { background: rgba(0,0,0,.07); }
body.light #topbar { background: rgba(255, 255, 255, .7); color: var(--text); box-shadow: 0 1px 0 var(--line); }
body.light #sceneSel { background: #fff; border-color: var(--line); }
body.light .bgmch { color: var(--text); }
body.light .bgmch.on { color: var(--accent2); }
body.light #boardArea { background-color: #c9cdd4; }
body.light #zoomBox { background: rgba(255,255,255,.9); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
body.light .msg { border-bottom-color: rgba(0,0,0,.07); }
body.light .msg .face.none, body.light .facebtn, body.light .facegrid .fc .noface { background-color: #d9dce2 !important; color: #555; }
body.light .msg .dice, body.light #msgwin .mw-dice { color: #2b4fb3; }
body.light .msg .dice.ok, body.light #msgwin .mw-dice.ok { color: var(--ok); }
body.light .msg .dice.ng, body.light #msgwin .mw-dice.ng { color: var(--ng); }
body.light .msg.system .systext { color: #555; }
body.light :is(#chatTabs, #chatTabs2) .ctab.active, body.light .ptab.active, body.light .stab.active, body.light :is(#chatTabs, #chatTabs2) .tool:hover { color: var(--text); }
body.light :is(#chatTabs, #chatTabs2) .ctab:hover { background: rgba(0,0,0,.04); }
body.light #diceBtns button { color: #333; }
body.light #diceBtns button:hover { background: rgba(0,0,0,.07); color: #000; }
body.light .popmenu { box-shadow: 0 6px 24px rgba(0,0,0,.2); }
body.light .popmenu .mi:hover, body.light .palline:hover, body.light .bdir:hover, body.light .bfile:hover, body.light .srow:hover { background: rgba(0,0,0,.06); }
body.light .popmenu .mh.grouph { color: #444; }
body.light .sndtabs.sub { background: rgba(0,0,0,.03); }
body.light .fwin { box-shadow: 0 8px 30px rgba(0,0,0,.2); }
body.light .srow .sbgm { color: #1f6fb8; }
body.light .dirty { color: #c56a00; }
body.light dialog::backdrop { background: rgba(0,0,0,.35); }
body.light #toast { background: rgba(30,30,30,.85); color: #fff; }
body.light #msgwin .mw-box { background: rgba(255,255,255,.94); border-color: rgba(0,0,0,.15); color: var(--text); }
body.light #msgwin .mw-name { border-bottom-color: rgba(0,0,0,.12); }
body.light #msgwin .mw-close { color: #777; }
body.light #msgwin .mw-close:hover { color: #000; }
body.light #typing { color: var(--muted); }
/* 盤面の上の文字は、テーマに関係なく白（暗い影付き） */
#initList, .piece .plabel { color: #fff; }

/* ダイスボタンの個数 */
#diceBtns button[data-dice] { position: relative; }
#diceBtns .dcount { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; font-weight: bold; line-height: 16px; text-align: center; }
#diceBtns .dclear { font-size: 18px; color: var(--text); padding: 2px 6px; line-height: 1; }
/* 横スクロールする帯のスクロールバーは表示しない（ホイールで左右に動かせる） */
.sndtabs, .paltabs, :is(#chatTabs, #chatTabs2) { scrollbar-width: none; -ms-overflow-style: none; }
.sndtabs::-webkit-scrollbar, .paltabs::-webkit-scrollbar, #chatTabs::-webkit-scrollbar, #chatTabs2::-webkit-scrollbar { display: none; height: 0; }

/* 重なり順：小窓（60〜999）＜ カットイン ＜ 右クリックメニュー ＜ 通知 */
#cutin { z-index: 5000; }
.popmenu { z-index: 6000; }
#toast { z-index: 7000; }

/* BGMの並べ替え：入る位置に線 */
.track.dropbefore { box-shadow: inset 0 2px 0 var(--accent2); }
.track.dropafter { box-shadow: inset 0 -2px 0 var(--accent2); }
.tracks .track[draggable="true"] { cursor: grab; }

/* カットインを閉じるボタン（右上） */
#cutin .cclose { position: absolute; top: 14px; right: 18px; pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.5); background: rgba(0,0,0,.55); color: #fff; font-size: 22px; line-height: 1; padding: 0; cursor: pointer; animation: none !important; }
#cutin .cclose:hover { background: rgba(0,0,0,.8); border-color: #fff; }

/* 画像なしのカットイン：右上の通知 */
#cutnote { position: fixed; top: 12px; right: 16px; z-index: 5001; display: flex; align-items: center; gap: 12px; min-width: 260px; max-width: min(420px, 90vw); padding: 12px 10px 12px 16px; background: rgba(32, 33, 37, .97); color: #eee; border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
#cutnote.in { animation: cnIn .25s ease-out; }
#cutnote.out { opacity: 0; transition: opacity .4s; }
@keyframes cnIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
#cutnote .cnicon svg.ic { width: 22px; height: 22px; }
#cutnote .cntext { flex: 1; min-width: 0; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
#cutnote .cclose { background: transparent; border: none; color: #ddd; font-size: 22px; line-height: 1; padding: 2px 6px; cursor: pointer; }
#cutnote .cclose:hover { color: #fff; }
body.light #cutnote { background: rgba(255,255,255,.98); color: #222; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
body.light #cutnote .cclose { color: #555; }
/* BGMの末尾発動の表示 */
.track .trig { font-size: 10px; color: #ffb74d; margin-left: 4px; }
body.light .track .trig { color: #c56a00; }

.item .ico.bgmico { display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--accent2); background: var(--panel); }

/* チャット欄の二列表示・非表示 */
#chatCols { flex: 1; min-height: 0; display: flex; }
.chatcol { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#chatCol1 { flex: 1; }
#chatCol2 { flex: none; width: 50%; }
#colSplit { width: 5px; flex: none; cursor: col-resize; background: var(--line); }
#colSplit:hover, #colSplit.drag { background: var(--accent2); }
#colSplit, #chatCol2 { display: none; }
body.chat2 #colSplit { display: block; }
body.chat2 #chatCol2 { display: flex; }
body.chathide #splitter { display: none; }

/* チャット欄の上部（右上に設定メニュー） */
#chatHead { flex: none; display: flex; justify-content: flex-end; align-items: center; padding: 2px 6px; border-bottom: 1px solid var(--line); }
#chatHead .ibtn svg.ic { width: 18px; height: 18px; }
body.popmode #chatHead { display: none; }
body.chatlock #splitter, body.chatlock #colSplit { cursor: default; }
body.chatlock #splitter:hover, body.chatlock #colSplit:hover { background: var(--line); }
/* ログの縦スクロールバーは目立たないように */
#log, #log2 { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
#log::-webkit-scrollbar, #log2::-webkit-scrollbar { width: 6px; }
#log::-webkit-scrollbar-track, #log2::-webkit-scrollbar-track { background: transparent; }
#log::-webkit-scrollbar-thumb, #log2::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
body.light #log, body.light #log2 { scrollbar-color: rgba(0,0,0,.15) transparent; }
body.light #log::-webkit-scrollbar-thumb, body.light #log2::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); }
/* チャット欄のダイスを少し小さく */
#diceBtns svg { width: 22px; height: 22px; }

/* 発言ごとの上下余白（参考画像） */
.msg { padding: 5px 0; gap: 10px; line-height: 1.5; }
.msg .face { width: 40px; height: 40px; }
.msg .text { margin-top: 0; }
.msg.system { padding: 4px 0; }
/* 差分：画像一覧表示（プルダウンを押すと画像の一覧が出る） */
.facegrid.faces3 { grid-template-columns: repeat(3, 72px); }
/* テキストのみのチャット欄 */
body.chattext .msg { display: block; padding: 2px 0; border-bottom: none; }
body.chattext .msg .face, body.chattext .msg .time { display: none; }
body.chattext .msg .body .name { margin-right: 0; }
body.chattext .msg .body .name::after { content: "："; }
body.chattext .msg .body > .text { display: inline; }
body.chattext .msg.system { padding: 2px 0; }

/* チャットの文字サイズ（各自） */
#log, #log2 { font-size: var(--chatfs, 14px); }
#log .msg .time, #log2 .msg .time { font-size: .8em; }
#log .msg.system .systext, #log2 .msg.system .systext { font-size: .93em; }
.popmenu .fsrow { display: flex; align-items: center; gap: 4px; padding: 2px 14px 6px; }
.popmenu .fsrow .mi { width: auto; padding: 3px 12px; border: 1px solid var(--line); border-radius: 4px; text-align: center; }
.popmenu .fsrow .fsv { min-width: 48px; text-align: center; }
/* テキストのみ表示の時刻（オンのときだけ） */
body.chattext.chattime .msg .time { display: inline; float: right; margin-left: 8px; }

/* チャット欄を隠しているときも右上の歯車は残す */
body.chathide #chatPanel { width: 0 !important; min-width: 0; }
body.chathide #chatPanel > :not(#chatHead) { display: none; }
body.chathide #chatHead { position: fixed; top: 0; right: 0; z-index: 30; border-bottom: none; padding: 4px 6px; }
body.chathide #topbar { padding-right: 40px; }
/* 固定した駒・パネルはマウスを乗せても枠を出さない */
.piece.locked:hover .pimg { outline: none; }

/* フォルダ移動：2階層目は1階層目にマウスを乗せたときに表示 */
.popmenu .mwrap > .sub { display: none; position: fixed; min-width: 150px; }
.popmenu .mwrap:hover > .sub { display: block; }
.popmenu .mwrap:hover > .mi { background: rgba(255,255,255,.08); }
.popmenu .mi .arrow { float: right; margin-left: 12px; color: var(--muted); }
body.light .popmenu .mwrap:hover > .mi { background: rgba(0,0,0,.06); }

/* 名前の色：既定のカラーパレット */
.popmenu .swatches { display: grid; grid-template-columns: repeat(5, 26px); gap: 6px; padding: 6px 14px 8px; }
.popmenu .swatches .sw { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); }
.popmenu .swatches .sw:hover { transform: scale(1.12); }
.popmenu .swatches .sw.sel { border-color: var(--accent2); box-shadow: 0 0 0 2px var(--accent2); }
body.light .popmenu .swatches .sw { border-color: rgba(0,0,0,.2); }
.colorbtn input { pointer-events: none; }
/* マークダウン */
.md-code { font-family: ui-monospace, Consolas, monospace; background: rgba(127,127,127,.2); border-radius: 3px; padding: 0 4px; font-size: .92em; }
.md-pre { font-family: ui-monospace, Consolas, monospace; background: rgba(127,127,127,.15); border-radius: 4px; padding: 6px 8px; margin: 2px 0; white-space: pre-wrap; font-size: .92em; }
.md-quote { border-left: 3px solid rgba(127,127,127,.5); padding-left: 8px; color: var(--muted); }
.md-h { font-weight: bold; }
.md-h1 { font-size: 1.4em; }
.md-h2 { font-size: 1.25em; }
.md-h3 { font-size: 1.1em; }
.msg .text a, #msgwin a { color: var(--accent2); }
/* シーン一覧：シーンごとの上書きボタン（小さめ）・アイコンで切り替え */
.srow { cursor: default; }
.srow .sthumb { cursor: pointer; }
.srow .sthumb:hover { outline: 2px solid var(--accent2); }
.srow .sbtn { flex: none; font-size: 10px; padding: 1px 5px; line-height: 1.5; }
.srow .stext { font-size: 10px; }

/* シーン一覧：2段（1段目=シーン名・保存・切り替えアイコン、2段目=BGM） */
.srow .sinfo { gap: 1px; }
.srow .sline1 { display: flex; align-items: center; gap: 2px; min-width: 0; }
.srow .sline1 .sname { flex: 1; min-width: 0; cursor: pointer; }
.srow .sline1 .sname:hover { text-decoration: underline; }
.srow .sline2 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.srow .sline2 .sbgm { flex: 1; min-width: 0; }
.srow .sline1 .ibtn { padding: 2px 3px; flex: none; position: relative; }
.srow .sline1 .ibtn svg.ic { width: 16px; height: 16px; }
.srow .sv-bgm .badge-note { position: absolute; right: -2px; bottom: -3px; font-size: 11px; line-height: 1; color: var(--accent2); font-weight: bold; }

/* シーン編集：文字色はキャラクターの右 */
.charopt { display: inline-flex; align-items: flex-end; gap: 8px; }
.charopt[hidden] { display: none; }

/* 画像の全体表示 */
.imgview { position: fixed; inset: 0; z-index: 6500; background: rgba(0,0,0,.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: zoom-out; }
.imgview img { max-width: 94vw; max-height: 88vh; object-fit: contain; box-shadow: 0 6px 30px rgba(0,0,0,.6); background: repeating-conic-gradient(#555 0 25%, #444 0 50%) 0 0 / 16px 16px; }
.imgview .ivname { color: #ddd; font-size: 13px; }
.imgview .ivclose { position: absolute; top: 12px; right: 16px; background: transparent; border: none; color: #fff; font-size: 28px; line-height: 1; }
/* パネルのサイズ変更つまみ（右下） */
.piece .presize { display: none; position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; border-radius: 3px; background: var(--accent2); border: 2px solid #fff; cursor: nwse-resize; z-index: 2; }
.piece.panel.canresize:hover .presize, .piece.panel.resizing .presize { display: block; }

/* ブラックアウト/ホワイトアウト（盤面の上に大きく重ねる） */
#fadeOv { position: absolute; left: -100000px; top: -100000px; width: 200000px; height: 200000px; pointer-events: none; opacity: 0; transition-property: opacity; transition-timing-function: ease; background: #000; }
#fadeOv.on { opacity: 1; }

/* 前景（表示優先度0）。マス目は前景のすぐ上 */
#fgLayer { position: absolute; inset: 0; background-repeat: no-repeat; z-index: 10000000; pointer-events: none; }
#grid { z-index: 10000000; }
/* 部屋一覧（トレーラー画像のカード） */
.roomgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 10px 0; }
.roomcard { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px; margin: 0; padding: 8px; }
.roomcard .rname { min-width: 0; cursor: pointer; font-size: 14px; }
.roomcard .rname:hover { text-decoration: underline; }
.rtrailer { position: relative; display: block; width: 100%; flex: none; aspect-ratio: 16 / 9; text-decoration: none; border-radius: 6px; background: #111 center / cover no-repeat; border: 1px solid var(--line); overflow: hidden; }
.roomcard .rtrailer:hover { outline: 2px solid var(--accent2); }
.rtrailer.noimg { display: flex; text-decoration: none; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; letter-spacing: .1em; }
.rtrailer.big { width: 100%; margin: 6px 0; }
.rtrailer .ronline { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 8px; }
.roomcard .ricons { display: flex; gap: 4px; justify-content: flex-end; }
.roomcard .ricons .ibtn { font-size: 15px; }
.roomcard .ricons .ibtn svg.ic { width: 18px; height: 18px; }
body.light .rtrailer { background-color: #d9dce2; }

/* 発言の操作（公開・編集・削除）はアイコン */
.msg .ops .ibtn { padding: 2px 4px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; line-height: 0; }
.msg .ops .ibtn svg.ic { width: 15px; height: 15px; }
/* シークレットダイス */
.msg .secretlabel { color: var(--secret); font-weight: bold; font-size: .9em; }
/* 部屋一覧は全画面 */
#lobby { align-items: stretch; justify-content: stretch; padding: 0; }
#lobby .card.wide { width: 100%; max-width: none; min-height: 100%; margin: 0; border-radius: 0; border: none; }
#lobby .roomgrid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.roomcard .rname small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 部屋一覧：部屋ごとの招待URL */
.roomcard .rinvite { width: 100%; font-size: 11px; padding: 3px 6px; color: var(--muted); }

/* 部屋一覧：インターネット用のアドレス（固定） */
#publicUrlForm label { display: flex; align-items: center; gap: 6px; }
#publicUrlForm #publicUrl { flex: 1; }
