:root {
  --pen-cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg stroke='%23fff' stroke-width='4'%3E%3Cpath d='M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z'/%3E%3Cpath d='m15 5 4 4'/%3E%3C/g%3E%3Cg stroke='%232b2a27' stroke-width='2'%3E%3Cpath d='M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z' fill='%23fff'/%3E%3Cpath d='m15 5 4 4'/%3E%3C/g%3E%3C/svg%3E") 2 22, crosshair; /* ペンのときのマウスの形（ペン先が書く位置） */
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #f8f6f1;
  --border: #e3ddd1;
  --text: #2b2a27;
  --muted: #7a756b;
  --primary: #3b5bdb;
  --primary-text: #ffffff;
  --danger: #d6363b;
  --ok: #2f9e44;
  --warn: #e8a317;
  --dock: rgba(32, 31, 29, 0.92);
  --dock-text: #f1efe9;
  --speaking: #40c057;
  --radius-fill: rgba(59, 91, 219, 0.14);
  --radius-line: rgba(59, 91, 219, 0.45);
  --shadow: 0 6px 24px rgba(30, 25, 15, 0.12);
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.ic-svg { flex: none; vertical-align: -0.15em; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px;
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
}
.hint { font-size: 12px; color: var(--muted); margin: 0; }

.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select {
  padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  font-size: 16px; color: var(--text);
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.field textarea {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  font: inherit; font-size: 15px; color: var(--text); resize: vertical; line-height: 1.6;
}

/* ---------- 入室画面 ---------- */
/* 入室画面は1画面に収める（ノートPCの高さでもスクロールしないように、余白と入力欄を詰める） */
.join { min-height: 100%; display: grid; place-items: center; padding: 8px 16px; }
.join-card {
  width: min(400px, 100%); display: grid; gap: 8px; padding: 16px 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.join-card h1 { margin: -8px 0 0; font-size: 22px; letter-spacing: 0.02em; }
.join-eyebrow { margin: 0; font-size: 12px; color: var(--muted); }
.join-card .field { gap: 4px; }
.join-card .field input, .join-card .field select { padding: 8px 12px; font-size: 15px; }
.join-card .field textarea { padding: 8px 12px; font-size: 14px; line-height: 1.5; }
.join-card .check-field { margin: 0; }
.join-card .avatar-preview { width: 52px; height: 52px; font-size: 20px; }
.join-card .avatar-edit { gap: 10px; }
.join-card .avatar-edit-actions { gap: 2px; }
.join-card .hint { font-size: 11px; }
.join-card .join-account { margin: 0; }
.join-admin { margin: 0; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary); font-weight: 600; }

/* ---------- 全体の配置 ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.app > .main { flex: 1; } /* 注意書きの有無に関係なく、部屋の表示が残りの高さいっぱいになるように */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 15px; }
.room-title { font-size: 14px; color: var(--muted); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.conn[data-state="ok"]::before { background: var(--ok); }
.conn.slow[data-state="ok"]::before { background: var(--warn); }
.conn[data-state="connecting"]::before { background: var(--warn); }
.conn[data-state="error"]::before, .conn[data-state="off"]::before { background: var(--danger); }

.banner {
  display: grid; gap: 4px; padding: 8px 16px; font-size: 13px;
  background: #fff6e0; border-bottom: 1px solid #f0dca8; color: #6b5310;
}
.banner-line { line-height: 1.6; }
.banner-line .ic-svg { margin-right: 6px; }
.banner-line .btn { margin-left: 8px; }
.banner .btn { padding: 4px 10px; font-size: 12px; }

.main { min-height: 0; display: grid; grid-template-columns: 1fr 320px; }
.main.panel-closed { grid-template-columns: 1fr; }
.main.panel-closed .panel { display: none; }
.topbar .icon-btn.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.stage { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* ---------- 部屋（マップ） ---------- */
.map-wrap { flex: 1; min-height: 0; display: flex; padding: 0; overflow: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.map-wrap::-webkit-scrollbar { display: none; } /* 見える範囲はドラッグで動かすので、スクロールバーは出さない */
.map-wrap > .map { margin: auto; } /* 小さいときは真ん中、大きいときはスクロール */

.zoom {
  position: absolute; right: 16px; bottom: 16px; z-index: 6; display: flex; align-items: center;
  padding: 4px; border-radius: 12px; background: var(--dock); color: var(--dock-text); box-shadow: var(--shadow);
}
.zoom button {
  height: 36px; min-width: 36px; display: grid; place-items: center; border: none; border-radius: 8px;
  background: transparent; color: inherit; font-size: 13px; font-variant-numeric: tabular-nums;
}
.zoom button:hover { background: rgba(255,255,255,0.12); }
#zoom-level { min-width: 52px; }
.map {
  position: relative; flex: none; cursor: grab;
  overflow: hidden;
  background-color: #efe6d2;
  background-image:
    linear-gradient(rgba(255,255,255,0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.35) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center; touch-action: none;
}
.map.has-wallpaper { background-size: 100% 100%; } /* 部屋の比率を壁紙に合わせてあるので、そのまま全体が収まる */

/* ---------- グリッド表示 ---------- */
.grid-view {
  position: absolute; inset: 0 0 76px 0; z-index: 5; display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 12px;
  background: #16151a;
}
.grid-tiles { display: grid; align-content: start; gap: 8px; overflow-y: auto; }
.grid-tile {
  position: relative; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: #2a2830; color: #fff; border: 3px solid transparent;
}
.grid-tile.speaking { border-color: var(--speaking); }
.grid-tile .face { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; font-weight: 700; color: #fff; }
.grid-tile .face.has-photo { width: 100%; height: 100%; border-radius: 0; }
.grid-tile .tile-name {
  position: absolute; left: 6px; bottom: 6px; max-width: calc(100% - 12px); padding: 2px 8px; border-radius: 6px;
  background: rgba(0,0,0,0.55); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.grid-tile .tile-mic { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,0.55); }
.grid-main { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; }
.grid-main video { width: 100%; height: 100%; object-fit: contain; }
.grid-empty { position: absolute; margin: 0; color: #aaa; font-size: 14px; text-align: center; }
.grid-shares { position: absolute; top: 0; left: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.grid-shares button { padding: 5px 10px; border: none; border-radius: 999px; background: rgba(255,255,255,0.12); color: #fff; font-size: 12px; }
.grid-shares button.active { background: var(--primary); }
/* 画面共有がないとき：タイルだけを大きく並べる */
.grid-view.no-share { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.grid-view.no-share .grid-main { display: none; }
.grid-view.no-share .grid-tiles {
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 12px; align-content: start;
}
.grid-view.no-share .grid-tile { aspect-ratio: 1; border-radius: 6px; background: #fff; }
.grid-view.no-share .grid-tile .face:not(.has-photo) { width: 40%; height: 40%; font-size: 48px; }
.grid-view.no-share .tile-name { font-size: 13px; }
.grid-view.no-share .tile-mic { top: auto; bottom: 8px; right: 8px; width: 28px; height: 28px; }
@media (max-width: 760px) {
  .grid-view.no-share .grid-tiles { grid-auto-flow: row; grid-template-columns: repeat(2, 1fr); overflow-y: auto; }
  .grid-view { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .grid-tiles { order: 2; grid-auto-flow: column; grid-auto-columns: 120px; overflow-x: auto; }
}

/* ---------- 部屋の中の画面共有の窓 ---------- */
.screen-win {
  position: absolute; background: #000; border-radius: 8px; border: 2px solid #fff;
  box-shadow: 0 6px 24px rgba(0,0,0,0.3); cursor: zoom-in;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; /* つかんで動かすときに青く選択されないように */
}
.screen-win video::selection, .screen-win *::selection { background: transparent; }
.screen-win video { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 6px; pointer-events: none; }
.screen-wait { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: #aaa; font-size: 12px; pointer-events: none; }
.screen-bar {
  position: absolute; left: -2px; right: -2px; bottom: calc(100% + 4px); height: 30px;
  display: flex; align-items: center; gap: 6px; padding: 0 4px 0 10px; border-radius: 8px;
  background: var(--dock); color: var(--dock-text); font-size: 12px; white-space: nowrap; cursor: default;
}
.screen-win.movable, .screen-win.movable .screen-bar { cursor: grab; }
.dragging-share .screen-win.movable { cursor: grabbing; }
.screen-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.screen-bar button {
  height: 24px; min-width: 24px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 0 6px;
  border: none; border-radius: 6px; background: transparent; color: inherit; font-size: 11px;
}
.screen-bar button:hover { background: rgba(255,255,255,0.15); }
.screen-bar .stop { background: var(--danger); }
.screen-win .obj-handle { z-index: 3; width: 14px; height: 14px; }
.screen-win .obj-handle[data-corner="nw"] { left: -7px; top: -7px; }
.screen-win .obj-handle[data-corner="ne"] { right: -7px; top: -7px; }
.screen-win .obj-handle[data-corner="sw"] { left: -7px; bottom: -7px; }
.screen-win .obj-handle[data-corner="se"] { right: -7px; bottom: -7px; }
.screen-win.pen-on { cursor: var(--pen-cursor); }
.screen-bar [data-pen].active { background: var(--primary); }
.screen-bar .mini-colors { display: none; gap: 3px; padding: 0 2px; }
.screen-win.pen-on .mini-colors { display: inline-flex; }
.mini-colors span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.mini-colors span.active { border-color: #fff; }
.screen-win.pen-on [data-undo] { display: inline-flex; }
.screen-bar [data-undo] { display: none; }
/* 書いている人の名前の札 */
.pen-labels { position: absolute; pointer-events: none; }
.map-pen-surface { position: absolute; inset: 0; pointer-events: none; }
.map.pen-mode #map-pen-canvas { cursor: var(--pen-cursor); }
.pen-label {
  position: absolute; transform: translate(8px, -120%); padding: 2px 8px; border-radius: 999px;
  color: #fff; font-size: 11px; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ---------- 掲示物 ---------- */
.obj {
  position: absolute; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.obj img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.obj-text {
  width: 100%; height: 100%; overflow: hidden; padding: calc(10px * var(--mapscale, 1)) calc(12px * var(--mapscale, 1));
  background: rgba(255, 255, 255, 0.95); border-radius: calc(8px * var(--mapscale, 1)); box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  font-size: calc(18px * var(--mapscale, 1)); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; color: #2b2a27;
}
.obj-text a { color: var(--primary); }
.obj.has-link { cursor: pointer; }
.obj.has-link:hover { filter: brightness(1.04); }
.obj.editing { outline: 1.5px solid rgba(255,255,255,0.95); box-shadow: 0 0 0 2.5px rgba(0,0,0,0.25); cursor: move; }
.obj-handle {
  position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 1.5px solid #2b2a27; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.obj-handle[data-corner="nw"] { left: -6px; top: -6px; cursor: nwse-resize; }
.obj-handle[data-corner="ne"] { right: -6px; top: -6px; cursor: nesw-resize; }
.obj-handle[data-corner="sw"] { left: -6px; bottom: -6px; cursor: nesw-resize; }
.obj-handle[data-corner="se"] { right: -6px; bottom: -6px; cursor: nwse-resize; }
.obj-text { position: relative; }
.obj-text.is-empty::before { content: attr(data-placeholder); position: absolute; left: 0; right: 0; top: 0; padding: inherit; opacity: 0.55; pointer-events: none; }
.obj-grip {
  position: absolute; left: 50%; bottom: -34px; margin-left: -12px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; background: var(--primary); color: #fff; border: 2px solid #fff; cursor: move; box-shadow: var(--shadow);
}
.obj.editing .obj-text { cursor: text; outline: none; user-select: text; -webkit-user-select: text; }
.obj-toolbar {
  position: fixed; z-index: 30; display: grid; gap: 6px; padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.ot-row, .ot-group { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.obj-toolbar { max-width: calc(100vw - 24px); }
.ot-btn {
  min-width: 32px; height: 32px; display: grid; place-items: center; padding: 0 6px; border: none; border-radius: 8px;
  background: transparent; font-size: 14px;
}
.ot-btn:hover { background: var(--surface-2); }
.ot-btn.active { background: var(--primary); color: var(--primary-text); }
.ot-small { font-size: 12px; }
.ot-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
#ot-size { width: 62px; height: 32px; border: 1px solid var(--border); border-radius: 8px; padding: 0 4px; font: inherit; font-size: 13px; background: var(--surface); }
.ot-swatch { position: relative; display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 6px; border-radius: 8px; cursor: pointer; font-size: 11px; color: var(--muted); }
.ot-swatch:hover { background: var(--surface-2); }
.ot-swatch { border: none; background: transparent; font: inherit; font-size: 11px; }
.ot-chip {
  width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 6px;
  background: linear-gradient(var(--chip, #fff), var(--chip, #fff)), repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 8px 8px;
}
/* 色を選ぶ窓 */
.cp {
  position: absolute; z-index: 5; width: 220px; padding: 12px; display: grid; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.cp-sv { position: relative; height: 140px; border-radius: 6px; cursor: crosshair; touch-action: none; }
.cp-knob { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.4); pointer-events: none; }
.cp-bar { position: relative; height: 12px; border-radius: 6px; cursor: pointer; touch-action: none; }
.cp-hue { background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.cp-alpha { background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 8px 8px; }
.cp-alpha-fill { position: absolute; inset: 0; border-radius: 6px; }
.cp-thumb { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.3); pointer-events: none; }
.ot-done {
  display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; margin-left: 4px; border: none; border-radius: 8px;
  background: var(--primary); color: var(--primary-text); font-size: 13px; font-weight: 600;
}
.ot-link-row { display: flex; gap: 6px; }
.ot-link-row input { flex: 1; min-width: 220px; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }

.radius {
  position: absolute; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none;
  background: rgba(59, 91, 219, 0.3); border: none; /* 縁は付けず、青の半透明だけ。色の多い壁紙でも見える濃さにする */
  transition: left 0.35s ease, top 0.35s ease, opacity 0.4s ease;
  opacity: 0; /* ふだんは隠し、動いているときと範囲を調整しているときだけ出す */
}
.radius.show { opacity: 1; }
.radius.pink { background: rgba(236, 72, 153, 0.3); }
.dragging .radius, .dragging .avatar.self, .dragging .avatar.pulled { transition: none; }

.avatar:not(.self) { cursor: pointer; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.member { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.avatar {
  position: absolute; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 4px;
  transition: left 0.35s ease, top 0.35s ease; touch-action: none;
}
.avatar-face {
  position: relative; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px;
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  transition: box-shadow 0.15s ease;
}
.avatar.self .avatar-face { cursor: grab; }
.avatar.speaking .avatar-face { box-shadow: 0 0 0 4px var(--speaking), 0 2px 8px rgba(0,0,0,0.18); }
.avatar-name {
  max-width: 140px; padding: 2px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(255,255,255,0.92); border: 1px solid var(--border);
}
.avatar-badge {
  position: absolute; bottom: -4px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; background: #222; color: #fff; border: 2px solid #fff;
}
.avatar-badge.admin { left: -6px; background: #e6a700; color: #222; }
.avatar-badge.muted { right: auto; left: -6px; top: -4px; bottom: auto; } /* 右下は入室日数のバッジに使う */
.avatar-badge .ic-svg { width: 11px; height: 11px; }

/* ---------- 画面共有の一覧 ---------- */
.shares { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: calc(100% - 32px); }
.share-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow);
}
.share-chip.mine { border-color: var(--danger); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: live 1.4s ease-in-out infinite; }
@keyframes live { 50% { opacity: 0.35; } }
.avatar-sharing {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 600;
}
.member .sharing-mark { color: var(--danger); }
.share-chip .btn { padding: 5px 10px; font-size: 12px; border-radius: 999px; }


/* ---------- ツールバー（フッター型。画面の下に固定） ---------- */
:root { --tb-size: 64px; }
.toolbar {
  position: absolute; z-index: 6; display: flex; align-items: center; gap: 2px; padding: 0 12px;
  background: var(--surface); color: var(--text);
}
.stage.tb-bottom .toolbar { left: 0; right: 0; bottom: 0; height: var(--tb-size); border-top: 1px solid var(--border); }
.stage.tb-left .toolbar, .stage.tb-right .toolbar {
  top: 0; bottom: 0; width: 76px; flex-direction: column; padding: 10px 0; gap: 2px; overflow-y: auto; scrollbar-width: none;
}
.stage.tb-left .toolbar { left: 0; border-right: 1px solid var(--border); }
.stage.tb-right .toolbar { right: 0; border-left: 1px solid var(--border); }
.stage.tb-bottom .tb-mic { margin-right: auto; }
.tb-spacer { flex: 1; }
.stage.tb-bottom .tb-spacer { flex: 0; margin-left: auto; }
.tb-group { position: relative; }
.tb-btn {
  min-width: 58px; height: 52px; padding: 4px 6px; display: grid; justify-items: center; align-content: center; gap: 3px;
  border: none; border-radius: 10px; background: transparent; color: var(--text); cursor: pointer;
}
.tb-label { font-size: 11px; line-height: 1; white-space: nowrap; color: var(--muted); }
.tb-btn:hover { background: var(--surface-2); }
.tb-btn:hover .tb-label { color: var(--text); }
.tb-btn.is-on { color: #2b8a3e; background: rgba(64, 192, 87, 0.12); }
.tb-btn.is-on .tb-label { color: #2b8a3e; }
.tb-btn.is-off { color: var(--danger); background: rgba(214, 54, 59, 0.1); }
.tb-btn.is-off .tb-label { color: var(--danger); }
.tb-btn:disabled { opacity: 0.45; cursor: default; }
.tb-leave, .tb-leave .tb-label { color: var(--danger); }
.tb-leave:hover { background: rgba(214, 54, 59, 0.1); }
.tb-mic { display: flex; align-items: center; }
.tb-caret {
  width: 20px; height: 52px; display: grid; place-items: center; padding: 0; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.tb-caret:hover { background: var(--surface-2); color: var(--text); }
.stage.tb-left .tb-caret svg, .stage.tb-right .tb-caret svg { transform: rotate(90deg); }
.stage.tb-right .tb-caret svg { transform: rotate(-90deg); }
.stage.tb-right .tb-mic { flex-direction: row-reverse; }
/* ツールバーのぶん、部屋・拡大縮小・グリッド表示などをよける */
.stage.tb-bottom .map-wrap { margin-bottom: var(--tb-size); }
.stage.tb-left .map-wrap { margin-left: 76px; }
.stage.tb-right .map-wrap { margin-right: 76px; }
.stage.tb-bottom .zoom { bottom: calc(var(--tb-size) + 14px); }
.stage.tb-right .zoom { right: 92px; }
.stage.tb-bottom .grid-view { bottom: var(--tb-size); }
.stage.tb-left .grid-view { left: 76px; bottom: 0; }
.stage.tb-right .grid-view { right: 76px; bottom: 0; }
.stage.tb-bottom .timer-chip { bottom: calc(var(--tb-size) + 14px); }
.stage.tb-left .timer-chip, .stage.tb-right .timer-chip { bottom: 16px; }
/* 左・右のときは、メニューを横に開く */
.stage.tb-left .toolbar .menu { left: calc(100% + 10px); right: auto; bottom: auto; top: 0; transform: none; }
.stage.tb-right .toolbar .menu { right: calc(100% + 10px); left: auto; bottom: auto; top: 0; transform: none; }
.stage.tb-left .toolbar, .stage.tb-right .toolbar { overflow: visible; }
/* マイクテスト */
.mic-menu { min-width: 300px; }
.dev-select { width: 100%; height: 36px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; font: inherit; font-size: 13px; background: var(--surface); color: var(--text); }
.mic-meter { display: flex; gap: 3px; }
.mic-meter span { flex: 1; height: 10px; border-radius: 2px; background: var(--border); }
.mic-meter span.on { background: #40c057; }
.stage.tb-bottom .tb-mic .menu { left: 0; transform: none; }

.menu {
  position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%);
  min-width: 190px; padding: 6px; display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.menu button {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: none; border-radius: 8px;
  background: transparent; text-align: left; font-size: 14px; white-space: nowrap;
}
.menu button:hover { background: var(--surface-2); }
/* メニューの中の「スタート」などの主ボタンは、メニューの見た目に上書きされないようにする */
.menu .btn-primary { justify-content: center; background: var(--primary); color: var(--primary-text); font-weight: 600; }
.menu .btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.menu-wide { min-width: 260px; padding: 14px; gap: 10px; }
.pen-menu-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tb-pen-colors, .tb-pen-sizes { display: inline-flex; gap: 6px; }
.tb-pen-colors { display: grid; grid-template-columns: repeat(6, 26px); gap: 8px; }
.menu .tb-pen-colors button, .mini-colors span { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15); } /* 白も見えるように */
.menu .tb-pen-colors button { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid transparent; }
.menu .tb-pen-colors button.active { border-color: var(--text); }
.menu .tb-pen-sizes button { width: 30px; height: 30px; padding: 0; justify-content: center; border: 1px solid var(--border); border-radius: 8px; }
.menu .tb-pen-sizes button.active { border-color: var(--primary); background: var(--surface-2); }
.tb-pen-sizes span { display: block; border-radius: 50%; background: var(--text); }
.menu .pen-menu-row .btn { padding: 6px 10px; font-size: 12px; }
.slider-label { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.radius-value { color: var(--primary); }
.radius.all { display: none; }
input[type="range"] { width: 100%; accent-color: var(--primary); }

/* ---------- タイマー・全体アナウンス ---------- */
.timer-form { display: grid; gap: 8px; }
.timer-form input {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); font-size: 18px; width: 100%;
}
.timer-chip {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 6;
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 12px;
  background: var(--dock); color: var(--dock-text); box-shadow: var(--shadow);
}
.timer-left { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-chip.ending .timer-left { color: #ffa8a8; }
.timer-by { font-size: 11px; opacity: 0.75; }
.timer-chip button { width: 28px; height: 28px; display: grid; place-items: center; border: none; border-radius: 8px; background: transparent; color: inherit; }
.timer-chip button:hover { background: rgba(255,255,255,0.12); }
.avatar.megaphone .avatar-face { width: 76px; height: 76px; font-size: 26px; box-shadow: 0 0 0 5px rgba(240, 140, 0, 0.55), 0 2px 8px rgba(0,0,0,0.18); }

/* ---------- チャット・リアクション ---------- */
.menu-chat { width: 320px; padding: 12px; gap: 10px; }
.reaction-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.menu .reaction-grid button { justify-content: center; padding: 6px 0; font-size: 22px; line-height: 1; }
.chat-form {
  display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 12px;
  border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
}
.chat-form input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; font-size: 14px; padding: 8px 0; }
.menu .chat-send, .chat-send {
  width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: none; border-radius: 10px;
  background: var(--primary); color: var(--primary-text);
}
.chat-bubble {
  position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); z-index: 2;
  width: max-content; max-width: 220px; padding: 6px 10px; border-radius: 12px;
  background: #fff; color: var(--text); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere;
  box-shadow: 0 3px 12px rgba(0,0,0,0.18); pointer-events: none;
  animation: bubble 5s ease forwards;
}
.chat-bubble::after {
  content: ""; position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #fff;
}
@keyframes bubble {
  0% { opacity: 0; transform: translate(-50%, 6px); }
  6% { opacity: 1; transform: translate(-50%, 0); }
  88% { opacity: 1; }
  100% { opacity: 0; }
}
.reaction-float {
  position: absolute; left: 50%; top: -6px; transform: translate(-50%, 0); font-size: 30px; pointer-events: none;
  animation: float-up 2.6s ease-out forwards;
}
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -14px) scale(1.1); }
  80% { opacity: 1; transform: translate(-50%, -40px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -56px) scale(1); }
}

.tabs { display: flex; gap: 4px; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 5px; padding: 7px 9px; border-radius: 10px;
  border: none; background: transparent; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.tabs { min-width: 0; }
.tab.active { background: var(--surface-2); color: var(--text); }
.unread {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 11px; display: inline-grid; place-items: center;
}
.icon-btn { position: relative; }
.dot { position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }
.tab-body { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.chat-body { flex: 1; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 12px; padding: 2px; }
.chat-msg { position: relative; display: grid; grid-template-columns: 30px 1fr; gap: 8px; border-radius: 8px; }
.chat-msg:hover { background: var(--surface-2); }
.msg-del {
  position: absolute; top: 0; right: 0; display: none; width: 28px; height: 28px; place-items: center;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted);
}
.chat-msg:hover .msg-del { display: grid; }
.msg-del:hover { color: var(--danger); }
@media (hover: none) { .msg-del { display: grid; opacity: 0.7; } }
.dm-home { display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1; }
.dm-home > .btn { align-self: flex-start; }
.dm-picker, .dm-list { display: grid; gap: 4px; overflow-y: auto; }
.dm-picker { max-height: 40vh; padding: 6px; border: 1px solid var(--border); border-radius: 12px; }
.dm-row {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px; padding: 8px;
  border: none; border-radius: 10px; background: transparent; text-align: left;
}
.dm-row:hover { background: var(--surface-2); }
.dm-row .dm-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-row .dm-last { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-thread { display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1; }
.dm-thread-head { display: flex; align-items: center; gap: 8px; }
.dm-peer { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; min-width: 0; }
.profile-card .btn { margin-top: 10px; padding: 7px 12px; font-size: 13px; }
.chat-meta { display: flex; align-items: baseline; gap: 8px; font-size: 12px; color: var(--muted); }
.chat-meta strong { color: var(--text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-text { font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-text.big { font-size: 28px; line-height: 1.2; }
.chat-text a { color: var(--primary); }
.chat-empty { color: var(--muted); font-size: 13px; text-align: center; margin: 24px 0; }

/* ---------- 右側の参加者パネル ---------- */
.panel {
  min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--surface); border-left: 1px solid var(--border); overflow: hidden;
}
#tab-people { overflow-y: auto; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-head h2 { margin: 0; font-size: 15px; }
.search {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
}
.search input { border: none; background: transparent; outline: none; flex: 1; min-width: 0; font-size: 14px; color: var(--text); }
.room-list { display: grid; gap: 2px; }
.room { border-radius: 10px; }
/* 今いる部屋は、見出しの行を色で塗って示す（枠線は付けない） */
.room.current .room-head, .room.current .room-head:hover { background: var(--primary); color: #fff; }
.room.current .room-count, .room.current .room-caret, .room.current .row-more { color: rgba(255,255,255,0.85); }
.room.current .room-caret:hover, .room.current .row-more:hover { background: rgba(255,255,255,0.15); color: #fff; }
.room-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 6px; }
.room-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; border: none; background: transparent; padding: 2px; text-align: left; color: inherit;
}
.room-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.room-action {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); font-size: 12px; white-space: nowrap;
}
.room-action.icon { padding: 5px; color: var(--muted); border-color: transparent; background: transparent; }
.room-action.icon:hover { color: var(--text); background: var(--surface-2); }
.room-action.icon.danger:hover { color: var(--danger); }
/* 部屋の編集・削除は、マウスを乗せたときだけ出す（スマホなどマウスがない端末では常に出す） */
@media (hover: hover) {
  .room-head .room-action.icon { display: none; }
  .room-head:hover .room-action.icon, .room-head:focus-within .room-action.icon { display: inline-flex; }
}
.room-members { list-style: none; margin: 0; padding: 0 10px 10px; display: grid; gap: 6px; }
.member { display: flex; align-items: center; gap: 8px; font-size: 13px; border-radius: 8px; padding: 2px 4px; margin: 0 -4px; cursor: pointer; }
.member:hover { background: var(--surface-2); }
.member-dot {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: #fff; font-size: 12px; font-weight: 700;
}
.member-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-you { color: var(--muted); font-size: 12px; }
.member .ic-svg { color: var(--muted); }
.member .admin-mark { color: #c28a00; }
.show-more {
  display: block; width: calc(100% - 20px); margin: -2px 10px 10px; padding: 6px; border: none; border-radius: 8px;
  background: var(--surface-2); color: var(--muted); font-size: 12px;
}
.show-more:hover { color: var(--text); }
.room-empty { padding: 0 12px 10px; font-size: 12px; color: var(--muted); margin: 0; }

/* ---------- 画面共有を見る ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 20; display: grid; grid-template-rows: auto 1fr;
  background: #111;
}
.viewer-head {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: #1d1c1a; color: #eee; flex-wrap: wrap;
}
.viewer-title { font-weight: 600; font-size: 14px; flex: 1; min-width: 120px; }
.pen-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pen-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px;
  border: 1px solid #3a3936; background: #2a2926; color: #eee;
}
.pen-btn.active { background: var(--primary); border-color: var(--primary); }
.pen-colors, .pen-sizes { display: flex; gap: 4px; padding: 0 4px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; }
.swatch.active { border-color: #fff; }
.size-btn {
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; border: 1px solid #3a3936; background: #2a2926;
}
.size-btn span { display: block; border-radius: 50%; background: #eee; }
.size-btn.active { border-color: #fff; }
.viewer-body { position: relative; min-height: 0; }
.viewer-body video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pen-canvas { position: absolute; pointer-events: none; touch-action: none; }
.viewer-wait { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: #aaa; font-size: 14px; }

/* ---------- 小さな窓 ---------- */
.pop {
  position: fixed; z-index: 30; width: min(360px, calc(100vw - 32px)); padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.pop form { display: grid; gap: 14px; }
.avatar-edit { display: flex; align-items: center; gap: 14px; }
.profile-modal { left: 50% !important; top: 50% !important; transform: translate(-50%, -50%); width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: 24px; border-radius: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-head .icon-btn { border: none; }
.profile-modal .avatar-preview { width: 88px; height: 88px; font-size: 32px; }
.count { justify-self: end; font-size: 11px; color: var(--muted); }
.self-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; padding: 0;
}
.avatar-preview {
  width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center;
  color: #fff; font-size: 24px; font-weight: 700; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.avatar-edit-actions { display: grid; gap: 6px; justify-items: start; }
.avatar-edit-actions .btn { padding: 7px 12px; font-size: 13px; }
.has-photo { background-size: cover !important; background-position: center !important; }
.profile-card h3 .member-dot { width: 32px; height: 32px; font-size: 13px; }
.pop-actions { display: flex; justify-content: flex-end; gap: 8px; }

.profile-card {
  position: fixed; z-index: 25; width: min(300px, calc(100vw - 24px)); max-height: 60vh; overflow: auto; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.profile-card h3 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.profile-card h3 .ic-svg { color: #c28a00; }
.profile-card p { margin: 0; font-size: 13px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-card p a { color: var(--primary); }
.profile-card .empty { color: var(--muted); }
.map.panning { cursor: grabbing; }
.map.drop-target { outline: 3px dashed var(--primary); outline-offset: -3px; }
.toast-action {
  margin-left: 12px; padding: 4px 10px; border: 1px solid rgba(255,255,255,0.4); border-radius: 8px;
  background: transparent; color: #fff; font-size: 12px; font-weight: 600;
}
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 40;
  padding: 10px 16px; border-radius: 10px; background: #222; color: #fff; font-size: 13px; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
}

.only-mobile { display: none; }

/* ---------- スマホ ---------- */
@media (max-width: 760px) {
  .only-mobile { display: inline-flex; }
  .main { grid-template-columns: 1fr; }
  .topbar { gap: 10px; padding: 8px 12px; }
  .brand { display: none; }
  .panel {
    position: fixed; inset: auto 0 0 0; height: 75vh; z-index: 15; border-left: none;
    border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
  }
  .main.panel-closed .panel { display: none; }
  .map-wrap { padding: 0; }
  .zoom { right: 8px; bottom: 76px; }
  .avatar-face { width: 38px; height: 38px; font-size: 15px; }
  .avatar-name { font-size: 11px; max-width: 96px; }
  /* スマホ：ツールバーはいつも下。文字は小さくし、位置の切り替えは出さない */
  .stage.tb-left .toolbar, .stage.tb-right .toolbar { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--tb-size); flex-direction: row; padding: 0 4px; border: none; border-top: 1px solid var(--border); }
  .stage .map-wrap { margin: 0 0 var(--tb-size) 0 !important; }
  .stage .zoom { right: 8px !important; bottom: calc(var(--tb-size) + 10px) !important; }
  .stage .grid-view { left: 0 !important; right: 0 !important; bottom: var(--tb-size) !important; }
  .stage .toolbar .menu { left: 50% !important; right: auto !important; top: auto !important; bottom: calc(100% + 10px) !important; transform: translateX(-50%) !important; }
  .toolbar { padding: 0 4px; padding-bottom: env(safe-area-inset-bottom); gap: 0; justify-content: space-between; }
  .tb-btn { min-width: 0; width: 36px; height: 44px; padding: 2px; }
  .tb-label { display: none; } /* 幅が足りないので、スマホはアイコンだけ */
  .tb-caret { width: 14px; }
  .tb-mic, .stage.tb-bottom .tb-mic { margin-right: 0; }
  .tb-spacer { display: none; }
  .stage .tb-caret svg { transform: none !important; }
  .stage .tb-mic { flex-direction: row !important; }
  .shares { top: 12px; }
  .viewer-head { padding: 8px; }
}

/* 掲示物や画面共有の窓を動かしている間は、どこも選択されないようにする */
body.no-select, body.no-select * { user-select: none !important; -webkit-user-select: none !important; }

/* 参加者一覧：マウスを乗せると行が薄く色づき、右端に「︙」が出る（スマホは常に出す） */
.room-head { border-radius: 10px; }
.room-head:hover, .room-head.menu-open, .member.menu-open { background: var(--surface-2); }
.row-more {
  margin-left: auto; flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: none; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer;
}
.row-more:hover { background: rgba(0,0,0,0.06); }
@media (hover: hover) {
  .row-more { visibility: hidden; }
  .room-head:hover .row-more, .member:hover .row-more, .menu-open .row-more { visibility: visible; }
}
.member { min-height: 32px; }
.row-menu {
  position: fixed; z-index: 40; min-width: 180px; padding: 6px; display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.row-menu button {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: none; border-radius: 8px;
  background: transparent; font: inherit; font-size: 14px; text-align: left; white-space: nowrap; cursor: pointer;
}
.row-menu button:hover { background: var(--surface-2); }
.row-menu button.danger { color: var(--danger); }
.room-caret { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; border: none; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.room-caret:hover { background: rgba(0,0,0,0.06); color: var(--text); }
.room-toggle { cursor: pointer; }
.room[draggable="true"] .room-head { cursor: grab; }
.room.dragging-room { opacity: 0.4; }
.room.drop-before { box-shadow: 0 -2px 0 var(--primary); }
.room.drop-after { box-shadow: 0 2px 0 var(--primary); }
.room-lock { display: inline-flex; color: var(--muted); flex: none; }
.room.current .room-lock { color: rgba(255,255,255,0.85); }
/* 左・右のときは、マイクと矢印が縦の帯の幅に収まるように少し詰める */
.stage.tb-left .tb-mic .tb-btn, .stage.tb-right .tb-mic .tb-btn { min-width: 54px; padding: 4px 2px; }
.stage.tb-left .tb-caret, .stage.tb-right .tb-caret { width: 16px; }
.tb-add { display: contents; }
.tb-add[hidden] { display: none; }
/* 初心者マーク・「質問あります」 */
.avatar-wakaba { position: absolute; top: -6px; right: -4px; line-height: 0; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3)); }
.avatar-question {
  position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%); z-index: 2;
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 11px; border-radius: 12px; white-space: nowrap;
  background: #fff; color: #7a4b00; font-size: 12px; font-weight: 700; box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}
.avatar-question .ic-svg { margin: 0; color: #e08a00; }
/* 吹き出しのしっぽ（縁線なし） */
.avatar-question::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -7px; border: solid transparent; border-width: 8px 7px 0; border-top-color: #fff; }
.member-wakaba { line-height: 0; flex: none; }
.member-question { display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px; border-radius: 999px; background: #fff4d6; color: #7a4b00; font-size: 11px; font-weight: 600; flex: none; }
.tb-btn.is-asking { background: #fff4d6; color: #7a4b00; }
.tb-btn.is-asking .tb-label { color: #7a4b00; }
.check-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; margin: 4px 0 12px; }
.check-field input { width: 16px; height: 16px; accent-color: var(--primary); }
.wakaba-slot { line-height: 0; }
/* 滞在時間・利用時間（「通話接続中」の左）とランキング */
.stay { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; font-variant-numeric: tabular-nums; cursor: pointer; white-space: nowrap; margin-left: auto; }
.stay:hover { color: var(--text); background: var(--surface-2); }
.stay-sep { width: 1px; height: 12px; background: var(--border); }
.ranking-pop { position: fixed; z-index: 40; width: 300px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.rank-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rank-list li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; font-size: 13px; }
.rank-list li.me { background: var(--surface-2); font-weight: 600; }
.rank-no { width: 20px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-list li:nth-child(-n+3) .rank-no { color: #b07a00; font-weight: 700; }
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-empty { color: var(--muted); }
.rank-mine { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
@media (max-width: 760px) { .stay span:not(:last-child), .stay .stay-sep { display: none; } }
/* 入室日数のバッジ */
.avatar-visit { position: absolute; right: -6px; bottom: -4px; width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
.avatar-visit .ic-svg, .member-visit .ic-svg { margin: 0; }
.member-visit { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.visit-row { margin: 2px 0 6px; }
.visit-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.visit-pill .ic-svg { margin: 0; }
.visit-next { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.visit-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-bottom: 8px; }
.visit-bar span { display: block; height: 100%; border-radius: 3px; }

/* ---------- 閉室中のカウントダウン（フリップ時計） ---------- */
.countdown {
  position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 28px;
  padding: 24px 16px; background: #fff; color: #444; text-align: center;
}
.cd-title { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0.08em; color: #555; }
.cd-cards { display: flex; gap: 28px; }
.cd-group { display: grid; justify-items: center; gap: 16px; }
.cd-digits { display: flex; gap: 6px; }
.cd-digit {
  position: relative; width: 66px; height: 92px; border-radius: 10px;
  background: linear-gradient(#ffffff 0%, #f4f4f4 49.5%, #e6e6e6 50%, #fbfbfb 100%);
  border: 1px solid #e2e2e2; /* 白い背景でも札の形が見えるように */
  box-shadow: 0 6px 0 -1px #c9d6d4, 0 10px 14px rgba(0, 0, 0, 0.12);
  display: grid; place-items: center; font-size: 64px; line-height: 1; color: #4a4a4a;
  font-family: 'Helvetica Neue', Arial, sans-serif; font-variant-numeric: tabular-nums;
}
.cd-digit::after { /* 真ん中の折り目 */
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0, 0, 0, 0.12);
}
.cd-bar {
  width: 100%; height: 12px; border-radius: 999px; background: linear-gradient(#ffffff, #ececec); border: 1px solid #e2e2e2;
  box-shadow: 0 3px 0 -1px #b9c9c7, 0 5px 8px rgba(0, 0, 0, 0.15);
}
.cd-unit { font-size: 22px; color: #555; letter-spacing: 0.04em; }
.cd-next { margin: 0; font-size: 14px; color: #555; line-height: 1.7; }
.cd-road { position: relative; width: 100vw; height: 140px; overflow: hidden; margin: 0 -16px; }
.cd-rider { position: absolute; bottom: 0; left: 100%; height: 100px; }
.cd-rider.cd-move { animation: cd-ride var(--ride-dur, 6s) linear infinite; } /* 速さは app.js が画面の幅から決める */
.cd-rider.cd-stay { left: 50%; transform: translateX(-50%); }
.cd-rider img { display: block; height: 100%; width: auto; }
.cd-rider img + img { position: absolute; inset: 0; }
/* 2枚の絵を交互に出して、ぱらぱら漫画のように動かす（2枚目のときは1枚目を隠して、二重に見えないように） */
.cd-rider img:first-child { animation: cd-pedal-a var(--frame-cycle, 0.6s) step-end infinite; }
.cd-rider img + img { animation: cd-pedal var(--frame-cycle, 0.6s) step-end infinite; }
/* ふわっと入れ替える場面（ポーズが大きく違う絵を、ぱっと切り替えると雑に見えるため） */
.cd-rider.cd-fade img:first-child { animation: cd-fade-a var(--frame-cycle) linear infinite; }
.cd-rider.cd-fade img + img { animation: cd-fade-b var(--frame-cycle) ease-in-out infinite; }
/* 下の1枚目は濃いまま残し、上の2枚目だけを薄く重ねて入れ替える（2枚を同時に薄くすると、途中で全体が透けてチカチカするため） */
@keyframes cd-fade-a { 0%, 50% { opacity: 1; } 50.1%, 87.9% { opacity: 0; } 88%, 100% { opacity: 1; } }
@keyframes cd-fade-b { 0%, 38% { opacity: 0; } 50%, 88% { opacity: 1; } 100% { opacity: 0; } }
@keyframes cd-ride { from { left: 100%; transform: none; } to { left: 0; transform: translateX(-100%); } } /* 絵の幅に関係なく、左の外まで抜ける */
@keyframes cd-pedal { 0% { opacity: 0; } 50% { opacity: 1; } }
@keyframes cd-pedal-a { 0% { opacity: 1; } 50% { opacity: 0; } }
.cd-wallstage { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); overflow: hidden; }
.cd-wallchar, .cd-wallfront { position: absolute; bottom: 0; width: auto; }
.cd-wallfront { z-index: 1; } /* 壁は人物より手前 */
.cd-caption {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 6px; white-space: nowrap;
  padding: 4px 10px; border-radius: 999px; background: #fff; border: 1px solid #e2e2e2; font-size: 12px; color: #555;
}
@media (prefers-reduced-motion: reduce) { .cd-rider, .cd-rider img { animation: none !important; } .cd-rider.cd-move { left: 50%; transform: translateX(-50%); } .cd-rider img + img { opacity: 0; } }
.cd-skip-wrap { padding: 0; }
.cd-skip {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 26px; border-radius: 999px;
  border: 1px solid #d8d8d8; background: #fff; color: #444; font-size: 14px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.cd-skip:hover { background: #f6f6f6; }
@media (max-width: 720px) {
  .cd-cards { gap: 10px; }
  .cd-group { gap: 10px; }
  .cd-digits { gap: 3px; }
  .cd-digit { width: 9.5vw; height: 13vw; font-size: 9vw; border-radius: 6px; }
  .cd-bar { height: 8px; }
  .cd-unit { font-size: 14px; }
}

/* ---------- 入室画面：今いる人（管理者だけ） ---------- */
.join-presence { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; display: grid; gap: 6px; }
.join-presence h3 { margin: 0; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.jp-room { display: grid; gap: 4px; }
.jp-room b { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.jp-count { font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.jp-names { display: flex; flex-wrap: wrap; gap: 4px; }
.jp-chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; color: var(--text); max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jp-chip.is-staff { border-color: var(--primary); color: var(--primary); }
.jp-chip.is-q { background: #fff4d6; border-color: #e8c76a; }
.jp-empty { color: var(--muted); }

/* ---------- スペースの設定 ---------- */
.space-modal { width: min(560px, calc(100vw - 32px)); }
.space-sec { display: grid; gap: 10px; }
.space-sec h3 { margin: 0; font-size: 15px; }
.space-status { margin: 0; font-size: 13px; color: var(--muted); }
.space-status b { color: var(--text); }
.oh-body { display: grid; gap: 14px; }
.oh-body.off { opacity: 0.5; }
.oh-block { display: grid; gap: 8px; justify-items: start; }
.oh-label { font-size: 13px; color: var(--muted); }
.oh-rows { display: grid; gap: 8px; width: 100%; }
.oh-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.oh-row input, .oh-row select {
  font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
}
.oh-days { display: flex; gap: 3px; }
.oh-day {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
  font-size: 12px; padding: 0;
}
.oh-day.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.oh-sep { font-size: 13px; color: var(--muted); }
.oh-allday { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.oh-del { margin-left: auto; border: none; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.space-error { margin: 0; font-size: 13px; color: #c0392b; }

/* ---------- 壁紙を選ぶ ---------- */
.wp-modal { width: min(720px, calc(100vw - 32px)); display: grid; gap: 12px; }
.wp-modal .hint { margin: 0; }
.wp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.wp-item { position: relative; display: grid; gap: 4px; align-content: start; }
.wp-pick {
  padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--border); cursor: pointer; aspect-ratio: 16 / 10;
}
.wp-pick:hover { border-color: var(--border); filter: brightness(0.95); }
.wp-item.on .wp-pick { border-color: var(--primary); }
.wp-pick img { display: block; width: 100%; height: 100%; object-fit: cover; }
.wp-rooms { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wp-badge {
  position: absolute; top: 6px; left: 6px; display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 999px; font-size: 11px; background: var(--surface); color: var(--text);
}
.wp-del { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; background: var(--surface); opacity: 0; transition: opacity 0.15s; }
.wp-item:hover .wp-del, .wp-del:focus-visible { opacity: 1; }
@media (hover: none) { .wp-del { opacity: 1; } }
.wp-add {
  aspect-ratio: 16 / 10; display: grid; place-content: center; justify-items: center; gap: 6px;
  border: 1.5px dashed var(--border); border-radius: 10px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.wp-add:hover { color: var(--text); border-color: var(--muted); }

/* ---------- Non→Proの開催リンク（要件定義書 3-15b） ---------- */
.event-mode .join { background-size: cover; background-position: center; }
.event-mode #stay { display: none !important; }
/* 部屋ごとの機能の切り替え（body の off-機能名。講師には付かない） */
.off-share .tb-group:has(#share-btn),
.off-pen .tb-group:has(#pen-btn),
.off-pen [data-pen],
.off-chat .tb-group:has(#chat-btn),
.off-chat .tab[data-tab="chat"],
.off-timer .tb-group:has(#timer-btn),
.off-radius .tb-group:has(#radius-btn),
.off-objects #add-group,
.off-question #question-btn,
.off-grid #grid-btn { display: none !important; }
.event-pop { display: grid; gap: 14px; }
.event-link-row { display: flex; gap: 8px; }
.event-link-row input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
/* 録画中の印 */
.head-dash {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); font-size: 13px; white-space: nowrap;
}
@media (max-width: 900px) {
  .head-dash { width: 36px; padding: 0; justify-content: center; }
  .head-dash-label { display: none; }
}
.rec-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tb-btn.is-rec { color: var(--danger); }

/* 塾ごとの入室画面（要件定義書 3-17） */
.join-logo { display: block; max-width: 160px; max-height: 64px; object-fit: contain; margin-bottom: 12px; }
.join-welcome { white-space: pre-wrap; font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.join-account { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.join-account a, .link-btn { color: var(--muted); text-decoration: underline; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.join { background-position: center; background-size: cover; }
/* 講師には塾の設定に当たるメニューを出さない（サーバーでも断る） */
body.role-teacher #space-btn, body.role-teacher #wallpaper-btn, body.role-teacher #wallpaper-clear, body.role-teacher #room-add { display: none; }
.join-card a.btn { text-decoration: none; }
.yt-uploads { position: fixed; right: 16px; top: 72px; z-index: 900; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.yt-card { display: grid; gap: 8px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); box-shadow: 0 6px 24px rgba(0,0,0,0.16); font-size: 14px; }
.yt-note { margin: 0; font-size: 12px; color: var(--muted); }
.yt-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.yt-bar span { display: block; width: 0; height: 100%; background: var(--primary); transition: width 0.2s; }
.yt-url { word-break: break-all; color: var(--primary); }
.yt-actions { display: flex; gap: 8px; flex-wrap: wrap; }
