/* ============ TOKENS ============ */
:root {
  --espresso: #2a1810;
  --walnut-900: #3a2415;
  --walnut-700: #5c3a21;
  --walnut-600: #6b4423;
  --walnut-400: #a67c52;
  --walnut-200: #d4b896;
  --cream: #f7f0e3;
  --cream-deep: #efe4d0;
  --moss-900: #1e2a18;
  --moss-700: #3f5233;
  --moss-500: #5c7a4a;
  --moss-300: #8fa878;
  --sage: #a8b89a;
  --amber: #c9762f;
  --amber-deep: #a85a1f;
  --ink: #241a12;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --shadow-soft: 0 10px 30px -12px rgba(42, 24, 16, 0.35);
  --font-display: 'Fredoka', 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Nunito', 'Work Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
}
h1, h2, h3, .wordmark { font-family: var(--font-display); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
a { color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 24px; border-radius: 999px; border: none;
  font-weight: 700; font-size: 0.98rem; font-family: var(--font-display);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
}
.btn-primary {
  background: var(--amber); color: var(--cream);
  box-shadow: 0 4px 0 var(--amber-deep);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--amber-deep); }
.btn-primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 var(--amber-deep); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: 0 4px 0 var(--amber-deep); }
.btn-ghost {
  background: transparent; color: var(--walnut-700);
  border: 2px solid var(--walnut-400);
}
.btn-ghost:hover { background: var(--walnut-200); }
.btn-small { padding: 8px 16px; font-size: 0.85rem; }
.btn-outline {
  background: var(--cream); color: var(--walnut-700);
  border: 2px solid var(--walnut-200); border-radius: 999px;
  padding: 8px 16px; font-weight: 700; font-size: 0.85rem; font-family: var(--font-display);
}
.btn-outline.active, .btn-outline:hover { background: var(--moss-500); color: var(--cream); border-color: var(--moss-500); }
.btn-icon {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--walnut-200); color: var(--walnut-900);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 800;
}
.btn-icon:hover { background: var(--amber); color: var(--cream); }

.mono-label {
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--walnut-600); margin: 0 0 8px;
}

/* ============ HEADER ============ */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--cream); border-bottom: 3px solid var(--walnut-900);
}
.header-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; }
.wordmark {
  font-size: 1.5rem; font-weight: 800; text-decoration: none; color: var(--walnut-900);
  display: flex; align-items: center; gap: 8px;
}
.wordmark .nut { display: inline-block; transition: transform 0.3s ease; }
.wordmark:hover .nut { transform: rotate(25deg) scale(1.15); }
.header-nav { display: flex; gap: 6px; align-items: center; }
.header-nav a {
  text-decoration: none; padding: 9px 16px; border-radius: 999px;
  font-weight: 700; color: var(--walnut-700); font-size: 0.95rem;
}
.header-nav a:hover { background: var(--walnut-200); }

/* ============ HERO ============ */
.hero { padding: 64px 0 40px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 48px; align-items: center; }
.eyebrow {
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em;
  font-size: 0.78rem; color: var(--moss-700); font-weight: 600; margin: 0 0 10px;
}
.hero h1 { font-size: 3.1rem; line-height: 1.06; margin: 0 0 18px; color: var(--walnut-900); }
.hero h1 .accent { color: var(--amber); }
.hero-sub { font-size: 1.08rem; color: var(--walnut-700); max-width: 46ch; margin: 0 0 26px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-art { position: relative; height: 340px; }
.hero-frame {
  position: absolute; border-radius: 8px; box-shadow: var(--shadow-soft);
  background: linear-gradient(135deg, var(--walnut-400), var(--walnut-700));
  padding: 10px; overflow: hidden; box-sizing: border-box;
}
.hero-frame img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 2px; }
.hero-frame.f1 { width: 150px; height: 190px; top: 10px; left: 30px; transform: rotate(-6deg); z-index: 2; }
.hero-frame.f2 { width: 130px; height: 130px; top: 130px; left: 210px; transform: rotate(5deg); z-index: 3; }
.hero-frame.f3 { width: 110px; height: 150px; top: 0; left: 260px; transform: rotate(-3deg); z-index: 1; }
.hero-blob {
  position: absolute; inset: 0; z-index: 0; opacity: 0.5;
  background: radial-gradient(circle at 30% 40%, var(--moss-300), transparent 60%);
}

