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

:root {
  --bg: #f5f3f0;
  --bg2: #eceae6;
  --bg3: #e2e0db;
  --white: #ffffff;
  --ink: #1a1816;
  --ink2: #3a3632;
  --ink3: #6a6460;
  --muted: #9a9490;
  --line: #e0ddd8;
  --line2: #ccc9c4;
  --gold: #b8860a;
  --gold2: #d4a020;
  --gold3: #f0bc38;
  --gold-bg: rgba(184,134,10,0.08);
  --gold-line: rgba(184,134,10,0.25);
  --red: #b83030;
  --red-bg: rgba(184,48,48,0.08);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
  --r: 12px;
  --r-sm: 8px;
  --sidebar-w: 220px;
}

html { background: var(--bg); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Geist', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.gate-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg); text-align: center; padding: 24px;
}
.gate-screen.done { display: none; }
.gate-title { font-family: 'Instrument Serif', serif; font-size: 22px; margin-bottom: 8px; }
.gate-sub { color: var(--muted); font-size: 13px; max-width: 320px; }

.reimagine-app {
  display: none;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  position: relative;
}
.reimagine-app.ready { display: grid; }

/* Sidebar */
.reimagine-sidebar {
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ri-brand { display: flex; align-items: center; gap: 8px; }
.ri-brand--stacked {
  flex-direction: column; align-items: flex-start; gap: 6px;
}
.ri-brand-logo {
  width: 40px; height: 40px; object-fit: contain; display: block;
}
.ri-brand-wordmark {
  font-family: 'Geist Mono', monospace;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.14em; color: var(--ink);
  line-height: 1;
}
.ri-brand-icon {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--ink); color: var(--gold3);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.ri-brand-title {
  font-family: 'Instrument Serif', serif;
  font-size: 16px; font-style: italic;
}
.ri-brand-sub {
  font-size: 9px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  font-family: 'Geist Mono', monospace;
}

.ri-section-label {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
  font-family: 'Geist Mono', monospace;
  margin-bottom: 8px;
}

.ri-upload-zone {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px;
  border: 1.5px dashed var(--line2);
  border-radius: var(--r-sm);
  padding: 14px 10px;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.12s, background 0.12s;
}
.ri-upload-zone:hover { border-color: var(--gold-line); background: var(--gold-bg); }
.ri-upload-label { font-size: 12px; font-weight: 500; color: var(--ink2); }
.ri-upload-hint { font-size: 10px; color: var(--muted); }
.ri-upload-example-link {
  margin-top: 7px;
  border: none;
  background: transparent;
  color: var(--gold);
  font-size: 10px;
  font-family: 'Geist Mono', monospace;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ri-upload-target-highlight {
  animation: ri-upload-target-pulse 1.6s ease;
}
@keyframes ri-upload-target-pulse {
  0%, 100% { box-shadow: none; }
  20%, 70% { box-shadow: 0 0 0 4px rgba(212,160,32,0.22); }
}

.ri-photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.ri-photo-grid:empty { display: none; }

.ri-recent-uploads { margin-top: 10px; }
.ri-recent-uploads-label {
  font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted);
  font-family: 'Geist Mono', monospace;
  margin-bottom: 6px;
}
.ri-recent-uploads-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.ri-recent-uploads-grid:empty { display: none; }
.ri-recent-thumb {
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--bg2);
  padding: 0;
  width: 100%;
}
.ri-recent-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ri-recent-thumb.active {
  border-color: var(--gold2);
  box-shadow: 0 0 0 2px var(--gold-bg);
}

