/* ============================================
   Clarke Size Finder V2
   Standalone modal size recommendation
   ============================================ */

/* --- Reset for all SF2 elements --- */
.clarke-sf2 *,
.clarke-sf2-overlay,
.clarke-sf2-modal,
.clarke-sf2-modal * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Theme isolation — prevent Shopify theme styles bleeding in --- */
.clarke-sf2-modal,
.clarke-sf2-modal * {
  font-family: var(--sf2-font, sans-serif);
  text-transform: none;
  letter-spacing: normal;
  word-spacing: normal;
  font-style: normal;
  font-variant: normal;
  text-decoration: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* --- Custom Properties ---
   Fixed defaults — does not inherit radius/corners from the Shopify theme.
   Colors and font still fall back to theme tokens where sensible.
   Merchants can override radius via block settings. */
.clarke-sf2 {
  --sf2-primary: var(--color-button, #000000);
  --sf2-primary-hover: var(--color-button-text, #333333);
  --sf2-text: var(--color-foreground, #1a1a1a);
  --sf2-bg: var(--color-background, #ffffff);
  --sf2-bg-secondary: #f7f7f8;
  --sf2-text-secondary: #6b7280;
  --sf2-border: var(--color-border, #e5e7eb);
  --sf2-font: var(--font-body-family, inherit);
  --sf2-radius: 8px;
  --sf2-radius-lg: 16px;
  --sf2-input-radius: 8px;
  --sf2-success: #16a34a;
  --sf2-success-bg: #f0fdf4;
  --sf2-success-border: #bbf7d0;
  --sf2-error: #dc2626;

  display: inline;
  font-family: var(--sf2-font);
}

/* --- Trigger Button --- */
.clarke-sf2-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: none;
  color: var(--sf2-text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  padding: 2px 0;
  transition: color 0.1s ease;
}

.clarke-sf2-trigger:hover {
  color: var(--sf2-primary);
}

.clarke-sf2-trigger:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: 3px;
  border-radius: 2px;
}

.clarke-sf2-trigger[data-size-found] {
  color: var(--sf2-text);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

/* --- Trigger Row (side-by-side buttons) --- */
.clarke-sf2-trigger-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.clarke-sf2-trigger-divider {
  color: var(--sf2-border, #e5e7eb);
  font-size: 0.9em;
  line-height: 1;
  user-select: none;
}

/* --- Size Chart Step --- */
.sf2-chart-wrap {
  padding: 4px 0 8px;
  width: 100%;
}

.sf2-chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--sf2-text);
  margin: 0 0 12px;
}

.sf2-chart-unit-toggle {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 14px;
}

.sf2-chart-unit-btn {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--sf2-border);
  background: none;
  color: var(--sf2-text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.sf2-chart-unit-btn.active {
  background: var(--sf2-primary);
  color: var(--sf2-bg, #fff);
  border-color: var(--sf2-primary);
}

.sf2-chart-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--sf2-border);
  border-radius: var(--sf2-radius, 8px);
}

/* When in chart step, expand table to full modal width (break out of body padding) */
.sf2-modal-is-chart .clarke-sf2-body {
  padding-left: 0;
  padding-right: 0;
  overflow-x: hidden;
}

.sf2-modal-is-chart .sf2-chart-wrap {
  padding-left: 20px;
  padding-right: 20px;
}

.sf2-modal-is-chart .sf2-chart-table-wrap {
  border-radius: 0;
  border-left: none;
  border-right: none;
  margin: 0;
}

.sf2-modal-is-chart .sf2-chart-find-link {
  margin-left: 20px;
}

.sf2-chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  color: var(--sf2-text);
  white-space: nowrap;
}

.sf2-chart-table th {
  background: var(--sf2-bg-secondary, #f7f7f8);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--sf2-border);
}

.sf2-chart-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--sf2-border);
}

.sf2-chart-table tr:last-child td {
  border-bottom: none;
}

.sf2-chart-empty {
  text-align: center;
  color: var(--sf2-text);
  opacity: 0.6;
  font-size: 0.9rem;
  padding: 24px 0;
}

.sf2-chart-loading {
  text-align: center;
  color: var(--sf2-text);
  opacity: 0.5;
  font-size: 0.9rem;
  padding: 32px 0;
}

.sf2-chart-find-link {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.85rem;
  color: var(--sf2-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: 0;
  margin-top: 14px;
  display: inline-block;
  opacity: 0.7;
}

.sf2-chart-find-link:hover {
  opacity: 1;
}

/* --- Overlay --- */
.clarke-sf2-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.clarke-sf2-overlay.sf2-visible {
  opacity: 1;
  visibility: visible;
}

/* --- Modal --- */
.clarke-sf2-modal {
  /* Fallback defaults — overridden at runtime by _syncBrandVars() which
     copies the resolved values from .clarke-sf2 into the modal.
     These are only used if _syncBrandVars fails or on the preview page. */
  --sf2-primary: #000000;
  --sf2-primary-hover: #333333;
  --sf2-text: #1a1a1a;
  --sf2-bg: #ffffff;
  --sf2-bg-secondary: #f7f7f8;
  --sf2-text-secondary: #6b7280;
  --sf2-border: #e5e7eb;
  --sf2-font: inherit;
  --sf2-radius: 0px;
  --sf2-radius-lg: 0px;
  --sf2-input-radius: 0px;
  --sf2-success: #16a34a;
  --sf2-success-bg: #f0fdf4;
  --sf2-success-border: #bbf7d0;
  --sf2-error: #dc2626;

  position: fixed;
  z-index: 99999;
  font-family: var(--sf2-font);
  color: var(--sf2-text);
  background: var(--sf2-bg);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.clarke-sf2-modal.sf2-visible {
  opacity: 1;
  visibility: visible;
}

/* Desktop — compact content-sized card */
@media (min-width: 641px) {
  .clarke-sf2-modal {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -48%);
    width: 460px;
    max-height: 85vh;
    overflow: hidden;
    border-radius: var(--sf2-radius-lg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  }
  .clarke-sf2-modal.sf2-visible {
    transform: translate(-50%, -50%);
  }
}

/* Mobile — bottom sheet */
@media (max-width: 640px) {
  .clarke-sf2-modal {
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    overflow: hidden;
    border-radius: var(--sf2-radius-lg) var(--sf2-radius-lg) 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(100%);
  }
  .clarke-sf2-modal.sf2-visible {
    transform: translateY(0);
  }
}

/* Drag handle (mobile) */
.clarke-sf2-handle {
  display: none;
}

@media (max-width: 640px) {
  .clarke-sf2-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 2px;
    flex-shrink: 0;
  }
  .clarke-sf2-handle span {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--sf2-border);
  }
}

/* --- Header — minimal, just close in top-right --- */
.clarke-sf2-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 12px 0;
  flex-shrink: 0;
}

/* Back button floats left when present */
.clarke-sf2-header-left {
  position: absolute;
  left: 12px;
  top: 12px;
}

/* Icon buttons (close, back) — 44px touch target */
.sf2-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--sf2-text-secondary);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
}

