/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f0f;
  --surface:   #1a1a1a;
  --border:    #2a2a2a;
  --text:      #e8e8e8;
  --muted:     #666;
  --accent:    #c8f0a0;
  --accent-dk: #9ecf70;
  --danger:    #f08080;
  --radius:    8px;
  --font:      'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
header {
  width: 100%;
  max-width: 640px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 0 1.5rem;
}

main {
  width: 100%;
  max-width: 640px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

footer {
  width: 100%;
  max-width: 640px;
  text-align: center;
  padding: 1.5rem 0 2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ── Logo ──────────────────────────────────────────────────────────────────── */
.logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  text-decoration: none;
}

/* ── Utility ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.mode-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg);
  border-radius: 6px;
  padding: 3px;
  width: fit-content;
}

.tab {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.35rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: var(--font);
}

.tab:hover { color: var(--text); }
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.dl-form {
  display: flex;
  gap: 0.5rem;
}

.dl-form input[type="url"] {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  padding: 0.6rem 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.dl-form input[type="url"]:focus {
  border-color: var(--accent);
}

.dl-form input[type="url"]::placeholder {
  color: var(--muted);
}

button[type="submit"], .btn-primary {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #111;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

button[type="submit"]:hover, .btn-primary:hover {
  background: var(--accent-dk);
}

button[type="submit"]:disabled, .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.8rem;
  font-family: var(--font);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

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

.logout-form { display: flex; }

/* ── Progress ──────────────────────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 100px;
  height: 4px;
  overflow: hidden;
}

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

.progress-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.progress-msg {
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.2em;
}

.progress-msg.is-error { color: var(--danger); }

/* ── Spinner ───────────────────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 0.5rem;
}

/* ── Clip editor ───────────────────────────────────────────────────────────── */
#clip-preview {
  width: 100%;
  border-radius: 6px;
  background: #000;
  max-height: 320px;
}

.clip-times {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.time-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 110px;
}

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

.time-field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: monospace;
  padding: 0.5rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}

.time-field input:focus { border-color: var(--accent); }
.time-field input:invalid { border-color: var(--danger); }

#clip-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #111;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  align-self: flex-end;
}

#clip-btn:hover { background: var(--accent-dk); }
#clip-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Dashboard ─────────────────────────────────────────────────────────────── */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dashboard-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 500;
}

#dashboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@keyframes item-appear {
  0%   { opacity: 0; transform: translateY(-6px); background: rgba(200, 240, 160, 0.10); border-color: rgba(200, 240, 160, 0.4); }
  35%  { opacity: 1; transform: translateY(0);    background: rgba(200, 240, 160, 0.10); border-color: rgba(200, 240, 160, 0.4); }
  100% { opacity: 1; transform: translateY(0);    background: var(--surface);            border-color: var(--border); }
}

.dl-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

.dl-item.is-new {
  animation: item-appear 2.5s ease forwards;
}

.dl-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dl-item-mode {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  flex-shrink: 0;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.badge-downloading { background: #1a2a1a; color: var(--accent); }
.badge-processing  { background: #1a1a2a; color: #80c0f0; }
.badge-finished    { background: #1a2a1a; color: var(--accent); }
.badge-error       { background: #2a1a1a; color: var(--danger); }
.badge-expired     { background: var(--border); color: var(--muted); }
.badge-queued      { background: var(--border); color: var(--muted); }

.dl-item-btn {
  background: var(--accent);
  color: #111;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font);
  text-decoration: none;
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 0.15s;
}

.dl-item-btn:hover { background: var(--accent-dk); }

.dl-item-ttl {
  font-size: 0.7rem;
  color: #e07030;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.login-card .logo {
  text-align: center;
  display: block;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-form input[type="password"],
.login-form input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font);
  padding: 0.65rem 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.login-form input[type="password"]:focus,
.login-form input[type="text"]:focus {
  border-color: var(--accent);
}

.login-form button {
  width: 100%;
  padding: 0.65rem;
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  text-align: center;
}
