/* ============================================================
   SIGMO AI — Mercury-inspired design system
   Warm ivory canvas · ink typography · serif display accents ·
   periwinkle brand accent · dark "product surface" modules.
   Legacy class names are preserved so all templates inherit it.
   ============================================================ */

:root {
  /* Canvas & surfaces */
  --paper: #f7f5f1;           /* warm ivory page background */
  --paper-2: #efebe3;         /* deeper ivory for alt sections */
  --surface: #ffffff;         /* cards */
  --surface-dark: #101322;    /* dark product-surface modules */
  --surface-dark-2: #181c30;

  /* Ink */
  --ink: #1c1d24;
  --ink-2: #4b4e58;
  --ink-3: #787c86;
  --ink-inverse: #f4f3ef;

  /* Hairlines & borders */
  --hairline: #e6e2d8;
  --hairline-2: #d8d3c6;

  /* Brand accent */
  --accent: #5266eb;          /* periwinkle */
  --accent-deep: #3f51d4;
  --accent-soft: #eceefb;

  /* Signals */
  --long: #0d8a60;
  --long-soft: #e6f4ee;
  --short: #cf3f47;
  --short-soft: #faeaea;
  --warn: #b97f18;
  --warn-soft: #faf3e3;

  /* Depth */
  --shadow-1: 0 1px 2px rgba(28, 29, 36, 0.05), 0 6px 24px rgba(28, 29, 36, 0.06);
  --shadow-2: 0 12px 40px rgba(28, 29, 36, 0.12);

  /* Shape & type */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  /* iOS inflates font sizes on rotation to landscape unless told not to.
     100% keeps our type scale intact without disabling the user's own zoom
     (never set user-scalable=no — it breaks accessibility). */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Touch behaviour. The grey flash on tap reads as a rendering bug on a
   designed surface; removing it is safe only because :active and :focus-visible
   states below still give real feedback. */
@media (pointer: coarse) {
  a, button, .btn, .btn-link, summary, [role="button"] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;   /* removes the 300ms double-tap-zoom delay */
  }
  a:active, button:active, .btn:active, .btn-link:active { opacity: 0.72; }
}

/* Scroll chaining: without this, hitting the end of a table's scroll drags
   the page behind it — and on iOS standalone it triggers the overscroll
   bounce that makes an installed app feel like a web page. */
.table-scroll,
.modal-body,
[data-scroll] { overscroll-behavior: contain; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

::selection { background: #d8ddfa; color: var(--ink); }

/* Page gutter is a single token so the breakpoints below can change the
   spacing without using a `padding` shorthand — a shorthand would silently
   reset the safe-area insets applied further down. Change --wrap-pad, never
   .wrap's padding directly. */
.wrap {
  --wrap-pad: 14px;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  padding: var(--wrap-pad);
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  color: var(--ink);
  letter-spacing: -0.02em;
  font-weight: 650;
}
h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); line-height: 1.12; margin: 10px 0 16px; }
h2 { font-size: clamp(1.25rem, 4vw, 1.55rem); line-height: 1.25; }
h3 { font-size: clamp(1.05rem, 3vw, 1.2rem); line-height: 1.4; }

a { color: var(--accent-deep); }

.text-muted { color: var(--ink-3); }
.mono, .price { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Serif display accent — the Mercury signature */
.serif-accent, .gradient-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.01em;
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--accent-deep);
}

/* ---------- Site header (full-bleed, reacts to scroll) ----------
   Also carries the app's safe-area handling.

   SAFE AREAS (installed app / notched phones)
   The viewport is declared `viewport-fit=cover` so the app fills the screen
   when installed, and iOS uses a translucent status bar. That means the OS
   will happily draw the notch and the home indicator ON TOP of our layout
   unless we reserve the space ourselves. env(safe-area-inset-*) resolves to
   0px on every device without a cutout — desktop included — so these are
   inert everywhere else and need no media query. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: rgba(247, 245, 241, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  /* Clears the status bar / notch when running as an installed app. */
  padding-top: env(safe-area-inset-top, 0px);
}
.site-header.scrolled {
  border-bottom-color: var(--hairline);
  box-shadow: 0 8px 30px rgba(28, 29, 36, 0.07);
  background: rgba(247, 245, 241, 0.94);
}
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 13px 18px;
  /* Landscape on a notched phone puts the cutout at the side. */
  padding-left: max(18px, env(safe-area-inset-left, 0px));
  padding-right: max(18px, env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Content must clear the side cutouts and the home indicator too. Written as
   individual sides so a breakpoint changing --wrap-pad keeps the insets. */
.wrap {
  padding-left: max(var(--wrap-pad), env(safe-area-inset-left, 0px));
  padding-right: max(var(--wrap-pad), env(safe-area-inset-right, 0px));
  padding-bottom: max(var(--wrap-pad), env(safe-area-inset-bottom, 0px));
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 750;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--ink-inverse);
  font-size: 0.95rem;
  font-weight: 800;
}

