* { box-sizing: border-box; }

body {
  margin: 0;
  font: 1rem/1.45 system-ui, sans-serif;
  color: #111;
  background: white;
}

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

#controls { display: flex; align-items: center; gap: .5rem; }
.display { overflow: hidden; }
.display:not(.active) { cursor: none; }

#screen {
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

.frame, .sample { position: absolute; inset: 0; background: white; }
.frame { display: flex; flex-direction: column; justify-content: center; padding: 4vmin; overflow-wrap: anywhere; }
.frame h1, .frame h2 { margin: 0; font-size: clamp(2rem, 6vmin, 10rem); }
.frame p, .frame ul { margin: .5em 0; font-size: clamp(1.25rem, 3.5vmin, 6rem); }
.frame ul { list-style: none; padding: 0; }
.frame li { margin-top: .5em; }
.frame time { margin-right: 1em; }
.frame img, .frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: black; }
#preview { position: relative; overflow: hidden; width: min(100%, 22rem); aspect-ratio: 16/9; border: 1px solid; }
.sample { display: grid; place-items: center; }
.sample[data-alternate="true"] { color: white; background: #333; }

#controls {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  opacity: 0;
  pointer-events: none;
}

.active #controls, #controls:focus-within { opacity: 1; pointer-events: auto; }
.display.screen-off { background: black; cursor: none; }
.screen-off #screen, .screen-off #controls { display: none; }

.admin {
  --ink: #202943;
  --muted: #526078;
  --line: #d6ddeb;
  --accent: #5341b5;
  background: #f1f4fa;
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem max(4vw, calc((100vw - 74rem) / 2));
  background: #232448;
  color: white;
}
.topbar strong { letter-spacing: -.035em; font-size: 1.15rem; }
.topbar a { color: #e2ddff; font-size: .9rem; text-underline-offset: .2em; }
.console { max-width: 78rem; margin: auto; padding: 2rem clamp(1rem, 4vw, 2rem) 5rem; }
.console h1 { margin: 0 0 1.5rem; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.06em; }
.console h2 { margin: 0 0 1rem; font-size: 1.18rem; letter-spacing: -.035em; }
#workspace { display: grid; grid-template-columns: minmax(13rem, 1fr) minmax(0, 2.8fr); align-items: start; gap: 1.25rem; }
.rail, #editor, .fields { display: grid; min-width: 0; gap: 1rem; }
.panel { min-width: 0; padding: clamp(1rem, 2vw, 1.6rem); background: white; border: 1px solid var(--line); border-radius: 14px; }
.live { background: #203f43; color: #fff; border-color: #203f43; }
.live > span { color: #c5ded9; font-size: .82rem; }
#active { display: block; font-size: 1.5rem; overflow-wrap: anywhere; }
.admin label { display: grid; gap: .4rem; min-width: 0; color: var(--muted); font-weight: 600; font-size: .88rem; }
.admin input, .admin select, .admin textarea {
  width: 100%; min-width: 0; padding: .6rem .7rem; border-radius: 7px;
  border: 1px solid #aebbd0; color: var(--ink); font-size: 1rem; font-weight: 400; background: white;
}
.admin select {
  appearance: none;
  padding-right: 2.5rem;
  background-image: linear-gradient(45deg, transparent 48%, currentColor 50%, currentColor 68%, transparent 70%),
    linear-gradient(135deg, transparent 30%, currentColor 32%, currentColor 50%, transparent 52%);
  background-size: 6px 6px;
  background-position: right calc(.85rem + 6px) center, right .85rem center;
  background-repeat: no-repeat;
}
@media (forced-colors: active) {
  .admin select { appearance: auto; background-image: none; }
}
.admin textarea { min-height: 6rem; resize: vertical; }
.admin .power { color: white; display: flex; gap: .6rem; align-items: center; margin-top: 1rem; cursor: pointer; }
.power input { appearance: none; width: 2.5rem; height: 1.45rem; margin: 0; padding: 2px; border: 1px solid #b5c8ce; border-radius: 1rem; background: #4e6366; cursor: pointer; }
.power input::before { content: ''; display: block; width: 1rem; height: 1rem; border-radius: 100%; background: white; }
.power input:checked { background: #74d4bc; }
.power input:checked::before { background: #153f36; transform: translateX(.95rem); }
.admin button, #controls button { border: 1px solid #c6cde0; background: white; color: #343e5a; border-radius: 7px; padding: .55rem .85rem; font-size: .9rem; font-weight: 600; cursor: pointer; }
.admin button:hover:enabled, #controls button:hover:enabled { background: #efedfc; border-color: #a39aca; }
.admin button:disabled, #controls button:disabled { color: #677188; background: #f0f2f7; cursor: default; }
.admin :focus-visible, #controls :focus-visible { outline: 3px solid #8865da; outline-offset: 3px; }
#library { display: grid; gap: .35rem; }
#library button { overflow-wrap: anywhere; text-align: left; border-color: transparent; }
#library [aria-pressed="true"] { background: #eeeafa; border-color: #cfc6f0; color: #4b349a; }
#new { margin-top: 1rem; width: 100%; }
.actions, .admin .tools, #actions { display: flex; align-items: end; flex-wrap: wrap; gap: .6rem; }
.actions { margin-top: 1rem; }
#publish { background: var(--accent); border-color: var(--accent); color: white; }
#publish:hover { background: #443393; }
#modules fieldset { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .9rem; min-width: 0; margin: 0 0 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 9px; background: #f9fafe; }
#modules legend { color: #4a3b82; font-weight: 700; padding: 0 .4rem; }
.admin .tools { grid-column: 1 / -1; }
.admin .tools button:last-child:enabled { color: #9c3648; }
#actions { border: 0; padding: 0; margin: 0; }
#actions label { flex: 1 1 10rem; }
.transitions { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 1.25rem; }
.fields button { justify-self: start; }
.admin #preview { width: 100%; border: 0; border-radius: 8px; }
.admin .sample { background: #ddd7fb; color: #423476; font-weight: 700; }
.admin .sample[data-alternate="true"] { background: #165953; color: white; }
#status:not(:empty) { position: fixed; bottom: .8rem; left: 50%; transform: translateX(-50%); margin: 0; width: max-content; max-width: 92vw; border-radius: 8px; background: #292c4c; color: white; padding: .65rem 1rem; pointer-events: none; }
@media (max-width: 720px) {
  #workspace { grid-template-columns: 1fr; }
  .console { padding-top: 1.25rem; }
}
@media (max-width: 470px) {
  #modules fieldset, .transitions { grid-template-columns: 1fr; }
}

.topbar nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.login { width: min(26rem, calc(100% - 2rem)); margin: clamp(2rem, 10vh, 7rem) auto; padding: 2rem; }
.login h1 { margin: 0; font-size: 2rem; letter-spacing: -.05em; }
.login p { color: var(--muted); }
.login form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.login button { color: white; background: var(--accent); }
.login button:hover:enabled { background: #443393; }
.login [role="alert"] { color: #932e43; }

.image-upload { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; }
.image-upload label { flex-basis: 100%; }
.image-upload input { flex: 1 1 11rem; }
.image-upload a { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--accent); }
.image-upload img { object-fit: contain; border: 1px solid var(--line); border-radius: 4px; background: white; }
