/* ============================================================
   RESET & BASE
============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Brand: deep burnt orange with full tonal range ── */
  --brand:        #CA4F00;
  --brand-dk:     #B84D12;
  --brand-lt:     #FEF2E8;
  --brand-mid:    #CA4F00;
  --brand-subtle: rgba(232, 104, 42, 0.08);
  --brand-glow:   rgba(232, 104, 42, 0.22);

  /* ── Ink system: near-black with zinc tones ── */
  --ink:   #141417;
  --ink-2: #3a3a42;
  --ink-3: #6c6c78;
  --ink-4: #9c9ca8;
  --ink-5: #c8c8d2;

  /* ── Surfaces ── */
  --white:     #ffffff;
  --surface:   #f9f9fb;
  --surface-2: #f3f3f6;
  --surface-3: #ebebef;
  --line:      #e2e2e8;
  --line-2:    #f0f0f4;

  /* ── Radius scale ── */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;
  --r-2xl:28px;

  /* ── Shadows ── */
  --sh-xs:    0 1px 2px rgba(0,0,0,.05);
  --sh-sm:    0 2px 8px rgba(0,0,0,.07),  0 1px 2px rgba(0,0,0,.04);
  --sh-md:    0 6px 20px rgba(0,0,0,.09), 0 2px 6px rgba(0,0,0,.05);
  --sh-lg:    0 16px 48px rgba(0,0,0,.13),0 4px 12px rgba(0,0,0,.06);
  --sh-xl:    0 28px 72px rgba(0,0,0,.18),0 8px 24px rgba(0,0,0,.08),0 2px 6px rgba(0,0,0,.04);
  --sh-brand: 0 6px 22px rgba(232,104,42,.34),0 2px 6px rgba(232,104,42,.18);
  --sh-brand-lg: 0 12px 36px rgba(232,104,42,.40),0 4px 10px rgba(232,104,42,.22);

  /* ── Typography ── */
  --font:      'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', 'Fira Code', monospace;

  /* ── Easing ── */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-std:    cubic-bezier(0.4, 0, 0.2, 1);
  --t:           all .18s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font);
  background: #eae7e1;
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   DEMO PAGE
============================================================ */
.demo {
  max-width: 880px;
  margin: 0 auto;
  padding: 80px 32px 180px;
}

/* Pulsing badge */
.demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--brand);
  background: var(--brand-lt);
  border: 1.5px solid rgba(232,104,42,.20);
  border-radius: 100px;
  padding: 5px 14px 5px 10px;
  margin-bottom: 26px;
}

.demo-badge span {
  width: 7px; height: 7px;
  background: var(--brand);
  border-radius: 50%;
  display: block;
  animation: pulse-dot 2.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 0 0 rgba(232,104,42,.4); }
  50%      { box-shadow: 0 0 0 5px rgba(232,104,42,.0); }
}

.demo h1 {
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.06;
  color: var(--ink);
  margin-bottom: 18px;
}

.demo h1 mark {
  background: none;
  color: var(--brand);
  position: relative;
}

.demo-lead {
  font-size: 1.05rem;
  color: var(--ink-3);
  max-width: 500px;
  margin-bottom: 52px;
  line-height: 1.78;
  font-weight: 400;
}

.demo-lead kbd {
  background: var(--white);
  border: 1px solid var(--line);
  border-bottom-width: 2.5px;
  border-radius: 6px;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: .80em;
  color: var(--ink-2);
  box-shadow: var(--sh-xs);
}

.demo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 620px) { .demo-grid { grid-template-columns: 1fr; } }

.demo-card {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 26px 24px;
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: var(--sh-sm);
  transition: transform .22s var(--ease-out), box-shadow .22s var(--ease-out);
}

.demo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}

.demo-card h2 { font-size: .88rem; font-weight: 700; margin-bottom: 8px; color: var(--ink); letter-spacing: -.01em; }
.demo-card p  { font-size: .84rem; color: var(--ink-3); line-height: 1.72; }
.demo-card a  { color: var(--brand); font-weight: 600; text-decoration: none; border-bottom: 1.5px solid rgba(232,104,42,.28); transition: border-color .14s; }
.demo-card a:hover { border-bottom-color: var(--brand); }

@keyframes demo-pulse { 0%,100%{opacity:1} 50%{opacity:.22} }

/* ============================================================
   SKIP LINK
============================================================ */
.skip-link {
  position: fixed;
  top: -110px;
  left: 18px;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font);
  font-size: .84rem;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: var(--r-sm);
  z-index: 99999;
  text-decoration: none;
  transition: top .18s var(--ease-out);
  box-shadow: var(--sh-lg);
}
.skip-link:focus { top: 18px; }

