* {
  box-sizing: border-box;
}

:root {
  --ink-pink: #ff2d78;
  --ink-cyan: #00e5c7;
  --ink-yellow: #ffd400;
  --ink-orange: #ff7a1a;
  --ink-purple: #6b2fd6;
  --ink-dark: #1a1330;
}

body {
  font-family: "Baloo 2", "Fredoka", "Hiragino Kaku Gothic ProN", sans-serif;
  background: var(--ink-dark);
  background-image:
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.03) 0px,
      rgba(255, 255, 255, 0.03) 24px,
      transparent 24px,
      transparent 48px
    ),
    radial-gradient(circle at 15% 10%, rgba(255, 45, 120, 0.35), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(0, 229, 199, 0.3), transparent 45%);
  color: #222;
  margin: 0;
  padding: 1.2rem 0.8rem;
  font-size: 15px;
  min-height: 100vh;
}

main {
  max-width: 520px;
  margin: 0 auto;
  background: #fff;
  border: 4px solid var(--ink-dark);
  border-radius: 18px;
  padding: 1.1rem;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.35);
}

h1 {
  font-family: "Fredoka", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  font-style: italic;
  margin: 0 0 0.3rem;
  color: var(--ink-pink);
  text-shadow:
    2px 2px 0 var(--ink-dark),
    -1px -1px 0 var(--ink-dark);
  transform: skewX(-4deg);
  letter-spacing: 0.5px;
}

/* 今どの画面にいるかが一目で分かるように、タイトルの下に画面名を出す
   (準備画面と本番画面は見た目が似ているため、遷移した実感を持ちやすくする) */
.screen-label {
  margin: 0 0 1rem;
  font-family: "Baloo 2", sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  background: var(--ink-purple);
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
}

h2 {
  font-family: "Baloo 2", sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  margin: 0 0 0.7rem;
  color: #fff;
  background: var(--ink-purple);
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}

.panel {
  background: #fff;
  border: 3px solid var(--ink-dark);
  border-radius: 14px;
  padding: 0.9rem;
  margin-bottom: 0.9rem;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: #555;
}

input[type="text"],
input[type="color"],
select {
  padding: 0.5rem;
  border-radius: 8px;
  border: 2px solid #ccc;
  background: #fff;
  color: #222;
  font-size: 0.9rem;
  font-family: inherit;
}

input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--ink-cyan);
}

input[type="text"] {
  width: 100%;
}

.key-preview {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: #1a9e6b;
  font-weight: 600;
  min-height: 1.2em;
}

.key-preview.invalid {
  color: var(--ink-pink);
}

.checkbox-row[hidden] {
  display: none;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.4rem 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: #555;
}

.checkbox-row input[type="checkbox"],
.checkbox-row input[type="radio"] {
  flex-shrink: 0;
}

.info-icon-button {
  width: auto;
  flex-shrink: 0;
  padding: 0 0.4rem;
  min-width: 1.6rem;
  height: 1.6rem;
  line-height: 1.4rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  background: var(--ink-cyan);
  color: var(--ink-dark);
  box-shadow: none;
  border-width: 2px;
}

button {
  width: 100%;
  padding: 0.75rem;
  border: 3px solid var(--ink-dark);
  border-radius: 999px;
  background: #f4f4f4;
  color: var(--ink-dark);
  font-family: "Baloo 2", sans-serif;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink-dark);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

button:hover {
  transform: translate(1px, 1px);
  box-shadow: 2px 2px 0 var(--ink-dark);
}

button:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}

