/* ─────────────────────────────────────────────────────────────────────────────
   Slab Brain Visualizer — style.css
   All colors via design-system tokens. No hardcoded hex.
───────────────────────────────────────────────────────────────────────────── */

/* ── Token bridge ────────────────────────────────────────────────────────── */
:root {
  --bg:        var(--color-bg);
  --surface:   var(--color-surface);
  --card:      var(--color-surface-raised);
  --text:      var(--color-text-primary);
  --muted-2:   var(--color-text-secondary);
  --muted:     var(--color-text-tertiary);
  --border:    var(--color-border);
  --border-s:  var(--color-border-strong);
  --accent:    var(--color-accent);
  --accent-sub:var(--color-accent-subtle);
  --accent-txt:var(--color-accent-text);
  --danger:    var(--color-danger);
  --danger-sub:var(--color-danger-subtle);
  --success:   var(--color-success);
  --overlay:   var(--color-overlay);
  /* Accent opacity via color-mix (no hardcoded hex) */
  --accent-10: color-mix(in srgb, var(--color-accent) 10%, transparent);
  --accent-15: color-mix(in srgb, var(--color-accent) 15%, transparent);
  --accent-20: color-mix(in srgb, var(--color-accent) 20%, transparent);
  --accent-30: color-mix(in srgb, var(--color-accent) 30%, transparent);
  --accent-50: color-mix(in srgb, var(--color-accent) 50%, transparent);
  --accent-80: color-mix(in srgb, var(--color-accent) 80%, transparent);
  /* Shadows — visits pattern, max 0.10 opacity */
  --sh-sm: 0 1px 3px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
  --sh-md: 0 4px 12px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.03);
  --sh-lg: 0 8px 24px rgba(0,0,0,.08), 0 3px 6px rgba(0,0,0,.04);
  --sh-xl: 0 20px 60px rgba(0,0,0,.10), 0 8px 16px rgba(0,0,0,.05);
  /* Transitions */
  --t-base: 0.15s ease;
  --t-fast: 0.10s ease;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── App shell ───────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 32px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 0.5px solid var(--border);
}

.brandRow {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo { display: flex; align-items: center; }

.logoImg {
  height: 36px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
}

.header h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 20px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.header .sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
  letter-spacing: 0.01em;
}

/* ── Main grid ───────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  padding: 20px 24px 40px;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--sh-md);
}

/* ── Section kicker labels ───────────────────────────────────────────────── */
.card h2, .kicker {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 12px;
}

/* ── Layout helpers ──────────────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 10px; }
.row   { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.divider {
  height: 0.5px;
  background: var(--border);
  margin: 16px 0;
}

/* ── Buttons — base ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t-base), opacity var(--t-base), transform var(--t-fast), border-color var(--t-base);
  white-space: nowrap;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-s);
}
.btn:hover:not(:disabled) { background: var(--surface); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.40; cursor: not-allowed; }

.btn.secondary {
  background: transparent;
  border-color: var(--border-s);
  color: var(--text);
}
.btn.secondary:hover:not(:disabled) { background: var(--surface); }

.btn.primary {
  background: var(--accent);
  color: var(--accent-txt);
  border-color: transparent;
}
.btn.primary:hover:not(:disabled) { opacity: 0.88; }

/* ── Primary CTA ─────────────────────────────────────────────────────────── */
.visualizePrimary {
  width: 100%;
  background: var(--accent);
  color: var(--accent-txt);
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  cursor: pointer;
  transition: opacity var(--t-base), transform var(--t-fast);
}
.visualizePrimary:hover:not(:disabled) { opacity: 0.90; }
.visualizePrimary:active:not(:disabled) { transform: translateY(1px); }
.visualizePrimary:disabled { opacity: 0.40; cursor: not-allowed; }

.vizText  { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; flex: 1; }
.vizMain  { font-size: 14px; font-weight: 600; }
.vizSub   { font-size: 11px; opacity: 0.80; }
.vizBadge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-size: 11px;
  font-weight: 500;
  background: color-mix(in srgb, var(--accent-txt) 12%, transparent);
  border-radius: 6px;
  padding: 5px 9px;
  flex-shrink: 0;
  text-align: center;
  line-height: 1.4;
}
.vizBadgeLine { display: flex; align-items: center; gap: 3px; justify-content: center; }

.heroStack { display: flex; flex-direction: column; gap: 8px; width: 100%; }

.tinyLinkBtn {
  background: none;
  border: none;
  padding: 2px 0;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--muted-2);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: color var(--t-base), text-decoration-color var(--t-base);
}
.tinyLinkBtn:hover { color: var(--text); text-decoration-color: var(--border-s); }

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.textInput, .stoneModalSearchInput, textarea, .stoneFilterSelect {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border-s);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text);
  transition: border-color var(--t-base);
  outline: none;
}
.textInput, .stoneModalSearchInput { height: 40px; padding: 0 14px; }
textarea { padding: 10px 14px; resize: vertical; min-height: 80px; }
.stoneFilterSelect { height: 36px; padding: 0 10px; }
.textInput:focus, .stoneModalSearchInput:focus, textarea:focus, .stoneFilterSelect:focus {
  border-color: var(--accent);
  border-width: 1.5px;
}
::placeholder { color: var(--muted); }

