/* Shademix styles — dark by default, mobile-first. */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
:root {
  color-scheme: dark light;
  --bg: #0e0f12;
  --panel: #15171c;
  --panel-2: #1c1f26;
  --line: #262a32;
  --text: #e8eaed;
  --muted: #8a90a0;
  --accent: #ff5e7e;
  --accent-2: #3ec1ff;
  --accent-3: #ffb547;
  --good: #44d28a;
  --warn: #ffae3b;
  --bad: #ff5460;
  --r: 12px;
  --shadow: 0 6px 30px rgba(0,0,0,.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f6f8;
    --panel: #ffffff;
    --panel-2: #f2f3f6;
    --line: #e5e7ec;
    --text: #1c1f26;
    --muted: #6b7180;
    --shadow: 0 6px 30px rgba(0,0,0,.07);
  }
}
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(90px + var(--safe-bottom));
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
header.top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  /* On iOS Capacitor + standalone PWA the webview overlays the notch; push content below it. */
  padding-top: max(10px, env(safe-area-inset-top, 10px));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(14,15,18,.85); z-index: 5;
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  will-change: transform;
}
header.top .brand {
  font-weight: 800; letter-spacing: .3px;
  display: flex; align-items: center; gap: 10px; min-width: 0;
  cursor: pointer; user-select: none;
  border-radius: 10px; padding: 4px; margin: -4px;
  transition: background .18s, transform .15s;
}
header.top .brand:hover { background: var(--panel-2); }
header.top .brand:active { transform: scale(.97); }
header.top .brand .logo {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: #0e0f12 url('icons/logo-mark.svg') center/72% no-repeat;
  border: 1px solid var(--line);
}
header.top h1 { font-size: 17px; margin: 0; white-space: nowrap; }
header.top .spacer { flex: 1; }
header.top a.icon, header.top button.icon {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 8px 12px; border-radius: 10px; cursor: pointer; font-size: 13px;
  font-weight: 600; text-decoration: none; display: inline-flex; align-items: center;
  white-space: nowrap; line-height: 1; min-height: 36px;
}
header.top button.icon-only {
  padding: 8px 10px; min-width: 40px; justify-content: center;
}
header.top button.icon:hover, header.top a.icon:hover { border-color: var(--accent); }
header.top a.icon.pro-cta {
  background: linear-gradient(90deg, #ff5e7e, #ffb547, #3ec1ff);
  color: #0e0f12; font-weight: 800; letter-spacing: .2px;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 2px 10px rgba(255,94,126,.25);
}
header.top a.icon.pro-cta:hover { filter: brightness(1.06); border-color: rgba(255,255,255,.35); }

nav.tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
  position: sticky; top: calc(56px + env(safe-area-inset-top, 0px)); background: rgba(14,15,18,.92); z-index: 4;
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  will-change: transform;
}
nav.tabs button {
  background: transparent; color: var(--muted); border: 0;
  padding: 14px 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent;
  min-height: 48px;
  letter-spacing: .2px;
  text-align: center;
}
nav.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
nav.tabs button:hover { color: var(--text); }
nav.tabs button:active { background: rgba(255,255,255,.03); }