button:disabled {
  background: #eee;
  color: #aaa;
  border-color: #ccc;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

#toPrepareButton,
#toLiveScreenButton,
#goLiveButton {
  background: linear-gradient(135deg, var(--ink-pink), #ff6aa8);
  color: #fff;
}

#goTestButton {
  background: linear-gradient(135deg, var(--ink-cyan), #6dfff0);
  color: var(--ink-dark);
}

.button-danger {
  background: repeating-linear-gradient(
    135deg,
    #ffcc00,
    #ffcc00 10px,
    #1a1330 10px,
    #1a1330 20px
  );
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}

.status {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  color: #555;
}

.status.error {
  color: var(--ink-pink);
  font-weight: 800;
}

/* Renderの無料プランがスリープから起きるまで(初回アクセス時30〜50秒ほど)、何の反応も無いと
   不安になる(素材追加等がWS接続待ちで無反応に見える)ため、待っている間だけ目立つ帯を出す。 */
.backend-waking-note {
  margin: 0 0 0.8rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  background: #fff3cd;
  border: 2px solid var(--ink-orange);
  color: #7a4a00;
}

/* ボタンを押してから画面が切り替わるまでの待ち時間、何も動きが無いと不安になるための
   簡易ローディング表示(エントリー画面のルーム作成・準備画面のバックエンド起床待ちで使う)。 */
.loading-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* display:flexの方が[hidden]のUAスタイル(display:none)より詳細度で勝ってしまうため、
   hidden属性を明示的に上書きしておく(.asset-add-row[hidden]と同じ理由のバグ。
   hidden=trueにしてもローディング表示が消えないまま残ってしまっていた)。 */
.loading-text[hidden] {
  display: none;
}

.spinner {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  border: 3px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--ink-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.view[hidden] {
  display: none;
}

.button-secondary {
  background: #eee;
  margin-top: 0.5rem;
}

.button-small {
  width: auto;
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
  border-radius: 999px;
}

.button-link {
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--ink-purple);
  font-weight: 700;
  text-decoration: underline;
  margin-top: 0.5rem;
}

.button-link:hover {
  transform: none;
  box-shadow: none;
}

.placeholder-note {
  color: #999;
  font-size: 0.8rem;
  text-align: center;
}

/* カメラの生映像は常時DOMに存在するが、見えるのはcanvas合成後のものだけ */
.hidden-source-video {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 2px;
  height: 2px;
  opacity: 0;
  pointer-events: none;
}

.workspace-video-panel {
  position: relative;
  padding: 0;
  overflow: hidden;
  border: 3px solid var(--ink-dark);
  border-radius: 14px;
}

.output-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
}

.asset-handle {
  position: absolute;
  cursor: grab;
  touch-action: none;
  border: 2px dashed rgba(255, 255, 255, 0.8);
  border-radius: 8px;
}

.asset-handle:active {
  cursor: grabbing;
}

/* リサイズ・変形・回転系のハンドルは、それぞれ.asset-handle(点線の枠)の子要素として
   相対位置(right/top等)で配置する。.asset-handleにtransform:rotate()を掛けると、
   子要素も一緒に回転して見える(見た目の配置にはCSSの回転だけで対応でき、
   JS側は角度を考慮したドラッグの計算だけ気にすればよい)。 */
.asset-resize-handle {
  position: absolute;
  right: -9px;
  bottom: -9px;
  width: 18px;
  height: 18px;
  background: var(--ink-yellow);
  border: 2px solid var(--ink-dark);
  border-radius: 50%;
  cursor: nwse-resize;
  touch-action: none;
}

/* 辺の中点(白い○): 幅か高さのどちらかだけを変える「変形」用ハンドル */
.asset-edge-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid var(--ink-dark);
  border-radius: 50%;
  touch-action: none;
}

.asset-edge-handle.edge-top {
  top: -7px;
  left: calc(50% - 7px);
  cursor: ns-resize;
}

.asset-edge-handle.edge-bottom {
  bottom: -7px;
  left: calc(50% - 7px);
  cursor: ns-resize;
}

.asset-edge-handle.edge-left {
  left: -7px;
  top: calc(50% - 7px);
  cursor: ew-resize;
}

.asset-edge-handle.edge-right {
  right: -7px;
  top: calc(50% - 7px);
  cursor: ew-resize;
}

/* 右上: ドラッグで回転 */
.asset-rotate-handle {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 16px;
  height: 16px;
  background: var(--ink-cyan);
  border: 2px solid var(--ink-dark);
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
}

/* 左上: クリックで90度刻みにスナップ(ドラッグではないのでtouch-actionは制限しない) */
.asset-snap-handle {
  position: absolute;
  top: -9px;
  left: -9px;
  width: 16px;
  height: 16px;
  background: var(--ink-pink);
  border: 2px solid var(--ink-dark);
  border-radius: 50%;
  cursor: pointer;
}

