/* 同時視聴（/watch/{platform}/{id}）。色は意見箱・過去ログと同じ変数を使う */
/* 画面の幅いっぱいを使う。映像は「横幅」と「画面の高さ」の小さいほうに合わせて最大まで大きくする */
:root { --watch-chrome: 185px; }            /* ヘッダー（タイトル＋メニュー）＋余白＋下のボタン列のだいたいの高さ */
html.theater { --watch-chrome: 64px; }      /* シアターモード：ヘッダーとフッターを隠す */
html.theater .site-header, html.theater .site-footer { display: none; }
html.theater main { padding-top: 8px; padding-bottom: 8px; }
main > .wrap { max-width: none; }
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
@media (max-width: 900px) { .watch { grid-template-columns: 1fr; } }

/* プレイヤーと流れるコメント */
.player {
    position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden;
    width: min(100%, calc((100vh - var(--watch-chrome)) * 16 / 9)); margin: 0 auto;
}
@media (max-width: 900px) { .player { width: 100%; } }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player:fullscreen { border-radius: 0; aspect-ratio: auto; }
.danmaku { position: absolute; inset: 0; pointer-events: none; overflow: hidden; contain: strict; }
.danmaku.off { display: none; }
.danmaku .dm {
    position: absolute; left: 100%; white-space: nowrap; font-weight: 700; line-height: 1.25;
    color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000, 1px 1px 2px #000;
    will-change: transform;
}
.danmaku .dm.ext { opacity: .85; }
/* スタンプ（エモート）画像 */
.emote { height: 1.6em; width: auto; vertical-align: middle; margin: 0 1px; }
.danmaku .emote { margin: 0 2px; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .6)); }
.danmaku .dm.mine { color: #ffe08a; }

/* コメント欄のポップアップ（PC のみ）。開いている間はこのページのコメント欄を隠して映像を広げる */
@media (max-width: 900px), (pointer: coarse) { .pc-only { display: none !important; } }
.stage-bar .btn[hidden] { display: none; }
.watch.popped { grid-template-columns: 1fr; }
.watch.popped .side { display: none; }
.popout-note { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 0; font-size: .82rem; color: var(--muted); }
.popout-note[hidden] { display: none; }
.popout-note .btn { padding: 3px 10px; font-size: .8rem; }

.stage-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 8px; font-size: .85rem; }
.stage-bar .grow { flex: 1; }
.stage-bar .btn { padding: 4px 10px; font-size: .82rem; }
.stage-bar .btn[aria-pressed="true"] { background: var(--accent-bg); }
.stage-bar .room { font-weight: 700; overflow-wrap: anywhere; }
.pf { font-size: .72rem; font-weight: 700; border-radius: 4px; padding: 1px 6px; margin-right: 6px; color: #fff; }
.pf-youtube { background: #c4302b; } .pf-twitch { background: #6441a5; } .pf-kick { background: #3a8f10; }

/* 右側：コメント欄 */
.side { display: flex; flex-direction: column; height: calc(100vh - var(--watch-chrome) + 40px); min-height: 360px; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: none; border: 0; padding: 9px 6px; font: inherit; font-size: .85rem; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); }
.tabpanel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.tabpanel[hidden] { display: none; }
.ytchat { flex: 1; width: 100%; border: 0; }
.source-bar { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 6px 10px; font-size: .78rem; border-bottom: 1px solid var(--line); }
.source-bar label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.ext-status { color: var(--muted); }
.muted { color: var(--muted); }

.clist { list-style: none; margin: 0; padding: 4px 10px; flex: 1; overflow-y: auto; overscroll-behavior: contain; font-size: .88rem; }
.clist li { padding: 4px 0; border-bottom: 1px dashed var(--line); line-height: 1.5; overflow-wrap: anywhere; }
.clist li:last-child { border-bottom: 0; }
.clist .meta { display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; font-size: .72rem; color: var(--muted); }
.clist .nm { font-weight: 700; color: var(--ok); }
.clist li.ext .nm { color: var(--muted); }
.clist .src { font-size: .65rem; font-weight: 700; color: #fff; border-radius: 3px; padding: 0 4px; }
.clist .act { margin-left: auto; display: inline-flex; gap: 6px; }
.clist .act button { background: none; border: 0; padding: 0; font: inherit; font-size: .7rem; color: var(--muted); cursor: pointer; }
.clist .act button:hover { color: var(--danger); text-decoration: underline; }
.clist li.mine { box-shadow: inset 3px 0 0 var(--accent); padding-left: 6px; }
.clist .empty { color: var(--muted); text-align: center; padding: 20px 0; border: 0; }

/* 実況スレ（掲示板のスレ）のレスと、スレの案内 */
.clist li.thr .nm { color: var(--muted); }
.clist li.thr .tx { white-space: pre-wrap; }
.clist .src-thr { background: #8a5a2b; }
.thread-bar { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; padding: 6px 10px; font-size: .78rem; border-bottom: 1px solid var(--line); background: var(--accent-bg); }
.thread-bar:empty { display: none; }
.thread-bar a.thr-title { font-weight: 700; overflow-wrap: anywhere; }
.thread-bar .btn { padding: 2px 8px; font-size: .74rem; }
.thread-bar .grow { flex: 1; }
.thread-bar .thr-form { display: flex; gap: 6px; width: 100%; }
.thread-bar .thr-form .field { flex: 1; min-width: 0; padding: 4px 8px; font-size: .82rem; }
.thread-bar .form-msg { width: 100%; }
.cform .to-thread { display: flex; align-items: center; gap: 4px; font-size: .74rem; color: var(--muted); cursor: pointer; }
.cform .to-thread[hidden] { display: none; }
.danmaku .dm.thr { color: #ffe9c7; }

.cform { display: grid; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.cform .row { display: flex; gap: 6px; }
.cform .row .field { flex: 1; min-width: 0; }
.cform .field { padding: 6px 9px; font-size: .9rem; }
.form-msg { margin: 0; min-height: 1em; font-size: .78rem; }
.form-msg.err { color: var(--danger); }
.side-note { margin: 0; padding: 0 10px 8px; font-size: .7rem; color: var(--muted); }

/* スマホ：映像とボタン列を画面の上に貼り付け、その下の残りの高さにコメント欄（最新コメントと入力欄）を収める */
@media (max-width: 900px) {
    main { padding-top: 10px; }
    .watch { gap: 8px; }
    /* --vv-top / --vvh は watch.js が「実際に見えている範囲」（キーボードを除いた部分）に合わせて入れる */
    .stage { position: sticky; top: var(--vv-top, 0px); z-index: 25; background: var(--bg); padding: 6px 0 4px; margin-top: -6px; }
    .player { border-radius: 6px; }
    .stage-bar { flex-wrap: nowrap; overflow-x: auto; margin-top: 6px; gap: 6px; font-size: .78rem; scrollbar-width: none; }
    .stage-bar::-webkit-scrollbar { display: none; }
    .stage-bar > * { flex: none; }
    .stage-bar .grow { display: none; }
    .stage-bar .btn { padding: 3px 8px; font-size: .74rem; }
    .side {
        height: calc(100vh - (100vw - 32px) * 9 / 16 - 64px);
        height: calc(var(--vvh, 100dvh) - (100vw - 32px) * 9 / 16 - 64px);   /* キーボードやアドレスバーの出し入れにも合わせる */
        min-height: 150px;
    }
    .tab { padding: 6px; font-size: .78rem; }
    .source-bar { padding: 4px 10px; font-size: .72rem; }
    .side-note { display: none; }
    .cform { padding: 6px 8px; gap: 4px; }
    .cform .field { font-size: 16px; padding: 5px 8px; }   /* 16px 未満だと iPhone が入力時に拡大してしまう */
    /* ブラウザが入力欄までスクロールするとき、上に貼り付いた映像の下に隠れないようにする */
    .cform .field, .clist { scroll-margin-top: calc((100vw - 32px) * 9 / 16 + 72px); }
    .form-msg:empty { display: none; }
    /* コメント入力中（キーボードが出ているとき）は、名前欄・タブ・切り替え欄を隠してコメントを多く見せる */
    .watch.typing .tabs, .watch.typing .source-bar, .watch.typing .thread-bar, .watch.typing .cform [name="name"] { display: none; }
}

/* 配信者向け：OBS 用のコメント表示の案内（PC のみ） */
.obs-box { margin-top: 8px; font-size: .82rem; }
.obs-box summary { cursor: pointer; color: var(--muted); }
.obs-box summary:hover { color: var(--primary); }
.obs-body { margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.obs-body p { margin: 0 0 8px; }
.obs-body ol { margin: 4px 0 8px; padding-left: 1.4em; }
.obs-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 8px; }
.obs-row label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.obs-row .field { flex: 1 1 320px; min-width: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8rem; padding: 5px 8px; }
.obs-row .btn { padding: 4px 12px; font-size: .82rem; }