/* Tools circle — sits in the header center, bottom 25% pokes out below header line */
.tab-trigger-circle {
  width: 64px; height: 64px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(155deg, #1c1f26 0%, #15171c 100%);
  border: 1.5px solid var(--accent);
  color: var(--text);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  font-family: inherit;
  margin-bottom: -16px;          /* 25% of 64 ≈ 16px sticks below header bottom */
  margin-top: -4px;
  box-shadow:
    0 6px 22px rgba(255, 94, 126, .35),
    0 0 0 4px rgba(14, 15, 18, .9),
    inset 0 1px 0 rgba(255, 255, 255, .08);
  z-index: 6;
  transition: transform .15s, box-shadow .2s, border-color .15s;
  position: relative;
}
.tab-trigger-circle:active { transform: scale(.93); }
.tab-trigger-circle:hover { border-color: var(--accent-3); }
.tab-trigger-circle .ico { color: #fff; }
.tab-trigger-circle .lbl {
  font-size: 11px; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(90deg, #ff5e7e, #ffb547, #3ec1ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-transform: uppercase;
}
/* When menu is open, give the Tools circle an active "lit" state */
body.tab-menu-open .tab-trigger-circle {
  border-color: var(--accent);
  box-shadow:
    0 6px 28px rgba(255, 94, 126, .55),
    0 0 0 4px rgba(255, 94, 126, .15),
    inset 0 1px 0 rgba(255, 255, 255, .12);
  transform: scale(1.02);
}

/* Allow the Tools circle to escape the header bottom (do NOT override the sticky positioning above) */
header.top { overflow: visible; }

/* Hide the desktop tab strip on phones — Tools circle replaces it */
@media (max-width: 760px) { nav.tabs { display: none; } }
@media (min-width: 761px) {
  /* On desktop the strip is enough; hide the circle to keep the header clean */
  .tab-trigger-circle { display: none; }
}

/* ---------- Radial fan tab menu ---------- */
#tab-menu { position: fixed; inset: 0; z-index: 50; display: block; }
#tab-menu.hidden { display: none; }
.tab-menu-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 9, 12, .55);
  /* No blur — keeps the underlying UI crisp; items already pop via colored glows */
  animation: tabFanFade .18s ease-out;
}
@keyframes tabFanFade { from { opacity: 0 } to { opacity: 1 } }
.tab-menu-fan {
  position: absolute;
  /* Position is set in JS to align with the Tools circle center */
  left: 50%;
  top: 0;
  width: 0; height: 0;
}
.tab-fan-item {
  position: absolute;
  --glow: #ff5e7e; /* per-item override comes from inline style */
  width: 72px; height: 72px;
  margin: -36px;  /* center on origin */
  border-radius: 50%;
  background: linear-gradient(155deg, #1c1f26 0%, #14161c 100%);
  border: 1.5px solid var(--glow);
  color: var(--text);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-family: inherit;
  /* Strong colored glow per item — much more visual interest than backdrop blur */
  box-shadow:
    0 0 18px var(--glow),
    0 0 0 1px rgba(255,255,255,.06) inset,
    0 6px 24px rgba(0,0,0,.6);
  /* DEFAULT (closed): collapsed at fan origin (translate by 0). */
  transform: rotate(var(--angle)) translateY(0) rotate(calc(-1 * var(--angle))) scale(.3);
  opacity: 0;
  transition:
    transform .4s cubic-bezier(.2, 1.2, .3, 1),
    opacity .25s ease,
    background .15s,
    box-shadow .25s,
    border-color .15s;
}
.tab-fan-item .ico { font-size: 22px; line-height: 1; }
.tab-fan-item .lbl { font-size: 11px; font-weight: 800; letter-spacing: .2px; color: var(--glow); }
.tab-fan-item.active {
  background: var(--glow);
  color: #0e0f12;
  border-color: #fff;
  box-shadow: 0 0 30px var(--glow), 0 8px 28px rgba(0,0,0,.5);
}
.tab-fan-item.active .lbl { color: #0e0f12; }
.tab-fan-item:hover { box-shadow: 0 0 26px var(--glow), 0 0 0 1px rgba(255,255,255,.08) inset, 0 6px 24px rgba(0,0,0,.6); }
.tab-fan-item:active {
  transform: rotate(var(--angle)) translateY(140px) rotate(calc(-1 * var(--angle))) scale(.94);
}

/* When menu opens, fan items spring out to their radial positions BELOW the trigger.
   Distance is increased to 150px to keep items well below the header content. */
#tab-menu.show .tab-fan-item {
  transform: rotate(var(--angle)) translateY(150px) rotate(calc(-1 * var(--angle))) scale(1);
  opacity: 1;
}
/* Stagger entrance — items appear one after another */
#tab-menu.show .tab-fan-item:nth-child(1) { transition-delay: 0ms; }
#tab-menu.show .tab-fan-item:nth-child(2) { transition-delay: 35ms; }
#tab-menu.show .tab-fan-item:nth-child(3) { transition-delay: 70ms; }
#tab-menu.show .tab-fan-item:nth-child(4) { transition-delay: 105ms; }
#tab-menu.show .tab-fan-item:nth-child(5) { transition-delay: 140ms; }
#tab-menu.show .tab-fan-item:nth-child(6) { transition-delay: 175ms; }

/* Close button — pinned to top-right, also serves as visual indication */
.tab-menu-close {
  position: absolute; top: 18px; right: 18px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  width: 40px; height: 40px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; cursor: pointer;
  font-size: 22px; line-height: 1;
}

main { padding: 18px; max-width: 1280px; margin: 0 auto; }
section.tab { display: none; }
section.tab.active { display: block; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.col { flex: 1 1 320px; min-width: 0; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 700; letter-spacing: .3px; color: var(--muted); text-transform: uppercase; }
.muted { color: var(--muted); font-size: 13px; }
button, input, select, textarea {
  font-family: inherit;
}
input[type="text"], input[type="search"], input[type="number"], select, textarea {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 12px; font-size: 14px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 14px; font-size: 14px; cursor: pointer; font-weight: 600;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { filter: brightness(1.07); }
button.ghost { background: transparent; }
.swatch { width: 100%; aspect-ratio: 1; border-radius: 10px; border: 1px solid rgba(0,0,0,.15); position: relative; }
.swatch.lg { height: 160px; }
.swatch .cv {
  position: absolute; inset: auto 6px 6px auto; background: rgba(0,0,0,.55); color: #fff;
  font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 700; letter-spacing: .3px;
}

.grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}
.grid .item {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; cursor: pointer; transition: transform .12s, border-color .12s;
}
.grid .item:hover { transform: translateY(-2px); border-color: var(--accent); }
.grid .item .swatch { aspect-ratio: 4 / 3; }
.grid .item .name { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.2; min-height: 2.4em; }
.grid .item .code { font-size: 12px; font-weight: 700; }

.eyedropper-canvas-wrap {
  position: relative; max-width: 100%; overflow: visible; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--panel-2); display: flex; justify-content: center;
}
#image-canvas {
  max-width: 100%; height: auto;
  cursor: crosshair;
  touch-action: none;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

/* ---- Press-and-hold loupe magnifier ---- */
#loupe-canvas {
  position: absolute;
  width: 140px; height: 140px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.95);
  box-shadow: 0 0 0 2px rgba(0,0,0,.5), 0 12px 30px rgba(0,0,0,.55);
  pointer-events: none;
  z-index: 20;
  display: none;
  background: #000;
}
#loupe-canvas.show { display: block; }

