/* Design tokens. One scale for space, type and radii; light and dark through prefers-color-scheme. */

:root {
  color-scheme: light dark;

  /* Spacing: 8px scale, plus a 4px half step */
  --space-half: 4px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --space-6: 64px;

  /* Type scale */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --leading-tight: 1.25;
  --leading-body: 1.5;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-bold: 650;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;

  /* Control sizing: 48px minimum tap target */
  --control-height: 48px;

  /* Colors, light */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #14181f;
  --text-muted: #46505f;
  --border: #cfd5de;
  --border-strong: #8a94a3;
  --accent: #1b5fd6;
  --accent-hover: #154cac;
  --on-accent: #ffffff;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --success: #17653a;
  --success-bg: #e8f5ec;
  --warn: #8a4b00;
  --warn-bg: #fff4e0;
  --focus: #1b5fd6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1217;
    --surface: #161b22;
    --text: #e8ebf0;
    --text-muted: #a6b0be;
    --border: #2b3340;
    --border-strong: #6c7788;
    --accent: #6aa5ff;
    --accent-hover: #8bb9ff;
    --on-accent: #0a1020;
    --danger: #ff9a90;
    --danger-bg: #2e1816;
    --success: #7fd6a0;
    --success-bg: #14281c;
    --warn: #ffc978;
    --warn-bg: #2e2210;
    --focus: #8bb9ff;
  }
}

/* Base */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-body);
}

h1, h2, p { margin: 0; }

h1 {
  font-size: var(--text-xl);
  line-height: var(--leading-tight);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -100px;
  padding: var(--space-1) var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--space-1); }

