/* ==========================================================================
   Design system — light theme
   ========================================================================== */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../fonts/plus-jakarta-sans-var.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-muted: #64748B;
  --text-subtle: #94A3B8;

  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-soft: #EEF2FF;
  --primary-ring: rgba(79, 70, 229, .35);
  --accent: #0EA5E9;
  --success: #10B981;
  --success-soft: #ECFDF5;
  --success-text: #047857;
  --warning: #F59E0B;
  --warning-soft: #FFFBEB;
  --warning-text: #B45309;
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --danger-soft: #FEF2F2;
  --danger-text: #B91C1C;
  --info-soft: #F0F9FF;
  --info-text: #0369A1;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 4px 12px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, .12);

  /* 4px spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;

  --container: 1200px;
  --gutter: clamp(16px, 4vw, 32px);
  --nav-h: 64px;

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --text-xs: .75rem;
  --text-sm: .875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --h1: clamp(2.1rem, 1.4rem + 3.2vw, 3.6rem);
  --h2: clamp(1.6rem, 1.2rem + 1.8vw, 2.4rem);
  --h3: clamp(1.15rem, 1.05rem + .5vw, 1.4rem);

  --ease: cubic-bezier(.2, .7, .3, 1);
  --t-fast: 150ms;
  --t: 200ms;
}

/* ---------- Reset & base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

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-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  overflow-x: hidden;
}

main { flex: 1 0 auto; }

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

h1, h2, h3, h4 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
  color: var(--text);
}
h1 { font-size: var(--h1); letter-spacing: -.03em; }
h2 { font-size: var(--h2); }
h3 { font-size: var(--h3); }
h4 { font-size: var(--text-lg); }

p { margin: 0 0 var(--space-4); }

a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }

code, kbd, pre { font-family: var(--font-mono); font-size: .9em; }
:not(pre) > code {
  padding: .1em .4em;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-8) 0; }

::selection { background: var(--primary-soft); color: var(--primary-hover); }

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

[x-cloak], [hidden] { display: none !important; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: var(--space-3); color: #fff; }

/* ---------- Layout helpers ---------- */

.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container-narrow { max-width: calc(760px + var(--gutter) * 2); }

.section { padding-block: clamp(56px, 8vw, 104px); }
.section-tight { padding-block: clamp(40px, 5vw, 64px); }
.section-alt { background: var(--surface); border-block: 1px solid var(--border); }

.section-head { max-width: 640px; margin: 0 auto var(--space-12); text-align: center; }
.section-head p { color: var(--text-muted); font-size: var(--text-lg); margin: 0; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  color: var(--primary);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: .02em;
}

.lead { font-size: clamp(1.05rem, 1rem + .3vw, 1.25rem); color: var(--text-muted); line-height: 1.65; }
.muted { color: var(--text-muted); }
.small { font-size: var(--text-sm); }
.tabular { font-variant-numeric: tabular-nums; }
.text-center { text-align: center; }

.stack > * + * { margin-top: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }

.grid { display: grid; gap: var(--space-6); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
/* Column counts are capped (3 / 4) and collapse responsively below the min width. */
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, max(260px, (100% - 2 * var(--space-6)) / 3)), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, max(200px, (100% - 3 * var(--space-6)) / 4)), 1fr)); }

.icon { width: 1.25em; height: 1.25em; flex: none; }
.icon-sm { width: 1em; height: 1em; flex: none; }

/* ==========================================================================
   Components
   ========================================================================== */

/* ---------- Buttons ---------- */

