: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; }

.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); }
.vdo-connect-link { align-self: flex-end; font-size: .78rem; margin-bottom: .45rem; color: var(--link); text-decoration: none; }
.vdo-connect-link:hover { text-decoration: underline; }
.vdo-connect-link.disabled { color: var(--muted); pointer-events: none; }

.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; }

.record-inline { display: flex; align-items: center; gap: .6rem; }
.record-button { background: #d32f2f; }
.record-button:hover:not(:disabled) { background: #b71c1c; }

.editor-wrap { margin-bottom: .75rem; }
.editor-summary { cursor: pointer; font-weight: 600; padding: .5rem 0; user-select: none; }
.editor-wrap[open] .editor-summary { margin-bottom: .5rem; }
.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; }

/* 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;
}