/* Page frame */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header__inner,
.site-main,
.site-footer__inner {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding-left: var(--space-2);
  padding-right: var(--space-2);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 64px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  font-weight: var(--weight-bold);
  font-size: var(--text-md);
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.wordmark:hover { color: var(--text); }

.header-account {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.header-account form { display: flex; margin: 0; }

.header-account__email {
  color: var(--text-muted);
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.header-account__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  padding: 0 var(--space-1);
  flex: none;
}

.site-main {
  flex: 1;
  padding-top: var(--space-5);
  padding-bottom: var(--space-6);
}

.site-footer { border-top: 1px solid var(--border); }
.site-footer__inner {
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Content blocks */

.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack--tight { gap: var(--space-1); }

.panel {
  max-width: 28rem;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.lede { color: var(--text-muted); }

.field { display: flex; flex-direction: column; gap: var(--space-1); }

.field__label { font-weight: var(--weight-medium); font-size: var(--text-sm); }

.input {
  width: 100%;
  min-height: var(--control-height);
  padding: 0 var(--space-2);
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.input[aria-invalid="true"] { border-color: var(--danger); }

.field__error { color: var(--danger); font-size: var(--text-sm); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  font: inherit;
  font-weight: var(--weight-medium);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.button--primary { background: var(--accent); color: var(--on-accent); }
.button--primary:hover { background: var(--accent-hover); color: var(--on-accent); }

.button--secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.button--secondary:hover { background: var(--bg); color: var(--text); }

.link-action {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  padding: 0 var(--space-1);
  margin-left: calc(var(--space-1) * -1);
  border-radius: var(--radius-sm);
}

.notice {
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
}
.notice--error { background: var(--danger-bg); border-color: var(--danger); color: var(--text); }
.notice--ok { background: var(--success-bg); border-color: var(--success); color: var(--text); }
.notice strong { display: block; margin-bottom: var(--space-half); }

.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-3); margin: 0; }
.meta-list dt { color: var(--text-muted); }
.meta-list dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 639px) {
  .site-main { padding-top: var(--space-4); }
  .panel { padding: var(--space-3); max-width: none; }
  .meta-list { grid-template-columns: 1fr; gap: 0; }
  .meta-list dd { margin-bottom: var(--space-2); }
  .header-account__email { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .button { transition: background-color 120ms ease; }
}

.mono-block { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font-size: var(--text-sm); }


/* I3: projects, onboarding wizard, keywords ----------------------------------------------------------------- */

.site-main--wide { max-width: 1280px; }

.crumb { font-size: var(--text-sm); }
.crumb a { display: inline-flex; align-items: center; min-height: var(--control-height); }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-2);
}

h2 { margin: 0; font-size: var(--text-lg); line-height: var(--leading-tight); font-weight: var(--weight-bold); }

.eyebrow { color: var(--text-muted); font-size: var(--text-sm); }

.textarea, .select {
  width: 100%;
  padding: var(--space-1) var(--space-2);
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.textarea { min-height: 10rem; line-height: var(--leading-body); resize: vertical; }
.select { min-height: var(--control-height); }
.field__hint { color: var(--text-muted); font-size: var(--text-sm); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--space-2); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.actions--forms form { display: contents; }

.button--danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.button--danger:hover { background: var(--danger-bg); color: var(--danger); }

.notice--warn { background: var(--warn-bg); border-color: var(--warn); color: var(--text); }
.notice--info { background: var(--surface); }
.notice p + p { margin-top: var(--space-1); }
.notice ul { margin: var(--space-1) 0 0; padding-left: var(--space-3); }

/* Wizard */

.wizard { width: 100%; max-width: 40rem; }
.wizard__panel {
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.progress { display: flex; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.progress li { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.progress li[data-state="done"], .progress li[aria-current="step"] { background: var(--accent); }

.choice-list { display: flex; flex-direction: column; gap: var(--space-1); margin: 0; padding: 0; border: 0; min-width: 0; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: var(--space-2);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.choice:hover { border-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice input { flex: none; width: 20px; height: 20px; margin: var(--space-half) 0 0; accent-color: var(--accent); }
.choice__body { display: flex; flex-direction: column; min-width: 0; }
.choice__title { font-weight: var(--weight-medium); overflow-wrap: anywhere; }
.choice__meta { color: var(--text-muted); font-size: var(--text-sm); overflow-wrap: anywhere; }

/* Dashboard project cards */

.project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.project-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-half);
  height: 100%;
  min-height: var(--control-height);
  padding: var(--space-3);
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.project-card:hover { color: var(--text); border-color: var(--accent); }
.project-card__name { font-weight: var(--weight-bold); overflow-wrap: anywhere; }
.project-card__meta { color: var(--text-muted); font-size: var(--text-sm); overflow-wrap: anywhere; }

/* Keyword table */

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2); }
.filters .field { min-width: 12rem; }
.check { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--control-height); padding: 0 var(--space-1); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  padding: var(--space-1) var(--space-2);
  color: var(--text-muted);
  font-weight: var(--weight-medium);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table td { padding: var(--space-1) var(--space-2); vertical-align: middle; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }

.kw-table td.kw-cell { max-width: 24rem; min-width: 12rem; padding: 0; }
.kw-link {
  display: block;
  min-height: var(--control-height);
  padding: var(--space-1) var(--space-2);
  color: var(--text);
  text-decoration: none;
}
.kw-link:hover { background: var(--bg); color: var(--text); }
.kw-link__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-weight: var(--weight-medium);
  color: var(--accent);
}
.kw-link__tags { display: flex; flex-wrap: wrap; gap: var(--space-half); margin-top: var(--space-half); }

.position { font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.position--text { font-weight: var(--weight-regular); color: var(--text-muted); }
.url-cell { max-width: 16rem; }
.url-cell a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--text-muted); }

.change { display: inline-flex; align-items: center; gap: var(--space-half); white-space: nowrap; font-variant-numeric: tabular-nums; }
.change svg { width: 12px; height: 12px; flex: none; }
.change--up { color: var(--success); }
.change--down { color: var(--danger); }
.change--none { color: var(--text-muted); }
.change svg path { fill: currentColor; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-1);
  min-height: 24px;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  white-space: nowrap;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.badge--ok { color: var(--success); background: var(--success-bg); border-color: var(--success); }
.badge--warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn); }

.skeleton { display: inline-block; width: 3rem; height: 1rem; vertical-align: middle; background: var(--border); border-radius: var(--radius-sm); }
.skeleton--wide { width: 6rem; }
@keyframes pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: pulse 1.6s ease-in-out infinite; }
}

.spark { display: block; width: 96px; height: 28px; overflow: visible; }
.spark__line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark__dot { fill: var(--accent); }

