/* =======================================================================
   REM Labs — Marketing Polish Pass
   Unified typography, spacing, interaction, and depth across marketing.
   Does NOT affect app pages (console, dream-studio, coma, morning, account,
   playground, memory-explorer) which opt out with `body.app` or inline overrides.
   ======================================================================= */

:root {
  --sec-y: clamp(56px, 10vw, 96px);
  --sec-head-mb: clamp(32px, 5vw, 56px);
  --card-pad: clamp(20px, 3vw, 28px);
  --card-gap: 18px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.18s;
  --grad-accent: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --grad-accent-soft: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(139,92,246,0.06) 50%, rgba(168,85,247,0.05) 100%);
  --shadow-sm: 0 1px 2px rgba(15,15,30,0.04), 0 1px 3px rgba(15,15,30,0.06);
  --shadow-md: 0 4px 12px rgba(15,15,30,0.06), 0 1px 3px rgba(15,15,30,0.05);
  --shadow-lg: 0 12px 40px rgba(15,15,30,0.08), 0 2px 8px rgba(15,15,30,0.04);
  --shadow-xl: 0 24px 64px rgba(15,15,30,0.1), 0 4px 16px rgba(15,15,30,0.06);
  --shadow-accent: 0 8px 32px rgba(99,102,241,0.2), 0 2px 8px rgba(99,102,241,0.12);
}

[data-theme="dark"] {
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35), 0 1px 3px rgba(0,0,0,0.25);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
  --shadow-xl: 0 24px 64px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.35);
  --shadow-accent: 0 8px 32px rgba(129,140,248,0.28), 0 2px 8px rgba(129,140,248,0.18);
}

/* ---------- Skip-link (a11y) ---------- */
.skip-link {
  position: absolute;
  top: -60px;
  left: 8px;
  z-index: 10000;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--accent, #6366f1);
  color: #fff;
  font-family: var(--font, system-ui, sans-serif);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.2));
  transition: top 0.18s var(--ease, cubic-bezier(0.4,0,0.2,1));
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 8px;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---------- Scroll behavior ---------- */
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h, 52px) + 16px);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- Numeric polish ---------- */
.tabular, .mono, code, pre, .section-eyebrow, .bench-bar-fill, .price, .price-num {
  font-variant-numeric: tabular-nums;
}

/* ---------- Typography rhythm (marketing only — not .app-shell) ---------- */
body:not(.app) h1,
body:not(.app) .hero h1 {
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-wrap: balance;
}

body:not(.app) .section-h2,
body:not(.app) h2.section-h2 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  text-wrap: balance;
}

body:not(.app) h3 {
  letter-spacing: -0.01em;
  line-height: 1.3;
}

body:not(.app) .section-eyebrow {
  display: inline-block;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
  font-variant-numeric: tabular-nums;
}

body:not(.app) .section-sub {
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--text2);
}