/* ============ SECTION GENERIC ============ */
.section { padding: 64px 0; }
.section h2 { font-size: 2rem; color: var(--walnut-900); margin: 0 0 8px; }
.section-sub { color: var(--walnut-700); max-width: 62ch; margin: 0 0 30px; }
.section-alt { background: var(--walnut-900); color: var(--cream); }
.section-alt .section-sub { color: var(--walnut-200); }
.section-alt h2 { color: var(--cream); }
.section-alt .mono-label { color: var(--moss-300); }

/* ============ STEP INDICATOR ============ */
.step-track { display: flex; gap: 10px; margin-bottom: 34px; flex-wrap: wrap; }
.step-pill {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px 8px 8px;
  border-radius: 999px; background: var(--cream-deep); border: 2px solid transparent;
  font-weight: 700; color: var(--walnut-400); font-size: 0.92rem;
}
.step-pill .num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--walnut-200);
  color: var(--walnut-900); display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem;
}
.step-pill.active { border-color: var(--amber); color: var(--walnut-900); background: #fff; }
.step-pill.active .num { background: var(--amber); color: #fff; }
.step-pill.done .num { background: var(--moss-500); color: #fff; }
.step-pill.done { color: var(--moss-700); }

/* ============ UPLOAD GRID ============ */
.upload-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; margin-bottom: 26px; }
.upload-slot {
  position: relative; border: 3px dashed var(--walnut-200); border-radius: var(--radius-lg);
  background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 18px; cursor: pointer; transition: border-color 0.2s, background 0.2s, transform 0.15s;
  overflow: hidden; min-height: 200px;
}
.upload-slot:hover { border-color: var(--amber); transform: translateY(-2px); }
.upload-slot.filled { border-style: solid; border-color: var(--moss-500); padding: 0; }
.upload-slot.wall-slot { min-height: 320px; }
.upload-slot img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.upload-slot .slot-badge {
  position: absolute; top: 10px; left: 10px; background: var(--walnut-900); color: var(--cream);
  font-family: var(--font-mono); font-size: 0.68rem; padding: 3px 9px; border-radius: 999px; z-index: 2;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.upload-slot .slot-remove { position: absolute; top: 8px; right: 8px; z-index: 2; }
.upload-slot .slot-icon { color: var(--walnut-400); margin-bottom: 8px; }
.upload-slot .slot-title { font-weight: 800; color: var(--walnut-800); margin: 0 0 4px; }
.upload-slot .slot-hint { font-size: 0.82rem; color: var(--walnut-400); margin: 0; }
.room-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.room-slots .upload-slot { min-height: 150px; }

.analyze-bar { display: flex; align-items: center; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.analyze-hint { color: var(--walnut-400); font-size: 0.9rem; }

/* ============ ANALYSIS RESULT ============ */
.analysis-card {
  background: #fff; border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-soft);
  margin-top: 10px;
}
.swatch-row { display: flex; gap: 8px; }
.swatch {
  width: 42px; height: 42px; border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08); flex-shrink: 0;
}
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 18px; }
.tag {
  background: var(--moss-500); color: #fff; font-size: 0.78rem; font-weight: 700;
  padding: 5px 13px; border-radius: 999px; text-transform: capitalize;
}
.tag.amber { background: var(--amber); }
.suggest-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 6px; }
.suggest-item { background: var(--cream-deep); border-radius: var(--radius-md); padding: 14px; }
.suggest-item .mono-label { margin-bottom: 4px; }
.suggest-item strong { display: block; color: var(--walnut-900); font-size: 1.02rem; }

/* ============ EDITOR ============ */
.editor-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: #fff; border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}
.toolbar-group { display: flex; align-items: center; gap: 6px; }
.toolbar-group .mono-label { margin: 0 6px 0 0; }

.upload-slot.drag-over { border-color: var(--amber); background: var(--cream-deep); transform: translateY(-2px); }

.photo-drop {
  border: 3px dashed var(--walnut-200); border-radius: var(--radius-lg);
  background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 30px 18px; cursor: pointer; transition: border-color 0.2s, background 0.2s, transform 0.15s;
  margin-bottom: 18px;
}
.photo-drop:hover, .photo-drop.drag-over { border-color: var(--amber); background: var(--cream-deep); transform: translateY(-2px); }
.photo-drop .slot-icon { color: var(--walnut-400); margin-bottom: 8px; }
.photo-drop .slot-title { font-weight: 800; color: var(--walnut-800); margin: 0 0 4px; }
.photo-drop .slot-hint { font-size: 0.85rem; color: var(--walnut-400); margin: 0; }

.photo-thumb-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 8px;
}
.photo-card {
  /* aspect-ratio is set per-card from the photo's own dimensions in JS
     (renderPhotoThumbs) via --photo-ar, so portrait photos preview as
     portrait and landscape photos preview as landscape instead of every
     upload being force-cropped into the same horizontal box. 4/3 here is
     only a fallback for the brief instant before that's set. */
  position: relative; border-radius: var(--radius-md); overflow: hidden; aspect-ratio: var(--photo-ar, 4/3);
  border: 3px solid transparent; cursor: pointer; background: var(--cream-deep);
}
.photo-card img { width: 100%; height: 100%; object-fit: cover; }
.photo-card.is-wall { border-color: var(--amber); }
.photo-card .wall-flag {
  position: absolute; top: 8px; left: 8px; background: var(--amber); color: #fff; font-weight: 800;
  font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px;
}
.photo-card .set-wall-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(42,24,16,0.55); color: #fff; font-weight: 700; font-size: 0.8rem; opacity: 0; transition: opacity 0.15s;
}
.photo-card:not(.is-wall):hover .set-wall-hint { opacity: 1; }
.photo-card .thumb-remove {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; border: none;
  background: rgba(42,24,16,0.75); color: #fff; font-size: 0.75rem; z-index: 2;
}
.photo-card .thumb-remove:hover { background: var(--amber); }