#loupe-chip {
  position: absolute; pointer-events: none; z-index: 21;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; font-weight: 800;
  padding: 5px 10px; border-radius: 999px;
  letter-spacing: .3px; transform: translate(-50%, 0);
  box-shadow: 0 4px 14px rgba(0,0,0,.5);
  border: 1px solid rgba(0,0,0,.25);
  display: none;
}
#loupe-chip.show { display: block; }

/* Canvas tap marker — pulsing ring at sample point */
#canvas-marker {
  position: absolute; width: 32px; height: 32px; pointer-events: none;
  border: 2.5px solid currentColor;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(.4);
  opacity: 0;
  box-shadow: 0 0 0 2px rgba(0,0,0,.5), inset 0 0 0 2px rgba(255,255,255,.6);
  z-index: 3;
}
#canvas-marker.show {
  animation: canvasMarkerPulse 1.1s ease-out forwards;
}
@keyframes canvasMarkerPulse {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(.3); }
  30%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.4); }
}

/* Hex chip floating above tap point */
#canvas-marker-chip {
  position: absolute; pointer-events: none; z-index: 4;
  font-size: 11px; font-weight: 800; padding: 4px 9px; border-radius: 999px;
  letter-spacing: .3px; transform: translate(-50%, -100%);
  opacity: 0; box-shadow: 0 4px 14px rgba(0,0,0,.45);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  border: 1px solid rgba(0,0,0,.25);
}
#canvas-marker-chip.show {
  animation: chipFade 1.6s ease-out forwards;
}
@keyframes chipFade {
  0%   { opacity: 0; transform: translate(-50%, -90%); }
  20%  { opacity: 1; transform: translate(-50%, -110%); }
  80%  { opacity: 1; transform: translate(-50%, -110%); }
  100% { opacity: 0; transform: translate(-50%, -130%); }
}