/* Mono detail labels */
body:not(.app) .mono-label,
body:not(.app) .kbd,
body:not(.app) .hiw-step-label {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

/* ---------- Spacing rhythm ---------- */
body:not(.app) .section {
  padding: var(--sec-y) 28px;
}
@media (max-width: 720px) {
  body:not(.app) .section { padding: var(--sec-y) 20px; }
}

body:not(.app) .section-head {
  margin-bottom: var(--sec-head-mb);
}

/* ---------- Buttons & interaction timing ---------- */
body:not(.app) a,
body:not(.app) button,
body:not(.app) .btn,
body:not(.app) .btn-primary,
body:not(.app) .btn-ghost,
body:not(.app) .nav-link,
body:not(.app) .nav-signin,
body:not(.app) .nav-cta {
  transition: color var(--dur) var(--ease),
              background var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              opacity var(--dur) var(--ease);
}

body:not(.app) .btn-primary:hover,
body:not(.app) .nav-cta:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
body:not(.app) .btn-primary:active,
body:not(.app) .nav-cta:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

body:not(.app) .btn-ghost:hover {
  transform: translateY(-1px);
}

/* Focus rings — every interactive element */
body:not(.app) a:focus-visible,
body:not(.app) button:focus-visible,
body:not(.app) .btn-primary:focus-visible,
body:not(.app) .btn-ghost:focus-visible,
body:not(.app) .nav-link:focus-visible,
body:not(.app) .nav-cta:focus-visible,
body:not(.app) input:focus-visible,
body:not(.app) textarea:focus-visible,
body:not(.app) select:focus-visible,
body:not(.app) [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- Card unification (marketing only) ---------- */
body:not(.app) .diff-card:hover,
body:not(.app) .uc-card:hover,
body:not(.app) .not-card:hover,
body:not(.app) .feat-card:hover,
body:not(.app) .int-card:hover,
body:not(.app) .pricing-card:hover,
body:not(.app) .card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-border, rgba(99,102,241,0.2));
  box-shadow: var(--shadow-lg);
}
body:not(.app) .diff-card,
body:not(.app) .uc-card,
body:not(.app) .not-card,
body:not(.app) .feat-card,
body:not(.app) .int-card,
body:not(.app) .pricing-card,
body:not(.app) .card {
  transition: transform var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}

/* ---------- Code block refinement ---------- */
body:not(.app) pre:not(.hero-snippet):not(.code-block pre) {
  background: #0d0d1a;
  color: rgba(255,255,255,0.88);
  border-radius: 12px;
  padding: 20px 22px;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 0.82rem;
  line-height: 1.7;
  overflow-x: auto;
  font-variant-numeric: tabular-nums;
}
body:not(.app) .code-block {
  background: #0d0d1a !important;
}

/* ---------- Nav scroll blur enhancement ---------- */
body:not(.app) .nav.scrolled {
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  box-shadow: 0 1px 0 var(--border), 0 6px 24px rgba(15,15,30,0.04);
}
[data-theme="dark"] body:not(.app) .nav.scrolled {
  box-shadow: 0 1px 0 var(--border), 0 6px 24px rgba(0,0,0,0.4);
}

/* ---------- Hero accent glow (top-right subtle) ---------- */
body:not(.app) .hero::before {
  content: '';
  position: absolute;
  top: -20%;
  right: -10%;
  width: 60%;
  height: 80%;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse at center, rgba(139,92,246,0.14), rgba(99,102,241,0.06) 40%, transparent 70%);
  filter: blur(40px);
  opacity: 0.6;
}
[data-theme="dark"] body:not(.app) .hero::before {
  background: radial-gradient(ellipse at center, rgba(139,92,246,0.22), rgba(99,102,241,0.1) 40%, transparent 70%);
  opacity: 0.9;
}
@media (prefers-reduced-motion: reduce) {
  body:not(.app) .hero::before { opacity: 0.3; }
}

/* ---------- Reveal animation (refined) ---------- */
@media (prefers-reduced-motion: no-preference) {
  body:not(.app) .reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
    will-change: opacity, transform;
  }
  body:not(.app) .reveal.visible {
    opacity: 1;
    transform: translateY(0);
  }
  body:not(.app) .reveal.visible {
    will-change: auto;
  }
  body:not(.app) .d1 { transition-delay: 0.1s; }
  body:not(.app) .d2 { transition-delay: 0.2s; }
  body:not(.app) .d3 { transition-delay: 0.3s; }
  body:not(.app) .d4 { transition-delay: 0.4s; }
}
@media (prefers-reduced-motion: reduce) {
  body:not(.app) .reveal { opacity: 1 !important; transform: none !important; }
}

/* ---------- Page-load progress bar ---------- */
#rem-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--grad-accent);
  z-index: 999;
  box-shadow: 0 0 8px rgba(99,102,241,0.4);
  transition: width 0.24s var(--ease-out), opacity 0.4s var(--ease);
  pointer-events: none;
}
#rem-progress.done { opacity: 0; }

