:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1c1c1c;
  --line: #303030;
  --line-2: #4b4b4b;
  --text: #f5f5f5;
  --muted: #a7a7a7;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 20px;
  --font-ui: "Segoe UI", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
}

body.overlay-page {
  background: transparent !important;
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

.home-page,
.auth-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.home-shell,
.auth-shell {
  width: min(960px, 100%);
}

.hero-card,
.auth-card,
.panel-card,
.preview-frame {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card,
.auth-card {
  padding: 34px;
}

.hero-card h1,
.auth-card h1,
.topbar h1 {
  margin: 8px 0 12px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
}

.hero-copy,
.hero-note,
.toolbar-note,
.status-text,
.empty-note {
  color: var(--muted);
}

.hero-links,
.topbar-actions,
.toolbar,
.panel-heading,
.field-grid,
.button-row {
  display: flex;
  gap: 12px;
}

.hero-links {
  margin: 22px 0 16px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 12px 18px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--line-2);
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.primary-btn {
  background: #f3f3f3;
  color: #080808;
  font-weight: 700;
}

.ghost-btn {
  background: transparent;
  color: var(--text);
}

.primary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.small-btn {
  padding: 10px 14px;
}

.tiny-btn,
.tiny-icon-btn {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.tiny-icon-btn {
  min-width: 38px;
}

.app-shell {
  padding: 20px;
  display: grid;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 430px);
  gap: 20px;
  align-items: start;
}

.preview-panel,
.sidebar {
  display: grid;
  gap: 16px;
}

.preview-frame {
  padding: 22px;
  overflow: hidden;
}

.toolbar {
  padding: 14px 18px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  flex-wrap: wrap;
}

.stage-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3200 / 1080;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--line-2);
  background:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    #0e0e0e;
  background-size: 64px 64px, 64px 64px, auto;
}

.stage-guide {
  position: absolute;
  top: 0;
  left: 20%;
  width: 60%;
  height: 100%;
  background: rgba(255, 255, 255, 0.06);
  border-left: 2px dashed rgba(255, 255, 255, 0.28);
  border-right: 2px dashed rgba(255, 255, 255, 0.28);
  pointer-events: none;
  z-index: 1;
}

.stage-stream,
.stage {
  position: absolute;
  top: 0;
  transform-origin: top left;
}

.stage-stream {
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.stage-stream .stream-frame {
  pointer-events: none;
}

.stage-wrapper.stream-clicks-enabled .stage-stream {
  pointer-events: auto;
}

.stage-wrapper.stream-clicks-enabled .stream-frame {
  pointer-events: auto;
}

.stage-wrapper.stream-clicks-enabled .stage {
  pointer-events: none;
}

.stage-wrapper.stream-clicks-enabled .widget,
.stage-wrapper.stream-clicks-enabled .resize-handle,
.stage-wrapper.stream-clicks-enabled .stage-guide {
  pointer-events: none;
}

.stage {
  z-index: 2;
}

.stream-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

.overlay-stream,
.overlay-root {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent !important;
}

.overlay-stream {
  z-index: 0;
  pointer-events: none;
}

.overlay-root {
  z-index: 1;
}

.overlay-root .widget {
  pointer-events: none;
}

.panel-card {
  padding: 18px;
}

.panel-heading {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.05rem;
}

.widget-list {
  display: grid;
  gap: 8px;
}

.widget-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.widget-list-item {
  width: 100%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.widget-list-item.active {
  border-color: #d8d8d8;
}

.widget-list-type {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
}

.editor-form,
.stack-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-size: 0.92rem;
  color: var(--muted);
}

.field input,
.field textarea,
.field select,
#media-file {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #101010;
  color: var(--text);
  padding: 12px 14px;
}

.field textarea {
  min-height: 120px;
}

.checkbox-field {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.widget {
  position: absolute;
  user-select: none;
  touch-action: none;
  will-change: left, top, width, height, opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.widget.editor {
  outline: 1px dashed rgba(255, 255, 255, 0.22);
  cursor: move;
}

.widget.editor.selected {
  outline: 2px solid rgba(255, 255, 255, 0.92);
}

.plain-text,
.plain-timer {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: pre-wrap;
}

.plain-image,
.plain-image img {
  width: 100%;
  height: 100%;
}

.plain-image img {
  display: block;
  object-position: center center;
}

.media-placeholder,
.audio-placeholder {
  width: 100%;
  height: 100%;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 12px;
}

.audio-placeholder span {
  display: block;
  font-size: 0.85rem;
  margin-top: 6px;
}

.timer-label {
  font-size: 0.74em;
  color: rgba(255, 255, 255, 0.72);
}

.timer-value {
  font-variant-numeric: tabular-nums;
}

.resize-handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid #000;
  cursor: nwse-resize;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}
