:root {
  --bg: #0f172a;
  --panel: #111827;
  --line: #253046;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-dark: #16a34a;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 0%, #1f2937, var(--bg) 40%);
}

h1, h2, h3 {
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.tiny {
  font-size: 0.86rem;
}

.field-help {
  margin-top: -0.15rem;
  margin-bottom: 0.25rem;
  color: #9ca3af;
  font-size: 0.82rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.field-help code {
  white-space: normal;
  overflow-wrap: anywhere;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
}

.brand-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-logo {
  height: 36px;
  width: auto;
  display: block;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-head h1 {
  margin: 0;
  line-height: 1.12;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem 0;
}

.tab-btn {
  width: auto;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-weight: 600;
}

.tab-btn.active {
  background: rgba(34, 197, 94, 0.16);
  border-color: #22c55e;
  color: #bbf7d0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.05fr) minmax(560px, 1.25fr);
  align-items: start;
  gap: 1rem;
  padding: 1rem 1.25rem 1.5rem;
}

.panel-shell {
  padding: 1rem 1.25rem 1.5rem;
}

.card {
  background: rgba(17, 24, 39, 0.88);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  min-width: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

.form-grid input,
.form-grid select,
.form-grid button {
  width: 100%;
}

input,
select,
button {
  border: 1px solid var(--line);
  background: #0b1220;
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font-size: 0.95rem;
}

.color-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0.15rem 0 0.35rem;
}

.color-item {
  display: grid;
  gap: 0.3rem;
  align-items: start;
}

.color-square {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
}

.form-grid .color-square {
  width: 42px;
  height: 42px;
}

.color-square::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-square::-webkit-color-swatch {
  border: none;
  border-radius: 8px;
}

button {
  cursor: pointer;
  background: var(--accent);
  color: #06230f;
  border: none;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  background: #4b5563;
  color: #d1d5db;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

button.secondary:hover {
  background: rgba(148, 163, 184, 0.12);
}

.actions {
  margin-top: 0.4rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.actions-single {
  grid-template-columns: 1fr;
}

.upload-progress {
  margin-top: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  background: rgba(11, 18, 32, 0.62);
}

.upload-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 0.35rem;
}

.upload-progress-track {
  height: 12px;
  margin-bottom: 0;
}

.jobs-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

.jobs-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.jobs-table th,
.jobs-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.3rem;
  vertical-align: top;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.jobs-table button.mini {
  width: auto;
  padding: 0.35rem 0.55rem;
  font-size: 0.82rem;
  border-radius: 7px;
}

.jobs-table button.danger {
  background: #ef4444;
  color: #fff;
}

.jobs-table button.danger:hover {
  background: #dc2626;
}

.jobs-table th {
  color: var(--muted);
  font-weight: 600;
}

.progress-wrap {
  height: 10px;
  width: 100%;
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.3rem;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #86efac);
  width: 0%;
  transition: width 0.3s ease;
}

.video-preview-wrap {
  position: relative;
  margin-top: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #020617;
  aspect-ratio: 16 / 9;
  min-height: 230px;
}

.video-preview-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

.video-preview-wrap.loading video {
  visibility: hidden;
}

.video-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background: rgba(2, 6, 23, 0.86);
  color: #e5e7eb;
  font-size: 0.92rem;
  text-align: center;
  padding: 0.8rem;
}

.video-loading-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(148, 163, 184, 0.35);
  border-top-color: #22c55e;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.subtitle-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  padding: 0.6rem;
  pointer-events: none;
}

.subtitle-box {
  max-width: min(95%, 92ch);
  border-radius: 6px;
  line-height: 1.16;
  padding: 0.18em 0.32em;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.span-full {
  grid-column: 1 / -1;
}

.hidden {
  display: none;
}

.review-grid {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 0.85rem;
  align-items: start;
}

.review-actions {
  margin-top: 0.65rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.sync-template-block {
  margin-top: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
}

.sync-template-grid {
  display: grid;
  gap: 0.4rem;
  max-height: none;
  overflow-y: visible;
  padding-right: 0;
}

.sync-template-grid input,
.sync-template-grid select {
  width: 100%;
}

.live-card {
  display: grid;
  gap: 0.8rem;
}

.live-controls {
  display: grid;
  grid-template-columns: minmax(210px, 320px) auto;
  gap: 0.55rem;
  align-items: end;
}

.live-controls label {
  grid-column: 1 / 2;
}

.live-controls select,
.live-controls .field-help {
  grid-column: 1 / 2;
}

.live-controls button {
  width: auto;
  min-width: 170px;
  grid-column: 2 / 3;
  grid-row: 1 / span 2;
  align-self: end;
}

.live-controls .field-help {
  margin: 0;
}

.live-style-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.75rem;
  align-items: start;
}

.live-color-row {
  grid-column: 1 / -1;
}

.live-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 1.15rem;
}

.live-status-grid p {
  margin: 0;
}

.live-players-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.live-live-and-subs {
  grid-template-columns: minmax(300px, 0.85fr) minmax(420px, 1.35fr);
}

.live-player-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  background: #0a1323;
  min-width: 0;
}

.live-player-card h3 {
  margin: 0 0 0.45rem;
}

.live-subtitle-feed-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  background: #0a1323;
  min-width: 0;
}

.live-subtitle-feed-card h3 {
  margin: 0 0 0.45rem;
}

.live-subtitle-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  max-height: 420px;
  overflow-y: auto;
}

.live-subtitle-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: rgba(148, 163, 184, 0.07);
}

.live-subtitle-time {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.22rem;
}

.live-subtitle-text {
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
}

.live-subtitle-source {
  margin-top: 0.32rem;
  color: var(--muted);
  font-size: 0.78rem;
  word-break: break-word;
}

.live-output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.45rem;
}

.live-output-head h3 {
  margin: 0;
}

.mini-refresh {
  width: auto;
  min-width: 120px;
  padding: 0.38rem 0.55rem;
  font-size: 0.82rem;
  border-radius: 8px;
}

.dm-embed-host {
  width: 100%;
  height: 100%;
}

.dm-embed-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 8px;
  background: #000;
}

.coming-soon-card {
  display: grid;
  gap: 0.8rem;
}

.coming-soon-pill {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  background: rgba(148, 163, 184, 0.1);
  color: #cbd5e1;
  font-weight: 600;
}

.error-box {
  border: 1px solid #7f1d1d;
  background: rgba(153, 27, 27, 0.2);
  color: #fecaca;
  border-radius: 8px;
  padding: 0.6rem;
  margin-bottom: 0.8rem;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(420px, 92vw);
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}

.auth-brand {
  display: grid;
  gap: 0.45rem;
}

.auth-brand h1 {
  margin: 0;
  line-height: 1.12;
}

.auth-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
}

.hint {
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.86rem;
}

a {
  color: #93c5fd;
}

code {
  color: #c4b5fd;
}

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

  .jobs-table {
    min-width: 0;
  }

  .color-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .review-grid {
    grid-template-columns: 1fr;
  }

  .live-controls {
    grid-template-columns: 1fr;
  }

  .live-controls label,
  .live-controls select,
  .live-controls input,
  .live-controls .field-help,
  .live-controls button {
    grid-column: auto;
    grid-row: auto;
    width: 100%;
  }

  .live-status-grid {
    grid-template-columns: 1fr;
  }

  .live-style-grid {
    grid-template-columns: 1fr;
  }

  .live-players-grid {
    grid-template-columns: 1fr;
  }

  .brand-logo {
    height: 30px;
  }
}
