
*, *::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);
  --accent:   #1a1816;
  --green:    #1a7a4a;
  --green-bg: rgba(26,122,74,0.08);
  --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;
}

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;
}

/* ── LAYOUT ── */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

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

.brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 24px; padding: 0 4px;
}
.brand--stacked {
  flex-direction: column; align-items: flex-start; gap: 6px;
}
.brand-logo {
  width: 44px; height: 44px; object-fit: contain; display: block;
  flex-shrink: 0;
}
.brand-wordmark {
  font-family: 'Geist Mono', monospace;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.14em; color: var(--ink);
  line-height: 1;
}
.brand-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--ink); display: flex;
  align-items: center; justify-content: center;
  font-size: 14px; color: var(--gold3); flex-shrink: 0;
}
.brand-title {
  font-family: 'Instrument Serif', serif;
  font-size: 17px; font-style: italic;
  color: var(--ink); letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 10px; color: var(--muted);
  letter-spacing: 0.04em; text-transform: uppercase;
  font-family: 'Geist Mono', monospace;
}

/* Credit balance */
.credit-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.cc-top {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 8px;
}
.cc-label { font-size: 11px; color: var(--muted); font-family: 'Geist Mono', monospace; letter-spacing: 0.04em; }
.cc-val {
  font-size: 28px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.04em; line-height: 1;
  font-family: 'Instrument Serif', serif;
}
.cc-sub { font-size: 11px; color: var(--muted); }
.cc-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
}
.cc-get-credits {
  font-size: 10px; font-weight: 500; color: var(--gold);
  text-decoration: none; padding: 4px 8px;
  border: 1px solid var(--gold-line); border-radius: 6px;
  background: var(--gold-bg); white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.cc-get-credits:hover {
  background: rgba(184,134,10,0.14); border-color: var(--gold2);
}
.cc-bar {
  height: 3px; background: var(--line);
  border-radius: 2px; margin: 8px 0;
  overflow: hidden;
}
.cc-bar-fill {
  height: 100%; background: var(--gold2);
  border-radius: 2px; transition: width 0.4s ease;
}

/* Buy button */
.btn-buy {
  width: 100%; padding: 9px;
  background: var(--ink); color: var(--white);
  border: none; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.13s;
  font-family: 'Geist', sans-serif;
  letter-spacing: 0.01em;
  margin-bottom: 20px;
}
.btn-buy:hover { background: var(--ink2); transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* Sidebar sections */
.sb-section { margin-bottom: 20px; }
.sb-label {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); font-family: 'Geist Mono', monospace;
  margin-bottom: 8px; padding: 0 4px;
}

/* Settings */
.setting-row {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 6px 4px; margin-bottom: 2px;
}
.setting-label { font-size: 12px; color: var(--ink2); }
.setting-val { font-size: 12px; color: var(--muted); font-family: 'Geist Mono', monospace; }
.setting-select {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px;
  font-size: 11px; font-family: 'Geist Mono', monospace;
  color: var(--ink); cursor: pointer; outline: none;
  appearance: none; -webkit-appearance: none;
  padding-right: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%239a9490'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center;
}

/* History list */
.history-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: min(480px, 42vh);
  overflow-y: auto;
  padding-right: 2px;
}
.history-load-more {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-family: inherit;
  color: var(--ink2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.history-load-more:hover { background: var(--bg2); }
.hist-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--r-sm);
  cursor: pointer; transition: background 0.1s;
  border: 1px solid transparent;
}
.hist-item:hover { background: var(--bg); border-color: var(--line); }
.hist-item:hover .hist-delete { opacity: 1; }
.hist-delete {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.12s, color 0.12s, background 0.12s, border-color 0.12s;
}
.hist-delete:hover {
  opacity: 1;
  color: #b83030;
  background: rgba(184, 48, 48, 0.1);
  border-color: rgba(184, 48, 48, 0.25);
}
.hist-thumb {
  width: 40px; height: 40px; border-radius: 6px;
  object-fit: cover; background: var(--bg2); flex-shrink: 0;
  border: 1px solid var(--line);
}
.hist-info { flex: 1; min-width: 0; }
.hist-prompt {
  font-size: 11px; color: var(--ink2); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.hist-meta { font-size: 10px; color: var(--muted); font-family: 'Geist Mono', monospace; }

.sb-spacer { flex: 1; }

/* Settings hidden — generations use server defaults */
.sb-settings-panel { display: none !important; }

.sb-footer-stack {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sb-user-welcome { padding: 0 4px; }
.sb-welcome-label {
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); font-family: 'Geist Mono', monospace;
  margin-bottom: 4px;
}
.sb-display-name {
  font-family: 'Instrument Serif', serif;
  font-size: 18px; font-style: italic;
  color: var(--ink); line-height: 1.25;
  word-break: break-word;
}
.sb-footer-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0 2px;
}
.sb-logout-btn {
  width: 100%;
  padding: 9px 12px;
  background: var(--white);
  color: var(--ink2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: 'Geist', sans-serif;
  transition: background 0.12s, border-color 0.12s;
}
.sb-logout-btn:hover {
  background: var(--bg);
  border-color: var(--line2);
}
.sb-playground-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 12px;
  background: #0a0a0a;
  color: #fafaf8;
  border: 1px solid #0a0a0a;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  font-family: 'Geist', sans-serif;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-md);
  transition: transform 0.12s, background 0.12s, box-shadow 0.12s;
}
.sb-playground-btn:hover {
  background: #000;
  border-color: #000;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.22);
}