/* Smooth scroll target offset so sticky header + nav don't cover the Sampled Color card */
#hero-card { scroll-margin-top: 130px; }
@media (max-width: 760px) {
  /* Mobile nav is 2 rows tall, so we need more breathing room */
  #hero-card { scroll-margin-top: 170px; }
}
.drop-target {
  border: 2px dashed var(--line); border-radius: var(--r); padding: 30px; text-align: center; color: var(--muted);
  background: var(--panel-2); cursor: pointer;
}
.drop-target.over { border-color: var(--accent); color: var(--text); }

.swatches-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.swatches-row .s { aspect-ratio: 1; border-radius: 10px; cursor: pointer; position: relative; border: 1px solid rgba(0,0,0,.2); }
.swatches-row .s span { position: absolute; bottom: 4px; left: 4px; right: 4px; font-size: 10px; text-align: center; background: rgba(0,0,0,.55); color: #fff; padding: 2px; border-radius: 4px; }

.hero-color {
  display: flex; gap: 14px; align-items: stretch;
}
.hero-color .swatch { width: 180px; height: 180px; flex-shrink: 0; }
.hero-color .meta { flex: 1; min-width: 0; }
.hero-color .meta h2 { margin: 0 0 4px; font-size: 22px; }
.hero-color .formats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 8px; font-size: 13px; }
.hero-color .formats .lbl { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.hero-color .formats code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer;
  background: var(--panel-2); padding: 4px 8px; border-radius: 6px; display: inline-block;
}
.hero-color .formats code:hover { color: var(--accent); }

.harmony-row { display: flex; gap: 6px; margin-bottom: 10px; }
.harmony-row .s { flex: 1; aspect-ratio: 2.5; border-radius: 8px; cursor: pointer; }
.harmony-row .lbl { font-size: 11px; color: var(--muted); width: 100px; flex-shrink: 0; padding-top: 6px; font-weight: 700; text-transform: uppercase; }

.gradient-bar { height: 60px; border-radius: 10px; }
.contrast-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.contrast-table td, .contrast-table th { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; }
.contrast-table .badge {
  font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; display: inline-block; min-width: 38px; text-align: center;
}
.badge.ok { background: rgba(68,210,138,.15); color: var(--good); }
.badge.fail { background: rgba(255,84,96,.15); color: var(--bad); }
.badge.warn { background: rgba(255,174,59,.15); color: var(--warn); }

.cvd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.cvd-tile { background: var(--panel-2); padding: 10px; border-radius: 10px; border: 1px solid var(--line); }
.cvd-tile .swatch { height: 80px; }
.cvd-tile h4 { margin: 6px 0 2px; font-size: 12px; }
.cvd-tile p { margin: 0; font-size: 11px; color: var(--muted); }

.recent-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.recent-strip .r { width: 26px; height: 26px; border-radius: 6px; cursor: pointer; border: 1px solid rgba(0,0,0,.2); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 600; opacity: 0; transition: opacity .2s; z-index: 99;
}
.toast.show { opacity: 1; }

footer.bot {
  text-align: center; color: var(--muted); font-size: 12px; padding: 24px 0 80px; max-width: 760px; margin: 24px auto 0;
}
.legal { font-size: 11px; color: var(--muted); padding: 12px 14px; border: 1px dashed var(--line); border-radius: 10px; }

@media (max-width: 720px) {
  nav.tabs { grid-template-columns: repeat(6, max-content); }
  .hero-color { flex-direction: column; }
  .hero-color .swatch { width: 100%; height: 120px; }
  header.top h1 { font-size: 15px; }
}

/* Install banner */
#install-banner {
  position: fixed; bottom: 14px; left: 14px; right: 14px; z-index: 50;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; display: none; align-items: center; gap: 10px;
  box-shadow: var(--shadow);
}
#install-banner.show { display: flex; }
#install-banner .text { font-size: 13px; }
#install-banner .text b { display: block; }
#install-banner .text small { color: var(--muted); }

.tag {
  display: inline-block; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--muted); font-size: 11px; padding: 2px 8px; border-radius: 999px; margin: 2px 2px 0 0;
}
.tag:hover { color: var(--text); border-color: var(--accent); cursor: pointer; }

