:root {
  --bg0: #10151c;
  --bg1: #17202b;
  --line: #2a3747;
  --text: #e8eef6;
  --muted: #8fa0b5;
  --accent: #e35d4b;
  --accent-hover: #f06d5a;
  --ok: #3dba7a;
  --warn: #d4a017;
  --err: #e35d4b;
  --field: #0c1118;
  --radius: 12px;
  --font: "DM Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(227, 93, 75, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(61, 186, 122, 0.1), transparent 50%),
    linear-gradient(165deg, #0b1016 0%, var(--bg0) 45%, #121a24 100%);
  background-attachment: fixed;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 12, 18, 0.92);
  backdrop-filter: blur(8px);
}

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

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

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 24px 22px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg1) 88%, transparent);
  border: 1px solid var(--line);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.login-brand {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.login-hint {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

.login-field input {
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--text);
  font: 500 16px/1.2 var(--font);
  outline: none;
}

.login-field input:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  box-shadow: 0 0 0 3px rgba(227, 93, 75, 0.18);
}

.login-error {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--err);
}

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

.login-submit {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: 600 15px/1 var(--font);
  cursor: pointer;
}

.login-submit:hover:not(:disabled) {
  background: var(--accent-hover);
}

.login-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

.page {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.brand {
  margin-bottom: 28px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.brand-mark {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.brand h1 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
  max-width: 36em;
}

.download-form {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 10px;
}

.url-field {
  flex: 1;
  min-width: 0;
}

.url-field input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--field) 88%, transparent);
  color: var(--text);
  font: 500 15px/1.2 var(--font);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.url-field input::placeholder {
  color: #6d7e93;
}

.url-field input:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  box-shadow: 0 0 0 3px rgba(227, 93, 75, 0.18);
}

#submit-btn {
  flex: 0 0 auto;
  min-width: 132px;
  height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: 600 15px/1 var(--font);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

#submit-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

#submit-btn:active:not(:disabled) {
  transform: translateY(1px);
}

#submit-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.form-error {
  margin: 0 0 18px;
  color: var(--err);
  font-size: 14px;
}

.form-error[hidden] {
  display: none !important;
}

.list-section {
  margin-top: 28px;
  padding-top: 8px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.list-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font: 500 13px/1 var(--font);
  cursor: pointer;
}

.ghost-btn:hover {
  color: var(--text);
  border-color: #3d4e63;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg1) 82%, transparent);
  animation: rise 0.35s ease both;
}

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

.file-main {
  min-width: 0;
}

.file-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-queued,
.status-downloading {
  color: var(--warn);
}

.status-done {
  color: var(--ok);
}

.status-error {
  color: var(--err);
}

.progress {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 999px;
  background: #243041;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e35d4b, #f0a060);
  transition: width 0.35s ease;
}

.progress.is-indeterminate > span {
  width: 35% !important;
  animation: indeterminate 1.1s ease-in-out infinite;
}

@keyframes indeterminate {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

.pct {
  font-variant-numeric: tabular-nums;
}

.file-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.action-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 11px;
  font: 500 12px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
}

.action-btn:hover {
  border-color: #4a5f78;
}

.action-btn.danger {
  color: var(--muted);
}

.action-btn.danger:hover {
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 45%, var(--line));
}

.empty-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.empty-hint[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 24px, 760px);
    padding-top: 28px;
  }

  .download-form {
    flex-direction: column;
  }

  #submit-btn {
    width: 100%;
  }

  .file-item {
    grid-template-columns: 1fr;
  }

  .file-actions {
    justify-content: flex-start;
  }
}