/* ── MAIN ── */
.main {
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* Canvas / output area */
.canvas-area {
  flex: 1; display: flex; flex-direction: column;
  align-items: stretch; justify-content: flex-start;
  padding: 24px 48px 16px; position: relative;
  overflow: hidden;
}
.canvas-area.canvas-loading {
  justify-content: center;
  align-items: center;
}
.canvas-area.has-result {
  align-items: center;
  justify-content: flex-start;
  padding-top: 20px;
  overflow-y: auto;
}

/* Gallery homepage */
.gallery-home {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0; width: 100%; max-width: 960px;
  margin: 0 auto; animation: fadeUp 0.35s ease;
}
.gallery-home[hidden], .pro-panel[hidden] { display: none !important; }

.gallery-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; flex-shrink: 0;
}
.gallery-title {
  font-family: 'Instrument Serif', serif;
  font-size: 26px; font-style: italic;
  color: var(--ink); letter-spacing: -0.02em; line-height: 1.2;
}
.gallery-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.pro-toggle {
  flex-shrink: 0;
  padding: 7px 14px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--white);
  font-size: 12px; font-weight: 500; color: var(--ink2);
  cursor: pointer; font-family: 'Geist', sans-serif;
  transition: all 0.12s;
}
.pro-toggle[aria-pressed="true"] {
  border-color: var(--ink); background: var(--ink); color: var(--white);
}

.gallery-upload-cta {
  text-align: center; padding: 20px 16px;
  background: var(--gold-bg); border: 1px solid var(--gold-line);
  border-radius: var(--r); margin-bottom: 16px; flex-shrink: 0;
}
.gallery-upload-cta[hidden] { display: none !important; }
.upload-cta-title {
  font-size: 14px; font-weight: 500; color: var(--ink);
  margin-bottom: 6px; line-height: 1.5;
}
.upload-cta-hint {
  font-size: 11px; color: var(--muted); line-height: 1.6;
  margin-bottom: 12px; max-width: 420px; margin-left: auto; margin-right: auto;
}
.upload-cta-btn {
  padding: 9px 18px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--white);
  border: none; font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: 'Geist', sans-serif;
}
.upload-cta-btn:hover { background: var(--ink2); }
.upload-cta-actions {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 10px 14px;
}
.upload-cta-alt {
  padding: 0; border: none; background: transparent;
  font-size: 12px; color: var(--muted); cursor: pointer;
  font-family: 'Geist', sans-serif; text-decoration: underline;
  text-underline-offset: 2px;
}
.upload-cta-alt:hover { color: var(--ink2); }