/* ============================================================
   LAUNCHER BUTTON
   — gradient orb, draggable, spring animation & glow ring
============================================================ */
#afw-launcher {
  position: fixed;
  /* JS will set top/left as inline style; these are the CSS fallback */
  bottom: 28px;
  left: 28px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #CA4F00;
  border: none;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 22px rgba(202,79,0,.38), 0 2px 6px rgba(202,79,0,.22);
  z-index: 9998;
  transition:
    box-shadow .22s var(--ease-out),
    background .18s;
  isolation: isolate;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#afw-launcher.afw-dragging {
  cursor: grabbing !important;
  box-shadow: 0 12px 36px rgba(202,79,0,.50), 0 4px 12px rgba(202,79,0,.28) !important;
  transition: box-shadow .12s !important;
}

/* Ambient glow ring that expands on hover */
#afw-launcher::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(202,79,0,.28) 0%, transparent 72%);
  opacity: 0;
  transform: scale(.7);
  transition: opacity .24s, transform .30s var(--ease-spring);
  z-index: -1;
  pointer-events: none;
}

#afw-launcher:hover:not(.afw-dragging) {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 36px rgba(202,79,0,.46), 0 4px 10px rgba(202,79,0,.26);
}

#afw-launcher:hover::after {
  opacity: 1;
  transform: scale(1);
}

#afw-launcher:focus-visible {
  box-shadow: 0 0 0 3px var(--white), 0 0 0 6px #CA4F00, 0 6px 22px rgba(202,79,0,.38);
}

#afw-launcher[aria-expanded="true"] {
  background: #CA4F00;
  box-shadow: 0 6px 24px rgba(202,79,0,.38), 0 2px 6px rgba(202,79,0,.22);
}

#afw-launcher .ico-open  { display: flex; }
#afw-launcher .ico-close { display: none; }

/* ============================================================
   PANEL
   — floating card, draggable, with layered shadow & crisp border
============================================================ */
#afw-panel {
  position: fixed;
  /* top/left will be set and maintained by JS — no CSS bottom/right here */
  width: 392px;
  height: 650px;
  max-height: 87vh;
  background: var(--white);
  border-radius: var(--r-2xl);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-xl), 0 0 0 1px rgba(0,0,0,.07);
  font-family: var(--font);
  isolation: isolate;
  transition:
    opacity .22s ease,
    visibility .22s,
    transform .22s var(--ease-out);
  overflow: hidden;
  /* critical: do NOT use transform for position — JS uses top/left */
  transform-origin: top left;
}

#afw-panel[hidden] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(.94);
  display: flex !important;
}

#afw-panel:not([hidden]) {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

#afw-panel.afw-dragging {
  transition: none !important;
  cursor: grabbing;
  user-select: none;
  box-shadow: var(--sh-xl), 0 0 0 2px rgba(98,0,177,.35) !important;
}

/* ============================================================
   HEADER
   — purple gradient with layered light orbs, drag handle
============================================================ */
.afw-header {
  background: #CA4F00;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.afw-header:active { cursor: grabbing; }

/* Top-right light orb */
.afw-header::before {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.14) 0%, transparent 68%);
  top: -90px;
  right: -50px;
  pointer-events: none;
}

/* Bottom-left warm glow */
.afw-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 140px 90px at 5% 130%, rgba(255,200,100,.12) 0%, transparent 100%),
    linear-gradient(180deg, rgba(255,255,255,.06) 0%, transparent 50%);
  pointer-events: none;
}

.afw-header-inner {
  padding: 20px 20px 17px;
  position: relative;
  z-index: 1;
}

.afw-header-row {
  display: flex;
  align-items: center;
  gap: 13px;
}

.afw-header-icon {
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.26);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 2px 8px rgba(0,0,0,.14);
}

.afw-header-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.025em;
  line-height: 1.2;
}

.afw-header-sub {
  font-size: .68rem;
  color: rgba(255,255,255);
  font-weight: 500;
  margin-top: 2px;
  letter-spacing: .01em;
}

/* Close button in header */
.afw-header-close {
  margin-left: auto;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.30);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: background .16s, transform .18s var(--ease-spring);
}

.afw-header-close:hover {
  background: rgba(255,255,255,.28);
  transform: scale(1.10);
}

.afw-header-close:focus-visible {
  outline: 2.5px solid #fff;
  outline-offset: 2px;
}

/* ============================================================
   TABS
   — seamless underline style inside tinted tray
============================================================ */
.afw-tabs {
  display: flex;
  background: var(--surface-2);
  border-bottom: 1.5px solid var(--line);
  padding: 0 8px;
  flex-shrink: 0;
}

.afw-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  padding: 10px 4px 9px;
  font-family: var(--font);
  font-size: .695rem;
  font-weight: 600;
  color: var(--ink-3);  /* #6c6c78 on #f3f3f6 ≈ 4.7:1 — passes AA */
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
  margin-bottom: -1.5px;
  letter-spacing: .01em;
  border-radius: var(--r-xs) var(--r-xs) 0 0;
}

