:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #07080d;
  color: #f7f8ff;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 70% 25%, rgba(123, 92, 255, .2), transparent 34rem),
    radial-gradient(circle at 20% 85%, rgba(0, 224, 255, .12), transparent 30rem),
    #07080d;
}

a { color: inherit; }

.topbar {
  position: fixed;
  z-index: 10;
  inset: 0 0 auto;
  height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1.25rem, 4vw, 4rem);
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(7,8,13,.78);
  backdrop-filter: blur(1rem);
}

.brand { font-size: 1.15rem; font-weight: 800; letter-spacing: -.04em; text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 1.25rem; color: #b6b9ca; font-size: .9rem; }
.topbar form { margin: 0; }
.link-button { padding: 0; border: 0; background: transparent; color: #87e8ff; }

.flash {
  position: fixed;
  z-index: 20;
  top: 5.25rem;
  left: 50%;
  translate: -50%;
  padding: .85rem 1.1rem;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: .75rem;
  background: #171923;
  box-shadow: 0 1rem 3rem rgba(0,0,0,.35);
}
.flash.success { border-color: rgba(94,240,176,.45); }
.flash.error { border-color: rgba(255,105,128,.55); }

.auth-shell, .app-shell {
  width: min(74rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 7rem 0 3rem;
}

.auth-shell { min-height: 100vh; display: grid; place-items: center; }
.auth-card, .panel, .welcome {
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(15,17,27,.88);
  box-shadow: 0 2rem 6rem rgba(0,0,0,.35);
}
.auth-card { width: min(31rem, 100%); padding: clamp(1.5rem, 5vw, 3rem); border-radius: 1.4rem; }
.auth-card h1, .page-heading h1 { margin: 0; font-size: clamp(2.2rem, 6vw, 4rem); line-height: 1; letter-spacing: -.055em; }
.auth-card > p:not(.eyebrow), .page-heading p, .welcome > p { color: #b6b9ca; line-height: 1.6; }

form { display: grid; gap: 1rem; margin-top: 1.75rem; }
label { display: grid; gap: .45rem; color: #dfe1ee; font-size: .9rem; }
input, select, button {
  min-height: 2.75rem;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: .65rem;
  background: #0b0d15;
  color: #f7f8ff;
  padding: .65rem .8rem;
  font: inherit;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid #87e8ff; outline-offset: 2px; }
button { cursor: pointer; }
button.primary { border-color: transparent; background: linear-gradient(135deg, #775cff, #3cbbdf); font-weight: 760; }
small { color: #8d91a6; line-height: 1.4; }

.page-heading { margin: 2rem 0 2.5rem; }
.admin-grid { display: grid; grid-template-columns: minmax(18rem, 25rem) 1fr; gap: 1.25rem; align-items: start; }
.panel { padding: 1.5rem; border-radius: 1rem; }
.panel h2 { margin: 0 0 1rem; }
.user-list article { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-top: 1px solid rgba(255,255,255,.08); }
.user-list article > div { display: grid; gap: .25rem; }
.user-list article span { color: #9da1b5; font-size: .86rem; }
.user-list article form { display: flex; align-items: center; margin: 0; gap: .65rem; }
.check { display: flex; align-items: center; grid-auto-flow: column; }
.check input { min-height: 0; }
.role-pill { align-self: center; padding: .4rem .7rem; border-radius: 999px; background: rgba(135,232,255,.1); color: #87e8ff !important; }
.role-pill.expired { background: rgba(255,105,128,.12); color: #ff8b9d !important; }
.pending-list { margin-top: 1.25rem; }
.empty { color: #9296aa; }
.firmware-download-shell { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.25rem; }
.firmware-download-shell h2 { margin: .75rem 0 .4rem; }
.firmware-download-shell p { margin: 0; color: #9da1b5; line-height: 1.55; }
.primary-link { border: 0; background: linear-gradient(135deg, #775cff, #3cbbdf); color: white; font-weight: 760; white-space: nowrap; }
.version-status { font-weight: 700; }
.version-status.current { color: #5ef0b0; }
.version-status.outdated { color: #ffbe68; }
.device-delete { color: #ff8b9d; border-color: rgba(255,139,157,.28); }
.firmware-list article { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-top: 1px solid rgba(255,255,255,.08); }
.firmware-main { display: grid; gap: .35rem; }
.firmware-main > div { display: flex; align-items: center; gap: .6rem; }
.firmware-main span { color: #9da1b5; font-size: .84rem; }
.firmware-main p { color: #c7cada; line-height: 1.5; }
.firmware-actions { display: flex; align-items: center; gap: .7rem; }
.firmware-actions form { margin: 0; }
.firmware-links { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 25rem); gap: 2rem; margin-bottom: 1.25rem; }
.firmware-links h2 { margin: .8rem 0; overflow-wrap: anywhere; font-size: 1.15rem; color: #87e8ff; }
.firmware-links p { color: #9da1b5; }
.firmware-links form { margin: 0; }
.downloader-instructions { margin-top: 1.25rem; padding: 1rem; border: 1px solid rgba(135,232,255,.18); border-radius: .8rem; background: rgba(135,232,255,.045); }
.downloader-instructions > span { display: block; color: #9da1b5; font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; }
.downloader-instructions > strong { display: block; margin: .2rem 0 .65rem; color: #87e8ff; font-size: 2rem; letter-spacing: .08em; }
.downloader-instructions ol { margin: 0; padding-left: 1.2rem; color: #c7cada; line-height: 1.55; }

.welcome { margin-top: 6vh; padding: clamp(2rem, 7vw, 6rem); border-radius: 1.5rem; }
.welcome h1 { max-width: 11ch; margin: 0; font-size: clamp(3.4rem, 9vw, 7.5rem); line-height: .9; letter-spacing: -.07em; }
.welcome > p { max-width: 42rem; font-size: 1.1rem; }
.feature-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-top: 3rem; }
.feature-row div { display: grid; gap: .4rem; padding: 1rem; border: 1px solid rgba(255,255,255,.08); border-radius: .8rem; background: rgba(255,255,255,.025); }
.feature-row span { color: #9296aa; font-size: .9rem; }

@media (max-width: 760px) {
  .topbar nav > span { display: none; }
  .admin-grid, .feature-row { grid-template-columns: 1fr; }
  .user-list article { display: grid; }
  .user-list article form { flex-wrap: wrap; }
  .firmware-download-shell, .firmware-list article { align-items: stretch; flex-direction: column; }
  .firmware-links { grid-template-columns: 1fr; }
}

.action-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
.action-link { display: inline-grid; place-items: center; min-height: 2.75rem; padding: .65rem 1rem; border-radius: .65rem; text-decoration: none; }
.page-list { padding: .5rem 1.5rem; }
.page-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.25rem 0; border-bottom: 1px solid rgba(255,255,255,.08); text-decoration: none; }
.page-row:last-child { border-bottom: 0; }
.page-row div { display: grid; gap: .35rem; }
.page-row span { color: #9296aa; font-size: .88rem; }
.empty-state { padding: 3rem 1rem; text-align: center; color: #9296aa; }
.empty-state h2 { color: #f7f8ff; }

.editor-shell { width: calc(100% - 2rem); max-width: none; padding-top: 5.25rem; }
.editor-shell .page-heading { min-height: 3.25rem; margin: 0 0 .75rem; padding: 0 .25rem; align-items: center; }
.editor-shell .page-heading .eyebrow, .editor-shell .page-heading p { display: none; }
.editor-shell .page-heading h1 { font-size: clamp(1.35rem, 2vw, 1.8rem); letter-spacing: -.035em; }
.editor-shell .page-heading a { font-size: .88rem; color: #87e8ff; }
.editor-form { display: block; margin: 0; }
.editor-settings { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.editor-settings label { flex: 1; }
.editor-actions { display: flex; gap: .75rem; }
.editor-grid { display: grid; grid-template-columns: 23rem minmax(0, 1fr); gap: 1rem; align-items: start; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.section-title h2 { margin: 0; }
.section-title span { color: #9296aa; font-size: .85rem; }
.editor-grid > .panel:first-child { padding-bottom: .5rem; }
#layer-list { max-height: calc(100vh - 20rem); overflow-y: auto; overscroll-behavior: contain; padding-right: .35rem; }
.layer-card { display: grid; gap: .85rem; padding: 1rem .65rem; border: 1px solid transparent; border-top-color: rgba(255,255,255,.09); border-radius: .75rem; }
.layer-card:first-child { border-top: 0; }
.layer-card.selected { border-color: rgba(135,232,255,.45); background: rgba(135,232,255,.035); }
.layer-card-head { display: flex; justify-content: space-between; align-items: center; }
.layer-card-head button { min-height: 2rem; padding: .3rem .55rem; color: #ff8b9d; }
.layer-card-head .layer-select { border: 0; padding-left: 0; background: transparent; color: #f7f8ff; font-weight: 750; }
.layer-card textarea { resize: vertical; }
.type-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: .65rem; }
.type-settings label:first-child:last-child { grid-column: 1 / -1; }
.type-settings input[type="color"] { width: 100%; padding: .2rem; }
.common-settings { display: grid; grid-template-columns: 1fr 6rem; align-items: end; gap: .65rem; }
.common-settings input[type="range"] { width: 100%; padding: 0; }
.drag-hint { margin: 0; color: #7f849a; font-size: .76rem; line-height: 1.4; }
.preview-panel { position: sticky; top: 5.25rem; }
.page-preview { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: .75rem; background: repeating-linear-gradient(45deg,#090b12,#090b12 12px,#0d0f18 12px,#0d0f18 24px); }
.preview-layer { position: absolute; display: grid; place-content: center; overflow: visible; padding: .5rem; border: 1px solid rgba(135,232,255,.5); background: rgba(61,72,113,.72); color: white; text-align: center; cursor: grab; touch-action: none; user-select: none; }
.preview-layer:active { cursor: grabbing; }
.preview-layer.selected { border: 2px solid #87e8ff; box-shadow: 0 0 0 1px rgba(0,0,0,.8), 0 0 1.5rem rgba(86,221,247,.18); }
.preview-layer.type-text { background: color-mix(in srgb, var(--layer-bg) 72%, transparent); color: var(--layer-color); }
.preview-layer strong { font-size: clamp(.45rem, 1vw, .75rem); color: #87e8ff; }
.preview-layer span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(.4rem, .9vw, .7rem); }
.preview-layer.type-rtsp,.preview-layer.type-udp_multicast,.preview-layer.type-video { background: rgba(76,43,128,.78); }
.preview-layer.type-web { background: rgba(18,88,105,.78); }
.delete-form { margin: 1.25rem 0 0; }
.delete-form button { color: #ff8b9d; }
.resize-handle { position: absolute; width: 12px; height: 12px; border: 2px solid #071016; border-radius: 50%; background: #87e8ff; z-index: 999; }
.resize-handle.nw { left: -7px; top: -7px; cursor: nwse-resize; }
.resize-handle.ne { right: -7px; top: -7px; cursor: nesw-resize; }
.resize-handle.sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.resize-handle.se { right: -7px; bottom: -7px; cursor: nwse-resize; }

@media (max-width: 900px) {
  .editor-grid { grid-template-columns: 1fr; }
  .preview-panel { order: -1; }
  .action-heading, .editor-settings { align-items: stretch; flex-direction: column; }
}

main {
  position: relative;
  width: min(74rem, calc(100% - 3rem));
  padding: clamp(2rem, 7vw, 7rem) 0;
}

.halo {
  position: absolute;
  z-index: -1;
  width: min(38rem, 72vw);
  aspect-ratio: 1;
  right: -6rem;
  top: 50%;
  translate: 0 -50%;
  border: clamp(1.5rem, 5vw, 4rem) solid rgba(136, 103, 255, .13);
  border-radius: 50%;
  box-shadow: 0 0 7rem rgba(79, 213, 255, .12), inset 0 0 6rem rgba(136, 103, 255, .08);
}

.eyebrow {
  margin: 0 0 1.5rem;
  color: #87e8ff;
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .22em;
}

h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(3.8rem, 9vw, 8.5rem);
  font-weight: 720;
  letter-spacing: -.07em;
  line-height: .88;
}

.intro {
  max-width: 37rem;
  margin: 2.25rem 0;
  color: #b6b9ca;
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.6;
}

.status {
  display: flex;
  align-items: center;
  gap: .7rem;
  width: fit-content;
  padding: .75rem 1rem;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  background: rgba(255,255,255,.045);
  color: #d8daea;
  font-size: .9rem;
}

.status span {
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: #5ef0b0;
  box-shadow: 0 0 1rem #5ef0b0;
}