.base-strip-wrap {
  margin-bottom: 14px; flex-shrink: 0;
}
.base-strip-wrap[hidden] { display: none !important; }
.base-strip-caption {
  font-size: 10px; color: var(--muted); margin-bottom: 6px; line-height: 1.5;
}
.base-strip {
  display: flex; align-items: center; gap: 10px;
  overflow-x: auto; padding-bottom: 4px;
}
.base-thumb {
  width: 52px; height: 68px; border-radius: 8px;
  object-fit: cover; border: 2px solid transparent;
  cursor: pointer; flex-shrink: 0; background: var(--bg2);
  transition: border-color 0.12s;
}
.base-thumb.active { border-color: var(--gold2); box-shadow: 0 0 0 2px var(--gold-bg); }
.base-thumb-label {
  font-size: 9px; font-family: 'Geist Mono', monospace;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em;
  text-align: center; margin-top: 2px;
}
.base-thumb-wrap {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center;
}
.base-add-btn {
  flex-shrink: 0; padding: 8px 12px; border-radius: 8px;
  border: 1px dashed var(--line2); background: var(--white);
  font-size: 11px; color: var(--ink2); cursor: pointer;
  font-family: 'Geist', sans-serif; align-self: center;
}
.base-add-btn:hover { border-color: var(--gold-line); color: var(--gold); }
.base-add-btn--subtle {
  border-style: solid; border-color: transparent; background: transparent;
  color: var(--muted); text-decoration: underline; text-underline-offset: 2px;
  padding: 8px 6px;
}
.base-add-btn--subtle:hover { border-color: transparent; color: var(--ink2); }
.base-thumb-placeholder {
  width: 100%; height: 100%; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2); color: var(--muted);
  font-size: 9px; font-family: 'Geist Mono', monospace;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.att-item--loading .base-thumb-placeholder::after {
  content: ''; width: 14px; height: 14px; margin-left: 4px;
  border: 2px solid var(--line2); border-top-color: var(--gold2);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.base-thumb-wrap--removable { position: relative; }
.base-att-item {
  width: 52px; height: 68px;
}
.base-att-item .base-thumb {
  width: 100%; height: 100%; border-radius: 8px;
}
.base-att-item .att-remove {
  width: 20px; height: 20px; font-size: 11px;
  top: -5px; right: -5px;
}

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 7px;
  margin-bottom: 14px; flex-shrink: 0;
}
.filter-bar-categories {
  display: contents;
}

  padding: 6px 12px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--white);
  font-size: 11px; color: var(--ink2); cursor: pointer;
  font-family: 'Geist', sans-serif; transition: all 0.12s;
}
.filter-pill:hover { border-color: var(--line2); background: var(--bg); }
.filter-pill.active {
  border-color: var(--ink); background: var(--ink); color: var(--white);
}
.filter-pill-adult {
  margin-left: auto; border-color: var(--line2);
}
.filter-pill-adult[aria-pressed="true"] {
  border-color: #8b3a3a; background: var(--red-bg); color: var(--red);
}

.style-gallery {
  flex: 1; min-height: 0; overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px; padding-bottom: 12px;
  align-content: start;
}
.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, box-shadow 0.12s;
  padding: 0; font-family: inherit;
}
.style-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-md);
  border-color: var(--gold-line);
}
.style-card.selected {
  border-color: var(--gold2); box-shadow: 0 0 0 3px var(--gold-bg);
}
.style-card-media {
  aspect-ratio: 3 / 4; width: 100%;
  background: linear-gradient(145deg, var(--bg2) 0%, var(--bg3) 55%, var(--gold-bg) 100%);
  position: relative; overflow: hidden;
}
.style-card-media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.style-card-placeholder-title {
  position: absolute; inset: 0; display: flex;
  align-items: flex-end; padding: 10px;
  font-family: 'Instrument Serif', serif;
  font-size: 15px; font-style: italic; color: var(--ink);
  background: linear-gradient(transparent 40%, rgba(245,243,240,0.92));
  line-height: 1.25;
}
.style-card-body { padding: 8px 10px 10px; }
.style-card-title {
  font-size: 12px; font-weight: 500; color: var(--ink);
  line-height: 1.3; margin-bottom: 3px;
  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;
}

