* {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  overflow-y: scroll;
}

html:has(body.in-session) {
  scrollbar-gutter: auto;
}

body.in-session {
  overflow-x: hidden;
  overflow-y: hidden;
  background: #000;
}

body:not(.in-session) {
  overflow-y: scroll;
}

button:not(:disabled),
a[href],
[role="button"]:not([aria-disabled="true"]) {
  cursor: pointer;
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

body.viewport-fullscreen {
  overflow: hidden;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body:not(.in-session) .app {
  padding-bottom: 48px;
}

body.in-session .app {
  max-width: none;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  grid-template-areas:
    "stage";
  column-gap: 0;
  row-gap: 0;
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
}

body.in-session #appLogo {
  display: none;
}

body.in-session #appHeaderRow,
body.in-session #appSubtitle {
  display: none;
}

body.in-session #sessionPanel {
  display: contents;
}

body.in-session .room-header {
  grid-area: header;
  margin-top: 0;
  padding: 8px 10px;
  border: 1px solid rgba(71, 85, 105, 0.75);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.86), rgba(2, 6, 23, 0.86));
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}


body.in-session #videoStage {
  grid-area: stage;
  justify-self: stretch;
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  border-radius: 0;
}

body.in-session .participants-box {
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
}

body.in-session .participants-list {
  margin-top: 0;
  gap: 6px;
  font-size: 13px;
}

@media (max-width: 980px) {
  body.in-session .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    grid-template-areas:
      "stage";
    align-items: stretch;
  }
}

#appLogo {
  cursor: pointer;
  user-select: none;
}

.tutorial-entry {
  margin: -4px 0 14px;
}

.tutorial-entry-panel {
  margin: 0 0 12px;
}

.tutorial-entry a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #93c5fd;
  text-decoration: none;
  border: 1px solid rgba(59, 130, 246, 0.4);
  background: rgba(30, 58, 138, 0.2);
  border-radius: 999px;
  padding: 6px 10px;
}

.tutorial-entry a:hover {
  background: rgba(37, 99, 235, 0.32);
  color: #bfdbfe;
}

#appLogo:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 5px;
  border-radius: 8px;
}

#createUrlInput::placeholder {
  color: rgba(148, 163, 184, 0.52);
  opacity: 1;
}


.subtitle {
  margin-top: 0;
  color: #94a3b8;
}



#sessionPanel label {
  display: grid;
  gap: 4px;
  font-size: 14px;
}

#sessionPanel input,
#sessionPanel button {
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  padding: 10px 12px;
}

#sessionPanel button {
  cursor: pointer;
  font-weight: 600;
}

#sessionPanel button:hover {
  background: #334155;
}

#sessionPanel button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: saturate(0.7);
}

.speed-btn {
  min-width: 52px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  text-align: center;
}

.hidden {
  display: none !important;
}

.modal-overlay {
  display: flex;
}

.modal-overlay button kbd {
  display: inline-flex;
  align-items: center;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  padding: 2px 4px;
  margin-left: 4px;
  border: 1px solid currentColor;
  border-radius: 4px;
  opacity: 0.85;
  vertical-align: middle;
  letter-spacing: 0;
  pointer-events: none;
}

body.in-session .subtitle,
body.in-session #lobbyPanel {
  display: none;
}

#sessionPanel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.room-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

#shareRoomBtn {
  margin-left: 0;
  border-color: rgba(20, 184, 166, 0.5);
  background: rgba(20, 184, 166, 0.15);
}
#shareRoomBtn:hover {
  border-color: rgba(20, 184, 166, 0.8);
  background: rgba(20, 184, 166, 0.28);
}
#shareRoomBtn svg {
  stroke: #14b8a6;
  stroke-width: 3;
}
#shareRoomBtn:hover svg {
  stroke: #2dd4bf;
}

.participants-box {
  min-width: 0;
}

.participants-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: #cbd5e1;
}