/* 左下: クリックのたびに「元の比率」→「配信画面いっぱい」→「配信画面の外側の余裕いっぱい」
   (以降は後者2つを往復)と進む。本来の縦横比が分かる素材にしか出さない(syncHandles参照)。 */
.asset-fit-handle {
  position: absolute;
  bottom: -9px;
  left: -9px;
  width: 16px;
  height: 16px;
  background: var(--ink-purple);
  border: 2px solid var(--ink-dark);
  border-radius: 50%;
  cursor: pointer;
}

/* 枠が大きく拡大された時、中央にも同じ○一式を出すミニクラスター(2026-07-14新設)。
   大きさの変化しない固定サイズで枠の中心に置くことで、外周まで手を伸ばさなくても
   リサイズ・変形・回転・スナップ・元の比率の操作ができるようにする(syncHandles参照)。
   中の○(.asset-resize-handle等)は既存クラスをそのまま再利用しており、right/bottom等の
   位置指定がこの固定サイズの枠を基準にした相対値になるため、CSSの追加は不要。 */
.asset-mini-handle-cluster {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 96px;
  height: 96px;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  pointer-events: none;
}

.asset-mini-handle-cluster > * {
  pointer-events: auto;
}

/* 実際に配信される範囲を示す目印。DOM要素なので配信データ自体には映らない。 */
.broadcast-area-guide {
  position: absolute;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  border-radius: 4px;
  pointer-events: none;
}

/* --- 本番画面: 上部の配信操作バー --- */

.live-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.topbar-button {
  width: auto;
  flex: 1 1 auto;
  padding: 0.55rem 0.8rem;
  font-size: 0.88rem;
}

.topbar-button-secondary {
  background: #eee;
}

#endLiveButton {
  background: linear-gradient(135deg, var(--ink-orange), #ffb15c);
  color: #fff;
}

.live-topbar .button-link {
  width: 100%;
  margin-top: 0.2rem;
  text-align: center;
}

.live-topbar .status {
  width: 100%;
}

/* --- 素材box(準備画面・本番画面で共通) --- */

.asset-tray-panel h2 {
  font-size: 0.8rem;
}

.asset-tray {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.asset-row {
  border: 2px solid #eee;
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  background: #fafafa;
}

.asset-row.dragging {
  opacity: 0.4;
}

.asset-row-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.asset-drag-icon {
  cursor: grab;
  color: var(--ink-purple);
  flex-shrink: 0;
}

.asset-type-icon {
  flex-shrink: 0;
}

.asset-row-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  font-weight: 600;
}

.asset-row.placeholder {
  background: transparent;
  border-style: dashed;
}

.asset-row.placeholder .asset-row-label {
  color: #aaa;
  font-weight: 500;
}

.asset-row-edit,
.asset-row-duplicate,
.asset-row-remove {
  width: auto;
  flex-shrink: 0;
  padding: 0.3rem 0.6rem;
  background: #eee;
  font-size: 0.75rem;
  box-shadow: none;
  border-width: 2px;
}

.asset-row-lock {
  width: auto;
  flex-shrink: 0;
  padding: 0 0.3rem;
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 0.9rem;
  cursor: pointer;
}

.asset-row-lock:disabled {
  cursor: default;
  opacity: 0.7;
}

.event-toggle {
  appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #ccc;
  border: 2px solid var(--ink-dark);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}

.event-toggle::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s ease;
}

.event-toggle:checked {
  background: var(--ink-cyan);
}

.event-toggle:checked::before {
  left: 19px;
}

.asset-edit-panel {
  margin: 0.5rem 0 0.1rem 1.6rem;
  padding: 0.6rem;
  background: #fff;
  border: 2px dashed #ddd;
  border-radius: 10px;
}

.asset-edit-panel select {
  width: auto;
}

/* --- 素材追加テーブル --- */

.asset-add-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0;
  border-top: 1px dashed #eee;
}

/* display:flexの方が[hidden]のUAスタイル(display:none)より詳細度で勝ってしまうため、
   hidden属性を明示的に上書きしておく(招待URL行・プレビューURL行が権限上非表示のはずなのに
   実際には表示され続けてしまうバグの原因だった)。 */