.style-selected-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 14px;
  background: var(--gold-bg); border: 1px solid var(--gold-line);
  border-radius: var(--r-sm); margin-top: 8px; flex-shrink: 0;
}
.style-selected-banner[hidden] { display: none !important; }
.style-selected-name {
  font-size: 13px; font-weight: 500; color: var(--ink);
  line-height: 1.4;
}
.style-selected-generate {
  flex-shrink: 0; padding: 9px 18px; border-radius: var(--r-sm);
  background: var(--gold); color: var(--white); border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: 'Geist', sans-serif;
}
.style-selected-generate:hover { background: var(--gold2); }

.pro-panel {
  flex: 1; display: flex; flex-direction: column;
  width: 100%; max-width: 720px; margin: 0 auto;
  min-height: 0;
}
.pro-panel-head { margin-bottom: 12px; flex-shrink: 0; }
.pro-back-btn {
  padding: 8px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--white);
  font-size: 12px; cursor: pointer; color: var(--ink2);
  font-family: 'Geist', sans-serif;
}
.pro-back-btn:hover { background: var(--bg); }
.pro-composer { flex: 0 0 auto; min-height: 0; width: 100%; }
.pro-prompt-box {
  display: flex; flex-direction: column;
  max-height: 420px;
}
.pro-prompt-box .prompt-input-wrap { flex: 0 1 auto; }
.pro-prompt-box .prompt-input { min-height: 100px; max-height: 200px; }
.pro-panel.has-result { display: none !important; }

.gallery-composer { position: sticky; bottom: 0; z-index: 10; background: var(--bg); }
.prompt-box.collapsed .composer-expandable { display: none; }
.prompt-box.collapsed:focus-within .composer-expandable,
.prompt-box.collapsed.expanded .composer-expandable,
.prompt-box.collapsed.gallery-ready .composer-expandable { display: flex; }
.prompt-box.collapsed.gallery-ready .composer-expandable .pa-btn { display: none; }
.prompt-box.collapsed:focus-within .composer-expandable .pa-btn,
.prompt-box.collapsed.expanded .composer-expandable .pa-btn { display: inline-flex; }
.prompt-box.collapsed .prompt-input { min-height: 20px; }
body.pro-mode .gallery-composer { display: none; }
body.pro-mode .gallery-home { display: none !important; }
body.pro-mode .pro-panel { display: flex !important; }