.wall-col { min-width: 0; }
.straighten-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
  background: #fff; border-radius: var(--radius-md); padding: 10px 14px; box-shadow: var(--shadow-soft);
}
.straighten-row input[type="range"] { flex: 1; accent-color: var(--amber); }
.straighten-row #straightenValue { min-width: 38px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.wall-stage {
  position: relative; border-radius: var(--radius-lg); overflow: hidden;
  background: var(--walnut-200); box-shadow: var(--shadow-soft);
  aspect-ratio: 4 / 3; /* fallback shape before a wall photo loads — JS sets
    this inline to the actual photo's own aspect ratio once one is loaded,
    so the container matches the photo's shape instead of cropping it */
  touch-action: none; /* a touch starting on the background (easy to do
    while aiming for a small corner dot) had no protection, letting iOS
    Safari's native pinch/pan-zoom fire instead of the intended drag */
}
.wall-stage img.wall-bg { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.wall-stage .empty-stage-msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--walnut-600); font-weight: 700; text-align: center; padding: 20px;
}
.quad-outline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.quad-outline polygon { fill: rgba(201, 118, 47, 0.06); stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 6 5; }
.quad-handle {
  position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
  background: var(--amber); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  cursor: grab; z-index: 6; touch-action: none;
}
.quad-handle:active { cursor: grabbing; }

