/* ---------- Tokens ---------- */
:root {
  --bg: #0b0c0e;
  --surface: #131417;
  --surface-2: #1a1b1f;
  --surface-3: #23252a;
  --ink: #f4f5f7;
  --muted: #9a9ea8;
  --faint: #6b6f78;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --accent: #3b74f2;
  --accent-hover: #5287f5;
  --accent-soft: rgba(59, 116, 242, 0.14);
  --on-accent: #ffffff;
  --success: #3ccf8e;
  --danger: #ff8a7a;
  --danger-bg: rgba(255, 90, 70, 0.12);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;

  --h-sm: 36px;
  --h-md: 44px;
  --h-lg: 52px;

  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font: 15px/1.5 "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, a { font: inherit; color: inherit; }
figure { margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

/* ---------- Buttons: one system everywhere ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--h-md);
  padding: 0 18px;
  border: 0;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: default; opacity: 0.45; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: rgba(255, 255, 255, 0.04); }

.btn-sm { height: var(--h-sm); padding: 0 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { height: var(--h-lg); font-size: 15px; }
.btn-block { width: 100%; }

.btn.is-done {
  background: transparent;
  color: var(--success);
  box-shadow: inset 0 0 0 1px rgba(60, 207, 142, 0.35);
  opacity: 1;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.icon-btn.remove:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }

/* ---------- Shell ---------- */
.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0 24px calc(40px + env(safe-area-inset-bottom));
}

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  margin: 0 -24px 8px;
  padding: 0 24px;
  background: rgba(11, 12, 14, 0.8);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.mark { width: 28px; height: 28px; border-radius: 8px; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.03em; }

.nav { display: flex; align-items: center; gap: 8px; }
.nav-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.nav-tabs button {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.nav-tabs button:hover:not(.is-current) { color: var(--ink); }
.nav-tabs button.is-current { background: var(--surface-3); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.4); }

.nav-out {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}
.nav-out:hover { color: var(--ink); background: var(--surface-2); }

/* ---------- Notifications ---------- */
.bell-wrap { position: relative; }
.bell {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
  transition: color .15s, box-shadow .15s, background .15s;
}
.bell:hover, .bell[aria-expanded="true"] { color: var(--ink); background: var(--surface-2); }

/* New notification: the border glows until the panel is opened */
.bell.is-glowing {
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 0 rgba(59, 116, 242, 0.6);
  animation: bell-glow 1.8s ease-out infinite;
}
.bell.is-glowing svg { animation: bell-ring 1.8s ease-in-out infinite; transform-origin: 50% 10%; }
@keyframes bell-glow {
  0% { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 0 rgba(59, 116, 242, 0.55), 0 0 14px rgba(59, 116, 242, 0.45); }
  70% { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 8px rgba(59, 116, 242, 0), 0 0 18px rgba(59, 116, 242, 0.25); }
  100% { box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 0 rgba(59, 116, 242, 0), 0 0 14px rgba(59, 116, 242, 0.45); }
}
@keyframes bell-ring {
  0%, 60%, 100% { transform: rotate(0); }
  10% { transform: rotate(14deg); }
  20% { transform: rotate(-12deg); }
  30% { transform: rotate(8deg); }
  40% { transform: rotate(-4deg); }
}

/* A job is running: a thin ring spins around the bell */
.bell.is-busy::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 12px;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
  pointer-events: none;
}

.bell-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  width: 360px;
  max-height: min(520px, 75vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-lg);
  animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 8px 16px;
  border-bottom: 1px solid var(--line);
}
.notif-title { margin: 0; font-size: 14px; font-weight: 700; }
.notif-list { overflow-y: auto; padding: 6px; }

.notif-item, .notif-live button {
  display: grid;
  grid-template-columns: 30px 1fr 8px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.notif-item:hover, .notif-live button:hover { background: var(--surface-2); }
.notif-live { padding: 6px 6px 0; }
.notif-live button { grid-template-columns: 30px 1fr; background: var(--accent-soft); }

.notif-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
}
.notif-icon.is-good { background: rgba(60, 207, 142, 0.14); color: var(--success); }
.notif-icon.is-bad { background: var(--danger-bg); color: var(--danger); }
.notif-icon .spinner { width: 16px; height: 16px; border-width: 2px; }

.notif-body { display: grid; gap: 2px; min-width: 0; }
.notif-msg { font-size: 13px; font-weight: 500; color: var(--muted); }
.notif-time { font-size: 12px; color: var(--faint); }
.notif-item.is-unread .notif-msg { color: var(--ink); font-weight: 600; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; }
.notif-item.is-unread .notif-dot { background: var(--accent); }

.tray-meter {
  display: block;
  height: 3px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}
#tray-fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }

.notif-empty { margin: 0; padding: 28px 16px 32px; color: var(--faint); font-size: 13px; text-align: center; }