.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.button[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

.disclosure { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.disclosure > summary {
  display: flex;
  align-items: center;
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  font-weight: var(--weight-medium);
  cursor: pointer;
  border-radius: var(--radius-md);
}
.disclosure[open] > summary { border-bottom: 1px solid var(--border); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.disclosure__body { padding: var(--space-3); }

.panel--wide { max-width: none; }

/* Keyword detail */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--space-2); }
.stat { padding: var(--space-2) var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.stat__label { color: var(--text-muted); font-size: var(--text-sm); }
.stat__value { font-size: var(--text-lg); font-weight: var(--weight-bold); overflow-wrap: anywhere; }
.stat__value--small { font-size: var(--text-md); }
@media (max-width: 639px) {
  .stat-grid--pairs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.chart { display: block; width: 100%; height: auto; }
.chart--wide { display: none; }
.chart__grid { stroke: var(--border); stroke-width: 1; }
.chart__line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart__dot { fill: var(--accent); }
.chart__miss { stroke: var(--text-muted); stroke-width: 2; }
.chart__label { fill: var(--text-muted); font-size: 12px; font-family: var(--font-sans); }
.chart-legend { color: var(--text-muted); font-size: var(--text-sm); }

.kw-title { overflow-wrap: anywhere; }

.empty { display: flex; flex-direction: column; gap: var(--space-1); }

@media (min-width: 640px) {
  .chart--compact { display: none; }
  .chart--wide { display: block; }
}

@media (max-width: 1099px) {
  .table .col-url { display: none; }
}

@media (max-width: 639px) {
  .wizard__panel { padding: var(--space-3); }
  .kw-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .kw-table, .kw-table tbody, .kw-table tr { display: block; }
  .kw-table tr { padding: var(--space-1) 0; border-bottom: 1px solid var(--border); }
  .kw-table tbody tr:last-child { border-bottom: 0; }
  .kw-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-half) var(--space-2);
    border: 0;
    text-align: right;
  }
  .kw-table td::before { content: attr(data-label); flex: none; color: var(--text-muted); text-align: left; }
  .kw-table td.kw-cell { display: block; max-width: none; padding: 0; text-align: left; }
  .kw-table td.kw-cell::before { content: none; }
  .kw-table td.col-url { display: flex; }
  .kw-table .url-cell { max-width: none; }
  .kw-table .url-cell a { max-width: 14rem; }
  .filters .field { flex: 1 1 100%; }
  .page-head .button { width: 100%; }
}

/* Project navigation: one row on every project page; scrolls sideways when it does not fit */

.project-bar { border-bottom: 1px solid var(--border); background: var(--surface); }
.project-nav { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 var(--space-2); }
.project-nav.site-main--wide { max-width: 1280px; }
.project-nav ul {
  display: flex; flex-wrap: nowrap; gap: var(--space-1); margin: 0; padding: 0; list-style: none; overflow-x: auto; overscroll-behavior-x: contain;
  /* Edge fade: a soft shade shows on a side only while there is more to scroll to (the surface-coloured covers scroll with the content and hide it at the ends). */
  background:
    linear-gradient(var(--surface), var(--surface)) left center / 24px 100% no-repeat local,
    linear-gradient(var(--surface), var(--surface)) right center / 24px 100% no-repeat local,
    linear-gradient(to right, var(--border-strong), transparent) left center / 16px 100% no-repeat scroll,
    linear-gradient(to left, var(--border-strong), transparent) right center / 16px 100% no-repeat scroll;
}
.project-nav .nav-short { display: none; }
.project-nav li { flex: 0 0 auto; }
.project-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  padding: 0 var(--space-2);
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.project-nav a:hover { color: var(--text); border-bottom-color: var(--border-strong); }
.project-nav a[aria-current="page"] { color: var(--text); font-weight: var(--weight-medium); border-bottom-color: var(--accent); }
.project-nav a:focus-visible { outline-offset: -3px; }
@media (max-width: 639px) {
  .project-nav ul { gap: 0; margin-left: calc(-1 * var(--space-1)); }
  .project-nav a { padding: 0 var(--space-1); }
}
/* Under 480 px the long labels give way to short ones. The long label stays in the page, hidden from the eye, as the accessible name. */
@media (max-width: 479px) {
  .project-nav .nav-short { display: inline; }
  .project-nav .nav-full { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* AI answers (I4) */

.subnav ul { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.subnav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  padding: 0 var(--space-2);
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.subnav a:hover { border-color: var(--border-strong); }
.subnav a[aria-current="page"] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); font-weight: var(--weight-medium); }

.stat--trend { display: flex; flex-direction: column; gap: var(--space-half); }
.stat__sub { color: var(--text-muted); font-size: var(--text-sm); }
.trend { display: block; width: 120px; height: 36px; margin-top: var(--space-1); overflow: visible; }
.trend__base { stroke: var(--border); stroke-width: 1; }
.trend__line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.trend__dot { fill: var(--accent); }

.engine-name { text-align: left; font-weight: var(--weight-regular); padding: var(--space-1) var(--space-2); }
.engine-name__text { display: block; font-weight: var(--weight-medium); }
.engine-name__full { display: block; font-size: var(--text-xs); }

.cell { display: inline-flex; align-items: flex-start; gap: var(--space-1); font-size: var(--text-sm); line-height: var(--leading-tight); }
.cell__icon { flex: none; width: 16px; height: 16px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.cell__text { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.cell__extra { color: var(--text-muted); font-size: var(--text-xs); }
.cell--good { color: var(--success); font-weight: var(--weight-medium); }
.cell--neutral { color: var(--text-muted); }
.cell--wait { color: var(--warn); }
.cell--bad { color: var(--danger); }

.ai-table td { vertical-align: top; }
.ai-table td.kw-cell { min-width: 14rem; }
.expand { margin-top: var(--space-half); padding: 0 var(--space-2) var(--space-1); }
.expand > summary { display: inline-flex; align-items: center; min-height: 32px; color: var(--accent); font-size: var(--text-sm); cursor: pointer; }
.expand p { margin: var(--space-half) 0 0; overflow-wrap: anywhere; font-size: var(--text-sm); }

.result { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-2) 0; border-top: 1px solid var(--border); }
.result:first-child { border-top: 0; padding-top: 0; }
.result__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1); }
.result__head h4 { margin: 0; font-size: var(--text-md); font-weight: var(--weight-bold); }
.result__meta { font-size: var(--text-sm); }
.excerpt { margin: 0; padding: var(--space-1) var(--space-2); background: var(--bg); border-left: 3px solid var(--border-strong); border-radius: var(--radius-sm); }
.excerpt__about { color: var(--text-muted); font-size: var(--text-xs); }
.excerpt blockquote { margin: var(--space-half) 0 0; overflow-wrap: anywhere; }
.excerpt mark { color: var(--text); background: var(--warn-bg); outline: 1px solid var(--warn); border-radius: 2px; padding: 0 2px; font-weight: var(--weight-medium); }

.textarea--short { min-height: 5rem; }

@media (max-width: 639px) {
  .ai-table td.kw-cell { min-width: 0; }
  .ai-table td { align-items: flex-start; }
  .engine-name { display: block; }
}

@media (max-width: 639px) {
  .kw-table td.cell-empty { display: none; }
}

/* Maps grid (I5) */

.hm-layout { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1000px) {
  .hm-layout { grid-template-columns: minmax(0, 36rem) minmax(0, 1fr); }
}

/* The frame scrolls sideways before a cell drops under 32px (SPEC 7). It holds the SVG at the width of its box up to a cap. */
.hm-frame {
  padding: var(--space-1);
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
/* --cells is set by a size class, not an inline style: the CSP allows no inline style attribute. */
.hm-frame--5 { --cells: 5; }
.hm-frame--7 { --cells: 7; }
.hm-frame--9 { --cells: 9; }
.hm {
  display: block;
  width: 100%;
  min-width: calc(var(--cells) * 32px);
  max-width: calc(var(--cells) * 88px);
  height: auto;
  margin: 0 auto;
}
.hm-back { fill: var(--bg); stroke: var(--border); stroke-width: 1; }
.hm-street { stroke: var(--border); stroke-width: 1; }
.hm-cell { cursor: pointer; outline: none; }
.hm-rect { stroke-width: 1.5; }
.hm-num { font-family: var(--font-sans); font-size: 21px; font-weight: 650; font-variant-numeric: tabular-nums; }
/* The label scales with the grid: the SVG shrinks as cells multiply, and "No data" still renders at about 11px or more on a phone. A halo keeps it clear of the hatch. */
.hm-small { font-family: var(--font-sans); font-size: 13px; font-weight: 500; fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.hm-frame--7 .hm-small { font-size: 15px; }
.hm-frame--9 .hm-small { font-size: 19px; }
.hm-hatch { stroke: var(--border-strong); stroke-width: 2; }
.hm-hatchfill { pointer-events: none; }
.hm-cell--b1 .hm-rect { fill: var(--success-bg); stroke: var(--success); }
.hm-cell--b1 .hm-num { fill: var(--success); }
.hm-cell--b2 .hm-rect { fill: var(--warn-bg); stroke: var(--warn); }
.hm-cell--b2 .hm-num { fill: var(--warn); }
.hm-cell--b3 .hm-rect { fill: var(--danger-bg); stroke: var(--danger); }
.hm-cell--b3 .hm-num { fill: var(--danger); }
.hm-cell--b4 .hm-rect { fill: var(--surface); stroke: var(--border-strong); }
.hm-cell--b4 .hm-num { fill: var(--text-muted); }
.hm-cell--nodata .hm-rect { fill: var(--surface); stroke: var(--border-strong); stroke-dasharray: 4 3; }
.hm-cell:hover .hm-rect { stroke: var(--text); stroke-width: 2.5; }
.hm-cell:focus-visible .hm-rect { stroke: var(--focus); stroke-width: 4; }
.hm-cell.is-selected .hm-rect { stroke: var(--text); stroke-width: 4; }
.hm-centre circle { fill: var(--text); stroke: var(--surface); stroke-width: 1.5; }
.hm-centre .hm-centre__dot { fill: var(--surface); stroke: none; }

.hm-legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); margin: 0; padding: 0; list-style: none; color: var(--text-muted); font-size: var(--text-sm); }
.hm-legend li { display: inline-flex; align-items: center; gap: var(--space-1); }
.hm-swatch { flex: none; width: 16px; height: 16px; border: 1.5px solid; border-radius: 4px; }
.hm-swatch--b1 { background: var(--success-bg); border-color: var(--success); }
.hm-swatch--b2 { background: var(--warn-bg); border-color: var(--warn); }
.hm-swatch--b3 { background: var(--danger-bg); border-color: var(--danger); }
.hm-swatch--b4 { background: var(--surface); border-color: var(--border-strong); }
.hm-swatch--nodata { border-style: dashed; border-color: var(--border-strong); background: repeating-linear-gradient(45deg, var(--border-strong) 0 1px, var(--surface) 1px 4px); }
.hm-swatch--centre { border-radius: 50%; border-color: var(--surface); background: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }

.point-panel { align-self: start; scroll-margin-top: var(--space-2); }
.point-list { display: flex; flex-direction: column; gap: var(--space-1); margin: 0; padding: 0; list-style: none; counter-reset: top; }
.point-list li { display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-height); padding: var(--space-1) var(--space-2); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); counter-increment: top; }
.point-list li::before { content: counter(top); flex: none; width: 24px; font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; color: var(--text-muted); }
.point-list__name { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.chart--trend { max-width: 34rem; }

.scan-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.scan-list li { border-top: 1px solid var(--border); }
.scan-list li:first-child { border-top: 0; }
.scan-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); min-height: var(--control-height); padding: var(--space-1) var(--space-2); color: var(--text); text-decoration: none; }
a.scan-row:hover { background: var(--bg); color: var(--text); }
.scan-row[aria-current="true"] { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
.scan-row__date { min-width: 6rem; font-weight: var(--weight-medium); }
.scan-row__stats { flex: 1; min-width: 12rem; color: var(--text-muted); font-size: var(--text-sm); }
.scan-row--static { color: var(--text-muted); }
.skeleton--map { display: block; width: 100%; max-width: 36rem; height: auto; aspect-ratio: 1; margin: 0 auto; }
.inline-badges { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }

/* Billing */

.account-banner { background: var(--warn-bg); border-bottom: 1px solid var(--warn); color: var(--text); font-size: var(--text-sm); }
.account-banner__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-half) var(--space-2);
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--space-1) var(--space-2);
}
.account-banner__link { display: inline-flex; align-items: center; min-height: var(--control-height); font-weight: var(--weight-medium); }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: var(--space-2); }
.plan-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.plan-card h3 { margin: 0; font-size: var(--text-lg); line-height: var(--leading-tight); font-weight: var(--weight-bold); }
.plan-card__list { margin: 0; padding-left: var(--space-3); color: var(--text-muted); }
.plan-card__buy { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--space-1); }
.plan-card__buy form { display: flex; margin: 0; }
.plan-card__buy .button { flex: 1; }
.button:disabled { opacity: 0.5; cursor: not-allowed; }

