/* 昭和レトロの見た目。色は下の変数だけで決める。
   古い言い回し（ラヂオ・只今放送中 など）は .deco の飾りにだけ使い、ボタンとエラーは今の言葉で書く。 */

:root {
  color-scheme: light;
  --paper: #f4ead5;
  --paper-2: #ebdcbf;
  --paper-3: #e1cda7;
  --ink: #3a2a1e;
  --ink-2: #5d4837;
  --brick: #a8402c;
  --brick-dark: #7e2e1f;
  --mustard: #d8a23a;
  --mustard-dark: #a87a1c;
  --teal: #2e7672;
  --teal-dark: #1f5654;
  --cream: #fff8e8;
  --cabinet: #2b1f17;
  --cabinet-2: #3d2c20;
  --ok: #3f8a4f;
  --warn: #c98a12;
  --bad: #b5402f;
  --radius: 14px;
  --tap: 52px;
  --f-body: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'BIZ UDPGothic', sans-serif;
  --f-head: 'Shippori Mincho', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  --f-logo: 'Dela Gothic One', 'Zen Maru Gothic', sans-serif;
  --f-dot: 'DotGothic16', ui-monospace, monospace;
  --shadow: 0 2px 0 rgba(58, 42, 30, 0.25), 0 10px 24px -14px rgba(58, 42, 30, 0.45);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--f-body);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
  background-color: var(--paper);
  /* 紙のざらつき＋ふちの網点 */
  background-image:
    url('../img/paper.svg'),
    radial-gradient(circle, rgba(168, 64, 44, 0.16) 1.3px, transparent 1.7px),
    radial-gradient(circle, rgba(46, 118, 114, 0.12) 1.3px, transparent 1.7px);
  background-size: 240px 240px, 9px 9px, 9px 9px;
  background-position: 0 0, 0 0, 4.5px 4.5px;
  background-attachment: fixed;
}
/* 網点は四隅だけ濃く、真ん中は消す */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 70% 65% at 50% 45%, var(--paper) 55%, transparent 100%);
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

h1, h2, h3 { font-family: var(--f-head); font-weight: 700; line-height: 1.35; margin: 0 0 0.5em; letter-spacing: 0.02em; }
p { margin: 0 0 0.8em; }
a { color: var(--teal-dark); }
small { font-size: 0.8em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.deco { font-family: var(--f-head); letter-spacing: 0.15em; }
.dot { font-family: var(--f-dot); letter-spacing: 0.04em; }

:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; border-radius: 6px; }

/* ---------- 題字（ヘッダー） ---------- */
.masthead {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 3px double var(--ink);
  background: linear-gradient(var(--paper), var(--paper-2));
}
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.logo img { width: 40px; height: 40px; }
.logo-text { font-family: var(--f-logo); font-size: 26px; letter-spacing: 0.03em; color: var(--brick); text-shadow: 2px 2px 0 var(--mustard); }
.logo-words { display: grid; line-height: 1.1; }
.logo-sub { font-family: var(--f-head); font-weight: 700; font-size: 11px; letter-spacing: 0.3em; color: var(--ink-2); }
.logo-sub:empty, .poster-sub-name:empty { display: none; }
.poster-sub-name { font-family: var(--f-head); font-weight: 700; font-size: clamp(16px, 2.6vw, 22px); letter-spacing: 0.5em; color: var(--brick-dark); margin: -6px 0 12px; }
.masthead .deco { margin-left: auto; font-size: 14px; color: var(--ink-2); }

main { width: min(1100px, 100%); margin: 0 auto; padding: 24px 16px 40px; }

/* ---------- カード・ポスター ---------- */
.card {
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 20px; display: flex; align-items: center; gap: 10px; }
.card-title::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--brick); box-shadow: 0 0 0 3px var(--mustard); flex: none; }

.poster {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 46px 20px 40px;
  margin-bottom: 26px;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: var(--mustard);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.sunburst {
  position: absolute;
  inset: -60%;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 248, 232, 0.45) 0deg 7deg, transparent 7deg 15deg);
  pointer-events: none;
}
.poster > * { position: relative; }
.poster-kicker { font-size: 15px; color: var(--brick-dark); margin-bottom: 4px; }
.poster-title {
  font-family: var(--f-logo);
  font-weight: 400;
  font-size: clamp(38px, 8vw, 72px);
  color: var(--brick);
  text-shadow: 3px 3px 0 var(--cream), 6px 6px 0 var(--ink);
  margin: 0 0 10px;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.poster-sub { font-size: 18px; font-weight: 700; margin: 0; }

/* 琺瑯（ほうろう）看板ふうの札 */
.enamel {
  --c: var(--teal);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 10px;
  background: var(--c);
  color: var(--cream);
  font-weight: 700;
  box-shadow: inset 0 0 0 2px var(--cream), inset 0 0 0 4px var(--c), 0 2px 0 rgba(0, 0, 0, 0.3);
  position: relative;
}
.enamel::before, .enamel::after {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--paper-3);
  box-shadow: inset -1px -1px 0 rgba(0, 0, 0, 0.35);
  flex: none;
}
.enamel.brick { --c: var(--brick); }
.enamel.mustard { --c: var(--mustard); color: var(--ink); }
.enamel.ink { --c: var(--ink); }

