/*
  AAmigo design system: framework-free CSS.

  For plain HTML sites (no React, no Tailwind). Self-contained: tokens, base
  element styles and aa- prefixed component classes. Values are copied from the
  shipped ibamigo components (components/ds, components/ui); see docs/DESIGN.md.

  In <head>:
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,700&family=DM+Sans:wght@600;700&family=Figtree:wght@400;500;600;700&display=swap">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.22/dist/katex.min.css">
    <link rel="stylesheet" href="aamigo.css">

  Specimen of every class: specimen.html
*/

/* ==========================================================================
   1. Tokens (identical to tokens/tokens.css)
   ========================================================================== */
:root {
  color-scheme: light;

  --font-sans: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --font-label: "DM Sans", "Figtree", system-ui, sans-serif;
  --font-math: "KaTeX_Main", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  --text-micro: 10.5px;
  --text-supporting: 12.5px;
  --text-body: 13.5px;
  --text-base: 14px;
  --text-card-title: 14px;
  --text-h2: 16px;
  --text-h1: 24px;
  --text-mkt-body: 15px;
  --text-mkt-h2: 30px;
  --text-hero: 46px;
  --text-math: 16px;

  --color-brand: #1a5fad;
  --color-brand-hover: #134a89;
  --color-brand-deep: #0b5a9e;
  --color-navy: #0f1f3d;
  --color-teal: #3dbfa8;
  --color-teal-hover: #2a9d8f;
  --color-teal-text: #007e6a;
  --color-amber: #f59e0b;
  --color-amber-deep: #92400e;

  --color-page: #f7f8fa;
  --color-tint: #f0f6ff;
  --color-panel: #f8fafc;
  --color-panel-2: #f1f5f9;
  --color-line: #e2e8f0;
  --color-line-soft: #f1f5f9;
  --color-white: #ffffff;

  --color-ink: #0f1f3d;
  --color-ink-2: #334155;
  --color-muted: #475569;
  --color-faint: #616f83;
  --color-faint-deco: #94a3b8;
  --color-faint-2: #cbd5e1;
  --color-on-dark-muted: #b7c6de;

  --color-easy-bg: #eafaf5;
  --color-easy-fg: #007f5c;
  --color-medium-bg: #fff4e8;
  --color-medium-fg: #92400e;
  --color-hard-bg: #feeceb;
  --color-hard-fg: #be4137;
  --color-paper-bg: #eef5fb;
  --color-paper-border: #cfe0ee;
  --color-paper-fg: #0b5a9e;
  --color-neutral-tag-bg: #eef1f4;
  --color-neutral-tag-fg: #5b6472;
  --color-danger-bg: #fee2e2;
  --color-danger-fg: #b83b32;
  --color-danger-hover: #fca5a5;
  --color-danger-line: #fececa;
  --color-error: #d92c32;
  --color-pdf-stage: #525659;

  --space-4: 4px;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-20: 20px;
  --space-24: 24px;
  --space-32: 32px;
  --space-40: 40px;
  --space-48: 48px;
  --space-64: 64px;
  --space-80: 80px;
  --card-padding: 24px;
  --app-main-padding: 28px 36px;
  --sidebar-width-expanded: 232px;
  --sidebar-width-collapsed: 68px;

  --radius-tag: 6px;
  --radius-sm: 8px;
  --radius-input: 10px;
  --radius-nested: 12px;
  --radius-card: 16px;
  --radius-card-lg: 20px;
  --radius-marketing: 24px;
  --radius-pill: 999px;

  --shadow-card-hover: 0 4px 10px rgba(15, 31, 61, 0.08);
  --shadow-nav-active: 0 4px 10px rgba(26, 95, 173, 0.25);
  --shadow-popover: 0 8px 20px rgba(15, 31, 61, 0.1);
  --shadow-modal: 0 20px 40px rgba(15, 31, 61, 0.25);
  --shadow-float: 0 8px 20px rgba(15, 31, 61, 0.14);
  --shadow-lift: 0 12px 28px rgba(15, 31, 61, 0.1);
  --shadow-segment: 0 1px 2px rgba(0, 0, 0, 0.06);
  --focus-ring: 0 0 0 3px rgba(26, 95, 173, 0.12);

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-standard: cubic-bezier(0.3, 0.7, 0.4, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-base: 200ms;
  --duration-sidebar: 250ms;
  --duration-progress: 500ms;
  --duration-reveal: 800ms;
}

/* ==========================================================================
   2. Base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--color-page);
  color: var(--color-ink);
  font-size: var(--text-base);
  line-height: 1.5;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-ink);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

a {
  color: var(--color-brand);
}

::selection {
  background: rgba(61, 191, 168, 0.35);
  color: var(--color-navy);
}

input,
select,
textarea,
button {
  font-family: inherit;
}

input::placeholder,
textarea::placeholder {
  color: var(--color-faint);
}

:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
  border-radius: 6px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-faint-2) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--color-faint-2);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--color-faint-deco);
  border: 3px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

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

/* ==========================================================================
   3. Type helpers
   ========================================================================== */
.aa-display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Uppercase micro label: DM Sans 700, 10.5px, tracked */
.aa-label-caps {
  font-family: var(--font-label);
  font-size: var(--text-micro);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  white-space: nowrap;
}

.aa-text-muted { color: var(--color-muted); }
.aa-text-faint { color: var(--color-faint); }
.aa-text-teal { color: var(--color-teal-text); }
.aa-text-brand { color: var(--color-brand); }

/* ==========================================================================
   4. Buttons
   Every variant is a pill; hover is a plain colour shift.
   <button class="aa-btn">, <a class="aa-btn aa-btn--secondary">
   ========================================================================== */
.aa-btn {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--color-brand);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--duration-base), color var(--duration-base), border-color var(--duration-base);
}
.aa-btn:hover { background: var(--color-brand-hover); }
.aa-btn:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; border-radius: var(--radius-pill); }
.aa-btn svg { width: 16px; height: 16px; flex-shrink: 0; pointer-events: none; }