.sf2-icon-btn:hover {
  background: var(--sf2-bg-secondary);
  color: var(--sf2-text);
}

.sf2-icon-btn:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: -2px;
}

.sf2-icon-btn svg {
  width: 20px;
  height: 20px;
}

/* --- Body --- */
.clarke-sf2-body {
  flex: 1;
  min-height: 420px;
  overflow-y: auto;
  padding: 16px 28px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- Step transitions --- */
.clarke-sf2-step {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: sf2SlideIn 0.3s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}

@keyframes sf2SlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.clarke-sf2-step.sf2-exiting {
  animation: sf2SlideOut 0.2s ease forwards;
}

@keyframes sf2SlideOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}

/* ===========================================
   STEP: Mode Selection
   =========================================== */

/* Hero title: "Find your fit for the / [Product name]" */
.sf2-mode-hero {
  width: 100%;
  text-align: left;
  margin-bottom: 14px;
}

.sf2-mode-hero--sm {
  margin-bottom: 16px;
}

.sf2-mode-eyebrow {
  font-size: 18px;
  font-weight: 400;
  color: var(--sf2-text-secondary);
  margin: 0 0 2px;
  line-height: 1.3;
}

.sf2-mode-heading {
  font-size: 28px;
  font-weight: 700;
  color: var(--sf2-text);
  margin: 0;
  line-height: 1.2;
  text-transform: none;
  letter-spacing: normal;
}

.sf2-mode-heading--sm {
  font-size: 22px;
  margin-bottom: 20px;
}

.sf2-mode-body-text {
  width: 100%;
  font-size: 15px;
  color: var(--sf2-text);
  margin: 0 0 20px;
  text-align: left;
  line-height: 1.5;
}

/* Intro block — "In 3 simple steps" card */
.sf2-intro-block {
  width: 100%;
  padding: 20px;
  border-radius: var(--sf2-radius);
  background: var(--sf2-bg-secondary);
  margin-bottom: 16px;
  text-align: left;
}

.sf2-intro-label {
  font-size: 13px;
  color: var(--sf2-text-secondary);
  margin: 0 0 16px;
  font-weight: 400;
}

.sf2-intro-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sf2-intro-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 400;
  color: var(--sf2-text);
}

.sf2-intro-steps li svg {
  width: 20px;
  height: 20px;
  color: var(--sf2-text);
  flex-shrink: 0;
}

/* CTA row — Get Started button right-aligned */
.sf2-mode-cta-row {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.sf2-btn-primary.sf2-btn-cta {
  width: auto;
  padding: 0 32px;
  min-width: 160px;
  height: 48px;
}

.sf2-mode-saved {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 16px;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--sf2-success-border);
  background: var(--sf2-success-bg);
  border-radius: var(--sf2-radius);
  cursor: pointer;
  transition: border-color 0.1s ease, background 0.1s ease;
}

.sf2-mode-saved:hover {
  border-color: var(--sf2-success);
}

.sf2-mode-saved:focus-visible {
  outline: 2px solid var(--sf2-success);
  outline-offset: 2px;
}

.sf2-mode-saved-label {
  font-size: 14px;
  color: var(--sf2-text);
}

.sf2-mode-saved-label strong {
  font-weight: 700;
}

.sf2-mode-saved-action {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sf2-success);
}

.sf2-mode-saved-action svg {
  width: 14px;
  height: 14px;
}

.sf2-mode-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.sf2-mode-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 20px;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--sf2-border);
  background: var(--sf2-bg);
  border-radius: var(--sf2-radius);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.1s ease, background 0.1s ease;
  width: 100%;
}

.sf2-mode-option:hover {
  border-color: var(--sf2-primary);
  background: var(--sf2-bg-secondary);
}

.sf2-mode-option:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: 2px;
}

.sf2-mode-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--sf2-radius);
  background: var(--sf2-bg-secondary);
  margin-bottom: 12px;
  color: var(--sf2-text);
}

.sf2-mode-icon svg {
  width: 22px;
  height: 22px;
}

.sf2-mode-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--sf2-text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sf2-mode-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--sf2-primary);
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--sf2-border);
  border-radius: 999px;
  padding: 2px 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sf2-mode-recommended {
  border-color: var(--sf2-primary);
  background: var(--sf2-bg-secondary);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.06);
}

@supports (background: color-mix(in srgb, red 10%, white)) {
  .sf2-mode-recommended {
    background: color-mix(in srgb, var(--sf2-primary) 8%, var(--sf2-bg));
  }
}

.sf2-mode-desc {
  font-size: 13px;
  color: var(--sf2-text-secondary);
  line-height: 1.4;
}

/* ===========================================
   STEP: Gender/Height/Weight Input
   =========================================== */
.sf2-input-title {
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 28px;
  letter-spacing: -0.01em;
  color: var(--sf2-text);
}

.sf2-field {
  width: 100%;
  margin-bottom: 20px;
}

.sf2-field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--sf2-text);
  margin-bottom: 8px;
}

.sf2-optional {
  font-weight: 400;
  color: var(--sf2-text-secondary);
}

.sf2-field-hint {
  display: block;
  font-size: 12px;
  color: var(--sf2-text-secondary);
  margin-top: 6px;
}

