:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #7c9cff;
  --green: #5bb974;
  --success: #5bb974;
  --error: #f07178;
  --border: #2d323c;
}

* { box-sizing: border-box; }

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

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.header h1 { font-size: 1.6rem; margin: 0 0 0.4rem; }
.sub { color: var(--muted); margin: 0 0 1.5rem; line-height: 1.5; }

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green);
  margin-bottom: 0.35rem;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.btn-logout {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-logout:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* Login page */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-wrap { width: 100%; max-width: 400px; }

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem 1.75rem;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.35rem;
}

.login-brand h1 {
  font-size: 1.25rem;
  margin: 0;
  color: var(--green);
}

.login-sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 1.5rem;
  line-height: 1.45;
}

.login-form label {
  display: block;
  margin-bottom: 1rem;
}

.login-form label span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.login-form input {
  width: 100%;
  background: #12151a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  font-size: 0.95rem;
}

.login-form input:focus {
  outline: none;
  border-color: var(--green);
}

.login-form button[type="submit"] {
  width: 100%;
  margin-top: 0.25rem;
  background: var(--green);
  color: #0f1115;
  border: none;
  padding: 0.75rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.login-form button[type="submit"]:disabled { opacity: 0.5; }

.login-error {
  color: var(--error);
  font-size: 0.82rem;
  margin: 0 0 0.75rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.step-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.card h2 { font-size: 1.15rem; margin: 0 0 0.4rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 1.25rem; line-height: 1.5; }

.albums-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.albums-header .hint { margin-bottom: 0; }

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #12151a;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1.4rem;
}

.btn-download:hover { border-color: var(--accent); color: var(--accent); }
.btn-download.disabled { opacity: 0.4; pointer-events: none; }

.btn-download-sm {
  font-size: 0.72rem;
  padding: 0.3rem 0.55rem;
  margin-top: 0;
  border-radius: 6px;
}

/* Upload */
.drop {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop:hover, .drop.dragover {
  border-color: var(--accent);
  background: rgba(124, 156, 255, 0.05);
}

.drop input { display: none; }
.drop-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.drop-title { font-weight: 600; margin-bottom: 0.25rem; }
.drop-sub { font-size: 0.82rem; color: var(--muted); }

.file-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  max-height: 160px;
  overflow-y: auto;
}

.file-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.6rem;
  background: #12151a;
  border-radius: 6px;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}

.file-list .remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

button#start-btn {
  background: var(--accent);
  color: #0f1115;
  border: none;
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

button#start-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.upload-note { font-size: 0.85rem; color: var(--muted); }

/* Stats — fixed height prevents jump */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  min-height: 72px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  text-align: center;
}

.stat-n {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-l {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}

/* Albums */
.albums {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 80px;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1.5rem 0;
  text-align: center;
}

.album {
  background: #12151a;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  contain: layout style;
}

.album-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  user-select: none;
}

.album-head-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.album-head-main:hover { opacity: 0.95; }

.album-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--border);
  flex-shrink: 0;
}

.album-info { flex: 1; min-width: 0; }

.album-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.album-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.badge.queued { background: rgba(154,160,166,0.15); color: var(--muted); }
.badge.running { background: rgba(124,156,255,0.15); color: var(--accent); }
.badge.paused { background: rgba(240,180,41,0.15); color: #f0b429; }
.badge.complete { background: rgba(91,185,116,0.15); color: var(--success); }
.badge.error { background: rgba(240,113,120,0.15); color: var(--error); }

.progress-wrap {
  height: 3px;
  background: var(--border);
  margin: 0 1rem 0.6rem;
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.4s ease;
  border-radius: 2px;
}

.progress-bar.done { background: var(--success); width: 100%; }

.album-body {
  display: none;
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
}

.albums-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.albums-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn-secondary,
.btn-retry {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
}

.btn-secondary:hover,
.btn-retry:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-secondary:disabled,
.btn-retry:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-delete {
  appearance: none;
  border: 1px solid rgba(240, 113, 120, 0.35);
  background: transparent;
  color: var(--error);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
}

.btn-delete-sm {
  font-size: 0.72rem;
  padding: 0.3rem 0.55rem;
  margin-top: 0;
  border-radius: 6px;
}

.btn-delete:hover:not(:disabled) {
  background: rgba(240, 113, 120, 0.12);
  border-color: var(--error);
}

.btn-delete:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  color: var(--muted);
  border-color: var(--border);
}

.album-actions {
  margin-bottom: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.album.open .album-body { display: block; padding-top: 0.85rem; }

.album-progress-text {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  min-height: 1.2em;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

.album-grid figure {
  margin: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0f1115;
}

.album-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.album-grid figcaption {
  font-size: 0.65rem;
  padding: 0.3rem 0.4rem;
  color: var(--muted);
  line-height: 1.2;
}

.cost-line {
  font-size: 0.78rem;
  color: var(--success);
  margin-top: 0.5rem;
}

@media (max-width: 600px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
}

/* Sticky running-process bar */
.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(26, 29, 36, 0.92);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.status-bar.visible {
  transform: translateY(0);
}

body.has-status-bar .wrap {
  padding-bottom: 5rem;
}

.status-bar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(124, 156, 255, 0.5);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.status-dot.queued {
  background: var(--muted);
  animation: none;
  opacity: 0.7;
}

.status-dot.paused {
  background: #f0b429;
  animation: pulse-dot-warn 2s ease-in-out infinite;
}

@keyframes pulse-dot-warn {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(240, 180, 41, 0.45);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(240, 180, 41, 0);
    transform: scale(1.05);
  }
}

@keyframes pulse-dot {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(124, 156, 255, 0.45);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(124, 156, 255, 0);
    transform: scale(1.08);
  }
}

.status-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.status-text strong {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-text span {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-queue {
  font-size: 0.72rem;
  color: var(--muted);
  background: #12151a;
  border: 1px solid var(--border);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-queue:empty {
  display: none;
}