.asset-add-row[hidden] {
  display: none;
}

.asset-add-row:first-of-type {
  border-top: none;
}

/* --- マイプリセット(準備画面、最大4枠) --- */

.personal-preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0;
  border-top: 1px dashed #eee;
}

.personal-preset-row[hidden] {
  display: none;
}

.personal-preset-row:first-child {
  border-top: none;
}

.personal-preset-row input[type="text"] {
  flex: 1 1 8rem;
  width: auto;
}

.personal-preset-row button {
  width: auto;
  flex-shrink: 0;
}

/* --- プリセットの中身一覧(マイプリセット行の「見る」から開く読み取り専用オーバーレイ) --- */

.preset-contents-list {
  margin: 0 0 0.8rem;
  max-height: 50vh;
  overflow-y: auto;
}

.preset-contents-row {
  padding: 0.4rem 0.2rem;
  border-top: 1px dashed #eee;
  font-size: 0.9rem;
}

.preset-contents-row:first-child {
  border-top: none;
}

.asset-add-label {
  flex: 1 1 auto;
  min-width: 4.5em;
  white-space: nowrap;
  font-size: 0.85rem;
  font-weight: 600;
}

.asset-add-row input[type="text"] {
  flex: 2 1 auto;
  min-width: 0;
  font-size: 0.78rem;
}

.se-button {
  flex: 1 1 auto;
}

/* --- 複数人ロビー: 招待URL・参加者一覧 --- */

#lobbyPanel h2 {
  font-size: 0.8rem;
}

#participantList {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

#participantList .asset-row select {
  width: auto;
  font-size: 0.75rem;
  padding: 0.2rem 0.4rem;
}

/* --- 自分のアバター位置プレースホルダー(複数人ロビー) --- */

.avatar-self-handle {
  border-color: var(--ink-cyan);
}

#pipThreadButton {
  margin-top: 0.6rem;
}

/* --- 素材の追加/編集オーバーレイ --- */

.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 6, 20, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  /* 筆談の入力バー(.written-chat-bar、z-index:500)より必ず手前に来るようにする
     (筆談を有効にしている間に素材の編集画面を開くと、パネル下端のOK/キャンセルが
     入力バーに隠れて押せなくなる不具合があったため)。 */
  z-index: 600;
}

.overlay-backdrop[hidden] {
  display: none;
}

.overlay-panel {
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 14px;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.45);
}

.overlay-panel .checkbox-row,
.overlay-panel label {
  color: #333;
}

/* 決定/キャンセルをパネル下端に固定し、一覧側だけがその下にスクロールしていくようにする
   (検索結果を選ぶたびに毎回一番下までスクロールしなくて済むように)。左右+下は
   .overlay-panelの余白(0.9rem、.panel基準)分を打ち消して端まで白背景を敷き、
   スクロール中の内容がボタンの下に隠れて見えるのを防ぐ。 */
.overlay-actions {
  display: flex;
  gap: 0.5rem;
  position: sticky;
  bottom: -0.9rem;
  margin: 0.8rem -0.9rem -0.9rem;
  padding: 0.55rem 0.9rem 0.9rem;
  background: #fff;
  border-top: 2px solid #eee;
}

/* display:flexがUA標準の[hidden]{display:none}より優先されてしまうため、明示的に上書きする
   (.asset-add-row[hidden]と同じ理由のバグ。プリセット拡大確認中に外側のキャンセル/追加ボタンを
   hidden属性で隠す仕組み(renderPresetPicker参照)が効かなくなっていた)。 */
.overlay-actions[hidden] {
  display: none;
}

/* 音声診断ログ(BGM+マイク同時使用時の無音化調査用)。iPad等DevToolsが使えない端末でも
   その場でコピーできるよう、画面上に直接ログを表示する。 */
