:root {
  --bg: #0b0d11;
  --bg-2: #12151c;
  --surface: #181c25;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef1f6;
  --muted: #8b93a7;
  --accent: #3ec6ff;
  --accent-2: #6ee7b7;
  --warn: #f5c16c;
  --err: #ff7b8a;
  --init: #3ec6ff;
  --seg: #6ee7b7;
  --mp4: #c4b5fd;
  --radius: 16px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

body {
  background-image:
    radial-gradient(1200px 500px at 10% -10%, rgba(62, 198, 255, 0.12), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(110, 231, 183, 0.08), transparent 45%);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  color: var(--accent);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app[hidden] {
  display: none !important;
}

.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-gate[hidden] {
  display: none !important;
}

.login-card {
  width: min(400px, 100%);
  padding: 28px 24px;
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card .brand-mark {
  display: block;
  margin-bottom: 14px;
}

.login-card h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.login-card > p {
  margin: 6px 0 20px;
  color: var(--muted);
  font-size: 0.88rem;
}

.login-card .field {
  margin-bottom: 12px;
}

.login-card input {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.92rem;
  width: 100%;
}

.login-card .btn {
  width: 100%;
  margin-top: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px 8px;
}

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

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(62, 198, 255, 0.55);
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 16px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.2);
}

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

.btn-primary {
  background: var(--text);
  color: #0b0d11;
  border-color: transparent;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: #fff;
}

.archive-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 28px 12px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.archive-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

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

.field-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field select,
.field input[type="time"] {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.88rem;
  min-width: 120px;
}

.field-time input[type="time"] {
  min-width: 100px;
}

.field select:disabled,
.field input:disabled {
  opacity: 0.5;
}

.archive-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.archive-preview {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 280px;
}

.duration-pills {
  display: flex;
  gap: 6px;
}

.pill {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.pill:hover {
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--text);
}

.pill.is-active {
  background: var(--text);
  color: #0b0d11;
  border-color: transparent;
}

.xfer-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 20%, rgba(62, 198, 255, 0.18), transparent 42%),
    rgba(8, 10, 14, 0.88);
  backdrop-filter: blur(10px);
  z-index: 3;
}

.xfer-overlay[hidden] {
  display: none !important;
}

.xfer-card {
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.xfer-orbit {
  width: 42px;
  height: 42px;
  margin: 0 auto 4px;
  border-radius: 50%;
  border: 2px solid rgba(62, 198, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

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

.xfer-phase {
  margin: 0;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.xfer-bar {
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.xfer-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(62, 198, 255, 0.45);
  transition: width 0.25s ease;
}

.xfer-detail {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.xfer-log {
  list-style: none;
  margin: 4px 0 0;
  padding: 10px 12px;
  max-height: 132px;
  overflow: auto;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--accent-2);
  line-height: 1.45;
}

.xfer-log li {
  opacity: 0.55;
}

.xfer-log li:last-child {
  opacity: 1;
  color: var(--text);
}

.stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  padding: 16px 28px 28px;
  min-height: 0;
}

.player-card,
.sidebar {
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.player-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.drop-zone {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px;
  text-align: center;
  color: var(--muted);
  background: radial-gradient(circle at 50% 30%, #1a2030, #0b0d11 70%);
}

.empty-state[hidden],
.drop-overlay[hidden],
.error[hidden],
.timeline[hidden] {
  display: none !important;
}

.empty-icon {
  width: 64px;
  height: 64px;
  color: var(--accent);
  margin-bottom: 8px;
}

.empty-state h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.empty-state p {
  max-width: 480px;
  line-height: 1.5;
  margin: 0 0 8px;
}

.empty-state p.hint {
  max-width: 480px;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 12px;
}

.empty-state p.hint a {
  color: var(--accent);
}

.drop-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(62, 198, 255, 0.16);
  border: 2px dashed var(--accent);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 600;
  pointer-events: none;
}

.drop-zone.is-dragover .drop-overlay {
  display: grid;
}

.player-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 10px;
  border-top: 1px solid var(--line);
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.error {
  margin: 0;
  color: var(--err);
  font-size: 0.86rem;
}

.timeline {
  display: flex;
  gap: 3px;
  padding: 0 16px 14px;
  min-height: 18px;
}

.tick {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: var(--seg);
  opacity: 0.45;
  cursor: pointer;
  border: 0;
  padding: 0;
}

.tick.init {
  background: var(--init);
}

.tick:hover,
.tick.is-active {
  opacity: 1;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 360px;
  max-height: calc(100vh - 120px);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 10px;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 0.92rem;
}

.count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0 10px 12px;
  overflow: auto;
}

.file-list-empty,
.file-item {
  padding: 10px 10px;
  border-radius: 10px;
}

.file-list-empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.file-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  cursor: pointer;
}

.file-item:hover,
.file-item.is-active {
  background: rgba(255, 255, 255, 0.04);
}

.file-item .idx {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.file-item .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.file-item .meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.badge {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.badge.init {
  color: var(--init);
  background: rgba(62, 198, 255, 0.12);
}

.badge.seg {
  color: var(--seg);
  background: rgba(110, 231, 183, 0.12);
}

.badge.mp4 {
  color: var(--mp4);
  background: rgba(196, 181, 253, 0.12);
}

.size {
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .archive-bar {
    margin: 0 16px 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .archive-actions {
    justify-content: space-between;
  }

  .stage {
    grid-template-columns: 1fr;
    padding: 12px 16px 24px;
  }

  .topbar {
    padding: 16px 16px 4px;
    flex-direction: column;
    align-items: flex-start;
  }

  .sidebar {
    max-height: 280px;
  }
}