/* Segmented control */
.sf2-segmented {
  display: flex;
  width: 100%;
  background: var(--sf2-bg-secondary);
  border: 1px solid var(--sf2-border);
  border-radius: var(--sf2-radius);
  padding: 3px;
  gap: 3px;
}

.sf2-segmented-btn {
  flex: 1;
  height: 36px;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  border-radius: calc(var(--sf2-radius) - 2px);
  color: var(--sf2-text-secondary);
  font-family: var(--sf2-font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.sf2-segmented-btn:hover {
  color: var(--sf2-text);
}

.sf2-segmented-btn.sf2-segmented-active {
  background: var(--sf2-bg);
  color: var(--sf2-text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.sf2-segmented-btn:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: -2px;
}

/* Unit system switch (Imperial/Metric at top) */
.sf2-unit-system {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  flex-wrap: nowrap;
}

.sf2-unit-system-label {
  font-size: 11px;
  color: var(--sf2-text-secondary);
  letter-spacing: 0.02em;
  padding: 2px 6px;
  border-radius: 999px;
}

.sf2-unit-system-label.sf2-active {
  color: var(--sf2-text);
  font-weight: 600;
  background: var(--sf2-bg);
  border: 1px solid var(--sf2-border);
}

.sf2-field-helper {
  font-size: 12px;
  color: var(--sf2-text-secondary);
  margin: -2px 0 8px;
}

.sf2-unit-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.sf2-unit-switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.sf2-unit-switch-track {
  width: 34px;
  height: 18px;
  background: var(--sf2-border);
  border-radius: 999px;
  border: 1px solid var(--sf2-border);
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sf2-unit-switch-track::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sf2-bg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}

.sf2-unit-switch-input:checked + .sf2-unit-switch-track {
  background: var(--sf2-primary);
  border-color: var(--sf2-primary);
}

.sf2-unit-switch-input:checked + .sf2-unit-switch-track::after {
  transform: translateX(16px);
}

.sf2-unit-switch-input:focus-visible + .sf2-unit-switch-track {
  outline: 2px solid var(--sf2-primary);
  outline-offset: 2px;
}

/* Unit toggle (small, inline) - kept for backwards compatibility */
.sf2-unit-toggle-sm {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.sf2-unit-btn {
  padding: 6px 12px;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--sf2-border);
  background: var(--sf2-bg);
  border-radius: 6px;
  color: var(--sf2-text-secondary);
  font-family: var(--sf2-font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.1s ease;
}

.sf2-unit-btn:hover {
  border-color: var(--sf2-text-secondary);
}

.sf2-unit-btn.sf2-active {
  border-color: var(--sf2-primary);
  background: var(--sf2-primary);
  color: var(--sf2-bg);
}

.sf2-unit-btn:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: 2px;
}

/* Standard input */
.sf2-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  border: 1.5px solid var(--sf2-border);
  background: var(--sf2-bg);
  border-radius: var(--sf2-input-radius, var(--sf2-radius));
  color: var(--sf2-text);
  font-family: var(--sf2-font);
  font-size: 16px;
  transition: border-color 0.1s ease;
}

.sf2-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23949aa5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
}

.sf2-input:hover {
  border-color: var(--sf2-text-secondary);
}

.sf2-input:focus {
  outline: none;
  border-color: var(--sf2-primary);
}

.sf2-input::placeholder {
  color: var(--sf2-text-secondary);
  opacity: 0.6;
}

.sf2-input.sf2-has-error {
  border-color: var(--sf2-error);
}

/* Remove spinner from number input */
.sf2-input::-webkit-outer-spin-button,
.sf2-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Small input variant */
.sf2-input-sm {
  width: 70px;
  height: 44px;
  text-align: center;
}

/* Feet + inches row */
.sf2-height-ft-in {
  display: flex;
  gap: 12px;
}

.sf2-ft-input,
.sf2-in-input {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sf2-unit-inline {
  font-size: 14px;
  color: var(--sf2-text-secondary);
  font-weight: 500;
}

/* Input with unit label */
.sf2-input-with-unit {
  position: relative;
}

.sf2-input-with-unit .sf2-input {
  padding-right: 50px;
}

.sf2-unit-label {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--sf2-text-secondary);
  pointer-events: none;
}

/* Input error message */
.sf2-input-error {
  min-height: 20px;
  font-size: 13px;
  color: var(--sf2-error);
  text-align: center;
  margin-bottom: 8px;
}

/* Block button (full width) */
.sf2-btn-block {
  width: 100%;
  margin-top: 8px;
}

/* ===========================================
   STEP: Manual Measurement Input
   =========================================== */
.sf2-manual-title {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 4px;
  color: var(--sf2-text);
}

.sf2-manual-subtitle {
  font-size: 14px;
  color: var(--sf2-text-secondary);
  text-align: center;
  margin-bottom: 24px;
}

.sf2-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sf2-help-btn {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: none;
  color: var(--sf2-primary);
  font-family: var(--sf2-font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sf2-help-btn:hover {
  opacity: 0.7;
}

.sf2-help-btn:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

.sf2-help-text {
  font-size: 13px;
  color: var(--sf2-text-secondary);
  background: var(--sf2-bg-secondary);
  padding: 10px 12px;
  border-radius: var(--sf2-radius);
  margin-bottom: 8px;
  line-height: 1.5;
}

/* ===========================================
   STEP: Mobile Scan
   =========================================== */
.sf2-scan-mobile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--sf2-radius-lg);
  background: var(--sf2-bg-secondary);
  margin: 0 auto 20px;
  color: var(--sf2-text);
}

.sf2-scan-mobile-icon svg {
  width: 32px;
  height: 32px;
}

.sf2-scan-note {
  font-size: 13px;
  color: var(--sf2-text-secondary);
  text-align: center;
  margin-top: 16px;
  margin-bottom: 8px;
}

/* Copy link button */
.sf2-copy-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 44px;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--sf2-border);
  background: var(--sf2-bg);
  border-radius: var(--sf2-radius);
  color: var(--sf2-text);
  font-family: var(--sf2-font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.1s ease;
}

