/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #050a12;
  --surface-1: rgba(255,255,255,.035);
  --surface-2: rgba(255,255,255,.06);
  --surface-3: rgba(255,255,255,.09);
  --border-subtle: rgba(255,255,255,.07);
  --border: rgba(255,255,255,.12);
  --border-strong: rgba(255,255,255,.22);
  --text-primary: #f0f2f5;
  --text-secondary: #b0b8c4;
  --text-muted: rgba(255,255,255,.45);
  --accent: #14b8a6;
  --accent-bright: #2dd4bf;
  --accent-dim: rgba(20,184,166,.15);
  --font: 'Avenir Next', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-base: 1rem;
  --text-lg: 1.125rem; --text-xl: 1.25rem; --text-2xl: 1.5rem;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-6: 24px; --space-8: 32px;
  --radius-sm: 8px; --radius: 12px; --radius-lg: 16px;
  --ease-snap: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 120ms; --dur: 200ms;

  /* Zone accent colors */
  --zone-head: #a78bfa;
  --zone-torso: #3b82f6;
  --zone-waist: #14b8a6;
  --zone-feet: #f59e0b;
  --zone-arm: #ef4444;
  --zone-hands: #f97316;
  --zone-accessories: #ec4899;
  --zone-sets: #8b5cf6;
}

html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  min-height: 100%;
  color: var(--text-primary);
  display: flex; flex-direction: column;
}

/* ── Layout ────────────────────────────────────────────────── */
.container {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 32px;
  padding-top: 40px;
  flex: 1;
}

/* ── Nav & Auth ────────────────────────────────────────────── */
nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-link {
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: background var(--dur), color var(--dur);
}
.nav-link:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.auth-toggle {
  padding: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  transition: background var(--dur), color var(--dur);
  display: flex;
  align-items: center;
}
.auth-toggle:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.auth-toggle svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: block;
}

/* ── Auth panel (collapsible) ──────────────────────────────── */
.auth-panel {
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border-subtle);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}
.auth-panel.open {
  max-height: 300px;
}
.auth-panel-inner {
  padding: 20px;
  max-width: 400px;
  margin: 0 auto;
}
.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.auth-tab {
  flex: 1;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur);
}
.auth-tab.active {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.auth-form input {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: var(--text-sm);
}
.auth-submit {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur);
}
.auth-submit:hover {
  background: var(--accent-bright);
}
#authUser {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.auth-username {
  color: var(--text-primary);
  font-weight: 600;
}
.auth-logout {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur);
}
.auth-logout:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.auth-divider {
  height: 1px;
  background: var(--border-subtle);
}

/* ── Button press feedback ────────────────────────────────────── */
button:active, .btn:active {
  transform: scale(0.97);
  transition-duration: var(--dur-fast);
}

/* ── Entrance animation ───────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Skeleton loading ─────────────────────────────────────────── */
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--surface-1) 25%, var(--surface-2) 50%, var(--surface-1) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 32px; left: 50%; z-index: 999;
  transform: translateX(-50%) translateY(100px);
  background: var(--accent);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: 0 4px 24px rgba(20,184,166,0.3);
  transition: transform 0.3s ease-out, opacity 0.3s;
  opacity: 0;
  pointer-events: none;
}
.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Footer ────────────────────────────────────────────────── */
.info-footer {
  text-align: center; padding: 20px var(--space-6) 28px;
  color: var(--text-muted); font-size: .78em; line-height: 1.8;
  border-top: 1px solid var(--border-subtle);
  margin-top: 48px;
}
.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--dur);
}
.footer-link:hover,
.footer-link:focus-visible {
  color: var(--text-secondary);
  text-decoration: underline;
}

/* ── Focus styles ──────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

/* ── Skip link ─────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  background: var(--accent-bright);
  color: #000;
  font-weight: 600;
  font-size: var(--text-sm);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
  transition: top var(--dur);
}
.skip-link:focus { top: 0; }

/* ── Reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ════════════════════════════════════════════════════════════════
   FitProfile — Core Identity
   ════════════════════════════════════════════════════════════════ */

