/* Cricket Overlay SaaS shell — "Sunny Pitch": a warm, cheerful, subtle light theme.
   No framework, no build step — plain CSS custom properties + a handful of classes
   shared by the vanilla-JS step modules. */

:root {
  --ink: #3a3226;
  --panel: #ffffff;
  --panel-2: #fdf7ea;
  --page-bg: #fff8ec;
  --line: #f3e4c8;
  --line-strong: #ebdbb8;
  --line-soft: #e9dcc2;
  --muted: #9c8f78;
  --muted-2: #8a7f6c;
  --muted-3: #b3a78d;
  --accent: #6fae8b;
  --accent-hover: #5b9a78;
  --accent-text: #4e8f6e;
  --signal: #f2b84b;
  --signal-soft: #fbefd6;
  --signal-text: #8a6a1e;
  --signal-mono: #c98e1e;
  --credit: #6fae8b;
  --danger: #e4695a;
  --secondary-text: #8a7561;
  --track-bg: #f4ead3;
  --radius-sm: 12px;
  --radius-md: 14px;
  --radius: 20px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --font-display: "Baloo 2", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", Consolas, monospace;

  --accent-rgb: 111, 174, 139;
  --signal-rgb: 242, 184, 75;
  --signal-mono-rgb: 201, 142, 30;
  --danger-rgb: 228, 105, 90;

  --shadow-card: 0 20px 40px -26px rgba(58, 50, 38, 0.22);
  --shadow-header: 0 16px 32px -24px rgba(58, 50, 38, 0.2);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font: 16px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(var(--accent-rgb), 0.35); }

/* --- header + step-rail --------------------------------------------------- */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 22px;
  margin: 1rem auto 0;
  max-width: 1040px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-header);
}
.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.account {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-size: 0.88rem;
  flex-wrap: wrap;
  row-gap: 0.5rem;
}
.account .email { color: var(--muted); }
.account .balance {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 0.3rem 0.75rem;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--signal-soft);
  color: var(--signal-text);
  white-space: nowrap;
  transition: filter 0.15s ease;
}
.account .balance:hover { filter: brightness(0.96); }

.step-rail {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.step-rail-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  padding: 0.25rem 0.1rem;
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--muted-3);
  cursor: default;
}
.step-rail-item.is-link { cursor: pointer; }
.step-rail-item.is-link:hover .step-rail-label { color: var(--ink); }
.step-rail-node {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--line-soft);
  flex-shrink: 0;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.step-rail-item.done .step-rail-node { background: var(--accent); }
.step-rail-item.done .step-rail-label { color: var(--accent-text); font-weight: 600; }
.step-rail-item.current .step-rail-node {
  background: var(--signal);
  box-shadow: 0 0 0 3px rgba(var(--signal-rgb), 0.25);
}
.step-rail-item.current .step-rail-label { color: var(--signal-text); font-weight: 600; }
.step-rail-label { display: none; }
.step-rail-chevron { color: var(--line-soft); font-size: 0.7rem; }
@media (min-width: 760px) {
  .step-rail-label { display: inline; }
}

/* --- layout ---------------------------------------------------------------- */
#app {
  max-width: 560px;
  margin: 2.5rem auto;
  padding: 0 1.25rem;
}
#app.wide { max-width: 860px; }

.step-head { margin-bottom: 1.25rem; }
.step-num {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--signal);
  font-weight: 600;
}
.step-head h2 {
  margin: 0.3rem 0 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.65rem;
  letter-spacing: -0.01em;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}
.card.notice p { color: var(--muted); }
.card h2 { margin-top: 0; font-family: var(--font-display); }
.card h3 { font-family: var(--font-display); font-weight: 700; }