.participant-chip {
  padding: 4px 10px;
  border: 1px solid rgba(125, 211, 252, 0.55);
  border-radius: 999px;
  background: rgba(14, 116, 144, 0.24);
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.2;
}

.participant-chip-empty {
  border-color: rgba(100, 116, 139, 0.65);
  background: rgba(30, 41, 59, 0.5);
  color: #cbd5e1;
}

.controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0;
  white-space: nowrap;
}

.controls-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  flex: 0 0 auto;
}

.controls-room-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  padding: 5px 8px;
  border: 1px solid rgba(71, 85, 105, 0.45);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
}

.controls-room-title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: #bfdbfe;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls-participants-box {
  position: relative;
  min-width: 0;
}

.participants-count-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(100, 116, 139, 0.65);
  border-radius: 9px;
  background: rgba(30, 41, 59, 0.78);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  line-height: 1;
  flex: 0 0 auto;
}

.participants-count-btn:hover,
.participants-count-btn[aria-expanded="true"] {
  background: rgba(51, 65, 85, 0.94);
  border-color: rgba(148, 163, 184, 0.5);
  color: #f1f5f9;
}

.participants-count-btn svg {
  stroke: currentColor;
  flex-shrink: 0;
}

.participants-dropdown {
  position: fixed;
  z-index: 9999;
  min-width: 160px;
  max-width: 260px;
  max-height: 240px;
  overflow-y: auto;
  background: rgba(10, 18, 38, 0.97);
  border: 1px solid rgba(71, 85, 105, 0.7);
  border-radius: 10px;
  padding: 8px;
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
}

.participants-dropdown-list {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 3px;
}

.participants-dropdown-list .participant-chip {
  font-size: 12px;
  padding: 5px 10px;
}

.share-icon-btn {
  margin-left: 2px;
}

.room-back-btn {
  padding: 4px 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  background: transparent;
  border-color: transparent;
}

.room-back-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.room-back-logo {
  height: 28px;
  width: auto;
  display: block;
}

.controls-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.playback-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border: 1px solid rgba(71, 85, 105, 0.45);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
}

.playback-row .icon-btn {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  min-width: 42px;
  border-color: rgba(100, 116, 139, 0.65);
  background: rgba(30, 41, 59, 0.88);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.playback-row .icon-btn kbd {
  display: inline-flex;
  align-items: center;
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 1px 3px;
  margin-left: 0;
  border: 1px solid rgba(226, 232, 240, 0.6);
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.35);
  color: rgba(255, 255, 255, 0.95);
  vertical-align: middle;
  letter-spacing: 0;
  pointer-events: none;
}

.playback-row .play-pause-btn {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  border-color: rgba(147, 197, 253, 0.7);
  color: #fff;
  min-width: 42px;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 8px;
}

.playback-row .play-pause-btn:hover {
  background: linear-gradient(180deg, #60a5fa, #2563eb);
}


.controls-meta {
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-btn {
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid rgba(100, 116, 139, 0.65);
  color: #cbd5e1;
}

.meta-btn:hover {
  background: rgba(51, 65, 85, 0.94);
  color: #f1f5f9;
}

.meta-btn.active {
  background: rgba(37, 99, 235, 0.34);
  border-color: rgba(96, 165, 250, 0.72);
  color: #bfdbfe;
}

.controls-utility {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.utility-icon-btn {
  flex: 0 0 auto;
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  border-radius: 9px;
}

.record-icon-btn {
  flex: 0 0 auto;
  width: 40px;
  min-width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 9px;
  color: #fca5a5;
  border-color: rgba(100, 116, 139, 0.65);
  background: rgba(30, 41, 59, 0.78);
}

.record-icon-btn:hover {
  background: rgba(51, 65, 85, 0.94);
  border-color: rgba(248, 113, 113, 0.72);
}

.record-icon-btn.staging {
  border-color: rgba(251, 191, 36, 0.82);
  background: rgba(120, 53, 15, 0.55);
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.28);
}

.record-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f87171;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.25);
}


