:root {
  --bg: #07151c;
  --panel: #102d3a;
  --ink: #eefbff;
  --muted: #91b3c1;
  --line: rgba(120, 220, 235, 0.22);
  --cyan: #16d8ef;
  --blue: #0b4b9a;
  --yellow: #f6dc47;
  --danger: #b72b36;
  --ok: #38e675;
}

* { box-sizing: border-box; font-family: Arial, sans-serif; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 28% 12%, rgba(22, 216, 239, 0.22), transparent 34%),
    radial-gradient(circle at 76% 0%, rgba(246, 220, 71, 0.12), transparent 24%),
    linear-gradient(180deg, #061015 0%, var(--bg) 100%);
  color: var(--ink);
}
button, input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
}
button {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  color: #fff;
  border-color: rgba(22, 216, 239, 0.45);
  font-weight: 700;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.secondary, .download-link {
  background: rgba(255,255,255,0.06);
  color: var(--ink);
  border: 1px solid var(--line);
}
button.ghost { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.16); }
button.small, .download-link { padding: 6px 8px; font-size: 12px; min-width: 34px; }
button.danger { background: var(--danger); border-color: var(--danger); }
button:disabled { opacity: 0.45; cursor: default; }
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
}
input[type="file"] { width: 100%; background: rgba(255,255,255,0.06); color: var(--ink); }
input { background: rgba(255,255,255,0.08); color: var(--ink); }
progress { width: 100%; height: 12px; margin-top: 10px; }
.hidden { display: none !important; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card, .panel, .preview-card, .modal-card {
  background: rgba(16, 45, 58, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}
.login-card {
  width: min(460px, 100%);
  padding: 26px;
  display: grid;
  gap: 12px;
}
.login-logo-box {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(215, 222, 233, 0.9);
  border-radius: 8px;
  height: 205px;
  overflow: hidden;
  padding: 0;
}
.login-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transform: scale(1.22);
}
.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
}
.link-button {
  background: transparent;
  border: 0;
  color: var(--cyan);
  padding: 4px 0;
  justify-self: start;
}
.login-card h1, .topbar h1, h2, p { margin: 0; }
.login-card p, .section-head p, .onair-head p { color: var(--muted); }
.danger { color: #ff8088; min-height: 20px; }

#app { min-height: 100vh; padding: 16px; display: grid; gap: 16px; }
.topbar {
  margin: -16px -16px 0;
  padding: 12px 20px;
  background: rgba(4, 18, 25, 0.95);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(215, 222, 233, 0.9);
  border-radius: 8px;
  width: min(540px, 62vw);
  height: 138px;
  overflow: hidden;
  padding: 0;
}
.brand img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transform: scale(1.2);
}
.topbar button { width: 110px; }

.top-grid, .content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
  gap: 16px;
  align-items: start;
}
.preview-card, .panel { padding: 16px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.section-head.compact { align-items: end; }
.section-head button { width: 180px; }
.playlist-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.playlist-summary span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,0.05);
  font-size: 12px;
  white-space: nowrap;
}
.screen-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(22, 216, 239, 0.24);
}
.screen-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}
.preview-empty {
  position: absolute;
  inset: 0;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 20px;
  text-align: center;
}
.preview-empty.small { font-size: 15px; }
.onair-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.onair-head h2 { color: #fff; }
.live-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(56, 230, 117, 0.9);
  animation: pulse 1.1s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(56, 230, 117, 0.85); }
  70% { box-shadow: 0 0 0 10px rgba(56, 230, 117, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 230, 117, 0); }
}
.flow-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 10px;
  padding-bottom: 2px;
}
.flow-chip {
  white-space: nowrap;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 12px;
  color: var(--muted);
}

.playlist-list, .library-list { display: grid; gap: 8px; }
.playlist-item, .library-item {
  display: grid;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 8px;
}
.playlist-item {
  grid-template-columns: 34px 82px minmax(0, 1fr) 82px 78px 34px 34px 34px;
}
.library-item {
  grid-template-columns: 92px minmax(0, 1fr) 66px 66px 66px 66px 48px;
}
.playlist-item.dragging { opacity: 0.55; }
.playlist-thumb, .library-thumb {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
}
.playlist-thumb video, .library-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.playlist-item strong, .media-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.index { color: var(--cyan); font-weight: 700; }
.media-meta { color: var(--muted); font-size: 12px; }
.badge {
  display: inline-flex;
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 11px;
  color: #041015;
  background: var(--yellow);
}

.drop-zone {
  border: 1px dashed rgba(22, 216, 239, 0.48);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  margin-bottom: 10px;
}
.drop-zone.drag { border-color: var(--yellow); color: var(--yellow); }
.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
}
.inline input { width: auto; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal-card {
  width: min(900px, 100%);
  padding: 16px;
}

@media (max-width: 900px) {
  #app { padding: 10px; }
  .topbar { margin: -10px -10px 0; padding: 10px; }
  .brand { width: min(320px, 68vw); height: 86px; }
  .top-grid, .content-grid { grid-template-columns: 1fr; }
  .onair-card { display: none; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .section-head button, .topbar button { width: 100%; }
  .playlist-item {
    grid-template-columns: 30px 76px minmax(0, 1fr) 64px;
  }
  .playlist-item button, .playlist-item .media-meta:nth-of-type(2) { margin-top: 4px; }
  .library-item {
    grid-template-columns: 86px minmax(0, 1fr);
  }
  .library-item button, .library-item .download-link { width: 100%; }
  .login-logo-box { height: 170px; }
}
