/* HiLooks — design system */

:root {
  /* Default = HOMEOWNER palette: cream paper, deep moss, warm amber */
  --bg:        #F4EFE6;   /* warm cream */
  --bg-1:      #EDE6D8;   /* slightly deeper paper */
  --bg-2:      #FFFCF6;   /* card surface */
  --bg-3:      #E5DCC8;
  --line:      rgba(36,46,38,0.10);
  --line-2:    rgba(36,46,38,0.18);
  --line-3:    rgba(36,46,38,0.30);

  --fg:        #1B2620;   /* deep ink/forest, never pure black */
  --fg-2:      rgba(27,38,32,0.78);
  --fg-3:      rgba(27,38,32,0.58);
  --fg-4:      rgba(27,38,32,0.42);

  --accent:    #2F5D43;   /* deep moss — calm, considered */
  --accent-2:  #3F7656;
  --accent-soft: rgba(47,93,67,0.10);
  --accent-glow: rgba(47,93,67,0.30);

  --warm:      #C97A3A;   /* hearth amber — the human accent */
  --warm-soft: rgba(201,122,58,0.12);

  --warn:      #B8651E;
  --danger:    #B23A2A;

  --serif: "Instrument Serif", "Times New Roman", serif;
  --sans:  "Geist", "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-2xl: 40px;

  --container: 1280px;
  --gutter: 32px;

  --tx-1: 11px;
  --tx-2: 13px;
  --tx-3: 15px;
  --tx-4: 18px;
  --tx-h: clamp(44px, 5.2vw, 76px);
  --tx-d: clamp(56px, 7vw, 104px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
html { scroll-behavior: smooth; }
body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(47,93,67,0.08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 20%, rgba(201,122,58,0.06), transparent 60%);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img, svg { display: block; max-width: 100%; }

h1,h2,h3,h4 { margin: 0; font-weight: 400; letter-spacing: -0.025em; }
p { margin: 0; }

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.02em; }
.mono  { font-family: var(--mono); font-feature-settings: "zero" on; }

/* === Type scale === */
.eyebrow {
  font-family: var(--mono);
  font-size: var(--tx-1);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: "";
  width: 18px; height: 1px;
  background: var(--accent);
  display: inline-block;
}

.h1-display {
  font-family: var(--serif);
  font-size: var(--tx-d);
  line-height: 0.94;
  letter-spacing: -0.04em;
  font-weight: 400;
}
.h2-display {
  font-family: var(--serif);
  font-size: var(--tx-h);
  line-height: 0.98;
  letter-spacing: -0.03em;
  font-weight: 400;
}

.lead {
  font-size: 18px;
  line-height: 1.55;
  color: var(--fg-2);
  max-width: 56ch;
  letter-spacing: -0.005em;
}

/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease, transform 200ms ease;
  white-space: nowrap;
}
.btn-primary {
  background: var(--fg);
  color: var(--bg-2);
}
.btn-primary:hover { background: var(--accent); color: #fff; }
.btn-accent {
  background: var(--accent);
  color: #FFFCF6;
}
.btn-accent:hover { background: var(--accent-2); }
.btn-warm {
  background: var(--warm);
  color: #FFFCF6;
}
.btn-warm:hover { filter: brightness(1.05); }
.btn-ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--line-2);
}
.btn-ghost:hover { border-color: var(--fg); }
.btn-sm { height: 36px; padding: 0 16px; font-size: 13px; }
.btn-lg { height: 52px; padding: 0 28px; font-size: 15px; }

.arrow { transition: transform 240ms ease; display: inline-block; }
.btn:hover .arrow { transform: translateX(3px); }

/* === Card / surface === */
.surface {
  background: linear-gradient(180deg, rgba(255,253,248,0.7), rgba(255,253,248,0.35));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.surface-2 {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 20px 60px rgba(27,38,32,0.06);
}
.glass {
  background: rgba(255,253,248,0.55);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--line-2);
}