.ri-photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--bg2);
}
.ri-photo-thumb.active { border-color: var(--gold2); box-shadow: 0 0 0 2px var(--gold-bg); }
.ri-photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ri-photo-remove {
  position: absolute; top: 3px; right: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.8);
  background: var(--red); color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  font-size: 16px; font-weight: 700; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.ri-photo-remove:hover { background: #8f2020; }

.ri-uuid-row { display: flex; gap: 6px; margin-top: 8px; }
.ri-likeness-wrap { margin-top: 10px; }
.ri-likeness-label {
  display: flex; align-items: center; gap: 8px; width: 100%;
  font-size: 11px; color: var(--muted);
}
.ri-likeness-title {
  flex-shrink: 0;
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink2);
}
.ri-likeness-label input[type="range"] {
  flex: 1; min-width: 0; accent-color: var(--gold2, #c89820);
}
.ri-likeness-val {
  flex-shrink: 0; min-width: 2.2rem; text-align: right;
  font-family: 'Geist Mono', monospace; color: var(--ink2);
}
.ri-uuid-input {
  flex: 1; min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px;
  font-size: 11px; font-family: 'Geist Mono', monospace;
  background: var(--white);
}
.ri-guidance { font-size: 10px; color: var(--muted); margin-top: 8px; line-height: 1.4; }

.ri-result-thumb-wrap {
  display: block; width: 100%; border: none; padding: 0;
  background: none; cursor: pointer; border-radius: var(--r-sm);
  overflow: hidden;
}
.ri-result-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.ri-result-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ri-result-actions .ri-btn { flex: 1 1 calc(50% - 3px); min-width: 0; font-size: 11px; padding: 6px 8px; }
.ri-result-actions .ri-btn--solid { flex: 1 1 100%; }

.ri-loading-panel {
  text-align: center;
  padding: 14px 12px;
  margin: 0 0 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.ri-loading-ring {
  width: 28px; height: 28px; margin: 0 auto 8px;
  border: 2px solid var(--line); border-top-color: var(--gold);
  border-radius: 50%; animation: ri-spin 0.8s linear infinite;
}
@keyframes ri-spin { to { transform: rotate(360deg); } }
.ri-loading-text { font-size: 11px; color: var(--muted); }

.ri-history-list { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.ri-hist-item {
  display: flex; gap: 8px; align-items: center;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px; background: var(--bg); cursor: pointer;
  text-align: left; width: 100%; font-family: inherit;
}
.ri-hist-item:hover { border-color: var(--line2); }
.ri-hist-item:hover .ri-hist-delete { opacity: 1; }
.ri-hist-delete {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.12s, color 0.12s, background 0.12s, border-color 0.12s;
}
.ri-hist-delete:hover {
  opacity: 1;
  color: #b83030;
  background: rgba(184, 48, 48, 0.1);
  border-color: rgba(184, 48, 48, 0.25);
}
.ri-hist-thumb { width: 36px; height: 36px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.ri-hist-prompt {
  flex: 1;
  min-width: 0;
  font-size: 10px; color: var(--ink2); line-height: 1.3;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

.ri-load-more {
  margin-top: 6px; width: 100%;
  border: 1px solid var(--line); background: var(--white);
  border-radius: 6px; padding: 6px; font-size: 11px;
  cursor: pointer; color: var(--ink2);
}

.ri-sidebar-foot {
  position: sticky;
  bottom: -16px;
  z-index: 6;
  margin: auto -12px -16px;
  padding: 12px 12px 14px;
  border-top: 1px solid var(--line);
  background: linear-gradient(rgba(255,255,255,0.94), var(--white) 18%);
  box-shadow: 0 -8px 20px rgba(0,0,0,0.04);
}
.ri-sidebar-credit-card {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--gold-line);
  border-radius: var(--r-sm);
  background: var(--gold-bg);
}
.ri-sidebar-credit-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-family: 'Geist Mono', monospace;
}
.ri-sidebar-credit-value {
  margin-top: 2px;
  font-family: 'Instrument Serif', serif;
  font-size: 34px;
  line-height: 1;
  color: var(--ink);
}
.ri-sidebar-credit-link {
  display: inline-block;
  margin-top: 5px;
  color: var(--gold);
  font-size: 10px;
  font-family: 'Geist Mono', monospace;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ri-sidebar-credit-link:hover { color: var(--gold2); }
.ri-sidebar-referral-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.72);
}
.ri-sidebar-referral-text {
  min-width: 0;
  color: var(--ink2);
  font-size: 10px;
  line-height: 1.3;
}
.ri-sidebar-referral-link {
  flex-shrink: 0;
  border: none;
  background: none;
  padding: 0;
  color: var(--gold);
  font: 500 10px 'Geist Mono', monospace;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.ri-sidebar-referral-link:hover { color: var(--gold2); }
.ri-referral-buy-option {
  width: 100%;
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  background: var(--gold-bg);
  color: var(--gold);
  padding: 8px 10px;
  font: 500 10px 'Geist Mono', monospace;
  cursor: pointer;
}
.ri-referral-buy-option {
  margin: 12px 0 0;
  background: var(--white);
}
.ri-referral-buy-option:hover { border-color: var(--gold); color: var(--gold2); }
.ri-referral-link-box {
  word-break: break-all;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.75);
  padding: 10px 12px;
  margin: 10px 0;
  color: var(--ink);
  font: 11px/1.45 'Geist Mono', monospace;
}
.ri-display-name { font-size: 11px; color: var(--muted); }
.ri-wizard-footer-link {
  display: block;
  margin-top: 6px;
  border: none;
  background: transparent;
  padding: 0;
  color: var(--muted);
  font-size: 9px;
  font-family: 'Geist Mono', monospace;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-align: left;
}
.ri-wizard-footer-link:hover { color: var(--gold); }

.ri-modal--wide { max-width: min(92vw, 440px); }
.ri-feedback-intro {
  font-size: 13px; color: var(--ink2); line-height: 1.5; margin-bottom: 12px;
}
.ri-feedback-types { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ri-feedback-type-btn {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--white);
  font-size: 11px;
  cursor: pointer;
  color: var(--ink2);
  font-family: inherit;
}
.ri-feedback-type-btn.active {
  border-color: var(--gold-line);
  background: var(--gold-bg);
  color: var(--gold);
  font-weight: 600;
}
.ri-feedback-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 10px;
  min-height: 100px;
}
.ri-feedback-submit {
  width: 100%;
  padding: 10px;
  background: var(--ink);
  color: var(--white);
  border: none;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.ri-feedback-submit:disabled { opacity: 0.45; cursor: not-allowed; }
.ri-feedback-status {
  font-size: 12px; color: var(--gold); line-height: 1.5;
  margin-bottom: 10px; display: none;
}
.ri-feedback-status.show { display: block; }
.ri-feedback-recent { margin-top: 12px; font-size: 11px; color: var(--muted); line-height: 1.55; }

/* Main */
.reimagine-main {
  display: flex; flex-direction: column;
  min-height: 100vh; min-width: 0;
  position: relative;
}

.ri-main-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
  padding: 10px 16px 6px;
  flex-shrink: 0;
}
.ri-main-head-side {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.ri-main-head-side--left { justify-self: start; }
.ri-main-head-center {
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-width: 0;
}
.ri-main-head-chips {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}
.ri-main-head-side--right { justify-self: end; align-items: stretch; }
.ri-toolbar-chip--switch {
  text-decoration: none;
  color: inherit;
  align-items: flex-start;
  text-align: left;
  min-width: 132px;
  flex-shrink: 0;
}
.ri-toolbar-chip--switch:hover {
  border-color: var(--gold-line);
  background: var(--gold-bg);
  box-shadow: var(--shadow-md);
}
.ri-toolbar-chip--switch .ri-toolbar-chip-hint {
  max-width: none;
}
.ri-main-toolbar {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.ri-main-toolbar::-webkit-scrollbar { display: none; }
.ri-main-head-spacer { flex: 1; min-width: 0; }
.ri-toolbar-chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 1px;
  min-height: 48px;
  padding: 7px 12px;
  border: 1.5px solid var(--line2);
  border-radius: 11px;
  background: var(--white);
  cursor: pointer;
  font-family: inherit;
  text-align: right;
  box-shadow: var(--shadow);
  transition: border-color 0.12s, background 0.12s, color 0.12s, box-shadow 0.12s;
}
.ri-toolbar-chip-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.15;
  white-space: nowrap;
}
.ri-toolbar-chip-hint {
  font-size: 9px;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
}
.ri-toolbar-chip--referral {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 360px;
  width: max-content;
  max-width: min(100%, 440px);
  text-align: left;
  border-color: rgba(255, 255, 255, 0.1);
  background: var(--ink);
  box-shadow: 0 2px 10px rgba(26, 24, 22, 0.22);
  cursor: default;
}
.ri-toolbar-chip--referral .ri-toolbar-chip-label {
  color: var(--white);
  font-weight: 600;
}
.ri-toolbar-chip--referral .ri-toolbar-chip-hint {
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  line-height: 1.25;
  white-space: nowrap;
}
.ri-referral-chip-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--gold3);
}
.ri-referral-chip-icon svg {
  width: 15px;
  height: 15px;
  display: block;
}
.ri-referral-chip-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  flex: 1;
  min-width: 0;
}
.ri-referral-chip-btn {
  flex-shrink: 0;
  align-self: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  padding: 7px 14px;
  font: 600 10px 'Geist Mono', monospace;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.ri-referral-chip-btn:hover {
  border-color: var(--gold3);
  color: var(--gold3);
  background: rgba(240, 188, 56, 0.12);
}
.ri-toolbar-chip--adult.is-on {
  border-color: #8b3a3a;
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-bg);
}
.ri-toolbar-chip--adult.is-on .ri-toolbar-chip-label,
.ri-toolbar-chip--adult.is-on .ri-toolbar-chip-hint { color: var(--white); }
.ri-toolbar-chip--pro input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.ri-toolbar-chip--pro:hover,
.ri-toolbar-chip--adult:hover {
  border-color: var(--ink);
  background: var(--bg);
}
.ri-toolbar-chip--adult.is-on:hover {
  border-color: #6f2f2f;
  background: #7a3333;
}
.ri-back-link { font-size: 12px; color: var(--ink2); text-decoration: none; }
.ri-back-link:hover { color: var(--ink); }
.ri-pro-back {
  display: none;
  align-items: center;
  align-self: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1.5px solid var(--line2);
  border-radius: 11px;
  background: var(--white);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink2);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.12s, background 0.12s;
  white-space: nowrap;
}
body.pro-mode .ri-pro-back { display: flex; }
body.pro-mode #pro-mode-toggle-wrap { display: none !important; }
.ri-pro-back:hover { border-color: var(--ink); background: var(--bg); }