.aa-btn--secondary {
  background: #fff;
  color: var(--color-brand);
  border: 1.5px solid var(--color-brand);
}
.aa-btn--secondary:hover { background: var(--color-brand); color: #fff; }

.aa-btn--ghost { background: transparent; color: var(--color-muted); }
.aa-btn--ghost:hover { background: var(--color-line); color: var(--color-ink); }

.aa-btn--accent { background: var(--color-teal); color: var(--color-navy); }
.aa-btn--accent:hover { background: var(--color-teal-hover); }

.aa-btn--soft { background: var(--color-panel-2); color: var(--color-ink-2); }
.aa-btn--soft:hover { background: var(--color-line); color: var(--color-ink); }

.aa-btn--destructive { background: var(--color-danger-bg); color: var(--color-danger-fg); }
.aa-btn--destructive:hover { background: var(--color-danger-hover); }

/* On the blue continue tile or the navy band */
.aa-btn--on-dark { background: #fff; color: var(--color-brand); }
.aa-btn--on-dark:hover { background: rgba(255, 255, 255, 0.9); }
.aa-btn--on-dark-outline {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.aa-btn--on-dark-outline:hover { background: rgba(255, 255, 255, 0.25); }
.aa-btn--on-dark:focus-visible,
.aa-btn--on-dark-outline:focus-visible { outline-color: #fff; }

.aa-btn--link {
  height: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-brand);
  text-underline-offset: 4px;
}
.aa-btn--link:hover { background: transparent; text-decoration: underline; }

.aa-btn--xs { height: 28px; padding: 0 12px; font-size: 12px; }
.aa-btn--sm { height: 32px; padding: 0 16px; font-size: 12.5px; }
.aa-btn--lg { height: 44px; padding: 0 24px; font-size: 14px; }
.aa-btn--icon { width: 40px; padding: 0; }
.aa-btn--icon.aa-btn--sm { width: 32px; }
.aa-btn--icon.aa-btn--xs { width: 28px; }
.aa-btn--icon.aa-btn--lg { width: 44px; }

.aa-btn:disabled,
.aa-btn[aria-disabled="true"] {
  background: var(--color-panel-2);
  color: var(--color-muted);
  border-color: transparent;
  cursor: not-allowed;
  pointer-events: none;
}

/* Touch screens: small controls get an invisible hit area of at least 44px */
@media (pointer: coarse) {
  .aa-btn::after { content: ""; position: absolute; inset: -2px; }
  .aa-btn--sm::after { inset: -6px; }
  .aa-btn--xs::after { inset: -8px; }
  .aa-btn--lg::after { content: none; }
}

/* ==========================================================================
   5. Filter pills
   <button class="aa-pill" aria-pressed="true">All <span class="aa-pill__count">146</span></button>
   ========================================================================== */
.aa-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-pill);
  background: #fff;
  color: var(--color-ink-2);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--duration-base), color var(--duration-base), border-color var(--duration-base);
}
.aa-pill:hover { border-color: var(--color-brand); color: var(--color-brand); }
.aa-pill[aria-pressed="true"],
.aa-pill.is-active {
  background: var(--color-navy);
  border-color: var(--color-navy);
  color: #fff;
  font-weight: 700;
}
.aa-pill__count { font-size: 11.5px; font-weight: 600; color: var(--color-faint); }
.aa-pill[aria-pressed="true"] .aa-pill__count,
.aa-pill.is-active .aa-pill__count { color: rgba(255, 255, 255, 0.8); }
.aa-pill-divider { display: inline-block; width: 1px; height: 18px; margin: 0 2px; background: var(--color-line); }
.aa-pill-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ==========================================================================
   6. Tags
   <span class="aa-tag aa-tag--easy">Easy</span>
   ========================================================================== */