.afw-tab:hover {
  color: var(--brand-dk);
  background: rgba(232,104,42,.04);
}

.afw-tab[aria-selected="true"] {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 700;
  background: var(--white);
}

.afw-tab:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* ============================================================
   BODY SCROLL AREA
============================================================ */
.afw-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 22px;
  scroll-behavior: smooth;
  background: var(--surface-2);
}

.afw-body::-webkit-scrollbar { width: 3px; }
.afw-body::-webkit-scrollbar-track { background: transparent; }
.afw-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.afw-section { display: none; }
.afw-section.active { display: block; }

/* Section label with trailing rule */
.afw-label {
  font-size: .60rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-2); /* #3a3a42 on #f3f3f6 ≈ 8.5:1 — passes AAA */
  margin: 20px 0 7px 1px;
  padding-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1.5px solid var(--line);
}

.afw-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.afw-label:first-child {
  margin-top: 2px;
  padding-top: 0;
  border-top: none;
}

/* ============================================================
   PROFILE NOTE (above profile buttons)
============================================================ */
.afw-note {
  background: var(--brand-lt);
  border: 1px solid rgba(232,104,42,.22);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.afw-note-label {
  display: block;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--brand-dk);
  margin-bottom: 4px;
}
.afw-note-text {
  font-size: .75rem;
  line-height: 1.5;
  color: #000000;
  margin: 0;
}

/* ============================================================
   PROFILE PILLS
============================================================ */
.afw-profiles {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.afw-profile {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px 6px 9px;
  border: 1.5px solid var(--line);
  border-radius: 100px;
  background: var(--white);
  font-family: var(--font);
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  user-select: none;
  transition: all .16s var(--ease-out);
  box-shadow: var(--sh-xs);
}

.afw-profile:hover {
  border-color: rgba(232,104,42,.38);
  color: var(--brand);
  background: var(--brand-lt);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(232,104,42,.14);
}

.afw-profile.active {
  background: linear-gradient(135deg, var(--brand-mid) 0%, var(--brand-dk) 100%);
  border-color: transparent;
  color: var(--white);
  box-shadow: 0 4px 14px rgba(232,104,42,.36);
}

.afw-profile svg { flex-shrink: 0; }
.afw-profile:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ============================================================
   FEATURE TILES
   — white cards with brand-tinted active state & spring check
============================================================ */
.afw-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.afw-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.afw-grid-1 { grid-template-columns: 1fr; }

.afw-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 11px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  overflow: visible; /* MUST be visible — overflow:hidden clips the check badge */
  min-height: 54px;
  box-shadow: var(--sh-xs);
  transition:
    border-color .16s,
    transform .18s var(--ease-out),
    box-shadow .18s var(--ease-out),
    background .16s;
}

/* Ambient tint fill — uses border-radius clip so it stays inside tile boundary */
.afw-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg,
    rgba(254,243,232,.90) 0%,
    rgba(255,248,240,.50) 100%);
  opacity: 0;
  transition: opacity .16s;
  pointer-events: none;
  z-index: 0;
}

.afw-tile:hover {
  border-color: rgba(232,104,42,.35);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(232,104,42,.10), var(--sh-sm);
}

.afw-tile:hover::after { opacity: 1; }

.afw-tile.on {
  border-color: var(--brand);
  background: linear-gradient(135deg, rgba(254,238,220,1) 0%, rgba(255,245,234,1) 100%);
  box-shadow: 0 0 0 2px rgba(232,104,42,.25), 0 4px 14px rgba(232,104,42,.14);
}

.afw-tile.on::after { opacity: 0; } /* turn off the overlay — bg handles it */

.afw-tile:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Icon box */
.afw-tile-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  color: var(--ink-4);
  transition: all .18s var(--ease-out);
}

.afw-tile:hover .afw-tile-icon {
  color: var(--brand);
  background: rgba(232,104,42,.07);
  border-color: rgba(232,104,42,.22);
}