/* ── Profile header card ──────────────────────────────────── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
  padding: 24px 28px;
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  animation: fadeIn 0.3s ease-out both;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--zone-torso) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-avatar svg {
  width: 36px;
  height: 36px;
  color: #fff;
  opacity: 0.9;
}

.profile-fields { flex: 1; min-width: 0; }

.profile-name-input {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border);
  padding: 8px 0;
  width: 100%;
  transition: border-color var(--dur);
}
.profile-name-input::placeholder { color: var(--text-muted); }
.profile-name-input:focus {
  outline: none;
  border-color: var(--accent);
}

.profile-pronouns-input {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  padding: 6px 0;
  width: 100%;
  margin-top: 4px;
}
.profile-pronouns-input::placeholder { color: var(--text-muted); }
.profile-pronouns-input:focus {
  outline: none;
  border-color: var(--border);
}

/* ── Progress & save state ────────────────────────────────── */
.profile-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.completeness {
  display: flex;
  align-items: center;
  gap: 8px;
}
.completeness-track {
  width: 90px;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.completeness-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  transition: width var(--dur) ease;
}
.completeness-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.save-state {
  font-size: var(--text-xs);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  white-space: nowrap;
}
.save-state[data-state="unsaved"] {
  color: #fbbf24;
  border-color: rgba(251,191,36,.28);
  background: rgba(251,191,36,.08);
}

/* ── Global search ─────────────────────────────────────────── */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  animation: fadeIn .3s ease-out .03s both;
}
.search-icon {
  position: absolute;
  left: 14px;
  display: flex;
  color: var(--text-muted);
  pointer-events: none;
}
.search-icon svg { width: 16px; height: 16px; }
#globalSearch {
  width: 100%;
  padding: 12px 42px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font);
  transition: border-color var(--dur), box-shadow var(--dur);
}
#globalSearch::placeholder { color: var(--text-muted); }
#globalSearch::-webkit-search-cancel-button { display: none; }
#globalSearch:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.search-clear {
  position: absolute;
  right: 10px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: all var(--dur);
}
.search-clear:hover { background: var(--surface-3); color: var(--text-primary); }

.search-results:not(:empty) { margin-bottom: 32px; }
.search-count,
.search-empty {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.search-empty { text-transform: none; letter-spacing: 0; font-size: var(--text-sm); }
.search-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-hit {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: 'title zone' 'detail zone';
  gap: 2px 12px;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: inherit;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--dur);
}
.search-hit:hover {
  background: var(--surface-2);
  border-color: var(--border);
  transform: translateX(2px);
}
.search-hit-title {
  grid-area: title;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}
.search-hit-detail {
  grid-area: detail;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}
.search-hit-detail:empty { display: none; }
.search-hit-zone {
  grid-area: zone;
  align-self: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}
.fav-dot { color: #fbbf24; }

/* ── Body Map Layout ──────────────────────────────────────── */
.body-map-section {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
  margin-bottom: 32px;
  animation: fadeIn 0.3s ease-out 0.05s both;
}

.body-map-container {
  padding: 32px 24px;
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.body-map-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 30%, rgba(20,184,166,0.04) 0%, transparent 60%),
    radial-gradient(circle at 50% 70%, rgba(59,130,246,0.03) 0%, transparent 50%);
  pointer-events: none;
}

.body-map-title {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 500;
  position: relative;
}

/* ── Zone sidebar (replaces legend) ──────────────────────── */
.zone-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.zone-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 14px;
  text-align: left;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--zone-color, var(--accent));
  border-radius: var(--radius-sm);
  color: inherit;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--dur);
  position: relative;
}
.zone-card:hover {
  background: var(--surface-2);
  border-left-width: 4px;
  transform: translateX(2px);
}
.zone-card.active {
  background: var(--surface-2);
  border-color: var(--zone-color, var(--accent));
  border-left-width: 4px;
  box-shadow: 0 0 16px rgba(var(--zone-color-rgb, 20,184,166), 0.1);
}
.zone-card.is-empty { opacity: .82; }
.zone-card.is-empty:hover,
.zone-card.is-empty.active { opacity: 1; }

.zone-card-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
/* The hint is guidance for an empty zone, not permanent chrome — it disappears
   once the zone has content, and on the narrow chip strip. */
.zone-card-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.35;
}
.zone-card:not(.is-empty) .zone-card-hint { display: none; }

.zone-card-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(var(--zone-color-rgb, 20,184,166), 0.12);
  flex-shrink: 0;
}
.zone-card-icon svg {
  width: 16px;
  height: 16px;
  color: var(--zone-color, var(--accent));
}