/* Result display */
.result-display {
  display: none; width: 100%; max-width: 640px;
  margin: 0 auto; align-self: center;
  animation: fadeUp 0.3s ease;
}
.result-display.show { display: block; }
.result-img-wrap {
  border-radius: var(--r); overflow: hidden;
  box-shadow: var(--shadow-lg); margin-bottom: 14px;
  background: var(--bg2); position: relative;
  cursor: zoom-in;
}
.result-img-wrap img {
  width: 100%; display: block;
  max-height: 560px; object-fit: contain;
}
.result-lightbox-overlay {
  background: rgba(0,0,0,0.88); backdrop-filter: blur(6px);
}
.result-lightbox-overlay .result-lightbox {
  position: relative; max-width: min(96vw, 1200px); max-height: 92vh;
  margin: auto; display: flex; align-items: center; justify-content: center;
}
.result-lightbox-overlay .result-lightbox img {
  max-width: 100%; max-height: 92vh; width: auto; height: auto;
  object-fit: contain; border-radius: var(--r);
  box-shadow: var(--shadow-lg);
}
.result-lightbox-close {
  position: absolute; top: -12px; right: -12px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--white);
  color: var(--ink2); font-size: 22px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
}
.result-lightbox-close:hover { color: var(--ink); border-color: var(--line2); }
.result-badge {
  position: absolute; top: 12px; left: 12px;
  padding: 4px 10px; border-radius: 6px;
  font-size: 10px; font-family: 'Geist Mono', monospace;
  letter-spacing: 0.06em; text-transform: uppercase;
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.5);
  color: var(--ink2);
}
.result-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  align-items: center;
}
.ra-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 14px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.12s;
  font-family: 'Geist', sans-serif;
  text-decoration: none; border: 1px solid;
}
.ra-primary {
  background: var(--ink); color: var(--white);
  border-color: var(--ink);
}
.ra-primary:hover { background: var(--ink2); }
.ra-secondary {
  background: var(--white); color: var(--ink2);
  border-color: var(--line); box-shadow: var(--shadow);
}
.ra-secondary:hover { border-color: var(--line2); background: var(--bg); }
.ra-gold {
  background: var(--gold-bg); color: var(--gold);
  border-color: var(--gold-line);
}
.ra-gold:hover { background: rgba(184,134,10,0.14); }
.result-prompt-label {
  margin-left: auto; font-size: 11px; color: var(--muted);
  font-style: italic; max-width: 300px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Loading */
.loading-display {
  display: none; text-align: center;
  max-width: 320px; width: 100%;
  margin: 0 auto;
}
.loading-display.show { display: block; animation: fadeUp 0.2s ease; }
.canvas-area.canvas-loading .loading-display.show {
  flex-shrink: 0;
}
.loading-ring {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title {
  font-family: 'Instrument Serif', serif;
  font-size: 20px; font-style: italic;
  color: var(--ink); margin-bottom: 6px;
}
.loading-sub { font-size: 12px; color: var(--muted); }
.loading-progress {
  width: 100%; height: 2px; background: var(--line);
  border-radius: 2px; overflow: hidden; margin-top: 16px;
}
.loading-bar {
  height: 100%; background: var(--ink);
  border-radius: 2px;
  animation: progress 25s ease-out forwards;
  width: 0;
}
@keyframes progress { 0%{width:0} 80%{width:85%} 100%{width:90%} }

/* ── PROMPT AREA ── */
.prompt-area {
  padding: 0 48px 32px;
  flex-shrink: 0;
}

.prompt-box {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.prompt-box:focus-within {
  border-color: var(--line2);
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

/* Attachment preview */
.attachment-preview {
  display: none; padding: 12px 14px 0;
}
.attachment-preview.show {
  display: flex; gap: 8px; flex-wrap: nowrap;
  overflow-x: auto; padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.att-item {
  position: relative; width: 72px; height: 72px;
}
.att-item img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line);
}
.att-remove {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: var(--white);
  border: 2px solid var(--white); cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  font-size: 12px; line-height: 1; font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 2;
}
.att-remove:hover { background: #8b3a3a; }
.att-badge {
  position: absolute; bottom: 4px; left: 4px;
  font-size: 8px; font-family: 'Geist Mono', monospace;
  background: rgba(0,0,0,0.65); color: white;
  padding: 1px 4px; border-radius: 3px;
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* UUID attachment */
.uuid-att {
  display: none; padding: 8px 14px 0;
}
.uuid-att.show { display: flex; align-items: center; gap: 8px; }
.uuid-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 11px; font-family: 'Geist Mono', monospace;
  color: var(--ink2);
}
.uuid-chip-remove, .att-remove-flat {
  cursor: pointer; color: var(--muted); font-size: 12px;
  line-height: 1; transition: color 0.1s;
  border: none; background: none; padding: 0 2px; font-family: inherit;
}
.uuid-chip-remove:hover, .att-remove-flat:hover { color: var(--red); }

.attach-chip-inline { flex-shrink: 0; max-width: 100%; }
.result-chip { align-self: center; }

/* Textarea */
.prompt-input-wrap { padding: 12px 14px 6px; }
.prompt-input {
  width: 100%; border: none; outline: none;
  font-size: 15px; font-family: 'Geist', sans-serif;
  color: var(--ink); resize: none; background: transparent;
  line-height: 1.6; min-height: 44px; max-height: 160px;
}
.prompt-input::placeholder { color: var(--muted); }

.prompt-char-hint {
  margin-top: 4px;
  font-size: 11px;
  font-family: 'Geist Mono', monospace;
  color: var(--muted);
  text-align: right;
}
.prompt-char-hint.over-limit { color: var(--red); }

.prompt-tier-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 0 14px 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink3);
  cursor: pointer;
}
.prompt-tier-check input { margin-top: 2px; flex-shrink: 0; }
.prompt-tier-check-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.prompt-tier-check-title { font-weight: 500; color: var(--ink2); }
.prompt-tier-check-hint {
  font-size: 11px;
  color: var(--muted);
  font-family: 'Geist Mono', monospace;
  line-height: 1.4;
}

/* Prompt actions bar */
.prompt-actions {
  display: flex; align-items: center;
  padding: 8px 10px 10px; gap: 6px;
}
.pa-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 8px;
  font-size: 12px; color: var(--ink3);
  background: none; border: 1px solid transparent;
  cursor: pointer; transition: all 0.12s;
  font-family: 'Geist', sans-serif;
}
.pa-btn:hover { background: var(--bg); border-color: var(--line); color: var(--ink); }
.pa-btn--subtle {
  border-color: transparent; background: transparent; color: var(--muted);
  font-weight: 400; padding: 5px 8px;
}
.pa-btn--subtle:hover { background: transparent; border-color: transparent; color: var(--ink2); }
.pa-btn--example {
  font-size: 10px;
}
.pa-btn svg { width: 14px; height: 14px; }
.uuid-modal-hint {
  font-size: 11px; color: var(--muted); line-height: 1.5; margin: 10px 0 12px;
}
.att-item--loading img { opacity: 0.45; }
.att-sl-badge {
  font-size: 8px; letter-spacing: 0.06em; text-transform: uppercase;
}
.pa-spacer { flex: 1; }

.transform-strength-wrap {
  display: flex; align-items: center; min-width: 0;
}
.transform-strength-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted); white-space: nowrap;
  font-family: 'Geist Mono', monospace;
}
.transform-strength-label input[type="range"] {
  width: 88px; max-width: 28vw; accent-color: var(--gold2, #c89820);
}
.transform-strength-val {
  min-width: 2.2rem; text-align: right; color: var(--ink2);
}

/* Mode indicator */
.mode-indicator {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 6px;
  font-size: 11px; font-family: 'Geist Mono', monospace;
  background: var(--bg); border: 1px solid var(--line);
  color: var(--muted); transition: all 0.2s;
}
.mode-indicator.transform {
  background: var(--gold-bg); border-color: var(--gold-line);
  color: var(--gold);
}
.mode-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted); transition: background 0.2s;
}
.mode-indicator.transform .mode-dot { background: var(--gold2); }

