/* Polaris-faithful tokens (matches Shopify admin v13+) */
:root {
  --p-bg: #f1f1f1;
  --p-bg-surface: #ffffff;
  --p-bg-surface-secondary: #fafafa;
  --p-bg-surface-tertiary: #f3f3f3;
  --p-bg-surface-success: #cdfee1;
  --p-bg-surface-success-subdued: #e3fded;
  --p-bg-surface-info: #ebf9fc;
  --p-bg-surface-warning: #fff5d4;
  --p-bg-surface-critical: #fff0f0;
  --p-bg-fill-brand: #303030;
  --p-bg-fill-brand-hover: #1a1a1a;
  --p-bg-fill-success: #1f513f;
  --p-bg-fill-info-secondary: #4ea7d8;

  --p-text: #303030;
  --p-text-secondary: #616161;
  --p-text-disabled: #b5b5b5;
  --p-text-inverse: #ffffff;
  --p-text-success: #0c5132;
  --p-text-info: #00527c;
  --p-text-link: #005bd3;

  --p-border: #e3e3e3;
  --p-border-secondary: #ebebeb;
  --p-border-strong: #cccccc;
  --p-border-brand: #303030;
  --p-border-success: #29845a;
  --p-border-info: #99c9e0;
  --p-border-focus: #005bd3;

  --p-radius-100: 4px;
  --p-radius-200: 6px;
  --p-radius-300: 8px;
  --p-radius-400: 12px;
  --p-radius-500: 16px;

  --p-space-100: 4px;
  --p-space-200: 8px;
  --p-space-300: 12px;
  --p-space-400: 16px;
  --p-space-500: 20px;
  --p-space-600: 24px;
  --p-space-800: 32px;
  --p-space-1000: 40px;

  --p-shadow-100: 0 1px 0 rgba(0, 0, 0, 0.05);
  --p-shadow-200: 0 1px 1px rgba(0, 0, 0, 0.05), 0 3px 1px rgba(0, 0, 0, 0.03);
  --p-shadow-300: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.06);

  --p-font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --p-font-size-75: 12px;
  --p-font-size-100: 13px;
  --p-font-size-200: 14px;
  --p-font-size-300: 16px;
  --p-font-size-400: 20px;
  --p-font-size-500: 24px;
  --p-font-size-600: 28px;
  --p-font-weight-medium: 500;
  --p-font-weight-semibold: 600;
  --p-font-weight-bold: 650;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: var(--p-font);
  font-size: var(--p-font-size-200);
  color: var(--p-text);
  background: var(--p-bg);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--p-space-600);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--p-space-600);
}

.page-title {
  font-size: var(--p-font-size-500);
  font-weight: var(--p-font-weight-bold);
  margin: 0;
}

/* Card */
.card {
  background: var(--p-bg-surface);
  border-radius: var(--p-radius-400);
  box-shadow: var(--p-shadow-200);
  padding: var(--p-space-500);
  margin-bottom: var(--p-space-500);
  position: relative;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--p-space-400);
}
.card-title {
  font-size: var(--p-font-size-300);
  font-weight: var(--p-font-weight-semibold);
  margin: 0;
}
.card-subtitle {
  font-size: var(--p-font-size-200);
  color: var(--p-text-secondary);
  margin: var(--p-space-100) 0 0;
}

/* Banner */
.banner {
  border-radius: var(--p-radius-300);
  padding: var(--p-space-400);
  margin-bottom: var(--p-space-500);
  display: flex;
  gap: var(--p-space-300);
  align-items: flex-start;
}
.banner-info { background: var(--p-bg-surface-info); border: 1px solid var(--p-border-info); }
.banner-success { background: var(--p-bg-surface-success-subdued); border: 1px solid var(--p-border-success); }
.banner-warning { background: var(--p-bg-surface-warning); border: 1px solid #c9a51e; }
.banner-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.banner-content { flex: 1; }
.banner-title {
  font-weight: var(--p-font-weight-semibold);
  margin: 0 0 var(--p-space-100);
  font-size: var(--p-font-size-200);
}
.banner-text { margin: 0; font-size: var(--p-font-size-200); }

/* Buttons (Polaris v13+ shape: dark fill primary) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--p-space-200);
  padding: 8px 14px;
  border-radius: var(--p-radius-300);
  font-family: inherit;
  font-size: var(--p-font-size-200);
  font-weight: var(--p-font-weight-medium);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms ease, transform 80ms ease;
  text-decoration: none;
  line-height: 1;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--p-bg-fill-brand);
  color: var(--p-text-inverse);
  box-shadow: 0 -1px 0 0 rgba(255, 255, 255, 0.2) inset, 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.btn-primary:hover { background: var(--p-bg-fill-brand-hover); }
.btn-secondary {
  background: var(--p-bg-surface);
  color: var(--p-text);
  border: 1px solid var(--p-border-strong);
  box-shadow: var(--p-shadow-100);
}
.btn-secondary:hover { background: var(--p-bg-surface-tertiary); }
.btn-plain {
  background: transparent;
  color: var(--p-text-link);
  padding: 6px 8px;
}
.btn-plain:hover { background: rgba(0, 91, 211, 0.06); }
.btn-large { padding: 12px 20px; font-size: var(--p-font-size-300); }
.btn-block { width: 100%; }

/* Choice list / option tile (used by persona variant) */
.option-tile {
  display: flex;
  flex-direction: column;
  gap: var(--p-space-200);
  padding: var(--p-space-400);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-300);
  background: var(--p-bg-surface);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 120ms ease, background 120ms ease;
}
.option-tile:hover { border-color: var(--p-border-strong); }
.option-tile.selected {
  border-color: var(--p-border-brand);
  background: var(--p-bg-surface-tertiary);
  box-shadow: 0 0 0 1px var(--p-border-brand) inset;
}