.aa-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-tag);
  background: var(--color-panel-2);
  color: var(--color-muted);
  font-family: var(--font-label);
  font-size: var(--text-micro);
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}
.aa-tag--easy { background: var(--color-easy-bg); color: var(--color-easy-fg); text-transform: uppercase; }
.aa-tag--medium { background: var(--color-medium-bg); color: var(--color-medium-fg); text-transform: uppercase; }
.aa-tag--hard { background: var(--color-hard-bg); color: var(--color-hard-fg); text-transform: uppercase; }
.aa-tag--paper { background: var(--color-paper-bg); color: var(--color-paper-fg); border: 1px solid var(--color-paper-border); }
.aa-tag--level { background: var(--color-brand); color: #fff; }
.aa-tag--calc { background: var(--color-paper-bg); color: var(--color-paper-fg); text-transform: uppercase; }
.aa-tag--nocalc { background: var(--color-neutral-tag-bg); color: var(--color-neutral-tag-fg); text-transform: uppercase; }
.aa-tag--teal { background: var(--color-easy-bg); color: var(--color-easy-fg); }
.aa-tag--reference {
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  background: var(--color-tint);
  color: var(--color-brand);
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.aa-tag--soon {
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--color-medium-bg);
  color: var(--color-medium-fg);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.aa-tag--new {
  padding: 1px 6px;
  background: var(--color-easy-bg);
  color: var(--color-easy-fg);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   7. Cards and panels
   ========================================================================== */
.aa-card {
  background: #fff;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  padding: var(--card-padding);
}
.aa-card--lg { border-radius: var(--radius-card-lg); }
.aa-card--marketing { border-radius: var(--radius-marketing); }
.aa-card--flush { padding: 0; }
.aa-card--nested {
  background: var(--color-panel);
  border-radius: var(--radius-nested);
  padding: 16px;
}
.aa-card--tint { background: var(--color-tint); border-color: transparent; }

/* Clickable list cards: teal border and the card-hover shadow, no lift */
.aa-card--interactive {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color var(--duration-base) ease, box-shadow var(--duration-base) ease;
}
.aa-card--interactive:hover { border-color: var(--color-teal); box-shadow: var(--shadow-card-hover); }

/* Landing feature tiles only: may lift 4 to 6px with a neutral shadow */
.aa-tile-lift { transition: transform 300ms var(--ease-out-expo), box-shadow 300ms var(--ease-out-expo); }
.aa-tile-lift:hover { transform: translateY(-5px); box-shadow: var(--shadow-lift); }
@media (prefers-reduced-motion: reduce) {
  .aa-tile-lift:hover { transform: none; }
}

.aa-card__title { margin: 0; font-family: var(--font-display); font-size: var(--text-card-title); font-weight: 700; color: var(--color-ink); }
.aa-card__text { margin: 4px 0 0; font-size: var(--text-supporting); color: var(--color-muted); }

/* Solid brand "continue" tile */
.aa-continue-tile {
  background: var(--color-brand);
  color: #fff;
  border-radius: var(--radius-card-lg);
  padding: var(--card-padding);
}
.aa-continue-tile h2,
.aa-continue-tile h3 { color: #fff; }

/* Navy band: the only large dark block (landing CTA) */
.aa-band-navy {
  position: relative;
  background: var(--color-navy);
  color: #fff;
}
.aa-band-navy h2,
.aa-band-navy h3 { color: #fff; }
.aa-band-navy p { color: var(--color-on-dark-muted); }

/* Icon box: 36px soft rounded square */
.aa-iconbox {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--color-tint);
  color: var(--color-brand);
}
.aa-iconbox svg { width: 18px; height: 18px; }
.aa-iconbox--panel { background: var(--color-panel-2); color: var(--color-ink-2); }
.aa-iconbox--danger { background: var(--color-hard-bg); color: var(--color-danger-fg); }
.aa-iconbox--easy { background: var(--color-easy-bg); color: var(--color-easy-fg); }
.aa-iconbox--navy { background: var(--color-navy); color: #fff; }

/* ==========================================================================
   8. Forms
   ========================================================================== */
.aa-field { display: flex; flex-direction: column; gap: 6px; }
.aa-label { font-size: 12.5px; font-weight: 600; color: var(--color-ink-2); }
.aa-help { font-size: 12px; color: var(--color-faint); }
.aa-field-error { font-size: 12px; font-weight: 600; color: var(--color-error); }

.aa-input,
.aa-textarea,
.aa-select {
  display: block;
  width: 100%;
  height: 40px;
  padding: 8px 12px;
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-input);
  background: #fff;
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
  transition: border-color var(--duration-base), box-shadow var(--duration-base);
}
.aa-textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.aa-select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23616F83' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.aa-input:hover,
.aa-textarea:hover,
.aa-select:hover { border-color: var(--color-faint-2); }
.aa-input:focus-visible,
.aa-textarea:focus-visible,
.aa-select:focus-visible {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: var(--focus-ring);
}
.aa-input[aria-invalid="true"],
.aa-textarea[aria-invalid="true"],
.aa-select[aria-invalid="true"] { border-color: var(--color-error); }
.aa-input:disabled,
.aa-textarea:disabled,
.aa-select:disabled { background: var(--color-panel-2); color: var(--color-muted); cursor: not-allowed; }

/* Search: icon + input inside one bordered box
   <label class="aa-search"><svg>...</svg><input type="search" placeholder="Search"></label> */
.aa-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  padding: 9px 14px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-input);
  background: #fff;
  transition: border-color var(--duration-base), box-shadow var(--duration-base);
}
.aa-search:focus-within { border-color: var(--color-brand); box-shadow: var(--focus-ring); }
.aa-search svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--color-faint-deco); }
.aa-search input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--color-ink);
  font-size: 13px;
}
.aa-search input::-webkit-search-cancel-button { display: none; }