.afw-tile.on .afw-tile-icon {
  background: linear-gradient(135deg, #F58040 0%, #D05010 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px rgba(232,104,42,.36);
}

.afw-tile-body { flex: 1; min-width: 0; position: relative; z-index: 1; }

.afw-tile-name {
  font-size: .76rem;
  font-weight: 700;
  color: var(--ink-2);
  display: block;
  line-height: 1.25;
  letter-spacing: -.01em;
}

.afw-tile.on .afw-tile-name { color: var(--brand-dk); }

.afw-tile-desc {
  font-size: .64rem;
  color: var(--ink-3); /* #6c6c78 on white tile ≈ 4.7:1 — passes AA */
  display: block;
  margin-top: 2px;
  line-height: 1.32;
}

/* Spring-popping check badge */
.afw-tile-check {
  position: absolute;
  top: -6px; right: -6px;
  width: 20px; height: 20px;
  background: linear-gradient(135deg, #6200B1, #4A0088);
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  transform: scale(.3) rotate(-60deg);
  transition:
    transform .28s var(--ease-spring),
    opacity .18s;
  box-shadow: 0 2px 8px rgba(98,0,177,.50);
  pointer-events: none;
}

.afw-tile.on .afw-tile-check {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Wide variant */
.afw-tile-wide { padding: 13px 14px; gap: 12px; }
.afw-tile-wide .afw-tile-icon { width: 36px; height: 36px; border-radius: 10px; }

/* ============================================================
   STEPPERS
============================================================ */
.afw-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 11px 13px;
  margin-bottom: 6px;
  box-shadow: var(--sh-xs);
  transition: border-color .16s, box-shadow .16s;
}

.afw-stepper:hover { border-color: rgba(232,104,42,.30); box-shadow: var(--sh-sm); }

.afw-stepper-info {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}

.afw-stepper-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--ink-3); /* improved from ink-4 */
}

.afw-stepper-name {
  font-size: .76rem;
  font-weight: 700;
  color: var(--ink-2);
  display: block;
  letter-spacing: -.01em;
}

.afw-stepper-val {
  font-size: .65rem;
  color: var(--brand);
  font-weight: 600;
  font-family: var(--font-mono);
  display: block;
  margin-top: 2px;
}

.afw-ctrl {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.afw-btn-step {
  width: 30px; height: 30px;
  background: none; border: none;
  cursor: pointer;
  font-size: 1.05rem;
  font-family: var(--font-mono);
  color: var(--ink-3);
  display: flex; align-items: center; justify-content: center;
  transition: var(--t);
  flex-shrink: 0;
}

.afw-btn-step:hover { background: var(--brand-lt); color: var(--brand); }
.afw-btn-step:disabled { opacity: .24; cursor: not-allowed; }
.afw-btn-step:disabled:hover { background: none; color: var(--ink-3); }
.afw-btn-step:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

.afw-step-num {
  min-width: 32px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700;
  font-family: var(--font-mono);
  color: var(--ink);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0 4px;
  background: var(--white);
}

/* ============================================================
   SCREEN READER PANEL
   — dark terminal with scanlines & glowing progress bar
============================================================ */
.afw-sr-panel {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--sh-xs);
}

.afw-sr-output {
  background: #0f0f13;
  padding: 14px 16px;
  min-height: 78px;
  font-family: var(--font-mono);
  font-size: .71rem;
  line-height: 1.75;
  color: #f2b654;
  word-break: break-word;
  position: relative;
}

/* CRT scanline texture */
.afw-sr-output::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent, transparent 3px,
    rgba(255,255,255,.010) 3px, rgba(255,255,255,.010) 4px
  );
  pointer-events: none;
  z-index: 1;
}

.afw-sr-output .idle { color: #353546; font-style: italic; }

/* Glowing progress bar */
.afw-sr-progress {
  height: 3px;
  background: #1a1a22;
}

.afw-sr-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-mid), var(--brand));
  width: 0%;
  transition: width .22s var(--ease-out);
  box-shadow: 0 0 10px rgba(232,104,42,.55);
}

.afw-sr-controls {
  padding: 9px 11px;
  display: flex; gap: 5px; align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.afw-sr-btn {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 11px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--white);
  font-family: var(--font);
  font-size: .70rem; font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  transition: all .14s var(--ease-out);
  white-space: nowrap;
  box-shadow: var(--sh-xs);
}

.afw-sr-btn:hover { border-color: rgba(232,104,42,.38); color: var(--brand); background: var(--brand-lt); }
.afw-sr-btn.active {
  background: linear-gradient(135deg, #F07832, #C84808);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px rgba(232,104,42,.32);
}
.afw-sr-btn:disabled { opacity: .28; cursor: not-allowed; pointer-events: none; }
.afw-sr-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.afw-sr-sep { flex: 1; }

.afw-sr-settings {
  padding: 10px 12px 12px;
  display: flex; flex-direction: column; gap: 10px;
  border-top: 1px solid var(--line);
}

.afw-sr-row { display: flex; align-items: center; gap: 10px; }

.afw-sr-row label {
  font-size: .70rem; font-weight: 600;
  color: var(--ink-4);
  min-width: 44px;
  letter-spacing: .01em;
}

/* Custom range slider */
.afw-range {
  flex: 1;
  height: 4px;
  appearance: none;
  background: var(--surface-3);
  border-radius: 100px;
  cursor: pointer;
}

.afw-range::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F07832, #C84808);
  box-shadow: 0 0 0 2.5px var(--white), 0 2px 8px rgba(232,104,42,.42);
  cursor: pointer;
  transition: transform .15s var(--ease-spring);
}

.afw-range::-webkit-slider-thumb:hover { transform: scale(1.22); }
.afw-range:focus-visible { outline: 2px solid var(--brand); border-radius: 4px; }