/* Send button */
.send-btn {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--ink); border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.13s;
  flex-shrink: 0;
  color: var(--white);
  font-family: 'Geist', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.send-btn--label {
  width: auto;
  min-width: 88px;
  height: 34px;
  padding: 0 14px;
}
.send-btn:hover { background: var(--ink2); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.send-btn svg { width: 15px; height: 15px; fill: white; }
.prompt-box.gallery-ready { border-color: var(--gold-line); }

/* File input hidden */
#file-input { display: none; }
#uuid-input-hidden { display: none; }

/* ── MODALS ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white); border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px;
  transform: translateY(8px); transition: transform 0.2s;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-head {
  padding: 20px 20px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.modal-title {
  font-family: 'Instrument Serif', serif;
  font-size: 20px; font-style: italic; color: var(--ink);
}
.modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line);
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 14px; color: var(--muted);
  transition: all 0.1s;
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 16px 20px 20px; }

.upload-example-link {
  margin-top: 8px;
  border: none;
  background: transparent;
  color: var(--gold);
  font-size: 11px;
  font-family: 'Geist Mono', monospace;
  cursor: pointer;
  text-decoration: underline;
}
.upload-onboarding-modal {
  max-width: min(92vw, 720px);
}
.upload-onboarding-kicker {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.upload-onboarding-body {
  display: grid;
  gap: 14px;
}
.upload-onboarding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.upload-example-card {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg);
}
.upload-example-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.upload-example-card figcaption {
  padding: 10px;
  font-size: 12px;
  color: var(--ink2);
  line-height: 1.45;
}
.upload-example-card strong {
  display: block;
  color: var(--ink);
  margin-bottom: 3px;
}
.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);
}
.upload-target-highlight {
  animation: uploadTargetPulse 1.6s ease;
}
@keyframes uploadTargetPulse {
  0%, 100% { box-shadow: none; }
  20%, 70% { box-shadow: 0 0 0 4px rgba(212,160,32,0.22); }
}

/* UUID modal */
.uuid-field {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.uuid-field input {
  flex: 1; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: 13px;
  font-family: 'Geist Mono', monospace; color: var(--ink);
  outline: none; transition: border-color 0.12s;
}
.uuid-field input:focus { border-color: var(--line2); }
.uuid-preview-area {
  border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--line); display: none;
  margin-bottom: 12px; background: var(--bg);
}
.uuid-preview-area.show { display: block; }
.uuid-preview-area img { width: 100%; display: block; max-height: 200px; object-fit: contain; }
.uuid-note { font-size: 11px; color: var(--muted); line-height: 1.6; }

/* Buy credits modal */
.credit-packs { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 16px; }
.pack {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 14px 12px; text-align: center; cursor: pointer;
  transition: all 0.13s;
}
.pack:hover { border-color: var(--line2); box-shadow: var(--shadow); }
.pack.best {
  border-color: var(--ink); background: var(--ink);
}
.pack-credits {
  font-family: 'Instrument Serif', serif;
  font-size: 30px; font-style: italic;
  color: var(--ink); line-height: 1; margin-bottom: 3px;
}
.pack.best .pack-credits { color: var(--white); }
.pack-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-family: 'Geist Mono', monospace; margin-bottom: 8px; }
.pack.best .pack-label { color: rgba(255,255,255,0.5); }
.pack-price { font-size: 13px; font-weight: 600; color: var(--ink); }
.pack.best .pack-price { color: var(--white); }
.pack-per { font-size: 10px; color: var(--muted); font-family: 'Geist Mono', monospace; }
.pack.best .pack-per { color: rgba(255,255,255,0.5); }

