:root {
  --fg: #111;
  --bg: #fff;
  --muted: #666;
  --link: #0a58ca;
  --border: #ddd;
  --panel-bg: #f7f7f8;
  --accent: #1e64d6;
  --success: #1a7f37;
  --error: #c1272d;
}

html, body { margin: 0; padding: 0; color: var(--fg); background: var(--bg); font-family: system-ui, Segoe UI, Roboto, Arial, sans-serif; }
.container { max-width: 95%; margin: 1.25rem auto; padding: 0 1rem; }
h1 { font-size: 1.35rem; margin: 0; }
.site-header, .site-footer { border-bottom: 1px solid var(--border); padding: .75rem 1rem; }
.site-footer { border-top: 1px solid var(--border); border-bottom: 0; margin-top: 2rem; color: var(--muted); }
.brand { font-weight: 700; margin-right: 1rem; color: var(--fg); text-decoration: none; }
nav a { margin-right: .75rem; color: var(--link); text-decoration: none; }
nav a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.error { color: var(--error); }
.success { color: var(--success); }

.link-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .5rem; }

.create-scene-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; margin: 1.25rem 0; }
.create-scene-form .field { flex: 1 1 260px; }

#create-message { font-size: .9rem; min-height: 1.2rem; }

.scene-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.scene-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
}
.scene-row a { font-weight: 600; color: var(--fg); text-decoration: none; }
.scene-row a:hover { text-decoration: underline; }
.scene-actions { display: flex; gap: .5rem; flex-shrink: 0; }
button.danger { background: var(--error); }

.inline-form { display: flex; align-items: center; gap: .5rem; flex: 1; }
.inline-form input { flex: 1; }
.inline-error { width: 100%; font-size: .85rem; margin-top: .5rem; }

.studio-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.studio-heading a { font-size: .85rem; color: var(--link); text-decoration: none; }
.studio-heading a:hover { text-decoration: underline; }
.studio-heading-links { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; }

.nav-pill-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--accent);
  color: #fff !important;
  font-weight: 600;
  font-size: .85rem !important;
  padding: .4rem .85rem;
  border-radius: 999px;
  text-decoration: none !important;
  transition: background .15s ease, transform .15s ease;
}
.nav-pill-link:hover { background: #164ea3; transform: translateY(-1px); }

.settings-bar { display: flex; flex-direction: column; gap: .5rem; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .85rem; margin-bottom: .75rem; }

label { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; color: var(--muted); }
.settings-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }
.settings-fields .field { flex: 1 1 160px; }
.settings-fields button { flex: 0 0 auto; }

select { border: 1px solid var(--border); border-radius: 6px; padding: .35rem .5rem; font-size: .85rem; font-family: inherit; background: #fff; color: var(--fg); }

.intro-field { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; color: var(--muted); }
.intro-controls { display: flex; gap: .4rem; }
.intro-controls input { flex: 1; min-width: 0; }

.settings-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.settings-meta .url-copy { margin-left: auto; }

input[type="text"], input[type="file"], input[type="number"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .35rem .5rem;
  font-size: .85rem;
  font-family: inherit;
  background: #fff;
  color: var(--fg);
}

input[type="color"] {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  width: 3rem;
  height: 2rem;
  background: #fff;
}

button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: .4rem .75rem;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}

button:disabled { opacity: .6; cursor: default; }
button.secondary { background: var(--muted); }

#message { font-size: .82rem; }
#message:empty { display: none; }

.url-copy { display: flex; gap: .4rem; flex: 1 1 280px; max-width: 420px; }
.url-copy input { flex: 1; font-family: monospace; font-size: .78rem; }

.join-links { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .75rem; }
.join-link-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.join-link-label { flex: 0 0 4.5rem; font-size: .8rem; color: var(--muted); }