/* ---------- Floating hamburger FAB ---------- */
.fab {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.55);
  z-index: 30;
  transition: transform .12s, border-color .15s;
}
.fab:active { transform: scale(.93); }
.fab:hover { border-color: var(--accent); }

/* ---------- FAB radial menu (bottom-right corner; fans into upper-left quadrant) ---------- */
#fab-menu-fan { position: fixed; inset: 0; z-index: 80; display: block; }
#fab-menu-fan.hidden { display: none; }
.fab-menu-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 9, 12, .55);
  animation: tabFanFade .18s ease-out;
}
.fab-fan {
  position: absolute;
  /* Anchored to FAB center via JS at open time */
  left: 50%; top: 50%;
  width: 0; height: 0;
}
.fab-fan-item {
  position: absolute;
  --glow: #ff5e7e;
  --radius: 130px;
  width: 64px; height: 64px;
  margin: -32px;
  border-radius: 50%;
  background: linear-gradient(155deg, #1c1f26 0%, #14161c 100%);
  border: 1.5px solid var(--glow);
  color: var(--text);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  font-family: inherit;
  text-decoration: none;
  box-shadow:
    0 0 16px var(--glow),
    0 0 0 1px rgba(255,255,255,.06) inset,
    0 6px 22px rgba(0,0,0,.55);
  transform: rotate(var(--angle)) translateY(0) rotate(calc(-1 * var(--angle))) scale(.3);
  opacity: 0;
  transition:
    transform .42s cubic-bezier(.2, 1.2, .3, 1),
    opacity .25s ease,
    background .15s,
    box-shadow .25s;
}
.fab-fan-item .ico { font-size: 20px; line-height: 1; }
.fab-fan-item .lbl { font-size: 10.5px; font-weight: 800; letter-spacing: .2px; color: var(--glow); }
#fab-menu-fan.show .fab-fan-item {
  transform: rotate(var(--angle)) translateY(var(--radius)) rotate(calc(-1 * var(--angle))) scale(1);
  opacity: 1;
}
.fab-fan-item:hover { box-shadow: 0 0 24px var(--glow), 0 0 0 1px rgba(255,255,255,.08) inset, 0 6px 24px rgba(0,0,0,.6); }
.fab-fan-item:active {
  transform: rotate(var(--angle)) translateY(calc(var(--radius) - 6px)) rotate(calc(-1 * var(--angle))) scale(.94);
}
/* Stagger entrance for FAB fan items */
#fab-menu-fan.show .fab-fan-item:nth-child(1) { transition-delay: 0ms; }
#fab-menu-fan.show .fab-fan-item:nth-child(2) { transition-delay: 30ms; }
#fab-menu-fan.show .fab-fan-item:nth-child(3) { transition-delay: 60ms; }
#fab-menu-fan.show .fab-fan-item:nth-child(4) { transition-delay: 90ms; }
#fab-menu-fan.show .fab-fan-item:nth-child(5) { transition-delay: 120ms; }
#fab-menu-fan.show .fab-fan-item:nth-child(6) { transition-delay: 150ms; }
#fab-menu-fan.show .fab-fan-item:nth-child(7) { transition-delay: 180ms; }

/* When the menu is open, rotate the FAB hamburger icon into an "X" */
body.fab-menu-open .fab { transform: rotate(45deg); border-color: var(--accent); }

/* ---------- Language picker sheet ---------- */
#lang-sheet { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 18px; }
#lang-sheet.hidden { display: none; }
.lang-backdrop {
  position: absolute; inset: 0; background: rgba(8, 9, 12, .78);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  animation: tabFanFade .18s ease-out;
}
.lang-card {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 24px 22px 16px; max-width: 380px; width: 100%;
  box-shadow: 0 20px 70px rgba(0,0,0,.55);
  animation: proCardIn .35s cubic-bezier(.2, 1.05, .3, 1);
}
.lang-card h2 { margin: 0 0 6px; font-size: 20px; }
.lang-card .lang-sub { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }
.lang-close {
  position: absolute; top: 10px; right: 12px; background: transparent; border: 0; color: var(--muted);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.lang-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lang-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; text-align: left;
}
.lang-item .flag { font-size: 18px; line-height: 1; }
.lang-item .chk { margin-left: auto; color: var(--good); font-weight: 800; }
.lang-item .soon {
  margin-left: auto;
  font-size: 9px; font-weight: 700; letter-spacing: .5px; color: var(--muted);
  text-transform: uppercase; padding: 2px 6px; border: 1px solid var(--line); border-radius: 999px;
}
.lang-item.active { border-color: var(--accent); background: rgba(255,94,126,.08); }
.lang-item:hover { border-color: var(--accent); }
@media (max-width: 420px) {
  .lang-list { grid-template-columns: 1fr; }
}

