:root {
  --bg: #0a0a0b;
  --panel: #111113;
  --ink: #fafafa;
  --muted: #8b8b90;
  --faint: #5c5c62;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --live: #4ade80;
  --danger: #f87171;
  --font-ui: 'Instrument Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  display: flex;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---------- Left rail ---------- */

.rail {
  flex: 0 0 25%;
  min-width: 300px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  padding: 28px 32px 32px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 56px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.rail-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  animation: rail-in 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rail-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.rail-intro { margin-bottom: 36px; }

.rail-intro h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.rail-intro p {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

/* Fields */

.field { margin-bottom: 24px; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 8px;
}

.field input[type="text"],
.field input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  transition: border-color 0.15s ease;
}

.field input::placeholder { color: var(--faint); }

.field input:hover { border-color: var(--line-strong); }

.field input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.32);
}

/* Toggle */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-label span {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
}

.toggle-label small {
  display: block;
  font-size: 12px;
  color: var(--faint);
  margin-top: 2px;
}

.switch {
  flex: none;
  width: 36px;
  height: 21px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.switch .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), background 0.18s ease;
}

.switch[aria-checked="true"] {
  background: rgba(74, 222, 128, 0.18);
  border-color: rgba(74, 222, 128, 0.45);
}

.switch[aria-checked="true"] .knob {
  transform: translateX(15px);
  background: var(--live);
}

.switch:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.pw-reveal {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.pw-reveal > input { min-height: 0; }

.pw-reveal.open { grid-template-rows: 1fr; margin-top: 14px; }

.pw-reveal input { opacity: 0; transition: opacity 0.18s ease 0.06s; }

.pw-reveal.open input { opacity: 1; }

.pw-reveal:not(.open) input {
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  pointer-events: none;
}

/* Footer of rail */

.rail-footer { margin-top: auto; padding-top: 24px; }

.file-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--faint);
  margin-bottom: 14px;
}

.file-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}

.file-status.ready { color: var(--muted); }

.file-status.ready .dot {
  background: var(--live);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

.file-status-text { overflow-wrap: anywhere; }

.btn-publish {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-publish:hover:not(:disabled) { background: #e4e4e7; }

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

.btn-publish:focus-visible,
.btn-again:focus-visible,
.btn-copy:focus-visible,
.btn-browse:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.publish-error {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--danger);
}

/* Live / success state */

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 8px;
  border: 1px solid rgba(74, 222, 128, 0.35);
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.1);
  color: var(--live);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 16px;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(74, 222, 128, 0); }
}

.url-ticket {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 16px;
  margin-bottom: 16px;
}

.url-ticket-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  margin-bottom: 8px;
}

.url-ticket-url {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  word-break: break-all;
  margin-bottom: 14px;
}

.btn-copy {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-copy:hover { background: rgba(255, 255, 255, 0.1); }

.btn-copy .copy-done { display: none; }

.btn-copy.copied {
  border-color: rgba(74, 222, 128, 0.45);
  background: rgba(74, 222, 128, 0.12);
  color: var(--live);
}

.btn-copy.copied .copy-idle { display: none; }
.btn-copy.copied .copy-done { display: inline; }

.view-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.view-link:hover { color: var(--ink); }

.btn-again {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.btn-again:hover { border-color: var(--line-strong); color: var(--ink); }

/* ---------- Right stage ---------- */

.stage-wrap {
  flex: 1;
  min-width: 0;
  padding: 16px 16px 16px 0;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #101012;
}

.stage-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage-scrim {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(10, 10, 11, 0.1), rgba(10, 10, 11, 0.55));
  pointer-events: none;
}

/* Empty state */

.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 32px;
}

.stage-headline {
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.45);
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.dropzone {
  width: min(440px, 80%);
  padding: 44px 32px;
  border: 1.5px dashed rgba(255, 255, 255, 0.28);
  border-radius: 18px;
  background: rgba(10, 10, 11, 0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
  animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.08s backwards;
}

.dropzone:hover,
.stage.dragging .dropzone {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(10, 10, 11, 0.62);
}

.stage.dragging .dropzone { transform: scale(1.015); }

.dropzone:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 4px;
}

.dropzone.reject { animation: shake 0.35s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--ink);
  margin-bottom: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.dropzone-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.dropzone-sub {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 20px;
}

.btn-browse {
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-browse:hover { background: rgba(255, 255, 255, 0.14); }

.dropzone-error {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--danger);
}

/* Preview state */

.stage-preview {
  position: absolute;
  inset: 0;
  animation: fade 0.35s ease;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.stage-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.preview-chip {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(10, 10, 11, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: calc(100% - 32px);
}

.preview-chip-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-chip-size {
  font-size: 11.5px;
  color: var(--faint);
  white-space: nowrap;
}

.preview-chip-btn {
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.preview-chip-btn:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.3); }

/* Drag glow across whole stage */

.drag-glow {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.6);
  transition: opacity 0.15s ease;
}

.stage.dragging .drag-glow { opacity: 1; }

/* ---------- Responsive & motion ---------- */

@media (max-width: 860px) {
  body { flex-direction: column; overflow: auto; }
  .rail { flex: none; width: 100%; max-width: none; padding: 24px; }
  .rail-footer { margin-top: 28px; }
  .stage-wrap { padding: 0 16px 16px; min-height: 70vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .stage-video { display: none; }
}