/* ── Upload section ──────────────────────────────────────────────────────── */
#uploadBtn { width: 100%; }

.uploadStatus {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: var(--accent-10);
  border: 1px solid var(--accent-20);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted-2);
}
.uploadStatusIcon { color: var(--accent); font-size: 14px; flex-shrink: 0; }

/* ── Key-value display ───────────────────────────────────────────────────── */
.kv  { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; }
.k   { color: var(--muted); min-width: 60px; flex-shrink: 0; padding-top: 1px; }
.v   { color: var(--muted-2); }
.code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 11px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}
.codeWrap { word-break: break-all; }

.err {
  font-size: 12px;
  color: var(--danger);
  padding: 6px 10px;
  background: var(--danger-sub);
  border-radius: 6px;
}

.urlRow { font-size: 11px; color: var(--muted); gap: 6px; }
.urlLabel { flex-shrink: 0; }

/* ── Insight cards ───────────────────────────────────────────────────────── */
.insightCard {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.insightHeader { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.insightTitle {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.insightSubHeader { margin-bottom: 6px; }
.insightBody { font-size: 13px; color: var(--muted-2); line-height: 1.5; }
.insightNext { font-size: 12px; }
.insightChips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* ── Chip buttons ────────────────────────────────────────────────────────── */
.chipBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  background: var(--card);
  border: 1px solid var(--border-s);
  border-radius: 999px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background var(--t-base), border-color var(--t-base), transform var(--t-fast);
  white-space: nowrap;
}
.chipBtn:hover  { background: var(--surface); border-color: var(--accent-50); }
.chipBtn:active { transform: translateY(1px); }

/* Hero AI chip */
.chipBtn--aiHero {
  height: auto;
  padding: 10px 14px;
  border-radius: 10px;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: var(--accent-10);
  border-color: var(--accent-30);
  width: 100%;
}
.chipBtn--aiHero:hover { background: var(--accent-20); border-color: var(--accent-50); }
.aiSpark { font-size: 16px; }
.aiLabel { font-size: 13px; font-weight: 600; color: var(--text); }
.aiSub   { font-size: 11px; color: var(--muted-2); }


/* ── Recommendation strip ────────────────────────────────────────────────── */
.stoneRecommendRow  { margin-bottom: 8px; }
.recommendLabel     { margin-bottom: 6px; }
.recommendChips     { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Slab chooser button ─────────────────────────────────────────────────── */
.slabChooseBtn {
  width: 100%;
  height: auto;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 8px;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border-s);
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}
.slabChooseBtn:hover { background: var(--surface); }

.slabChooseMainCol  { display: flex; flex-direction: column; gap: 3px; width: 100%; }
.slabChooseHint     { font-size: 11px; color: var(--muted); }
.slabChooseSelected { font-size: 12px; color: var(--muted-2); white-space: normal; overflow-wrap: break-word; word-break: break-word; }

.slabChoosePreview      { width: 100%; margin-top: 8px; }
.slabChoosePreview img  {
  width: 100%; height: 72px; object-fit: cover;
  border-radius: 6px; border: 0.5px solid var(--border);
}

.stonePreview      { display: flex; flex-direction: column; gap: 6px; }
.stonePreview img  {
  width: 100%; height: 72px; object-fit: cover;
  border-radius: 6px; border: 0.5px solid var(--border);
}

.islandChooseBtn { margin-top: 0; }
.slabChooseBtnWide { width: 100%; }

/* ── Enhancements ────────────────────────────────────────────────────────── */
.enhancements     { width: 100%; }
.enhancementsGrid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.aiDesignHeroRow  { width: 100%; }

/* ── Pill toggle buttons ─────────────────────────────────────────────────── */
.pillBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  background: var(--card);
  border: 1px solid var(--border-s);
  color: var(--muted-2);
  cursor: pointer;
  transition: background var(--t-base), border-color var(--t-base), color var(--t-base);
  width: 100%;
  justify-content: space-between;
}
.pillBtn:hover { background: var(--surface); }
.pillBtn[aria-pressed="true"] {
  background: var(--accent-15);
  border-color: var(--accent-50);
  color: var(--text);
}

.pillDot {
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--border-s);
  flex-shrink: 0;
  transition: background var(--t-base), border-color var(--t-base);
}
.pillBtn[aria-pressed="true"] .pillDot {
  background: var(--accent);
  border-color: var(--accent);
}

.pillText  { flex: 1; text-align: left; }

.colorDot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--border-s);
  flex-shrink: 0;
  overflow: hidden;
  background: var(--surface);
}

/* ── Palette row ─────────────────────────────────────────────────────────── */
.paletteRow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 8px;
}
.paletteLabel    { font-size: 11px; color: var(--muted); white-space: nowrap; }
.paletteSwatches { display: flex; gap: 6px; flex-wrap: wrap; }

.paletteSwatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.paletteSwatch:hover  { transform: scale(1.15); }
.paletteSwatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-30); }