.audio-debug-log {
  max-height: 50vh;
  overflow-y: auto;
  background: #1a1330;
  color: #9ef7d6;
  font-family: monospace;
  font-size: 0.72rem;
  line-height: 1.4;
  padding: 0.6rem;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 常時画面下部に居座るため、他のボタンより一回り小さくして圧迫感を減らす。 */
.overlay-actions button {
  flex: 1 1 auto;
  padding: 0.55rem;
  font-size: 0.9rem;
  border-width: 2px;
  box-shadow: 2px 2px 0 var(--ink-dark);
}

.overlay-name-row {
  margin-bottom: 0.7rem;
}

.overlay-name-row input[type="text"] {
  width: 100%;
}

.alarm-duration-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.4rem 0;
}

/* display:flexを明示指定しているため、hidden属性を明示的に上書きしておく
   (「繰り返しがちなCSSのハマりどころ」参照。筆談のメッセージを消すタイミング設定で
   input.hiddenを切り替えるため書き忘れずに追加した)。 */
.alarm-duration-row[hidden] {
  display: none;
}

.alarm-duration-row input[type="number"] {
  width: 4rem;
}

/* --- 筆談の入力バー(この機器の画面下部に固定。canvasには映らないローカル専用UI) --- */
.written-chat-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem;
  background: rgba(26, 19, 48, 0.92);
  border-top: 3px solid var(--ink-pink);
}

/* display:flexを明示指定しているため、hidden属性を明示的に上書きしておく
   (「繰り返しがちなCSSのハマりどころ」参照。書き忘れるとhidden=trueにしても消えなくなる)。 */
.written-chat-bar[hidden] {
  display: none;
}

/* --- 同一スレへの配信衝突対応: 準備完了ボタン横の赤/緑○、配信中の告知バナー(2026-07-14新設) --- */

.stream-status-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--ink-dark);
  flex-shrink: 0;
}

.stream-status-dot[hidden] {
  display: none;
}

.stream-status-dot.occupied {
  background: var(--ink-pink);
}

.stream-status-dot.free {
  background: #2ecc71;
}

.stream-collision-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 550;
  display: flex;
  justify-content: center;
  padding: 0.7rem 1rem;
  background: rgba(26, 19, 48, 0.94);
  border-bottom: 3px solid var(--ink-yellow);
  color: #fff;
  font-weight: 700;
  text-align: center;
}

.stream-collision-banner[hidden] {
  display: none;
}

.written-chat-bar-name-row {
  display: flex;
  align-items: center;
}

.written-chat-bar-name-row input[type="text"] {
  width: auto;
  max-width: 45%;
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  opacity: 0.85;
}

.written-chat-bar-message-row {
  display: flex;
  gap: 0.5rem;
}

.written-chat-bar-message-row input[type="text"] {
  flex: 1 1 auto;
  width: auto;
}

.written-chat-bar-message-row button {
  width: auto;
  flex-shrink: 0;
  padding: 0.6rem 1rem;
}

/* --- オーバーレイ内のタブ切り替え(資料の「編集画面想定」に合わせたタブUI) --- */

.overlay-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.8rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px dashed #ddd;
}

.overlay-tab-button {
  width: auto;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
  border: 2px solid var(--ink-dark);
  background: #eee;
  color: var(--ink-dark);
  box-shadow: none;
}

.overlay-tab-button.active {
  background: var(--ink-purple);
  color: #fff;
}

.overlay-tab-content {
  min-height: 6rem;
}

/* --- プリセット選択(サムネ一覧→拡大確認→決定の2段階UI。スマホの写真選択画面のような見た目) --- */

.preset-thumb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.4rem 0;
}

.preset-thumb-card {
  width: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem;
  background: #f4f4f4;
  border: 2px solid var(--ink-dark);
  border-radius: 10px;
  box-shadow: none;
  font-size: 0.7rem;
  color: var(--ink-dark);
}

.preset-thumb-card.selected {
  border-color: var(--ink-cyan);
  background: #e6fffb;
}

/* --- 音声(BGM)/効果音のプリセット一覧(サムネではなく試聴プレイヤー付きの行一覧) --- */

.audio-preset-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  border: 2px solid #ddd;
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.5rem;
}

.audio-preset-row.selected {
  border-color: var(--ink-cyan);
  background: #e6fffb;
}

.audio-preset-row-info {
  flex: 1;
  min-width: 8rem;
}

.audio-preset-row-preview {
  height: 32px;
  max-width: 220px;
}