/* Checkbox: 16px, 6px radius, fills brand */
.aa-checkbox {
  appearance: none;
  display: inline-grid;
  place-content: center;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1.5px solid var(--color-faint);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: background-color var(--duration-base), border-color var(--duration-base);
}
.aa-checkbox::before {
  content: "";
  width: 10px;
  height: 10px;
  background: #fff;
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 24%, 86% 10%, 38% 72%);
  transform: scale(0);
}
.aa-checkbox:checked { background: var(--color-brand); border-color: var(--color-brand); }
.aa-checkbox:checked::before { transform: scale(1); }
.aa-checkbox:disabled { opacity: 0.5; cursor: not-allowed; }

/* Switch: 36x20, brand when on (add aa-switch--teal for completion toggles)
   <input type="checkbox" role="switch" class="aa-switch"> */
.aa-switch {
  appearance: none;
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 36px;
  height: 20px;
  margin: 0;
  border-radius: var(--radius-pill);
  background: var(--color-line);
  cursor: pointer;
  transition: background-color var(--duration-base);
}
.aa-switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 31, 61, 0.2);
  transition: transform var(--duration-base) var(--ease-standard);
}
.aa-switch:checked { background: var(--color-brand); }
.aa-switch--teal:checked { background: var(--color-teal); }
.aa-switch:checked::before { transform: translateX(16px); }
.aa-switch:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==========================================================================
   9. Segmented control (SL/HL level toggle, view switchers)
   <div class="aa-segmented" role="radiogroup" aria-label="Level" style="--count:2; --index:0">
     <span class="aa-segmented__thumb" aria-hidden="true"></span>
     <button type="button" role="radio" aria-checked="true">SL</button>
     <button type="button" role="radio" aria-checked="false">HL</button>
   </div>
   Set --index on the wrapper when the choice changes. The thumb slides 200ms.
   ========================================================================== */
.aa-segmented {
  position: relative;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  min-width: 88px;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: var(--color-panel-2);
}
.aa-segmented__thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc((100% - 4px) / var(--count, 2));
  border-radius: var(--radius-pill);
  background: var(--color-brand);
  transform: translateX(calc(100% * var(--index, 0)));
  transition: transform var(--duration-base) var(--ease-standard);
}
.aa-segmented > button {
  position: relative;
  z-index: 1;
  padding: 4px 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-ink);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--duration-base);
}
.aa-segmented > button:hover { color: var(--color-brand); }
.aa-segmented > button[aria-checked="true"],
.aa-segmented > button[aria-selected="true"] { color: #fff; }
.aa-segmented--md { min-width: 120px; }
.aa-segmented--md > button { padding: 5px 14px; font-size: 12px; }

/* Tab variant: one white highlight on grey, dark text */
.aa-segmented--tabs { border-radius: var(--radius-nested); padding: 3px; }
.aa-segmented--tabs .aa-segmented__thumb {
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / var(--count, 2));
  border-radius: 9px;
  background: #fff;
  box-shadow: var(--shadow-segment);
}
.aa-segmented--tabs > button { padding: 6px 14px; border-radius: 9px; color: var(--color-muted); font-size: 13px; font-weight: 600; }
.aa-segmented--tabs > button:hover { color: var(--color-ink); }
.aa-segmented--tabs > button[aria-checked="true"],
.aa-segmented--tabs > button[aria-selected="true"] { color: var(--color-ink); }