/* ---------- Naming dialog ---------- */
.name-dialog {
  width: min(420px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-lg);
}
.name-dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); }
.name-dialog[open] { animation: pop .16s ease-out; }
.name-dialog form { display: grid; gap: 4px; padding: 22px; }
.name-title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.name-sub { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.name-dialog .status { margin-top: 8px; }
.name-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Page head ---------- */
main { padding-top: 24px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 3.4vw, 32px);
  line-height: 1.1;
  letter-spacing: -0.035em;
  font-weight: 700;
}

.lead { margin: 6px 0 0; color: var(--muted); font-size: 15px; max-width: 44em; }

/* ---------- Auth ---------- */
main:has(> .auth-panel:not([hidden])) {
  min-height: calc(100dvh - 120px);
  display: grid;
  place-items: center;
}
.auth-panel { width: min(400px, 100%); }
.auth-card {
  padding: 32px 28px 20px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line), 0 20px 50px -24px rgba(0, 0, 0, 0.7);
  text-align: center;
}
.auth-mark { display: block; margin: 0 auto 18px; border-radius: 12px; }
.auth-card form { margin-top: 20px; text-align: left; }
.auth-card .btn-primary { margin-top: 20px; }
.auth-card .btn-ghost { margin-top: 6px; }
.auth-card .btn-secondary { margin-top: 20px; }

.field-label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
.field {
  width: 100%;
  height: var(--h-md);
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.field:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent); }