.header-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-nav a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 550;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
  min-height: 0;
}
.header-nav a:hover { color: var(--ink); background: var(--paper-2); }
.header-nav a.nav-cta {
  color: var(--ink-inverse);
  background: var(--ink);
  margin-left: 6px;
}
.header-nav a.nav-cta:hover { background: #33353f; color: var(--ink-inverse); }

/* ---------- Hero (Mercury-style) ---------- */
.hero {
  text-align: left;
  padding: 46px 4px 30px;
  max-width: 780px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border: 1px solid #dde1f8;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}

.hero h1, .hero-title {
  font-size: clamp(2.3rem, 7vw, 3.9rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
  font-weight: 620;
}

.hero-sub {
  max-width: 560px;
  margin: 0 0 26px;
  color: var(--ink-2);
  font-size: clamp(1rem, 2.5vw, 1.14rem);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.hero-trust {
  font-size: 0.85rem;
  color: var(--ink-3);
  margin-top: 10px;
}

/* Hero split: copy + product shot */
.hero-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 26px;
  align-items: center;
  margin-bottom: 10px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--hairline);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: 640px;
  margin: 26px 0 0;
}

.hero-stat { background: var(--surface); padding: 16px 14px; text-align: left; }
.hero-stat .value {
  display: block;
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 3.5vw, 1.7rem);
  font-weight: 550;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.hero-stat .label {
  font-size: 0.72rem;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ---------- Dark product surface (signal modules) ---------- */
.product-surface {
  background: linear-gradient(160deg, var(--surface-dark-2) 0%, var(--surface-dark) 70%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-2);
  color: #cdd3e1;
  padding: 20px;
  overflow: hidden;
}
.product-surface h2, .product-surface h3, .product-surface h4, .product-surface strong { color: #f2f4f9; }
.product-surface .muted { color: #8d94a6; }

.signal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.signal-row:last-child { border-bottom: 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  padding: 18px;
  border-radius: var(--radius);
  margin: 14px 0;
  overflow-x: auto;
  box-shadow: var(--shadow-1);
}

/* Card that hosts dark JS-rendered trading modules */
.card-dark {
  background: linear-gradient(160deg, var(--surface-dark-2) 0%, var(--surface-dark) 70%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #cdd3e1;
}
.card-dark h2, .card-dark h3 { color: #f2f4f9; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 30px 0 4px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }

.divider { height: 1px; background: var(--hairline); border: 0; margin: 20px 0; }

/* ---------- Badges & signals ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge-long, .signal-long { background: var(--long-soft); color: var(--long); border: 1px solid #c4e5d6; }
.badge-short, .signal-short { background: var(--short-soft); color: var(--short); border: 1px solid #f2cfd1; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid #ecd9ae; }
.badge-accent { background: var(--accent-soft); color: var(--accent-deep); border: 1px solid #dde1f8; }

/* Status banner (market hours) */
.status-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface);
  font-size: 0.92rem;
  color: var(--ink-2);
  margin: 14px 0;
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status-dot.open { background: var(--long); box-shadow: 0 0 0 4px var(--long-soft); }
.status-dot.closed { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }

/* ---------- Forms ---------- */
label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline-2);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px; /* prevents iOS zoom */
  font-family: inherit;
  min-height: 46px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23787c86' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(82, 102, 235, 0.15);
}

input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- Buttons ---------- */
button, .btn {
  margin-top: 14px;
  padding: 12px 22px;
  background: var(--ink);
  color: var(--ink-inverse);
  font-weight: 650;
  font-family: inherit;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  min-height: 46px;
  min-width: 44px;
  touch-action: manipulation;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
  letter-spacing: -0.01em;
}
button:hover, .btn:hover { background: #33353f; transform: translateY(-1px); box-shadow: var(--shadow-1); }
button:active, .btn:active { transform: translateY(0); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 650;
  font-size: 0.92rem;
  text-align: center;
  min-height: 44px;
  min-width: 44px;
  transition: background 0.15s ease, transform 0.15s ease, filter 0.15s ease;
  line-height: 1.3;
  border: 1px solid transparent;
}
.btn-link:hover { transform: translateY(-1px); }

/* Primary CTA — periwinkle */
.btn-cta { background: var(--accent); color: #fff !important; }
.btn-cta:hover { background: var(--accent-deep); }

.btn-primary { background: var(--ink); color: var(--ink-inverse); }
.btn-primary:hover { background: #33353f; }
.btn-success { background: var(--long); color: #fff; }
.btn-success:hover { filter: brightness(1.08); }
.btn-warning { background: var(--warn); color: #fff; }
.btn-danger  { background: var(--short); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink-2); border: 1px solid var(--hairline-2); }
.btn-secondary:hover { background: var(--paper-2); }
.btn-ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--hairline-2); }
.btn-ghost:hover { background: var(--paper-2); }

.btn-group { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.btn-group .btn-link,
.btn-group button,
.btn-group a { width: 100%; margin: 0; }

/* ---------- Result / metrics ---------- */
.result h2 { margin-top: 0; font-size: 1.1rem; }
.disclaimer { color: var(--ink-3); font-size: 0.8rem; margin-top: 12px; line-height: 1.5; }
.cheatsheet p { margin: 8px 0; font-size: 0.92rem; color: var(--ink-2); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.metric {
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.metric .k { display: block; font-size: 0.7rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.metric .v { font-size: 1.1rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
  font-variant-numeric: tabular-nums;
}
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--hairline); min-width: 100px; }
th {
  background: var(--paper);
  font-weight: 650;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  position: sticky;
  top: 0;
  z-index: 10;
}
tbody tr:hover { background: var(--paper); }

/* ---------- Wide tables: .table-scroll ----------
   A bare `table { display: block; overflow-x: auto }` puts the horizontal
   scrollbar at the very BOTTOM of the table, so on a long table you must
   scroll past every row to reach it — and by the time you drag it sideways
   the header row and the symbol column have scrolled out of view, leaving
   unlabelled numbers. Wrapping the table in .table-scroll fixes both halves:
   the box scrolls in BOTH axes within one viewport-sized frame (so the
   scrollbar is always in reach), the header row pins to the top, and the
   identity column (.col-key) pins to the left, so every cell keeps its row
   and column labels no matter where you scroll. */
.table-scroll {
  overflow: auto;
  /* Capped height is what puts the horizontal scrollbar back within reach:
     the frame never grows taller than the viewport, so the bar sits at the
     bottom of what you are looking at instead of below row 200. */
  max-height: min(70vh, 640px);
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
/* Inside the frame the table is a real table again: `display: block` would
   defeat both sticky axes and collapse the column widths. */
.table-scroll > table {
  display: table;
  width: 100%;
  margin: 0;
  overflow: visible;
  border-collapse: separate;   /* separate borders survive sticky cells */
  border-spacing: 0;
}
.table-scroll th,
.table-scroll td { border-bottom: 1px solid var(--hairline); }
.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--paper);
  /* box-shadow, not border-bottom: borders on sticky cells scroll away. */
  box-shadow: inset 0 -1px 0 var(--hairline-2);
}
/* The identity column — pinned so rows stay readable when scrolled right. */
.table-scroll .col-key {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: inset -1px 0 0 var(--hairline);
}
.table-scroll thead .col-key {
  z-index: 4;                  /* header ∩ key column: above both */
  background: var(--paper);
  box-shadow: inset -1px 0 0 var(--hairline-2), inset 0 -1px 0 var(--hairline-2);
}
/* Hover must repaint the pinned cell too, or the row highlight stops at it. */
.table-scroll tbody tr:hover td { background: var(--paper); }
.table-scroll tbody tr:hover .col-key { background: var(--paper); }

/* The pinned column must never wrap or clip its symbol: it is the row's only
   label once you scroll right, so a broken "^STOXX50E" costs more than the
   width it saves. Ticker length is bounded (9 chars is the longest the board
   publishes), so sizing to content is safe — the vw ceiling is only a
   backstop against a pathological symbol on a very narrow screen, and
   ellipsis degrades gracefully instead of slicing a glyph in half. */
.table-scroll .col-key {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 767px) {
  .table-scroll .col-key { max-width: min(45vw, 168px); }
}

/* ---------- App shell: toast, offline banner, installed mode ---------- */
.sigmo-toast {
  position: fixed;
  left: max(14px, env(safe-area-inset-left, 0px));
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  margin: 0 auto;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--ink-inverse);
  box-shadow: var(--shadow-2);
  font-size: 0.9rem;
  /* Animate in from below; the reduced-motion block above neutralises this. */
  transform: translateY(16px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.sigmo-toast.in { transform: translateY(0); opacity: 1; }
.sigmo-toast span { flex: 1 1 auto; }
.sigmo-toast-action {
  flex: 0 0 auto;
  background: var(--ink-inverse);
  color: var(--ink);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font: inherit;
  font-weight: 650;
  min-height: 40px;
  cursor: pointer;
  width: auto;
  min-width: 0;
}
.sigmo-toast-close {
  flex: 0 0 auto;
  background: transparent;
  color: var(--ink-inverse);
  border: 0;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  opacity: 0.7;
  min-height: 40px;
  min-width: 40px;
  width: auto;
}
.sigmo-toast-close:hover { opacity: 1; }

.sigmo-offline {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--warn);
  color: #fff;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 600;
}

/* Installed app: the browser chrome is gone, so the in-page "install this
   app" affordances are noise — and the header can sit tighter without a URL
   bar above it. `.is-installed` is set on <html> before first paint. */
.is-installed #pwa-install-banner,
.is-installed #ios-install-banner,
.is-installed [data-install-only] { display: none !important; }
.is-installed .site-header { position: sticky; }
.is-installed .header-inner { padding-top: 10px; padding-bottom: 10px; }

/* ---------- Nav (legacy) ---------- */
nav { display: flex; flex-direction: column; gap: 8px; }
nav a {
  padding: 12px;
  text-decoration: none;
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
}
nav a:hover { background: var(--paper-2); }

img { max-width: 100%; height: auto; display: block; }

details summary { cursor: pointer; color: var(--ink-2); font-weight: 600; }
details summary:hover { color: var(--ink); }

/* ---------- PWA refresh button ---------- */
.pwa-refresh-btn {
  position: fixed;
  /* Sits above the home indicator instead of under it. */
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: calc(20px + env(safe-area-inset-right, 0px));
  width: 52px;
  height: 52px;
  min-height: 52px;
  min-width: 52px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--ink-inverse);
  border: none;
  box-shadow: var(--shadow-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  padding: 0;
}
.pwa-refresh-btn:hover { transform: scale(1.08); }
.pwa-refresh-btn:active { transform: scale(0.95); }
.pwa-refresh-btn svg { animation: none; }
.pwa-refresh-btn.refreshing svg { animation: spin 0.8s linear infinite; }

@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes slideInRight { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes fadeUp { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.fade-up { animation: fadeUp 0.5s ease both; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 36px 20px 30px;
  margin-top: 52px;
  border-top: 1px solid var(--hairline);
  color: var(--ink-3);
  font-size: 0.88rem;
  background: var(--paper-2);
}
.site-footer a { color: var(--ink-2); text-decoration: none; margin: 0 10px; transition: color 0.15s ease; }
.site-footer a:hover { color: var(--accent-deep); }
.footer-links { margin-bottom: 14px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; }

/* ---------- Markets (programmatic SEO pages) ---------- */
.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.market-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: var(--font-mono);
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.market-chip:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}

.breadcrumbs { font-size: 0.85rem; color: var(--ink-3); margin: 6px 0 14px; }
.breadcrumbs a { color: var(--ink-2); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent-deep); }

.prose p { margin: 12px 0; color: var(--ink-2); line-height: 1.8; }
.prose h2 { margin: 28px 0 10px; font-size: 1.3rem; }
.prose h3 { margin: 20px 0 8px; font-size: 1.05rem; }
.prose ul { margin: 10px 0 10px 22px; color: var(--ink-2); }
.prose li { margin: 6px 0; }

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================
   Responsive breakpoints
   ============================================================ */

@media (max-width: 640px) {
  .pwa-refresh-btn { bottom: 16px; right: 16px; width: 46px; height: 46px; min-height: 46px; min-width: 46px; }
  .hero { padding: 30px 2px 20px; }
}

@media (min-width: 640px) {
  .wrap { --wrap-pad: 18px; }
  .card { padding: 22px; margin: 16px 0; }
  button, .btn { width: auto; min-width: 130px; }
  nav { flex-direction: row; gap: 12px; }
  .btn-group { flex-direction: row; flex-wrap: wrap; }
  .btn-group .btn-link,
  .btn-group button,
  .btn-group a { width: auto; flex: 0 1 auto; }
}

@media (min-width: 768px) {
  .wrap { max-width: 768px; --wrap-pad: 22px; margin: 0 auto; }
  .card { padding: 24px; border-radius: var(--radius-lg); }
  table { display: table; }
  .hero-split { grid-template-columns: 1.1fr 0.9fr; gap: 40px; }
}

@media (min-width: 1024px) {
  .wrap { max-width: 1000px; --wrap-pad: 26px; }
  .card { padding: 26px; }
  .terminal-grid { display: grid; grid-template-columns: 420px 1fr; gap: 0 20px; align-items: start; }
}

@media (min-width: 1280px) {
  .wrap { max-width: 1180px; }
}

/* ============================================================
   Landing page system (Mercury-style marketing sections)
   ============================================================ */

.landing { overflow-x: hidden; }

.section { padding: 72px 18px; position: relative; }
.section-alt { background: var(--paper-2); }
.section-dark {
  background: linear-gradient(160deg, var(--surface-dark-2) 0%, var(--surface-dark) 70%);
  color: #cdd3e1;
}
.section-dark h2, .section-dark h3, .section-dark strong { color: #f2f4f9; }
.section-dark .section-title { color: #8d94a6; }
.section-dark .section-title::after { background: rgba(255, 255, 255, 0.1); }

.container { max-width: 1180px; margin: 0 auto; }
.container.narrow { max-width: 760px; }

/* ---------- Hero ---------- */
.hero-landing {
  position: relative;
  padding: 84px 18px 64px;
  overflow: hidden;
}
.hero-glow {
  position: absolute;
  width: 760px;
  height: 760px;
  right: -240px;
  top: -260px;
  background: radial-gradient(circle, rgba(82, 102, 235, 0.14) 0%, transparent 62%);
  pointer-events: none;
}
.hero-glow::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  left: -900px;
  top: 620px;
  background: radial-gradient(circle, rgba(185, 127, 24, 0.08) 0%, transparent 60%);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
  align-items: center;
  position: relative;
}
.hero-visual { position: relative; }
.hero-visual::before {
  content: "";
  position: absolute;
  inset: -8%;
  background: radial-gradient(circle at 50% 40%, rgba(82, 102, 235, 0.16) 0%, transparent 65%);
  pointer-events: none;
}

/* Entrance sequence */
@keyframes enterUp { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: translateY(0); } }
.enter { opacity: 0; animation: enterUp 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) forwards; }
.enter.d1 { animation-delay: 0.05s; }
.enter.d2 { animation-delay: 0.15s; }
.enter.d3 { animation-delay: 0.28s; }
.enter.d4 { animation-delay: 0.42s; }
.enter.d5 { animation-delay: 0.55s; }

/* Floating product mockup */
@keyframes floaty {
  0%, 100% { transform: rotate(-1.2deg) translateY(0); }
  50% { transform: rotate(-1.2deg) translateY(-12px); }
}
.mockup-float {
  animation: floaty 7s ease-in-out infinite;
  will-change: transform;
}

/* Scroll reveals */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
.reveal.visible { opacity: 1; transform: none; }

/* ---------- Ticker marquee ---------- */
.marquee-strip {
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  overflow: hidden;
  padding: 13px 0;
}
.marquee-track {
  display: flex;
  gap: 44px;
  width: max-content;
  animation: marquee 36s linear infinite;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-3);
  white-space: nowrap;
}
.marquee-track span strong { color: var(--ink); font-weight: 650; }
.marquee-track .up { color: var(--long); }
.marquee-track .down { color: var(--short); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Stat band ---------- */
.stat-band {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 34px 20px;
  text-align: center;
}
.stat-band .stat .num {
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 6vw, 3.2rem);
  font-weight: 550;
  color: #f2f4f9;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  display: block;
}
.stat-band .stat .cap {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #8d94a6;
}

/* ---------- Feature splits ---------- */
.feature-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
  align-items: center;
  margin: 54px 0;
}
.feature-split .feature-copy h2 { margin-bottom: 12px; font-size: clamp(1.4rem, 3.5vw, 1.9rem); }
.feature-split .feature-copy p { color: var(--ink-2); max-width: 480px; }
.feature-kicker {
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-deep);
  margin-bottom: 10px;
}

/* Monitoring timeline visual */
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.85rem;
  align-items: baseline;
}
.timeline-item:last-child { border-bottom: 0; }
.timeline-time { font-family: var(--font-mono); color: #8d94a6; font-size: 0.76rem; flex: none; width: 52px; }

/* Win-rate bars visual */
.bar-row { margin: 12px 0; font-size: 0.84rem; }
.bar-row .bar-label { display: flex; justify-content: space-between; margin-bottom: 5px; font-family: var(--font-mono); }
.bar-row .bar-track { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #5b8ef0, #7f9ff5); }
.bar-row.good .bar-fill { background: linear-gradient(90deg, #17a173, #3ec096); }
.bar-row.bad .bar-fill { background: linear-gradient(90deg, #cf3f47, #e27077); }

/* ---------- Pricing ---------- */
.pricing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 26px;
}
.price-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 30px 28px;
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
}
.price-card .plan { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); }
.price-card .amount {
  font-family: var(--font-serif);
  font-size: 2.6rem;
  font-weight: 550;
  color: var(--ink);
  margin: 8px 0 2px;
  letter-spacing: -0.02em;
}
.price-card .amount small { font-size: 1rem; color: var(--ink-3); font-family: var(--font-sans); }
.price-card ul { list-style: none; margin: 18px 0 22px; padding: 0; flex: 1; }
.price-card li { padding: 7px 0 7px 26px; position: relative; font-size: 0.94rem; }
.price-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 13px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='7' viewBox='0 0 8 7'%3E%3Cpath d='M1 3.5 3 5.5 7 1' stroke='%233f51d4' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center no-repeat;
}
.price-card.featured {
  background: linear-gradient(160deg, var(--surface-dark-2) 0%, var(--surface-dark) 70%);
  border-color: rgba(82, 102, 235, 0.4);
  color: #cdd3e1;
  box-shadow: 0 20px 50px rgba(28, 29, 36, 0.22), 0 0 0 4px rgba(82, 102, 235, 0.08);
}
.price-card.featured .plan { color: #9aa6f0; }
.price-card.featured .amount { color: #f2f4f9; }
.price-card.featured .amount small { color: #8d94a6; }
.price-card.featured li::before { background-color: rgba(82, 102, 235, 0.25); }

/* ---------- FAQ ---------- */
.faq-item {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  margin: 10px 0;
  box-shadow: var(--shadow-1);
}
.faq-item summary {
  padding: 17px 20px;
  font-weight: 620;
  color: var(--ink);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.25rem; color: var(--ink-3); transition: transform 0.25s ease; line-height: 1; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item .faq-body { padding: 0 20px 18px; color: var(--ink-2); font-size: 0.95rem; }

/* ---------- CTA band ---------- */
.cta-band { text-align: center; }
.cta-band h2 {
  font-size: clamp(1.7rem, 5vw, 2.6rem);
  margin-bottom: 10px;
  letter-spacing: -0.025em;
}
.cta-band .serif-accent { color: #9aa6f0; }

/* ---------- Responsive (landing) ---------- */
@media (min-width: 860px) {
  .hero-grid { grid-template-columns: 1.05fr 0.95fr; gap: 56px; }
  .hero-landing { padding: 108px 22px 84px; }
  .section { padding: 92px 22px; }
  .stat-band { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .feature-split { grid-template-columns: 1fr 1fr; gap: 64px; margin: 84px 0; }
  .feature-split.flip .feature-visual { order: -1; }
  .pricing-grid { grid-template-columns: 1fr 1fr; gap: 22px; max-width: 860px; margin-left: auto; margin-right: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .enter { opacity: 1; animation: none; }
  .mockup-float { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .marquee-track { animation: none; }
}