#pinControlsBtn.utility-icon-btn {
  color: #cbd5e1;
  border-color: rgba(100, 116, 139, 0.65);
  background: rgba(30, 41, 59, 0.78);
}

#pinControlsBtn.utility-icon-btn:hover {
  background: rgba(51, 65, 85, 0.94);
}

#pinControlsBtn.utility-icon-btn.active {
  opacity: 1;
  color: #2dd4bf;
  border-color: rgba(20, 184, 166, 0.6);
  background: rgba(20, 184, 166, 0.22);
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.2), 0 0 8px rgba(20, 184, 166, 0.25);
}

#toggleControlsBtn.utility-icon-btn {
  color: #cbd5e1;
  border-color: rgba(100, 116, 139, 0.65);
  background: rgba(30, 41, 59, 0.78);
}

#toggleControlsBtn.utility-icon-btn:hover {
  color: #f1f5f9;
  background: rgba(51, 65, 85, 0.94);
}

#toggleControlsBtn.utility-icon-btn.show-state {
  color: #2dd4bf;
  border-color: rgba(20, 184, 166, 0.6);
  background: rgba(20, 184, 166, 0.22);
}

.add-moment-btn {
  width: auto;
  min-width: 40px;
  height: 40px;
  min-height: unset;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid rgba(251, 191, 36, 0.6);
  background: rgba(30, 41, 59, 0.78);
  color: #fbbf24;
}

.add-moment-btn:hover {
  border-color: rgba(251, 191, 36, 0.95);
  background: rgba(51, 65, 85, 0.94);
  color: #fde68a;
}

.draw-controls-group button.active {
  background: rgba(14, 165, 233, 0.38);
  border-color: rgba(125, 211, 252, 0.8);
  color: #e0f2fe;
  box-shadow: inset 0 0 0 1px rgba(224, 242, 254, 0.2);
}

.tools-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  padding-top: 0;
  border-top: none;
  flex: 0 0 auto;
}

.controls .control-group {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

.controls .draw-controls-group {
  gap: 7px;
  padding: 5px 8px;
  border: 1px solid rgba(71, 85, 105, 0.45);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
}

.controls .draw-controls-group button {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  min-width: 42px;
  border-color: rgba(100, 116, 139, 0.65);
  background: rgba(30, 41, 59, 0.88);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.controls .draw-controls-group button kbd {
  display: inline-flex;
  align-items: center;
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 1px 3px;
  margin-left: 0;
  border: 1px solid rgba(226, 232, 240, 0.6);
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.35);
  color: rgba(255, 255, 255, 0.95);
  vertical-align: middle;
  pointer-events: none;
}

.color-dot-field {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #64748b;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.35);
  cursor: pointer;
  flex-shrink: 0;
}

.color-dot-preview {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ff3b30;
  pointer-events: none;
  transition:
    width 80ms linear,
    height 80ms linear,
    background-color 80ms linear;
}

.color-dot-field input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  opacity: 0;
  cursor: pointer;
}

.color-dot-field:focus-within {
  border-color: #7dd3fc;
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.35);
}

.size-field {
  display: flex;
  align-items: center;
}

.size-field input[type="range"] {
  width: 76px;
  margin: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: #334155;
  outline: none;
  cursor: pointer;
}

.size-field input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: #334155;
}

.size-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #94a3b8;
  cursor: pointer;
  margin-top: -5px;
}

.size-field input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: #334155;
}

.size-field input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #94a3b8;
  cursor: pointer;
}

.controls .moment-controls-group {
  border: none;
  border-radius: 0;
  padding: 0;
  padding-left: 10px;
  border-left: 1px solid rgba(71, 85, 105, 0.35);
  margin-left: 0;
  background: transparent;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

.moment-add-btn {
  padding: 5px 10px;
  font-size: 12px;
  background: rgba(250, 204, 21, 0.22);
  border: 1px solid rgba(250, 204, 21, 0.7);
  color: #fef08a;
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.12), 0 2px 6px rgba(250, 204, 21, 0.12);
}