input[type="color"] { display: none; }

/* ── Advanced settings ───────────────────────────────────────────────────── */
.advancedBlock  { border-top: 0.5px solid var(--border); padding-top: 10px; }
.advancedToggle {
  background: none; border: none;
  font-family: 'Inter', sans-serif; font-size: 12px; color: var(--muted-2);
  cursor: pointer; padding: 0; transition: color var(--t-base);
}
.advancedToggle:hover { color: var(--text); }
.advancedBody { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }

.label {
  font-size: 11px; font-weight: 500; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted-2);
  display: block; margin-bottom: 4px;
}

/* ── Preview area — single panel, state-driven ───────────────────────────── */
.previewGrid {
  display: block;  /* single panel at a time, no grid */
}

/* Default: show original card (with welcome instructions), hide visualization */
#originalCard { display: block; }
.previewGrid > .previewCard { display: none; }

/* After upload: original card shows uploaded photo (already visible) */

/* After render: hide original, reveal visualization */
.app.hasRender #originalCard { display: none; }
.app.hasRender .previewGrid > .previewCard { display: flex; flex-direction: column; }

.previewCard {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

/* The original card wrapper fills its panel */
#originalCard > .previewCard { display: flex; }

.previewHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.previewHeadTabs { flex-direction: column; align-items: flex-start; }

.previewTitle {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted-2);
}

#rotateBtn {
  height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px;
  background: var(--card); border: 1px solid var(--border); color: var(--muted-2);
  cursor: pointer; transition: background var(--t-base);
}
#rotateBtn:hover { background: var(--border); }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.previewTabs {
  display: flex;
  justify-content: center;
  gap: 2px;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  margin-top: 6px;
  align-self: center;
  width: fit-content;
}

.tabBtn {
  flex: 1; height: 28px; padding: 0 10px;
  border-radius: 6px; background: transparent; border: none;
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 500;
  color: var(--muted-2); cursor: pointer;
  transition: background var(--t-base), color var(--t-base);
}
.tabBtn.isActive, .tabBtn[aria-selected="true"] {
  background: var(--card); color: var(--text); box-shadow: var(--sh-sm);
}
.tabBtn:hover:not(.isActive):not([aria-selected="true"]) { color: var(--text); }

/* ── Image panels ────────────────────────────────────────────────────────── */
.vizPanels { flex: 1; overflow: hidden; }
.vizPanel  { display: none; height: 100%; }
.vizPanel.isActive { display: block; height: 100%; }

.imgWrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--bg);
}
/* When original card is full-width, cap the height so it doesn't stretch too tall */
#originalCard .imgWrap {
  aspect-ratio: unset;
  min-height: 380px;
  max-height: 540px;
}

.zoomableWrap { cursor: zoom-in; }
.zoomableImg  { width: 100%; height: 100%; object-fit: contain; display: block; }
.zoomHint {
  position: absolute; bottom: 8px; right: 8px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  padding: 2px 7px; border-radius: 4px;
  font-size: 10px; color: var(--muted); pointer-events: none;
}

/* ── Welcome / instructions panel — hidden once image is uploaded ────────── */
.origInstructions {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto;
  background: var(--surface); z-index: 2;
}
.app.hasUpload .origInstructions { display: none; }
.origInstructionsInner {
  padding: 28px 28px 24px;
  width: 100%; max-width: 480px;
  box-sizing: border-box;
  text-align: center;
}
.origLogoRow   { margin-bottom: 12px; }
.origLogoBadge img { height: 42px; width: auto; object-fit: contain; }
.origWelcome {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 24px; font-weight: 400; color: var(--text);
  margin-bottom: 6px; letter-spacing: -0.01em;
}
.origStepTitle {
  font-size: 14px; color: var(--muted-2);
  margin-bottom: 18px; line-height: 1.45;
}
.origStepList {
  list-style: none; text-align: left;
  display: flex; flex-direction: column; gap: 14px;
  counter-reset: steps;
}
.origStepList li {
  display: flex; align-items: flex-start; gap: 10px;
  counter-increment: steps;
}
.origStepList li::before {
  content: counter(steps);
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-15); border: 1px solid var(--accent-30);
  color: var(--accent); font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.stepLabel { font-size: 13px; font-weight: 600; color: var(--text); display: block; margin-bottom: 2px; }
.stepDesc  { font-size: 12px; color: var(--muted-2); line-height: 1.45; }
.origHint  { margin-top: 16px; font-size: 11px; color: var(--muted); line-height: 1.45; font-style: italic; }

/* On very short panels hide the pro tip to keep steps visible */
@media (max-height: 380px) {
  .origHint { display: none; }
  .origStepTitle { display: none; }
  .origLogoRow { margin-bottom: 6px; }
  .origInstructionsInner { padding-top: 12px; }
}

/* ── Viz action bar (overlaid on image) — used by Original tab only ─────── */
.vizActions {
  position: absolute; bottom: 8px; left: 8px; right: 8px;
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
}