.audio-preset-row-select {
  width: auto;
  flex-shrink: 0;
}

.preset-thumb-visual {
  display: block;
  border-radius: 6px;
  object-fit: cover;
}

.preset-thumb-placeholder {
  background: repeating-linear-gradient(45deg, #ccc, #ccc 6px, #ddd 6px, #ddd 12px);
}

/* --- Live2Dプリセットの選択行(サムネ+名前+説明文、2026-07-14新設) --- */

.avatar-preset-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0;
  padding: 0.5rem;
  border: 2px solid #ddd;
  border-radius: 10px;
  cursor: pointer;
}

.avatar-preset-option:has(input:checked) {
  border-color: var(--ink-cyan);
  background: #e6fffb;
}

.avatar-preset-option input[type="radio"] {
  flex-shrink: 0;
}

.avatar-preset-option-thumb {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

/* 「自分の枠」用: サムネ画像を持たないため、同じサイズの枠に絵文字を中央表示するだけの代用 */
.avatar-preset-option-thumb-emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: rgba(107, 47, 214, 0.15);
  border-radius: 8px;
}

.avatar-preset-option-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.avatar-preset-option-label {
  font-weight: 700;
  color: var(--ink-dark);
}

.avatar-preset-option-desc {
  font-size: 0.75rem;
  color: #777;
}

/* フリー素材タブのその場検索(input+種類セレクト+検索ボタン)。
   全体共通のbutton/input[type="text"]がどちらもwidth:100%のため、そのままだと
   flexが効かず入力欄が潰れてボタンだけ広がってしまう。ここで明示的にautoへ戻す。 */
.preset-search-row {
  display: flex;
  gap: 0.4rem;
  margin: 0.4rem 0;
  align-items: stretch;
}

.preset-search-row input[type='text'] {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.preset-search-row select {
  flex: 0 0 auto;
  width: auto;
}

.preset-search-row button {
  flex: 0 0 auto;
  width: auto;
  white-space: nowrap;
}

/* admin.htmlのプリセット一覧カード内、名前変更/削除ボタンを横並びにする */
.preset-card-buttons {
  display: flex;
  gap: 0.3rem;
}

.preset-preview-area {
  display: flex;
  justify-content: center;
  margin: 0.6rem 0;
}

/* 拡大確認画面で、一覧に戻らずプレビュー中身の左右に他のプリセットへ移動できる矢印ボタン。
   プリセットが1個以下の時は移動先が無い(または自分自身に戻るだけ)ので表示しない。 */
.preset-preview-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: 0.6rem 0;
}

.preset-preview-nav-btn {
  flex: 0 0 auto;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
}

/* --- トリミング(パワポの画像トリミングのような、実際の映像/画像に枠を重ねて4辺をドラッグする方式) --- */

.crop-stage {
  position: relative;
  margin: 0.6rem auto;
  background: #000;
  border: 2px solid var(--ink-dark);
  border-radius: 8px;
  overflow: hidden;
}

.crop-source-visual {
  position: absolute;
  object-fit: fill;
}

.crop-box {
  position: absolute;
  border: 1px dashed var(--ink-cyan);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
}

/* 見た目は枠線(.crop-box)の細い点線だけにし、ハンドル自体は透明にする
   (掴みやすさのためヒット領域だけは広めに確保する)。 */
.crop-handle {
  position: absolute;
  background: transparent;
}

.crop-handle-top,
.crop-handle-bottom {
  left: 0;
  right: 0;
  height: 10px;
  cursor: ns-resize;
  touch-action: none;
}

.crop-handle-top {
  top: -5px;
}

.crop-handle-bottom {
  bottom: -5px;
}

.crop-handle-left,
.crop-handle-right {
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
  touch-action: none;
}

.crop-handle-left {
  left: -5px;
}

.crop-handle-right {
  right: -5px;
}

/* --- 時間トリミング(バー両端のハンドルで使用区間を選ぶ。iPhoneの動画トリミングのような見た目) --- */