/* ---------- Cards / status ---------- */
.card {
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.status {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.status:empty { display: none; }
.status.error { color: var(--danger); background: var(--danger-bg); box-shadow: none; }

.note { margin: 10px 0 0; color: var(--faint); font-size: 13px; text-align: center; }

/* ---------- Make page layout by state ---------- */
.draw { display: grid; gap: 20px; }
.draw > .page-head { margin-bottom: 4px; }

/* empty: just the drop zone */
.draw[data-state="empty"] .clip-card { display: none; }
.draw[data-state="empty"] .draw-side:not(:has(.status:not(:empty))) { display: none; }

/* result: compare full width, side shows only status */
.draw[data-state="result"] .clip-card { display: none; }
.draw[data-state="result"] .draw-side { max-width: 720px; }
.draw[data-state="result"] .status { margin: 0; }

.clip-head:has(.clip-name:empty) { display: none; }

@media (min-width: 860px) {
  .draw[data-state="clip"],
  .draw[data-state="working"] {
    grid-template-columns: minmax(0, 1fr) 340px;
    column-gap: 24px;
    align-items: start;
  }
  .draw[data-state="clip"] > .page-head,
  .draw[data-state="working"] > .page-head,
  .draw[data-state="clip"] > .resume,
  .draw[data-state="working"] > .resume { grid-column: 1 / -1; }
  .draw[data-state="clip"] .draw-side,
  .draw[data-state="working"] .draw-side { position: sticky; top: 88px; }
  /* working after refresh: no local preview, centre the progress card */
  .draw[data-state="working"]:has(#stage[hidden]) { grid-template-columns: minmax(0, 480px); justify-content: center; }
}

/* ---------- Resume banner ---------- */
.resume {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 12px 12px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.resume-body { display: flex; align-items: center; gap: 12px; min-width: 0; }
.resume-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.resume-title { margin: 0; font-size: 14px; font-weight: 600; }
.resume-sub { margin: 0; color: var(--faint); font-size: 13px; }
.resume-actions { display: flex; gap: 6px; flex: none; }

/* ---------- Drop zone ---------- */
.file {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 280px;
  padding: 32px 20px;
  border-radius: var(--r-lg);
  background:
    radial-gradient(600px 240px at 50% 0%, rgba(59, 116, 242, 0.08), transparent 70%),
    var(--surface);
  border: 1.5px dashed var(--line-strong);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.file:hover { border-color: rgba(59, 116, 242, 0.6); }
.file.dragover { border-color: var(--accent); background: var(--accent-soft); }

.file-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 10px;
  border-radius: 16px;
  color: var(--accent);
  background: var(--accent-soft);
}
#file-label { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
#file-label u { color: var(--accent); text-decoration: none; }
.file-hint { color: var(--faint); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 18px; }
.chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.file input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- Tips (empty state only) ---------- */
.draw:not([data-state="empty"]) .tips { display: none; }
.tips-title {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}
.tips-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tip {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.tip-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.tip-title { margin: 1px 0 3px; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.tip-text { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

@media (max-width: 960px) { .tips-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .tips-grid { grid-template-columns: 1fr; } }

/* ---------- Video ---------- */
video {
  display: block;
  width: 100%;
  border-radius: var(--r-lg);
  background: #000;
}
#preview { max-height: 70vh; }
.stage-frame { position: relative; }
.drop-cover {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  place-items: center;
  border-radius: var(--r-lg);
  background: rgba(11, 12, 14, 0.78);
  border: 1.5px dashed var(--accent);
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
}
.stage.dragover .drop-cover { display: grid; }

/* ---------- Side card ---------- */
.clip-card { display: grid; gap: 14px; }

.clip-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.clip-icon {
  flex: none;
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--muted);
}
.clip-name {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.stage-actions { display: flex; flex: none; gap: 2px; }

.clip-card #go { margin-top: 2px; }
.clip-card .note { margin: -4px 0 0; }

/* Trim */
.window {
  padding: 14px 14px 10px;
  border-radius: var(--r-md);
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
}
.window-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.window-label { margin: 0; font-size: 13px; font-weight: 600; }
.window-help { margin: 0; color: var(--faint); font-size: 12px; }
.times {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.slider { position: relative; height: 40px; touch-action: none; }
.slider-track,
.slider-fill { position: absolute; top: 17px; height: 6px; border-radius: 999px; }
.slider-track { left: 0; right: 0; background: var(--surface-3); }
.slider-fill { background: var(--accent); }
.slider input[type="range"] {
  position: absolute; left: 0; top: 17px;
  width: 100%; height: 6px; margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none; appearance: none;
}
.slider input[type="range"]::-webkit-slider-runnable-track { height: 6px; background: transparent; }
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px; margin-top: -7px;
  border: 0; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px var(--accent-soft), 0 2px 6px rgba(0,0,0,.5);
  pointer-events: auto; cursor: grab;
}
.slider input[type="range"]::-moz-range-track { height: 6px; background: transparent; border: 0; }
.slider input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border: 0; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px var(--accent-soft), 0 2px 6px rgba(0,0,0,.5);
  pointer-events: auto; cursor: grab;
}

/* Optional details */
.details {
  border-radius: var(--r-md);
  box-shadow: inset 0 0 0 1px var(--line);
}
.details.is-open { background: var(--bg); }
.details-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.details-toggle:hover { color: var(--ink); }
.details-toggle svg { transition: transform .15s; }
.details.is-open .details-toggle svg { transform: rotate(45deg); }
.details-optional {
  margin-left: auto;
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
}
.details-toggle.has-note .details-optional::before {
  content: "Added · ";
  color: var(--success);
}
.details-body { display: grid; gap: 10px; padding: 0 12px 12px; }
.details-help { margin: 0; color: var(--faint); font-size: 12px; }
.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer;
}
.chip-btn:hover { color: var(--ink); background: var(--surface-3); }
.details-field { position: relative; }
.details-note {
  display: block;
  width: 100%;
  min-height: 84px;
  padding: 10px 12px 22px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  resize: vertical;
  font-size: 13px;
  line-height: 1.45;
}
.details-note:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent); }
.details-note::placeholder { color: var(--faint); }
.details-count {
  position: absolute;
  right: 10px;
  bottom: 6px;
  color: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.details-count.is-near { color: var(--danger); }

/* Details belong to setup only */
.draw[data-state="working"] .details { display: none; }

/* Live progress */
.live { display: grid; gap: 14px; }

.live-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.live-kicker { margin: 0; color: var(--muted); font-size: 12px; font-weight: 500; }
.live-pct {
  margin: 2px 0 0;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.live-pct small { margin-left: 2px; color: var(--faint); font-size: 20px; font-weight: 600; }
.live-time {
  margin: 0 0 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.meter { position: relative; height: 6px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #4c86ff, #6a45f0);
  transition: width .45s ease;
}
/* moving sheen so it feels alive even when the number is slow */
.meter-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  transform: translateX(-100%);
  animation: sheen 1.6s ease-in-out infinite;
}
@keyframes sheen { to { transform: translateX(100%); } }

.steps { display: grid; gap: 0; margin: 2px 0 0; padding: 0; list-style: none; }
.steps li {
  position: relative;
  display: grid;
  grid-template-columns: 20px 1fr;
  column-gap: 12px;
  padding: 7px 0;
  color: var(--faint);
  font-size: 13px;
}
/* connector line between dots */
.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 9.5px;
  top: 25px;
  bottom: -7px;
  width: 1px;
  background: var(--line-strong);
}
.steps li.is-done:not(:last-child)::after { background: rgba(60, 207, 142, 0.45); }
.step-dot {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
}
.step-name { align-self: center; font-weight: 500; }
.step-detail {
  grid-column: 2;
  display: none;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.steps li.is-active { color: var(--ink); }
.steps li.is-active .step-name { font-weight: 600; }
.steps li.is-active .step-detail { display: block; }
.steps li.is-active .step-dot {
  box-shadow: none;
  background:
    conic-gradient(from 0deg, var(--accent), transparent 70%) border-box;
  -webkit-mask: radial-gradient(circle, transparent 6.5px, #000 7px);
  mask: radial-gradient(circle, transparent 6.5px, #000 7px);
  animation: spin .9s linear infinite;
}
.steps li.is-done { color: var(--muted); }
.steps li.is-done .step-dot {
  box-shadow: none;
  background: var(--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b0c0e' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 12px no-repeat;
}

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

.live-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
}
.live-hint svg { flex: none; }

/* While drawing, the clip on the left gets a soft "being redrawn" sweep */
.draw[data-state="working"] .stage-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-lg);
  pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(106, 69, 240, 0.22) 45%, rgba(76, 134, 255, 0.28) 50%, transparent 65%);
  background-size: 250% 100%;
  animation: redraw 2.8s ease-in-out infinite;
}
@keyframes redraw { from { background-position: 120% 0; } to { background-position: -20% 0; } }

/* Replace/remove are locked while a job runs, so hide them */
.draw[data-state="working"] .stage-actions { display: none; }

/* ---------- Result ---------- */
.compare { display: grid; gap: 16px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.compare-pane { min-width: 0; }
.compare-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.cartoon-pane .compare-label { color: var(--accent); }
.compare-video { aspect-ratio: 16 / 9; object-fit: contain; }

.cartoon-frame { position: relative; }
.fix-overlay {
  display: none;
  position: absolute;
  inset: 0;
  border-radius: var(--r-lg);
  background: rgba(11, 12, 14, 0.62);
  backdrop-filter: blur(3px);
  place-items: center;
  align-content: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
}
.compare.is-fixing .fix-overlay { display: grid; }

.spinner {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  animation: spin .8s linear infinite;
}

.result-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 8px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.fix-box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 4px 4px 4px 14px;
  border-radius: var(--r-md);
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
}
.fix-box:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent); }
.fix-note {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  height: 36px;
  max-height: 140px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  resize: none;
  overflow-y: hidden;
  font-size: 14px;
  line-height: 20px;
}
.fix-note:focus { outline: none; }
.fix-note::placeholder { color: var(--faint); }

.choices { display: flex; gap: 8px; flex: none; }

/* ---------- Library ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.vcard {
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.vcard video { border-radius: 0; aspect-ratio: 16 / 9; object-fit: cover; background: #000; }
.vcard-thumb { position: relative; cursor: pointer; }
.vcard-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: opacity .15s;
}
.vcard-play span {
  display: grid; place-items: center;
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
}
.vcard.is-playing .vcard-play { opacity: 0; pointer-events: none; }
.vcard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 10px 14px;
}
.vcard-foot > div:first-child { min-width: 0; }
.vcard-title {
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.vcard-sub { margin: 0; color: var(--faint); font-size: 12px; }
.vcard-actions { display: flex; gap: 2px; }

.vcard.is-pending .vcard-thumb {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  cursor: default;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 56px 20px;
  border-radius: var(--r-lg);
  border: 1.5px dashed var(--line-strong);
  text-align: center;
}
.empty-title { margin: 0; font-size: 16px; font-weight: 600; }
.empty-sub { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

/* ---------- Admin ---------- */
.stack { display: grid; gap: 8px; }
.person-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.person-name { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.person-sub { margin: 0; color: var(--faint); font-size: 12px; }
.detail-card { max-width: 520px; padding: 22px; }
.person-email { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.detail-card .note { text-align: left; margin-top: 4px; }
.detail-actions { display: flex; gap: 8px; margin-top: 20px; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .app { padding-left: 16px; padding-right: 16px; }
  /* backdrop-filter would trap the fixed tab bar inside the header */
  .bar {
    margin-left: -16px; margin-right: -16px; padding: 0 16px;
    background: var(--bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  main { padding-top: 16px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }

  .page-head { align-items: center; margin-bottom: 16px; }
  .page-head .lead { display: none; }

  .nav-tabs {
    position: fixed;
    z-index: 20;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    padding: 5px;
    border-radius: 16px;
    background: rgba(19, 20, 23, 0.94);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line);
  }
  .nav-tabs button { height: 44px; }
  .notif-panel { position: fixed; top: 70px; left: 12px; right: 12px; width: auto; }

  .file { min-height: 220px; }
  .compare-grid { grid-template-columns: 1fr; }
  .result-bar { flex-direction: column; align-items: stretch; }
  .choices .btn { flex: 1; }
  .resume { flex-direction: column; align-items: stretch; }
  .resume-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .bell.is-glowing, .bell.is-glowing svg, .bell.is-busy::after,
  .spinner, .tray-dot, .meter-fill::after, .steps li.is-active .step-dot,
  .draw[data-state="working"] .stage-frame::after { animation: none; }
  .meter-fill, #tray-fill { transition: none; }
}