.sf2-copy-link:hover {
  border-color: var(--sf2-text-secondary);
}

.sf2-copy-link:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: 2px;
}

.sf2-copy-link.sf2-copied {
  color: var(--sf2-success);
  border-color: var(--sf2-success);
}

/* Fallback button */
.sf2-fallback-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: none;
  color: var(--sf2-text-secondary);
  font-family: var(--sf2-font);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  text-align: center;
}

.sf2-fallback-btn:hover {
  color: var(--sf2-text);
}

/* ===========================================
   STEP: Age Input
   =========================================== */
.sf2-age-title {
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 36px;
  letter-spacing: -0.01em;
  color: var(--sf2-text);
}

.sf2-age-input-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 8px;
}

/* Age +/- stepper buttons */
.sf2-age-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--sf2-border);
  background: var(--sf2-bg);
  border-radius: 50%;
  color: var(--sf2-text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.1s ease, background 0.1s ease;
  user-select: none;
  flex-shrink: 0;
}

.sf2-age-btn:hover {
  border-color: var(--sf2-primary);
  background: var(--sf2-bg-secondary);
}

.sf2-age-btn:active {
  transform: scale(0.95);
}

.sf2-age-btn:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: 2px;
}

/* Editable age display */
.sf2-age-display {
  text-align: center;
  min-width: 100px;
}

.sf2-age-input {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  border: none;
  background: transparent;
  font-family: var(--sf2-font);
  font-size: 56px;
  font-weight: 700;
  text-align: center;
  color: var(--sf2-text);
  line-height: 1;
  padding: 0;
  outline: none;
  caret-color: var(--sf2-primary);
}

/* Remove spinner from number input */
.sf2-age-input::-webkit-outer-spin-button,
.sf2-age-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.sf2-age-label {
  font-size: 13px;
  color: var(--sf2-text-secondary);
  margin-top: 6px;
}

.sf2-age-error {
  font-size: 13px;
  color: var(--sf2-error);
  min-height: 20px;
  text-align: center;
}

/* ===========================================
   STEP: Scan / QR
   =========================================== */

/* Override step centering — scan uses left-aligned layout */
.clarke-sf2-step[data-sf2-step="scan"] {
  align-items: stretch;
}

.sf2-scan-title {
  font-size: 22px;
  font-weight: 700;
  text-align: left;
  margin-bottom: 6px;
  color: var(--sf2-text);
  line-height: 1.25;
}

.sf2-scan-subtitle {
  font-size: 15px;
  color: var(--sf2-text-secondary);
  text-align: left;
  margin-bottom: 18px;
  line-height: 1.45;
}

/* Two-column card */
.sf2-scan-card {
  display: flex;
  flex-direction: row;
  gap: 16px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  width: 100%;
}

.sf2-scan-card-heading {
  font-size: 14px;
  font-weight: 500;
  color: var(--sf2-text);
  margin-bottom: 14px;
}

/* Left column: instructions */
.sf2-scan-instructions {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.sf2-scan-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.sf2-scan-tip-divider {
  height: 1px;
  background: var(--sf2-border);
  margin: 2px 0;
}

.sf2-scan-tip-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sf2-text);
}

.sf2-scan-tip-icon svg {
  width: 24px;
  height: 24px;
}

.sf2-scan-tip-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 4px;
}

.sf2-scan-tip-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--sf2-text);
  line-height: 1.3;
}

.sf2-scan-tip-desc {
  font-size: 12px;
  color: var(--sf2-text-secondary);
  line-height: 1.4;
}

/* Right column: QR code */
.sf2-scan-qr-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 160px;
}

.sf2-qr-container {
  width: 148px;
  height: 148px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  border-radius: var(--sf2-radius);
  background: var(--sf2-bg);
  border: 1px solid var(--sf2-border);
  overflow: hidden;
}

.sf2-qr-container img {
  width: 136px;
  height: 136px;
  object-fit: contain;
}

.sf2-qr-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--sf2-text-secondary);
  font-size: 13px;
}

/* URL copy row */
.sf2-scan-url-row {
  display: flex;
  align-items: center;
  width: 100%;
  border: 1px solid var(--sf2-border);
  border-radius: 8px;
  background: var(--sf2-bg);
  padding: 0 6px 0 10px;
  height: 36px;
  gap: 4px;
}

.sf2-scan-url-text {
  flex: 1;
  font-size: 11px;
  color: var(--sf2-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sf2-scan-copy-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sf2-text-secondary);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.1s, color 0.1s;
}

.sf2-scan-copy-btn:hover {
  background: var(--sf2-border);
  color: var(--sf2-text);
}

/* "Why do we need this?" popup */
.sf2-why-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 28px;
  right: 28px;
  background: var(--sf2-bg);
  border: 1px solid var(--sf2-border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 10;
  padding: 14px 16px;
}

.sf2-why-popup-inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.sf2-why-popup-icon {
  flex-shrink: 0;
  color: var(--sf2-text);
  display: flex;
  align-items: center;
}

.sf2-why-popup-text {
  font-size: 13px;
  color: var(--sf2-text);
  line-height: 1.5;
}

/* "Why do we need this?" footer link */
.sf2-scan-why-link,
.sf2-footer-link {
  background: none;
  border: none;
  font-size: 12px;
  font-family: var(--sf2-font);
  color: var(--sf2-text-secondary);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  order: 1;
}

.sf2-scan-why-link:hover,
.sf2-footer-link:hover {
  color: var(--sf2-text);
}

/* Legacy / mobile-only classes kept for mobile branch */
.sf2-scan-lead {
  font-size: 12px;
  color: var(--sf2-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.sf2-scan-disclaimer {
  position: relative;
  font-size: 12px;
  color: var(--sf2-text-secondary);
  line-height: 1.4;
  width: 100%;
  margin: 12px 0 18px;
  padding: 8px 10px 8px 32px;
  border-radius: var(--sf2-radius);
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--sf2-border);
}

.sf2-scan-privacy-note {
  font-size: 13px;
  color: var(--sf2-text-secondary);
  line-height: 1.5;
  margin: 0 0 20px;
}

/* Mobile: stack card columns */
@media (max-width: 640px) {
  .sf2-scan-card {
    flex-direction: column;
  }
  .sf2-scan-qr-col {
    width: 100%;
  }
  .sf2-qr-container {
    width: 160px;
    height: 160px;
    margin: 0 auto 8px;
  }
  .sf2-qr-container img {
    width: 148px;
    height: 148px;
  }
  .sf2-scan-title {
    font-size: 20px;
  }
}

.sf2-scan-progress {
  font-size: 12px;
  color: var(--sf2-text-secondary);
  margin-bottom: 12px;
}

/* Status indicator - Shimmer text */
.sf2-scan-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 24px;
  text-align: center;
}