/* ── Rendered panel: flex column so action bar sits below the image ──────── */
#panelRendered.isActive {
  display: flex;
  flex-direction: column;
  height: 100%;
}
#panelRendered .imgWrap {
  flex: 1;
  min-height: 0;
  aspect-ratio: unset;
}

/* ── Action bar below the rendered image ─────────────────────────────────── */
.vizActionsBar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 6px 12px;
  border-top: 0.5px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}
/* zoomHint sits in col 3, right-aligned — override absolute positioning */
.vizActionsBar .zoomHint {
  position: static;
  background: transparent;
  padding: 0;
  bottom: auto; right: auto;
  justify-self: end;
}

/* ── Viz action buttons (email + edge) ───────────────────────────────────── */
.vizActionBtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  background: var(--card);
  border: 1px solid var(--border-s);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-base), border-color var(--t-base), transform var(--t-fast);
}
.vizActionBtn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent-30);
}
.vizActionBtn:active:not(:disabled) { transform: translateY(1px); }
.vizActionBtn:disabled { opacity: 0.40; cursor: not-allowed; }
/* Both action buttons same fixed width, labels centered */
.vizActionsBar .vizActionBtn { width: 120px; justify-content: center; }
/* Email button is in the 1fr column — stop it stretching to fill the column */
.vizActionsBar > button:first-child { justify-self: start; }

/* ── In-image loading overlay — hidden until .app.isRendering ────────────── */
.previewLoading {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
  z-index: 10;
  overflow: hidden;
}
.app.isRendering .previewLoading { display: flex; }

/* Rotating colour aura — the "cool swirling colours" behind the loader card */
.app.isRendering .previewLoading::before {
  content: "";
  position: absolute;
  inset: -50%;
  background: conic-gradient(
    from 0deg,
    color-mix(in srgb, var(--accent)  5%, transparent),
    color-mix(in srgb, var(--accent) 65%, transparent),
    rgba(56, 189, 248, 0.55),
    rgba(94, 234, 212, 0.50),
    color-mix(in srgb, var(--accent)  5%, transparent)
  );
  filter: blur(28px);
  animation: vizColors 4s linear infinite;
  pointer-events: none;
}
@keyframes vizColors { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Blur the underlying image so the colour aura reads clearly */
.app.isRendering #renderImg {
  filter: blur(4px) saturate(1.1);
  transition: filter 0.25s ease;
}
#renderImg { transition: filter 0.25s ease; }

.previewLoadingInner {
  position: relative; z-index: 1;
  text-align: center; padding: 18px 22px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-radius: 16px;
  backdrop-filter: blur(6px);
  border: 0.5px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.previewLogoSpin {
  height: 36px; width: auto; object-fit: contain;
  animation: logoPulse 1.8s ease-in-out infinite;
  margin-bottom: 10px;
}
@keyframes logoPulse { 0%,100%{opacity:.6;transform:scale(.95)} 50%{opacity:1;transform:scale(1)} }
.previewLoadingTitle { font-size: 13px; font-weight: 500; color: var(--text); }
.previewLoadingSub   { font-size: 11px; color: var(--muted); margin-top: 4px; }
.previewLoadingBar {
  height: 2px; background: var(--border); border-radius: 1px;
  margin-top: 12px; overflow: hidden;
}
.previewLoadingBarFill {
  height: 100%; background: var(--accent); border-radius: 1px;
  width: 0; transition: width 0.4s ease;
}

/* ── Compare widget ──────────────────────────────────────────────────────── */
.compareTopRow {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; gap: 8px; border-bottom: 0.5px solid var(--border);
}
.compareHint { font-size: 11px; color: var(--muted); }

.compareStage {
  position: relative; overflow: hidden;
  aspect-ratio: 4/3; background: var(--bg); cursor: col-resize;
}
.compareStage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.compareOverlay   { position: absolute; inset: 0; overflow: hidden; }
.compareOverlay img { width: 100%; height: 100%; object-fit: contain; }

.compareSlider {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: col-resize; z-index: 10; -webkit-appearance: none;
}
.compareHandle {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--card); left: 50%; transform: translateX(-50%);
  pointer-events: none; z-index: 9;
}
.compareHandle::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--card); border: 1.5px solid var(--border-s);
  box-shadow: var(--sh-md);
}
.compareLabels {
  display: flex; justify-content: space-between;
  padding: 6px 12px; font-size: 11px; color: var(--muted);
  border-top: 0.5px solid var(--border);
}

/* ── History ─────────────────────────────────────────────────────────────── */
.historySection {
  margin-top: 16px;
  border-top: 0.5px solid var(--border);
  padding-top: 12px;
}
.historyHeader {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.historyTitle {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted-2);
}
.historyList {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 252px;   /* ~4 items visible; scroll for more */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-s) transparent;
}
.historyList::-webkit-scrollbar { width: 4px; }
.historyList::-webkit-scrollbar-track { background: transparent; }
.historyList::-webkit-scrollbar-thumb { background: var(--border-s); border-radius: 2px; }