.afw-range-val {
  font-size: .66rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--brand);
  min-width: 30px;
  text-align: right;
}

.afw-voice-select {
  flex: 1; padding: 6px 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--white);
  font-family: var(--font);
  font-size: .71rem; font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  min-width: 0;
}

.afw-voice-select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

/* ============================================================
   KEYBOARD SHORTCUTS TABLE
============================================================ */
.afw-shortcuts {
  display: flex; flex-direction: column;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--white);
  box-shadow: var(--sh-xs);
}

.afw-shortcut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-2);
  font-size: .76rem;
  transition: background .12s;
}

.afw-shortcut:hover { background: var(--surface-2); }
.afw-shortcut:last-child { border-bottom: none; }
.afw-shortcut span { color: var(--ink-3); font-weight: 500; }

.afw-shortcut kbd {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-width: 2.5px;
  border-radius: 6px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: .64rem;
  color: var(--ink-2);
  font-weight: 600;
  box-shadow: var(--sh-xs);
}

/* ============================================================
   RESET BUTTON
============================================================ */
.afw-reset {
  width: 100%;
  padding: 10px 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-md);
  background: transparent;
  font-family: var(--font);
  font-size: .75rem; font-weight: 600;
  color: var(--ink-4);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 8px;
  transition: all .18s var(--ease-out);
  letter-spacing: .01em;
}

.afw-reset:hover {
  border-style: solid;
  border-color: rgba(232,104,42,.45);
  color: var(--brand);
  background: var(--brand-lt);
  box-shadow: 0 2px 10px rgba(232,104,42,.12);
}

.afw-reset:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ============================================================
   FOOTER
   — gradient band, frosted badge
============================================================ */
.afw-footer {
  background: #CA4F00;
  padding: 10px 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.afw-footer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,.05) 0%, transparent 60%);
  pointer-events: none;
}

.afw-footer-text {
  font-size: .64rem;
  color: rgba(255,255,255);
  font-family: var(--font-mono);
  letter-spacing: .03em;
  position: relative;
}

.afw-footer-text strong { color: #fff; font-weight: 700; }

.afw-footer-badge {
  /* background: rgba(255,255,255,.15); */
  border: 1px solid rgba(255,255,255,.24);
  color: #fff;
  font-size: .59rem; font-weight: 700;
  font-family: var(--font-mono);
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: .06em;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
  position: relative;
}

/* ============================================================
   OVERLAYS
============================================================ */
#afw-guide {
  position: fixed;
  left: 0; right: 0;
  height: 42px;
  top: -200px;
  pointer-events: none;
  z-index: 9990;
  display: none;
  background: rgba(232,104,42,.07);
  border-top: 2px solid rgba(232,104,42,.38);
  border-bottom: 2px solid rgba(232,104,42,.38);
}

body.afw-guide #afw-guide { display: block; }

#afw-mask {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9989;
  display: none;
}

body.afw-mask #afw-mask { display: block; }

.afw-mask-top, .afw-mask-bot {
  position: absolute;
  left: 0; right: 0;
  background: rgba(0,0,0,.62);
}
.afw-mask-top { top: 0; }
.afw-mask-bot { bottom: 0; }

#afw-ring {
  position: fixed;
  pointer-events: none;
  z-index: 9997;
  border: 2px solid var(--brand);
  border-radius: 8px;
  box-shadow:
    0 0 0 4px rgba(232,104,42,.18),
    inset 0 0 0 1px rgba(255,255,255,.26);
  display: none;
  transition: top .07s, left .07s, width .07s, height .07s;
}

body.afw-sr-active #afw-ring { display: block; }

/* ============================================================
   PAGE ROOT WRAPPER
   JS wraps all original page content in #afw-page-root so that
   CSS filters (invert, grayscale, color-blindness) can be applied
   to it without ever setting filter on <body> — which would break
   position:fixed for the widget elements.
============================================================ */
#afw-page-root {
  /* Full-page transparent wrapper — must be a real box for filter to work */
  display: block;
  min-height: 100%;
  width: 100%;
}

/* ============================================================
   FILTER ISOLATION — widget elements live outside #afw-page-root
============================================================ */

/* Font-size isolation: prevent body font-size overrides from affecting widget */
#afw-panel {
  font-size: 14px !important;
}
body[class*="afw-fs-"] #afw-panel,
body.afw-fs--1 #afw-panel {
  font-size: 14px !important;
}
body[class*="afw-fs-"] #afw-launcher,
body.afw-fs--1 #afw-launcher {
  width: 62px !important;
  height: 62px !important;
  font-size: 14px !important;
}
/* CRITICAL: Keep panel and launcher using fixed positioning driven by JS top/left.
   Never let any rule override position, top, or left on #afw-panel or #afw-launcher
   so JS drag coordinates remain authoritative. */