.ri-filter-bar-wrap {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 70%, transparent);
  padding: 6px 16px 8px; flex-shrink: 0;
}
.ri-filter-bar {
  display: flex; gap: 7px; overflow-x: auto;
  padding-bottom: 4px; scrollbar-width: thin;
}
.ri-filter-pill {
  flex-shrink: 0;
  padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--white);
  font-size: 11px; color: var(--ink2); cursor: pointer;
  font-family: inherit; transition: all 0.12s;
}
.ri-filter-pill:hover { border-color: var(--line2); background: var(--bg); }
.ri-filter-pill.active { border-color: var(--ink); background: var(--ink); color: var(--white); }

.ri-canvas {
  flex: 1; overflow-y: auto;
  padding: 0 16px 120px;
}

.ri-section { margin-bottom: 28px; }
.ri-section-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.ri-section-title {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
  font-family: 'Geist Mono', monospace;
  flex: 1;
}
.ri-section-nav { display: flex; gap: 4px; }
.ri-section-nav button {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--white);
  cursor: pointer; font-size: 14px; color: var(--ink2);
}
.ri-section-nav button:disabled { opacity: 0.3; cursor: default; }
.ri-view-all { font-size: 11px; color: var(--gold); text-decoration: none; white-space: nowrap; }
.ri-view-all:hover { text-decoration: underline; }

