:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #141b2f;
  --panel-2: #1b2540;
  --line: rgba(255,255,255,0.1);
  --text: #f8fafc;
  --muted: #93a4bc;
  --accent: #38bdf8;
  --accent-2: #f43f5e;
  --good: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, rgba(56,189,248,0.18), transparent 36%), var(--bg);
  color: var(--text);
}

a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d1324;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}
textarea { resize: vertical; }
label span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 6px; text-transform: uppercase; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card, .panel-card {
  width: min(440px, 100%);
  background: rgba(20,27,47,0.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
}
.auth-card h1, .hero h1 { margin: 0 0 8px; font-size: 34px; }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; margin: 0 0 8px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.error { color: #fca5a5; min-height: 20px; }
.stack { display: grid; gap: 16px; }
.hidden { display: none !important; }

.primary, .ghost, .danger, .tool-grid button, .control-card button, .ghost-link {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  background: var(--panel-2);
  text-decoration: none;
  font-weight: 800;
}
.primary { background: linear-gradient(135deg, #0ea5e9, #2563eb); border-color: transparent; }
.ghost, .ghost-link { background: transparent; }
.danger { background: rgba(239,68,68,0.16); border-color: rgba(239,68,68,0.35); color: #fecaca; }
.primary:hover, .ghost:hover, .danger:hover, .tool-grid button:hover, .control-card button:hover, .ghost-link:hover { filter: brightness(1.12); }

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  background: rgba(11,16,32,0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { text-decoration: none; font-weight: 950; letter-spacing: -0.03em; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; padding: 10px 0; }
.page { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 40px 0; }
.page.narrow { width: min(900px, calc(100% - 32px)); }
.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 28px;
}
.compact-hero { align-items: flex-start; }
.create-scene { display: grid; grid-template-columns: 220px 150px 92px 92px auto; gap: 10px; }
.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.scene-card {
  background: rgba(20,27,47,0.88);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}
.scene-card h2 { margin: 0 0 8px; }
.scene-meta { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.scene-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.editor-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  min-height: calc(100vh - 64px);
}
.sidebar, .inspector {
  border-right: 1px solid var(--line);
  background: rgba(14,20,38,0.8);
  padding: 18px;
  overflow: auto;
}
.inspector { border-right: 0; border-left: 1px solid var(--line); }
.sidebar h2, .inspector h2 { margin: 6px 0 14px; font-size: 16px; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 24px; }
.asset-upload-form { margin-bottom: 24px; }
.compact-form { gap: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkbox { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.checkbox input { width: auto; }
.button-row { display: flex; gap: 8px; }
.button-row button { flex: 1; }
.shortcut-help { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }
.canvas-panel { min-width: 0; display: grid; grid-template-rows: 52px 1fr; }
.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,16,32,0.55);
}
.canvas-actions { display: flex; align-items: center; gap: 8px; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
.stage-wrap {
  overflow: auto;
  padding: 28px;
  display: grid;
  place-items: start center;
}
#stage {
  background: repeating-conic-gradient(#1e293b 0% 25%, #172033 0% 50%) 50% / 32px 32px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.55);
}

.control-list { display: grid; gap: 14px; }
.control-card {
  background: rgba(20,27,47,0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}
.control-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.control-head h2 { margin: 0; font-size: 20px; }
.control-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.control-editor { display: grid; gap: 10px; margin-top: 12px; }

.overlay-body {
  margin: 0;
  overflow: hidden;
  background: transparent;
}
.overlay-root {
  position: relative;
  overflow: hidden;
  background: transparent;
  transform-origin: top left;
}
.overlay-element {
  position: absolute;
  box-sizing: border-box;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
  transform: var(--base-transform, rotate(0deg));
  transition-property: opacity, transform;
  transition-timing-function: cubic-bezier(.2,.8,.2,1);
  will-change: opacity, transform;
}
.overlay-element.is-hidden { opacity: 0; pointer-events: none; }
.overlay-element.is-visible { opacity: 1; }
.overlay-element img { width: 100%; height: 100%; display: block; object-fit: contain; }
.ticker { overflow: hidden; white-space: nowrap; }
.ticker-track { display: inline-block; padding-left: 100%; animation: ticker-scroll var(--ticker-duration, 14s) linear infinite; }
.lower-title { font-weight: 900; }
.lower-subtitle { margin-top: 8px; opacity: 0.78; font-size: 0.68em; }
.election-title-card,
.election-lower-card,
.election-question-card,
.election-candidate-card,
.election-speaker-card,
.election-notice-card {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-shadow: none;
}
.election-title-wrap {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  text-shadow: 0 3px 8px rgba(0,0,0,0.42);
  padding: 0 18px 0 6px;
}
.election-emblem {
  width: 58px;
  height: 58px;
  border: 3px solid rgba(255,255,255,0.86);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  font-size: 20px;
  font-weight: 950;
}
.election-title-copy { min-width: 0; }
.election-title-kicker { font-size: 18px; font-weight: 850; line-height: 1; }
.election-title-main { margin-top: 5px; font-size: 31px; font-weight: 950; letter-spacing: -0.045em; line-height: 1.05; }
.election-title-status { margin-left: auto; font-size: 24px; font-weight: 950; line-height: 1.04; text-align: right; white-space: nowrap; opacity: 0.88; }
.election-lower-main {
  height: 72px;
  display: flex;
  box-shadow: 0 12px 26px rgba(0,0,0,0.18);
}
.election-lower-brand {
  width: 150px;
  display: grid;
  place-items: center;
  background: #3974e8;
  color: #fff;
  font-size: 34px;
  font-weight: 950;
  letter-spacing: -0.04em;
  padding: 0 10px;
}
.election-lower-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fff;
  color: #111827;
  padding: 0 28px;
}
.election-lower-label { font-size: 18px; font-weight: 750; line-height: 1; }
.election-lower-title { margin-top: 5px; font-size: 30px; font-weight: 900; line-height: 1.05; letter-spacing: -0.05em; }
.election-lower-note {
  height: 34px;
  margin-top: 10px;
  border-radius: 0;
  display: grid;
  place-items: center;
  background: #fff;
  color: #111827;
  font-size: 15px;
  font-weight: 750;
  box-shadow: 0 8px 18px rgba(0,0,0,0.16);
}
.election-question-tag {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 22px;
  background: #050505;
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 100%, 0 100%);
}
.election-question-body {
  min-height: 54px;
  display: flex;
  align-items: center;
  background: #fff;
  color: #111;
  padding: 0 26px;
  font-size: 29px;
  font-weight: 950;
  letter-spacing: -0.055em;
  line-height: 1.12;
}
.election-color-strip {
  height: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
}
.election-color-strip span:nth-child(1) { background: #ef4444; }
.election-color-strip span:nth-child(2) { background: #a3e635; }
.election-color-strip span:nth-child(3) { background: #2563eb; }
.election-question-meta {
  min-height: 28px;
  display: grid;
  place-items: center;
  background: #fff;
  color: #111;
  font-size: 16px;
  font-weight: 850;
}
.election-candidate-main {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  color: #111;
  padding: 0 22px;
}
.election-candidate-number { font-size: 21px; font-weight: 750; white-space: nowrap; }
.election-candidate-name { font-size: 39px; font-weight: 950; letter-spacing: -0.065em; line-height: 1; }
.election-candidate-role {
  display: grid;
  place-items: center;
  background: #fff;
  color: #111;
  font-size: 13px;
  font-weight: 850;
  padding: 4px 0;
}
.election-candidate-topic {
  height: 36px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  background: #fff;
  color: #111;
  padding: 0 16px;
  border-left: 4px solid #d1d5db;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.045em;
  box-shadow: 0 8px 16px rgba(0,0,0,0.12);
}
.election-speaker-card {
  display: flex !important;
  height: 100%;
  box-shadow: 0 10px 18px rgba(0,0,0,0.18);
}
.election-speaker-name {
  flex: 1;
  display: grid;
  place-items: center;
  background: #fff;
  color: #111;
  font-size: 31px;
  font-weight: 950;
  letter-spacing: -0.045em;
  padding: 0 14px;
}
.election-speaker-label {
  width: 126px;
  display: grid;
  place-items: center;
  background: #3974e8;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  padding: 0 8px;
}
.election-notice-wrap {
  height: 100%;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255,255,255,0.94);
  color: #1f2937;
  font-size: 20px;
  font-weight: 850;
  box-shadow: 0 12px 24px rgba(0,0,0,0.18);
  padding: 0 24px;
}
.election-notice-wrap span {
  border-radius: 0;
  padding: 6px 10px;
  background: #3974e8;
  color: #fff;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.04em;
}
.exit-slide-up.is-hidden { transform: var(--base-transform, rotate(0deg)) translateY(-30px); }
.exit-slide-down.is-hidden { transform: var(--base-transform, rotate(0deg)) translateY(30px); }
.exit-slide-left.is-hidden { transform: var(--base-transform, rotate(0deg)) translateX(-40px); }
.exit-slide-right.is-hidden { transform: var(--base-transform, rotate(0deg)) translateX(40px); }
.exit-pop.is-hidden { transform: var(--base-transform, rotate(0deg)) scale(0.85); }

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

@media (max-width: 980px) {
  .hero { display: block; }
  .create-scene { grid-template-columns: 1fr 1fr; margin-top: 18px; }
  .editor-layout { grid-template-columns: 1fr; }
  .sidebar, .inspector { border: 0; border-bottom: 1px solid var(--line); }
}