/* === Chip === */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-2);
  background: rgba(255,253,248,0.7);
  border: 1px solid var(--line);
}
.chip .led {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  animation: led 2s ease-out infinite;
}
@keyframes led {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

/* === Tab toggle === */
.tab-group {
  display: inline-flex;
  padding: 4px;
  background: rgba(27,38,32,0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tab-group button {
  height: 32px;
  padding: 0 16px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--fg-3);
  font-size: 13px;
  font-weight: 500;
  transition: all 220ms ease;
}
.tab-group button.active {
  background: var(--fg);
  color: var(--bg-2);
}

/* === Header === */
.header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244,239,230,0.75);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}
.nav-links {
  display: flex; gap: 24px;
  font-size: 13px;
  color: var(--fg-3);
}
.nav-links a {
  transition: color 200ms;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--fg); }

/* === Logo === */
.logo {
  display: inline-flex; align-items: baseline; gap: 10px;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.logo-mark {
  width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  flex-shrink: 0;
  color: var(--accent);
  align-self: center;
  position: relative;
  transition: transform 600ms cubic-bezier(0.22,1,0.36,1);
}
.logo:hover .logo-mark { transform: translateY(-1px) rotate(-2deg); }
.logo-mark svg { width: 100%; height: 100%; display: block; }

/* Photo variant — feathered edges so it dissolves into the page background */
.logo-mark-photo {
  width: 40px; height: 40px;
  overflow: hidden;
}
.logo-mark-photo img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: 60% 55%;
  display: block;
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 60% 55%, #000 38%, rgba(0,0,0,0.85) 58%, transparent 92%);
          mask-image: radial-gradient(ellipse 50% 50% at 60% 55%, #000 38%, rgba(0,0,0,0.85) 58%, transparent 92%);
  filter: saturate(1.05) contrast(1.02);
}

/* Photo on homeowner, SVG on engineer */
.logo-mark-svg { display: none; }
body.eng-mode .logo-mark-photo { display: none; }
body.eng-mode .logo-mark-svg { display: inline-grid; }
.logo-word {
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--fg);
  line-height: 1;
}
.logo-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--fg-3);
  text-transform: uppercase;
  margin-left: 2px;
  align-self: baseline;
  position: relative;
  top: -4px;
}

/* === Hero glow === */
.hero-glow {
  position: absolute;
  inset: -40% 0 auto 0;
  height: 80vh;
  background:
    radial-gradient(ellipse 50% 60% at 50% 40%, rgba(47,93,67,0.18), transparent 60%),
    radial-gradient(ellipse 30% 40% at 70% 30%, rgba(201,122,58,0.12), transparent 60%);
  pointer-events: none;
  filter: blur(40px);
}

/* === Grid lines bg === */
.grid-bg {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(27,38,32,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(27,38,32,0.04) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse 60% 50% at 50% 50%, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 60% 50% at 50% 50%, black 30%, transparent 80%);
  pointer-events: none;
}

/* Reveal */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 700ms cubic-bezier(0.22,1,0.36,1), transform 700ms cubic-bezier(0.22,1,0.36,1);
}
.reveal.in { opacity: 1; transform: none; }

/* Scroll progress */
.scroll-progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 1px;
  background: var(--accent);
  transform-origin: left;
  z-index: 200;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Section spacing */
.section { padding: 120px 0; position: relative; }
.section-sm { padding: 80px 0; }
.section-lg { padding: 160px 0; }

/* Divider */
.divider { height: 1px; background: var(--line); }

/* Selection */
::selection { background: var(--accent); color: var(--bg); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--line-3); }