#afw-panel {
  position: fixed !important;
}
#afw-launcher {
  position: fixed !important;
}

/* ── Dark mode ── */
body.afw-dark { background: #000000 !important; color: #ffffff !important; }
body.afw-dark #afw-page-root {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #444 !important;
}
body.afw-dark #afw-page-root * {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #444 !important;
}
/* Protect editors and generated content from contrast overrides in dark mode */
body.afw-dark #afw-page-root .CodeMirror,
body.afw-dark #afw-page-root .CodeMirror *,
body.afw-dark #afw-page-root [class*="editor"],
body.afw-dark #afw-page-root [class*="editor"] *,
body.afw-dark #afw-page-root [class*="email-preview"],
body.afw-dark #afw-page-root [class*="email-preview"] *,
body.afw-dark #afw-page-root [class*="generated"],
body.afw-dark #afw-page-root [class*="generated"] * {
  background-color: revert !important;
  color: revert !important;
  border-color: revert !important;
}
/* ── Dark mode: button & link distinction ── */
body.afw-dark #afw-page-root a {
  color: #ffff00 !important;
  text-decoration: underline !important;
}
body.afw-dark #afw-page-root button,
body.afw-dark #afw-page-root [role="button"],
body.afw-dark #afw-page-root input[type="button"],
body.afw-dark #afw-page-root input[type="submit"],
body.afw-dark #afw-page-root input[type="reset"] {
  background-color: #1a1a1a !important;
  color: #ffffff !important;
  border: 1.5px solid #555555 !important;
  outline: none !important;
}
body.afw-dark #afw-page-root button:hover,
body.afw-dark #afw-page-root [role="button"]:hover {
  background-color: #2a2a2a !important;
  border-color: #888888 !important;
}

/* ── Light mode ── */
body.afw-light { background: #ffffff !important; color: #000000 !important; }
body.afw-light #afw-page-root {
  background-color: #ffffff !important;
  color: #000000 !important;
}
body.afw-light #afw-page-root * {
  background-color: #ffffff !important;
  color: #000000 !important;
}
body.afw-light #afw-page-root canvas,
body.afw-light #afw-page-root video,
body.afw-light #afw-page-root img {
  background-color: revert !important;
}

/* ── Light mode: button & link distinction ── */
body.afw-light #afw-page-root a {
  color: #0000cc !important;
  text-decoration: underline !important;
}
body.afw-light #afw-page-root button,
body.afw-light #afw-page-root [role="button"],
body.afw-light #afw-page-root input[type="button"],
body.afw-light #afw-page-root input[type="submit"],
body.afw-light #afw-page-root input[type="reset"] {
  background-color: #f0f0f0 !important;
  color: #000000 !important;
  border: 1.5px solid #aaaaaa !important;
}
body.afw-light #afw-page-root button:hover,
body.afw-light #afw-page-root [role="button"]:hover {
  background-color: #e0e0e0 !important;
  border-color: #666666 !important;
}

/* ── High contrast ── */
body.afw-hc { background: #000 !important; color: #fff !important; }
body.afw-hc #afw-page-root {
  background-color: #000 !important;
  color: #fff !important;
}
body.afw-hc #afw-page-root * {
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
  text-shadow: none !important;
}
/* Protect editors and generated content from contrast overrides */
body.afw-hc #afw-page-root .CodeMirror,
body.afw-hc #afw-page-root .CodeMirror *,
body.afw-hc #afw-page-root [class*="editor"],
body.afw-hc #afw-page-root [class*="editor"] *,
body.afw-hc #afw-page-root [class*="email-preview"],
body.afw-hc #afw-page-root [class*="email-preview"] *,
body.afw-hc #afw-page-root [class*="generated"],
body.afw-hc #afw-page-root [class*="generated"] * {
  background-color: revert !important;
  color: revert !important;
  border-color: revert !important;
}
/* ── High contrast: button & link distinction ── */
body.afw-hc #afw-page-root a {
  color: #ffff00 !important;
  text-decoration: underline !important;
  background-color: transparent !important;
}
body.afw-hc #afw-page-root button,
body.afw-hc #afw-page-root [role="button"],
body.afw-hc #afw-page-root input[type="button"],
body.afw-hc #afw-page-root input[type="submit"],
body.afw-hc #afw-page-root input[type="reset"] {
  background-color: #000000 !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
  outline: none !important;
}
body.afw-hc #afw-page-root button:hover,
body.afw-hc #afw-page-root [role="button"]:hover {
  background-color: #222222 !important;
  border-color: #ffffff !important;
  outline: 2px solid #ffffff !important;
}

/* ── Vision profile also enables hc — ensure selected/active buttons are distinguishable ── */
body.afw-hc #afw-page-root button[aria-pressed="true"],
body.afw-hc #afw-page-root button.active,
body.afw-hc #afw-page-root button[aria-selected="true"] {
  background-color: #ffffff !important;
  color: #000000 !important;
  border: 2px solid #ffffff !important;
}