.moment-add-btn:hover {
  background: rgba(250, 204, 21, 0.34);
  border-color: rgba(250, 204, 21, 0.88);
  color: #fef9c3;
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.2), 0 2px 8px rgba(250, 204, 21, 0.22);
}


.controls .playback-controls-group {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(30, 41, 59, 0.35);
}

.recording-controls-group {
  display: none;
}

.recording-controls-group.active {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  position: fixed;
  z-index: 200;
  border: 1px solid rgba(248, 113, 113, 0.55);
  background: rgba(18, 5, 5, 0.94);
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(239, 68, 68, 0.18), inset 0 1px 0 rgba(248, 113, 113, 0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 12px;
  padding: 10px 14px;
  gap: 10px;
}

.recording-controls-group button {
  font-size: 13px;
  font-weight: 600;
  min-height: 32px;
  padding: 7px 12px;
}

.recording-drag-handle {
  display: none;
  cursor: grab;
  color: rgba(248, 113, 113, 0.45);
  padding: 2px 4px;
  flex-shrink: 0;
  margin-right: 2px;
  touch-action: none;
}

.recording-drag-handle:hover {
  color: rgba(248, 113, 113, 0.85);
}

.recording-drag-handle:active {
  cursor: grabbing;
}

.recording-controls-group.active .recording-drag-handle {
  display: flex;
  align-items: center;
}

.recording-controls-group.dragging {
  opacity: 0.92;
  cursor: grabbing;
}

.recording-controls-group.dragging .recording-drag-handle {
  cursor: grabbing;
}

.begin-recording-btn {
  min-height: 32px;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #fff1f2;
  border: 1px solid rgba(254, 202, 202, 0.6);
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.95), rgba(159, 18, 57, 0.95));
}

.begin-recording-btn:hover {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.98), rgba(190, 24, 93, 0.98));
}

.recording-panel-close-btn {
  order: 999;
  margin-left: auto;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  font-weight: 600;
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: rgba(69, 10, 10, 0.65);
}

.recording-panel-close-btn:hover {
  color: #fee2e2;
  border-color: rgba(248, 113, 113, 0.7);
  background: rgba(127, 29, 29, 0.72);
}

.mic-staging-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mic-level-track {
  width: 120px;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: rgba(15, 23, 42, 0.9);
}

.mic-level-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #22c55e 0%, #f59e0b 70%, #ef4444 100%);
  transition: width 120ms linear;
}

.mic-level-text {
  font-size: 12px;
  color: #cbd5e1;
  min-width: 64px;
}

.recording-status {
  font-size: 11px;
  color: #fecaca;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.recording-download-link {
  font-size: 13px;
  color: #2dd4bf;
}

.recording-download-link.hidden {
  display: none;
}

.recording-share-btn {
  font-size: 12px;
  font-weight: 600;
  color: #2dd4bf;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(20, 184, 166, 0.5);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}

.recording-share-btn:hover {
  background: rgba(20, 184, 166, 0.2);
  color: #5eead4;
  border-color: rgba(45, 212, 191, 0.6);
}

.recording-share-btn.hidden {
  display: none;
}

.small {
  width: 120px;
}

.controls .control-field {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.controls .field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
  white-space: nowrap;
}

.controls .control-field input {
  margin: 0;
}

.controls .control-field select {
  margin: 0;
  border: 1px solid rgba(100, 116, 139, 0.8);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.95);
  color: #e2e8f0;
  padding: 5px 8px;
  min-height: 30px;
}

.controls .control-field-color input[type="color"] {
  width: 42px;
  height: 34px;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  cursor: pointer;
}

.controls .control-field-color input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.controls .control-field-color input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

.controls .control-field input[type="range"] {
  width: 96px;
  padding: 0;
}

