:root {
  color-scheme: dark;
  --bg: #080909;
  --bg-soft: #101211;
  --surface: rgba(24, 27, 26, 0.78);
  --surface-strong: rgba(31, 34, 33, 0.94);
  --surface-muted: rgba(255, 255, 255, 0.06);
  --text: #f4f7f4;
  --muted: #9aa6a0;
  --border: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.2);
  --accent: #35d0a2;
  --accent-strong: #7bf0c5;
  --accent-soft: rgba(53, 208, 162, 0.14);
  --gold: #f1ba4b;
  --gold-soft: rgba(241, 186, 75, 0.15);
  --info: #68b7ff;
  --info-soft: rgba(104, 183, 255, 0.14);
  --danger: #ff6678;
  --danger-soft: rgba(255, 102, 120, 0.14);
  --ok: #60df8b;
  --ok-soft: rgba(96, 223, 139, 0.14);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  --focus: 0 0 0 3px rgba(53, 208, 162, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(145deg, rgba(53, 208, 162, 0.1), transparent 34%),
    linear-gradient(235deg, rgba(241, 186, 75, 0.09), transparent 42%),
    linear-gradient(180deg, #080909 0%, #101211 52%, #080909 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent 72%);
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  color: #ffffff;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
  align-items: center;
  gap: 18px;
  margin-bottom: 30px;
  padding: 10px;
  background: rgba(15, 17, 16, 0.7);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 950;
  letter-spacing: 0;
  padding: 0 8px;
  white-space: nowrap;
}

.brand:hover {
  color: var(--text);
}

.topbar-actions {
  display: contents;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-self: center;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.nav-links a {
  color: var(--muted);
  padding: 9px 12px;
  border-radius: 7px;
  font-weight: 800;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-links a:hover,
.nav-links a.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.nav-links a.nav-upload {
  color: var(--accent-strong);
}

.nav-links a.nav-upload.is-active {
  background: linear-gradient(135deg, rgba(53, 208, 162, 0.22), rgba(241, 186, 75, 0.12));
  color: var(--text);
}

.logout-form {
  margin: 0;
  justify-self: end;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 20px;
}

.page-header h1,
.auth-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel,
.auth-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.metric {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--info));
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 1.8rem;
  line-height: 1.1;
}

.panel {
  padding: 22px;
  margin-bottom: 18px;
}

.narrow-panel {
  max-width: 780px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: rgba(255, 255, 255, 0.025);
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.16s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.045);
}