.toolbar-group.controls-disabled { opacity: 0.35; pointer-events: none; }
.frame-wrap {
  position: absolute; left: 0; top: 0; cursor: grab; touch-action: none;
  transform-origin: 0 0;
  filter: drop-shadow(0 3px 4px rgba(20, 12, 6, 0.42)) drop-shadow(0 16px 20px rgba(20, 12, 6, 0.3));
  /* Forces its own compositor layer. Without this, a filter + matrix3d
     transform on the same element can leave stale/duplicated paints behind
     on scroll in Chrome/Safari — most visible when a frame's transform is
     large (exactly what the runaway size bug above was causing). */
  will-change: transform;
  backface-visibility: hidden;
}
.frame-wrap:active { cursor: grabbing; }
.frame-wrap.selected .frame-border { outline: 3px dashed var(--amber); outline-offset: 3px; }
.frame-border {
  width: 100%; height: 100%; padding: 10px; border-radius: 2px;
  background: linear-gradient(135deg, var(--frame-c1, #8a5a34), var(--frame-c2, #5c3a21));
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25), inset 0 2px 4px rgba(255,255,255,0.25), inset 0 -2px 4px rgba(0,0,0,0.35);
  display: flex;
}
.frame-mat {
  flex: 1; background: #f4efe4; box-shadow: inset 0 0 8px rgba(0,0,0,0.15);
  display: flex; padding: var(--mat-px, 14px);
}
.frame-photo-wrap { position: relative; flex: 1; overflow: hidden; background: #d8cfc0; }
.frame-photo-wrap img { width: 100%; height: 100%; object-fit: fill; }
.frame-empty-slot {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--walnut-400); font-size: 1.6rem; font-weight: 800;
  background: repeating-linear-gradient(45deg, #efe6d6, #efe6d6 8px, #e6dac4 8px, #e6dac4 16px);
}
.frame-glass {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 32%, rgba(255,255,255,0) 68%, rgba(255,255,255,0.12) 100%);
}
.frame-wrap[data-glass="polycarbonate"] {
  /* A thin acrylic panel sits closer to the wall and casts a lighter,
     tighter shadow than a deep wood frame. */
  filter: drop-shadow(0 2px 3px rgba(20, 12, 6, 0.22)) drop-shadow(0 8px 10px rgba(20, 12, 6, 0.16));
}
.frame-wrap[data-glass="polycarbonate"] .frame-border {
  /* Fully edge-to-edge — no visible frame at all, just the ~5mm panel
     edge, which reads as a barely-there highlight rather than a border. */
  padding: 0;
  background: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35), 0 1px 3px rgba(0,0,0,0.15);
}
.frame-wrap[data-glass="polycarbonate"] .frame-mat {
  padding: 0;
  background: transparent;
  box-shadow: none;
}
.frame-wrap[data-glass="polycarbonate"] .frame-glass {
  /* 4 standoff-bolt caps at the corners, like the acrylic panel sits a
     few mm off the wall on metal standoffs rather than hanging in a frame. */
  background:
    radial-gradient(circle at center, rgba(255,255,255,0.95) 0%, rgba(215,215,215,0.9) 32%, rgba(110,110,110,0.55) 55%, rgba(110,110,110,0) 62%),
    radial-gradient(circle at center, rgba(255,255,255,0.95) 0%, rgba(215,215,215,0.9) 32%, rgba(110,110,110,0.55) 55%, rgba(110,110,110,0) 62%),
    radial-gradient(circle at center, rgba(255,255,255,0.95) 0%, rgba(215,215,215,0.9) 32%, rgba(110,110,110,0.55) 55%, rgba(110,110,110,0) 62%),
    radial-gradient(circle at center, rgba(255,255,255,0.95) 0%, rgba(215,215,215,0.9) 32%, rgba(110,110,110,0.55) 55%, rgba(110,110,110,0) 62%),
    repeating-linear-gradient(125deg, rgba(255,255,255,0.14) 0 3px, rgba(255,255,255,0.02) 3px 9px),
    linear-gradient(115deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0.04) 55%);
  background-repeat: no-repeat;
  background-size: 14px 14px, 14px 14px, 14px 14px, 14px 14px, auto, auto;
  background-position: 10px 10px, calc(100% - 10px) 10px, 10px calc(100% - 10px), calc(100% - 10px) calc(100% - 10px), 0 0, 0 0;
}
.frame-wrap[data-glass="polycarbonate"] .frame-photo-wrap img { filter: saturate(0.9) contrast(0.96); }

.frame-resize {
  position: absolute; right: -7px; bottom: -7px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--amber); border: 2px solid #fff; cursor: nwse-resize; box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.frame-toolbar { position: absolute; top: -34px; left: 0; display: none; gap: 4px; }
.frame-wrap.selected .frame-toolbar { display: flex; }
.frame-toolbar button {
  width: 26px; height: 26px; border-radius: 50%; border: none; background: var(--walnut-900); color: #fff; font-size: 0.75rem;
}
.frame-toolbar button:hover { background: var(--amber); }