.ri-card-row {
  display: flex; gap: 12px; overflow-x: auto;
  scroll-behavior: smooth; padding-bottom: 4px;
  scrollbar-width: thin;
}
.ri-card-row .style-card { flex: 0 0 calc(25% - 9px); min-width: 130px; max-width: 160px; }

.ri-category-grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px; padding-top: 8px;
}

.style-card {
  border: 2px solid transparent; border-radius: var(--r-sm);
  background: var(--white); box-shadow: var(--shadow);
  cursor: pointer; overflow: hidden; text-align: left;
  transition: border-color 0.12s, transform 0.12s;
  padding: 0; font-family: inherit; width: 100%;
}
.style-card:hover { transform: translateY(-2px); border-color: var(--gold-line); }
.style-card.selected { border-color: var(--gold2); box-shadow: 0 0 0 3px var(--gold-bg); }
.style-card.style-card--pulse {
  animation: ri-style-pulse 2s ease-out 1;
}
@keyframes ri-style-pulse {
  0% { box-shadow: 0 0 0 0 rgba(212, 160, 32, 0.55); border-color: var(--gold2); }
  40% { box-shadow: 0 0 0 10px rgba(212, 160, 32, 0.18); border-color: var(--gold2); }
  100% { box-shadow: 0 0 0 0 rgba(212, 160, 32, 0); border-color: var(--gold2); }
}
.style-card-media {
  aspect-ratio: 3 / 4; width: 100%;
  background: linear-gradient(145deg, var(--bg2), var(--bg3));
  position: relative; overflow: hidden;
}
.style-card-scene-badge-wrap {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 7px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
  pointer-events: none;
}
.style-card-scene-badge {
  width: 16px;
  height: 16px;
  color: var(--ink2);
  display: block;
}
.style-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.style-card-placeholder {
  position: absolute; inset: 0; display: flex; align-items: flex-end;
  padding: 10px; font-family: 'Instrument Serif', serif;
  font-size: 14px; font-style: italic;
  background: linear-gradient(transparent 40%, rgba(245,243,240,0.92));
}
.style-card-body { padding: 8px 10px 10px; }
.style-card-title {
  font-size: 12px; font-weight: 500; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.style-card-tag {
  font-size: 10px; color: var(--muted);
  font-family: 'Geist Mono', monospace;
  text-transform: uppercase; letter-spacing: 0.04em;
}

.ri-pro-panel { padding-top: 8px; }
.ri-pro-caption {
  font-size: 13px; color: var(--ink2);
  margin-bottom: 10px; line-height: 1.45;
}
.ri-pro-textarea {
  width: 100%; border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 12px;
  font-family: inherit; font-size: 14px;
  resize: vertical; min-height: 160px;
  background: var(--white);
}
.ri-pro-attached {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--gold-line);
  border-radius: var(--r-sm);
  background: var(--gold-bg);
}
.ri-pro-attached-head { margin-bottom: 8px; }
.ri-pro-attached-title { font-size: 12px; font-weight: 600; color: var(--ink2); display: block; }
.ri-pro-attached-hint { font-size: 10px; color: var(--muted); display: block; margin-top: 2px; }
.ri-pro-attached-preview {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.ri-pro-ref-thumb,
.ri-selected-ref-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}
.ri-pro-ref-thumb img,
.ri-selected-ref-thumb img {
  width: 56px; height: 56px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--line);
  background: var(--white);
}
.ri-pro-attached-name {
  font-size: 11px; color: var(--ink2); line-height: 1.35;
  flex-basis: 100%;
}
.ri-ref-remove {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.85);
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.ri-tier-check--pro {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--white);
}