/* ---------- Icon unification ---------- */
body:not(.app) svg.icon-16 { width: 16px; height: 16px; }
body:not(.app) svg.icon-20 { width: 20px; height: 20px; }
body:not(.app) svg.icon-24 { width: 24px; height: 24px; }

/* ---------- Microtypography ---------- */
body:not(.app) {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body:not(.app) h1, body:not(.app) h2, body:not(.app) h3 {
  text-wrap: balance;
}
body:not(.app) p {
  text-wrap: pretty;
}

/* Dark mode border opacity unification */
[data-theme="dark"] body:not(.app) .diff-card,
[data-theme="dark"] body:not(.app) .uc-card,
[data-theme="dark"] body:not(.app) .not-card,
[data-theme="dark"] body:not(.app) .feat-card,
[data-theme="dark"] body:not(.app) .int-card,
[data-theme="dark"] body:not(.app) .pricing-card,
[data-theme="dark"] body:not(.app) .card {
  border-color: var(--border);
}

/* Hanging punctuation where supported */
body:not(.app) blockquote,
body:not(.app) .hero-sub,
body:not(.app) .section-sub {
  hanging-punctuation: first;
}

/* ---------- Gradient section depth accents ---------- */
body:not(.app) .section-dark,
body:not(.app) .cta-band,
body:not(.app) .demo-section {
  position: relative;
}
body:not(.app) .cta-band::after,
body:not(.app) .demo-section::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    135deg,
    rgba(255,255,255,0.005) 0,
    rgba(255,255,255,0.005) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.5;
}

/* Button hover elevation unified */
body:not(.app) a.btn-primary,
body:not(.app) button.btn-primary {
  will-change: transform;
}

/* Sticky scroll-triggered CTA (global, marketing pages only) */
.sticky-cta {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.sticky-cta.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.sticky-cta:hover { filter: brightness(1.1); }
@media (max-width: 720px) {
  .sticky-cta { bottom: 16px; right: 16px; padding: 10px 16px; font-size: 13px; }
}
body.app .sticky-cta { display: none; }

/* ---------- Search modal (search.js) ---------- */
.rem-search-modal {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  padding-left: 16px;
  padding-right: 16px;
}
.rem-search-modal.hidden { display: none; }
.rem-search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.rem-search-panel {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 640px;
  max-width: 92vw;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
[data-theme="dark"] .rem-search-panel {
  background: #12121a;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.6);
}
.rem-search-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 16px;
  background: transparent;
  color: var(--text);
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
  font-family: inherit;
}
.rem-search-input::placeholder { color: var(--text3); }
.rem-search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  max-height: calc(60vh - 108px);
}
.rem-search-item {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s ease;
}
.rem-search-item.sel,
.rem-search-item:hover { background: var(--bg2); }
.rem-search-title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.94rem;
}
.rem-search-desc {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
  line-height: 1.4;
}
.rem-search-meta {
  font-family: var(--mono, monospace);
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}
.rem-search-empty {
  padding: 28px 20px;
  text-align: center;
  color: var(--text3);
  font-size: 0.88rem;
  list-style: none;
}
.rem-search-hint {
  padding: 8px 20px;
  font-size: 11px;
  color: var(--text3);
  border-top: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.rem-search-hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  padding: 1px 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono, monospace);
  font-size: 10px;
  color: var(--text2);
}
body.rem-search-open { overflow: hidden; }
@media (max-width: 720px) {
  .rem-search-modal { padding-top: 6vh; }
  .rem-search-panel { max-height: 80vh; }
  .rem-search-results { max-height: calc(80vh - 108px); }
}

/* =====================================================================
   INTERACTION POLISH PASS — 2026-04-25
   Skeletons, button-loading, error states, hover/focus, page transitions,
   form validation, brain-mark hover-pause. Apple/Linear-tier micro-interactions.

   These rules apply to BOTH marketing and app pages (no `body:not(.app)`
   guard) unless explicitly noted. All animations are wrapped in
   `prefers-reduced-motion: no-preference` or have a reduced-motion override.
   ===================================================================== */