.inworld-btn {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, #1a1208, #2a1c08);
  border: 1px solid rgba(200,152,32,0.4);
  border-radius: var(--r-sm); cursor: pointer;
  transition: all 0.13s; margin-bottom: 10px;
  text-align: center; text-decoration: none; display: block;
}
.inworld-btn:hover { border-color: rgba(200,152,32,0.7); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(200,152,32,0.2); }
.iw-label {
  font-family: 'Instrument Serif', serif;
  font-size: 15px; font-style: italic;
  color: #f0bc38; margin-bottom: 2px;
}
.iw-sub { font-size: 11px; color: rgba(240,188,56,0.6); font-family: 'Geist Mono', monospace; letter-spacing: 0.04em; }

.modal-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0;
}
.modal-divider::before, .modal-divider::after { content:''; flex:1; height:1px; background:var(--line); }
.modal-divider span { font-size: 11px; color: var(--muted); white-space: nowrap; font-family: 'Geist Mono', monospace; }

/* ── ANIMATIONS ── */
@keyframes fadeUp { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--ink); color: var(--white);
  padding: 9px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0;
  transition: all 0.2s; pointer-events: none; z-index: 200;
  white-space: nowrap; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); white-space: normal; max-width: min(420px, 92vw); text-align: center; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 3px; }