@media (prefers-reduced-motion: reduce) {
  .aa-segmented__thumb { transition: none; }
}

/* ==========================================================================
   10. Progress, streaks
   ========================================================================== */
/* <span class="aa-progress" style="--value:62"><span class="aa-progress__fill"></span></span> */
.aa-progress {
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--color-panel-2);
}
.aa-progress__fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--color-brand);
  transform: translateX(calc(var(--value, 0) * 1% - 100%));
  transition: transform var(--duration-progress) var(--ease-standard);
}
.aa-progress--teal .aa-progress__fill { background: var(--color-teal); }
.aa-progress--amber .aa-progress__fill { background: var(--color-amber); }
.aa-progress--white .aa-progress__fill { background: #fff; }
.aa-progress--on-dark { background: rgba(255, 255, 255, 0.25); }
@media (prefers-reduced-motion: reduce) {
  .aa-progress__fill { transition: none; }
}

/* <div class="aa-streak" role="img" aria-label="4 of 7 days"><span class="is-lit"></span>...</div> */
.aa-streak { display: flex; gap: 4px; }
.aa-streak > span {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--color-line);
  border-radius: 50%;
  background: #fff;
  transition: background-color 300ms, border-color 300ms;
}
.aa-streak > span.is-lit { background: var(--color-amber); border-color: var(--color-amber); }
.aa-streak--teal > span.is-lit { background: var(--color-teal); border-color: var(--color-teal); }

/* ==========================================================================
   11. Navigation: breadcrumbs, page header, section heading
   ========================================================================== */
.aa-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--color-faint);
}
.aa-breadcrumbs li + li::before { content: "/"; margin: 0 6px; color: var(--color-faint); font-weight: 400; }
.aa-breadcrumbs a { color: inherit; text-decoration: none; transition: color var(--duration-base); }
.aa-breadcrumbs a:hover { color: var(--color-brand); }
.aa-breadcrumbs [aria-current="page"] { font-weight: 600; color: var(--color-ink); }

.aa-page-header { display: flex; flex-direction: column; gap: 20px; }
.aa-page-header__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.aa-page-header h1 { margin: 0; font-size: var(--text-h1); }
.aa-page-header__subtitle { margin: 6px 0 0; font-size: 13.5px; color: var(--color-muted); }

.aa-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.aa-section-heading h2 { margin: 0; font-size: var(--text-h2); }
.aa-section-heading p { margin: 4px 0 0; font-size: var(--text-supporting); color: var(--color-muted); }

/* ==========================================================================
   12. Amigo tip and avatars
   ========================================================================== */
.aa-avatar {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-navy);
  color: #fff;
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 700;
}
.aa-avatar--tint { background: var(--color-tint); color: var(--color-brand); }
.aa-avatar--lg { width: 40px; height: 40px; font-size: 13px; }
.aa-avatar-group { display: flex; }
.aa-avatar-group > .aa-avatar + .aa-avatar { margin-left: -8px; box-shadow: 0 0 0 2px #fff; }

.aa-tip { display: flex; align-items: flex-start; gap: 10px; }
.aa-tip__bubble {
  position: relative;
  padding: 12px 14px;
  border: 1px solid var(--color-line);
  border-radius: 14px;
  background: #fff;
  color: var(--color-ink-2);
  font-size: 12px;
  line-height: 1.625;
}
.aa-tip__bubble::before {
  content: "";
  position: absolute;
  top: 9px;
  left: -6px;
  width: 11px;
  height: 11px;
  border-bottom: 1px solid var(--color-line);
  border-left: 1px solid var(--color-line);
  background: #fff;
  transform: rotate(45deg);
}

/* ==========================================================================
   13. System states: empty, skeleton, toast, tooltip, menu
   ========================================================================== */
.aa-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  padding: 32px 20px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  background: #fff;
  text-align: center;
}
.aa-empty__title { font-family: var(--font-display); font-size: 17px; font-weight: 700; color: var(--color-ink); }
.aa-empty__text { max-width: 240px; margin: 6px 0 0; font-size: 12.5px; color: var(--color-muted); }
.aa-empty__action { margin-top: 16px; }
.aa-empty--dashed { border: 1.5px dashed var(--color-line); background: var(--color-panel); }
.aa-empty--dashed .aa-empty__title,
.aa-empty--dashed .aa-empty__text { color: var(--color-faint); }