/* ── Invert ── */
/* CRITICAL: Never set filter on body — it breaks position:fixed for the widget.
   Instead JS wraps page content in #afw-page-root and we filter that. */
body.afw-invert #afw-page-root { filter: invert(1) hue-rotate(180deg); }

/* Re-invert images, videos, iframes so photos look natural */
body.afw-invert #afw-page-root img,
body.afw-invert #afw-page-root video,
body.afw-invert #afw-page-root canvas,
body.afw-invert #afw-page-root iframe {
  filter: invert(1) hue-rotate(180deg) !important;
}

/* Re-invert inline SVG icons so they don't turn into black blobs */
body.afw-invert #afw-page-root svg:not(#afw-cb-filters) {
  filter: invert(1) hue-rotate(180deg) !important;
}

/* Elements with explicit white/black backgrounds that become invisible after invert */
body.afw-invert #afw-page-root [style*="background-color: white"],
body.afw-invert #afw-page-root [style*="background-color:#fff"],
body.afw-invert #afw-page-root [style*="background-color: #fff"],
body.afw-invert #afw-page-root [style*="background:#fff"],
body.afw-invert #afw-page-root [style*="background: white"] {
  filter: invert(1) !important;
}

/* Ensure text on dark backgrounds post-invert stays readable */
body.afw-invert #afw-page-root {
  background-color: #ffffff;
}

/* ── Grayscale ── */
body.afw-gray #afw-page-root { filter: grayscale(1); }

/* ── Low contrast ── */
body.afw-lowcon #afw-page-root { filter: contrast(.65) brightness(1.08); }

/* ── Desaturate ── */
body.afw-desat #afw-page-root { filter: saturate(.15); }

/* ── Color blindness ── */
body.afw-cb-proto #afw-page-root { filter: url(#f-proto); }
body.afw-cb-deut  #afw-page-root { filter: url(#f-deut);  }
body.afw-cb-trit  #afw-page-root { filter: url(#f-trit);  }

/* ── Font size ── */
body.afw-fs--1 { font-size: 13px !important; }
body.afw-fs-1  { font-size: 17px !important; }
body.afw-fs-2  { font-size: 20px !important; }
body.afw-fs-3  { font-size: 23px !important; }
body.afw-fs-4  { font-size: 26px !important; }
body.afw-fs-5  { font-size: 30px !important; }

/* ── Spacing ── */
body.afw-ls-1 * { letter-spacing: .04em !important; }
body.afw-ls-2 * { letter-spacing: .09em !important; }
body.afw-ls-3 * { letter-spacing: .16em !important; }
body.afw-lh-1 * { line-height: 1.75 !important; }
body.afw-lh-2 * { line-height: 2.10 !important; }
body.afw-lh-3 * { line-height: 2.50 !important; }
body.afw-ws   * { word-spacing: .20em !important; }

/* ── Font / alignment ── */
body.afw-dyslexia * { font-family: 'Lexend', sans-serif !important; }
body.afw-alignl   * { text-align: left !important; }

/* ── Animation freeze ── */
body.afw-pause *, body.afw-pause *::before, body.afw-pause *::after {
  animation-play-state: paused !important;
  transition-duration: 0s !important;
}
body.afw-pause #afw-panel,
body.afw-pause #afw-panel *,
body.afw-pause #afw-panel *::before,
body.afw-pause #afw-panel *::after,
body.afw-pause #afw-launcher,
body.afw-pause #afw-launcher::after {
  animation-play-state: running !important;
  transition-duration: revert !important;
}

/* ── Focus indicators ── */
body.afw-focus *:focus {
  outline: 3px solid var(--brand) !important;
  outline-offset: 4px !important;
  border-radius: 4px !important;
}
body.afw-spotlight *:focus {
  box-shadow: 0 0 0 4px var(--brand), 0 0 0 8px rgba(232,104,42,.22) !important;
  outline: none !important;
}
body.afw-spotlight.afw-hc *:focus {
  box-shadow: 0 0 0 4px #fff, 0 0 0 8px rgba(255,255,255,.3) !important;
  outline: none !important;
}

/* ── Link & heading highlights ── */
body.afw-hl-links a {
  background: #fff7de !important;
  color: #1a1a22 !important;
  padding: 1px 4px !important;
  border-radius: 4px !important;
  border-bottom: 2px solid var(--brand) !important;
  text-decoration: none !important;
}

body.afw-hl-heads h1, body.afw-hl-heads h2,
body.afw-hl-heads h3, body.afw-hl-heads h4 {
  border-left: 4px solid var(--brand) !important;
  padding-left: 13px !important;
  background: rgba(232,104,42,.05) !important;
}