@media (max-width: 980px) {
  .controls-header {
    gap: 8px;
    flex-wrap: wrap;
  }

  .controls-room-meta {
    flex-basis: 100%;
    order: 1;
    flex-wrap: wrap;
  }

  .playback-row {
    order: 2;
    width: 100%;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .controls-utility {
    order: 3;
    margin-left: 0;
    border-left: none;
    padding-left: 0;
    flex-wrap: wrap;
  }

  .tools-row {
    border-left: none;
    padding-left: 0;
    flex-wrap: wrap;
  }

  .controls .draw-controls-group {
    flex-wrap: wrap;
  }
}

/* Mobile-friendly session layout (phones) */
@media (max-width: 640px) {
  body.in-session .app {
    min-height: 100dvh;
    min-height: 100vh;
  }

  #sessionPanel button,
  #sessionPanel .icon-btn,
  #sessionPanel .meta-btn,
  #sessionPanel .participants-count-btn {
    touch-action: manipulation;
  }

  .controls-overlay {
    left: 8px;
    right: 8px;
    top: max(8px, env(safe-area-inset-top));
    padding: 8px 10px;
    max-height: min(55vh, calc(100% - 120px));
    max-height: min(55dvh, calc(100% - 120px));
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: calc(100% - 16px);
    min-width: 0;
    box-sizing: border-box;
  }

  .controls {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
    width: 100%;
    white-space: normal;
  }

  .controls-header {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 8px;
    min-width: 0;
    width: 100%;
    flex-shrink: 0;
  }

  .controls-room-meta {
    flex-basis: auto;
    width: 100%;
    min-width: 0;
    padding: 6px 10px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .room-back-logo {
    height: 24px;
  }

  .participants-count-btn {
    min-height: 44px;
    padding: 0 14px;
    font-size: 13px;
  }

  .share-icon-btn,
  .utility-icon-btn,
  .record-icon-btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  .playback-row {
    width: 100%;
    min-width: 0;
    padding: 6px 8px;
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: flex-start;
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .playback-row .icon-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 10px;
    font-size: 11px;
    flex-shrink: 0;
  }

  .playback-row .icon-btn kbd {
    display: none;
  }

  .playback-row .play-pause-btn {
    min-width: 48px;
    min-height: 44px;
  }

  .speed-btn {
    min-width: 48px;
  }

  .add-moment-btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  .controls-utility {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
    width: 100%;
    flex-shrink: 0;
  }

  .tools-row {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 8px;
    flex-shrink: 0;
  }

  .controls .draw-controls-group {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
    min-width: 0;
    max-width: 100%;
    flex-shrink: 0;
  }

  .controls .draw-controls-group button {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 10px;
    font-size: 11px;
    flex-shrink: 0;
  }

  .controls .draw-controls-group button kbd {
    display: none;
  }

  .size-field {
    flex-shrink: 0;
  }

  .size-field input[type="range"] {
    width: 52px;
    min-width: 52px;
  }

  #controlsFab {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    min-height: 44px;
    min-width: 44px;
    padding: 10px 14px;
    font-size: 13px;
  }

  .timeline-hud {
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    padding: 8px 10px;
  }

  .timeline-track {
    height: 8px;
  }

  .timeline-thumb {
    width: 18px;
    height: 18px;
  }

  .recording-controls-group.active {
    max-width: calc(100vw - 24px);
    max-width: calc(100dvw - 24px);
    max-height: 70vh;
    max-height: 70dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .webcam-preview {
    width: 140px;
    max-width: 45vw;
  }

  .webcam-resize-handle,
  .webcam-move-handle {
    width: 32px;
    height: 32px;
  }

  .moment-markers-bar {
    bottom: max(36px, env(safe-area-inset-bottom));
  }

  .participants-dropdown {
    max-width: min(260px, calc(100vw - 24px));
    max-height: 50vh;
  }
}

/* iPhone 17 Pro and similar (402×874) - ensure timeline always visible */
@media (max-width: 430px) and (max-height: 900px) {
  .controls-overlay {
    max-height: min(50vh, calc(100% - 100px));
    max-height: min(50dvh, calc(100% - 100px));
  }

  .timeline-hud {
    bottom: max(24px, env(safe-area-inset-bottom));
  }

  .moment-markers-bar {
    bottom: max(44px, calc(24px + env(safe-area-inset-bottom)));
  }
}

/* Extra compact layout for very small phones */
@media (max-width: 400px) {
  .controls-overlay {
    left: 6px;
    right: 6px;
    padding: 6px 8px;
    width: calc(100% - 12px);
  }

  .playback-row .icon-btn {
    min-height: 40px;
    min-width: 40px;
    padding: 6px 8px;
    font-size: 10px;
  }

  .playback-row .play-pause-btn {
    min-width: 44px;
    min-height: 40px;
  }

  .add-moment-btn,
  .share-icon-btn,
  .utility-icon-btn,
  .record-icon-btn {
    min-width: 40px;
    min-height: 40px;
    width: 40px;
    height: 40px;
  }

  .controls .draw-controls-group button {
    min-height: 40px;
    min-width: 40px;
    padding: 6px 8px;
    font-size: 10px;
  }

  .participants-count-btn {
    min-height: 40px;
    padding: 0 10px;
    font-size: 12px;
  }

  .size-field input[type="range"] {
    width: 44px;
    min-width: 44px;
  }

  .room-back-logo {
    height: 22px;
  }
}


#videoStage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  min-height: 0;
  margin: 0 auto;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}