/* Composer */
.ri-composer {
  position: sticky; bottom: 0; z-index: 10;
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 12px 16px 14px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.04);
}
.ri-composer-top {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.ri-scene-hint {
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink2);
  background: var(--gold-bg);
  border: 1px solid var(--gold-line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.ri-scene-confirm-text {
  font-size: 14px;
  color: var(--ink2);
  line-height: 1.55;
  margin-bottom: 16px;
}
.ri-scene-confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.ri-scene-confirm-actions .ri-btn { flex: 1 1 auto; min-width: 140px; }
.ri-selected-refs {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg);
}
.ri-selected-refs-label {
  margin-bottom: 6px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-family: 'Geist Mono', monospace;
}
.ri-selected-refs-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ri-style-pro-link {
  background: none; border: none; padding: 0; margin: 0;
  font: inherit; font-weight: 600; color: var(--gold);
  cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
}
.ri-style-pro-link:hover { color: var(--gold2); }

.ri-style-chip {
  flex: 1; min-width: 160px;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink2);
}
.ri-style-chip-clear {
  border: none; background: var(--bg);
  width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; font-size: 14px; color: var(--muted);
}
.ri-composer-row { display: flex; gap: 10px; align-items: flex-end; }
.ri-composer-input {
  flex: 1; border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 12px;
  font-family: inherit; font-size: 13px;
  resize: none; min-height: 44px; background: var(--bg);
}
.ri-generate-btn {
  flex-shrink: 0;
  padding: 10px 20px; border: none;
  border-radius: var(--r-sm); background: var(--ink);
  color: var(--white); font-weight: 500;
  cursor: pointer; font-size: 13px;
  transition: opacity 0.12s, transform 0.12s;
}
.ri-generate-btn:hover:not(:disabled) { transform: scale(1.02); }
.ri-generate-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.ri-composer-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 8px;
  font-size: 10px;
  font-family: 'Geist Mono', monospace;
  color: var(--muted);
  line-height: 1.4;
}
.ri-credit-line { color: var(--muted); }
.ri-composer-foot-sep { opacity: 0.45; user-select: none; }
.ri-composer-link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--gold);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ri-composer-link-btn:hover { color: var(--gold2); }
.ri-composer-link {
  color: var(--gold);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ri-composer-link:hover { color: var(--gold2); }

.ri-tier-check {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px; color: var(--ink3); cursor: pointer;
}
.ri-tier-check--inline { max-width: 280px; }
.ri-tier-check-copy { display: flex; flex-direction: column; gap: 2px; }
.ri-tier-check-title { font-weight: 500; color: var(--ink2); }
.ri-tier-check-hint { font-size: 10px; color: var(--muted); line-height: 1.35; }

.ri-btn {
  border: 1px solid var(--line); background: var(--white);
  border-radius: 6px; padding: 5px 10px;
  font-size: 11px; cursor: pointer; color: var(--ink2);
  font-family: inherit;
}
.ri-btn--subtle:hover { border-color: var(--line2); }
.ri-btn--solid {
  border-color: var(--gold-line);
  background: var(--gold-bg);
  color: var(--gold);
  font-weight: 600;
}
.ri-btn--solid:hover { background: rgba(184,134,10,0.14); }
.ri-btn--gold {
  border-color: var(--gold-line); background: var(--gold-bg); color: var(--gold);
}

/* Modals — fixed to viewport so they stay centered while the gallery scrolls */
.ri-modal-overlay {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.ri-modal-overlay[hidden] { display: none; }
.ri-modal {
  background: var(--white); border-radius: 16px;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 420px;
}
.ri-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 0;
}
.ri-modal-title {
  font-family: 'Instrument Serif', serif;
  font-size: 20px; font-style: italic;
}
.ri-modal-close {
  border: 1px solid var(--line); background: var(--bg);
  width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; font-size: 16px; color: var(--muted);
}
.ri-modal-body { padding: 16px; }
.ri-upload-onboarding-modal {
  max-width: min(92vw, 720px);
}
.ri-upload-onboarding-kicker {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.ri-upload-onboarding-body {
  display: grid;
  gap: 14px;
}
.ri-upload-onboarding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.ri-upload-example-card {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg);
}
.ri-upload-example-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.ri-upload-example-card figcaption {
  padding: 10px;
  font-size: 12px;
  color: var(--ink2);
  line-height: 1.45;
}
.ri-upload-example-card strong {
  display: block;
  color: var(--ink);
  margin-bottom: 3px;
}
.ri-upload-onboarding-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 13px;
  color: var(--ink2);
}
.ri-inworld-btn {
  display: block; text-decoration: none;
  border: 1px solid var(--gold-line); background: var(--gold-bg);
  border-radius: var(--r-sm); padding: 14px; text-align: center;
}
.ri-iw-label { font-weight: 500; color: var(--gold); font-size: 13px; }
.ri-iw-sub { font-size: 10px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.ri-modal-note { font-size: 11px; color: var(--muted); text-align: center; margin-top: 12px; }

.ri-modal-image {
  max-width: min(92vw, 720px); max-height: 90vh;
  display: flex; flex-direction: column; align-items: stretch; gap: 12px;
  position: relative;
  background: var(--white);
  border-radius: var(--r);
  padding: 12px;
  box-shadow: var(--shadow-lg);
}
.ri-modal-image img {
  max-width: 100%; max-height: calc(90vh - 120px);
  object-fit: contain; border-radius: var(--r-sm);
  background: var(--bg2);
}
.ri-modal-actions {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  background: var(--white);
  padding: 10px 4px 4px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}
.ri-community-opt-in {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink2);
  cursor: pointer;
  user-select: none;
  padding: 0 4px;
}
.ri-community-opt-in[hidden] { display: none !important; }
.ri-community-opt-in input { width: 16px; height: 16px; accent-color: var(--gold); }
.ri-modal-close {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  background: var(--white);
}