/* ── Hide images ── */
body.afw-hide-img img, body.afw-hide-img [role="img"],
body.afw-hide-img picture, body.afw-hide-img svg:not(#afw-cb-filters svg) {
  opacity: 0 !important;
}

/* ── Large cursor ── */
body.afw-bigcursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpolygon points='5,3 5,31 12,23 17,35 22,32 17,20 26,20' fill='%23E8682A' stroke='white' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") 5 3, auto !important;
}

/* ── Large scrollbar: targets both page root scroll (html) and child scrollbars ── */

/* Page-level scrollbar on <html> */
html:has(body.afw-sb)::-webkit-scrollbar {
  width: 16px !important;
  height: 16px !important;
}
html:has(body.afw-sb)::-webkit-scrollbar-track {
  background: #e0e0e0 !important;
  border-radius: 0 !important;
}
html:has(body.afw-sb)::-webkit-scrollbar-thumb {
  background: #CA4F00 !important;
  border-radius: 8px !important;
  border: 3px solid #e0e0e0 !important;
  min-height: 40px !important;
}
html:has(body.afw-sb)::-webkit-scrollbar-thumb:hover {
  background: #a33e00 !important;
}

/* Child element scrollbars (panels, textareas, overflow:auto containers) */
body.afw-sb ::-webkit-scrollbar {
  width: 16px !important;
  height: 16px !important;
}
body.afw-sb ::-webkit-scrollbar-track {
  background: #e0e0e0 !important;
  border-radius: 0 !important;
}
body.afw-sb ::-webkit-scrollbar-thumb {
  background: #CA4F00 !important;
  border-radius: 8px !important;
  border: 3px solid #e0e0e0 !important;
  min-height: 40px !important;
}
body.afw-sb ::-webkit-scrollbar-thumb:hover {
  background: #a33e00 !important;
}

/* When dark/HC mode is also active — keep scrollbar visible on dark backgrounds */
body.afw-sb.afw-dark ::-webkit-scrollbar-track,
body.afw-sb.afw-hc   ::-webkit-scrollbar-track {
  background: #333333 !important;
}
body.afw-sb.afw-dark ::-webkit-scrollbar-thumb,
body.afw-sb.afw-hc   ::-webkit-scrollbar-thumb {
  background: #CA4F00 !important;
  border-color: #333333 !important;
}
html:has(body.afw-sb.afw-dark)::-webkit-scrollbar-track,
html:has(body.afw-sb.afw-hc)::-webkit-scrollbar-track {
  background: #333333 !important;
}
html:has(body.afw-sb.afw-dark)::-webkit-scrollbar-thumb,
html:has(body.afw-sb.afw-hc)::-webkit-scrollbar-thumb {
  background: #CA4F00 !important;
  border-color: #333333 !important;
}

/* Firefox: color only (no width control available) */
html:has(body.afw-sb),
body.afw-sb,
body.afw-sb * {
  scrollbar-color: #CA4F00 #e0e0e0 !important;
}
body.afw-sb.afw-dark,
body.afw-sb.afw-hc,
body.afw-sb.afw-dark *,
body.afw-sb.afw-hc * {
  scrollbar-color: #CA4F00 #333333 !important;
}

/* ── Text magnify: expanded element coverage ── */
body.afw-magnify #afw-page-root p:hover,
body.afw-magnify #afw-page-root li:hover,
body.afw-magnify #afw-page-root td:hover,
body.afw-magnify #afw-page-root th:hover,
body.afw-magnify #afw-page-root span:hover,
body.afw-magnify #afw-page-root label:hover,
body.afw-magnify #afw-page-root div:hover > span,
body.afw-magnify #afw-page-root div:hover > p,
body.afw-magnify #afw-page-root blockquote:hover,
body.afw-magnify #afw-page-root figcaption:hover,
body.afw-magnify #afw-page-root article:hover > p,
body.afw-magnify #afw-page-root section:hover > p,
body.afw-magnify #afw-page-root .text:hover,
body.afw-magnify #afw-page-root [class*="text"]:hover,
body.afw-magnify #afw-page-root [class*="content"]:hover,
body.afw-magnify #afw-page-root [class*="body"]:hover,
body.afw-magnify #afw-page-root [class*="description"]:hover {
  font-size: 1.18em !important;
  transition: font-size .12s ease !important;
}

/* Headings must NOT change size */
body.afw-magnify h1, body.afw-magnify h2, body.afw-magnify h3,
body.afw-magnify h4, body.afw-magnify h5, body.afw-magnify h6 {
  font-size: revert !important;
}

/* Keep widget completely unaffected */
body.afw-magnify #afw-panel *:hover,
body.afw-magnify #afw-launcher:hover {
  font-size: inherit !important;
  transition: none !important;
}

/* ============================================================
   MOBILE
============================================================ */
@media (max-width: 480px) {
  #afw-panel { width: calc(100vw - 20px) !important; border-radius: var(--r-xl); }
}