.sf2-status-text {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--sf2-text);
}

.sf2-status-subtext {
  font-size: 11px;
  color: var(--sf2-text-secondary);
  line-height: 1.3;
}

/* Stage: Processing - faster shimmer */
.sf2-scan-status.sf2-status-processing .sf2-status-text {
  background: linear-gradient(90deg, var(--sf2-primary) 0%, var(--sf2-text-secondary) 40%, var(--sf2-bg) 50%, var(--sf2-text-secondary) 60%, var(--sf2-primary) 100%);
  background-size: 300% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: sf2TextShimmer 1.5s ease-in-out infinite;
}

/* Stage: Waiting - subtle animated dots */
.sf2-scan-status.sf2-status-waiting .sf2-status-text::after {
  content: "...";
  display: inline-block;
  width: 0;
  overflow: hidden;
  vertical-align: baseline;
  line-height: inherit;
  position: relative;
  top: 1px;
  animation: sf2Dots 1.2s steps(4, end) infinite;
}

/* Stage: Success - solid green */
.sf2-scan-status.sf2-status-success .sf2-status-text {
  background: none;
  -webkit-text-fill-color: var(--sf2-success);
  color: var(--sf2-success);
  animation: none;
}

/* Stage: Error - simple, focused on message */
.sf2-scan-status.sf2-status-error .sf2-status-text {
  background: none;
  -webkit-text-fill-color: var(--sf2-error);
  color: var(--sf2-error);
  animation: none;
  font-size: 15px;
  position: relative;
  padding-left: 18px;
}

.sf2-scan-status.sf2-status-error .sf2-status-subtext {
  color: var(--sf2-text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

.sf2-scan-status.sf2-status-error .sf2-status-text::before {
  content: "!";
  position: absolute;
  left: 0;
  top: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sf2-error);
  color: var(--sf2-bg);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===========================================
   Error Screen (replaces scan content on failure)
   =========================================== */
.sf2-error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 24px 24px;
}

.sf2-error-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--sf2-error) 10%, transparent);
  color: var(--sf2-error);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.sf2-error-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--sf2-text);
  margin: 0 0 8px;
  line-height: 1.3;
}

.sf2-error-hint {
  font-size: 14px;
  color: var(--sf2-text-secondary);
  margin: 0 0 32px;
  line-height: 1.5;
  max-width: 280px;
}

.sf2-error-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Mobile: error screen as compact bottom-sheet content */
@media (max-width: 640px) {
  .sf2-error-screen {
    padding: 24px 20px;
    justify-content: flex-end;
  }

  .sf2-error-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
  }

  .sf2-error-icon svg {
    width: 24px;
    height: 24px;
  }

  .sf2-error-title {
    font-size: 17px;
  }

  .sf2-error-hint {
    margin-bottom: 24px;
  }
}

/* Animations */
@keyframes sf2TextShimmer {
  0% { background-position: 200% center; }
  100% { background-position: -200% center; }
}

@keyframes sf2Dots {
  to { width: 1.2em; }
}

/* ===========================================
   STEP: Result
   =========================================== */
.sf2-result-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 16px;
}

.sf2-result-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--sf2-success-bg);
  border: 1.5px solid var(--sf2-success-border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  animation: sf2Pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes sf2Pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.sf2-result-icon svg {
  width: 22px;
  height: 22px;
  color: var(--sf2-success);
}

.sf2-result-size-name {
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  color: var(--sf2-text);
  text-transform: uppercase;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.sf2-set-sizes {
  font-size: 15px;
  font-weight: 500;
  color: var(--sf2-muted);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.sf2-result-confidence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 100px;
  background: var(--sf2-success-bg);
  border: 1px solid var(--sf2-success-border);
  color: var(--sf2-success);
  font-size: 13px;
  font-weight: 600;
}

.sf2-result-confidence svg {
  width: 14px;
  height: 14px;
}

/* Result hero — kicker + size, no background card */
.sf2-result-hero {
  width: 100%;
  text-align: center;
  margin-bottom: 20px;
}

.sf2-result-kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sf2-text-secondary);
  margin-bottom: 8px;
}

/* Description card */
.sf2-result-card {
  width: 100%;
  padding: 16px 20px;
  border-radius: var(--sf2-radius);
  margin-bottom: 16px;
  background: var(--sf2-bg-secondary);
  color: var(--sf2-text);
  border: 1px solid var(--sf2-border);
}

.sf2-result-card p {
  font-size: 15px;
  color: inherit;
  line-height: 1.6;
  text-align: left;
  margin: 0 0 12px;
}

.sf2-result-card p:last-child {
  margin-bottom: 0;
}

/* Update Measurements footer link */
.sf2-result-why-link {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: none;
  font-family: var(--sf2-font);
  font-size: 13px;
  font-weight: 400;
  color: var(--sf2-text);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  order: 1;
}

.sf2-result-why-link:hover {
  color: var(--sf2-text-secondary);
}

/* ===========================================
   STEP: Why This Size
   =========================================== */
.sf2-why-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 20px;
  color: var(--sf2-text);
}

.sf2-why-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.sf2-why-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--sf2-radius);
  background: var(--sf2-bg-secondary);
}

.sf2-why-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--sf2-radius);
  background: var(--sf2-success-bg);
  border: 1px solid var(--sf2-success-border);
  color: var(--sf2-success);
}

.sf2-why-icon svg {
  width: 18px;
  height: 18px;
}

.sf2-why-content {
  flex: 1;
  min-width: 0;
}

