@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* Palette matched to pragmiq.com: navy ink on white/soft-blue-grey, deep royal-blue accent. */
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #ebeff5;
  --text: #11192c;
  --text-dim: #58626b;
  --border: #dde3ec;
  --accent: #0c2a8d;
  --accent-ink: #ffffff;
  --accent-dim: #e4e8f5;
  /* "Success/connected" reuses the brand blue rather than a separate green — pragmiq.com
     has no green in its palette, and the connected state is already conveyed by the border,
     checkmark and copy, not just hue. */
  --good: #0c2a8d;
  --good-bg: #e4e8f5;
  --warn: #a5590c;
  --warn-bg: #fbeee0;
  --blocked: #a5342b;
  --blocked-bg: #fbe9e7;
  --radius: 12px;
  --shadow-card: 0 1px 2px rgba(20, 30, 40, 0.04), 0 8px 24px -12px rgba(20, 30, 40, 0.10);
  --shadow-pop: 0 12px 40px -8px rgba(20, 30, 40, 0.28);
  --font-display: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Same navy pragmiq.com uses for its own dark CTA band, brightened royal-blue accent
       for contrast against it. */
    --bg: #11192c;
    --surface: #182238;
    --surface-2: #202c48;
    --text: #eef1f7;
    --text-dim: #93a0ba;
    --border: #2b3654;
    --accent: #5b74e6;
    --accent-ink: #ffffff;
    --accent-dim: #1c274a;
    --good: #5b74e6;
    --good-bg: #1c274a80;
    --warn: #e7a44f;
    --warn-bg: #3a2a1580;
    --blocked: #e8776a;
    --blocked-bg: #3a161380;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    --shadow-pop: 0 12px 40px -8px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --bg: #11192c;
  --surface: #182238;
  --surface-2: #202c48;
  --text: #eef1f7;
  --text-dim: #93a0ba;
  --border: #2b3654;
  --accent: #5b74e6;
  --accent-ink: #ffffff;
  --accent-dim: #1c274a;
  --good: #5b74e6;
  --good-bg: #1c274a80;
  --warn: #e7a44f;
  --warn-bg: #3a2a1580;
  --blocked: #e8776a;
  --blocked-bg: #3a161380;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 12px 40px -8px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand-group { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px; overflow: hidden; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand-tagline { color: var(--text-dim); font-size: 12px; font-family: var(--font-mono); }
.topbar-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface-2);
  border: none;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.topbar-badge--warning { background: var(--warn-bg); color: var(--warn); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-link {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.topbar-link:hover { color: var(--text); }

/* ---------- layout ---------- */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 36px 20px 100px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
main[hidden] { display: none; }

/* ---------- stepper ---------- */
.stepper {
  display: flex;
  align-items: center;
  padding: 4px 4px 8px;
}
.stepper-item { display: flex; align-items: center; gap: 9px; }
.stepper-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.stepper-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  transition: color 0.2s;
}
.stepper-item.active .stepper-dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stepper-item.active .stepper-label { color: var(--text); }
.stepper-item.complete .stepper-dot { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.stepper-item.complete .stepper-dot::after { content: "✓"; }
.stepper-item.complete .stepper-dot span { display: none; }
.stepper-line { flex: 1; height: 1px; background: var(--border); margin: 0 10px; min-width: 16px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: var(--shadow-card);
}

.card-head { display: flex; flex-direction: column; gap: 3px; margin-bottom: 18px; }
h2 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.hint { color: var(--text-dim); font-size: 13px; margin: 0; }
.warning[hidden] { display: none; }
.warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--warn);
  background: var(--warn-bg);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 12px;
}

/* ---------- platform grid ---------- */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.platform-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.platform-card .icon-badge { width: 36px; height: 36px; }
.platform-card .name { font-size: 13.5px; font-weight: 600; }
.platform-card .status {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  min-height: 14px;
}
.platform-card.connected {
  border-color: color-mix(in srgb, var(--good) 45%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--good) 20%, transparent);
}
.platform-card.connected .status { color: var(--good); font-weight: 600; }
.platform-card.coming-soon { opacity: 0.55; }
.platform-card.coming-soon .icon-badge { filter: grayscale(1); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  padding: 13px 22px;
  font-size: 14.5px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); color: var(--accent-ink); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