/* ── DRAG OVER ── */
.prompt-box.drag-over { border-color: var(--gold2); box-shadow: 0 0 0 3px var(--gold-bg); }

.gate-screen {
  display: flex;
  align-items: center; justify-content: center;
  min-height: 100vh;
  flex-direction: column;
  padding: 48px 16px;
  text-align: center;
}
.gate-screen.done { display: none; }

#imagine-root { display: none; }
#imagine-root.ready { display: grid; min-height: 100vh; }

@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; height: auto; max-height: none;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .canvas-area { padding: 16px 16px 8px; }
  .prompt-area { padding: 0 16px 16px; }
  .style-gallery { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .filter-pill-adult { margin-left: 0; }
}

/* Beta-specific */
.beta-banner {
  display: none;
  background: var(--gold-bg);
  border-bottom: 1px solid var(--gold-line);
  padding: 8px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--ink2);
}
.beta-banner a { color: var(--gold); font-weight: 500; }
.beta-banner .beta-legacy-link { color: var(--ink2); font-weight: 500; text-decoration: underline; }
.beta-banner .beta-legacy-link:hover { color: var(--ink); }
body.beta-ready .beta-banner { display: block; }

.gate-title {
  font-family: 'Instrument Serif', serif;
  font-size: 22px;
  font-style: italic;
  color: var(--ink);
  margin-bottom: 12px;
}
.gate-sub {
  font-size: 13px;
  color: var(--muted);
  max-width: 360px;
  line-height: 1.6;
}

.btn-feedback-toggle {
  width: 100%;
  padding: 9px;
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid var(--gold-line);
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 16px;
  font-family: 'Geist', sans-serif;
}
.btn-feedback-toggle:hover { background: rgba(184,134,10,0.14); }

.feedback-widget {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px;
  margin-bottom: 20px;
}
.feedback-types { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.feedback-type-btn {
  padding: 5px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--white);
  font-size: 11px;
  cursor: pointer;
  color: var(--ink2);
}
.feedback-type-btn.active {
  border-color: var(--gold-line);
  background: var(--gold-bg);
  color: var(--gold);
}
.feedback-textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px;
  font-size: 12px;
  font-family: 'Geist', sans-serif;
  resize: vertical;
  margin-bottom: 8px;
}
.btn-feedback-submit {
  width: 100%;
  padding: 8px;
  background: var(--ink);
  color: var(--white);
  border: none;
  border-radius: var(--r-sm);
  font-size: 12px;
  cursor: pointer;
}
.feedback-status {
  font-size: 11px; color: var(--gold); line-height: 1.5;
  margin-bottom: 8px; display: none;
}
.feedback-status.show { display: block; }
.feedback-recent { margin-top: 10px; font-size: 10px; color: var(--muted); line-height: 1.5; }
.btn-feedback-submit:disabled { opacity: 0.45; cursor: not-allowed; }


.iteration-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 12px;
  margin-bottom: 4px;
}
.iteration-strip:empty { display: none; }
.iter-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--bg2);
}
.iter-thumb.active { border-color: var(--gold2); }

.refine-panel {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.modal-body input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: 'Geist Mono', monospace;
  margin-bottom: 10px;
}

.credit-foot {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-top: 10px;
  font-family: 'Geist Mono', monospace;
}

#imagine-root.ready { display: grid; }

.result-share-overlay {
  z-index: 200;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
}
.result-share-modal {
  max-width: min(92vw, 680px);
  max-height: 92vh;
  overflow: auto;
}
.result-share-body {
  padding-top: 8px;
}
.result-share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}
body.result-share-open {
  overflow: hidden;
}
.result-landing-img-wrap {
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--bg2);
}
.result-landing-img-wrap img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}