/* Flat skeleton, no shimmer: fades in after a beat, breathes if the wait goes on */
.aa-skeleton {
  display: block;
  border-radius: 8px;
  background: var(--color-panel-2);
  animation: aa-fade-in 150ms ease-out 120ms both;
}
@media (prefers-reduced-motion: no-preference) {
  .aa-skeleton {
    animation:
      aa-fade-in 150ms ease-out 120ms both,
      aa-breathe 1.4s ease-in-out 1.2s infinite alternate;
  }
}
.aa-content-in { animation: aa-fade-in 200ms var(--ease-out-expo) backwards; }

/* Toast: navy for success and info, white with a red line for errors */
.aa-toast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: var(--radius-nested);
  background: var(--color-navy);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-popover);
  animation: aa-rise-in 200ms var(--ease-out-expo) both;
}
.aa-toast--error { background: #fff; color: var(--color-navy); border: 1px solid var(--color-danger-line); }
.aa-toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.aa-toast--success svg { color: var(--color-teal); }
.aa-toast--error svg { color: var(--color-error); }

/* Tooltip: navy, 12px text */
.aa-tooltip {
  display: inline-flex;
  align-items: center;
  max-width: 320px;
  padding: 6px 12px;
  border-radius: var(--radius-input);
  background: var(--color-navy);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
}

/* Dropdown / popover menu */
.aa-menu {
  min-width: 8rem;
  padding: 6px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-nested);
  background: #fff;
  color: var(--color-ink);
  box-shadow: var(--shadow-popover);
  animation: aa-slide-in 150ms var(--ease-out-expo) both;
}
.aa-menu__item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--duration-base), color var(--duration-base);
}
.aa-menu__item:hover,
.aa-menu__item:focus-visible { background: var(--color-tint); color: var(--color-brand); outline: none; }
.aa-menu__item--danger { color: var(--color-error); }
.aa-menu__separator { height: 1px; margin: 6px -6px; background: var(--color-line); }

/* ==========================================================================
   14. Modal (native <dialog>)
   <dialog class="aa-modal"><div class="aa-modal__header">...</div><div class="aa-modal__body">...</div></dialog>
   Open with dialog.showModal(). Escape closes it natively.
   ========================================================================== */
.aa-modal {
  width: calc(100% - 32px);
  max-width: 560px;
  max-height: 92dvh;
  padding: 0;
  border: 0;
  border-radius: var(--radius-card);
  background: #fff;
  color: var(--color-ink);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}
.aa-modal[open] { display: flex; flex-direction: column; animation: aa-modal-in 200ms var(--ease-out-expo) both; }
.aa-modal::backdrop { background: rgba(15, 31, 61, 0.5); animation: aa-fade-in 150ms ease-out both; }
.aa-modal--sm { max-width: 420px; }
.aa-modal--lg { max-width: 820px; }
.aa-modal--xl { max-width: 1040px; }
.aa-modal__header {
  display: flex;
  flex-shrink: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-line);
}
.aa-modal__title { margin: 0; font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--color-ink); }
.aa-modal__description { margin: 4px 0 0; font-size: 12.5px; color: var(--color-muted); }
.aa-modal__close {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  transition: background-color var(--duration-base), color var(--duration-base);
}
.aa-modal__close:hover { background: var(--color-panel-2); color: var(--color-ink); }
.aa-modal__close svg { width: 16px; height: 16px; }
.aa-modal__body { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; }
.aa-modal__footer {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--color-line);
}

/* ==========================================================================
   15. Math
   ========================================================================== */
/* Question body typography: real KaTeX, serif reading rhythm */
.aa-math-body {
  font-family: var(--font-math);
  font-size: var(--text-math);
  line-height: 1.9;
  color: var(--color-ink);
}
.aa-math-body .katex { font-size: 1em; }
.aa-math-body p { margin: 0 0 14px; }
.aa-math-body p:last-child { margin-bottom: 0; }
.aa-math-body .katex-display { margin: 12px 0; }
.aa-marks { float: right; margin-left: 16px; font-family: var(--font-sans); font-size: 12.5px; font-weight: 600; color: var(--color-muted); }