/* .btn-primary's explicit display:flex above has the same specificity as the browser's
   built-in [hidden] rule and comes later in the cascade, so it silently wins and the button
   stays visible even with the hidden attribute set — this project's recurring [hidden]-vs-
   explicit-display gotcha. The profile modal is the first place a .btn-primary gets toggled
   hidden/shown at runtime, which is what surfaced it. */
.btn-primary[hidden] { display: none; }
.btn-large { padding: 15px 22px; font-size: 15px; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  margin-bottom: 18px;
  padding: 20px;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--accent); background: var(--accent-dim); }
.dropzone-icon {
  width: 40px; height: 40px;
  margin: 0 auto 10px;
  color: var(--text-dim);
}
.dropzone p { margin: 4px 0; font-size: 14px; }
.dropzone .hint { margin-top: 2px; }
#video-preview { max-height: 360px; max-width: 210px; border-radius: 10px; background: #000; box-shadow: var(--shadow-pop); }

.field-label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 7px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; font-family: var(--font-mono); }
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  margin-bottom: 18px;
}
textarea:focus, .dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea:focus { border-color: var(--accent); }

/* ---------- captions grid ---------- */
.captions-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.caption-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--surface);
}
.caption-card .caption-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}
.caption-card .icon-badge { width: 20px; height: 20px; }
.caption-card .caption-title { font-size: 13.5px; font-weight: 600; flex: 1; }
.caption-card .char-count { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.caption-card .char-count.over { color: var(--blocked); font-weight: 600; }
.caption-card textarea { margin-bottom: 0; font-size: 13.5px; }

/* ---------- publish results ---------- */
.publish-results { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
}
.result-row .icon-badge { width: 22px; height: 22px; flex-shrink: 0; }
.result-row .name { font-weight: 600; min-width: 82px; }
.result-row .state { color: var(--text-dim); flex: 1; }
.result-row .result-icon { flex-shrink: 0; width: 16px; height: 16px; }
.result-row.success { border-color: color-mix(in srgb, var(--good) 35%, var(--border)); }
.result-row.success .state { color: var(--good); }
.result-row.failed { border-color: color-mix(in srgb, var(--blocked) 35%, var(--border)); }
.result-row.failed .state { color: var(--blocked); }
.result-row a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  white-space: nowrap;
}
.result-row a:hover { text-decoration: underline; }
.spinner {
  width: 15px; height: 15px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- oauth modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 16, 22, 0.5);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 44px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-pop);
}
.modal p { margin: 0; font-size: 14px; color: var(--text); max-width: 260px; }
.modal-spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .spinner, .modal-spinner { animation-duration: 1.6s; }
}

/* ---------- profile modal ---------- */
.profile-modal {
  position: relative;
  align-items: stretch;
  text-align: left;
  width: 100%;
  max-width: 340px;
  padding: 32px 28px 28px;
}
.profile-modal h2 { font-size: 17px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.005em; }
.profile-modal .hint { margin: 2px 0 18px; }
.profile-modal .btn { width: 100%; margin-top: 8px; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.profile-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.profile-field:last-of-type { border-bottom: none; }
.profile-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-dim);
}

/* ---------- sign-in / paywall gates ---------- */
.gate {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 40;
}
.gate[hidden] { display: none; }
.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.gate-card h1 { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.gate-card .hint { margin: 0; }
.gate-card #auth-form, .gate-card #auth-sent { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.gate-card #auth-form[hidden], .gate-card #auth-sent[hidden] { display: none; }
.gate-card input[type="email"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.gate-card input[type="email"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.gate-error {
  color: var(--blocked);
  background: var(--blocked-bg);
  border: 1px solid color-mix(in srgb, var(--blocked) 30%, transparent);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin: 0;
}
.gate-error[hidden] { display: none; }