/* ── Full-screen loading overlay ─────────────────────────────────────────── */
.loadingOverlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--overlay); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.loadingCard {
  background: var(--card); border: 0.5px solid var(--border);
  border-radius: 16px; padding: 32px 40px; text-align: center;
  max-width: 320px; width: 90%; box-shadow: var(--sh-xl);
}
.spinnerRow {
  position: relative; width: 64px; height: 64px;
  margin: 0 auto 16px;
}
.loadingTitle {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px; font-weight: 400; color: var(--text); margin-bottom: 6px;
}
.loadingSub  { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.loadingBar  { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: 10px; }
.loadingBarFill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-80));
  border-radius: 2px; width: 0; transition: width 0.5s ease;
}
.loadingLogoBeat {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.loadingLogoBeat img {
  height: 32px; width: auto; object-fit: contain;
  animation: logoPulse 1.8s ease-in-out infinite;
}

/* ── Spinner ring ────────────────────────────────────────────────────────── */
.ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  animation: spin 1.2s linear infinite;
}
.ring.ring2 { inset: 6px; border-top-color: var(--accent-50); animation-duration: 1.8s; }
.ring.ring3 { inset: 12px; border-top-color: var(--accent-20); animation-duration: 2.4s; }
.ring.ring-sm {
  position: static; display: inline-block;
  width: 18px; height: 18px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Stone picker modal (bottom sheet) ───────────────────────────────────── */
.stoneModal {
  position: fixed; inset: 0; z-index: 100;
  background: var(--overlay); backdrop-filter: blur(4px);
  display: none; align-items: flex-end; justify-content: center;
}
.stoneModal.open { display: flex; }

.stoneModalInner {
  background: var(--card); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 680px; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: var(--sh-xl);
}
.stoneModalHeader {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 0.5px solid var(--border); flex-shrink: 0;
}
.stoneModalTitle {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px; font-weight: 400; color: var(--text);
}
.stoneModalSub    { margin-top: 2px; }
.stoneModalClose  {
  background: var(--surface); border: 1px solid var(--border); border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--muted-2); cursor: pointer; flex-shrink: 0;
  transition: background var(--t-base);
}
.stoneModalClose:hover { background: var(--border); }

.stoneModalSearchRow {
  padding: 10px 20px; flex-shrink: 0; border-bottom: 0.5px solid var(--border);
}
.stoneModalFilters {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 20px; flex-wrap: wrap;
  flex-shrink: 0; border-bottom: 0.5px solid var(--border);
}
.favFilterLabel {
  display: flex; align-items: center; gap: 4px;
  cursor: pointer; white-space: nowrap;
}

.stoneModalBody { flex: 1; overflow: hidden; display: flex; }
.stoneModalLeft { flex: 1; overflow-y: auto; padding: 12px 20px 20px; }

.stoneModalLoading {
  display: flex; align-items: center; gap: 8px;
  padding: 20px 0; font-size: 13px; color: var(--muted);
}
.stoneModalGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.stoneFilterClearBtn { white-space: nowrap; }

/* ── Generic modals ──────────────────────────────────────────────────────── */
.modalOverlay {
  position: fixed; inset: 0; z-index: 150;
  background: var(--overlay); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modalOverlay.open { display: flex; }

.modalCard {
  background: var(--card); border: 0.5px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 480px;
  box-shadow: var(--sh-xl); overflow: hidden;
}
.modalHeader {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 0.5px solid var(--border);
}
.modalTitle {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px; font-weight: 400; color: var(--text);
}
.modalCloseBtn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--muted-2); cursor: pointer; line-height: 1;
  transition: background var(--t-base);
}
.modalCloseBtn:hover { background: var(--border); }

.modalBody { padding: 16px 20px 20px; }

.fieldLabel {
  display: block; font-size: 11px; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted-2); margin-bottom: 6px;
}
.tinyMeta { font-size: 12px; color: var(--muted); }

.modalActions { display: flex; gap: 8px; margin-top: 16px; }

.primaryBtn {
  flex: 1; height: 40px; background: var(--accent); color: var(--accent-txt);
  border: none; border-radius: 8px;
  font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: opacity var(--t-base);
}
.primaryBtn:hover:not(:disabled) { opacity: 0.88; }
.primaryBtn:disabled { opacity: 0.40; cursor: not-allowed; }

.secondaryBtn {
  flex: 1; height: 40px; background: var(--card); color: var(--text);
  border: 1px solid var(--border-s); border-radius: 8px;
  font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background var(--t-base);
}
.secondaryBtn:hover { background: var(--surface); }

.muted { color: var(--muted-2); }

/* ── Edge profile modal ──────────────────────────────────────────────────── */
.edgeGrid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  max-width: 340px; margin: 0 auto;
}
.edgeOption {
  padding: 12px; background: var(--card);
  border: 1px solid var(--border-s); border-radius: 8px;
  cursor: pointer; text-align: left;
  transition: border-color var(--t-base), background var(--t-base);
}
.edgeOption:hover  { background: var(--surface); border-color: var(--accent-50); }
.edgeOption.isActive { border-color: var(--accent); background: var(--accent-10); }
.edgeName { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.edgeDesc { font-size: 11px; color: var(--muted); }

/* ── AI design modal ─────────────────────────────────────────────────────── */
.miniLabel {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted-2); margin-bottom: 8px;
}
.miniHelp { font-size: 12px; color: var(--muted); }