/* Step transition — cross-fade + a small rise, one orchestrated moment. */
#app > * { animation: step-in 0.22s ease-out; }
@keyframes step-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- forms ------------------------------------------------------------------ */
form { display: flex; flex-direction: column; gap: 0.9rem; }
label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
input {
  padding: 0.65rem 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus { outline: none; border-color: var(--accent); }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* --- buttons ----------------------------------------------------------------- */
button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  padding: 0.65rem 1.05rem;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
button.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:hover:not([disabled]) { background: var(--accent-hover); }
/* .cta-14 marks the two sign-in/step-1 primary buttons the design calls out at a
   fixed 14px radius rather than a full pill — everywhere else button.primary
   stays pill-shaped (the default above). */
button.primary.cta-14 { border-radius: var(--radius-md); }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
button.secondary {
  background: var(--panel-2);
  color: var(--secondary-text);
  border-color: var(--line-strong);
}
button.secondary:hover { border-color: var(--muted); }
button.google {
  background: #fff;
  color: #1a1a1a;
  font-weight: 700;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
}
button.google:hover { background: #f6f2e8; }
button.link {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 500;
  padding: 0.3rem 0.1rem;
  position: relative;
}
button.link::after {
  content: "";
  position: absolute;
  left: 0.1rem; right: 0.1rem; bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.18s ease;
}
button.link:hover { color: var(--ink); }
button.link:hover::after { transform: scaleX(1); }

/* --- sign-in ------------------------------------------------------------ */
.signin-wrap {
  background: var(--page-bg);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 1.75rem;
  box-shadow: 0 24px 48px -28px rgba(58, 50, 38, 0.28);
}
.card.signin {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.625rem;
  box-shadow: none;
  display: flex; flex-direction: column; gap: 1rem;
}
.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted-3);
  font-size: 0.8rem;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.toggle { font-size: 0.85rem; color: var(--muted); margin: 0; }
.toggle a { color: var(--accent-text); }

.error {
  color: var(--danger);
  font-size: 0.88rem;
  margin: 0;
}

/* --- gate (step 2) ------------------------------------------------------ */
.card.gate {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.card.gate h3 { margin: 0; }
.gate-msg { margin: 0; color: var(--muted-2); }
.card.gate .hint { text-align: center; }
.card.gate button { margin-top: 0.5rem; }

.spin { color: var(--signal); }
.spinner { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-good, .icon-bad {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 700;
}
.icon-good { background: rgba(var(--accent-rgb), 0.15); color: var(--accent-text); }
.icon-bad { background: rgba(var(--danger-rgb), 0.15); color: var(--danger); }

code {
  background: var(--panel-2);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.actions { display: flex; gap: 0.75rem; margin-top: 1rem; }

/* --- step 3: sync preview ------------------------------------------------ */
.inn-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.inn-tab {
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-weight: 600;
  position: relative;
}
.inn-tab.active { background: var(--signal-soft); color: var(--signal-text); border-color: var(--signal-soft); }
.inn-tab.has-video::after {
  content: "✓";
  margin-left: 0.4rem;
  color: var(--credit);
  font-weight: 700;
}

.preview { display: flex; flex-direction: column; gap: 0.75rem; }
.pv-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.pv-video { width: 100%; height: 100%; display: block; object-fit: contain; }
.pv-video:not(.loaded) { display: none; }
.pv-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.pv-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.5rem; color: var(--muted); font-size: 0.85rem;
}
.pv-ph-icon { opacity: 0.6; }
.pv-ph-icon svg { width: 32px; height: 32px; }

.pv-transport {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius-md); padding: 0.625rem 1rem;
}
.pv-btn {
  background: var(--accent); color: #fff; border: none;
  width: 34px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.pv-seek {
  flex: 1; appearance: none; -webkit-appearance: none;
  height: 6px; background: var(--line-strong); border-radius: 3px; outline: none;
}
.pv-seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
}
.pv-seek::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
}
.pv-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem; min-width: 120px; text-align: center;
}
.pv-cur { color: var(--signal-mono); font-weight: 700; }
.pv-dur { color: var(--muted-3); }
.pv-use {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line-strong); font-size: 0.78rem; padding: 0.4rem 0.6rem;
}
.pv-use:hover { color: var(--signal-text); border-color: var(--signal); }