.badges { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; padding: 0; margin: 26px 0 0; }

/* ---------- ボタン・入力 ---------- */
.btn {
  min-height: var(--tap);
  padding: 0 22px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.05s, box-shadow 0.05s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brick); color: var(--cream); }
.btn-teal { background: var(--teal); color: var(--cream); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:active { transform: none; }
.btn-big { width: 100%; min-height: 60px; font-size: 20px; letter-spacing: 0.1em; }
.btn-small { min-height: 40px; padding: 0 14px; font-size: 15px; }

input[type='text'], input[type='url'], input[type='number'], select, textarea {
  font: inherit;
  color: var(--ink);
  background: #fffdf6;
  border: 2px solid var(--ink-2);
  border-radius: 10px;
  min-height: var(--tap);
  padding: 8px 12px;
  width: 100%;
}
select { padding-right: 32px; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline: 3px solid rgba(46, 118, 114, 0.25); outline-offset: 0; }
label { font-weight: 700; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 200px; }
.mt { margin-top: 12px; }
.center-actions { justify-content: center; }
.link-btn { display: inline-flex; align-items: center; text-decoration: none; }
.hint { font-size: 15px; color: var(--ink-2); }
.hint.warn { color: var(--ink); background: #f8dfa0; border-left: 5px solid var(--warn); padding: 8px 12px; border-radius: 6px; }
.error { color: var(--bad); font-weight: 700; min-height: 1.5em; margin: 10px 0 0; }
.error:empty { min-height: 0; margin: 0; }

/* つまみのようなスイッチ */
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 700; }
.switch input { appearance: none; width: 54px; height: 30px; border-radius: 999px; background: var(--paper-3); border: 2px solid var(--ink); position: relative; cursor: pointer; flex: none; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--cream); border: 2px solid var(--ink); transition: left 0.15s; }
.switch input:checked { background: var(--teal); }
.switch input:checked::after { left: 26px; }

/* 選択肢を、ラヂオの選局目盛りのように並べる */
.dial { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.dial legend { font-weight: 700; padding: 0; margin-bottom: 6px; }
.dial .scale {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, transparent 0 9px, rgba(58, 42, 30, 0.35) 9px 10px) bottom / 100% 9px no-repeat,
    linear-gradient(#fbf3df, #efe1c3);
}
.dial label { position: relative; display: grid; place-items: center; min-height: var(--tap); padding: 6px 4px 12px; cursor: pointer; font-family: var(--f-dot); font-size: 18px; text-align: center; line-height: 1.2; }
.dial label + label { border-left: 1px dashed rgba(58, 42, 30, 0.35); }
.dial label small { display: block; font-family: var(--f-body); font-size: 12px; color: var(--ink-2); }
.dial input { position: absolute; opacity: 0; pointer-events: none; }
.dial label:has(input:checked) { background: rgba(216, 162, 58, 0.35); color: var(--brick-dark); }
.dial label:has(input:checked)::after { content: ''; position: absolute; bottom: 0; left: 50%; width: 4px; height: 12px; transform: translateX(-50%); background: var(--brick); border-radius: 2px 2px 0 0; box-shadow: 0 0 6px rgba(168, 64, 44, 0.6); }
.dial label:has(input:checked)::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--brick); }
.dial label:has(input:focus-visible) { outline: 3px solid var(--mustard); outline-offset: -3px; }
.dial label:has(input:disabled) { opacity: 0.4; cursor: not-allowed; }
.dial.words label { font-family: var(--f-body); font-weight: 700; font-size: 16px; }

/* ---------- 入口（招待リンク） ---------- */
.paste { display: flex; gap: 10px; flex-wrap: wrap; }
.paste input { flex: 1 1 260px; }
.paste .btn { flex: 0 0 auto; }