.controls-overlay {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(71, 85, 105, 0.62);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(6px);
  z-index: 45;
  transition: opacity 180ms ease, transform 180ms ease;
}

#videoStage.controls-hidden .controls-overlay {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

#controlsWakeZone {
  position: absolute;
  inset: 0;
  z-index: 44;
  pointer-events: none;
  background: transparent;
}

#videoStage.controls-hidden:not(.controls-manually-hidden) #controlsWakeZone {
  pointer-events: auto;
}

#controlsFab {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 46;
  display: none;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(100, 116, 139, 0.9);
}

#videoStage.controls-hidden.controls-manually-hidden #controlsFab {
  display: inline-flex;
}

#videoStage:fullscreen {
  width: min(100vw, calc(100vh * 16 / 9));
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 0;
}

body.viewport-fullscreen #sessionPanel {
  position: fixed;
  inset: 0;
  z-index: 999;
  margin: 0;
  padding: 0;
  background: #000;
  display: grid;
  place-items: center;
}

body.viewport-fullscreen .room-header {
  display: none;
}

body.viewport-fullscreen #videoStage {
  width: min(100vw, calc(100vh * 16 / 9));
  border-radius: 0;
}

#player,
#drawCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Transparent shield over the video area. Intercepts pointer events so clicks
   in the video area never steal focus from the parent document, keeping all
   keyboard shortcuts alive. The bottom 48px (YouTube's controls bar) is
   intentionally exposed so settings/CC/quality panels open and stay open. */
#playerFocusShield {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 48px;
  z-index: 2;
  cursor: default;
}

#drawCanvas {
  z-index: 20;
  touch-action: none;
  pointer-events: none;
  cursor: default;
}

.webcam-preview {
  position: fixed;
  right: auto;
  bottom: auto;
  left: 0;
  top: 0;
  width: 210px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(125, 211, 252, 0.65);
  background: rgba(2, 6, 23, 0.9);
  z-index: 120;
  box-shadow: 0 8px 18px rgba(2, 6, 23, 0.5);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.webcam-preview.dragging {
  cursor: grabbing;
}

.webcam-preview-hint {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  font-size: 11px;
  line-height: 1;
  color: #e2e8f0;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.5);
  pointer-events: none;
}

#webcamPreview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);
}

.webcam-resize-handle {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 28px;
  height: 28px;
  z-index: 3;
  cursor: nwse-resize;
  border-radius: 8px;
  border: 2px solid rgba(226, 232, 240, 0.95);
  background: rgba(15, 23, 42, 0.88);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.webcam-move-handle {
  position: absolute;
  right: 36px;
  bottom: 4px;
  width: 28px;
  height: 28px;
  z-index: 3;
  cursor: move;
  border-radius: 8px;
  border: 2px solid rgba(226, 232, 240, 0.95);
  background: rgba(15, 23, 42, 0.88);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.webcam-move-handle::before {
  content: "✥";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #f8fafc;
  font-size: 15px;
  line-height: 1;
}

.webcam-resize-handle::before {
  content: "⤡";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #f8fafc;
  font-size: 16px;
  line-height: 1;
}

#drawCursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 30;
  display: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.95);
  background: rgba(255, 59, 48, 0.7);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transform: translate(-9999px, -9999px);
  will-change: transform;
}