.katex { font-size: 1.05em; }
/* Long display math scrolls in its own box instead of widening the page */
.katex-display { max-width: 100%; overflow-x: auto; overflow-y: hidden; padding-block: 0.25em; }

/* ==========================================================================
   16. Decorative surfaces (landing, auth)
   ========================================================================== */
/* 40px math grid behind a section */
.aa-mg-surface,
.aa-mg-surface-dark { position: relative; isolation: isolate; }
.aa-mg-surface::after,
.aa-mg-surface-dark::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-size: 40px 40px;
}
.aa-mg-surface::after {
  background-image: linear-gradient(rgba(15, 31, 61, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 31, 61, 0.06) 1px, transparent 1px);
}
.aa-mg-surface-dark::after {
  background-image: linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
}

/* Faded floating math glyphs. Position each span inline (top/left, font-size,
   color, opacity 0.12 to 0.2, rotate -14 to 12deg); see docs for the sets. */
.aa-mathsym-layer {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}
.aa-mathsym-layer > span { position: absolute; font-family: var(--font-math); line-height: 1; }

/* Scroll reveal: add .is-visible with an IntersectionObserver.
   Content stays visible without JavaScript and with reduced motion. */
.aa-reveal {
  opacity: 0;
  transform: translateY(26px) scale(0.96);
  transition: opacity var(--duration-reveal) var(--ease-out-expo), transform var(--duration-reveal) var(--ease-out-expo);
}
.aa-reveal.is-visible { opacity: 1; transform: none; }
@media (scripting: none), (prefers-reduced-motion: reduce) {
  .aa-reveal { opacity: 1; transform: none; transition: none; }
}

/* ==========================================================================
   17. Keyframes and reduced motion
   ========================================================================== */
@keyframes aa-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes aa-breathe { from { opacity: 1; } to { opacity: 0.55; } }
@keyframes aa-rise-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes aa-slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes aa-modal-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .aa-toast { animation-name: aa-fade-in; }
  .aa-menu { animation-name: aa-fade-in; }
  .aa-modal[open] { animation-name: aa-fade-in; }
  .aa-btn,
  .aa-pill,
  .aa-card--interactive { transition-duration: 0ms; }
}

/* ==========================================================================
   18. Marketing: nav, hero, sections, CTA band, footer
   Copied from components/marketing in ibamigo. The hero card float and the
   feature-tile hover choreography are in css/landing.css (plain CSS).
   ========================================================================== */
.aa-section { padding: 64px 20px; }
.aa-eyebrow {
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-teal-text);
  white-space: nowrap;
}
.aa-section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--color-ink);
}
.aa-lede { max-width: 400px; margin: 20px 0 0; font-size: 15px; line-height: 1.6; color: var(--color-muted); }

/* Text links in the nav and footer: a teal underline grows in on hover */
.aa-link-underline {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: text-decoration-color 300ms ease-out, color 300ms ease-out;
}
.aa-link-underline:hover { color: var(--color-brand); text-decoration-color: var(--color-teal); }

/* A key word in a headline */
.aa-underline-teal {
  text-decoration: underline;
  text-decoration-color: var(--color-teal);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* Marketing CTAs: blue pill with a 2px border that turns teal on hover */
.aa-btn--marketing { border: 2px solid var(--color-brand); transition-duration: 300ms; }
.aa-btn--marketing:hover { border-color: var(--color-teal); background: var(--color-teal); color: var(--color-navy); }
.aa-btn--hero { height: auto; padding: 10px 22px; }
.aa-btn--nav { height: 36px; padding: 0 19px; font-size: 13px; }

/* Sticky white nav */
.aa-nav { position: sticky; top: 0; z-index: 50; background: #fff; }
.aa-nav__inner { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; }
.aa-nav__left { display: flex; align-items: center; gap: 40px; }
.aa-nav__brand { display: flex; align-items: center; }
.aa-nav__brand img { display: block; width: auto; height: 28px; }
.aa-nav__links,
.aa-nav__actions { display: none; align-items: center; }
.aa-nav__links { gap: 32px; }
.aa-nav__actions { gap: 16px; }
.aa-nav__link {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--color-muted);
  white-space: nowrap;
}
.aa-nav__login {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-ink-2);
  white-space: nowrap;
  text-decoration: none;
  transition: color 300ms;
}
.aa-nav__login:hover { color: var(--color-brand); }
.aa-nav__menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
  transition: background-color var(--duration-base);
}
.aa-nav__menu-btn:hover { background: var(--color-panel-2); }
.aa-nav__menu-btn svg { width: 20px; height: 20px; }
.aa-nav__mobile { padding: 8px 20px 20px; border-top: 1px solid var(--color-line); background: #fff; }
.aa-nav__mobile-link {
  display: block;
  padding: 12px 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-ink-2);
  text-decoration: none;
  transition: color var(--duration-base);
}
.aa-nav__mobile-link:hover { color: var(--color-brand); }
.aa-nav__mobile-actions { display: flex; gap: 12px; margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--color-line); }
.aa-nav__mobile-actions > .aa-btn { flex: 1; }