.btn {
  --btn-h: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--btn-h);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .1), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn-primary:hover { background: var(--primary-hover); color: #fff; box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .55); }

.btn-secondary { border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }

.btn-sm { --btn-h: 34px; padding: 0 12px; font-size: var(--text-xs); border-radius: 7px; }
.btn-lg { --btn-h: 52px; padding: 0 26px; font-size: var(--text-base); border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-icon { width: var(--btn-h); padding: 0; }

/* ---------- Forms ---------- */

.field { display: grid; gap: 6px; }
.field + .field { margin-top: var(--space-4); }
.label { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.hint { font-size: var(--text-xs); color: var(--text-muted); }
.error-text { font-size: var(--text-xs); color: var(--danger-text); }
.hint-warning { color: var(--warning-text); }
.hint-warning:not([hidden]) { display: flex; align-items: flex-start; gap: 6px; }
.hint-warning .icon { flex: none; margin-top: 1px; }

.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  line-height: 1.4;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.textarea { min-height: 110px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-mono { font-family: var(--font-mono); letter-spacing: .04em; }

.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 12px; color: var(--text-subtle); pointer-events: none; }
.input-group > .input { padding-left: 38px; }

/* Checkbox */
.check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }

/* Segmented control (radio group) */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.segmented label { position: relative; flex: 1 1 auto; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.segmented label:hover span { color: var(--text); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }
.segmented-block { display: flex; }

/* Toggle switch */
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  cursor: pointer;
  font-size: var(--text-sm);
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  transition: background-color var(--t) var(--ease);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .2);
  transition: transform var(--t) var(--ease);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Color field: swatch (native picker) + hex text */
.color-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 4px 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.color-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.color-swatch {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .12);
  overflow: hidden;
}
.color-swatch input[type="color"] {
  position: absolute;
  inset: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
  border: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}
.color-field .input {
  min-height: 32px;
  padding: 4px 6px;
  border: 0;
  box-shadow: none;
  font-family: var(--font-mono);
  text-transform: uppercase;
}
.color-field .input:focus { box-shadow: none; }

/* Range slider with value bubble */
.range { position: relative; padding-top: 30px; }
.range input[type="range"] {
  --pct: 50%;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  appearance: none;
  cursor: pointer;
}
.range input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(to right, var(--primary) var(--pct), var(--border) var(--pct));
}
.range input[type="range"]::-moz-range-track { height: 6px; border-radius: var(--radius-full); background: var(--border); }
.range input[type="range"]::-moz-range-progress { height: 6px; border-radius: var(--radius-full); background: var(--primary); }
.range input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  transition: transform var(--t-fast) var(--ease);
}
.range input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary);
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
}
.range input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
.range input[type="range"]:focus-visible { outline: none; }
.range input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--primary-ring); }
.range input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px var(--primary-ring); }
.range-bubble {
  position: absolute;
  top: 0;
  left: var(--pct, 50%);
  transform: translateX(-50%);
  min-width: 32px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  pointer-events: none;
}
.range-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 8px;
  height: 8px;
  background: var(--text);
  transform: translateX(-50%) rotate(45deg);
  z-index: -1;
}

/* ---------- Cards ---------- */