.zone-card-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.zone-card-count {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin-left: auto;
  border-radius: 11px;
  background: rgba(var(--zone-color-rgb, 20,184,166), 0.14);
  color: var(--zone-color, var(--accent));
  font-size: var(--text-xs);
  font-weight: 600;
  flex-shrink: 0;
}
.zone-card.is-empty .zone-card-count {
  background: var(--surface-2);
  color: var(--text-muted);
}

/* Zone color custom properties */
.zone-card[data-zone="head"] { --zone-color: var(--zone-head); --zone-color-rgb: 167,139,250; }
.zone-card[data-zone="torso"] { --zone-color: var(--zone-torso); --zone-color-rgb: 59,130,246; }
.zone-card[data-zone="waist-legs"] { --zone-color: var(--zone-waist); --zone-color-rgb: 20,184,166; }
.zone-card[data-zone="feet"] { --zone-color: var(--zone-feet); --zone-color-rgb: 245,158,11; }
.zone-card[data-zone="arm"] { --zone-color: var(--zone-arm); --zone-color-rgb: 239,68,68; }
.zone-card[data-zone="hands"] { --zone-color: var(--zone-hands); --zone-color-rgb: 249,115,22; }
.zone-card[data-zone="accessories"] { --zone-color: var(--zone-accessories); --zone-color-rgb: 236,72,153; }
.zone-card[data-zone="sets"] { --zone-color: var(--zone-sets); --zone-color-rgb: 139,92,246; }

/* ── SVG Anatomical Body Map ─────────────────────────────────
   Two layers in one SVG: `.body-art` is decoration and never receives
   pointer events, `.body-hit` owns every hit test. Hovering a region tints
   the art beneath it, so the highlight always matches the visible shape. */
.body-map {
  display: block;
  width: 100%;
  max-width: 260px;
  height: auto;
  margin: 0 auto;
  overflow: visible;
}

.body-art {
  pointer-events: none;
}

.art-part {
  transition: fill var(--dur) ease, opacity var(--dur) ease, filter var(--dur) ease;
  opacity: 0.5;
}

/* Each part carries its own glow colour, so every lit/dim rule below can share
   a single declaration block instead of repeating one per zone. */
.art-part.zone-head { fill: var(--zone-head); --glow: var(--zone-head); }
.art-part.zone-torso { fill: var(--zone-torso); --glow: var(--zone-torso); }
.art-part.zone-waist-legs { fill: var(--zone-waist); --glow: var(--zone-waist); }
.art-part.zone-feet { fill: var(--zone-feet); --glow: var(--zone-feet); }
.art-part.zone-arm { fill: var(--zone-arm); --glow: var(--zone-arm); }
.art-part.zone-hands { fill: var(--zone-hands); --glow: var(--zone-hands); }

/* Hit regions stay invisible at all times. The region is a rounded box for
   reliable pointing; drawing it would put a shape on screen that does not match
   the body underneath — the glow on the art is the feedback instead.
   Keyboard focus is the one exception: it must show where you are. */
