:root {
  --bg-dark: #07090e;
  --bg-card: #0d121f;
  --bg-surface: #12192c;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 240, 255, 0.3);
  --accent-cyan: #00f0ff;
  --accent-purple: #8b5cf6;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --font-main: 'Outfit', sans-serif;
  --font-mono: 'Space Grotesk', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(13, 18, 31, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: #000;
  font-weight: 800;
  font-size: 1.4rem;
  border-radius: 10px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.35);
}

.brand-info h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-info h1 span {
  color: var(--accent-cyan);
}

.server-host {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #10b981;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 10px #10b981;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), #00b4d8);
  color: #050b14;
  box-shadow: 0 4px 14px rgba(0, 240, 255, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 240, 255, 0.45);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: #1a233d;
  border-color: var(--accent-cyan);
}

/* Metrics Bar */
.metrics-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  padding: 1.5rem 2rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 1.1rem 1.4rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.metric-icon {
  font-size: 1.8rem;
}

.metric-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-value.highlight {
  color: var(--accent-cyan);
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Studio Layout */
.studio-container {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 2rem;
  padding: 0 2rem 2rem 2rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* Gallery Section */
.gallery-section {
  display: flex;
  flex-direction: column;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}

.section-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.badge {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
}

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.video-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-glow);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.video-card.active {
  border-color: var(--accent-cyan);
  background: #11182c;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.2);
}

.video-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.format-tag {
  font-size: 0.72rem;
  background: rgba(0, 240, 255, 0.1);
  color: var(--accent-cyan);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-weight: 600;
}

.duration-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.video-card h3 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  min-height: 2.8rem;
}

.video-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Player Aside */
.player-aside {
  position: sticky;
  top: 5.5rem;
  height: fit-content;
}

.player-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.player-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.pill-badge {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  color: var(--text-secondary);
}

.player-viewport {
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border-color);
}

.player-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.player-details h4 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.video-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.full-width {
  width: 100%;
  justify-content: center;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  place-items: center;
  z-index: 100;
  padding: 1rem;
}

.modal-overlay.open {
  display: grid;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 580px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-header h3 {
  font-size: 1.3rem;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .half {
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

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

.loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

/* Mode Tabs */
.mode-tabs {
  display: flex;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 1.2rem;
  border: 1px solid var(--border-color);
}

.mode-tab {
  flex: 1;
  padding: 0.6rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-tab.active {
  background: rgba(0, 240, 255, 0.15);
  color: var(--accent-cyan);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.script-textarea {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
}

.help-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  display: block;
}

/* Login Gate Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 14, 0.94);
  backdrop-filter: blur(20px);
  display: none;
  place-items: center;
  z-index: 200;
  padding: 1.5rem;
}

.login-overlay.active {
  display: grid;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 240, 255, 0.15);
}

.brand-icon.lg {
  width: 58px;
  height: 58px;
  font-size: 2rem;
  margin: 0 auto 1.2rem;
}

.login-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.login-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.password-input {
  text-align: center;
  font-size: 1.1rem;
  letter-spacing: 2px;
}

.error-msg {
  color: #ef4444;
  font-size: 0.82rem;
  min-height: 1.2rem;
  margin-bottom: 0.8rem;
}

/* Responsive */
@media (max-width: 1024px) {
  .studio-container {
    grid-template-columns: 1fr;
  }
  .player-aside {
    position: static;
  }
}

