/* ── Tokens ───────────────────────────────────────────────────────────────── */
:root {
  --bg:           #0c0c0c;
  --surface:      #161616;
  --surface-2:    #1e1e1e;
  --surface-3:    #252525;
  --border:       #2a2a2a;
  --border-focus: #444;

  --accent:       #ff2d2d;
  --accent-dim:   rgba(255, 45, 45, 0.12);
  --accent-glow:  rgba(255, 45, 45, 0.35);

  --text:         #f0f0f0;
  --text-dim:     #aaa;
  --text-muted:   #555;

  --green:        #22c55e;
  --green-dim:    rgba(34, 197, 94, 0.12);
  --blue:         #60a5fa;
  --blue-dim:     rgba(96, 165, 250, 0.12);
  --yellow:       #eab308;
  --yellow-dim:   rgba(234, 179, 8, 0.12);
  --red:          #ef4444;
  --red-dim:      rgba(239, 68, 68, 0.12);

  --radius:       10px;
  --radius-sm:    6px;

  --font-ui:      'Inter', system-ui, sans-serif;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Menlo', monospace;

  --ease-out:     cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}
.status-dot.ready  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.busy   { background: var(--blue);  box-shadow: 0 0 6px var(--blue); animation: pulse 1.5s ease-in-out infinite; }
.status-dot.error  { background: var(--red);   box-shadow: 0 0 6px var(--red); }

/* ── URL Row ──────────────────────────────────────────────────────────────── */
.input-section { margin-bottom: 40px; }

.url-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.url-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.url-field:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}

.url-icon { color: var(--text-muted); flex-shrink: 0; }

#url-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  padding: 15px 0;
}
#url-input::placeholder { color: var(--text-muted); }

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.clear-btn:hover { color: var(--text); }

.download-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}
.download-btn:hover  { background: #ff4444; }
.download-btn:active { transform: scale(0.97); }
.download-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Video Preview ────────────────────────────────────────────────────────── */
.video-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  position: relative;
  animation: slide-down 0.25s var(--ease-out);
}

.preview-thumb {
  width: 96px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-2);
  flex-shrink: 0;
}

.preview-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preview-title {
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.preview-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22,22,22,0.7);
  border-radius: var(--radius);
  backdrop-filter: blur(2px);
}

/* ── Options Bar ──────────────────────────────────────────────────────────── */
.options-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.type-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.type-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.83rem;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.type-btn:hover { color: var(--text-dim); }
.type-btn.active {
  background: var(--surface-3);
  color: var(--text);
}

.option-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.option-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.83rem;
  padding: 6px 10px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.option-select:focus { border-color: var(--border-focus); }
.option-select option { background: #1e1e1e; }

.output-field { flex: 1; min-width: 220px; }

.dir-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.dir-wrap:focus-within { border-color: var(--border-focus); }

.dir-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 6px 10px;
}

/* ── Queue ────────────────────────────────────────────────────────────────── */
.queue-section {}

.queue-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  border-top: 1px solid var(--border);
  padding-top: 32px;
}

.clear-completed-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.clear-completed-btn:hover { background: var(--red-dim); color: var(--red); border-color: rgba(239,68,68,0.3); }

.queue-title {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.queue-count {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 1px 8px;
}

.queue { display: flex; flex-direction: column; gap: 8px; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Job Card ─────────────────────────────────────────────────────────────── */
.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color 0.2s;
  animation: slide-down 0.2s var(--ease-out);
}
.job-card:hover { border-color: #363636; }
.job-card.is-complete { border-color: rgba(34,197,94,0.2); }
.job-card.is-error    { border-color: rgba(239,68,68,0.2); }
.job-card.is-expired  { opacity: 0.5; }

.job-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.job-thumb-wrap {
  flex-shrink: 0;
  width: 72px;
  height: 40px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface-2);
}

.job-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.job-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
}