.hit-zone {
  cursor: pointer;
  fill: transparent;
  stroke: transparent;
  stroke-width: 2;
  outline: none;
}
.hit-zone:focus-visible {
  stroke: #fff;
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

/* Dim the whole body while one region is engaged, then restore and glow the
   part matching that region. `drop-shadow` needs an explicit colour —
   `currentColor` on the art layer resolves to inherited text and glows white. */
.body-map:has(.hit-zone.is-active) .art-part { opacity: 0.28; }
.body-map:has(.hit-zone[data-zone="head"].is-active) .art-part.zone-head,
.body-map:has(.hit-zone[data-zone="torso"].is-active) .art-part.zone-torso,
.body-map:has(.hit-zone[data-zone="waist-legs"].is-active) .art-part.zone-waist-legs,
.body-map:has(.hit-zone[data-zone="feet"].is-active) .art-part.zone-feet,
.body-map:has(.hit-zone[data-zone="arm"].is-active) .art-part.zone-arm,
.body-map:has(.hit-zone[data-zone="hands"].is-active) .art-part.zone-hands {
  opacity: 1;
  filter: drop-shadow(0 0 10px var(--glow));
}

/* Hover is a pointing-device affordance only. On touch there is no un-hover, so
   the last-tapped region would stay lit in a state nobody chose. */
@media (hover: hover) {
  .body-map:has(.hit-zone:hover) .art-part { opacity: 0.28; }
  .body-map:has(.hit-zone[data-zone="head"]:hover) .art-part.zone-head,
  .body-map:has(.hit-zone[data-zone="torso"]:hover) .art-part.zone-torso,
  .body-map:has(.hit-zone[data-zone="waist-legs"]:hover) .art-part.zone-waist-legs,
  .body-map:has(.hit-zone[data-zone="feet"]:hover) .art-part.zone-feet,
  .body-map:has(.hit-zone[data-zone="arm"]:hover) .art-part.zone-arm,
  .body-map:has(.hit-zone[data-zone="hands"]:hover) .art-part.zone-hands {
    opacity: 1;
    filter: drop-shadow(0 0 10px var(--glow));
  }
}

/* ── Zone Panel (slide-in from right) ────────────────────── */
.zone-panel {
  position: fixed;
  top: 68px;
  right: 0;
  width: 480px;
  max-width: 92vw;
  height: calc(100vh - 68px);
  background: rgba(5, 10, 18, 0.98);
  backdrop-filter: blur(24px);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
  overflow-y: auto;
  z-index: 150;
}
.zone-panel.open {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: rgba(5, 10, 18, 0.95);
  backdrop-filter: blur(16px);
  z-index: 10;
}
.panel-header-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(var(--zone-color-rgb, 20,184,166), 0.15);
  flex-shrink: 0;
}
.panel-header-icon svg {
  width: 20px;
  height: 20px;
  color: var(--panel-accent, var(--accent));
}
.panel-header-text { flex: 1; min-width: 0; }
.panel-header h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}
.panel-header-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

/* Grip is the mobile sheet's drag/close affordance; on desktop it is absent. */
.panel-grip { display: none; }
.close-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--dur);
}
.close-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.panel-body {
  padding: 24px;
}

/* ── Sections within zone panel ──────────────────────────── */
.section {
  margin-bottom: 28px;
}
.section-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 24px 0;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section h3 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--panel-accent, var(--accent));
  display: flex;
  align-items: center;
  gap: 8px;
}
.section h3::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 16px;
  background: var(--panel-accent, var(--accent));
  border-radius: 2px;
}
.section h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ── Form elements ────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--panel-accent, var(--accent));
  box-shadow: 0 0 0 3px rgba(var(--zone-color-rgb, 20,184,166), 0.1);
}
.form-group textarea {
  min-height: 80px;
  resize: vertical;
}
.form-group input[type="number"] {
  font-family: ui-monospace, 'SF Mono', 'Courier New', monospace;
  letter-spacing: 0.5px;
}

/* ── Select with custom input combo ───────────────────────── */
.select-with-custom {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.select-with-custom select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font);
  cursor: pointer;
  transition: border-color var(--dur), box-shadow var(--dur);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23b0b8c4' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.select-with-custom select:focus {
  outline: none;
  border-color: var(--panel-accent, var(--accent));
  box-shadow: 0 0 0 3px rgba(var(--zone-color-rgb, 20,184,166), 0.1);
}
.select-with-custom select option {
  background: var(--bg);
  color: var(--text-primary);
}
.select-with-custom .custom-input {
  display: none;
}
.select-with-custom .custom-input.visible {
  display: block;
}

/* ── Toggle switch ────────────────────────────────────────── */
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--text-secondary);
}
.toggle input[type="checkbox"] {
  width: 36px;
  height: 20px;
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: all var(--dur);
}
.toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--dur);
}
.toggle input[type="checkbox"]:checked {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.toggle input[type="checkbox"]:checked::after {
  left: 18px;
  background: var(--accent);
}

/* ── Item rows ─────────────────────────────────────────────────
   One stored item is three stacked bands: identity, size + fit, notes.
   The size only means something alongside the system it belongs to, so the
   two sit in a single bordered pair rather than as separate fields. */
.brands-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  transition: border-color var(--dur), background var(--dur);
}
.item-row:hover { border-color: var(--border); }
.item-row:focus-within {
  border-color: var(--border);
  border-left-color: var(--panel-accent, var(--accent));
  background: var(--surface-2);
}
.item-row.is-fav { border-left-color: #fbbf24; }

.item-row input,
.item-row select {
  padding: 8px 10px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font);
  min-width: 0;
  transition: border-color var(--dur);
}
.item-row input:focus,
.item-row select:focus {
  outline: none;
  border-color: var(--panel-accent, var(--accent));
}
.item-row input::placeholder { color: var(--text-muted); }
.item-row input:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.item-row-main {
  display: flex;
  align-items: center;
  gap: 6px;
}
.item-name {
  flex: 1;
  font-weight: 500;
}