/* frame tone presets */
[data-tone="walnut"]   { --frame-c1: #8a5a34; --frame-c2: #4a2f1f; }
[data-tone="oak"]      { --frame-c1: #e0c9a6; --frame-c2: #a67c52; }
[data-tone="espresso"] { --frame-c1: #4a2f1f; --frame-c2: #1c110a; }
[data-tone="black"]    { --frame-c1: #4a4a4a; --frame-c2: #0d0d0d; }
[data-tone="white"]    { --frame-c1: #ffffff; --frame-c2: #d8d2c4; }

/* ============ SIDEBAR / TABS ============ */
.editor-sidebar { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-soft); overflow: hidden; }
.selected-panel { padding: 16px 18px; border-bottom: 2px solid var(--cream-deep); background: var(--cream-deep); }
.selected-panel.empty { color: var(--walnut-400); font-size: 0.9rem; text-align: center; }
.style-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.tone-dot {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
  cursor: pointer;
}
.tone-dot.active { box-shadow: 0 0 0 3px var(--amber); }
.tone-dot[data-tone="walnut"] { background: linear-gradient(135deg, #8a5a34, #4a2f1f); }
.tone-dot[data-tone="oak"] { background: linear-gradient(135deg, #e0c9a6, #a67c52); }
.tone-dot[data-tone="espresso"] { background: linear-gradient(135deg, #4a2f1f, #1c110a); }
.tone-dot[data-tone="black"] { background: linear-gradient(135deg, #4a4a4a, #0d0d0d); }
.tone-dot[data-tone="white"] { background: linear-gradient(135deg, #ffffff, #d8d2c4); }

.size-select {
  width: 100%; padding: 9px 10px; border-radius: var(--radius-sm); border: 2px solid var(--walnut-200);
  font-family: var(--font-body); font-size: 0.88rem; color: var(--walnut-800); background: #fff;
}
.price-row { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.price-amount { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; color: var(--walnut-900); }
.price-amount.muted { font-family: var(--font-body); font-weight: 600; font-size: 0.85rem; color: var(--walnut-400); }
.order-note { font-size: 0.78rem; color: var(--amber-deep); }

.order-panel {
  grid-column: 1 / -1; margin-top: 8px; background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft); padding: 28px;
}
.order-panel h2 { margin-top: 4px; }
.order-line {
  display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--cream-deep);
}
.order-line img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.order-line-info { flex: 1; min-width: 0; }
.order-line-info .title { font-weight: 700; color: var(--walnut-900); font-size: 0.92rem; }
.order-line-info .meta { font-size: 0.8rem; color: var(--walnut-400); }
.order-line-price { font-weight: 700; color: var(--walnut-900); white-space: nowrap; }
.order-line.not-ready { opacity: 0.55; }
.order-line.not-ready .order-line-price { color: var(--walnut-400); font-weight: 600; font-size: 0.8rem; }
.order-empty { color: var(--walnut-400); font-size: 0.9rem; padding: 16px 0; }
.order-total-row {
  display: flex; justify-content: space-between; align-items: center; padding: 16px 0 4px; font-weight: 800;
  color: var(--walnut-900); font-size: 1.15rem; font-family: var(--font-display);
}
.order-email-row { margin: 18px 0; }
.order-email-row label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--walnut-700); margin-bottom: 6px; }
.order-email-row input {
  width: 100%; max-width: 360px; padding: 11px 14px; border-radius: 999px; border: 2px solid var(--walnut-200);
  font-family: var(--font-body); font-size: 0.95rem;
}
.order-cta-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.order-hint { font-size: 0.82rem; color: var(--walnut-400); }
.pill-select { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-select button {
  border: 2px solid var(--walnut-200); background: #fff; border-radius: 999px; padding: 6px 12px;
  font-size: 0.78rem; font-weight: 700; color: var(--walnut-700);
}
.pill-select button.active { background: var(--moss-500); border-color: var(--moss-500); color: #fff; }

.tab-row { display: flex; border-bottom: 2px solid var(--cream-deep); }
.tab-btn {
  flex: 1; padding: 13px; background: none; border: none; font-weight: 800; color: var(--walnut-400);
  border-bottom: 3px solid transparent; font-family: var(--font-display);
}
.tab-btn.active { color: var(--walnut-900); border-bottom-color: var(--amber); }
.tab-panel { display: none; padding: 16px 18px; max-height: 480px; overflow-y: auto; }
.tab-panel.active { display: block; }

.upload-drop {
  border: 2px dashed var(--walnut-200); border-radius: var(--radius-md); padding: 18px; text-align: center;
  color: var(--walnut-500); font-size: 0.88rem; cursor: pointer; margin-bottom: 12px;
}
.upload-drop:hover { border-color: var(--amber); }
.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; cursor: pointer; border: 2px solid transparent; }
.thumb.selected { border-color: var(--amber); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .thumb-score {
  position: absolute; bottom: 2px; right: 2px; background: rgba(42,24,16,0.75); color: #fff;
  font-size: 0.6rem; padding: 1px 5px; border-radius: 6px; font-family: var(--font-mono);
}
.gallery-search {
  width: 100%; max-width: 420px; padding: 11px 16px; border-radius: 999px; border: 2px solid var(--walnut-200);
  font-family: var(--font-body); font-size: 0.92rem; margin-bottom: 12px; display: block;
}
.gallery-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.helper-text { font-size: 0.82rem; color: var(--walnut-400); margin: 0 0 12px; }

/* ============ GALLERY SECTION (standalone tab) ============ */
.gallery-grid { column-count: 4; column-gap: 18px; }
.gallery-card {
  background: #fff; border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease; break-inside: avoid; margin-bottom: 18px; display: inline-block; width: 100%;
  content-visibility: auto; contain-intrinsic-size: 0 320px;
}
.gallery-card:hover { transform: translateY(-4px) rotate(-0.5deg); }
.gallery-card img { width: 100%; height: auto; display: block; cursor: zoom-in; }
.gallery-card-body { padding: 12px 14px; }
.gallery-card-body h4 { margin: 0 0 6px; font-size: 0.95rem; color: var(--walnut-900); }
.gallery-card-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.gallery-card-tags span { font-size: 0.68rem; background: var(--cream-deep); color: var(--walnut-600); padding: 2px 8px; border-radius: 999px; }
.gallery-card-body button { width: 100%; margin-top: 10px; }

@media (max-width: 1100px) { .gallery-grid { column-count: 3; } }
@media (max-width: 780px) { .gallery-grid { column-count: 2; } }
@media (max-width: 480px) { .gallery-grid { column-count: 1; } }

/* ============ FOOTER ============ */
.site-footer { background: var(--walnut-900); color: var(--cream-deep); padding: 34px 0; margin-top: 40px; }
.footer-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.footer-row .wordmark { color: var(--cream); }
.footer-note { font-size: 0.85rem; color: var(--walnut-200); }

.lightbox {
  position: fixed; inset: 0; background: rgba(24, 14, 8, 0.82); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.lightbox.show { display: flex; }
.lightbox-inner {
  position: relative; background: #fff; border-radius: var(--radius-lg); overflow: hidden;
  max-width: 780px; width: 100%; max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 30px 60px rgba(0,0,0,0.4);
}
.lightbox-inner img { width: 100%; max-height: 62vh; object-fit: contain; background: var(--cream-deep); }
.lightbox-close { position: absolute; top: 12px; right: 12px; z-index: 2; background: #fff; }
.lightbox-info { padding: 20px 24px; }
.lightbox-info h3 { margin: 0 0 8px; color: var(--walnut-900); }
.lightbox-info .gallery-card-tags { margin-bottom: 16px; }

/* ============ MISC ============ */
.hidden { display: none !important; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--walnut-900); color: var(--cream); padding: 12px 22px; border-radius: 999px;
  font-weight: 700; font-size: 0.9rem; opacity: 0; transition: all 0.25s ease; pointer-events: none; z-index: 100;
  box-shadow: var(--shadow-soft);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 880px) {
  .hero-grid { grid-template-columns: 1fr; }
  .upload-grid { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: 1fr; }
  .suggest-grid { grid-template-columns: 1fr 1fr; }
}