.trim-timeline {
  position: relative;
  height: 40px;
  margin: 0.6rem 0;
  background: #444;
  border: 2px solid var(--ink-dark);
  border-radius: 6px;
  /* overflow:hiddenにすると、範囲が0%/100%に達した時ハンドルがちょうど境界で
     クリップされて掴めなくなるため、意図的に付けない(帯の見た目はグラデーション/
     dim要素自体が幅で収まっているので、はみ出しても実害は無い)。 */
}

.trim-dim {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.55);
}

.trim-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--ink-dark);
  cursor: ew-resize;
  touch-action: none;
}

.trim-position-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  pointer-events: none;
}

.trim-preview-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.4rem 0;
}

.trim-preview-swatch {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 2px solid var(--ink-dark);
  border-radius: 6px;
}

.trim-preview-row button {
  width: auto;
}

/* --- 素材box一覧: 普通動画/BGMの再生バー(枠の下部の細いストリップ) --- */

.asset-row-playback {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.5rem 0.35rem;
}

.asset-row-playback-btn {
  width: auto;
  flex-shrink: 0;
  padding: 0.2rem 0.45rem;
  background: #eee;
  font-size: 0.75rem;
  box-shadow: none;
  border-width: 2px;
}

.asset-row-playback-slider {
  flex: 1 1 auto;
  width: auto;
  height: 18px;
  padding: 0;
  border: none;
  box-shadow: none;
  background: none;
}

/* --- 半透明ドラッグプレビュー(iPhone風) --- */

/* 配信映像には映らない編集用の目印なので、パワポの選択枠のように塗りは付けず点線の枠だけにする */
.asset-handle.dragging-active {
  border-color: var(--ink-cyan);
  border-style: solid;
}

.asset-resize-handle.dragging-active,
.asset-edge-handle.dragging-active,
.asset-rotate-handle.dragging-active {
  background: var(--ink-pink);
}

/* --- 効果音/エフェクト/イベントの「発動」トリガー行 --- */

.asset-row-trigger {
  width: auto;
  flex-shrink: 0;
  padding: 0.3rem 0.7rem;
  background: var(--ink-cyan);
  color: var(--ink-dark);
  font-size: 0.78rem;
  box-shadow: none;
  border-width: 2px;
}

/* --- イベントbox(素材boxの下に、イベントが1つ以上ある時だけ現れる第2のリスト) --- */
/* displayを明示指定しないため、hidden切り替えはUAスタイルのdisplay:noneに任せる
   (「繰り返しがちなCSSのハマりどころ」参照。ここでは踏んでいない)。 */
.event-tray-wrap {
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 2px dashed #ddd;
}

.event-step-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

.event-step-row select {
  width: auto;
  flex: 1 1 130px;
  min-width: 0;
}

.event-step-row input[type="range"] {
  flex: 1 1 110px;
}

.event-step-fine-button {
  width: auto;
  flex-shrink: 0;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  border-width: 2px;
  box-shadow: none;
}

.event-step-delay-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-purple);
  flex-shrink: 0;
  white-space: nowrap;
}

.event-steps-editor {
  margin-bottom: 0.6rem;
}

/* --- 準備画面: 配信音量メーター(枠・ラベル無しの省スペースな細いバーのみ) --- */

.volume-meter-bar {
  position: relative;
  height: 6px;
  margin: 0 0 0.9rem;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(to right, #2ecc71 0%, #2ecc71 55%, #ffd400 75%, #ff7a1a 88%, #ff2d78 100%);
}

.volume-meter-mask {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background: #fff;
  transition: width 0.05s linear;
}

/* --- 素材boxの並び順の連番 --- */

.asset-row-number {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-purple);
  min-width: 1.4em;
  text-align: right;
}

/* --- マイクの3段階ルーティングスライダー(オフ/ルーム内のみ/配信中) --- */

.mic-routing-slider {
  appearance: none;
  width: 70px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 2px solid var(--ink-dark);
  background: linear-gradient(to right, #ccc 0%, #ccc 33.3%, var(--ink-cyan) 33.3%, var(--ink-cyan) 66.6%, var(--ink-pink) 66.6%, var(--ink-pink) 100%);
  cursor: pointer;
}

.mic-routing-slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink-dark);
  cursor: pointer;
}

.mic-routing-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink-dark);
  cursor: pointer;
}