/* ---------- 1. CANONICAL FOCUS RING ----------
   Single source of truth. Uses --accent (indigo) per palette spec. */
:focus-visible {
  outline: 2px solid var(--accent, #6366f1);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent, #6366f1);
  outline-offset: 2px;
}
/* Strip default mouse-click ring; only show for keyboard nav */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible) { outline: none; }

/* ---------- 2. SKELETON LOADERS ----------
   Replace "Loading..." text with these. Example markup:
   <div class="rem-skel rem-skel-line" style="width:60%"></div>
   <div class="rem-skel rem-skel-card"><div class="rem-skel-line"></div>...</div> */
.rem-skel,
.rem-skel-line,
.rem-skel-block,
.rem-skel-card {
  background: linear-gradient(
    90deg,
    rgba(0,0,0,0.04) 0%,
    rgba(0,0,0,0.08) 40%,
    rgba(0,0,0,0.04) 80%
  );
  background-size: 200% 100%;
  border-radius: 6px;
  animation: skeleton-pulse 1.6s ease-in-out infinite;
  will-change: background-position;
}
[data-theme="dark"] .rem-skel,
[data-theme="dark"] .rem-skel-line,
[data-theme="dark"] .rem-skel-block,
[data-theme="dark"] .rem-skel-card {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.10) 40%,
    rgba(255,255,255,0.04) 80%
  );
  background-size: 200% 100%;
}
.rem-skel-line { height: 14px; border-radius: 7px; margin: 6px 0; }
.rem-skel-line.tall { height: 22px; border-radius: 8px; }
.rem-skel-line.short { width: 40%; }
.rem-skel-line.med { width: 65%; }
.rem-skel-block { height: 80px; border-radius: 12px; }
.rem-skel-card {
  border: 1px solid var(--border, rgba(0,0,0,0.07));
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg, #fff);
  /* The card itself doesn't pulse — its inner lines do */
  animation: none;
}
.rem-skel-card .rem-skel-line { animation: skeleton-pulse 1.6s ease-in-out infinite; }
.rem-skel-card .rem-skel-line:nth-child(2) { animation-delay: 0.1s; }
.rem-skel-card .rem-skel-line:nth-child(3) { animation-delay: 0.2s; }
.rem-skel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .rem-skel-grid { grid-template-columns: 1fr; } }

@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .rem-skel,
  .rem-skel-line,
  .rem-skel-block,
  .rem-skel-card .rem-skel-line {
    animation: none;
    background: rgba(0,0,0,0.05);
  }
  [data-theme="dark"] .rem-skel,
  [data-theme="dark"] .rem-skel-line,
  [data-theme="dark"] .rem-skel-block,
  [data-theme="dark"] .rem-skel-card .rem-skel-line {
    background: rgba(255,255,255,0.06);
  }
}

/* ---------- 3. BUTTON LOADING STATE ----------
   Add `.is-loading` class (or `[data-loading="true"]`) to any button.
   Spinner replaces icon, button is disabled visually. JS in interactions.js
   handles disable + restore on click for `[data-rem-loading]` buttons. */
.btn-loading-spinner,
.rem-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  margin-right: 6px;
  animation: rem-spin 0.7s linear infinite;
  flex-shrink: 0;
}
.rem-spinner.lg { width: 18px; height: 18px; border-width: 2.5px; }
.rem-spinner.indigo { color: var(--accent, #6366f1); }

@keyframes rem-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn-loading-spinner,
  .rem-spinner { animation-duration: 1.6s; }
}

/* `is-loading` works on any button — replaces label with spinner +
   "Working…" text, locks width, prevents clicks. */
button.is-loading,
.btn.is-loading,
.btn-primary.is-loading,
.btn-accent.is-loading,
.btn-ghost.is-loading,
[data-loading="true"] {
  position: relative;
  pointer-events: none;
  cursor: progress !important;
  color: transparent !important;
  text-shadow: none !important;
}
button.is-loading::after,
.btn.is-loading::after,
.btn-primary.is-loading::after,
.btn-accent.is-loading::after,
.btn-ghost.is-loading::after,
[data-loading="true"]::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: inherit;
  opacity: 0.85;
  animation: rem-spin 0.7s linear infinite;
}
/* Restore visible color for the spinner ring (color: transparent on the
   button hides the text but currentColor for ::after needs a real value) */
