/* Shared Cue / Interval components own the frame, panels and controls.
   Comms adds only its audio layout and white product accent. */
:root {
  color-scheme: dark;
  --bg: #151515; --surface: #1d1d1d; --raised: #242424;
  --border: #333; --text: #f2f2f2; --muted: #a8a8a8;
  --accent: #e4e4e4; --soft: #fff;
  --ui-primary-text: #151515;
  --green: #73ac56; --yellow: #d6a84c; --red: #b84a52;
}
[hidden] { display: none !important; }
.comms-app > .louhos-app-topbar { width: 100%; }
.comms-app .account-button { max-width: min(170px, 44vw); }
.comms-app #account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 0 16px; min-width: 0; }
.workspace-heading h1 { min-width: 0; margin: 0; font-size: 1.5rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-tools { display: flex; align-items: center; gap: 8px; justify-content: flex-end; flex-shrink: 0; }
.workspace-tools > .btn { min-height: 38px; }
.version-label { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.connection-chip { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8rem; }
.connection-chip::before { content: ''; width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: var(--yellow); }
.connection-chip[data-state="connected"]::before { background: var(--green); }
.help, .panel-help, .mobile-note { color: var(--muted); font-size: .8rem; line-height: 1.45; }
.help { margin: 10px 0 0; }
.help:empty { display: none; }
.notice { padding: 10px 12px; margin: 12px 0 0; border: 1px solid var(--border); border-left: 4px solid var(--yellow); border-radius: 4px; background: var(--surface); color: var(--text); font-size: .82rem; overflow-wrap: anywhere; }
.field { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: .84rem; }
.field input { width: 100%; min-width: 0; height: var(--ui-control-height); padding: 0 12px; border: 1px solid var(--border); border-radius: var(--ui-control-radius); background: var(--ui-input-bg); color: var(--text); }
.field input::placeholder { color: #777; }

/* Room list: names and actions use the same row measurements as Cue. */
.comms-lobby { display: grid; gap: 24px; }
.comms-lobby .btn { height: var(--ui-control-height); min-height: var(--ui-control-height); padding: 0 14px; font: inherit; line-height: 20px; white-space: nowrap; }
.quick-join-form { display: grid; grid-template-columns: minmax(0,calc(var(--ui-control-height) * 6 + 40px)) auto; justify-content: start; align-items: end; gap: 16px; padding: 24px 20px; }
.room-code-field { min-width: 0; padding: 0; margin: 0; border: 0; }
.room-code-field legend { padding: 0; margin-bottom: 12px; color: var(--muted); font-size: .84rem; }
/* Six ordinary Louhos inputs; no separate OTP component dimensions. */
.room-code-digits { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 8px; direction: ltr; max-width: calc(var(--ui-control-height) * 6 + 40px); }
.room-code-digits > input { box-sizing: border-box; width: 100%; min-width: 0; height: var(--ui-control-height); min-height: var(--ui-control-height); padding: 0; border: 1px solid var(--border); border-radius: var(--ui-control-radius); background: var(--ui-input-bg); color: var(--text); font: inherit; font-variant-numeric: tabular-nums; text-align: center; caret-color: var(--text); }
.room-code-digits > input:focus-visible { outline: 2px solid var(--soft); outline-offset: 2px; }
.quick-join-form .help, .quick-link-form .help { grid-column: 1 / -1; margin: 0; }
.join-link-option { margin: 0 20px 20px; border-top: 1px solid var(--border); }
.join-link-option > summary { display: flex; align-items: center; gap: 10px; padding: 16px 0; min-height: 44px; box-sizing: border-box; cursor: pointer; color: var(--muted); list-style: none; font-size: .84rem; }
.join-link-option > summary::marker { content: ''; }
.join-link-option > summary::-webkit-details-marker { display: none; }
.join-link-option > summary svg { width: 16px; height: 16px; flex: 0 0 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.join-link-option[open] > summary svg { transform: rotate(90deg); }
.join-link-option > summary:focus-visible { outline: 2px solid var(--soft); outline-offset: 2px; border-radius: var(--ui-control-radius); }
.join-link-option > summary:hover { color: var(--text); }
.quick-link-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px; align-items: end; padding-top: 4px; }
.room-join-code { font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.invite-code-box { display: grid; gap: 10px; padding: 20px; margin-bottom: 20px; border: 1px solid var(--border); border-radius: 6px; background: var(--ui-input-bg); }
.invite-code-box > span { color: var(--muted); }
.invite-code-box output { font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .12em; }
@media(max-width:640px) { .comms-lobby { --ui-control-height: 44px; } .quick-join-form, .quick-link-form { grid-template-columns: minmax(0,1fr); } .quick-join-form { padding: 20px 18px; } .quick-join-form > .btn, .quick-link-form > .btn { justify-self: start; } }
html.louhos-accessibility .comms-lobby { --ui-control-height: 44px; }
.comms-app:has(#call:not([hidden])) > .comms-lobby { display: none; }
.room-toolbar { display: flex; align-items: stretch; flex-wrap: wrap; gap: 8px; }
.comms-app #rooms-panel .room-toolbar > .btn { box-sizing: border-box; height: var(--ui-control-height); min-height: var(--ui-control-height); max-height: var(--ui-control-height); margin: 0; padding: 0 14px; font-size: 14px; line-height: 20px; white-space: nowrap; }
.join-body { padding: 8px 16px 16px; }
.room-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; overflow-wrap: anywhere; }
.room-copy { min-width: 0; display: grid; gap: 3px; }
.room-copy strong { font-size: 1rem; }
.room-copy small { color: var(--muted); font-size: .8rem; }
.room-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
.rooms-empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.rooms-empty strong { color: var(--text); font-weight: 600; }
.rooms-empty p { margin: 6px 0 0; font-size: .82rem; }
.rooms-bottom { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.preview-link { display: flex; align-items: center; gap: 16px; color: var(--muted); text-decoration: none; font-size: .82rem; }
.preview-link:hover { color: var(--text); }
.mobile-note { margin: 18px 0 0; }

/* Connected room: a compact own microphone panel, room members in the main area.
   The header stays at exactly the same position as the room list / landing. */
body:has(#call:not([hidden])) { height: 100dvh; overflow: hidden; }
.comms-app:has(#call:not([hidden])) { height: 100dvh; display: flex; flex-direction: column; padding-bottom: 12px; gap: 12px; overflow: hidden; }
.comms-app:has(#call:not([hidden])) > .workspace-heading,
.comms-app:has(#call:not([hidden])) > .notice { margin: 0; flex: 0 0 auto; }
.comms-app:has(#call:not([hidden])) > .notice { max-height: 70px; overflow-y: auto; }
.comms-app:has(#call:not([hidden])) > .mobile-note { display: none; }
.comms-app:has(#call:not([hidden])) > .louhos-footer { margin-top: 0; padding-top: 8px; flex: 0 0 auto; }
#call { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
#call .layout { flex: 1 1 0; min-height: 0; margin-top: 0; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; }
#call .talk-panel, #call .side, #call .people-panel { display: flex; flex-direction: column; min-height: 0; }
#call .talk-panel { align-self: start; max-height: 100%; }
#call .side { align-content: normal; }
#call .people-panel { flex: 1; }
#call .panel-head { flex: 0 0 auto; }
#call .talk-panel .panel-head { gap: 8px; }
#call .talk-panel .panel-head .version-label { font-size: .72rem; }
#call .talk-body { flex: 1; display: flex; flex-direction: column; gap: 16px; min-height: 0; padding: 16px; overflow-y: auto; }
.speaker-stage { flex: 0 0 auto; display: grid; gap: 10px; padding: 0; }
.speaker-kicker { color: var(--muted); font-size: .75rem; }
.speaker-stage.is-speaking .speaker-kicker { color: var(--green); }
.voice-meter { --level: 0%; position: relative; height: 8px; width: 100%; background: var(--border); border-radius: 2px; overflow: hidden; }
.voice-meter::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, #8fba70 0%, #8fba70 70%, #d9bc71 90%, #ce7c76 100%); clip-path: inset(0 calc(100% - var(--level)) 0 0); }
.voice-meter::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0, transparent calc(5% - 2px), var(--surface) calc(5% - 2px), var(--surface) 5%); }
.stage-meter { height: 14px; }
.mic-console { flex: 1 1 auto; display: flex; flex-direction: column; gap: 10px; min-height: 170px; }
.audio-actions { display: flex; flex-direction: column; gap: 8px; }
.audio-actions:not(:has(> :not([hidden]))) { display: none; }
.audio-actions .help { margin: 0; }
#call .talk-button { flex: 1 1 auto; width: 100%; min-height: 100px; max-height: 240px; padding: 18px; font-size: 1.1rem; line-height: 1.4; font-weight: 600; touch-action: none; user-select: none; -webkit-touch-callout: none; white-space: pre-line; transition: none; }
#call .talk-button.talking { background: var(--green); border-color: var(--green); color: #151515; }
.ptt-hint { color: var(--muted); text-align: center; font-size: .75rem; margin: 0; }
.call-volume { flex: 0 0 auto; display: grid; gap: 8px; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.call-volume label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .8rem; }
.call-volume output { font-variant-numeric: tabular-nums; }
.call-volume input, #listen-volume { width: 100%; min-width: 0; height: 28px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.participant-list { list-style: none; margin: 0; }
#call .participant-list { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); align-content: start; gap: 8px; padding: 12px; overflow-y: auto; overscroll-behavior: contain; }
#call .participant-list .voice-person { display: grid; grid-template-columns: 36px minmax(0, 1fr); grid-template-areas: "avatar copy" "meter meter"; align-items: center; gap: 10px 12px; padding: 12px; margin: 0; min-height: 90px; border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 4px; background: var(--ui-row-bg); }
#call .voice-person > .person-avatar { grid-area: avatar; }
#call .voice-person > .person-copy { grid-area: copy; }
#call .voice-person > .voice-meter { grid-area: meter; min-width: 0; }
#call .voice-person.speaking { border-left-color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--surface)); }
#call .voice-person { position: relative; }
.person-edit { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent; cursor: pointer; }
.person-edit:hover { border-color: var(--soft); }
.person-edit:focus-visible { outline: 2px solid var(--soft); outline-offset: 2px; }
.person-edit:active { background: color-mix(in srgb,var(--soft) 8%,transparent); }
#participant-name { overflow-wrap: anywhere; }
.person-avatar { display: grid; place-items: center; width: 36px; height: 36px; background: var(--raised); border: 1px solid var(--border); border-radius: 5px; color: var(--muted); font-weight: 700; }
.speaking .person-avatar { border-color: var(--green); color: #a8d28b; }
.person-copy { min-width: 0; }
.person-copy strong { display: block; font-size: 1rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-copy span { display: block; color: var(--muted); font-size: .8rem; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.speaking .person-copy span { color: #a8d28b; }
.panel-help { margin: 0; padding: 0 16px 16px; }
.call-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: 0 0 auto; }
.call-actions .help { margin: 0; }

/* Audio and room administration share Cue's settings dialog, but not one long form. */
.comms-app .cue-settings-intro { padding-right: 42px; }
.settings-switch { width: fit-content; margin-bottom: 16px; }
.request-count { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; min-height: 28px; padding: 0 7px; border-radius: 4px; background: var(--raised); color: var(--text); font-variant-numeric: tabular-nums; }
.requests-heading { display: flex; align-items: center; gap: 12px; margin: 20px 0 12px; }
.requests-heading h3 { margin: 0; font-size: 1.15rem; }
.request-attention { border-color: var(--yellow) !important; color: var(--yellow) !important; }
.request-state { display: grid; gap: 8px; padding: 20px; margin: 16px 0; border: 1px solid var(--border); border-left: 4px solid var(--yellow); border-radius: 6px; background: var(--ui-input-bg); }
.request-state strong { font-size: 1.1rem; }
.request-state p { margin: 0; line-height: 1.5; color: var(--muted); }
.request-state[data-state="approved"] { border-left-color: var(--green); }
.request-state[data-state="rejected"] { border-left-color: var(--red); }
.request-row { padding: 20px 0; border-bottom: 1px solid var(--border); min-height: 88px; }
.request-row .room-copy { gap: 8px; }
.request-row .room-actions > .btn { min-height: 44px; min-width: 96px; }
.requests-empty { padding: 28px 0; display: grid; gap: 8px; color: var(--muted); }
.requests-empty strong { color: var(--text); }
.requests-empty p { margin: 0; line-height: 1.5; }
@media(max-width:580px) { .request-row { align-items: flex-start; flex-direction: column; gap: 16px; } .request-row .room-actions { width: 100%; } .request-row .room-actions > .btn { flex: 1; } }
.comms-app .cue-setting-row select, .comms-app .cue-setting-row input[type="range"] { max-width: 100%; min-width: 0; }
.comms-app .cue-setting-row input[type="checkbox"] { justify-self: end; }
.room-form { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 10px; margin: 16px 0; }
.cue-settings-card .room-row { display: grid; grid-template-columns: minmax(0,1fr); gap: 8px; }
.cue-settings-card .room-actions .btn { min-height: 38px; padding: 0 12px; font-size: .8rem; }
#close-room { margin-top: 12px; }
.room-form-status { margin: -6px 0 16px; }
#room-close-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
#room-close-section summary { color: var(--muted); cursor: pointer; font-size: .84rem; }
#room-close-section summary:hover { color: var(--text); }
#room-close-section summary:focus-visible { outline: 2px solid var(--soft); outline-offset: 2px; }
.cue-settings-saved { max-width: 240px; font-size: .75rem; }
.qr-image { background: #fff; border-radius: 5px; width: min(280px,100%); margin: 20px auto; }
.qr-image svg { display: block; width: 100%; height: auto; }
.qr-link { display: block; color: var(--text); overflow-wrap: anywhere; font-size: .85rem; }

@media (max-width: 700px) {
  .field input { font-size: 16px; }
  .workspace-heading { gap: 8px; }
  .workspace-heading h1 { font-size: 1.2rem; }
  .workspace-tools { gap: 6px; }
  .workspace-tools .btn { padding: 0 10px; font-size: .8rem; }
  .connection-chip { font-size: .72rem; }
  #call .layout { grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr); gap: 12px; }
  #call .talk-panel .panel-head { min-height: 44px; padding: 10px 12px; }
  #call .talk-body { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px 12px; padding: 12px; overflow: visible; }
  #call .speaker-stage { grid-column: 1; grid-row: 1; gap: 8px; align-self: center; }
  #call .mic-console { display: contents; }
  #call .audio-actions { grid-column: 1; grid-row: 2; }
  #call .audio-actions > .btn { min-height: 40px; padding: 0 8px; font-size: .8rem; }
  #call .talk-button { grid-column: 2; grid-row: 1 / span 2; min-height: 88px; max-height: none; height: 100%; padding: 12px; font-size: 1rem; }
  #call .ptt-hint { grid-column: 1 / -1; grid-row: 3; font-size: .72rem; }
  #call .call-volume { grid-column: 1 / -1; grid-row: 4; display: grid; grid-template-columns: 115px minmax(0,1fr); align-items: center; gap: 12px; margin: 0; padding: 4px 0 0; border: 0; }
  #call .people-panel .panel-head { min-height: 44px; padding: 10px 12px; }
  #call .participant-list { grid-template-columns: minmax(0,1fr); gap: 6px; padding: 8px; }
  #call .participant-list .voice-person { min-height: 76px; padding: 8px 10px; gap: 6px 10px; }
  #call .panel-help { padding: 0 12px 10px; }
  .call-actions { gap: 8px; }
  .call-actions .help { display: none; }
}
@media (max-width: 600px) {
  .room-toolbar { width: 100%; }
  .room-toolbar .btn { flex: 1; }
  .room-row { flex-wrap: wrap; }
  .room-actions { width: 100%; }
  .room-actions .btn { flex: 1; }
  .room-form { grid-template-columns: 1fr; }
  .comms-app:has(#call:not([hidden])) .workspace-heading { flex-wrap: wrap; }
  .comms-app:has(#call:not([hidden])) .workspace-tools { width: 100%; justify-content: flex-start; }
  .workspace-tools .connection-chip { margin-right: auto; }
}
@media (max-height: 650px) {
  .comms-app:has(#call:not([hidden])) { gap: 8px; padding-bottom: 6px; }
  #call, #call .layout { gap: 8px; }
  #call .panel-head { min-height: 44px; padding: 10px 12px; }
  #call .talk-body { gap: 10px; padding: 12px; }
  #call .mic-console { min-height: 130px; }
  #call .talk-button { min-height: 80px; }
  #call .panel-help, #call .ptt-hint { display: none; }
  #call .call-volume { padding-top: 8px; }
}
@media (prefers-reduced-motion: reduce) { .comms-app *, .cue-settings-dialog * { transition: none !important; } }
