:root {
  --bg: #f2f7fc;
  --bg-soft: #fbfdff;
  --panel: rgba(252, 254, 255, 0.992);
  --panel-strong: rgba(255, 255, 255, 1);
  --panel-inset: rgba(247, 251, 255, 0.995);
  --text: #071428;
  --muted: #465f7c;
  --gold: #1392ff;
  --gold-soft: rgba(19, 146, 255, 0.1);
  --emerald: #0b71ff;
  --emerald-soft: rgba(11, 113, 255, 0.1);
  --blue: #004fe4;
  --blue-soft: rgba(0, 79, 228, 0.14);
  --danger: #e45f5f;
  --line: rgba(72, 116, 176, 0.34);
  --line-strong: rgba(37, 82, 162, 0.48);
  --shadow: 0 12px 28px rgba(9, 36, 78, 0.08);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
  margin: 0;
  font-family: "Comfortaa", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(36, 130, 255, 0.08), transparent 17%),
    radial-gradient(circle at 85% 8%, rgba(0, 63, 177, 0.08), transparent 18%),
    linear-gradient(180deg, #ffffff 0%, #f4f8fc 50%, #e7eef7 100%);
  overflow-x: hidden;
}

.page-glow {
  position: fixed;
  width: 24rem; height: 24rem;
  filter: blur(90px);
  opacity: 0.24;
  pointer-events: none; z-index: 0;
}
.glow-left  { top: -8rem; left: -6rem; background: rgba(36, 132, 255, 0.12); }
.glow-right { top: 10rem; right: -8rem; background: rgba(0, 60, 184, 0.1); }

.grid-noise {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(60, 101, 160, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(60, 101, 160, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.35), transparent);
  pointer-events: none; z-index: 0;
}

/* ── Matrix overlay ─────────────────── */
.matrix-overlay { position: fixed; inset: 0; z-index: 32; overflow: hidden; pointer-events: none; }
.matrix-overlay.hidden { display: none; }
.matrix-line {
  position: absolute; left: -8%; right: -8%;
  color: rgba(12, 93, 202, 0.24);
  font-family: "Comfortaa", sans-serif;
  font-size: 0.8rem; letter-spacing: 0.22em;
  white-space: nowrap; text-transform: uppercase;
  filter: blur(0.25px); opacity: 0;
  will-change: transform, opacity, letter-spacing;
}
.matrix-line.left  { text-align: left;  transform: translateX(-18vw) scaleX(1.08); }
.matrix-line.right { text-align: right; transform: translateX(18vw) scaleX(1.08); }

body.app-ready .matrix-overlay { opacity: 0; transition: opacity 1080ms ease 1180ms; }
body.app-ready .matrix-line { animation: matrixSweep 1180ms cubic-bezier(.2,.9,.22,1) forwards; }
body.app-ready .matrix-line.right { animation-name: matrixSweepRight; }

@keyframes matrixSweep {
  0%   { opacity: 1; }
  62%  { opacity: 1; transform: translateX(14vw) scaleX(0.96); }
  100% { opacity: 0; transform: translateX(40vw) scaleX(0.66); }
}
@keyframes matrixSweepRight {
  0%   { opacity: 1; }
  62%  { opacity: 1; transform: translateX(-14vw) scaleX(0.96); }
  100% { opacity: 0; transform: translateX(-40vw) scaleX(0.66); }
}

/* ── App shell ──────────────────────── */
.app-shell {
  position: relative; z-index: 1;
  width: min(440px, calc(100% - 16px));
  margin: 0 auto;
  padding: 10px 0 16px;
  max-height: 100vh;
}

/* Entrance animations */
.upload-card, .progress-card, .admin-backdoor {
  opacity: 1;
  will-change: transform, opacity;
}
.upload-card    { transform: none; }
.progress-card  { transform: translateY(24px); }
.admin-backdoor { transform: translateY(24px); }

body.app-ready .upload-card    { animation: shellIn 520ms 200ms  cubic-bezier(.34,1.56,.64,1) forwards; }
body.app-ready .progress-card  { animation: shellIn 480ms 320ms  cubic-bezier(.34,1.56,.64,1) forwards; }
body.app-ready .admin-backdoor { animation: shellIn 480ms 400ms  cubic-bezier(.34,1.56,.64,1) forwards; }

@keyframes shellIn {
  from { opacity: 0; }
  to   { opacity: 1; transform: none; }
}

/* ── Panels ─────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hidden { display: none !important; }

/* ── Section heading (compact) ──────── */
.section-heading.compact {
  display: flex; align-items: center;
  margin-bottom: 12px;
}
.section-heading.compact h2 {
  margin: 0; font-size: 1rem; font-weight: 600;
}

/* ── Upload card ────────────────────── */
.upload-card {
  padding: 16px;
  margin-bottom: 10px;
}