/* Progress bar */
.progress {
  height: 6px;
  background: var(--p-border-secondary);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--p-bg-fill-success);
  border-radius: 999px;
  transition: width 240ms ease;
}

/* Step indicator */
.step-list { display: flex; flex-direction: column; gap: 0; }
.step-item {
  display: flex;
  gap: var(--p-space-300);
  align-items: flex-start;
  padding: var(--p-space-300) 0;
  border-bottom: 1px solid var(--p-border-secondary);
}
.step-item:last-child { border-bottom: none; }
.step-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1.5px dashed var(--p-border-strong);
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--p-bg-surface);
}
.step-checkbox.complete {
  background: var(--p-bg-fill-success);
  border-color: var(--p-bg-fill-success);
  border-style: solid;
  color: white;
  font-size: 11px;
}
.step-body { flex: 1; }
.step-title { font-weight: var(--p-font-weight-semibold); margin: 0 0 2px; font-size: var(--p-font-size-200); }
.step-desc { color: var(--p-text-secondary); font-size: var(--p-font-size-100); margin: 0 0 var(--p-space-200); }

/* Badges / chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--p-font-size-75);
  font-weight: var(--p-font-weight-medium);
  background: var(--p-bg-surface-tertiary);
  color: var(--p-text);
}
.badge-success { background: var(--p-bg-surface-success); color: var(--p-text-success); }
.badge-info { background: var(--p-bg-surface-info); color: var(--p-text-info); }
.badge-attn { background: var(--p-bg-surface-warning); color: #6b4d00; }

/* Layout helpers */
.stack { display: flex; flex-direction: column; gap: var(--p-space-400); }
.stack-tight { display: flex; flex-direction: column; gap: var(--p-space-200); }
.row { display: flex; gap: var(--p-space-400); align-items: center; }
.row-between { justify-content: space-between; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--p-space-400); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--p-space-400); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--p-space-400); }
@media (max-width: 800px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* Form controls (Polaris-faithful) */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--p-font-size-200); font-weight: var(--p-font-weight-medium); color: var(--p-text); }
.field-help { font-size: var(--p-font-size-100); color: var(--p-text-secondary); }
.input, .select {
  padding: 8px 12px;
  border: 1px solid var(--p-border-strong);
  border-radius: var(--p-radius-200);
  background: var(--p-bg-surface);
  font-family: inherit;
  font-size: var(--p-font-size-200);
  color: var(--p-text);
  width: 100%;
}
.input:focus, .select:focus { outline: 2px solid var(--p-border-focus); outline-offset: 1px; }

/* ==== Reasoning tooltip system (NEW: explains every change) ==== */
.reason-pin {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #ffd79d;
  color: #4a2800;
  border: 2px solid #4a2800;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.reason-pin .reason-tip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  padding: 12px 14px;
  background: #1a1a1a;
  color: #fff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  text-align: left;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.reason-pin .reason-tip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  right: 8px;
  border: 6px solid transparent;
  border-bottom-color: #1a1a1a;
}
.reason-pin .reason-tip strong { color: #ffd79d; display: block; margin-bottom: 4px; }
.reason-pin:hover .reason-tip,
.reason-pin:focus .reason-tip { opacity: 1; pointer-events: auto; }

/* Position variants for the pin */
.pin-anchor { position: relative; }
.reason-pin.left { right: auto; left: -10px; }
.reason-pin.left .reason-tip { right: auto; left: 0; }
.reason-pin.left .reason-tip::before { right: auto; left: 8px; }

/* Variant selector (index page) */
.variant-card {
  background: var(--p-bg-surface);
  border-radius: var(--p-radius-400);
  padding: var(--p-space-500);
  text-decoration: none;
  color: var(--p-text);
  border: 1px solid var(--p-border);
  display: flex;
  flex-direction: column;
  gap: var(--p-space-300);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.variant-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--p-shadow-300);
}
.variant-meta {
  display: flex;
  gap: var(--p-space-200);
  flex-wrap: wrap;
  margin-top: auto;
}

/* Footer note */
.legend {
  margin-top: var(--p-space-800);
  padding: var(--p-space-400);
  background: #fff8e6;
  border: 1px dashed #c9a51e;
  border-radius: var(--p-radius-300);
  font-size: var(--p-font-size-100);
  color: #6b4d00;
}
.legend strong { color: #4a2800; }