/* ---------- Pro modal ---------- */
.pro-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.pro-modal.hidden { display: none; }
.pro-backdrop { position: absolute; inset: 0; background: rgba(8,9,12,.78); backdrop-filter: blur(6px); }
.pro-card {
  position: relative; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 18px; padding: 24px 22px 18px;
  max-width: 440px; width: 100%; box-shadow: 0 20px 70px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.4);
  animation: pro-in .25s ease-out;
}
@keyframes pro-in { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.pro-close {
  position: absolute; top: 10px; right: 12px; background: transparent; border: 0; color: var(--muted);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.pro-close:hover { color: var(--text); background: var(--panel-2); border: 0; }
.pro-hero { text-align: center; padding: 4px 0 12px; }
.pro-mark { display: inline-flex; padding: 6px; border-radius: 18px; background: var(--panel-2); margin-bottom: 8px; }
.pro-card h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: .3px; }
.pro-tagline { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.pro-price {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  background: linear-gradient(90deg, #ff5e7e, #ffb547, #3ec1ff);
  color: #0e0f12; font-weight: 800; font-size: 14px; letter-spacing: .3px;
}
.pro-bullets { list-style: none; padding: 0; margin: 14px 6px; font-size: 14px; }
.pro-bullets li { padding: 6px 0 6px 26px; position: relative; color: var(--text); }
.pro-bullets li::before {
  content: '✓'; position: absolute; left: 4px; top: 5px; color: var(--good); font-weight: 800;
}
.pro-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.pro-btn {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: #000; color: #fff; text-decoration: none; font-family: inherit; transition: transform .12s, box-shadow .12s;
}
.pro-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,.45); }
.pro-btn span { display: flex; flex-direction: column; line-height: 1.1; }
.pro-btn small { font-size: 9.5px; opacity: .85; letter-spacing: .5px; }
.pro-btn strong { font-size: 14px; font-weight: 700; letter-spacing: .2px; }
.pro-trust { text-align: center; color: var(--muted); font-size: 11.5px; margin: 12px 0 2px; }

/* ---------- Lock badge on gated features ---------- */
.pro-locked { position: relative; }
.pro-lock-badge {
  position: absolute; top: 6px; right: 6px;
  background: rgba(14,15,18,.85); color: #ffb547;
  font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 999px;
  letter-spacing: .4px; pointer-events: none; border: 1px solid rgba(255,181,71,.4);
}
.pro-locked.disabled { opacity: .55; filter: grayscale(.4); }

/* ---------- Pro chip on header / inline ---------- */
.pro-chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 10px; font-weight: 800;
  background: linear-gradient(90deg, #ff5e7e, #ffb547, #3ec1ff); color: #0e0f12;
  letter-spacing: .4px; vertical-align: middle; margin-left: 6px;
}

@media (max-width: 480px) {
  .pro-buttons { grid-template-columns: 1fr; }
}

/* ========================================================================
   Smooth motion polish — gentle animations, easing, micro-interactions
   ======================================================================== */

/* Respect users who explicitly disable motion (Reduce Motion in iOS settings) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Smooth global scrolling + iOS momentum */
html { scroll-behavior: smooth; }
body { -webkit-overflow-scrolling: touch; }

/* Page-load gentle fade-in */
body { animation: pageBoot 0.4s cubic-bezier(.2, 1, .3, 1); }
@keyframes pageBoot {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Tab content slides in when activated */
section.tab.active {
  animation: tabSwitch .42s cubic-bezier(.2, 1, .25, 1);
}
@keyframes tabSwitch {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* Cards inside the active tab fade up with subtle stagger */
section.tab.active > .card,
section.tab.active > .row > .col > .card {
  animation: cardRise .5s cubic-bezier(.2, 1, .25, 1) backwards;
}
section.tab.active > .row > .col:nth-child(1) > .card { animation-delay: 0ms; }
section.tab.active > .row > .col:nth-child(2) > .card { animation-delay: 80ms; }
section.tab.active > .row > .col:nth-child(3) > .card { animation-delay: 160ms; }
section.tab.active > .card:nth-of-type(1) { animation-delay: 0ms; }
section.tab.active > .card:nth-of-type(2) { animation-delay: 100ms; }
section.tab.active > .card:nth-of-type(3) { animation-delay: 200ms; }
@keyframes cardRise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* Color swatches transition smoothly when sample changes */
.swatch {
  transition: background .35s cubic-bezier(.2, 1, .25, 1), border-color .2s;
}

/* Universal button feedback — subtle press */
button, a.icon, .pro-btn, .menu-item, .recent-strip .r, .swatches-row .s, .harmony-row .s {
  transition:
    transform .14s cubic-bezier(.2, 1.05, .3, 1),
    background-color .2s,
    border-color .2s,
    box-shadow .25s,
    color .18s,
    opacity .2s;
}
button:not(:disabled):active, a.icon:active, .recent-strip .r:active, .menu-item:active {
  transform: scale(.96);
}

/* Grid items appear with staggered fade-up — used in Palettes, Library, Cross-system */
.grid .item, .swatches-row .s {
  animation: gridFadeIn .42s cubic-bezier(.2, 1, .25, 1) backwards;
}
.grid .item:nth-child(1)  { animation-delay: 0ms; }
.grid .item:nth-child(2)  { animation-delay: 25ms; }
.grid .item:nth-child(3)  { animation-delay: 50ms; }
.grid .item:nth-child(4)  { animation-delay: 75ms; }
.grid .item:nth-child(5)  { animation-delay: 100ms; }
.grid .item:nth-child(6)  { animation-delay: 125ms; }
.grid .item:nth-child(7)  { animation-delay: 150ms; }
.grid .item:nth-child(8)  { animation-delay: 175ms; }
.grid .item:nth-child(9)  { animation-delay: 200ms; }
.grid .item:nth-child(10) { animation-delay: 225ms; }
.grid .item:nth-child(n+11) { animation-delay: 250ms; }
.swatches-row .s:nth-child(1) { animation-delay: 0ms; }
.swatches-row .s:nth-child(2) { animation-delay: 35ms; }
.swatches-row .s:nth-child(3) { animation-delay: 70ms; }
.swatches-row .s:nth-child(4) { animation-delay: 105ms; }
.swatches-row .s:nth-child(5) { animation-delay: 140ms; }
.swatches-row .s:nth-child(6) { animation-delay: 175ms; }
@keyframes gridFadeIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: none; }
}

/* Harmony rows fade in horizontally with subtle bounce */
.harmony-row {
  animation: harmonySlide .45s cubic-bezier(.2, 1.1, .3, 1) backwards;
}
.harmony-row:nth-child(1) { animation-delay: 0ms; }
.harmony-row:nth-child(2) { animation-delay: 50ms; }
.harmony-row:nth-child(3) { animation-delay: 100ms; }
.harmony-row:nth-child(4) { animation-delay: 150ms; }
.harmony-row:nth-child(5) { animation-delay: 200ms; }
.harmony-row:nth-child(6) { animation-delay: 250ms; }
.harmony-row:nth-child(7) { animation-delay: 300ms; }
@keyframes harmonySlide {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: none; }
}