.card {
  position: relative;
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.card-hover { transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.card-title { display: flex; align-items: center; gap: 8px; margin-bottom: var(--space-2); font-size: var(--text-lg); }
.card-title .icon-sm { color: var(--primary); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.card-head h2, .card-head h3 { margin: 0; font-size: var(--text-lg); }

.feature-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--space-4);
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
}
.feature-icon .icon { width: 22px; height: 22px; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-primary { background: var(--primary-soft); color: var(--primary-hover); }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Alerts ---------- */

.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid;
  border-radius: var(--radius);
  font-size: var(--text-sm);
}
.alert > .icon { margin-top: 1px; }
.alert p:last-child { margin-bottom: 0; }
.alert strong { display: block; margin-bottom: 2px; }
.alert-info { background: var(--info-soft); border-color: #BAE6FD; color: var(--info-text); }
.alert-success { background: var(--success-soft); border-color: #A7F3D0; color: var(--success-text); }
.alert-warning { background: var(--warning-soft); border-color: #FDE68A; color: var(--warning-text); }
.alert-danger { background: var(--danger-soft); border-color: #FECACA; color: var(--danger-text); }

/* ---------- Tabs ---------- */

.tabs-list {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-list::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  padding: 10px 14px;
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease);
}
.tab:hover { color: var(--text); }
.tab::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--primary);
  transform: scaleX(0);
  transition: transform var(--t) var(--ease);
}
.tab[aria-selected="true"] { color: var(--primary); }
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab-panel { padding-top: var(--space-4); }

/* ---------- Code block with copy ---------- */

.code-block {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #F8FAFC;
}
.code-block pre {
  margin: 0;
  padding: var(--space-4) 96px var(--space-4) var(--space-4);
  overflow-x: auto;
  color: #1E293B;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.code-block .btn { position: absolute; top: 8px; right: 8px; }

/* ---------- Toasts ---------- */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: var(--space-6);
  z-index: 90;
  display: grid;
  gap: var(--space-2);
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 16px;
  border-radius: var(--radius-full);
  background: var(--text);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in var(--t) var(--ease);
}
.toast .icon { color: #6EE7B7; }
.toast-error .icon { color: #FCA5A5; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Modal (native <dialog>) ---------- */

.modal {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal[open] { animation: modal-in var(--t) var(--ease); }
.modal::backdrop { background: rgba(15, 23, 42, .35); backdrop-filter: blur(2px); }
.modal-body { padding: var(--space-6); }
.modal-body h2 { font-size: var(--text-lg); }
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Accordion (native <details>) ---------- */

.accordion { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.accordion details + details { border-top: 1px solid var(--border); }
.accordion summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  transition: background-color var(--t-fast) var(--ease);
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary:hover { background: var(--surface-2); }
.accordion summary .icon { color: var(--text-muted); transition: transform var(--t) var(--ease); }
.accordion details[open] summary .icon { transform: rotate(180deg); }
.accordion summary:focus-visible { outline-offset: -2px; border-radius: 0; }
.accordion-body { padding: 0 var(--space-6) var(--space-5); color: var(--text-muted); }
.accordion-body p:last-child { margin-bottom: 0; }

/* ---------- Tooltip (CSS only; use on focusable elements) ---------- */

[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: max-content;
  max-width: 240px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  white-space: normal;
  opacity: 0;
  transform: translate(-50%, 4px);
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Skeleton loaders ---------- */

.skeleton {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, #E9EEF5 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: skeleton 1.4s ease infinite;
}
.skeleton-text { height: .8em; margin-block: .35em; }
@keyframes skeleton { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

/* ---------- Empty state ---------- */

.empty-state {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-12) var(--space-6);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--text-muted);
}
.empty-state .feature-icon { margin-bottom: var(--space-2); }
.empty-state h3 { margin: 0; color: var(--text); font-size: var(--text-lg); }
.empty-state p { max-width: 380px; margin: 0; }

/* ---------- Pagination ---------- */

.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-1); }
.pagination a, .pagination span {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.pagination a:hover { background: var(--surface-2); color: var(--text); }
.pagination [aria-current="page"] { background: var(--primary); color: #fff; }
.pagination .disabled { opacity: .45; }

/* ---------- Flags ---------- */

.fi {
  display: inline-block;
  flex: none;
  width: 1.333em;
  height: 1em;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .08);
  vertical-align: -.125em;
}
.flag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.flag-chip .fi { font-size: 1.05rem; border-radius: 50%; width: 1.25em; height: 1.25em; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { background: var(--surface-2); color: var(--text-muted); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Chrome: navbar & footer
   ========================================================================== */

.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  border-bottom: 1px solid rgba(226, 232, 240, .8);
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
}
.navbar-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-6); height: 100%; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.02em;
  text-decoration: none;
}
.brand:hover { color: var(--text); }
/* Logo files: public/assets/img/logo.svg (icon + name) and logo-icon.svg (icon only). */
.brand-logo { display: block; width: auto; max-width: none; height: 32px; }
.brand-icon { display: block; flex: none; width: 32px; height: 32px; }

.nav-links { display: flex; align-items: center; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.nav-links a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.nav-actions { display: flex; align-items: center; gap: var(--space-2); }
.nav-toggle { display: none; }

.nav-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, .3);
  backdrop-filter: blur(2px);
}
.nav-sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  width: min(320px, 86vw);
  padding: var(--space-4) var(--space-6) var(--space-8);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}
.nav-sheet-head { display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
.nav-sheet ul { display: grid; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.nav-sheet ul a {
  display: block;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}
.nav-sheet ul a:hover { background: var(--surface-2); }
.sheet-enter { transition: transform 220ms var(--ease), opacity 220ms var(--ease); }
.sheet-from { transform: translateX(100%); }
.sheet-to { transform: translateX(0); }
.fade-enter { transition: opacity 200ms var(--ease); }
.fade-from { opacity: 0; }
.fade-to { opacity: 1; }

.site-banner { border-bottom: 1px solid; font-size: var(--text-sm); }
.site-banner-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px; min-height: 40px; padding-block: 6px; text-align: center; }
.site-banner-inner > span { display: inline-flex; align-items: center; gap: 8px; }
.site-banner-info { background: var(--info-soft); border-color: #BAE6FD; color: var(--info-text); }
.site-banner-warning { background: var(--warning-soft); border-color: #FDE68A; color: var(--warning-text); }
.site-banner-success { background: var(--success-soft); border-color: #A7F3D0; color: var(--success-text); }
.site-banner-impersonate { background: #1E1B4B; border-color: #312E81; color: #E0E7FF; }
.site-banner-impersonate strong { color: #fff; }

@media (max-width: 860px) {
  .navbar .nav-links, .navbar .nav-actions .nav-desktop { display: none; }
  .nav-toggle { display: inline-flex; }
}

.site-footer { margin-top: auto; padding-top: var(--space-16); border-top: 1px solid var(--border); background: var(--surface); }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: var(--space-8); }
.footer-grid h2 { margin-bottom: var(--space-3); color: var(--text); font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 600; letter-spacing: 0; }
.footer-grid ul { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.footer-grid a { color: var(--text-muted); font-size: var(--text-sm); text-decoration: none; }
.footer-grid a:hover { color: var(--text); }
.footer-about p { max-width: 300px; margin-top: var(--space-3); color: var(--text-muted); font-size: var(--text-sm); }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-12);
  padding-block: var(--space-6);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-xs);
}
.footer-bottom a { color: inherit; }
@media (max-width: 760px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-about { grid-column: 1 / -1; }
}

/* ==========================================================================
   Home page
   ========================================================================== */

.hero { position: relative; isolation: isolate; overflow: hidden; padding-block: clamp(48px, 8vw, 112px) clamp(56px, 8vw, 104px); }
.hero-bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.blob-1 { width: 520px; height: 520px; top: -180px; right: -80px; background: radial-gradient(circle, rgba(79, 70, 229, .22), transparent 70%); }
.blob-2 { width: 460px; height: 460px; bottom: -200px; left: -120px; background: radial-gradient(circle, rgba(14, 165, 233, .2), transparent 70%); }
.blob-3 { width: 360px; height: 360px; top: 30%; left: 45%; background: radial-gradient(circle, rgba(16, 185, 129, .14), transparent 70%); }
.hero-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(79, 70, 229, .32) 1.3px, transparent 1.6px);
  background-size: 12px 12px;
  -webkit-mask-image: url("../img/world-mask.svg");
  mask-image: url("../img/world-mask.svg");
  -webkit-mask-size: min(1200px, 140%) auto;
  mask-size: min(1200px, 140%) auto;
  -webkit-mask-position: 60% 55%;
  mask-position: 60% 55%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  opacity: .55;
}

.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: clamp(32px, 6vw, 72px); }
.hero h1 { margin-bottom: var(--space-5); }
.hero h1 .grad {
  background: linear-gradient(100deg, var(--primary) 10%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .lead { max-width: 540px; margin-bottom: var(--space-8); }
.hero-ctas { display: flex; flex-wrap: wrap; gap: var(--space-3); }
/* "I'm not a robot" check (HumanCheck::widget): room for Google's box before it loads */
.human-check { margin-top: var(--space-4); }
.human-check-box { min-height: 78px; }
.human-check-box.is-compact { min-height: 144px; }
.human-check-error { margin: var(--space-2) 0 0; color: var(--danger-text); font-size: var(--text-sm); }

.ph-badge { display: inline-block; margin-top: var(--space-6); border-radius: 10px; }
.ph-badge img { display: block; width: 250px; height: 54px; }

.hero-visual { position: relative; display: grid; place-items: center; min-height: 380px; }
.float-chip { position: absolute; animation: float 6s ease-in-out infinite; }
.float-chip:nth-child(2) { top: 4%; left: 2%; animation-delay: -1s; }
.float-chip:nth-child(3) { top: 14%; right: -2%; animation-delay: -3s; }
.float-chip:nth-child(4) { bottom: 10%; left: -4%; animation-delay: -2s; }
.float-chip:nth-child(5) { bottom: 2%; right: 6%; animation-delay: -4s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-visual { min-height: 320px; }
}
@media (max-width: 520px) {
  .float-chip:nth-child(2), .float-chip:nth-child(4), .float-chip:nth-child(5) { display: none; }
}

/* Sample widget (HTML replica used in the hero) */
.sample-widget {
  position: relative;
  width: min(100%, 340px);
  padding: 18px 20px 14px;
  border: 1px solid #E5E7EB;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-lg), 0 0 0 6px rgba(255, 255, 255, .6);
  font-variant-numeric: tabular-nums;
  animation: float 7s ease-in-out infinite;
}
.sample-widget-title { margin-bottom: 10px; color: #111827; font-family: var(--font-sans); font-size: 15px; font-weight: 600; letter-spacing: 0; }
.sample-widget-grid { display: grid; grid-template-columns: repeat(2, 1fr); column-gap: 22px; }
.sample-widget-row { display: flex; align-items: center; gap: 8px; height: 30px; font-size: 13px; }
.sample-widget-row .fi { width: 24px; height: 18px; font-size: inherit; }
.sample-widget-row .cc { color: #9CA3AF; font-weight: 500; }
.sample-widget-row .n { margin-left: auto; color: #374151; font-weight: 600; }
.sample-widget-foot { margin-top: 8px; padding-top: 10px; border-top: 1px solid #F1F5F9; color: #9CA3AF; font-size: 12px; }

.trust-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3) var(--space-8);
  margin: 0;
  padding: var(--space-6) 0;
  list-style: none;
}
.trust-row li { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: var(--text-sm); font-weight: 500; }
.trust-row .icon { color: var(--success); }

.steps { counter-reset: step; }
.step { padding-top: var(--space-8); }
.step-num {
  position: absolute;
  top: calc(var(--space-6) * -1 + 4px);
  left: var(--space-6);
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  box-shadow: 0 8px 18px -8px rgba(79, 70, 229, .7);
}
.step p { margin: 0; color: var(--text-muted); }

.builder-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.builder-panel { padding: 0; overflow: hidden; }
.builder-preview { position: sticky; top: calc(var(--nav-h) + 24px); }
.preview-canvas {
  display: grid;
  place-items: center;
  min-height: 320px;
  padding: var(--space-8);
  border-radius: var(--radius);
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #F1F5F9 25%, transparent 25%),
    linear-gradient(-45deg, #F1F5F9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #F1F5F9 75%),
    linear-gradient(-45deg, transparent 75%, #F1F5F9 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
@media (max-width: 900px) {
  .builder-shell { grid-template-columns: minmax(0, 1fr); }
  .builder-preview { position: static; order: -1; }
}
@media (max-width: 520px) {
  .preview-canvas { min-height: 240px; padding: var(--space-4); }
  .builder-preview .card { padding: var(--space-4); }
}

/* ---------- Builder ---------- */

.builder-controls { min-width: 0; }
.builder-panel summary > span { display: inline-flex; align-items: center; gap: 10px; }
.builder-panel summary > span .icon-sm { color: var(--primary); }
.builder-group { display: grid; gap: 18px; padding-top: 4px; }
.builder-group .field + .field { margin-top: 0; }
.builder-group fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.builder-group legend { padding: 0; margin-bottom: 6px; }
.field-row .field + .field { margin-top: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 18px; }
.input-xs { width: 76px; min-height: 32px; padding: 4px 8px; text-align: right; }
.segmented-sm span { min-height: 26px; padding: 0 10px; font-size: var(--text-xs); }
.segmented-block label { flex: 1 1 0; }
.segmented-wrap label { min-width: max-content; }
.builder-submit { margin-top: 20px; }
.builder-submit.is-busy { opacity: .7; }
.hp-field { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.layout-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.layout-card { position: relative; cursor: pointer; }
.layout-card input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.layout-card-body {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 12px 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.layout-card:hover .layout-card-body { border-color: var(--border-strong); }
.layout-card input:checked + .layout-card-body { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary); }
.layout-card input:focus-visible + .layout-card-body { outline: 2px solid var(--primary); outline-offset: 2px; }
.layout-card-label { font-size: var(--text-sm); font-weight: 600; }
.thumb { display: grid; width: 64px; height: 40px; padding: 5px; border-radius: 6px; background: #fff; box-shadow: inset 0 0 0 1px var(--border); gap: 3px; }
.thumb i { display: block; border-radius: 2px; background: linear-gradient(90deg, #93C5FD 0 30%, #CBD5E1 30% 100%); }
.thumb-grid { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }
.thumb-list { grid-template-rows: repeat(3, 1fr); }
.thumb-list i:nth-child(n+4) { display: none; }
.thumb-list i { background: linear-gradient(90deg, #93C5FD 0 18%, transparent 18% 24%, var(--primary) 24% 90%, #E2E8F0 90%); height: 6px; align-self: center; }
.thumb-badge { place-items: center; padding: 12px 6px; }
.thumb-badge i { display: none; }
.thumb-badge i:first-child { display: block; width: 100%; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--primary) 0 45%, #E2E8F0 45%); }

.preset-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.preset-swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.preset-swatch:hover { border-color: var(--border-strong); }
.preset-swatch.is-active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.preset-dot { position: relative; flex: none; width: 22px; height: 22px; border: 1px solid; border-radius: 6px; overflow: hidden; }
.preset-dot i { position: absolute; left: 4px; right: 4px; bottom: 5px; height: 3px; border-radius: 2px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 12px; }

.preview-card { padding: var(--space-5); }
.preview-card .card-head { flex-wrap: wrap; }
.preview-toggle { display: none; }
.preview-canvas { position: relative; display: flex; overflow: auto; }
/* Always the real size: wide widgets scroll instead of shrinking (auto margins keep scrolling safe). */
.preview-canvas img { flex: none; max-width: none; height: auto; margin: auto; transition: opacity var(--t) var(--ease); }
/* A pinned preview must never be taller than the screen: tall widgets scroll inside it. */
.builder-preview .preview-canvas { max-height: calc(100vh - var(--nav-h) - 200px); }
.preview-hint { display: flex; align-items: flex-start; justify-content: center; gap: 6px; margin: 8px 0 0; color: var(--warning-text); font-size: var(--text-xs); text-align: center; }
.preview-hint .icon-sm { margin-top: 2px; }

/* Wide widgets: full-width preview pinned above the settings. */
.builder-shell.is-wide { grid-template-columns: minmax(0, 1fr); }
.builder-shell.is-wide .builder-preview { order: -1; position: sticky; top: var(--nav-h); z-index: 20; }
/* Let the wide preview use more of a big screen than the 1200px content column. */
@media (min-width: 1280px) {
  .builder-shell.is-wide .builder-preview { width: min(calc(100vw - 64px), 1440px); justify-self: center; }
}
.builder-shell.is-wide .builder-preview .preview-card { box-shadow: var(--shadow-lg); }
.builder-shell.is-wide .preview-canvas { min-height: 0; max-height: 46vh; padding: var(--space-5); }
.builder-shell.is-wide .preview-toggle { display: inline-flex; }
.builder-shell.is-wide .builder-preview.is-collapsed .preview-body { display: none; }
.preview-canvas.is-loading img { opacity: .55; }
.preview-meta { margin: 10px 0 0; color: var(--text-muted); font-size: var(--text-xs); text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  .builder-preview { position: sticky; top: var(--nav-h); z-index: 20; }
  .builder-preview .preview-card { box-shadow: var(--shadow-lg); }
  .preview-toggle { display: inline-flex; }
  .builder-preview.is-collapsed .preview-body { display: none; }
  .builder-preview .preview-canvas { min-height: 0; max-height: 46vh; }
}

/* ---------- Created page ---------- */

.success-hero { position: relative; overflow: hidden; padding-block: clamp(40px, 6vw, 72px) var(--space-8); text-align: center; }
.success-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-5);
  border-radius: 20px;
  background: var(--success-soft);
  color: var(--success);
  box-shadow: 0 0 0 8px rgba(16, 185, 129, .08);
}
.success-icon .icon { width: 30px; height: 30px; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti 2.6s var(--ease) forwards;
}
.confetti i:nth-child(odd) { width: 6px; height: 6px; border-radius: 50%; }
@keyframes confetti {
  0% { opacity: 0; transform: translateY(0) rotate(0); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translateY(260px) rotate(540deg); }
}
.created-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: var(--space-6); align-items: start; padding-bottom: clamp(56px, 8vw, 96px); }
.created-grid > * { min-width: 0; }
@media (max-width: 900px) { .created-grid { grid-template-columns: minmax(0, 1fr); } }
.key-card { border-color: #FDE68A; background: linear-gradient(180deg, #FFFBEB, #FFFFFF 60%); }
.edit-key {
  display: block;
  margin: var(--space-3) 0;
  padding: 14px 16px;
  border: 1px dashed #F59E0B;
  border-radius: var(--radius);
  background: #fff;
  font-family: var(--font-mono);
  font-size: clamp(1.05rem, .9rem + 1vw, 1.35rem);
  font-weight: 600;
  letter-spacing: .08em;
  text-align: center;
  word-break: break-all;
  user-select: all;
}
.link-list { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.link-list a { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; text-decoration: none; }
.link-list a:hover { background: var(--surface-2); }
.link-list a > span { display: inline-flex; align-items: center; gap: 10px; }
.link-list a > span .icon-sm { color: var(--primary); }
.link-list code { color: var(--text-muted); font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-showcase { display: flex; padding: var(--space-6); border-radius: var(--radius); background: var(--surface-2); overflow-x: auto; }
.widget-showcase img { flex: none; max-width: none; height: auto; margin: auto; }

.cta-band {
  position: relative;
  overflow: hidden;
  padding: clamp(40px, 6vw, 64px);
  border-radius: 24px;
  background: linear-gradient(120deg, var(--primary) 0%, #6366F1 45%, var(--accent) 100%);
  color: #fff;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.cta-band h2 { color: #fff; }
.cta-band p { max-width: 520px; margin: 0 auto var(--space-6); color: rgba(255, 255, 255, .85); font-size: var(--text-lg); }
.cta-band .btn-secondary { border-color: transparent; color: var(--primary-hover); }
.cta-band::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .18) 1px, transparent 1.2px);
  background-size: 18px 18px;
  -webkit-mask-image: radial-gradient(ellipse at center, #000, transparent 70%);
  mask-image: radial-gradient(ellipse at center, #000, transparent 70%);
  pointer-events: none;
}
.cta-band > * { position: relative; }

/* ==========================================================================
   Countries page
   ========================================================================== */

.page-header { padding-block: clamp(40px, 6vw, 72px) var(--space-8); }
.page-header p { max-width: 620px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-bottom: var(--space-6); }
.toolbar .input-group { flex: 1 1 260px; max-width: 420px; }

.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.country-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.country-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.country-item .fi { font-size: 1.35rem; }
.country-item .name { flex: 1; min-width: 0; overflow: hidden; font-size: var(--text-sm); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.country-item code { color: var(--text-muted); font-size: var(--text-xs); }

/* ==========================================================================
   Statistics
   ========================================================================== */

.stats-page { padding-bottom: clamp(56px, 8vw, 96px); }
.stats-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); padding-top: clamp(28px, 4vw, 48px); margin-bottom: var(--space-5); }
.stats-header-main { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.stats-widget-thumb { display: grid; place-items: center; flex: none; width: 96px; height: 72px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.stats-widget-thumb img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.stats-title { margin: 2px 0 4px; font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); overflow-wrap: anywhere; }
.stats-tabs { margin-bottom: var(--space-6); }
.stats-tabs a.tab { text-decoration: none; }
.stats-tabs a.tab[aria-current="page"] { color: var(--primary); }
.stats-tabs a.tab[aria-current="page"]::after { transform: scaleX(1); }
.stats-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.segmented a { display: block; flex: 1 1 auto; text-decoration: none; border-radius: 7px; }
.segmented a span { pointer-events: none; }
.segmented a:hover span { color: var(--text); }
.segmented a[aria-current="true"] span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.segmented a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
[data-stats].is-loading .kpi-grid, [data-stats].is-loading .chart-card, [data-stats].is-loading .stats-grid, [data-stats].is-loading .breakdown-grid { opacity: .55; transition: opacity var(--t) var(--ease); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.kpi { padding: var(--space-5); }
.kpi-head { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { color: var(--text-muted); font-size: var(--text-sm); font-weight: 500; }
.kpi-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); }
.kpi-value { margin: 8px 0 6px; font-family: var(--font-display); font-size: clamp(1.6rem, 1.3rem + 1vw, 2.1rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi-foot { font-size: var(--text-xs); }
.kpi-change { display: inline-flex; padding: 1px 7px; border-radius: var(--radius-full); background: var(--surface-2); color: var(--text-muted); font-weight: 600; }
.kpi-change.up { background: var(--success-soft); color: var(--success-text); }
.kpi-change.down { background: var(--danger-soft); color: var(--danger-text); }

.chart-card { margin-bottom: var(--space-4); }
.chart-wrap { position: relative; height: 300px; }
.stats-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: var(--space-4); margin-bottom: var(--space-4); }
@media (max-width: 1199px) { .stats-grid { grid-template-columns: minmax(0, 1fr); } }
/* Top countries: the numbers must stay in view — long names ("Heard Island and McDonald
   Islands") wrap instead of pushing Visitors/Views/Share out of the card. */
#countries-table th, #countries-table td { padding-left: 8px; padding-right: 8px; }
#countries-table th:first-child, #countries-table td:first-child { padding-left: 0; }
#countries-table th:last-child, #countries-table td:last-child { padding-right: 0; }
#countries-table td.country-cell { white-space: normal; overflow-wrap: anywhere; }
#countries-table .share-bar { width: 40px; margin-right: 6px; }
@media (max-width: 640px) {
  #countries-table th:nth-child(4), #countries-table td:nth-child(4), #countries-table .share-bar { display: none; }
  /* Live traffic on phones: country, new/returning and when (browser, OS and device have their own boxes above). */
  .live-card th:nth-child(2), .live-card td:nth-child(2), .live-card th:nth-child(3), .live-card td:nth-child(3),
  .live-card th:nth-child(4), .live-card td:nth-child(4) { display: none; }
  .live-card th, .live-card td { padding-left: 8px; padding-right: 8px; }
  .live-card td.country-cell { white-space: normal; overflow-wrap: anywhere; }
}
.world-map, .world-map.jvm-container { height: 340px; }
@media (max-width: 600px) { .world-map, .world-map.jvm-container { height: 220px; } .chart-wrap { height: 240px; } }
.jvm-tooltip { padding: 6px 10px !important; border-radius: 8px !important; background: #0F172A !important; font-family: var(--font-sans) !important; font-size: 12px !important; box-shadow: var(--shadow) !important; }
.table-plain { border: 0; border-radius: 0; background: none; }
.table-plain .table th { background: none; border-bottom: 1px solid var(--border); }
.table-plain .table th:first-child, .table-plain .table td:first-child { padding-left: 0; }
.table-plain .table th:last-child, .table-plain .table td:last-child { padding-right: 0; }
.country-cell { white-space: nowrap; }
.country-cell .fi { margin-right: 10px; font-size: 1.1rem; }
.share-col { width: 1%; white-space: nowrap; }
.share-bar { display: inline-block; width: 64px; height: 6px; margin-right: 8px; border-radius: 3px; background: var(--surface-2); vertical-align: middle; overflow: hidden; }
.share-bar span, .bar-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #818CF8); }
.share-pct { display: inline-block; width: 44px; color: var(--text-muted); font-size: var(--text-xs); text-align: right; font-variant-numeric: tabular-nums; }

.breakdown-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: var(--space-4); margin-bottom: var(--space-3); }
/* minmax(0, 1fr): a long label (a site's hostname) must shrink and ellipsize, not widen the list. */
.bar-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 0; padding: 0; list-style: none; }
.bar-head { display: flex; justify-content: space-between; gap: var(--space-3); margin-bottom: 5px; font-size: var(--text-sm); }
.bar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bar-value { flex: none; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.bar-track { display: block; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar-track span { background: linear-gradient(90deg, var(--accent), #38BDF8); }

.live-card { margin-top: var(--space-4); }
.live-card h2 { display: flex; align-items: center; gap: 10px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0 rgba(16, 185, 129, .5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
tr.is-new { animation: row-in .6s var(--ease); }
@keyframes row-in { from { background: var(--success-soft); opacity: 0; } to { background: transparent; opacity: 1; } }
.empty-inline { margin: var(--space-4) 0 0; }
.modal-wide { width: min(720px, calc(100vw - 32px)); }

/* ==========================================================================
   Edit, auth & dashboard
   ========================================================================== */

.auth-wrap { display: grid; place-items: center; padding-block: clamp(40px, 8vw, 96px); }
.auth-card { width: min(100%, 440px); padding: clamp(24px, 4vw, 36px); box-shadow: var(--shadow-lg); }
.auth-card .feature-icon { display: grid; }
.auth-title { margin-bottom: 8px; font-size: clamp(1.4rem, 1.2rem + .8vw, 1.75rem); text-align: center; overflow-wrap: anywhere; }
.auth-card .stack { margin-top: 20px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-subtle); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .08em; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-google { gap: 10px; }
.btn-google svg { width: 18px; height: 18px; }

.danger-zone { margin-top: var(--space-8); border-color: #FECACA; }
.danger-zone .card-title .icon-sm { color: var(--danger); }
.danger-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) 0; border-top: 1px solid var(--border); }
.danger-row:first-of-type { border-top: 0; }
.danger-row p { margin: 2px 0 0; }
.modal .label + .input { margin-top: 6px; }

.dashboard-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); padding-block: clamp(32px, 5vw, 56px) var(--space-6); }
.counter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: var(--space-5); }
.counter-card { display: flex; flex-direction: column; gap: var(--space-4); }
.counter-card-thumb { display: grid; place-items: center; height: 120px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); overflow: hidden; }
.counter-card-thumb img { max-width: 100%; max-height: 96px; width: auto; height: auto; object-fit: contain; }
.counter-card h3 { margin: 0; font-size: var(--text-lg); overflow-wrap: anywhere; }
.counter-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin: 0; }
.counter-stats div { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.counter-stats dt { color: var(--text-muted); font-size: var(--text-xs); }
.counter-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.sparkline { display: block; width: 100%; height: 40px; }
.counter-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: auto; }

/* ==========================================================================
   Long-form pages (about, privacy, terms)
   ========================================================================== */

.prose-page { padding-bottom: clamp(56px, 8vw, 96px); }
.prose { font-size: 1.0625rem; line-height: 1.75; color: #334155; }
.prose h2 { margin: 2.2em 0 .6em; font-size: 1.35rem; color: var(--text); }
.prose h2:first-child { margin-top: 0; }
.prose ul { padding-left: 1.25em; }
.prose li + li { margin-top: .5em; }
.prose li::marker { color: var(--primary); }
.prose strong { color: var(--text); }

/* ==========================================================================
   Error pages
   ========================================================================== */

.error-page { display: grid; place-items: center; padding-block: clamp(64px, 12vw, 140px); text-align: center; }
.error-code {
  font-family: var(--font-display);
  font-size: clamp(5rem, 3rem + 10vw, 9rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.05em;
  background: linear-gradient(120deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.error-page p { max-width: 460px; margin-inline: auto; }

/* ==========================================================================
   Motion preferences
   ========================================================================== */

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

/* ==========================================================================
   Guides, landing pages and calls to action
   ========================================================================== */

@media (max-width: 1000px) and (min-width: 761px) {
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
  .footer-about { grid-column: 1 / -1; }
}
.footer-contact { display: flex; align-items: center; gap: 6px; }
.footer-contact a { color: var(--text-muted); font-size: var(--text-sm); }
.footer-contact .footer-social { display: inline-flex; align-items: center; gap: 6px; }
.footer-contact .footer-social:hover { color: var(--text); }

.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: var(--space-6) 0 0; list-style: none; color: var(--text-muted); font-size: var(--text-sm); }
.breadcrumb li + li::before { content: "/"; margin-right: 6px; color: var(--border-strong); }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }
.breadcrumb + .page-header { padding-top: var(--space-6); }

.guide-example { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--space-6); margin: var(--space-8) 0; padding: var(--space-6); border-radius: var(--radius); background: var(--surface-2); text-align: center; }
.guide-example figure { margin: 0; }
.guide-example img { display: inline-block; max-width: 100%; height: auto; }
.guide-example figcaption { flex-basis: 100%; margin-top: var(--space-1); color: var(--text-muted); font-size: var(--text-sm); }
.example-pair figcaption { margin-top: var(--space-2); }

.prose .guide-steps { counter-reset: guide-step; padding: 0; list-style: none; }
.guide-steps li { position: relative; padding-left: 52px; }
.prose .guide-steps li + li { margin-top: var(--space-6); }
.guide-steps li::before {
  counter-increment: guide-step;
  content: counter(guide-step);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}
.guide-steps h3 { margin: 4px 0 4px; font-size: 1.1rem; }
.guide-steps p { margin: 0; }
.prose .code-block pre { white-space: pre-wrap; word-break: break-all; }
.prose .accordion { margin-top: var(--space-4); font-size: 1rem; }

.guide-cta { margin-top: var(--space-12); }
.guide-related { margin-top: var(--space-12); }
.guide-related h2 { margin-bottom: var(--space-4); font-size: 1.35rem; }
.guide-all { margin-top: var(--space-4); }
.guide-all a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.guide-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: var(--space-4); margin: 0; padding: 0; list-style: none; }
/* Ten guides: 5 × 2 on wide screens, two columns on tablets, one on phones. */
.guide-cards-wide { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) { .guide-cards-wide { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .guide-cards-wide { grid-template-columns: 1fr; } }
.guide-card { display: flex; flex-direction: column; gap: 6px; height: 100%; color: inherit; text-decoration: none; }
.guide-card strong { color: var(--text); }
.guide-cards-lg .guide-card { gap: var(--space-2); padding: var(--space-6); }
.guide-card-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: var(--space-2); border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary); }
.guide-card-more { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: var(--space-2); color: var(--primary); font-size: var(--text-sm); font-weight: 600; }
.guide-help { margin-top: var(--space-8); }
.guide-help h2 { margin: 0 0 var(--space-2); font-size: 1.2rem; }
.guide-help p { margin: 0; }
.guides-page .section-head { margin-bottom: var(--space-8); }

.stats-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); margin-top: var(--space-6); background: var(--primary-soft); border-color: #C7D2FE; }
.stats-cta > div { display: grid; gap: 2px; }