/* --- BGM/効果音の音量スライダー行 --- */

.asset-row-volume {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 1.6rem;
  padding: 0.1rem 0;
}

.asset-row-volume-icon {
  flex-shrink: 0;
  font-size: 0.8rem;
}

.asset-row-volume-slider {
  flex: 1 1 auto;
  width: auto;
  height: 18px;
  padding: 0;
  border: none;
  box-shadow: none;
  background: none;
}

/* --- Live2Dアバターの仕草ボタン一覧行(狙った仕草・エフェクトを個別に選んで再生できるように) --- */

.asset-row-gestures {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-left: 1.6rem;
  padding: 0.3rem 0 0.1rem;
}

.asset-row-gesture-button {
  width: auto;
  flex-shrink: 0;
  padding: 0.25rem 0.6rem;
  background: var(--ink-yellow);
  color: var(--ink-dark);
  font-size: 0.74rem;
  box-shadow: none;
  border-width: 2px;
}

/* 赤面トグルは一発トリガーの仕草ボタンと見分けが付くよう、ON/OFFで背景色を変える
   (OFF=グレー、ON=ピンク)。仕草ボタンと同じ.asset-row-gesture-buttonの上に重ねる。 */
.asset-row-blush-toggle {
  background: #ddd;
}

.asset-row-blush-toggle.active {
  background: var(--ink-pink);
  color: #fff;
}

/* --- テキスト入力欄の下線/ルビボタン --- */

.rich-text-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.rich-text-toolbar .button-secondary {
  width: auto;
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
}

/* --- テキスト編集画面のプレビュー --- */

.text-preview-canvas {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  aspect-ratio: 280 / 90;
  margin: 0 auto 0.8rem;
  border: 2px solid var(--ink-dark);
  border-radius: 10px;
}

/* 筆談プレビューは名前+メッセージの縦方向レイアウトのため、テキスト機能用(280/90)より
   縦長のキャンバス実寸(280x140)に合わせてアスペクト比だけ上書きする。 */
.written-chat-preview-canvas {
  aspect-ratio: 280 / 140;
}

/* --- 接続者数ボタン(押すと参加者・役割管理オーバーレイを開く) --- */

.participant-summary-button {
  width: auto;
  background: #fff;
  color: var(--ink-purple);
  text-align: left;
}

/* --- 会話・話し合いスペース --- */

.chat-messages {
  max-height: 10rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
  padding: 0.4rem;
  background: #fafafa;
  border: 2px solid #eee;
  border-radius: 10px;
}

.chat-message {
  font-size: 0.82rem;
}

.chat-message .chat-message-name {
  font-weight: 800;
  color: var(--ink-purple);
  margin-right: 0.4rem;
}

/* --- admin.html: 同時接続数の推移グラフ --- */

.stats-range-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.stats-range-button {
  width: auto;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
}

.stats-range-button.active {
  background: var(--ink-purple);
  color: #fff;
}

#statsChartContainer {
  position: relative;
}

.stats-chart-svg {
  width: 100%;
  height: auto;
  display: block;
  font-family: "Baloo 2", sans-serif;
}

.stats-chart-gridline {
  stroke: #e5e5e5;
  stroke-width: 1;
}

.stats-chart-axis-label {
  fill: #999;
  font-size: 11px;
}

.stats-chart-area {
  fill: var(--ink-orange);
  fill-opacity: 0.1;
  stroke: none;
}

.stats-chart-line {
  fill: none;
  stroke: var(--ink-orange);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.stats-chart-end-dot,
.stats-chart-hover-dot {
  fill: var(--ink-orange);
  stroke: #fff;
  stroke-width: 2;
}

.stats-chart-end-label {
  fill: var(--ink-dark);
  font-size: 12px;
  font-weight: 700;
}

.stats-chart-crosshair {
  stroke: #ccc;
  stroke-width: 1;
}

.stats-chart-tooltip {
  position: absolute;
  transform: translate(-50%, -130%);
  background: var(--ink-dark);
  color: #fff;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  font-size: 0.75rem;
  line-height: 1.4;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1;
}

/* --- 参加者・役割管理オーバーレイ内の行 --- */

.participant-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