.fav-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--dur);
}
.fav-btn svg { width: 16px; height: 16px; fill: none; }
.fav-btn:hover { color: #fbbf24; background: rgba(251,191,36,.08); }
.fav-btn[aria-pressed="true"] { color: #fbbf24; }
.fav-btn[aria-pressed="true"] svg { fill: #fbbf24; }

.item-row-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.field-pair {
  display: flex;
  flex: 1 1 180px;
  min-width: 0;
}
.field-pair .item-size {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
  font-family: ui-monospace, 'SF Mono', 'Courier New', monospace;
}
.field-pair .item-system {
  flex-shrink: 0;
  width: auto;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
}
.field-pair .item-system option {
  background: var(--bg);
  color: var(--text-primary);
}

.fit-group {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.fit-chip {
  padding: 7px 11px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--dur);
}
.fit-chip:hover {
  color: var(--text-primary);
  border-color: var(--border);
}
.fit-chip.selected {
  background: var(--accent-dim);
  border-color: var(--panel-accent, var(--accent));
  color: var(--text-primary);
  font-weight: 600;
}

.item-notes {
  width: 100%;
  font-size: var(--text-xs) !important;
}

.empty-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: 4px 0 2px;
}
.field-note {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 8px;
}
.add-row { align-self: flex-start; }

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* ── Measurement inputs in the panel ─────────────────────── */
.measure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}
.measure-field { margin-bottom: 0; }
.input-unit { position: relative; display: flex; }
.input-unit input { padding-right: 40px !important; }
.input-unit .unit {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-xs);
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Products/Sets lists ──────────────────────────────────── */
.product-item, .set-item, .set-subitem {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px;
  background: var(--surface-1);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  align-items: center;
}
.product-item input, .set-item input, .set-subitem input {
  flex: 1;
  padding: 8px 10px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: var(--text-sm);
}
.product-item input:focus, .set-item input:focus, .set-subitem input:focus {
  outline: none;
  border-color: var(--panel-accent, var(--accent));
}

/* A set stacks its title above its pieces, so it opts out of the shared row flex */
.set-item {
  display: block;
}
.set-item-head {
  display: flex;
  gap: 8px;
  align-items: center;
}
.set-item-head input { flex: 1; }

.set-items {
  margin-top: 12px;
  padding-left: 12px;
  border-left: 2px solid var(--border-subtle);
}
.set-subitem:last-of-type { margin-bottom: 12px; }

/* ── Preferences section ──────────────────────────────────── */
.preferences-section {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface-1);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  padding: 10px 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur);
}
.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
  box-shadow: 0 4px 16px rgba(20,184,166,0.25);
}
.btn-sm {
  padding: 7px 14px;
  font-size: var(--text-xs);
}
.btn-xs {
  padding: 4px 10px;
  font-size: var(--text-xs);
}
.btn-icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all var(--dur);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.2);
  color: #ef4444;
}
.btn-icon svg {
  width: 14px;
  height: 14px;
}

/* ── Action bar ───────────────────────────────────────────── */
.action-bar {
  display: flex;
  gap: 12px;
  justify-content: center;
  animation: fadeIn 0.3s ease-out 0.1s both;
}
.export-bar {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}
.import-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

/* ── Profile View Mode (read-only) ────────────────────────── */
.profile-card {
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 40px;
  animation: fadeIn 0.3s ease-out both;
}
.profile-card-header {
  text-align: center;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}
.profile-card-header h1 {
  color: var(--text-primary);
  font-size: var(--text-2xl);
  margin-bottom: 8px;
}
.profile-card-header .pronouns {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.profile-card-body h3 {
  color: var(--accent);
  margin: 24px 0 12px;
  font-size: var(--text-base);
  display: flex;
  align-items: center;
  gap: 8px;
}
.profile-card-body h3::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
}