/* === ENGINEER mode override (cockpit / dark) === */
body.eng-mode {
  --bg:        #07090A;
  --bg-1:      #0B0E10;
  --bg-2:      #11151A;
  --bg-3:      #181D24;
  --line:      rgba(255,255,255,0.08);
  --line-2:    rgba(255,255,255,0.14);
  --line-3:    rgba(255,255,255,0.22);

  --fg:        #F5F7F8;
  --fg-2:      rgba(245,247,248,0.78);
  --fg-3:      rgba(245,247,248,0.55);
  --fg-4:      rgba(245,247,248,0.38);

  --accent:    #4ADE80;
  --accent-2:  #22C55E;
  --accent-soft: rgba(74,222,128,0.12);
  --accent-glow: rgba(74,222,128,0.55);

  --warn:      #F5A524;
  --danger:    #F75555;
}
body.eng-mode {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(74,222,128,0.08), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 20%, rgba(74,222,128,0.04), transparent 50%);
}
body.eng-mode .surface {
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.005));
}
body.eng-mode .surface-2 {
  background: var(--bg-2);
  box-shadow: none;
}
body.eng-mode .chip {
  background: rgba(255,255,255,0.04);
}
body.eng-mode .tab-group {
  background: rgba(255,255,255,0.04);
}
body.eng-mode .tab-group button.active {
  background: var(--fg);
  color: var(--bg);
}
body.eng-mode .header {
  background: rgba(7,9,10,0.65);
}
body.eng-mode .grid-bg {
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
}
body.eng-mode .hero-glow {
  background:
    radial-gradient(ellipse 50% 60% at 50% 40%, rgba(74,222,128,0.25), transparent 60%),
    radial-gradient(ellipse 30% 40% at 70% 30%, rgba(74,222,128,0.12), transparent 60%);
}
body.eng-mode .btn-primary { color: var(--bg); }
body.eng-mode .btn-accent { color: var(--bg); }

/* Utilities */
.row { display: flex; }
.col { display: flex; flex-direction: column; }
.between { justify-content: space-between; align-items: center; }
.center { align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; } .gap-32 { gap: 32px; }
.grid { display: grid; }

/* Numbered tile (Huly style features) */
.feat-tile {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 32px;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0));
  position: relative;
  overflow: hidden;
  transition: border-color 300ms ease, transform 300ms ease;
}
.feat-tile:hover { border-color: var(--line-2); transform: translateY(-2px); }
.feat-tile .feat-num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--fg-4);
}

/* Pulse ring */
.pulse-ring {
  position: absolute;
  border: 1px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  animation: pulsering 3s linear infinite;
}
@keyframes pulsering {
  0% { transform: scale(0.4); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Fan blades */
.fan { transform-origin: 50% 50%; animation: spinfan 1.5s linear infinite; }
@keyframes spinfan { to { transform: rotate(360deg); } }

/* Light theme override (engineer console actually stays dark — but homeowner has subtle warm wash) */
.warm-grain::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence baseFrequency='0.85' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.04;
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* Marquee */
.marquee { overflow: hidden; }
.marquee-track {
  display: flex; gap: 64px;
  animation: marq 50s linear infinite;
  white-space: nowrap;
  padding-right: 64px;
}
@keyframes marq { to { transform: translateX(-50%); } }

/* === Tabular figures — opt-in via .tnum or .mono === */
.tnum, .mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" on, "zero" on; }

/* === Refined surfaces === */

/* Vellum: premium paper card. Used on hero feature surfaces. */
.vellum {
  position: relative;
  background:
    radial-gradient(ellipse 70% 50% at 25% 10%, rgba(255,253,248,0.95), rgba(245,238,222,0.7) 70%),
    radial-gradient(ellipse 60% 50% at 90% 90%, rgba(201,122,58,0.05), transparent 60%),
    var(--bg-2);
  border: 1px solid rgba(36,46,38,0.10);
  border-radius: var(--r-lg);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    0 1px 2px rgba(255,255,255,0.5),
    0 24px 60px -20px rgba(27,38,32,0.18),
    0 60px 120px -40px rgba(27,38,32,0.12);
  overflow: hidden;
}
.vellum::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence baseFrequency='0.85' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.04;
  mix-blend-mode: overlay;
  pointer-events: none;
  border-radius: inherit;
}
body.eng-mode .vellum {
  background:
    radial-gradient(ellipse 70% 50% at 25% 10%, rgba(255,255,255,0.04), rgba(255,255,255,0.005) 70%),
    radial-gradient(ellipse 60% 50% at 90% 90%, rgba(74,222,128,0.04), transparent 60%),
    var(--bg-2);
  border-color: rgba(255,255,255,0.10);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 24px 80px -20px rgba(0,0,0,0.55),
    0 60px 120px -40px rgba(74,222,128,0.04);
}

/* === Editorial chapter divider === */
.chapter {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 56px 0 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-4);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.chapter::before,
.chapter::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-2), transparent);
}
.chapter-no { color: var(--accent); }

