:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --soft: #f8fafc;
  --ink: #0f172a;
  --mute: #475569;
  --border: #cbd5e1;
  --input: #94a3b8;
  --primary: #18181b;
  --accent: #d97706;
  --success: #15803d;
  --danger: #dc2626;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
}

.font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Vector Broadcast Overlay Container Stage */
.tv-stage {
  position: relative;
  overflow: hidden;
  container-type: size;
  background: #090d16;
  user-select: none;
}

.tv-player-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: #000000;
}

.tv-video-slot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.tv-standby {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(circle at 50% 42%, rgba(120, 53, 15, 0.36), rgba(9, 13, 22, 1) 72%);
  color: #f8fafc;
}

.tv-standby img {
  height: 25cqh;
  width: auto;
  opacity: 0.9;
}

.tv-standby p {
  margin-top: 2.2cqh;
  font-size: 2.1cqh;
  color: rgba(248, 250, 252, 0.78);
}

/* Vector Overlay Layer */
.tv-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  overflow: hidden;
  font-family: var(--font-sans);
}

.tv-overlay-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2cqh;
}

.tv-overlay-corner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.8cqh;
}

.tv-overlay-corner--right {
  justify-content: flex-end;
}

.tv-logo-group {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
}

.tv-logo-img {
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.48));
}

.tv-logo-tv-tag {
  margin-left: -1.05cqh;
  margin-top: 0.1cqh;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.22cqh 0.55cqh;
  border-radius: 0.4cqh;
  font-size: 1.25cqh;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.tv-pill {
  display: flex;
  align-items: center;
  gap: 0.9cqh;
  border-radius: 1.15cqh;
  padding: 0.8cqh 1.45cqh;
}

.tv-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.55cqh;
  padding: 0.22cqh 0.78cqh;
  font-size: 1.5cqh;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: #d97706;
  color: #ffffff;
}

.tv-channel-name {
  font-size: 1.9cqh;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.tv-clock-weather {
  display: flex;
  align-items: center;
  gap: 1.8cqh;
  border-radius: 1.35cqh;
  padding: 1.15cqh 2.1cqh;
}

.tv-clock-col {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.tv-clock-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 3.9cqh;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tv-clock-sub {
  margin-top: 0.38cqh;
  font-size: 1.45cqh;
  font-weight: 500;
  white-space: nowrap;
}

.tv-divider {
  width: 1px;
  height: 4.6cqh;
  flex-shrink: 0;
}

.tv-weather-col {
  display: flex;
  align-items: center;
  gap: 1.1cqh;
  line-height: 1;
}

.tv-weather-icon {
  width: 3.1cqh;
  height: 3.1cqh;
  flex-shrink: 0;
}

.tv-weather-temp {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 3.4cqh;
  font-weight: 700;
}

.tv-weather-cond {
  margin-top: 0.35cqh;
  font-size: 1.4cqh;
  font-weight: 500;
  white-space: nowrap;
}

/* Promo Ticker */
.tv-ticker-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0;
}

.tv-ticker-bar {
  display: flex;
  align-items: center;
  width: 100%;
  height: 5.8cqh;
  border-radius: 0;
  overflow: hidden;
}

.tv-ticker-prefix {
  z-index: 2;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 2cqh;
  font-size: 1.85cqh;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  background: #d97706;
  color: #ffffff;
  flex-shrink: 0;
}

.tv-ticker-viewport {
  position: relative;
  flex: 1;
  overflow: hidden;
}

@keyframes tv-marquee {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-50%, 0, 0);
  }
}

.tv-ticker-track {
  display: flex;
  width: max-content;
  will-change: transform;
  animation: tv-marquee var(--tv-ticker-duration, 24s) linear infinite;
}

.tv-ticker-group {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.tv-ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 1.2cqh;
  padding: 0 2.4cqh;
  font-size: 2.2cqh;
  font-weight: 600;
  white-space: nowrap;
}

.tv-ticker-badge {
  border-radius: 0.45cqh;
  padding: 0.2cqh 0.8cqh;
  font-size: 1.45cqh;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tv-ticker-diamond {
  margin-left: 1.2cqh;
  width: 1.05cqh;
  height: 1.05cqh;
  opacity: 0.65;
  flex-shrink: 0;
}

/* Corner Kiosk Controls (auto-hidden) */
.tv-corner-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 250ms ease;
}

.tv-ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(12, 15, 22, 0.84);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tv-ctrl-btn:hover {
  background: rgba(15, 23, 42, 0.96);
}

/* Studio ERP-Style UI */
.studio-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.studio-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.studio-header {
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.studio-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.studio-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
}

.studio-h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.studio-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--mute);
}

.studio-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: var(--soft);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: #090d16;
}

.btn-danger {
  color: var(--danger);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.screens-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.screen-tile {
  padding: 12px;
  text-align: left;
  cursor: pointer;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.screen-tile:hover {
  background: var(--soft);
}

.screen-tile.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.screen-tile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.screen-title {
  font-size: 14px;
  font-weight: 600;
}

.screen-key {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mute);
  margin-top: 2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--mute);
  background: var(--soft);
}

.pill-online {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

.studio-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

@media (max-width: 1024px) {
  .studio-main {
    grid-template-columns: 1fr;
  }
}

.studio-panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-box {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.preview-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.transport-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.tabs-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.tab-btn {
  height: 32px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--mute);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 640px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.input,
.select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--input);
  border-radius: 4px;
  background: var(--soft);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
}

.input:focus,
.select:focus {
  outline: 2px solid #1d4ed8;
  outline-offset: -1px;
  background: var(--card);
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--soft);
}

.row-meta {
  min-width: 0;
  flex: 1;
}

.row-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  font-size: 11px;
  color: var(--mute);
  font-family: var(--font-mono);
}

.dropzone {
  border: 2px dashed var(--input);
  border-radius: 4px;
  padding: 16px;
  text-align: center;
  background: var(--soft);
  font-size: 13px;
  color: var(--mute);
  cursor: pointer;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: #e2e8f0;
}

.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 90;
  padding: 10px 14px;
  border-radius: 4px;
  background: var(--primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
}

.code-box {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  font-family: var(--font-mono);
  font-size: 11px;
  word-break: break-all;
  user-select: all;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--soft);
  font-size: 12px;
  font-weight: 500;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-banner {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--soft);
  font-size: 12px;
  line-height: 1.45;
  color: var(--mute);
}

.guide-banner strong {
  color: var(--ink);
}

.playlist-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.drag-handle {
  cursor: grab;
  color: var(--mute);
  font-size: 14px;
  line-height: 1;
  padding: 2px 3px;
  user-select: none;
}

.row-card.dragging {
  opacity: 0.45;
}

.row-card.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.pill-accent {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}
