:root {
  color-scheme: dark;
  --bg: #05070b;
  --bg-alt: #10131a;
  --bg-elevated: #151924;
  --border-subtle: #262b3a;
  --accent: #7f5cff;
  --accent-soft: rgba(127, 92, 255, 0.25);
  --accent-strong: #b49bff;
  --danger: #ff4f6b;
  --fg: #e7ebff;
  --fg-muted: #a2aac9;
  --fg-soft: #6b7285;
  --shadow-soft: 0 14px 40px rgba(0, 0, 0, 0.45);
  --radius-lg: 18px;
  --radius-md: 10px;
  --radius-pill: 999px;
  --pad-card: 16px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: radial-gradient(circle at top left, #15192b 0, #05070b 52%, #020209 100%);
  color: var(--fg);
}

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: rgba(5, 7, 11, 0.93);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-weight: 600;
  color: var(--accent-strong);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: radial-gradient(circle at top left, rgba(127, 92, 255, 0.35), transparent 55%);
  border: 1px solid rgba(127, 92, 255, 0.5);
}

.brand:hover {
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Layout */

.main {
  max-width: 1120px;
  margin: 16px auto 32px;
  padding: 0 12px 32px;
}

/* Tabs */

.tabs {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: rgba(16, 19, 32, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.03);
  margin-bottom: 16px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  padding: 6px 18px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.9rem;
}

.tab.active {
  background: radial-gradient(circle at top, rgba(127, 92, 255, 0.8), rgba(56, 189, 248, 0.5));
  color: #fff;
}

/* Buttons */

.btn {
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(26, 30, 48, 0.9);
  color: var(--fg);
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn.small {
  padding: 4px 11px;
  font-size: 0.78rem;
}

.btn.primary {
  background-image: linear-gradient(90deg, #7f5cff, #38bdf8);
  border-color: rgba(189, 181, 255, 0.7);
}

.btn.primary:hover {
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  background: rgba(255, 79, 107, 0.08);
  border-color: rgba(255, 79, 107, 0.7);
  color: #ffb3c0;
}

/* Panels */

.panel {
  display: none;
  margin-bottom: 18px;
}

.panel.active {
  display: block;
}

/* Cards */

.card {
  background: radial-gradient(circle at top left, rgba(58, 71, 117, 0.4), rgba(11, 15, 29, 0.95));
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--pad-card);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.card-title-row h2 {
  margin: 0;
  font-size: 0.95rem;
}

.card-body {
  padding: var(--pad-card);
}

.card-footer {
  padding: 8px var(--pad-card) 12px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

/* Sticky progress cards (stay visible while scrolling table) */

.card-progress {
  position: sticky;
  top: 72px; /* just below topbar */
  z-index: 15;
}

/* Grid */

.grid {
  display: grid;
  gap: 14px;
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  }
}

/* Text bits */

.small {
  font-size: 0.78rem;
  color: var(--fg-muted);
}

.mono {
  font-family: "SF Mono", ui-monospace, Menlo, Monaco, "Courier New", monospace;
  font-size: 0.8rem;
}

.label {
  color: var(--fg-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Inputs */

input,
select {
  background: rgba(11, 14, 24, 0.9);
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--fg);
  padding: 6px 12px;
  font-size: 0.85rem;
  min-width: 0;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.search {
  width: 160px;
}

.select {
  margin-left: 8px;
}

/* Rows */

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 10px;
  font-size: 0.8rem;
}

/* Dropzone */

.dropzone {
  position: relative;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(162, 170, 201, 0.5);
  padding: 16px 14px;
  text-align: center;
  background: rgba(6, 11, 23, 0.65);
  cursor: pointer;
}

.dropzone .drop-main {
  font-size: 0.9rem;
}

.dropzone .drop-sub {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.dropzone.drag {
  border-color: var(--accent-strong);
  background: radial-gradient(circle at top, rgba(127, 92, 255, 0.2), rgba(6, 11, 23, 0.8));
}

/* Table */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(7, 10, 21, 0.85);
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.tbl thead {
  background: rgba(20, 25, 44, 0.9);
}

.tbl th,
.tbl td {
  padding: 6px 9px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.tbl tbody tr:nth-child(even) {
  background: rgba(11, 15, 30, 0.85);
}

.tbl tbody tr:hover {
  background: rgba(30, 38, 70, 0.9);
}

.cChk {
  width: 26px;
}

.cType {
  width: 90px;
}

.cSize {
  width: 90px;
  text-align: right;
}

.cEnc {
  width: 70px;
  text-align: center;
}

.cAction {
  width: 80px;
  text-align: right;
}

/* Table toolbars */

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.chk-all {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--fg-soft);
}

/* Scroll containers for tables (only table scrolls) */

.card-body-browser,
.card-body-stage {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* Reserve space such that table scrolls inside card */
  max-height: calc(100vh - 260px);
}

.card-body-browser .table-wrap,
.card-body-stage .table-wrap {
  flex: 1;
  min-height: 120px;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
}

/* Progress */

.progress {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(22, 26, 41, 0.95);
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  border-radius: inherit;
  background-image: linear-gradient(90deg, #7f5cff, #38bdf8);
  transition: width 0.18s ease-out;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.op-subtitle {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-bottom: 6px;
}

.op-hint {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--fg-soft);
}

/* Pills */

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--fg-muted);
}

.pill.ok {
  border-color: rgba(56, 189, 248, 0.7);
  color: #bae6fd;
}

.pill.bad {
  border-color: rgba(248, 113, 113, 0.8);
  color: #fecaca;
}

/* Logs */

.log {
  max-height: 120px;
  overflow: auto;
  background: rgba(6, 9, 18, 0.9);
  border-radius: var(--radius-md);
  padding: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.78rem;
}

/* Password gate */

.pw-gate {
  border-radius: var(--radius-md);
  border: 1px dashed rgba(162, 170, 201, 0.6);
  padding: 10px 12px;
  background: rgba(8, 11, 25, 0.9);
}

.pw-message {
  margin-bottom: 8px;
}

.pw-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Drawer (collapsible) */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 100%);
  background: radial-gradient(circle at top left, rgba(58, 71, 117, 0.6), rgba(5, 7, 14, 0.98));
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: -14px 0 40px rgba(0, 0, 0, 0.6);
  z-index: 41;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.drawer.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header h2 {
  margin: 0;
  font-size: 0.95rem;
}

.drawer-body {
  padding: 10px 16px 16px;
  overflow-y: auto;
}

.drawer-section {
  margin-bottom: 14px;
}

.drawer-section h3 {
  font-size: 0.85rem;
  margin: 0 0 4px;
}

/* Dialog */

.dlg {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  background: transparent;
}

.dlg::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.dlg-inner {
  background: radial-gradient(circle at top left, rgba(58, 71, 117, 0.7), rgba(7, 10, 20, 0.98));
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-soft);
}

.dlg-header {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dlg-header h2 {
  margin: 0;
  font-size: 0.95rem;
}

.dlg-body {
  padding: 12px 16px 10px;
}

.dlg-footer {
  padding: 8px 16px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  text-align: right;
}

/* Forms */

.form-row {
  margin-bottom: 10px;
}

.form-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--fg-soft);
}

.field-hint {
  margin-top: 4px;
}

/* History */

.history {
  min-height: 40px;
}

.hItem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.hLeft {
  flex: 1;
}

.hTitle {
  font-size: 0.82rem;
}

.hMeta {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.hTag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.hTag.ok {
  border-color: rgba(34, 197, 94, 0.8);
  color: #bbf7d0;
}

.hTag.bad {
  border-color: rgba(248, 113, 113, 0.85);
  color: #fecaca;
}

/* Toasts */

.toasts {
  position: fixed;
  inset-inline: 0;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 60;
}

.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 360px;
  background: rgba(9, 12, 22, 0.98);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 7px 11px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
  font-size: 0.78rem;
}

.toast .tTitle {
  font-weight: 600;
  margin-bottom: 2px;
}

.toast .tBody {
  color: var(--fg-muted);
}

/* Misc */

.grow {
  flex: 1;
}