/* ---------- 参加前の確認 ---------- */
.lobby-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 18px; }
.lobby-head .enamel { font-size: 18px; }
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* ブラウン管テレビの枠 */
.tv { display: flex; gap: 12px; padding: 14px; border-radius: 22px; background: linear-gradient(145deg, #6b4a33, #4a3324); border: 2px solid var(--ink); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.15), var(--shadow); }
.tv-screen { position: relative; flex: 1; aspect-ratio: 16 / 9; border-radius: 26px / 20px; overflow: hidden; background: #1a1410; box-shadow: inset 0 0 0 4px #2a1d14, inset 0 0 40px rgba(0, 0, 0, 0.8); }
.tv-screen video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tv-screen.mirror video { transform: scaleX(-1); }
.tv-off { position: absolute; inset: 0; display: grid; place-items: center; color: var(--paper-3); text-align: center; padding: 12px; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.03) 0 2px, transparent 2px 4px); }
.tv-knobs { display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.tv-knobs span { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f0d28a, var(--mustard-dark)); border: 2px solid var(--ink); }
.tv-knobs span:nth-child(2) { width: 20px; height: 20px; margin-left: 3px; background: radial-gradient(circle at 35% 35%, #9fd0cb, var(--teal-dark)); }

/* 入力レベル計（VUメーター） */
.vu { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; margin: 4px 0 14px; }
.vu-face { position: relative; width: 150px; height: 84px; border: 2px solid var(--ink); border-radius: 12px 12px 6px 6px; overflow: hidden; background: radial-gradient(ellipse 85% 95% at 50% 100%, #fff6dc 0 60%, #f1dfb3 61%); }
.vu-face::before { content: ''; position: absolute; inset: 0; background: url('../img/vu.svg') center bottom / 100% 100% no-repeat; }
.vu-face::after { content: 'VU'; position: absolute; left: 10px; top: 6px; font-family: var(--f-dot); font-size: 12px; color: var(--brick); }
.vu-red { position: absolute; right: 8px; top: 4px; font-family: var(--f-dot); font-size: 12px; color: var(--brick); }
.vu-needle { position: absolute; left: 50%; bottom: 4px; width: 3px; height: 70px; margin-left: -1.5px; background: var(--brick-dark); border-radius: 2px; transform-origin: 50% 100%; transform: rotate(calc(-48deg + var(--level, 0) * 96deg)); transition: transform 0.08s linear; }
.vu-pivot { position: absolute; left: 50%; bottom: -8px; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: var(--ink); }
.vu-text { font-size: 15px; color: var(--ink-2); }
.vu-text b { font-family: var(--f-dot); font-size: 20px; color: var(--ink); }

details.more { border-top: 2px dashed var(--paper-3); margin: 10px 0 16px; padding-top: 10px; }
details.more summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; gap: 8px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: '▸'; color: var(--brick); transition: transform 0.15s; }
details.more[open] summary::before { transform: rotate(90deg); }

/* ---------- 会議室（ブラウン管の並ぶ、夜の茶の間） ---------- */
body.in-room {
  background-color: var(--cabinet);
  background-image:
    radial-gradient(circle, rgba(216, 162, 58, 0.07) 1.3px, transparent 1.7px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.015) 0 2px, transparent 2px 14px);
  background-size: 9px 9px, auto;
  color: var(--paper);
}
body.in-room::before { display: none; }
body.in-room .masthead { display: none; }
body.in-room main { width: 100%; max-width: none; padding: 0; }
.view-room { display: flex; flex-direction: column; height: 100dvh; }

.room-bar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 2px solid #000; background: linear-gradient(#4a3426, var(--cabinet-2)); }
.onair { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 8px; border: 2px solid #1a110b; background: #4b1d14; color: #e9b8a8; font-family: var(--f-head); font-weight: 700; letter-spacing: 0.2em; }
.onair .lamp { width: 10px; height: 10px; border-radius: 50%; background: #6d2a1d; }
.onair.live { background: var(--brick); color: var(--cream); box-shadow: 0 0 14px rgba(255, 90, 60, 0.55); }
.onair.live .lamp { background: #ffd2a0; box-shadow: 0 0 8px #ffb070; }
.room-title { font-size: 17px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-meta { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 15px; color: var(--paper-2); flex-wrap: wrap; }
.clock { font-family: var(--f-dot); font-size: 20px; color: #ffcf6b; text-shadow: 0 0 6px rgba(255, 190, 80, 0.5); background: #140d08; padding: 0 10px; border-radius: 6px; border: 1px solid #000; }
.light-switch { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 2px 12px 2px 4px; border-radius: 999px; border: 2px solid #120b07; background: #1d140e; color: var(--paper-2); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.light-switch .knob { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3c4, #e0a93a); box-shadow: 0 0 8px rgba(255, 200, 90, 0.7); }
#conn:empty { display: none; }
#conn { color: #ffcf6b; font-weight: 700; }

.room-body { flex: 1; min-height: 0; display: flex; gap: 10px; padding: 10px; }
.stage-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.stage { flex: 1; min-height: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.stage:empty { display: none; }
.grid { flex: 1; min-height: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); grid-auto-rows: minmax(0, 1fr); align-content: center; }
.room.has-screen .grid { flex: 0 0 auto; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 220px; grid-auto-rows: 124px; overflow-x: auto; justify-content: start; }

.tile { position: relative; min-height: 0; border-radius: 18px; padding: 8px; background: linear-gradient(145deg, #5e412d, #3e2b1f); border: 2px solid #120b07; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); display: flex; flex-direction: column; }
.tile-screen { position: relative; flex: 1; min-height: 0; border-radius: 22px / 16px; overflow: hidden; background: #120d09; box-shadow: inset 0 0 0 3px #1d140e, inset 0 0 28px rgba(0, 0, 0, 0.8); }
.tile video { width: 100%; height: 100%; display: block; object-fit: cover; }
.tile.screen video { object-fit: contain; background: #000; }
.tile.local.camera:not(.rear) video { transform: scaleX(-1); }
.tile .avatar { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--f-logo); font-size: 44px; color: var(--mustard); background: radial-gradient(circle, #3a2a1e, #160f0a); }
.tile.speaking { border-color: var(--mustard); box-shadow: 0 0 0 3px var(--mustard), 0 0 18px rgba(216, 162, 58, 0.5); }
.tile-cap { display: flex; align-items: center; gap: 8px; padding: 6px 4px 0; min-height: 32px; color: var(--paper); font-size: 15px; }
.tile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
/* 放送のランプ: カメラ＝「ON AIR」（昔のスタジオの赤いランプ）、画面共有＝「放送中」 */
.tlamps { position: absolute; top: 9px; left: 10px; display: flex; gap: 6px; z-index: 1; pointer-events: none; }
.tlamp { font-family: var(--f-logo); font-size: 12px; line-height: 1; letter-spacing: 0.08em; padding: 5px 8px 4px; border-radius: 6px; border: 2px solid #140c07; white-space: nowrap; }
.tlamp.onair { background: linear-gradient(#4b231a, #2f140e); color: rgba(255, 200, 180, 0.32); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.tlamp.onair[data-on='true'] { background: radial-gradient(ellipse at 50% 35%, #ff8a68 0%, #e2341d 55%, #b11f10 100%); color: #fff7e8; text-shadow: 0 0 5px rgba(255, 245, 210, 0.95); box-shadow: 0 0 12px 3px rgba(255, 70, 40, 0.7), inset 0 0 6px rgba(255, 255, 255, 0.45); }
.tlamp.live { font-family: var(--f-head); font-weight: 700; font-size: 13px; letter-spacing: 0.15em; background: linear-gradient(#4a3a1c, #2e230f); color: rgba(255, 230, 170, 0.3); }
.tlamp.live[data-on='true'] { background: radial-gradient(ellipse at 50% 35%, #ffe7a6 0%, #e6b143 60%, #c08a1e 100%); color: #2a1a10; box-shadow: 0 0 12px 3px rgba(255, 196, 70, 0.65), inset 0 0 6px rgba(255, 255, 255, 0.5); }
/* 放送している人のタイル: 枠が赤く光る */
.tile.broadcasting { border-color: #e2341d; box-shadow: 0 0 0 2px #e2341d, 0 0 16px 2px rgba(255, 60, 30, 0.55); }
.tile.broadcasting.speaking { box-shadow: 0 0 0 2px #e2341d, 0 0 0 5px var(--mustard), 0 0 20px 3px rgba(255, 90, 40, 0.6); }
/* 自分が画面を共有している間: ページ全体を赤い枠で囲む */
.share-frame { display: none; }
body.in-room.sharing .share-frame { display: block; position: fixed; inset: 0; z-index: 30; pointer-events: none; border: 4px solid #e2341d; box-shadow: inset 0 0 22px rgba(255, 60, 30, 0.45); }
.share-frame-tab { position: absolute; top: 0; left: 50%; transform: translateX(-50%); padding: 2px 14px 4px; border-radius: 0 0 10px 10px; background: #e2341d; color: #fff7e8; font-size: 13px; font-weight: 700; white-space: nowrap; box-shadow: 0 0 10px rgba(255, 60, 30, 0.6); }
/* マイク＝小さな針のVUメーター。切っているときは灰色で、斜線が入る */
.mini-vu { position: relative; flex: none; width: 34px; height: 20px; border: 2px solid #140c07; border-radius: 17px 17px 4px 4px; overflow: hidden; background: radial-gradient(ellipse 90% 100% at 50% 100%, #fff4d6 0 62%, #ecd8a8 63%); }
.mini-vu::before { content: ''; position: absolute; right: 3px; top: 3px; width: 8px; height: 3px; border-radius: 2px; background: var(--brick); transform: rotate(32deg); }
.mini-needle { position: absolute; left: 50%; bottom: 1px; width: 2px; height: 15px; margin-left: -1px; background: #7e2e1f; border-radius: 1px; transform-origin: 50% 100%; transform: rotate(calc(-52deg + var(--level, 0) * 104deg)); transition: transform 0.06s linear; }
.mini-vu[data-on='false'] { background: #5f5047; }
.mini-vu[data-on='false']::before { display: none; }
.mini-vu[data-on='false'] .mini-needle { display: none; }
.mini-vu[data-on='false']::after { content: ''; position: absolute; left: 50%; top: -4px; width: 3px; height: 30px; margin-left: -1.5px; background: #ff7b63; transform: rotate(-40deg); border-radius: 2px; }
.qos { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; min-height: 30px; border-radius: 8px; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.12); color: var(--paper); font: inherit; font-family: var(--f-dot); font-size: 14px; cursor: pointer; flex: none; }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.bars i { width: 4px; background: rgba(255, 255, 255, 0.2); border-radius: 1px; }
.bars i:nth-child(1) { height: 5px; } .bars i:nth-child(2) { height: 9px; } .bars i:nth-child(3) { height: 14px; }
.qos[data-level='good'] .bars i { background: #7fd08a; }
.qos[data-level='fair'] .bars i:nth-child(-n + 2) { background: #ffd166; }
.qos[data-level='poor'] .bars i:nth-child(1) { background: #ff7b63; }
.qos-detail { position: absolute; left: 12px; right: 12px; bottom: 44px; padding: 8px 10px; border-radius: 10px; background: rgba(20, 13, 8, 0.92); border: 1px solid var(--mustard-dark); font-size: 14px; line-height: 1.5; color: var(--paper); z-index: 2; }
.qos-detail b { font-family: var(--f-dot); color: #ffcf6b; font-weight: 400; }
.stats { position: absolute; left: 14px; top: 14px; right: 14px; white-space: pre-wrap; font-family: var(--f-dot); font-size: 13px; line-height: 1.45; color: #ffe7a8; text-shadow: 0 1px 2px #000; pointer-events: none; display: none; }
body.show-stats .stats { display: block; }
.share-warn-chip { position: absolute; left: 12px; bottom: 12px; right: 12px; padding: 6px 10px; border-radius: 8px; background: rgba(201, 138, 18, 0.92); color: var(--ink); font-size: 14px; font-weight: 700; }

.chat { width: 340px; flex: none; display: flex; flex-direction: column; border-radius: 16px; background: var(--paper); color: var(--ink); border: 2px solid #000; overflow: hidden; position: relative; }
.chat-head { display: flex; align-items: baseline; gap: 10px; padding: 8px 12px; background: var(--teal); color: var(--cream); }
.chat-head h2 { font-size: 17px; margin: 0; }
.chat-sub { font-size: 12px; opacity: 0.9; }
.chat-close { margin-left: auto; min-width: 36px; min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--cream); font-size: 22px; line-height: 1; cursor: pointer; }
.chat-warn { margin: 0; padding: 6px 12px; font-size: 13px; background: #f8dfa0; border-bottom: 1px solid var(--paper-3); }
.chat-log { flex: 1; min-height: 0; margin: 0; padding: 10px 12px; list-style: none; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; align-self: flex-start; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; }
.msg-meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--ink-2); }
.msg-meta b { color: var(--teal-dark); }
.msg.mine .msg-meta { justify-content: flex-end; }
.msg-meta time { font-family: var(--f-dot); }
.msg-text { white-space: pre-wrap; padding: 6px 10px; border-radius: 12px 12px 12px 4px; background: var(--cream); border: 1.5px solid var(--paper-3); }
.msg.mine .msg-text { border-radius: 12px 12px 4px 12px; background: #e3efe9; border-color: #bcd8cf; }
.msg.notice { align-self: center; font-size: 13px; color: var(--ink-2); background: var(--paper-2); padding: 4px 12px; border-radius: 999px; }
.file-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; background: var(--cream); border: 1.5px solid var(--paper-3); }
.thumb-btn { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 8px; overflow: hidden; line-height: 0; }
.file-thumb { width: 96px; height: 72px; object-fit: cover; background: var(--paper-2); display: block; }
.file-icon { display: grid; place-items: center; width: 72px; height: 54px; border-radius: 8px; background: var(--paper-2); font-size: 13px; color: var(--ink-2); }
.file-svg { width: 34px; height: 34px; fill: var(--paper-2); stroke: var(--ink-2); stroke-width: 1.5; stroke-linejoin: round; }
.file-info { display: grid; min-width: 0; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 14px; }
.file-size { font-family: var(--f-dot); font-size: 13px; color: var(--ink-2); }
.file-save { min-height: 40px; }
.chat-drop { position: absolute; inset: 44px 8px 60px; display: grid; place-items: center; border: 3px dashed var(--teal); border-radius: 12px; background: rgba(244, 234, 213, 0.92); font-weight: 700; color: var(--teal-dark); z-index: 3; }
.chat-uploads { display: grid; gap: 4px; padding: 0 12px; }
.chat-uploads:empty { display: none; }
.upload-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: 8px; align-items: center; font-size: 13px; }
.chat-form { display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-top: 2px dashed var(--paper-3); }
.chat-form input[type='text'] { min-width: 0; flex: 1; min-height: 44px; }
.chat-form .btn { flex: none; white-space: nowrap; }
.chat-attach { flex: none; display: grid; justify-items: center; gap: 0; min-width: 48px; min-height: 44px; padding: 2px 4px; border-radius: 10px; border: 2px solid var(--ink-2); background: var(--cream); font-size: 11px; cursor: pointer; position: relative; }
.chat-attach svg { width: 20px; height: 20px; }
.chat-attach input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.chat-attach:focus-within { outline: 3px solid var(--mustard); outline-offset: 2px; }
.chat-foot { margin: 0; padding: 0 12px 8px; font-size: 12px; color: var(--ink-2); }
#btn-chat .badge { position: absolute; top: 4px; right: 6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--brick); color: var(--cream); font-size: 12px; line-height: 20px; font-family: var(--f-dot); }
#btn-chat { position: relative; }
.view-chat { display: flex; flex-direction: column; min-height: calc(100dvh - 140px); }
.chat-view-actions { margin-left: auto; }
.chat-host { flex: 1; display: flex; min-height: 420px; }
.chat-host .chat { width: 100%; max-width: 820px; margin: 0 auto; border-color: var(--ink); box-shadow: var(--shadow); }
.chat-host .chat-close { display: none; }
dialog.lightbox img { display: block; max-width: 100%; max-height: 65dvh; margin: 0 auto; border-radius: 8px; background: var(--paper-2); }

.controls { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(var(--cabinet-2), #1f160f); border-top: 2px solid #000; }
.ctl { white-space: nowrap; min-width: 76px; min-height: 64px; padding: 6px 10px; display: grid; justify-items: center; align-content: center; gap: 2px; border-radius: 14px; border: 2px solid #120b07; background: linear-gradient(#6b4a33, #4a3324); color: var(--paper); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; box-shadow: 0 3px 0 #120b07; }
.ctl svg { width: 26px; height: 26px; }
.ctl:active { transform: translateY(2px); box-shadow: 0 1px 0 #120b07; }
.ctl:disabled { opacity: 0.4; cursor: not-allowed; }
.ctl[data-on='false'] { background: linear-gradient(#5a2a20, #3d1a13); color: #ffc2b2; }
.ctl[aria-pressed='true'] { background: linear-gradient(var(--teal), var(--teal-dark)); color: var(--cream); }
.ctl-leave { background: linear-gradient(var(--brick), var(--brick-dark)); color: var(--cream); }
.ctl-leave small { font-size: 10px; font-weight: 500; opacity: 0.85; letter-spacing: 0.1em; }
.share-warn { margin: 0 10px; padding: 8px 12px; border-radius: 10px; background: #f8dfa0; color: var(--ink); font-weight: 700; font-size: 15px; }
.audio-unlock { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 5; }
.big-clock { position: fixed; top: 64px; right: 14px; z-index: 6; font-family: var(--f-dot); font-size: 46px; color: #fff; background: #000; padding: 4px 14px; border-radius: 8px; border: 2px solid var(--mustard); }

/* ---------- 明るめの会議室（昼の茶の間） ---------- */
body.in-room.room-light {
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    url('../img/paper.svg'),
    radial-gradient(circle, rgba(168, 64, 44, 0.13) 1.3px, transparent 1.7px),
    radial-gradient(circle, rgba(46, 118, 114, 0.1) 1.3px, transparent 1.7px);
  background-size: 240px 240px, 9px 9px, 9px 9px;
  background-position: 0 0, 0 0, 4.5px 4.5px;
}
.room-light .room-bar { background: linear-gradient(var(--paper), var(--paper-2)); border-bottom: 3px double var(--ink); }
.room-light .room-meta { color: var(--ink-2); }
.room-light #conn { color: var(--brick-dark); }
.room-light .onair { background: #e9c9bd; color: #8a4a3c; border-color: var(--ink); }
.room-light .onair.live { background: var(--brick); color: var(--cream); }
.room-light .light-switch { background: var(--cream); color: var(--ink); border-color: var(--ink); }
.room-light .light-switch .knob { background: radial-gradient(circle at 35% 35%, #c9d6e8, #4c5d7a); box-shadow: none; }
.room-light .tile { background: linear-gradient(145deg, #8a5f40, #6a4630); border-color: var(--ink); box-shadow: 0 2px 0 rgba(58, 42, 30, 0.3); }
.room-light .tile.speaking { border-color: var(--mustard); box-shadow: 0 0 0 3px var(--mustard), 0 0 18px rgba(216, 162, 58, 0.6); }
.room-light .tile.broadcasting { border-color: #e2341d; box-shadow: 0 0 0 2px #e2341d, 0 0 16px 2px rgba(255, 60, 30, 0.5); }
.room-light .tile.broadcasting.speaking { box-shadow: 0 0 0 2px #e2341d, 0 0 0 5px var(--mustard), 0 0 20px 3px rgba(255, 90, 40, 0.55); }
.room-light .controls { background: linear-gradient(var(--paper-2), var(--paper-3)); border-top: 3px double var(--ink); }
.room-light .ctl { background: var(--cream); color: var(--ink); border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.room-light .ctl[data-on='false'] { background: #f3cfc3; color: var(--brick-dark); }
.room-light .ctl[aria-pressed='true'] { background: var(--teal); color: var(--cream); }
.room-light .ctl-leave { background: var(--brick); color: var(--cream); }
.room-light .chat { border-color: var(--ink); }

/* ---------- 入室・退室のお知らせ（構内放送の札ふう） ---------- */
.announce { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 9; display: grid; gap: 8px; width: min(420px, calc(100vw - 24px)); pointer-events: none; }
.announce-card { position: relative; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; padding: 10px 16px 10px 22px; border: 2px solid var(--ink); border-radius: 10px; background: var(--cream); color: var(--ink); box-shadow: 0 3px 0 var(--ink), 0 12px 24px -12px rgba(0, 0, 0, 0.6); animation: announce-in 0.35s ease-out both; }
/* 切符のミシン目 */
.announce-card::before { content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 4px; background: radial-gradient(circle, var(--paper-3) 1.6px, transparent 2px) 0 0 / 4px 8px repeat-y; }
.announce-card.leaving { animation: announce-out 0.35s ease-in both; }
.announce-card .horn { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brick); color: var(--cream); border: 2px solid var(--ink); }
.announce-card .horn svg { width: 20px; height: 20px; }
.announce-card.out .horn { background: var(--teal); }
.announce-card.again .horn { background: var(--mustard); color: var(--ink); }
.announce-head { font-family: var(--f-head); font-size: 12px; letter-spacing: 0.3em; color: var(--brick-dark); }
.announce-card.out .announce-head { color: var(--teal-dark); }
.announce-body { font-weight: 700; font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.announce-body b { font-size: 18px; }
@keyframes announce-in { from { opacity: 0; transform: translateY(-16px) rotate(-1.5deg); } to { opacity: 1; transform: none; } }
@keyframes announce-out { to { opacity: 0; transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) { .announce-card, .announce-card.leaving { animation: none; } }

/* ---------- 全画面・横向きのスマホ: 上下の帯を映像に重ね、しばらく触らなければ隠す ---------- */
.full-btn svg { width: 22px; height: 22px; margin-left: 6px; }
body.fs .view-room { position: relative; height: 100dvh; }
body.fs .room-bar, body.fs .controls { position: absolute; left: 0; right: 0; z-index: 7; transition: opacity 0.25s ease, transform 0.25s ease; }
body.fs .room-bar { top: 0; border-bottom: 0; padding-bottom: 24px; background: linear-gradient(rgba(20, 13, 8, 0.9), rgba(20, 13, 8, 0)); }
body.fs .controls { bottom: 0; border-top: 0; padding-top: 24px; background: linear-gradient(rgba(20, 13, 8, 0), rgba(20, 13, 8, 0.9)); }
body.fs.room-light .room-bar { background: linear-gradient(rgba(244, 234, 213, 0.96), rgba(244, 234, 213, 0)); border-bottom: 0; }
body.fs.room-light .controls { background: linear-gradient(rgba(235, 220, 191, 0), rgba(235, 220, 191, 0.96)); border-top: 0; }
body.fs .room-body { flex: 1; height: 100dvh; }
body.fs .share-warn { position: absolute; top: 70px; left: 10px; right: 10px; z-index: 6; }
body.fs.idle .room-bar { opacity: 0; transform: translateY(-110%); pointer-events: none; }
body.fs.idle .controls { opacity: 0; transform: translateY(110%); pointer-events: none; }
body.fs.idle .room-body, body.fs.idle .room-body * { cursor: none; }

/* 横向きのスマホ（高さが低い）: 共有画面の右にカメラを縦に並べる */
@media (orientation: landscape) and (max-height: 540px) {
  .room-body { padding: 4px; gap: 4px; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 4px; }
  .room.has-screen .stage-wrap { flex-direction: row; }
  .room.has-screen .stage { flex: 1; }
  .room.has-screen .grid { flex: 0 0 min(200px, 32vw); grid-auto-flow: row; grid-template-columns: 1fr; grid-auto-columns: auto; grid-auto-rows: 104px; overflow-y: auto; align-content: start; }
  .room-body .chat { position: fixed; inset: 0 0 0 auto; width: min(380px, 62vw); height: auto; z-index: 8; border-radius: 16px 0 0 16px; }
  .controls { flex-wrap: nowrap; gap: 6px; }
  .ctl { min-width: 64px; min-height: 52px; font-size: 12px; }
  .ctl-leave small { display: none; }
  .room-meta { margin-left: auto; width: auto; gap: 8px; font-size: 13px; }
  .tlamp { font-size: 10px; padding: 4px 6px 3px; }
  .room-bar { flex-wrap: nowrap; padding: 4px 8px 18px; gap: 8px; }
  .onair { font-size: 12px; padding: 2px 8px; letter-spacing: 0.1em; }
  .room-title { font-size: 13px; padding: 2px 10px; max-width: 34vw; }
  .light-switch { min-height: 30px; padding: 2px 6px 2px 2px; font-size: 12px; }
  .light-switch .knob { width: 22px; height: 22px; }
  .light-switch .light-label { display: none; }
  .full-btn svg { margin-left: 2px; }
  .clock { font-size: 15px; padding: 0 6px; }
  .controls { justify-content: center; padding: 16px 6px 6px; }
  .ctl { min-width: 58px; min-height: 46px; padding: 2px 6px; font-size: 11px; }
  .ctl svg { width: 22px; height: 22px; }
  .tile-cap { font-size: 12px; min-height: 26px; padding-top: 3px; }
  .mini-vu { width: 28px; height: 17px; }
  .mini-needle { height: 12px; }
  .qos { min-height: 24px; font-size: 12px; padding: 1px 6px; }
}

/* ---------- ダイアログ（画面共有の設定） ---------- */
dialog.dlg { width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 3px solid var(--ink); border-radius: 18px; background: var(--cream); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
dialog.dlg::backdrop { background: rgba(20, 13, 8, 0.7); }
.dlg form { padding: 20px 22px; }
.dlg-title { font-size: 22px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; border-bottom: 3px double var(--ink); padding-bottom: 10px; margin-bottom: 14px; }
.dlg-title .deco { font-size: 13px; color: var(--ink-2); }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 14px; position: sticky; bottom: 0; background: var(--cream); padding-top: 8px; }
.checks { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 6px; }
.checks li { padding: 8px 12px; border-radius: 8px; border-left: 5px solid var(--teal); background: rgba(46, 118, 114, 0.1); font-size: 15px; }
.checks li.warn { border-left-color: var(--warn); background: #f8dfa0; }
.checks li.bad { border-left-color: var(--bad); background: #f6cdbf; }
.checks:empty { display: none; }

/* ---------- 退室後・主催者ページ ---------- */
.center { text-align: center; max-width: 560px; margin: 40px auto; }
.owner-grid { display: grid; gap: 20px; }
.room-card .room-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 12px; }
.room-card .room-head h3 { margin: 0; font-size: 22px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 0 10px; min-height: 28px; border-radius: 999px; font-size: 14px; font-weight: 700; border: 2px solid var(--ink); background: var(--paper); }
.pill.live { background: var(--brick); color: var(--cream); }
.pill.ok { background: #d7ecd9; }
.pill.dead { background: var(--paper-3); color: var(--ink-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
table.list th, table.list td { text-align: left; padding: 8px 6px; border-bottom: 1px dashed var(--paper-3); vertical-align: middle; }
table.list th { font-family: var(--f-head); }
.issued { margin: 12px 0; padding: 12px; border-radius: 10px; border: 2px dashed var(--teal); background: rgba(46, 118, 114, 0.08); }
.issued input { font-family: ui-monospace, monospace; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--cream); font-weight: 700; box-shadow: var(--shadow); }
.colophon { text-align: center; font-size: 13px; color: var(--ink-2); padding: 0 16px 24px; }
.colophon a { color: inherit; }

/* ---------- スマホ ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .masthead { padding: 10px 14px; }
  .masthead .deco { display: none; }
  .logo-text { font-size: 22px; }
  main { padding: 16px 12px 32px; }
  .card { padding: 16px; }
  .poster { padding: 34px 14px 30px; }
  .lobby-grid { grid-template-columns: 1fr; }
  .tv { padding: 10px; }
  .tv-knobs { display: none; }
  .vu { grid-template-columns: 130px 1fr; }
  .vu-face { width: 130px; }
  .room-bar { padding: 8px 10px; gap: 6px 10px; }
  .room-meta { margin-left: 0; width: 100%; justify-content: space-between; }
  .onair { font-size: 13px; letter-spacing: 0.1em; }
  .room-body { padding: 6px; gap: 6px; }
  .grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 6px; }
  .room.has-screen .grid { grid-auto-columns: 150px; grid-auto-rows: 100px; }
  .tile { padding: 5px; border-radius: 14px; }
  .tile-cap { font-size: 13px; }
  .room-body .chat { position: fixed; inset: auto 0 0 0; width: auto; height: 62dvh; z-index: 8; border-radius: 16px 16px 0 0; }
  .chat-host { min-height: 70dvh; }
  .chat-sub { display: none; }
  .controls { gap: 6px; padding-left: 6px; padding-right: 6px; flex-wrap: nowrap; }
  .ctl { min-width: 0; flex: 1; min-height: 60px; padding: 4px 2px; font-size: 11px; letter-spacing: 0; }
  .room.has-screen .stage-wrap { overflow-y: auto; }
  .room.has-screen .stage { flex: 0 0 auto; grid-template-columns: 1fr; }
  .stage .tile-screen { flex: none; aspect-ratio: 16 / 9; }
  .room.has-screen .grid { flex: 1 0 auto; grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-columns: auto; grid-auto-rows: 130px; overflow: visible; align-content: start; }
  .ctl svg { width: 24px; height: 24px; }
  .ctl-leave small { display: none; }
  .light-switch .light-label { display: none; }
  .light-switch { padding: 2px 4px; }
  .tlamp { font-size: 10px; padding: 4px 6px 3px; }
  .tlamp.live { font-size: 11px; }
  .dial label { font-size: 16px; }
  table.list .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