/* ── Dropzone ───────────────────────── */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 18px 12px;
  text-align: center;
  transition: border-color 220ms ease, background 220ms ease;
  margin-bottom: 14px;
}
.dropzone.drag-over,
.dropzone.selected { border-color: var(--blue); background: rgba(0, 79, 228, 0.04); }
.clear-files { margin-left: 8px; color: #e55; cursor: pointer; font-size: 0.82em; opacity: 0.8; white-space: nowrap; }
.clear-files:hover { opacity: 1; text-decoration: underline; }

.dropzone-icon {
  width: 42px; height: 42px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 38%, rgba(0, 79, 228, 0.18), transparent 60%),
    var(--blue-soft);
  border: 1px solid rgba(0, 79, 228, 0.22);
  display: grid; place-items: center;
}
.dropzone-icon::after { content: "⬆"; font-size: 1.1rem; opacity: 0.6; }

.dropzone h3 {
  margin: 0 0 4px; font-size: 0.88rem; font-weight: 600;
}
.dropzone p {
  margin: 0 0 10px; color: var(--muted); font-size: 0.72rem;
}
.dropzone button { margin-top: 2px; }

.dropzone-status {
  margin-top: 8px; font-size: 0.76rem; font-weight: 600; color: var(--blue);
}

/* ── Upload form ────────────────────── */
.upload-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.copies-row {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.copies-label {
  font-size: 0.76rem; font-weight: 600; color: var(--muted);
}

.copies-select {
  padding: 8px 28px 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer; outline: none;
  transition: border-color 200ms ease;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23465f7c' d='M2 3l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.copies-select:focus { border-color: var(--blue); }

/* ── Buttons ────────────────────────── */
.primary-btn, .ghost-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.78rem; font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 200ms ease;
  border: none; outline: none;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; text-decoration: none;
  white-space: nowrap;
}
.primary-btn:active, .ghost-btn:active { transform: scale(0.97); }
.primary-btn {
  background: var(--blue); color: #fff;
  box-shadow: 0 4px 14px rgba(0, 79, 228, 0.22);
}
.primary-btn:hover { background: #003bcb; }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ghost-btn {
  background: transparent; color: var(--text);
  border: 1px solid var(--line);
}
.ghost-btn:hover { background: rgba(72, 116, 176, 0.06); }

.small-btn { padding: 5px 10px; font-size: 0.7rem; }
.submit-btn { flex: 1; padding: 10px; font-size: 0.82rem; }

/* ── Status pill ────────────────────── */
.status-pill {
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 600; white-space: nowrap;
}
.status-pill.queued     { background: rgba(72, 116, 176, 0.1); color: var(--muted); }
.status-pill.processing { background: var(--blue-soft); color: var(--blue); }
.status-pill.completed  { background: var(--emerald-soft); color: var(--emerald); }
.status-pill.failed     { background: rgba(228, 95, 95, 0.1); color: var(--danger); }

/* ── Progress card ──────────────────── */
.progress-card {
  padding: 14px 16px; margin-bottom: 10px;
}
.progress-head-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.progress-head-row h2 {
  margin: 0; font-size: 0.88rem; font-weight: 600;
}
.progress-box { margin-top: 0; }
.progress-track {
  height: 6px; border-radius: 999px;
  background: rgba(72, 116, 176, 0.1); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--gold));
  transition: width 600ms ease;
}
.progress-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px;
}
.progress-percent { font-size: 0.78rem; font-weight: 700; color: var(--blue); }
.progress-actions { margin-top: 12px; display: flex; gap: 10px; }

.job-meta { font-size: 0.7rem; color: var(--muted); }

/* ── Admin backdoor ─────────────────── */
.admin-backdoor { padding: 14px 16px; margin-bottom: 10px; }
.search-wrap { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search-wrap input {
  flex: 1; min-width: 140px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  color: var(--text); font-family: inherit;
  font-size: 0.78rem; outline: none;
  transition: border-color 200ms ease;
}
.search-wrap input:focus { border-color: var(--blue); }

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

/* ── Job card (admin list) ──────────── */
.job-card {
  background: var(--panel-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}
.job-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.job-title {
  margin: 0 0 3px; font-size: 0.84rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px;
}
.job-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.seo-quick-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.seo-meta-pill {
  padding: 2px 8px; border-radius: 999px;
  background: rgba(72, 116, 176, 0.06);
  color: var(--muted); font-size: 0.66rem;
}
.seo-meta-pill strong { color: var(--text); font-weight: 600; }

/* ── Toast ──────────────────────────── */
.toast-stack {
  position: fixed; right: 12px; bottom: 12px;
  display: grid; gap: 8px; z-index: 20;
}
.toast {
  min-width: 200px; max-width: 300px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: 0 10px 26px rgba(9, 36, 78, 0.12);
  animation: toastIn 300ms cubic-bezier(.34,1.56,.64,1);
}
.toast strong {
  display: block; font-size: 0.66rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 3px; color: var(--muted);
}
.toast div { font-size: 0.8rem; color: var(--text); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* ── Utility ────────────────────────── */
.eyebrow {
  font-size: 0.66rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--muted);
  font-weight: 600;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #2dbb4f;
  box-shadow: 0 0 12px rgba(45, 187, 79, 0.5);
}