.sf2-why-item-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--sf2-text);
  margin-bottom: 2px;
}

.sf2-why-item-value {
  font-size: 13px;
  color: var(--sf2-text-secondary);
  line-height: 1.4;
}

/* ===========================================
   SHARED: Buttons
   =========================================== */

/* Primary — used for scan step "Open Scan" link/button */
.sf2-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: var(--sf2-radius);
  background: var(--sf2-primary);
  color: var(--sf2-bg);
  font-family: var(--sf2-font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s ease;
}

.sf2-btn-primary:hover {
  background: var(--sf2-primary-hover);
}

.sf2-btn-primary:active {
  transform: scale(0.98);
}

.sf2-btn-primary:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: 2px;
}

.sf2-btn-primary:disabled,
.sf2-btn-primary[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Secondary — outlined button for alternative actions */
.sf2-btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  border: 1.5px solid var(--sf2-border);
  border-radius: var(--sf2-radius);
  background: var(--sf2-bg);
  color: var(--sf2-text);
  font-family: var(--sf2-font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}

.sf2-btn-compact {
  height: 40px;
  font-size: 14px;
  font-weight: 500;
}

.sf2-btn-secondary:hover {
  border-color: var(--sf2-primary);
  background: var(--sf2-bg-secondary);
}

.sf2-btn-secondary:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: 2px;
}

.sf2-btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Button group — used within scan step body */
.sf2-btn-group {
  display: flex;
  flex-direction: row;
  gap: 10px;
  width: 100%;
}

.sf2-btn-group .sf2-btn-primary,
.sf2-btn-group .sf2-btn-secondary {
  flex: 1;
  min-width: 0;
}

/* ===========================================
   Footer — branding left, action right
   =========================================== */
.clarke-sf2-footer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 28px;
  min-height: 60px;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.clarke-sf2-footer-brand {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--sf2-text-secondary);
  order: 2;
  margin-left: auto;
}

.clarke-sf2-footer-brand a {
  color: var(--sf2-text);
  font-weight: 600;
  text-decoration: none;
}

.clarke-sf2-footer-brand a:hover {
  text-decoration: underline;
}

.clarke-sf2-footer-brand a:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

.clarke-sf2-footer-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.clarke-sf2-footer-logo {
  display: block;
  height: 22px;
  min-height: 22px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  image-rendering: auto;
}

/* Footer action button (smaller, fits alongside branding) */
.sf2-footer-action {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 24px;
  order: 1;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--sf2-border);
  border-radius: var(--sf2-radius);
  background: var(--sf2-bg);
  color: var(--sf2-text);
  font-family: var(--sf2-font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.1s ease, background 0.1s ease;
  flex-shrink: 0;
}

.sf2-footer-action:hover {
  border-color: var(--sf2-text-secondary);
  background: var(--sf2-bg-secondary);
}

.sf2-footer-action:active {
  transform: scale(0.98);
}

.sf2-footer-action:focus-visible {
  outline: 2px solid var(--sf2-primary);
  outline-offset: 2px;
}

/* ===========================================
   Utilities
   =========================================== */

/* Spinner */
.sf2-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--sf2-border);
  border-top-color: var(--sf2-primary);
  border-radius: 50%;
  animation: sf2Spin 0.7s linear infinite;
}

@keyframes sf2Spin {
  to { transform: rotate(360deg); }
}

/* ===========================================
   Safe area + reduced motion
   =========================================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 640px) {
    .clarke-sf2-footer {
      padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .clarke-sf2-modal,
  .clarke-sf2-overlay,
  .clarke-sf2-step,
  .sf2-result-icon,
  .sf2-progress-dot,
  .sf2-spinner,
  .sf2-status-text {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===========================================
   RESULT: Per-zone Fit Bars
   =========================================== */
.sf2-fit-bars {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 8px 0;
  padding: 10px 16px;
  border-radius: var(--sf2-radius);
  background: var(--sf2-bg-secondary);
}

.sf2-fit-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sf2-fit-bar-label {
  width: 80px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sf2-text);
  text-align: right;
  flex-shrink: 0;
}

.sf2-fit-bar-track {
  flex: 1;
  position: relative;
  height: 6px;
  overflow: visible;
  background: linear-gradient(to right, #f4a0a0 0%, #f0d060 20%, #6fcf6f 35%, #6fcf6f 65%, #f0d060 80%, #e8c840 100%);
  border-radius: 3px;
}

.sf2-fit-bar-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #27ae60;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  z-index: 1;
  pointer-events: none;
}

.sf2-fit-bar-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}

.sf2-fit-bar-legend-labels {
  flex: 1;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--sf2-text-secondary);
  opacity: 0.7;
}

.sf2-fit-bar-seg {
  flex: 1;
  border-radius: 4px;
  background: var(--sf2-border);
  transition: background 0.2s ease;
}

.sf2-fit-bar-rating {
  width: 80px;
  font-size: 12px;
  color: var(--sf2-text-secondary);
  flex-shrink: 0;
}

/* Result screen CTA stack */
.sf2-result-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
}

.sf2-result-chat-prompt {
  font-size: 14px;
  color: var(--sf2-text);
  margin: 0;
  text-align: center;
}