tbody tr:last-child td {
  border-bottom: 0;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

td strong,
td .subtle {
  display: block;
}

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

.align-right {
  text-align: right;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-completed,
.status-youtube-done {
  background: var(--ok-soft);
  border-color: rgba(96, 223, 139, 0.35);
  color: var(--ok);
}

.status-uploading-youtube,
.status-uploading-storage-box {
  background: var(--info-soft);
  border-color: rgba(104, 183, 255, 0.35);
  color: var(--info);
}

.status-failed-youtube,
.status-failed-storage-box {
  background: var(--danger-soft);
  border-color: rgba(255, 102, 120, 0.4);
  color: var(--danger);
}

.status-pending {
  background: var(--gold-soft);
  border-color: rgba(241, 186, 75, 0.38);
  color: var(--gold);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #04110d;
  box-shadow: 0 14px 34px rgba(53, 208, 162, 0.22);
}

.button-primary:hover {
  color: #020605;
  border-color: rgba(255, 255, 255, 0.22);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border);
  color: var(--text);
}

.button-secondary:hover,
.button-ghost:hover {
  background: rgba(255, 255, 255, 0.13);
  color: var(--text);
}

.button-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.button-small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.button-full {
  width: 100%;
}

.auth-layout {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(440px, 100%);
  padding: 28px;
}

.auth-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

label,
.file-field {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 900;
}

.field-label {
  color: var(--text);
  font-weight: 900;
}

input[type="text"],
input[type="password"],
input[type="file"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input::placeholder {
  color: rgba(244, 247, 244, 0.45);
}

input:focus {
  outline: 0;
  border-color: rgba(53, 208, 162, 0.58);
  box-shadow: var(--focus);
  background: rgba(255, 255, 255, 0.09);
}

.upload-panel {
  overflow: hidden;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 28px;
  border: 1px dashed rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(53, 208, 162, 0.12), transparent),
    rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.dropzone:hover,
.dropzone.is-dragover,
.dropzone:focus {
  border-color: var(--accent);
  background:
    linear-gradient(135deg, rgba(53, 208, 162, 0.2), rgba(241, 186, 75, 0.1)),
    rgba(255, 255, 255, 0.07);
  box-shadow: var(--focus);
  transform: translateY(-1px);
  outline: 0;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: rgba(53, 208, 162, 0.14);
  border: 1px solid rgba(53, 208, 162, 0.35);
  color: var(--accent-strong);
  font-size: 2rem;
  line-height: 1;
}

.dropzone-title {
  display: block;
  font-size: 1.25rem;
  font-weight: 950;
}

.dropzone-copy,
.dropzone-hint {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.dropzone-hint {
  max-width: 520px;
  font-size: 0.9rem;
}

.file-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.file-meta span {
  overflow-wrap: anywhere;
}

.file-meta strong {
  color: var(--accent-strong);
  white-space: nowrap;
}

.alert,
.flash {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-weight: 800;
}

.alert-error,
.flash-error {
  background: var(--danger-soft);
  color: #ffd7dd;
  border: 1px solid rgba(255, 102, 120, 0.38);
}

.flash-success {
  background: var(--ok-soft);
  color: #d6ffe2;
  border: 1px solid rgba(96, 223, 139, 0.38);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.detail-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.detail-list div {
  display: grid;
  gap: 4px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.detail-list dd:has(.link-action) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.copy-link {
  cursor: copy;
}

.is-disabled-link {
  pointer-events: none;
  cursor: default;
}

.link-action {
  justify-self: start;
}

.settings-actions {
  margin-top: 22px;
}

.youtube-table-link {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.retry-form {
  margin-top: 18px;
}

.progress-card {
  position: relative;
  overflow: hidden;
}

.progress-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(53, 208, 162, 0.08), rgba(241, 186, 75, 0.06), transparent);
}

.progress-card > * {
  position: relative;
}

.status-message {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 1.04rem;
  font-weight: 800;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 900;
}

.progress-head strong {
  color: var(--accent-strong);
}

progress {
  display: block;
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

progress::-webkit-progress-bar {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  box-shadow: 0 0 22px rgba(53, 208, 162, 0.28);
  transition: width 0.22s ease;
}

progress::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.progress-stats,
.progress-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.progress-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  color: var(--muted);
  font-weight: 800;
}

.progress-stats div {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.progress-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.progress-stats strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.upload-progress {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 18px 0;
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.error-text {
  margin: 0;
  color: #ffd7dd;
  font-weight: 800;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  border: 1px solid rgba(96, 223, 139, 0.35);
  border-radius: 8px;
  background: rgba(18, 30, 24, 0.94);
  color: #dcffe6;
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out;
}

.toast-error {
  border-color: rgba(255, 102, 120, 0.42);
  background: rgba(37, 20, 24, 0.95);
  color: #ffd7dd;
}

.toast-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.clipboard-buffer {
  position: fixed;
  left: -9999px;
  top: 0;
}

.is-hidden {
  display: none !important;
}

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

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .topbar,
  .page-header,
  .detail-grid {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

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

  .brand {
    justify-content: center;
    padding: 4px 0;
  }

  .topbar-actions {
    display: grid;
    gap: 10px;
  }

  .nav-links {
    width: 100%;
    justify-self: stretch;
    justify-content: space-between;
  }

  .nav-links a {
    flex: 1;
    text-align: center;
  }

  .logout-form .button,
  .page-header .button {
    width: 100%;
  }

  .metric-grid,
  .progress-stats,
  .progress-meta {
    grid-template-columns: 1fr;
  }

  .panel,
  .auth-panel {
    padding: 18px;
  }

  .dropzone {
    min-height: 220px;
    padding: 22px;
  }

  .detail-list dd:has(.link-action) {
    grid-template-columns: 1fr;
  }

  .file-meta {
    align-items: start;
    flex-direction: column;
  }
}