.job-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.job-title {
  font-size: 0.88rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.job-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.job-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Status Badge ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-pending     { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-downloading { background: var(--blue-dim);  color: var(--blue);  border: 1px solid rgba(96,165,250,0.2); }
.badge-processing  { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(234,179,8,0.2); }
.badge-complete    { background: var(--green-dim);  color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.badge-error       { background: var(--red-dim);    color: var(--red);   border: 1px solid rgba(239,68,68,0.2); }
.badge-expired     { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Progress Bar (signature element: video-editor playhead) ──────────────── */
.progress-area { margin-top: 14px; }

.progress-track {
  position: relative;
  height: 3px;
  background: var(--surface-2);
  border-radius: 2px;
  margin-bottom: 8px;
}

/* Quarter-mark ticks — reference video timeline UI */
.progress-track::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 24.8%, var(--bg) 24.8%, var(--bg) 25.2%, transparent 25.2%),
    linear-gradient(90deg, transparent 49.8%, var(--bg) 49.8%, var(--bg) 50.2%, transparent 50.2%),
    linear-gradient(90deg, transparent 74.8%, var(--bg) 74.8%, var(--bg) 75.2%, transparent 75.2%);
  z-index: 2;
  border-radius: 2px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  position: relative;
  transition: width 0.4s var(--ease-out);
  overflow: visible;
}

/* Playhead — the signature element */
.playhead {
  position: absolute;
  right: -1.5px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 14px;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 8px 2px var(--accent-glow);
  opacity: 1;
}

.progress-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
}

.progress-pct  { color: var(--text-dim); font-weight: 500; }
.progress-speed { }
.progress-eta  { }

/* ── Action Buttons ───────────────────────────────────────────────────────── */
.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.action-btn:hover { background: var(--surface-3); color: var(--text); border-color: #3a3a3a; }

.dl-btn { border-color: rgba(96,165,250,0.3); color: var(--blue); }
.dl-btn:hover { background: var(--blue-dim); color: var(--blue); border-color: rgba(96,165,250,0.5); }

.trash-btn:hover { background: var(--red-dim); color: var(--red); border-color: rgba(239,68,68,0.3); }

.error-msg {
  display: block;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--red);
  font-family: var(--font-mono);
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  margin-top: 60px;
  padding: 40px 24px 0;
}

.footer-inner {
  max-width: 860px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 32px;
  align-items: start;
  padding-bottom: 32px;
}

.footer-brand {}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.footer-tagline {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.footer-heading {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.footer-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-link {
  font-size: 0.83rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.footer-link:hover { color: var(--accent); }

.footer-col--right {
  display: flex;
  justify-content: flex-end;
}

.footer-copy {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.83rem;
  color: var(--text-muted);
  position: relative;
  padding-right: 64px;
}

.footer-copy-name {
  font-weight: 600;
  color: var(--text);
}

.footer-pentos-logo {
  position: absolute;
  right: 28px;
  bottom: -4px;
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.footer-bottom {
  border-top: 1px solid var(--border);
}

.footer-bottom-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  justify-content: flex-end;
}

.footer-version {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.6;
}

.footer-version:empty { display: none; }

@media (max-width: 600px) {
  .footer-inner {
    grid-template-columns: 1fr;
  }
  .footer-col--right {
    justify-content: flex-start;
  }
}

/* ── Cookie / Storage consent banner ─────────────────────────────────────── */
.consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  animation: slide-up 0.3s var(--ease-out);
}

.consent-banner--hiding {
  animation: slide-down-out 0.25s var(--ease-out) forwards;
}

.consent-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.consent-body {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.consent-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.consent-text {
  font-size: 0.83rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.consent-text strong {
  color: var(--text);
  font-weight: 500;
}

.consent-link {
  color: var(--accent);
  text-decoration: none;
  margin-left: 6px;
  white-space: nowrap;
}
.consent-link:hover { text-decoration: underline; }

.consent-close {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
}
.consent-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

@keyframes slide-down-out {
  from { transform: translateY(0); opacity: 1; }
  to   { transform: translateY(100%); opacity: 0; }
}

/* ── Toasts ───────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.83rem;
  padding: 10px 16px;
  max-width: 320px;
  animation: slide-up 0.25s var(--ease-out);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.toast.error   { border-color: rgba(239,68,68,0.4); color: var(--red); }
.toast.success { border-color: rgba(34,197,94,0.4); color: var(--green); }

.toast-clipboard {
  max-width: 280px;
}
.toast-clipboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast-clipboard-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}
.toast-clipboard-text {
  line-height: 1.3;
}
.toast-clipboard-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.toast-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.8rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.toast-btn:hover {
  background: var(--surface-3, rgba(255,255,255,0.06));
}
.toast-btn-primary {
  background: #b91c1c;
  border-color: transparent;
  color: #fff;
}
.toast-btn-primary:hover {
  filter: brightness(1.15);
}

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.shake { animation: shake 0.4s ease; }

/* ── Downloading pulse on badge ───────────────────────────────────────────── */
.badge-downloading {
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