.sf2-result-chat-link {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: none;
  font-family: var(--sf2-font);
  font-size: 14px;
  color: var(--sf2-text);
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sf2-result-chat-link:hover {
  opacity: 0.7;
}

/* ===========================================
   STEP: Chat — AI-powered Q&A
   Clarke Design System · 60-30-10
   60% Cream · 30% Clarke Brown · 10% Light Brown accents
   =========================================== */

/* ── Clarke brand tokens (chat screen only) ─ */
.sf2-modal-is-chat {
  overflow: hidden !important;

  /* Brand palette — all shades of brown */
  --ck-brown:       #5A4138;
  --ck-brown-dark:  #4a342d;
  --ck-brown-light: #c4a39a;
  --ck-brown-pale:  #e8d8d3;
  --ck-cream:       #F4F1EC;
  --ck-fg:          #4A342C;
  --ck-fg-muted:    #8a6b60;
  --ck-border:      #ddd0c8;

  /* Override sf2 tokens so all chat components pick up Clarke colors */
  --sf2-primary:        var(--ck-brown);
  --sf2-primary-hover:  var(--ck-brown-dark);
  --sf2-bg:             var(--ck-cream);
  --sf2-bg-secondary:   #ffffff;
  --sf2-text:           var(--ck-fg);
  --sf2-text-secondary: var(--ck-fg-muted);
  --sf2-border:         var(--ck-border);
}

/* Chat body overrides — thread manages its own scroll internally */
.sf2-modal-is-chat .clarke-sf2-body {
  overflow: hidden;
  padding: 0;
  align-items: stretch;
}

@media (max-width: 640px) {
  .sf2-modal-is-chat {
    top: 0;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: var(--sf2-radius-lg) var(--sf2-radius-lg) 0 0;
  }
  /* Hide drag handle — not needed for fullscreen chat */
  .sf2-modal-is-chat .clarke-sf2-handle {
    display: none;
  }
}

@media (min-width: 641px) {
  .sf2-modal-is-chat {
    height: min(680px, 88vh);
    max-height: min(680px, 88vh);
  }
}

/* ── Chat header (white card surface) ───────── */
.sf2-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px;
  background: var(--sf2-bg-secondary);
  border-bottom: 1px solid var(--ck-border);
  flex-shrink: 0;
}

.sf2-chat-header-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  padding: 4px 4px;
}

.sf2-chat-header-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ck-fg);
  letter-spacing: -0.01em;
}

/* "AI size assistant" — dark → light brown shimmer (never goes lighter than --ck-brown-light) */
.sf2-chat-header-status {
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(90deg, var(--ck-brown-dark) 0%, var(--ck-brown) 30%, var(--ck-brown-light) 50%, var(--ck-brown) 70%, var(--ck-brown-dark) 100%);
  background-size: 300% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: sf2TextShimmer 2.5s ease-in-out infinite;
}

.sf2-chat-header-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ck-brown);
  flex-shrink: 0;
}

/* ── Icon buttons on white header — need visible hover ── */
.sf2-modal-is-chat .sf2-icon-btn:hover {
  background: var(--ck-brown-pale);
  color: var(--ck-fg);
}

/* ── Product context card (white surface on cream) ── */
.sf2-chat-context-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--sf2-bg-secondary);
  border-bottom: 1px solid var(--ck-border);
  flex-shrink: 0;
}

.sf2-chat-ctx-img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--sf2-radius);
  border: 1px solid var(--ck-border);
  flex-shrink: 0;
  background: var(--ck-cream);
}

.sf2-chat-ctx-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sf2-chat-ctx-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--ck-fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sf2-chat-ctx-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sf2-chat-ctx-size {
  font-size: 22px;
  font-weight: 800;
  color: var(--ck-fg);
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: 1;
}

.sf2-chat-ctx-sep {
  font-size: 13px;
  color: var(--ck-fg-muted);
  line-height: 1;
}

/* Match badge — pale brown bg + dark brown text = 8.2:1 contrast ✓ */
.sf2-chat-ctx-match {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  background: var(--ck-brown-pale);
  color: var(--ck-fg);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}

/* ── Chat step — cream background (60%) ──── */
.sf2-chat-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
  background: var(--ck-cream);
}

/* ── Thread ──────────────────────────────── */
.sf2-chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
}

/* ── Message rows ────────────────────────── */
.sf2-chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.sf2-chat-msg-ai {
  flex-direction: row;
  align-self: flex-start;
  max-width: 88%;
}

.sf2-chat-msg-user {
  flex-direction: row;
  justify-content: flex-end;
  align-self: flex-end;
  max-width: 78%;
}

/* ── Clarke avatar — dark → light brown gradient ── */
.sf2-chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ck-brown-dark) 0%, var(--ck-fg-muted) 100%);
  color: var(--ck-cream);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Message body ────────────────────────── */
.sf2-chat-msg-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

/* ── Bubbles ─────────────────────────────── */
.sf2-chat-bubble {
  padding: 11px 15px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
}

/* AI bubble — no background, plain text on the cream thread */
.sf2-chat-bubble-ai {
  background: transparent;
  color: var(--ck-fg);
  border-radius: 4px 18px 18px 18px;
  padding-left: 4px;
}

/* User bubble — Clarke Brown (30%), cream text, sharp top-right */
.sf2-chat-bubble-user {
  background: var(--ck-brown);
  color: var(--ck-cream);
  border-radius: 18px 4px 18px 18px;
}

.sf2-chat-bubble-content {
  margin: 0;
}

/* Images inside AI messages */
.sf2-chat-img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: 8px;
  margin-top: 10px;
  border: 1px solid var(--ck-border);
  background: var(--ck-cream);
}

/* Images in user bubbles — flush, no extra border */
.sf2-chat-img-user {
  margin-top: 0;
  border: none;
  background: transparent;
  border-radius: 14px 0 14px 14px;
  width: 100%;
  height: auto;
}

/* ── Composer (preview + input bar wrapper) ── */
.sf2-chat-composer {
  padding: 8px 12px 12px;
  background: var(--ck-cream);
  flex-shrink: 0;
}

/* Attachment preview sits inside the card, above the textarea */
.sf2-chat-attach-preview {
  padding: 10px 12px 0;
}

/* ── Attachment preview strip ────────────── */
.sf2-chat-attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sf2-chat-attach-thumb-wrap {
  position: relative;
  display: inline-flex;
}

.sf2-chat-attach-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--ck-border);
}

.sf2-chat-attach-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--ck-brown);
  color: var(--ck-cream);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* ── Attach (+) button ───────────────────── */
.sf2-chat-attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ck-fg-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
  padding: 0;
}

.sf2-chat-attach-btn:hover {
  background: var(--ck-brown-pale);
  color: var(--ck-brown);
}

.sf2-chat-attach-btn:disabled,
.sf2-chat-attach-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Feedback ────────────────────────────── */
.sf2-chat-feedback {
  display: flex;
  gap: 4px;
  padding: 0 2px;
}