/* First-ball sync — a hairline-divided readout row: the scrub-derived playhead
   value and the manual numeric field are co-equal, not primary/secondary. */
.pv-bar { display: flex; flex-direction: column; gap: 0.6rem; }
.pv-syncrow {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.9rem;
  padding: 0.75rem 1rem;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
}
.pv-synclabel { color: var(--muted); font-size: 0.85rem; }
.pv-syncval {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 1.0625rem;
  color: var(--signal-mono);
  border-radius: 6px;
  padding: 0.1rem 0.3rem;
  transition: background 0.15s ease;
}
.pv-syncval.lock-pulse { animation: lock-pulse 0.18s ease-out; }
@keyframes lock-pulse {
  0% { background: rgba(var(--signal-mono-rgb), 0); }
  40% { background: rgba(var(--signal-mono-rgb), 0.3); }
  100% { background: rgba(var(--signal-mono-rgb), 0); }
}

.pv-syncdivider {
  width: 1px; align-self: stretch;
  background: var(--line-strong);
}

/* Manual sync entry — an equally-weighted numeric field + apply button, not a
   subordinate side control. */
.pv-syncentry { display: inline-flex; align-items: center; gap: 0.5rem; }
.pv-syncentry-label { color: var(--muted); font-size: 0.85rem; }
.pv-syncinput {
  width: 6em; padding: 0.35rem 0.6rem; font-size: 0.95rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums; text-align: center;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 8px; color: var(--ink);
}
.pv-syncinput:focus { outline: none; border-color: var(--signal); }
.pv-syncinput.invalid { border-color: var(--danger); }
.pv-syncset {
  padding: 0.35rem 0.7rem; font-size: 0.85rem; cursor: pointer;
  background: var(--panel); color: var(--accent-text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
}
.pv-syncset:hover { border-color: var(--accent); color: var(--accent-hover); }
.pv-synchint { flex-basis: 100%; margin: 0; }

.consent {
  display: flex; flex-direction: row; align-items: center; gap: 0.5rem;
  margin-top: 1rem; color: var(--ink); font-size: 0.88rem;
}
.consent input { width: auto; }

/* --- step 4: packs ------------------------------------------------------ */
.packs { display: flex; gap: 0.9rem; flex-wrap: wrap; margin: 1rem 0; }
.pack {
  flex: 1; min-width: 160px;
  position: relative;
  display: flex; flex-direction: column; gap: 0.3rem; align-items: flex-start;
  background: var(--panel-2); border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 1.25rem;
  text-align: left;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.pack:hover:not([disabled]) {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card), 0 16px 28px -16px rgba(var(--accent-rgb), 0.35);
}
/* .featured marks the recommended tier (set via JS on the middle pack) — the
   one deliberate accent moment on this screen: a solid pale-gold card + badge,
   kept to a single tier so it reads as guidance, not decoration everywhere. */
.pack.featured { background: var(--signal-soft); border: 1.5px solid var(--signal); }
.pack.featured:hover {
  border-color: var(--signal);
  box-shadow: var(--shadow-card), 0 16px 28px -16px rgba(var(--signal-rgb), 0.35);
}
.pack-badge {
  position: absolute; top: -11px; left: 20px;
  background: var(--signal); color: #fff;
  text-transform: uppercase;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 0.19rem 0.625rem; border-radius: var(--radius-pill);
}
.pack-credits { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; }
.pack-label { color: var(--muted); font-size: 0.82rem; }
.pack-price { font-family: var(--font-mono); font-size: 0.94rem; color: var(--accent-text); font-weight: 700; margin-top: 0.3rem; }

/* --- step 5: upload progress ------------------------------------------- */
.up-row { margin-bottom: 1rem; }
.up-head { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 0.35rem; }
.up-pct { font-family: var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.up-status { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 0.35rem; font-family: var(--font-mono); }
.progress-track { height: 10px; background: var(--track-bg); border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 5px; transition: width 0.2s; }

/* --- step 6: jobs ------------------------------------------------------- */
.job-row { padding: 1rem 0; border-top: 1px solid var(--line); }
.job-row:first-of-type { border-top: none; }
.job-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 0.75rem; }
.job-status { color: var(--muted); font-weight: 500; }
.job-status.rendering { color: var(--signal-mono); }
.job-body {
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
  color: var(--accent);
}
a.download {
  text-decoration: none; text-align: center;
  padding: 0.65rem 1rem; border-radius: var(--radius-pill);
  background: var(--accent); color: #fff; font-weight: 600;
}
a.download:hover { background: var(--accent-hover); }

/* --- toast (cross-cutting errors/notices) ------------------------------- */
.toast {
  position: fixed; top: -100px; left: 50%; transform: translateX(-50%);
  max-width: min(90vw, 520px); z-index: 1000;
  padding: 0.75rem 1.1rem; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--ink);
  box-shadow: var(--shadow-card);
  opacity: 0; transition: top 0.25s ease, opacity 0.25s ease;
}
.toast.show { top: 1rem; opacity: 1; }
.toast.error { border-color: var(--danger); }
.toast.ok { border-color: var(--credit); }