/* Hero on the tinted math grid */
.aa-hero { position: relative; overflow: hidden; background: var(--color-tint); }
.aa-hero__inner { position: relative; z-index: 1; display: grid; align-items: center; gap: 24px; padding: 32px 20px 64px; }
.aa-hero__copy { padding-top: 24px; }
.aa-hero-pill {
  display: inline-block;
  margin-bottom: 28px;
  padding: 8px 16px;
  border: 1px solid var(--color-line);
  border-radius: 24px;
  background: #fff;
  color: var(--color-muted);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  animation: aa-pill-pop 700ms var(--ease-spring) both;
}
.aa-hero-title {
  max-width: 560px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--color-ink);
}
@keyframes aa-pill-pop {
  0% { opacity: 0; transform: rotate(-2deg) scale(0.85) translateY(24px); }
  65% { opacity: 1; transform: rotate(-2deg) scale(1.05) translateY(3px); }
  100% { opacity: 1; transform: rotate(-2deg) scale(1) translateY(7px); }
}

/* Navy CTA band with a white feedback card */
.aa-cta-band {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 64px 20px;
  background: var(--color-navy);
  color: #fff;
  text-align: center;
}
.aa-cta-band__title { margin: 0; font-size: 28px; color: #fff; }
.aa-cta-band__text { max-width: 420px; margin: 16px auto 0; font-size: 14.5px; line-height: 1.6; color: var(--color-on-dark-muted); }
.aa-feedback-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
  max-width: 820px;
  margin: 48px auto 0;
  padding: 24px;
  border-radius: var(--radius-card);
  background: #fff;
  color: var(--color-ink);
  text-align: left;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.aa-feedback-card__title { font-size: 14.5px; font-weight: 700; color: var(--color-ink); }
.aa-feedback-card__text { margin-top: 4px; font-size: 13px; color: var(--color-muted); }

/* Footer */
.aa-footer { padding: 40px 20px 24px; border-top: 1px solid var(--color-line); background: #fff; }
.aa-footer__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 24px; }
.aa-footer__about { grid-column: span 2; }
.aa-footer__about img { display: block; width: auto; height: 22px; }
.aa-footer__blurb { max-width: 280px; margin: 12px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--color-muted); }
.aa-footer__heading { margin: 0 0 12px; font-family: var(--font-display); font-size: 13.5px; font-weight: 700; color: var(--color-ink); }
.aa-footer__links { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.aa-footer__links a,
.aa-footer__links button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-muted);
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.aa-footer__bottom { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--color-line); font-size: 12px; color: var(--color-muted); }

@media (min-width: 640px) {
  .aa-feedback-card { flex-direction: row; align-items: center; justify-content: space-between; }
}
@media (min-width: 768px) {
  .aa-section { padding: 96px 40px; }
  .aa-section-title { font-size: 32px; }
  .aa-nav__inner { padding: 18px 40px; }
  .aa-nav__links,
  .aa-nav__actions { display: flex; }
  .aa-nav__menu-btn,
  .aa-nav__mobile { display: none !important; }
  .aa-hero__inner { padding: 8px 40px 140px; }
  .aa-hero__copy { padding-top: 40px; }
  .aa-hero-title { font-size: 46px; }
  .aa-cta-band { padding: 80px 40px; }
  .aa-cta-band__title { font-size: 36px; }
  .aa-feedback-card { padding: 24px 32px; }
  .aa-footer { padding: 56px 40px 32px; }
  .aa-footer__grid { grid-template-columns: 1.6fr 1fr 1fr; }
  .aa-footer__about { grid-column: span 1; }
  .aa-footer__blurb { margin-top: 16px; }
  .aa-footer__heading { margin-bottom: 16px; }
  .aa-footer__links { gap: 12px; }
  .aa-footer__bottom { margin-top: 40px; padding-top: 24px; }
}
@media (min-width: 1024px) {
  .aa-hero__inner { grid-template-columns: 1.15fr 0.85fr; }
}
@media (prefers-reduced-motion: reduce) {
  .aa-hero-pill { animation: none; transform: rotate(-2deg) translateY(7px); }
}