.measurement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.measurement-item {
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}
.measurement-item .label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.measurement-item .value {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  font-family: ui-monospace, 'SF Mono', monospace;
}

.category-section {
  margin-bottom: 20px;
}
.category-section h4 {
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.category-section ul {
  list-style: none;
  padding-left: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.category-section li {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: 6px 12px;
  background: var(--surface-2);
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}
.category-section li.is-fav { border-color: rgba(251,191,36,.35); }

/* ── Modals ────────────────────────────────────────────────── */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 4, 12, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-header h2 {
  color: var(--text-primary);
  font-size: var(--text-lg);
}
.modal-body {
  padding: 24px;
}

/* Share modal */
.share-url {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.share-url input {
  flex: 1;
  padding: 10px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: ui-monospace, monospace;
  font-size: var(--text-sm);
}
.qr-code-container {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}
.qr-code-container canvas {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.password-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}
.password-section label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

/* ── Responsive ───────────────────────────────────────────── */

/* Tablet: the map stacks above the zone list */
@media (max-width: 900px) {
  .container { padding: 24px 20px; }

  .body-map-section {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .body-map-container {
    max-width: 460px;
    margin: 0 auto;
    width: 100%;
  }

  .zone-sidebar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
  }
  .zone-card-hint { display: none; }

  .zone-panel {
    width: 440px;
  }
}

/* ── Phone: the panel becomes a bottom sheet ──────────────────
   A right-hand drawer on a 390px screen is just a full-screen takeover with
   the wrong animation. Below this width the panel rises from the bottom,
   leaving the map visible above it, and the zone list becomes a swipeable
   chip strip so it never eats the fold. */
@media (max-width: 700px) {
  .container { padding: 16px 12px 24px; }

  .profile-header {
    flex-wrap: wrap;
    padding: 18px 16px;
    gap: 14px;
  }
  .profile-avatar { width: 52px; height: 52px; }
  .profile-avatar svg { width: 26px; height: 26px; }
  .profile-fields { flex: 1 1 180px; }
  .profile-meta {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-basis: 100%;
  }

  .body-map-container { padding: 20px 12px; }
  .body-map { max-width: 210px; }

  /* Horizontal chip strip — scrolls under the thumb, snaps per chip.
     It sits above the map: on a phone the chips are the fast path, and a
     500px-tall figure would otherwise push every zone below the fold. */
  .zone-sidebar {
    display: flex;
    flex-direction: row;
    grid-template-columns: none;
    order: -1;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
    margin-inline: -12px;
    padding-inline: 12px;
    scrollbar-width: none;
  }
  .zone-sidebar::-webkit-scrollbar { display: none; }
  .zone-card {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 10px 12px;
    border-left-width: 0;
    border-top: 3px solid var(--zone-color, var(--accent));
    border-radius: var(--radius-sm);
  }
  .zone-card:hover,
  .zone-card.active { transform: none; border-left-width: 0; border-top-width: 3px; }
  .zone-card-count { margin-left: 4px; }

  .zone-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 86dvh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    box-shadow: 0 -12px 40px rgba(0,0,0,.55);
    overscroll-behavior: contain;
  }
  .zone-panel.open { transform: translateY(0); }

  .panel-grip {
    display: block;
    width: 44px;
    height: 4px;
    margin: 10px auto 2px;
    border-radius: 2px;
    background: var(--border-strong);
    cursor: pointer;
  }
  .panel-header { padding: 12px 18px; top: 0; }
  .panel-body { padding: 18px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }

  /* The sheet covers the page, so the page must not scroll behind it */
  body.panel-open { overflow: hidden; }

  .item-row-detail { gap: 6px; }
  .field-pair { flex-basis: 100%; }
  .fit-group { width: 100%; }
  .fit-chip { flex: 1; padding: 9px 8px; }

  .search-hit {
    grid-template-columns: 1fr;
    grid-template-areas: 'title' 'detail' 'zone';
  }
  .search-hit:hover { transform: none; }

  .action-bar { flex-direction: column; }
  .action-bar .btn { width: 100%; }
  .export-bar {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .export-bar .btn,
  .export-bar .import-label {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  .measurement-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-card { padding: 20px 16px; }
}

/* Very small screens */
@media (max-width: 380px) {
  .body-map { max-width: 180px; }
  .measure-grid { grid-template-columns: 1fr; }
}