.btn-primary.is-loading::after,
.btn-accent.is-loading::after,
.nav-cta.is-loading::after { color: #fff; }
.btn-ghost.is-loading::after { color: var(--text, #1d1d1f); }

@media (prefers-reduced-motion: reduce) {
  button.is-loading::after,
  .btn.is-loading::after,
  .btn-primary.is-loading::after,
  .btn-accent.is-loading::after,
  .btn-ghost.is-loading::after,
  [data-loading="true"]::after { animation-duration: 1.6s; }
}

/* ---------- 4. ERROR STATES ----------
   Replace generic "Error" with structured callouts. Markup:
   <div class="rem-error" role="alert">
     <span class="rem-error-icon">!</span>
     <div class="rem-error-body">
       <strong>Couldn't reach the server.</strong>
       <p>Check your connection and try again.</p>
     </div>
     <button class="rem-error-retry">Retry</button>
   </div> */
.rem-error,
.rem-error-inline {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  /* Coral, not alarming red — 20% saturation feel */
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.18);
  color: var(--text, #1d1d1f);
  font-size: 0.9rem;
  line-height: 1.5;
}
[data-theme="dark"] .rem-error,
[data-theme="dark"] .rem-error-inline {
  background: rgba(239, 68, 68, 0.10);
  border-color: rgba(239, 68, 68, 0.25);
}
.rem-error-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
  font-family: var(--mono, monospace);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  margin-top: 1px;
}
.rem-error-body { flex: 1; min-width: 0; }
.rem-error-body strong {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 2px;
  color: var(--text, #1d1d1f);
}
.rem-error-body p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text2, #6e6e73);
  line-height: 1.5;
}
.rem-error-body .rem-error-fix {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--accent, #6366f1);
  font-weight: 500;
}
.rem-error-retry {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--bg, #fff);
  color: var(--text, #1d1d1f);
  border: 1px solid var(--border2, rgba(0,0,0,0.12));
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.rem-error-retry:hover {
  background: var(--bg2, #f8f8fa);
  border-color: var(--text2, #6e6e73);
}
.rem-error-retry:active { transform: scale(0.97); }

/* Compact inline error (single line, no retry) */
.rem-error-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 0.82rem;
  color: rgba(239, 68, 68, 0.95);
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.18);
  border-radius: 8px;
}

/* ---------- 5. HOVER STATE INTENT ----------
   Touch devices skip hover entirely (handled via @media). Marketing pages
   already have card lift via earlier section, but app pages don't — this
   adds card lift universally. */
@media (hover: hover) and (pointer: fine) {
  /* Text-link underline + indigo on inline links inside content blocks.
     Scoped to known content classes to avoid clobbering nav/CTAs. */
  .rem-prose a:not(.btn):not(.btn-primary):not(.btn-ghost):not(.btn-accent),
  .section-sub a:not(.btn-primary):not(.btn-ghost),
  p a:not(.btn):not(.btn-primary):not(.btn-ghost):not(.btn-accent):not(.nav-link) {
    color: var(--accent, #6366f1);
    transition: color 0.15s, text-decoration-color 0.15s;
  }
  .rem-prose a:hover,
  .section-sub a:hover,
  p a:not(.btn):not(.btn-primary):not(.btn-ghost):not(.btn-accent):not(.nav-link):hover {
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
  }
}
@media (hover: none) {
  /* On touch, kill all .card:hover translateY etc. so we don't get
     stuck-pressed states after a tap. */
  .card:hover,
  .surface-card:hover,
  .loop-card:hover,
  .vert-card:hover,
  .price-card:hover,
  .feat-card:hover,
  .pricing-card:hover {
    transform: none !important;
    box-shadow: none !important;
  }
}

/* ---------- 6. PAGE FADE-IN ----------
   Subtle 150ms cross-fade on every page load. Skip for users who prefer
   reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  body { animation: page-fade-in 160ms ease-out; }
  @keyframes page-fade-in {
    from { opacity: 0.92; }
    to   { opacity: 1; }
  }
}

/* ---------- 7. FORM VALIDATION ----------
   Markup:
   <label>
     Email
     <input type="email" required>
     <span class="form-msg"></span>
   </label>
   JS in interactions.js handles validation on blur, clears on input. */
.rem-field { position: relative; }
.rem-field input.is-invalid,
.rem-field textarea.is-invalid,
input.is-invalid,
textarea.is-invalid {
  border-color: rgba(239, 68, 68, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.10);
}
.rem-field input.is-valid,
input.is-valid {
  border-color: rgba(52, 199, 89, 0.45) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3 8.5l3 3 7-7' stroke='%2334c759' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 14px;
  padding-right: 36px !important;
}
.rem-field .form-msg,
.form-msg {
  display: block;
  min-height: 1.1em;
  font-size: 0.78rem;
  color: rgba(239, 68, 68, 0.95);
  margin-top: 4px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.15s, transform 0.15s;
}
.rem-field .form-msg.show,
.form-msg.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- 8. BRAIN-MARK HOVER PAUSE ----------
   Pause hero waveform on hover so user can read. */
@media (hover: hover) and (pointer: fine) {
  .rem-mark-hero:hover svg { animation-play-state: paused; }
}

/* ---------- 9. EMPTY STATE POLISH ----------
   Adds an icon glow to the canonical .empty class. Existing markup keeps
   working; this is purely additive. */
.empty,
.rem-empty {
  position: relative;
}
.empty .empty-cta,
.rem-empty .empty-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 10px;
  background: var(--accent, #6366f1);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.15s;
  margin-top: 12px;
}
.empty .empty-cta:hover,
.rem-empty .empty-cta:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* ---------- 10. UTILITY: SR-ONLY ----------
   Standard accessibility helper. Used by interactions.js to attach
   off-screen labels for live status updates. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ---------- 11. INPUT FOCUS POLISH ----------
   Ring on focus rather than just border-color shift, so focused state
   reads at a glance. */
input:focus,
textarea:focus,
select:focus {
  box-shadow: 0 0 0 3px var(--accent-bg, rgba(99,102,241,0.10));
}
input:focus.is-invalid,
textarea:focus.is-invalid {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

/* ---------- 12. CARD HOVER UNIFICATION (app pages) ----------
   App pages opted out of marketing card hover via `body:not(.app)`.
   Add subtle hover here for any element with `data-rem-hover-card`. */
[data-rem-hover-card] {
  transition: transform 0.18s var(--ease, cubic-bezier(0.4,0,0.2,1)),
              border-color 0.18s var(--ease, cubic-bezier(0.4,0,0.2,1)),
              box-shadow 0.18s var(--ease, cubic-bezier(0.4,0,0.2,1));
}
@media (hover: hover) and (pointer: fine) {
  [data-rem-hover-card]:hover {
    transform: translateY(-2px);
    border-color: var(--accent-border, rgba(99,102,241,0.2));
    box-shadow: 0 8px 24px rgba(99,102,241,0.08);
  }
}
@media (prefers-reduced-motion: reduce) {
  [data-rem-hover-card]:hover { transform: none !important; }
}

/* === Mobile code-block wrap (Fix 7 — kills horizontal scroll on /agent-hooks, /migrate, /api) === */
@media (max-width: 768px) {
  .code-body, pre code, pre.code-body, pre,
  .code-block pre, .code-block code {
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    word-break: break-all !important;
    overflow-x: hidden !important;
  }
}