/* === Pull quote — magazine moment between sections === */
.pull-quote {
  font-family: var(--serif);
  font-size: clamp(28px, 3.6vw, 52px);
  line-height: 1.18;
  letter-spacing: -0.025em;
  font-style: italic;
  color: var(--fg);
  text-align: center;
  max-width: 22ch;
  margin: 0 auto;
  padding: 80px 0;
  position: relative;
}
.pull-quote em { color: var(--accent); font-style: italic; }
.pull-quote::before,
.pull-quote::after {
  content: "";
  display: block;
  width: 28px; height: 1px;
  margin: 24px auto;
  background: var(--line-2);
}

/* === Drop cap === */
.drop-cap::first-letter {
  font-family: var(--serif);
  font-size: 4em;
  line-height: 0.85;
  float: left;
  padding: 4px 14px 0 0;
  color: var(--accent);
  font-style: italic;
  font-weight: 400;
}

/* === Refined button states === */
.btn {
  position: relative;
  letter-spacing: -0.005em;
}
.btn-primary, .btn-accent, .btn-warm {
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 8px 24px -12px rgba(27,38,32,0.4);
}
.btn-primary:hover, .btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 14px 36px -12px rgba(47,93,67,0.45);
}
.btn-ghost:hover { transform: translateY(-1px); }
body.eng-mode .btn-primary, body.eng-mode .btn-accent {
  box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 8px 24px -12px rgba(0,0,0,0.55);
}
body.eng-mode .btn-accent:hover {
  box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 14px 36px -12px rgba(74,222,128,0.5);
}

/* === Lift utility for cards === */
.lift {
  transition: transform 320ms cubic-bezier(0.22,1,0.36,1), box-shadow 320ms ease, border-color 320ms ease;
}
.lift:hover { transform: translateY(-3px); }

/* === Refined feat-tile (depth + grain) === */
.feat-tile {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0)),
    var(--bg-2);
}
body.eng-mode .feat-tile {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0));
}
.feat-tile:hover {
  box-shadow: 0 24px 60px -20px rgba(27,38,32,0.12);
}
body.eng-mode .feat-tile:hover {
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.5);
}

/* === Subtle float for hero ornaments === */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.float-soft { animation: float 6s ease-in-out infinite; }

/* === Accreditation strip — gentle wash on hover === */
.accred-name { transition: color 200ms ease, letter-spacing 200ms ease; }
.accred-name:hover { color: var(--accent); }

/* === Marker bar (numeric counter motif) === */
.marker-bar {
  display: inline-block;
  width: 40px; height: 2px;
  background: var(--accent);
  margin-bottom: 16px;
}

/* === Text balance for headlines === */
.h1-display, .h2-display { text-wrap: balance; }
.lead { text-wrap: pretty; }

