:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #171a21;
  --panel-2: #202633;
  --line: #384150;
  --text: #f3f5f7;
  --muted: #aab1bd;
  --accent: #16c784;
  --accent-2: #4aa3ff;
  --danger: #ff5c6c;
  --warn: #ffbf47;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 1px solid var(--line);
  background: linear-gradient(#2b313d, #242a35);
  color: var(--text);
  border-radius: 7px;
  padding: 8px 11px;
  cursor: pointer;
  min-height: 34px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 2px 0 rgba(0, 0, 0, 0.35),
    0 8px 18px rgba(0, 0, 0, 0.18);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover {
  border-color: #596273;
  background: #303744;
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.35);
}

button.primary {
  border-color: #17a96f;
  background: #13a06a;
  color: #04100b;
  font-weight: 700;
}

button.blue {
  border-color: #347ec5;
  background: #246fab;
}

button.danger {
  border-color: #b43845;
  background: #54212a;
  color: #ffd7dc;
}

button.ghost {
  background: transparent;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #0f1116;
  color: var(--text);
  border-radius: 7px;
  padding: 7px 9px;
  outline: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 1px 0 rgba(0, 0, 0, 0.24);
}

input[type="color"] {
  min-height: 40px;
  padding: 4px;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(22, 199, 132, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(74, 163, 255, 0.14), transparent 40%),
    var(--bg);
}

.login-box {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 27, 34, 0.96);
  box-shadow: var(--shadow);
  padding: 26px;
}

.login-box h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.login-box p {
  margin: 0 0 22px;
  color: var(--muted);
}

.login-box form {
  display: grid;
  gap: 14px;
}

.app-shell {
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: #151820;
  padding: 0 12px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #061016;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 15px;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.project-switcher {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.project-switcher select {
  width: 210px;
  min-width: 0;
  min-height: 36px;
}

.project-switcher button,
.top-actions button {
  min-height: 36px;
  padding: 7px 12px;
  white-space: nowrap;
}