/* Toast slide-up + fade */
.toast {
  transition: opacity .28s ease, transform .28s cubic-bezier(.2, 1, .3, 1);
  transform: translate(-50%, 14px);
}
.toast.show { transform: translate(-50%, 0); }

/* Pro chip subtle breath animation — invites attention without being annoying */
.pro-chip {
  animation: chipBreath 3s ease-in-out infinite;
}
@keyframes chipBreath {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.07); }
}

/* Get Pro CTA — subtle shimmer on hover (desktop) */
header.top a.icon.pro-cta {
  position: relative;
  overflow: hidden;
}
header.top a.icon.pro-cta::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%);
  transform: translateX(-100%);
  pointer-events: none;
}
header.top a.icon.pro-cta:hover::after {
  animation: ctaShimmer 1.1s ease-in-out;
}
@keyframes ctaShimmer {
  to { transform: translateX(100%); }
}

/* Tab nav active indicator slides smoothly when changing */
nav.tabs button {
  transition: color .2s, border-bottom-color .25s;
}

/* Pro modal entrance — already had .2s, smooth out */
.pro-modal:not(.hidden) .pro-card {
  animation: proCardIn .35s cubic-bezier(.2, 1.05, .3, 1);
}
@keyframes proCardIn {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to { opacity: 1; transform: none; }
}
.pro-backdrop { animation: bdFade .2s ease-out; }
@keyframes bdFade { from { opacity: 0; } to { opacity: 1; } }