.aiThemeRow   { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.aiThemeBtn {
  height: 30px; padding: 0 12px; background: var(--card);
  border: 1px solid var(--border-s); border-radius: 999px;
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 500;
  color: var(--muted-2); cursor: pointer; transition: all var(--t-base);
}
.aiThemeBtn:hover   { background: var(--surface); color: var(--text); }
.aiThemeBtn.isActive {
  background: var(--accent-15); border-color: var(--accent-50); color: var(--text);
}

.aiRunRow { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.aiSpinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin 1s linear infinite; flex-shrink: 0;
}
.aiBar     { height: 2px; background: var(--border); border-radius: 1px; overflow: hidden; }
.aiBarFill { height: 100%; background: var(--accent); border-radius: 1px; width: 0; transition: width 0.4s ease; }

.chipRow { display: flex; flex-wrap: wrap; gap: 6px; }

.aiapplybtn {
  width: 100%; height: 40px;
  background: var(--accent); color: var(--accent-txt); border: none;
  border-radius: 8px; font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: opacity var(--t-base);
}
.aiapplybtn:hover { opacity: 0.88; }

/* ── Color picker modal (bottom sheet) ───────────────────────────────────── */
.colorModal {
  position: fixed; inset: 0; z-index: 150;
  background: var(--overlay); backdrop-filter: blur(4px);
  display: none; align-items: flex-end; justify-content: center;
}
.colorModal.open { display: flex; }

.colorModalInner {
  background: var(--card); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 480px; max-height: 80vh;
  display: flex; flex-direction: column; box-shadow: var(--sh-xl);
}
.colorModalHeader {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 0.5px solid var(--border); flex-shrink: 0;
}
.colorModalTitle {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 16px; font-weight: 400; color: var(--text);
}
.colorModalClose {
  background: var(--surface); border: 1px solid var(--border); border-radius: 50%;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--muted-2); cursor: pointer;
}
.colorModalClose:hover { background: var(--border); }

.colorModalBody {
  flex: 1; overflow-y: auto; padding: 12px 16px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.colorModalHint { font-size: 12px; color: var(--muted); }
.colorModalGrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px;
}
.colorModalCustomBtn {
  width: 100%; height: 38px; background: var(--card);
  border: 1px solid var(--border-s); border-radius: 8px;
  font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 500;
  color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--t-base);
}
.colorModalCustomBtn:hover { background: var(--surface); }
.customSparkle { font-size: 14px; }

/* ── Image zoom modal ────────────────────────────────────────────────────── */
.imgModal {
  position: fixed; inset: 0; z-index: 300;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.imgModalInner { max-width: 95vw; max-height: 95vh; }
.imgModalInner img {
  max-width: 95vw; max-height: 95vh; object-fit: contain;
  border-radius: 8px; box-shadow: var(--sh-xl);
}

/* ── Full-screen compare modal ───────────────────────────────────────────── */
.compareModal { padding: 16px; }
.compareModalCard {
  background: var(--card); border: 0.5px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 960px;
  box-shadow: var(--sh-xl); overflow: hidden;
  display: flex; flex-direction: column; max-height: 90vh;
}
.compareModalHeader {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 0.5px solid var(--border); flex-shrink: 0;
}
.compareModalTitle {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 16px; font-weight: 400; color: var(--text);
}
.compareModalClose {
  background: var(--surface); border: 1px solid var(--border); border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--muted-2); cursor: pointer;
}
.compareModalClose:hover { background: var(--border); }
.compareStageModal { flex: 1; aspect-ratio: auto; min-height: 0; }

/* ── Text helpers ────────────────────────────────────────────────────────── */
.tiny  { font-size: 11px; }
.small { font-size: 12px; }

/* ── Admin/debug box — hidden in prod ────────────────────────────────────── */
.apiBox { display: none !important; }

/* ── NLQ banner ──────────────────────────────────────────────────────────── */
.nlq-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--accent-10);
  border: 1px solid var(--accent-20); border-radius: 8px;
  font-size: 12px; color: var(--muted-2);
}
.nlq-banner-icon            { color: var(--accent); }
.nlq-banner .nlq-query-text { color: var(--accent); font-weight: 500; }

/* ── Generic room chips ──────────────────────────────────────────────────── */
.islandBlock       { width: 100%; }
.genericRoomsRow   { display: flex; flex-direction: column; gap: 6px; }
.genericRoomsLabel { }
.genericRoomChips  { display: flex; flex-wrap: wrap; gap: 6px; }

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

/* ── Tablet (≤900px) ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
    padding: 12px 16px 32px;
  }
  .header     { height: 56px; padding: 0 16px; }
  .header h1  { font-size: 17px; }
  .header .sub { display: none; }

  /* History: ~3 items on tablet */
  .historyList { max-height: 186px; }

  /* Tabs: slightly taller for tablet touch */
  .tabBtn { height: 32px; padding: 0 14px; }

  /* Instructions panel: full-width on tablet, slightly looser padding */
  .origInstructionsInner { max-width: 560px; padding: 24px 32px 20px; }

  /* Full-width tab strip so it doesn't look oddly small on tablet */
  .previewTabs { align-self: stretch; justify-content: stretch; }
  .previewTabs .tabBtn { flex: 1; }

  /* Stone modal: use more height on tablet */
  .stoneModalInner { max-height: 92vh; }
}