.ri-toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--white);
  padding: 10px 16px; border-radius: 8px;
  font-size: 12px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 300;
  max-width: min(90vw, 420px); text-align: center;
}
.ri-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

body.pro-mode .ri-filter-bar-wrap,
body.pro-mode #featured-sections { display: none; }
body.pro-mode .ri-pro-panel { display: block !important; }
body.pro-mode .ri-composer-top { display: none; }
body.pro-mode .ri-scene-hint { display: none !important; }
body.pro-mode .ri-composer-input { display: none; }
body.pro-mode .ri-composer-row { justify-content: flex-end; }
body.pro-mode .ri-canvas { padding-bottom: 100px; }
body.category-view .ri-filter-bar-wrap,
body.category-view #featured-sections { display: none; }
body.category-view .ri-category-grid-view { display: grid !important; }

@media (max-width: 768px) {
  .reimagine-app.ready { grid-template-columns: 1fr; }
  .reimagine-sidebar {
    position: relative; height: auto; max-height: none;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .ri-card-row .style-card { flex: 0 0 42vw; min-width: 120px; }
  .ri-main-head {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .ri-main-head-side--left,
  .ri-main-head-side--right,
  .ri-main-head-center {
    justify-self: stretch;
    width: 100%;
  }
  .ri-main-head-side--right { justify-content: flex-end; }
  .ri-main-head-chips {
    width: 100%;
    flex-direction: column;
  }
  .ri-toolbar-chip--switch,
  .ri-toolbar-chip--referral {
    min-width: 0;
    width: 100%;
    max-width: none;
  }
  .ri-toolbar-chip--referral .ri-toolbar-chip-hint {
    white-space: normal;
  }
  .ri-main-toolbar { max-width: 100%; }
  .ri-toolbar-chip-hint { max-width: 108px; overflow: hidden; text-overflow: ellipsis; }
  .ri-toolbar-chip--switch .ri-toolbar-chip-hint { max-width: none; }
}