/* My Matches (account render history) */
.matches-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem;
}
.matches-head h2 { margin: 0; font-family: var(--font-display); }
.matches-list { display: flex; flex-direction: column; gap: 0.75rem; }
.match-item {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-2); padding: 0.75rem 1rem;
}
.match-item-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.match-item .match-id { font-weight: 600; }
.match-item .match-when { margin: 0.15rem 0 0.5rem; font-size: 0.8rem; }
.match-item .badge {
  padding: 0.15rem 0.55rem; border: 1px solid var(--line-strong);
  border-radius: 999px; font-size: 0.8rem; color: var(--muted);
  white-space: nowrap;
}
.inn-list { display: flex; flex-direction: column; gap: 0.35rem; }
.inn-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; padding: 0.3rem 0; border-top: 1px solid var(--line);
}
.inn-row:first-child { border-top: none; }

/* --- Credit history ------------------------------------------------------ */
.credits-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem;
}
.credits-head h2 { margin: 0; font-family: var(--font-display); }
.credits-head-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.credits-list { display: flex; flex-direction: column; }
.credit-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
}
.credit-row:first-child { border-top: none; }
.credit-row.head {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 0.5rem;
}
.credit-date {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.credit-type { color: var(--ink); }
.credit-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
}
.credit-amount.positive { color: var(--credit); }
.credit-amount.negative { color: var(--muted); }
.credit-ref {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- edit videos (free, local tool) -------------------------------------- */
.ve-head { margin-bottom: 1rem; }
.ve-head h2 { margin: 0 0 0.3rem; font-family: var(--font-display); }
.ve-mode-toggle { margin-bottom: 1.25rem; }
.ve-file-list { display: flex; flex-direction: column; margin: 0.75rem 0; }
.ve-file-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.75rem; padding: 0.5rem 0; border-top: 1px solid var(--line);
  font-size: 0.88rem;
}
.ve-file-row:first-child { border-top: none; }
.ve-file-row.ve-file-row-error .ve-file-meta { color: var(--danger); }
.ve-file-name { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ve-file-meta { color: var(--muted); font-family: var(--font-mono); font-size: 0.82rem; text-align: right; flex-shrink: 0; }
.ve-audio-note { margin: 0.4rem 0; }
.ve-time-row { display: flex; gap: 1.5rem; margin: 1rem 0; flex-wrap: wrap; }
.ve-time-row label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--muted); }
.ve-time-input {
  font-family: var(--font-mono); font-size: 0.9rem; padding: 0.4rem 0.6rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink); width: 8rem;
}
.ve-time-input:focus { outline: none; border-color: var(--signal); }
.ve-progress { margin-top: 1rem; }