/* I7: dashboard, public pages, checker ------------------------------------------------------------------------ */

.site-header__inner { flex-wrap: wrap; }

.public-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-1); margin-left: auto; }
.public-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  padding: 0 var(--space-1);
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.public-nav a:hover { color: var(--accent); }
.public-nav .public-nav__cta { padding: 0 var(--space-2); border: 1px solid var(--border-strong); background: var(--surface); }
.public-nav .public-nav__cta:hover { color: var(--text); background: var(--bg); }

.site-footer__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 var(--space-3); }
.footer-nav { display: flex; gap: var(--space-1); }
.footer-nav a { display: inline-flex; align-items: center; min-height: var(--control-height); padding: 0 var(--space-1); }

.stack--page { gap: var(--space-5); }
h3 { margin: 0; font-size: var(--text-md); line-height: var(--leading-tight); font-weight: var(--weight-bold); }
.plain-list { margin: 0; padding-left: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); }

/* Dashboard */

.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: var(--space-2); }
.module-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-half);
  min-height: 15rem;
  padding: var(--space-3);
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.module-card:hover { color: var(--text); border-color: var(--accent); }
.module-card__title { font-size: var(--text-md); }
.module-card__value { margin-top: var(--space-1); font-size: var(--text-2xl); line-height: var(--leading-tight); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.module-card__value--text { font-size: var(--text-lg); }
.module-card__label { color: var(--text); }
.module-card__sub { color: var(--text-muted); font-size: var(--text-sm); }
.module-card__trend { margin-top: var(--space-1); }
.module-card__trend .trend { margin-top: 0; }
.module-card__cta { margin-top: auto; padding-top: var(--space-2); color: var(--accent); font-weight: var(--weight-medium); }
.project-card[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.account-strip { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.account-strip .meta-list { gap: var(--space-half) var(--space-3); }

.switcher { margin: 0; display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-1); }
.page-head .actions { align-items: flex-end; }
.switcher .select { min-width: 14rem; max-width: 100%; }

/* Home */

.hero { padding: var(--space-3) 0 var(--space-2); }
.hero__title { max-width: 24ch; font-size: var(--text-2xl); line-height: var(--leading-tight); font-weight: var(--weight-bold); letter-spacing: -0.015em; }
.hero__lede { max-width: 40rem; color: var(--text-muted); font-size: var(--text-lg); line-height: var(--leading-body); }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.feature { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }

.diff-list { display: flex; flex-direction: column; gap: var(--space-2); margin: 0; padding: 0; list-style: none; max-width: 44rem; }
.diff-list li { padding-left: var(--space-2); border-left: 3px solid var(--border-strong); }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.step { display: flex; gap: var(--space-2); }
.step > div { display: flex; flex-direction: column; gap: var(--space-half); }
.step__n { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; font-weight: var(--weight-bold); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }

.band { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }

/* Pricing */

.plan-grid--public { margin: 0; padding: 0; list-style: none; }
.plan-card__price { font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: var(--leading-tight); }
.plan-card__yearly { font-size: var(--text-sm); }
.badge--soon { margin-left: var(--space-1); color: var(--text-muted); }

.plan-table th[scope="row"] { color: var(--text); font-weight: var(--weight-medium); text-align: left; padding: var(--space-1) var(--space-2); vertical-align: top; border-bottom: 1px solid var(--border); }
.plan-table tbody tr:last-child th { border-bottom: 0; }
.plan-table td { vertical-align: top; min-width: 11rem; }
@media (max-width: 639px) {
  .plan-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .plan-table, .plan-table tbody, .plan-table tr { display: block; }
  .plan-table tr { padding: var(--space-1) 0; border-bottom: 1px solid var(--border); }
  .plan-table tbody tr:last-child { border-bottom: 0; }
  .plan-table th[scope="row"], .plan-table td { display: block; border-bottom: 0; }
  .plan-table td { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: var(--space-1); min-width: 0; padding-top: var(--space-half); padding-bottom: var(--space-half); }
  .plan-table td::before { content: attr(data-label); color: var(--text-muted); }
  .plan-table th[scope="row"] .badge--soon { display: table; margin: var(--space-half) 0 0; }
}

/* Checker */

.checker-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); align-items: start; }
@media (min-width: 900px) { .checker-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 24rem); } }
.checker-aside { align-self: start; }
.turnstile--dev { padding: var(--space-1) var(--space-2); color: var(--text-muted); font-size: var(--text-sm); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.stat--result { padding: var(--space-3); }
.stat__value--big { font-size: var(--text-2xl); line-height: var(--leading-tight); }
.meta-list--card { padding: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
@media (max-width: 639px) { .meta-list--card dd { margin-bottom: var(--space-1); } }

/* Terms and privacy */

.prose { max-width: 44rem; }
.prose p, .prose li { overflow-wrap: anywhere; }
.prose ul { margin: 0; padding-left: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); }
.prose section { margin-top: var(--space-2); }