.output-url-hint {
  width: 100%;
  max-width: 540px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace {
  display: grid;
  grid-template-columns: 292px minmax(520px, 1fr) 390px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.panel {
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.panel.right {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.panel-section {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.section-title h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--muted);
}

.upload-drop {
  display: grid;
  gap: 7px;
  border: 1px dashed #4d5667;
  border-radius: 8px;
  background: #11141b;
  padding: 10px;
}

.asset-section {
  max-height: 190px;
  overflow: auto;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.asset-card,
.playlist-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}

.asset-card {
  position: relative;
  padding: 0;
}

.asset-tile {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 8px;
  box-shadow: none;
}

.asset-card.selected,
.playlist-item.selected {
  border-color: var(--accent-2);
  outline: 1px solid rgba(74, 163, 255, 0.5);
}

.asset-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  width: 24px;
  height: 24px;
  min-height: 0;
  place-items: center;
  padding: 0;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
  opacity: 0;
}

.asset-card:hover .asset-delete,
.asset-card:focus-within .asset-delete {
  opacity: 1;
}

.asset-thumb {
  display: grid;
  height: 64px;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background-image:
    linear-gradient(45deg, #2b303a 25%, transparent 25%),
    linear-gradient(-45deg, #2b303a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2b303a 75%),
    linear-gradient(-45deg, transparent 75%, #2b303a 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  background-color: #1d222b;
}

.asset-thumb img {
  max-width: 100%;
  max-height: 100%;
}

.asset-name,
.playlist-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

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

.playlist-panel {
  overflow: auto;
}

.playlist-item {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  align-items: center;
  padding: 7px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 2px 0 rgba(0, 0, 0, 0.38),
    0 10px 20px rgba(0, 0, 0, 0.2);
}

.playlist-item.on-air {
  border-color: rgba(255, 92, 108, 0.9);
  background: linear-gradient(180deg, rgba(84, 33, 42, 0.82), rgba(32, 38, 51, 0.94));
  box-shadow:
    0 0 0 1px rgba(255, 92, 108, 0.32),
    0 0 18px rgba(255, 92, 108, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: livePulse 1.8s ease-in-out infinite;
}

.playlist-item.preview-ready {
  border-color: rgba(22, 199, 132, 0.9);
  background: linear-gradient(180deg, rgba(14, 83, 60, 0.72), rgba(32, 38, 51, 0.96));
  outline: 1px solid rgba(22, 199, 132, 0.45);
}

.playlist-item.on-air .playlist-num {
  background: #b62937;
  color: #ffe9ec;
}

.playlist-item.preview-ready .playlist-num {
  background: #0f8b61;
  color: #ddfff2;
}

.stack-buttons button {
  flex: 1 1 80px;
}

.playlist-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.playlist-actions button {
  min-height: 36px;
  min-width: 0;
  padding: 6px 8px;
  width: 100%;
  font-size: 12px;
  line-height: 1.05;
}

.playlist-actions #new-ticker {
  grid-column: span 1;
}

.playlist-num {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  background: #11141a;
  color: var(--muted);
  font-weight: 800;
}

.playlist-meta {
  color: var(--muted);
  font-size: 11px;
}

@keyframes livePulse {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(255, 92, 108, 0.28),
      0 0 12px rgba(255, 92, 108, 0.14),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  50% {
    box-shadow:
      0 0 0 2px rgba(255, 92, 108, 0.52),
      0 0 24px rgba(255, 92, 108, 0.28),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
}

@keyframes tickerScroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

.center {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  background: #0d0f14;
}

.stage-wrap {
  display: grid;
  min-height: 0;
  place-items: center;
  padding: 10px 12px;
  overflow: hidden;
}

.stage-shell {
  width: min(100%, calc((100vh - 84px) * 1.7777));
  max-height: 100%;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  gap: 12px;
}

.stage-toolbar span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-report {
  margin-left: auto;
  white-space: nowrap;
  font-weight: 700;
}

.output-report.ok {
  color: var(--accent);
}

.output-report.warn {
  color: var(--warn);
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid #3d4553;
  border-radius: 8px;
  box-shadow: var(--shadow);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    #171b23;
  background-size: 80px 80px;
}

.stage-canvas {
  position: absolute;
  left: 0;
  top: 0;
  transform: scale(var(--stage-scale, 1));
  transform-origin: top left;
}

.stage-canvas .output-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stage-canvas .output-object {
  position: absolute;
  box-sizing: border-box;
}

.stage-canvas .output-object img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.stage-canvas .output-text {
  display: block;
  white-space: pre-wrap;
  overflow: hidden;
  line-height: var(--text-line-height, 1.05em);
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

.stage-canvas .output-text-content {
  display: block;
  width: 100%;
  max-width: 100%;
  padding-top: var(--text-pad-top, 0);
  line-height: var(--text-line-height, 1.05em);
  pointer-events: none;
}

.stage-canvas .output-ticker {
  display: flex;
  align-items: center;
  overflow: hidden;
  border-top: 2px solid rgba(255, 255, 255, 0.18);
  border-bottom: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.25);
}

.stage-canvas .output-ticker-track {
  display: flex;
  align-items: center;
  gap: 1.4em;
  min-width: max-content;
  padding-left: 100%;
  animation-name: tickerScroll;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.stage-canvas .output-ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 0.36em;
  white-space: nowrap;
  line-height: 1;
}

.stage-canvas .output-ticker-item img {
  width: 1.45em;
  height: 1.45em;
  object-fit: contain;
}

.stage-canvas .output-ticker-item strong {
  font-weight: 800;
  text-transform: uppercase;
}

.stage-canvas .output-ticker-item em {
  color: rgba(255, 255, 255, 0.72);
  font-style: normal;
}

.safe-area {
  position: absolute;
  inset: 5%;
  border: 1px dashed rgba(255, 255, 255, 0.26);
  pointer-events: none;
  z-index: 1200;
}

.stage-object {
  position: absolute;
  user-select: none;
}

.stage-object img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.stage-object.selected {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.editor-hitbox {
  z-index: 1500;
  min-width: 12px;
  min-height: 12px;
  background: transparent;
  cursor: move;
  overflow: hidden;
}

.editor-hitbox.selected {
  background: rgba(74, 163, 255, 0.025);
}

.editor-text-mirror {
  z-index: 2147483000;
  pointer-events: none;
  display: block;
  white-space: pre-wrap;
  overflow: visible;
  line-height: var(--text-line-height, 1.05em);
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

.editor-text-mirror-content {
  display: block;
  width: 100%;
  max-width: 100%;
  padding-top: var(--text-pad-top, 0);
  line-height: var(--text-line-height, 1.05em);
  mix-blend-mode: normal;
  -webkit-text-stroke: 0.85px rgba(0, 0, 0, 0.78);
  paint-order: stroke fill;
  filter:
    drop-shadow(0 0 1px rgba(255, 255, 255, 0.8))
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.82));
  text-shadow:
    0 0 1px rgba(255, 255, 255, 0.78),
    0 1px 2px rgba(0, 0, 0, 0.88),
    0 0 3px rgba(0, 0, 0, 0.72);
}

.graphic-hitbox,
.text-hitbox {
  cursor: move;
}

.resize-handle {
  position: absolute;
  z-index: 2;
  width: 15px;
  height: 15px;
  border: 2px solid #061016;
  border-radius: 5px;
  background: var(--accent-2);
  cursor: nwse-resize;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.resize-nw {
  left: -7px;
  top: -7px;
  cursor: nwse-resize;
}

.resize-ne {
  right: -7px;
  top: -7px;
  cursor: nesw-resize;
}

.resize-sw {
  left: -7px;
  bottom: -7px;
  cursor: nesw-resize;
}

.resize-se {
  right: -7px;
  bottom: -7px;
  cursor: nwse-resize;
}

.stage-object:not(.selected) .resize-handle {
  display: none;
}

.text-object {
  display: block;
  min-width: 24px;
  min-height: 24px;
  white-space: pre-wrap;
  overflow: hidden;
  line-height: var(--text-line-height, 1.05em);
  cursor: move;
}

.stage-text-content {
  display: block;
  width: 100%;
  max-width: 100%;
  padding-top: var(--text-pad-top, 0);
  line-height: var(--text-line-height, 1.05em);
  pointer-events: none;
}

.graphic-object {
  cursor: move;
}

.ticker-preview {
  display: flex;
  align-items: center;
  overflow: hidden;
  border-top: 2px solid rgba(255, 255, 255, 0.16);
  border-bottom: 2px solid rgba(255, 255, 255, 0.16);
}

.ticker-preview-track {
  display: flex;
  align-items: center;
  gap: 28px;
  min-width: max-content;
  padding: 0 28px;
}

.ticker-preview-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.ticker-preview-item img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.ticker-preview-item strong {
  font-weight: 800;
  text-transform: uppercase;
}

.ticker-preview-item em {
  color: rgba(255, 255, 255, 0.74);
  font-style: normal;
}

.empty-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.program-strip {
  display: grid;
  grid-template-columns: minmax(240px, 0.72fr) 1fr;
  gap: 10px;
  border-top: 1px solid var(--line);
  background: #12151c;
  padding: 8px 10px;
  min-height: 0;
}

.monitor {
  display: grid;
  grid-template-rows: 18px 1fr;
  min-width: 0;
  min-height: 0;
}

.monitor h3 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.program-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(45deg, #2b303a 25%, transparent 25%),
    linear-gradient(-45deg, #2b303a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2b303a 75%),
    linear-gradient(-45deg, transparent 75%, #2b303a 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  background-color: #1d222b;
}

.inspector {
  display: grid;
  gap: 8px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.field-row.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inspector .button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.inspector .button-row button {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding-inline: 8px;
  white-space: nowrap;
}

.inspector .button-row button#text-on-graphic,
.inspector .button-row button#group-move {
  grid-column: 1 / -1;
}

.overlay-actions,
.overlay-tools,
.ticker-actions {
  margin-top: 4px;
}

.ticker-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ticker-actions #parse-ticker {
  grid-column: 1 / -1;
}

.live-section .button-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.layer-list {
  display: grid;
  gap: 6px;
}

.layer-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding-block: 8px;
  text-align: left;
}

.panel.right {
  font-size: 13px;
}

.panel.right textarea {
  min-height: 58px;
  resize: vertical;
}

.panel.right input,
.panel.right select,
.panel.right textarea {
  min-height: 34px;
}

.panel.right .button-row button {
  min-height: 34px;
}

.inspector-section {
  display: block;
}

.inspector-section summary {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  margin: 0 0 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  list-style: none;
  text-transform: uppercase;
}

.inspector-section summary::-webkit-details-marker {
  display: none;
}

.inspector-section summary::before {
  content: "+";
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
}

.inspector-section summary span:first-of-type {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector-section summary span:last-of-type {
  justify-self: end;
}

.inspector-section[open] summary::before {
  content: "-";
}

.live-section {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--panel);
  box-shadow: 0 -12px 24px rgba(0, 0, 0, 0.22);
}

.live-section .button-row button.primary {
  min-width: 0;
}

.ticker-item-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.ticker-item-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12151c;
}

.ticker-item-editor .ticker-item-logo {
  min-width: 0;
}

.ticker-item-editor .ticker-item-remove {
  width: 100%;
}

.layer-button.selected {
  border-color: var(--accent-2);
}

.status {
  color: var(--muted);
  font-size: 12px;
}

.status.live {
  color: var(--accent);
  font-weight: 800;
}

.ticker-count {
  color: var(--muted);
  font-size: 12px;
}

.error {
  color: #ff9aa5;
  font-size: 13px;
}

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

  .panel.right {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