.live-controls { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .85rem; margin-bottom: .75rem; }
.live-controls-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.live-controls-actions button { height: 2rem; box-sizing: border-box; padding: 0 .9rem; }
.self-video { display: none; width: 120px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: #000; }
.self-video.visible { display: block; }

/* A small "chip" look shared by the meter and every label+control pair in
   the live-controls row (gain/camera/mic), so mismatched control heights
   (a thin meter bar, a range input, a <select>) all read as same-sized,
   evenly spaced items on one line instead of a ragged row. */
.audio-meter, .gain-control {
  height: 2rem;
  box-sizing: border-box;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Zone stops sit on the meter's -60..0 dBFS scale (see audio-meter.js):
   -18 dBFS = 70%, -6 dBFS = 90%. The fill is always full-width and gets
   revealed via clip-path, so each zone keeps its own color. */
.audio-meter { padding: 0 .5rem; display: flex; align-items: center; gap: .4rem; }
.audio-meter-bar { position: relative; width: 180px; height: 12px; border-radius: 3px; background: #e4e4e7; overflow: hidden; }
.audio-meter-fill { position: absolute; inset: 0; background: linear-gradient(to right, #2e7d32 0 70%, #f9a825 70% 90%, #d32f2f 90% 100%); clip-path: inset(0 100% 0 0); }
.audio-meter-peak { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; margin-left: -1px; background: var(--fg); }
.audio-meter-db { width: 2.4rem; text-align: right; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.audio-meter .audio-meter-clip { height: 1.2rem; padding: 0 .35rem; font-size: .65rem; font-weight: 700; border: 1px solid var(--border); border-radius: 3px; background: none; color: var(--muted); }
.audio-meter .audio-meter-clip.clipped { background: var(--error); border-color: var(--error); color: #fff; }

/* Studio-only: one meter per connected guest, added as each guest's audio
   arrives (see attachGuestMeter in studio.js). Own row under the controls. */
.guest-meters { display: flex; flex-wrap: wrap; gap: .5rem; width: 100%; }
.guest-meters:empty { display: none; }
.guest-meter { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--muted); }

.gain-control { display: flex; flex-direction: row; align-items: center; gap: .4rem; font-size: .78rem; color: var(--muted); padding: 0 .6rem; }
.gain-control input[type="range"] { width: 200px; }
.gain-control select { border: 0; padding: 0; background: none; font-size: .8rem; }
.gain-value { display: inline-block; width: 2.2rem; font-variant-numeric: tabular-nums; }

.recording-indicator { display: flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 600; color: var(--error); }
.recording-indicator .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--error); }

.record-inline { display: flex; align-items: center; gap: .6rem; }
.record-inline a { color: var(--link); font-weight: 600; font-size: .85rem; }
.record-button { background: #d32f2f; }
.record-button:hover:not(:disabled) { background: #b71c1c; }

.mode-toggle { display: flex; gap: .5rem; margin-bottom: .75rem; }
.mode-button {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-weight: 600;
  padding: .5rem 1rem;
  border-radius: 8px;
}
.mode-button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.editor-toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.editor-toolbar span.muted { margin-left: auto; }
#save-layout-button { margin-left: .5rem; }
#selected-info { font-family: monospace; font-size: .78rem; }

.text-props { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; background: var(--panel-bg); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; margin-bottom: .5rem; }
.text-props .field { flex: 1 1 160px; }

#layout-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

#layout-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
}

.bg-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }

.edit-tile {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid rgba(255, 255, 255, .85);
  background: rgba(30, 100, 214, 0.25);
  cursor: move;
  touch-action: none;
}
.edit-tile.selected { border-color: #ffb300; }

/* Screen share editing view (Studio) - stands in for the actual shared
   screen, same idea as scene.html's own .screenshare-placeholder preview. */
.edit-tile.screenshare-placeholder {
  border-style: dashed;
  background: rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, .7);
  font-weight: 600;
}

.coverage-warning {
  background: #fff3cd;
  color: #7a5b00;
  border: 1px solid #ffe69c;
  border-radius: 8px;
  padding: .5rem .75rem;
  margin-bottom: .5rem;
  font-size: .85rem;
}

/* Matches scene.html's .name-label exactly (same source of truth, kept in
   sync by hand for now) so the editor previews real position/color/size. */
.name-label {
  position: absolute;
  left: 16px;
  bottom: 16px;
  background: #1e64d6;
  color: #fff;
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 30px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}

.edit-text-preview {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  font-weight: 600;
  line-height: 1.1;
  white-space: pre-wrap;
  pointer-events: none;
}

.edit-image-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.resize-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 3px;
  cursor: nwse-resize;
  touch-action: none;
}

.preview-label { margin: 0 0 .35rem; font-size: .8rem; }

.preview-wrap iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #000;
}

.takes-list { display: flex; flex-direction: column; gap: .75rem; }

.take-card {
  display: flex;
  gap: 1rem;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem;
}

.take-thumbnail {
  flex: 0 0 160px;
  width: 160px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
}

.take-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; }

.take-thumbnail.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
  padding: .5rem;
}

.take-info { flex: 1; display: flex; flex-direction: column; gap: .4rem; min-width: 0; }

.take-name-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.take-name { font-weight: 600; word-break: break-word; }
.rename-input { font-size: .9rem; padding: .3rem .5rem; min-width: 14rem; }

.take-meta { font-size: .8rem; }

.take-status {
  align-self: flex-start;
  font-size: .75rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 10px;
  background: var(--border);
  color: var(--fg);
}
.take-status.status-ready { background: #d7f0dd; color: var(--success); }
.take-status.status-failed { background: #f8d7d9; color: var(--error); }
.take-status.status-processing { background: #fff3cd; color: #8a6d00; }

.take-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .2rem; }

.download-button {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: .4rem .75rem;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.download-button.secondary { background: var(--muted); }

#preview-dialog {
  border: 0;
  border-radius: 10px;
  padding: 1rem;
  max-width: min(90vw, 960px);
  width: 100%;
}
#preview-dialog::backdrop { background: rgba(0, 0, 0, .6); }
#preview-video { width: 100%; display: block; border-radius: 6px; background: #000; margin-bottom: .75rem; }