/* === Refined selection === */
::selection { background: var(--accent); color: #FFFCF6; text-shadow: none; }
body.eng-mode ::selection { background: var(--accent); color: var(--bg); }

/* === Refined scrollbar (engineer mode) === */
body.eng-mode ::-webkit-scrollbar-track { background: var(--bg-1); }
body.eng-mode ::-webkit-scrollbar-thumb { background: var(--line-2); }

/* ==========================================================================
   RESPONSIVE LAYER
   Inline-styled grids dominate this codebase — to avoid rewriting every JSX
   file, we use [style*=] attribute selectors + !important to collapse
   multi-column layouts at narrower viewports. Three breakpoints:
   1080px (small laptop), 900px (tablet), 640px (phone), 420px (tight phone).
   ========================================================================== */

@media (max-width: 1080px) {
  :root { --gutter: 24px; --container: 100%; }
  .section { padding: 96px 0; }
  .section-lg { padding: 120px 0; }
  .h1-display { font-size: clamp(38px, 6.5vw, 76px); }
  .h2-display { font-size: clamp(34px, 5.4vw, 60px); }
}

@media (max-width: 900px) {
  :root { --gutter: 20px; }

  /* Multi-column grids → 2-col */
  [style*="grid-template-columns: repeat(6"],
  [style*="grid-template-columns: repeat(5"],
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns:repeat(6"],
  [style*="grid-template-columns:repeat(5"],
  [style*="grid-template-columns:repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns:repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Two-column ratio layouts → stack */
  [style*="grid-template-columns: 1fr 1.4fr"],
  [style*="grid-template-columns: 1fr 1.6fr"],
  [style*="grid-template-columns: 1.6fr 1fr"],
  [style*="grid-template-columns: 1.4fr 1fr"],
  [style*="grid-template-columns: 1.2fr 1fr"],
  [style*="grid-template-columns: 1fr 1.2fr"],
  [style*="grid-template-columns: 1.3fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }

  /* Fixed-width left + body (founder card, portal, etc.) → stack */
  [style*="grid-template-columns: 320px 1fr"],
  [style*="grid-template-columns: 280px 1fr"],
  [style*="grid-template-columns: 240px 1fr"],
  [style*="grid-template-columns: 220px 1fr"],
  [style*="grid-template-columns: 60px repeat"] {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  /* Funding section: 1fr 64px 1fr (with OR chip) → stack */
  [style*="grid-template-columns: 1fr 64px 1fr"],
  [style*="grid-template-columns: 1fr 80px 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  /* Engineer rate card / job board / pay grids — make scrollable */
  [style*="grid-template-columns: 2.6fr"],
  [style*="grid-template-columns: 90px 1.4fr"],
  [style*="grid-template-columns: 90px 1.6fr"],
  [style*="grid-template-columns: 120px 1.4fr"] {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  /* Hide table headers on mobile (the cells already self-label) */
  [style*="grid-template-columns: 2.6fr"][style*="font-size: 10px"],
  .mono[style*="grid-template-columns: 90px"] {
    display: none !important;
  }

  /* Header — drop the secondary nav, keep logo + tabs + apply CTA */
  .header-inner {
    height: auto !important;
    padding: 12px 0 !important;
    grid-template-columns: 1fr auto !important;
    gap: 12px !important;
  }
  .nav-links { display: none !important; }

  /* Section paddings tighter */
  .section { padding: 72px 0 !important; }
  .section-lg { padding: 96px 0 !important; }
  .section-sm { padding: 56px 0 !important; }

  /* Big card padding */
  .vellum { padding: 32px !important; }
  .surface-2[style*="padding: 56px"],
  .surface-2[style*="padding: 64px"] { padding: 32px !important; }
  [style*="padding: 56px"] { padding: 32px !important; }

  /* Big gaps tightened */
  [style*="gap: 80px"],
  [style*="gap: 64px"] { gap: 32px !important; }

  /* Pull-quote scales down */
  .pull-quote { font-size: clamp(24px, 5vw, 40px); padding: 56px 0; }
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }

  /* Force every multi-col grid to single column */
  [style*="grid-template-columns: repeat(6"],
  [style*="grid-template-columns: repeat(5"],
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns: repeat(2"],
  [style*="grid-template-columns:repeat("] {
    grid-template-columns: 1fr !important;
  }

  /* Header: stack to two rows */
  .header-inner {
    grid-template-columns: 1fr !important;
    text-align: center;
  }
  .header-inner > .logo { justify-content: center; }
  .header-inner > .tab-group { justify-self: center; }
  .header-inner > nav.nav-links {
    display: none !important;
  }

  /* Hero adjustments */
  .container { padding-inline: 16px !important; }
  .h1-display { font-size: clamp(32px, 9vw, 48px); }
  .h2-display { font-size: clamp(26px, 8vw, 38px); }
  .lead { font-size: 15.5px; }

  /* Section paddings */
  .section { padding: 56px 0 !important; }
  .section-lg { padding: 72px 0 !important; }

  /* Buttons */
  .btn { padding-inline: 18px; }
  .btn-lg { padding-inline: 22px; height: 48px; font-size: 14px; }

  /* Stat blocks: huge numbers shrink */
  .h1-display + * .serif[style*="fontSize: 56"],
  .serif.tnum[style*="fontSize: 56"] { font-size: 40px !important; }

  /* Cards inside containers don't blow out */
  .surface, .surface-2, .vellum, .feat-tile {
    padding: 24px !important;
  }

  /* Tier ladder cards stack with tighter padding */
  /* Funding section big numbers */
  [style*="font-size: clamp(80px, 10vw, 132px)"] {
    font-size: clamp(56px, 14vw, 88px) !important;
  }

  /* Portal preview — give it horizontal scroll rather than crushing */
  .surface-2[style*="border-radius: 24px"] {
    overflow-x: auto !important;
    border-radius: 16px !important;
  }
  /* Portal aside (sidebar) — full width on top */
  /* (already handled by 240px 1fr → 1fr collapse above) */

  /* Demo ribbon */
  .demo-ribbon { bottom: 8px; left: 8px; padding: 6px 10px; }
  .demo-ribbon__line { display: none; }

  /* Marquee scales */
  .marquee-track { gap: 32px; padding-right: 32px; }

  /* Pull-quote */
  .pull-quote { font-size: clamp(22px, 6vw, 32px); padding: 40px 0; }
  .pull-quote::before, .pull-quote::after { margin: 16px auto; }

  /* Footer 4-col → 1-col */
  footer .container > div:first-child {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }
  footer .container > div:nth-child(2) {
    flex-direction: column;
    gap: 8px;
    text-align: left;
  }
}

@media (max-width: 420px) {
  .container { padding-inline: 14px !important; }
  .section { padding: 44px 0 !important; }
  .h1-display { font-size: clamp(28px, 10vw, 42px); }
  .h2-display { font-size: clamp(24px, 9vw, 34px); }
  .surface, .surface-2, .vellum, .feat-tile { padding: 18px !important; }
  /* Funding section big numbers tighter still */
  [style*="font-size: clamp(80px, 10vw, 132px)"] {
    font-size: clamp(48px, 16vw, 72px) !important;
  }
  /* Chips wrap and tighten */
  .chip { font-size: 10px; padding: 5px 10px; }
  /* Demo ribbon — icon only */
  .demo-ribbon { font-size: 9px; }
}

/* === Demo ribbon (Anvul ownership disclosure on demo build) === */
.demo-ribbon {
  position: fixed;
  bottom: 14px; left: 14px;
  z-index: 300;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--fg-2);
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--line-2);
  box-shadow: 0 8px 30px rgba(27, 38, 32, 0.12);
  user-select: none;
  transition: transform 200ms ease, opacity 200ms ease;
}
.demo-ribbon:hover { transform: translateY(-1px); }
.demo-ribbon strong { color: var(--accent); font-weight: 600; }
.demo-ribbon__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--warm);
  box-shadow: 0 0 12px rgba(201, 122, 58, 0.55);
  animation: led 2s ease-out infinite;
}
body.eng-mode .demo-ribbon {
  background: rgba(11, 14, 16, 0.85);
  color: var(--fg-2);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
body.eng-mode .demo-ribbon strong { color: var(--accent); }
@media (max-width: 640px) {
  .demo-ribbon__line { display: none; }
  .demo-ribbon { padding: 8px 10px; }
}