/* Lock badge subtle entrance */
.pro-lock-badge {
  animation: badgeIn .35s cubic-bezier(.2, 1.1, .3, 1) backwards;
  animation-delay: 200ms;
}
@keyframes badgeIn {
  from { opacity: 0; transform: scale(.6); }
  to { opacity: 1; transform: scale(1); }
}

/* Hero color formats list — gentle stagger fade */
.hero-color .formats > * {
  animation: formatIn .3s ease-out backwards;
}
.hero-color .formats > *:nth-child(1)  { animation-delay: 0ms; }
.hero-color .formats > *:nth-child(2)  { animation-delay: 15ms; }
.hero-color .formats > *:nth-child(3)  { animation-delay: 30ms; }
.hero-color .formats > *:nth-child(4)  { animation-delay: 45ms; }
.hero-color .formats > *:nth-child(5)  { animation-delay: 60ms; }
.hero-color .formats > *:nth-child(6)  { animation-delay: 75ms; }
.hero-color .formats > *:nth-child(7)  { animation-delay: 90ms; }
.hero-color .formats > *:nth-child(8)  { animation-delay: 105ms; }
.hero-color .formats > *:nth-child(9)  { animation-delay: 120ms; }
.hero-color .formats > *:nth-child(10) { animation-delay: 135ms; }
.hero-color .formats > *:nth-child(11) { animation-delay: 150ms; }
.hero-color .formats > *:nth-child(12) { animation-delay: 165ms; }
.hero-color .formats > *:nth-child(13) { animation-delay: 180ms; }
.hero-color .formats > *:nth-child(14) { animation-delay: 195ms; }
.hero-color .formats > *:nth-child(15) { animation-delay: 210ms; }
.hero-color .formats > *:nth-child(16) { animation-delay: 225ms; }
@keyframes formatIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Toolbar / FAB hover and active — smoother */
.fab {
  transition: transform .18s cubic-bezier(.2, 1.1, .3, 1), border-color .2s, box-shadow .25s;
}
.fab:hover { transform: scale(1.05); }
.fab:active { transform: scale(.92); }

/* Tools circle gets a subtle continuous "alive" pulse to draw attention initially */
.tab-trigger-circle::after {
  content: ''; position: absolute; inset: -1px; border-radius: 50%;
  border: 2px solid rgba(255, 94, 126, .35);
  pointer-events: none;
  animation: toolsPulse 2.5s ease-out infinite;
}
@keyframes toolsPulse {
  0%   { transform: scale(1);   opacity: 0; }
  35%  { transform: scale(1.18); opacity: .8; }
  100% { transform: scale(1.4); opacity: 0; }
}
/* Stop the pulse once the user has opened the menu (no need to draw attention anymore) */
body.tab-menu-open .tab-trigger-circle::after,
body.tab-menu-opened-once .tab-trigger-circle::after { animation: none; opacity: 0; }

/* Smooth color transition on hover for grid items */
.grid .item { transition: transform .15s cubic-bezier(.2, 1, .3, 1), border-color .18s, box-shadow .25s; }
.grid .item:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.grid .item:active { transform: scale(.97); }

/* Recent strip color squares pop on hover */
.recent-strip .r:hover { transform: scale(1.15); border-color: var(--accent); }

/* Save Palette & primary buttons get a gentle press feedback */
button.primary {
  transition: transform .15s, filter .2s, box-shadow .25s;
}
button.primary:hover { filter: brightness(1.07); box-shadow: 0 4px 14px rgba(255, 94, 126, .35); }
button.primary:active { transform: scale(.97); }