/* ── Phone (≤640px) ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Compact header */
  .header   { height: 52px; padding: 0 12px; }
  .logoImg  { height: 28px; max-width: 110px; }
  .header h1 { font-size: 15px; }

  /* Card padding */
  .card { padding: 14px; }

  /* Instructions panel: compact but readable on phone */
  .origInstructionsInner {
    max-width: 100%;
    padding: 20px 18px 16px;
  }
  .origLogoBadge img  { height: 36px; }
  .origWelcome        { font-size: 20px; }
  .origStepTitle      { font-size: 13px; margin-bottom: 14px; }
  .origStepList       { gap: 11px; }
  .origStepList li::before { width: 20px; height: 20px; font-size: 10px; }
  .stepLabel          { font-size: 13px; }
  .stepDesc           { font-size: 12px; }
  .origHint           { font-size: 11px; margin-top: 12px; }

  /* Tabs: taller for phone touch, stretch full width */
  .tabBtn { height: 36px; padding: 0 8px; font-size: 12px; }

  /* Primary action buttons: slightly taller on phone.
     NOT applied to .btn globally — slabChooseBtn/visualizePrimary use height:auto
     or padding-driven height that must not be clamped. */
  #uploadBtn,
  #visualizeDraftBtn,
  #visualizeBtn,
  #loadStonesBtn { height: 44px; }
  /* Pills already 36px; bump to 40px for comfortable phone touch */
  .pillBtn { height: 40px; }

  /* History: ~2 items on phone, drop noisy secondary line */
  .historyList          { max-height: 126px; }
  .historyLineSecondary { display: none; }
  /* History thumbnails slightly smaller to fit more text */
  .historyThumb { width: 48px; height: 36px; }

  /* Action bar below render image: collapse 3-col to 2-col, drop zoom hint */
  .vizActionsBar {
    grid-template-columns: 1fr 1fr;
    padding: 6px 10px;
  }
  .vizActionsBar .zoomHint  { display: none; }
  .vizActionsBar .vizActionBtn { width: auto; justify-content: center; }

  /* Stone picker: near-full-height on phone */
  .stoneModalInner    { max-height: 95vh; border-radius: 16px 16px 0 0; }
  /* Filter row: smaller selects, tighter gaps */
  .stoneModalFilters  { gap: 5px; padding: 6px 12px; }
  .stoneFilterSelect  { height: 34px; font-size: 12px; padding: 0 8px; }
  /* Stone grid: smaller cards on narrow screens */
  .stoneModalGrid     { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }

  /* Compare panel: shrink hint text, stack hint + button */
  .compareTopRow      { flex-direction: column; gap: 4px; }
  .compareHint        { font-size: 11px; }

  /* Color picker: full width on phone */
  .colorModalInner    { max-height: 92vh; border-radius: 16px 16px 0 0; }

  /* Generic room modal: larger on phone */
  .genericRoomModalInner { max-height: 92vh; border-radius: 16px 16px 0 0; }
  .genericRoomModalGrid  { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }

  /* AI Design modal: full height */
  #aiDesignModal .modalCard { max-height: 92vh; display: flex; flex-direction: column; }
  #aiDesignModal .modalBody { flex: 1; overflow-y: auto; }
}

/* ── Small phone (≤480px) ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .grid  { padding: 6px 10px 20px; gap: 10px; }

  /* Stone grid: 2 columns minimum on very small phones */
  .stoneModalGrid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }

  /* Generic room: single column on tiny phones */
  .genericRoomModalGrid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

  /* AI theme chips: wrap tightly */
  .aiThemeRow { flex-wrap: wrap; gap: 6px; }
  .aiThemeBtn { flex: 1; min-width: 120px; }
}

/* ── Generic room image picker modal ─────────────────────────────────────── */
.genericRoomModal {
  position: fixed; inset: 0; z-index: 100;
  background: var(--overlay); backdrop-filter: blur(4px);
  display: none; align-items: flex-end; justify-content: center;
}
.genericRoomModal.open { display: flex; }

.genericRoomModalInner {
  background: var(--card); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 720px; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: var(--sh-xl);
}
.genericRoomModalHeader {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 20px 12px; border-bottom: 0.5px solid var(--border); flex-shrink: 0;
}
.genericRoomModalTitle {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px; font-weight: 400; color: var(--text);
  margin-bottom: 2px;
}
.genericRoomModalClose {
  background: var(--surface); border: 1px solid var(--border); border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--muted-2); cursor: pointer; flex-shrink: 0;
  transition: background var(--t-base);
}
.genericRoomModalClose:hover { background: var(--border); }

.genericRoomModalBody {
  flex: 1; overflow-y: auto; padding: 16px 20px 24px;
}
.genericRoomModalGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