.sf2-chat-feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--ck-brown-light);
  border-radius: 50%;
  background: var(--sf2-bg-secondary);
  color: var(--ck-fg-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.sf2-chat-feedback-btn:hover {
  border-color: var(--ck-brown);
  color: var(--ck-brown);
}

.sf2-chat-feedback-btn.sf2-chat-feedback-active {
  background: var(--ck-brown);
  border-color: var(--ck-brown);
  color: var(--ck-cream);
}

/* ── Typing indicator ────────────────────── */
.sf2-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 2px;
}

.sf2-chat-typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ck-fg-muted);
  animation: sf2TypingDot 1.3s ease-in-out infinite;
}

.sf2-chat-typing span:nth-child(1) { animation-delay: 0s; }
.sf2-chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.sf2-chat-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes sf2TypingDot {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* Streaming cursor */
.sf2-chat-streaming .sf2-chat-bubble-content > :not(.sf2-chat-typing)::after {
  content: '\258B';
  animation: sf2Blink 0.7s step-end infinite;
  margin-left: 1px;
  opacity: 0.6;
}

@keyframes sf2Blink {
  50% { opacity: 0; }
}

/* ── Suggested chips ─────────────────────── */
.sf2-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 16px 10px;
  flex-shrink: 0;
}

.sf2-chat-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 13px;
  border: 1px solid var(--ck-border);
  border-radius: 100px;
  background: var(--sf2-bg-secondary);
  color: var(--ck-fg);
  font-family: var(--sf2-font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.sf2-chat-chip:hover {
  border-color: var(--ck-brown);
  background: var(--ck-brown-pale);
}

/* ── Input card — single rounded container ── */
.sf2-chat-input-card {
  border: 1.5px solid var(--ck-border);
  border-radius: 16px;
  background: var(--sf2-bg);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease;
  outline: none !important;
  box-shadow: none !important;
}

.sf2-chat-input-card *,
.sf2-chat-input-card *:focus,
.sf2-chat-input-card *:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.sf2-chat-input-card:focus-within {
  border-color: var(--ck-brown-light);
  outline: none;
  box-shadow: none;
}

/* ── Textarea ────────────────────────────── */
.sf2-chat-input {
  width: 100%;
  height: 68px;
  padding: 14px 16px 8px;
  border: none;
  background: transparent;
  color: var(--sf2-text);
  font-family: var(--sf2-font);
  font-size: 15px;
  line-height: 1.5;
  outline: none;
  resize: none;
  overflow-y: hidden;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}

.sf2-chat-input:hover,
.sf2-chat-input:focus {
  background: transparent;
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
}

.sf2-chat-input::placeholder {
  color: var(--sf2-text-secondary);
}

.sf2-chat-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Action bar (bottom of card) ────────── */
.sf2-chat-input-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 8px;
}

.sf2-chat-input-actions-left {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ── Send button — filled circle ────────── */
.sf2-chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ck-brown-dark) 0%, var(--ck-fg-muted) 100%);
  color: var(--ck-cream);
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.1s ease;
  padding: 0;
}

.sf2-chat-send-btn:hover {
  opacity: 0.82;
}

.sf2-chat-send-btn:active {
  transform: scale(0.91);
}

.sf2-chat-send-btn:disabled,
.sf2-chat-send-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Mobile: prevent iOS zoom, safe area */
@media (max-width: 640px) {
  .sf2-chat-header {
    padding-top: max(6px, env(safe-area-inset-top, 0px));
    min-height: calc(52px + env(safe-area-inset-top, 0px));
  }

  .sf2-chat-input {
    font-size: 16px;
  }
  .sf2-chat-composer {
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  }
}

/* ============================================
   Custom Sizing Styles
   Added for custom/hybrid sizing modes
   ============================================ */

/* --- Custom intro text --- */
.sf2-custom-intro {
  color: var(--sf2-text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin: 8px 0 16px;
}

/* --- Custom measurements table --- */
.sf2-custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 12px 0;
}

.sf2-custom-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sf2-text-secondary);
  padding: 8px 12px;
  border-bottom: 2px solid var(--sf2-border);
}

.sf2-custom-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--sf2-border);
  vertical-align: middle;
}

.sf2-custom-table tbody tr:last-child td {
  border-bottom: none;
}

.sf2-custom-field {
  font-weight: 500;
  color: var(--sf2-text);
}

.sf2-custom-garment-val {
  color: var(--sf2-text);
}

/* --- Table wrapper with fade --- */
.sf2-custom-table-wrap {
  position: relative;
}

.sf2-custom-table-has-fade {
  overflow: hidden;
  max-height: 240px;
}

.sf2-custom-fade-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to bottom, transparent, var(--sf2-bg, #fff) 85%);
  pointer-events: none;
}

/* --- View all CTA --- */
.sf2-custom-view-all {
  display: block;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #c08050;
  text-decoration: none;
  padding: 10px 0 4px;
  margin: 4px 0 8px;
  transition: opacity 0.15s ease;
}
.sf2-custom-view-all:hover {
  opacity: 0.7;
}

/* --- Hybrid Mode Options --- */
.sf2-hybrid-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.sf2-hybrid-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--sf2-bg-secondary, #f7f7f8);
  border: 1px solid var(--sf2-border, #e5e7eb);
  border-radius: var(--sf2-radius, 10px);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: var(--sf2-font, inherit);
  color: var(--sf2-text, #1a1a1a);
}

.sf2-hybrid-option:hover {
  border-color: var(--sf2-primary, #000);
  box-shadow: 0 0 0 1px var(--sf2-primary, #000);
}

.sf2-hybrid-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sf2-bg, #fff);
  border-radius: 50%;
  border: 1px solid var(--sf2-border, #e5e7eb);
}

.sf2-hybrid-text {
  flex: 1;
  min-width: 0;
}

.sf2-hybrid-label {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.sf2-hybrid-desc {
  font-size: 13px;
  color: var(--sf2-text-secondary, #666);
  line-height: 1.4;
  margin-top: 2px;
}

.sf2-hybrid-arrow {
  flex-shrink: 0;
  opacity: 0.4;
  transition: opacity 0.15s;
}

.sf2-hybrid-option:hover .sf2-hybrid-arrow {
  opacity: 0.8;
}