.timeline-hud {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 44;
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(100, 116, 139, 0.7);
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(4px);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.timeline-hud.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.timeline-track {
  position: relative;
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.34);
  overflow: visible;
}

.timeline-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #14b8a6 0%, #2dd4bf 100%);
  transition: width 120ms linear;
}

.timeline-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 2px solid #14b8a6;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.timeline-label {
  font-size: 12px;
  color: #dbeafe;
  text-align: right;
  letter-spacing: 0.01em;
}

/* Action flash — brief text overlay when +10, -10, play, pause */
.action-flash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 450ms ease-out;
}

.action-flash.visible {
  opacity: 1;
  transition: none; /* instant appear, fade out only */
}

.action-flash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 28px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.25);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
}

.action-flash-label {
  font-size: 4rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: rgba(248, 250, 252, 0.95);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

.action-flash-name {
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: rgba(248, 250, 252, 0.65);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.action-flash-name.hidden {
  display: none;
}


/* Standalone moment markers bar — overlays the YouTube native progress bar area */
.moment-markers-bar {
  position: absolute;
  /* Align with YouTube's scrubber: ~40px up from the bottom of the iframe */
  bottom: max(40px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
  z-index: 45;
}

.moment-markers-bar .moment-marker {
  pointer-events: auto;
}

/* Moment markers — used both on the custom HUD track and the standalone bar */
.moment-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -95%);
  width: 14px;
  height: 18px;
  border-radius: 0;
  border: none;
  background: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 18'%3E%3Cpath d='M7 0C3.69 0 1 2.69 1 6c0 4.25 6 12 6 12s6-7.75 6-12C13 2.69 10.31 0 7 0zm0 8.5c-1.38 0-2.5-1.12-2.5-2.5S5.62 3.5 7 3.5s2.5 1.12 2.5 2.5S8.38 8.5 7 8.5z' fill='%23fbbf24'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
  z-index: 6;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
  transition: transform 0.15s ease, filter 0.15s ease;
}

.moment-marker:hover {
  transform: translate(-50%, -95%) scale(1.35);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.7));
}

.moment-marker-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(2, 6, 23, 0.92);
  border: 1px solid rgba(100, 116, 139, 0.6);
  color: #dbeafe;
  font-size: 11px;
  line-height: 1.3;
  padding: 4px 6px 4px 8px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 5px;
}

.moment-marker-tooltip.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Invisible bridge that fills the gap between the pin dot and the tooltip so
   the cursor doesn't lose hover state when moving slowly between them. */
.moment-marker-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: -10px;
  right: -10px;
  height: 12px;
}

.moment-marker-label {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Specificity must beat #sessionPanel button (1,0,1) which resets border/bg on all session buttons */
#sessionPanel .moment-marker-delete-btn {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(220, 38, 38, 0.55);
  border: 1px solid #ef4444;
  border-radius: 2px;
  color: #fecaca;
  font-size: 9px;
  font-weight: 700;
  line-height: 12px;
  cursor: pointer;
  padding: 0;
  padding-bottom: 1px;
}

#sessionPanel .moment-marker-delete-btn:hover {
  background-color: #dc2626;
  border-color: #ef4444;
  color: #fff;
}

#videoStage.draw-enabled #drawCanvas {
  pointer-events: auto;
  cursor: none;
}

#videoStage.draw-enabled #drawCursor {
  display: block;
}

#drawModeBtn.active {
  background: #14b8a6;
  border-color: #0d9488;
  color: #042f2e;
}