/* Each image option in the modal */
.genericRoomItem {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; cursor: pointer;
  transition: border-color var(--t-base), box-shadow var(--t-base), transform var(--t-fast);
  padding: 0;
}
.genericRoomItem:hover {
  border-color: var(--accent-50); box-shadow: var(--sh-md);
}
.genericRoomItem:active { transform: scale(0.98); }

.genericRoomItemImg {
  width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block;
}

/* ── Generic room chips (JS-generated) ───────────────────────────────────── */
.genericRoomChip {
  height: auto !important;
  padding: 6px 10px !important;
  border-radius: 8px !important;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 80px;
}
.genericRoomThumb {
  width: 100%;
  height: 52px;
  object-fit: cover;
  border-radius: 5px;
  display: block;
  flex-shrink: 0;
}
.genericRoomChip span { font-size: 11px; font-weight: 500; }
.genericRoomChip.isActive {
  background: var(--accent-15);
  border-color: var(--accent-50);
}

/* ── History items (JS-generated) ────────────────────────────────────────── */
.historyItem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--t-base);
}
.historyItem:hover { background: var(--card); }
.historyItem.isCompareArmed { border-color: var(--accent-50); background: var(--accent-10); }

.historyThumb {
  width: 56px;
  height: 40px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
  border: 0.5px solid var(--border);
}
.historyMain { flex: 1; min-width: 0; }
.historyLinePrimary {
  font-size: 12px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.historyLineSecondary { font-size: 11px; color: var(--muted); margin-top: 2px; }
.historyActions { display: flex; gap: 6px; flex-shrink: 0; }
.historyCompareBtn {
  height: 26px; padding: 0 8px; border-radius: 5px; font-size: 11px;
  background: var(--card); border: 1px solid var(--border-s); color: var(--muted-2);
  cursor: pointer; transition: background var(--t-base);
}
.historyCompareBtn:hover { background: var(--surface); color: var(--text); }

/* ── Color tiles in color picker modal (JS-generated) ────────────────────── */
.colorTile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 6px;
  background: var(--card);
  border: 1px solid var(--border-s);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color var(--t-base), background var(--t-base);
}
.colorTile:hover { border-color: var(--accent-50); background: var(--surface); }
.colorTileChip {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--border); flex-shrink: 0;
}
.colorTileLabel { font-size: 10px; color: var(--muted-2); text-align: center; line-height: 1.2; }

/* ── Stone modal items (JS-generated) ────────────────────────────────────── */
.stoneModalItem {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.stoneModalItem:hover { border-color: var(--accent-50); box-shadow: var(--sh-md); }
.stoneModalItem.isRecommended { border-color: var(--accent-30); }

.stoneModalThumbWrap { width: 100%; aspect-ratio: 3/2; overflow: hidden; background: var(--bg); }
.stoneModalThumb { width: 100%; height: 100%; object-fit: cover; display: block; }

.stoneModalMeta { padding: 8px; }
.stoneModalName { font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.stoneModalDetails { font-size: 10px; color: var(--muted); }

/* ── Compare toast (JS-generated, positioned by JS) ──────────────────────── */
.compareToast {
  position: fixed;
  z-index: 500;
  display: none; /* JS adds .show to make visible */
  background: var(--card); border: 0.5px solid var(--border-s);
  border-radius: 8px; padding: 8px 16px; font-size: 13px; color: var(--text);
  box-shadow: var(--sh-lg); white-space: nowrap; max-width: 360px;
}
.compareToast.show { display: block; }

/* ── Render wipe-reveal overlay (JS-generated img) ───────────────────────── */
.renderImgOverlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: contain;
  clip-path: inset(0 100% 0 0); /* fully hidden — wipe starts from left */
  will-change: clip-path;
}
.renderImgOverlay.is-revealing {
  clip-path: inset(0 0% 0 0); /* fully revealed */
  transition: clip-path 0.9s cubic-bezier(0.76, 0, 0.24, 1);
}

/* ── AI slab chip elements (JS-generated) ────────────────────────────────── */
.aiSlabThumb {
  width: 28px; height: 20px; object-fit: cover;
  border-radius: 3px; flex-shrink: 0; border: 0.5px solid var(--border);
}
.aiSlabName { font-size: 12px; font-weight: 500; flex: 1; }

/* ── Flash animation ─────────────────────────────────────────────────────── */
/* Shimmer for images loading from S3 — shows intent while bytes arrive */
@keyframes imgShimmer {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 0.85; }
}

.genericRoomThumb,
.genericRoomItemImg,
.stoneModalThumb {
  background: var(--surface);
}
.genericRoomThumb:not(.imgLoaded),
.genericRoomItemImg:not(.imgLoaded),
.stoneModalThumb:not(.imgLoaded) {
  animation: imgShimmer 1.3s ease-in-out infinite;
}

@keyframes stoneFlash {
  0%   { box-shadow: 0 0 0 0 var(--accent-30); }
  50%  { box-shadow: 0 0 0 6px var(--accent-10); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.stoneFlash { animation: stoneFlash 0.7s ease forwards; }
