:root {
  --bg: #1e1f22; --panel: #2b2d31; --panel2: #232428; --line: #3a3c42;
  --text: #dbdee1; --dim: #949ba4; --accent: #5865f2; --green: #23a55a; --red: #f23f43; --mine: #f0b232;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }

button, .button, select, input[type=text], input[type=password], input:not([type]) {
  font: inherit; color: var(--text); background: #404249; border: 0; border-radius: 4px; padding: 6px 12px;
}
button, .button { cursor: pointer; text-decoration: none; display: inline-block; }
button:hover:not(:disabled), .button:hover { background: #4e5058; }
button:disabled, .button.off { opacity: .4; cursor: default; pointer-events: none; }
input[type=range] { accent-color: var(--accent); }

/* join */
#join { height: 100%; display: grid; place-items: center; }
#joinForm { background: var(--panel); padding: 28px; border-radius: 8px; width: 300px; display: grid; gap: 10px; }
#joinForm h1 { margin: 0 0 6px; font-size: 22px; }
#joinForm input { padding: 9px 12px; background: var(--bg); }
#joinForm button { background: var(--accent); padding: 9px; }
#joinErr { color: var(--red); margin: 0; min-height: 1.4em; }

/* room */
#app { height: 100%; display: grid; grid-template-columns: 250px minmax(0, 1fr) minmax(300px, 30%); }
#side { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
#projName { padding: 14px 14px 10px; font-weight: 600; border-bottom: 1px solid var(--bg); }
#members { list-style: none; margin: 0; padding: 8px; flex: 1; overflow: auto; }
#members li { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 6px; }
#members li:hover { background: #35373c; }
.avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--accent); display: grid; place-items: center;
  font-weight: 600; box-shadow: 0 0 0 2px var(--panel); }
li.speaking .avatar { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--green); }
li.silent { opacity: .45; }
.who { min-width: 0; flex: 1; }
.who .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .mroles { color: var(--dim); font-size: 12px; }
.tag { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; background: var(--accent); border-radius: 3px; padding: 1px 5px; margin-left: 4px; }
.mutedIcon { color: var(--red); font-size: 12px; }
.mkhost { display: none; font-size: 11px; padding: 2px 6px; }
#app.isHost #members li:hover .mkhost { display: inline-block; }
#status { margin: 0; padding: 0 14px 8px; color: var(--mine); font-size: 12px; }
#userbar { background: var(--panel2); padding: 10px; display: grid; gap: 8px; }
#userbar .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#userbar select { width: 100%; }
#mute.on { background: var(--red); }
.check, .slider { display: flex; align-items: center; gap: 6px; color: var(--dim); }
.slider input { flex: 1; min-width: 0; }

main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px; gap: 10px; }
#stage { position: relative; flex: 1; min-height: 0; background: #000; border-radius: 6px; overflow: hidden; }
#video { width: 100%; height: 100%; object-fit: contain; display: block; }
#rec { position: absolute; top: 12px; right: 12px; background: var(--red); color: #fff; font-weight: 700; padding: 3px 10px; border-radius: 4px; }
#rec::before { content: "●  "; }
#prompt { background: var(--panel); border-radius: 6px; padding: 10px 14px; min-height: 76px; }
#nowLine { font-size: 20px; min-height: 28px; }
#nowLine.mine { color: var(--mine); font-weight: 600; }
#nextLine { color: var(--dim); min-height: 20px; }
#nextLine b { color: var(--mine); font-variant-numeric: tabular-nums; margin-right: 8px; }
#transport { display: flex; align-items: center; gap: 8px; }
#transport #seek { flex: 1; min-width: 0; }
#time { font-variant-numeric: tabular-nums; color: var(--dim); white-space: nowrap; }
#record { background: #7a2a2c; }
#record.on { background: var(--red); }
.host { display: none; }
#app.isHost .host { display: inline-block; }
#checks { margin: 0; padding: 0 0 0 18px; color: var(--mine); font-size: 12px; }
#checks:empty { display: none; }

#script { background: var(--panel); overflow: auto; padding: 0 12px 40vh; min-height: 0; }
#script h3 { position: sticky; top: 0; background: var(--panel); margin: 0; padding: 12px 0 6px; font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; z-index: 1; }
.shot { border-left: 3px solid transparent; padding: 6px 8px; border-radius: 0 4px 4px 0; }
#app.isHost .shot { cursor: pointer; }
.shot.now { border-left-color: var(--accent); background: var(--panel2); }
.shot .head { color: var(--dim); font-size: 12px; }
.shot .head b { color: var(--text); margin-right: 6px; }
.shot .desc { color: var(--dim); font-size: 12px; }
.sline { margin-top: 3px; }
.sline .sp { font-weight: 600; font-size: 12px; margin-right: 5px; }
.sline .mod { color: var(--dim); font-style: italic; font-size: 12px; margin-right: 5px; }
.sline.mine { color: var(--mine); }
.sline.now { background: #3b3d6b; border-radius: 3px; box-shadow: 0 0 0 3px #3b3d6b; }
.sline.nocue { text-decoration: line-through; opacity: .6; }
.sound { color: var(--dim); font-style: italic; font-size: 12px; margin-top: 3px; }

dialog { background: var(--panel); color: var(--text); border: 0; border-radius: 8px; padding: 20px; width: min(520px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog form { margin-top: 14px; text-align: right; }
dialog form button { background: var(--accent); }
.role { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.role .pick { min-width: 150px; text-align: left; }
.role.mine .pick { background: var(--mine); color: #000; font-weight: 600; }
.role .count { color: var(--dim); width: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.role .chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #404249; opacity: .6; }
.chip.heard { background: var(--green); opacity: 1; }
.chip:disabled { pointer-events: none; }
.chip:disabled.heard { opacity: 1; }
.chip:disabled:not(.heard) { opacity: .6; }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto auto 50vh; height: auto; }
  #stage { aspect-ratio: 16 / 9; flex: none; }
  #members { max-height: 30vh; }
}
