/* ========================================================================
   GPT Image Studio — light "atelier" theme
   Warm paper, deep ink text, champagne-gold accent, Fraunces + IBM Plex Mono.
   Built for legibility: high-contrast ink on paper, gold used sparingly.
   ===================================================================== */

:root {
  --bg:       #efe9df;   /* warm paper (page)        */
  --bg-2:     #ffffff;   /* panels / cards           */
  --bg-3:     #f7f3ec;   /* inputs / raised surfaces */
  --bg-4:     #e9e1d3;   /* tracks / chip wells      */
  --line:     rgba(40, 30, 15, 0.14);
  --line-2:   rgba(40, 30, 15, 0.10);
  --ink:      #000000;   /* primary text — black       */
  --ink-2:    #1c1c1c;   /* secondary text — near-black */
  --ink-3:    #3a3a3a;   /* muted text — dark grey      */
  --amber:    #2c4b86;   /* accent — deep navy        */
  --amber-2:  #3f63a8;   /* bright navy               */
  --amber-deep: #1f3a6b; /* navy for small labels     */
  --red:      #bf4a2e;
  --glow:     rgba(44, 75, 134, 0.28);
  --on-amber: #ffffff;   /* text on navy fills        */
  --radius:   14px;
  --radius-sm: 9px;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --serif: "Fraunces", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over any explicit `display` we set on
   overlays (lightbox, modals, drawer). */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--mono);
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: 0.01em;
}

/* Atmosphere mesh on its own fixed GPU layer — stays put with no per-frame repaint */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; transform: translateZ(0);
  background:
    radial-gradient(820px 480px at 6% -8%, rgba(44,75,134,0.11), transparent 60%),
    radial-gradient(1000px 560px at 104% 2%, rgba(63,99,168,0.08), transparent 55%),
    radial-gradient(760px 760px at 82% 118%, rgba(44,75,134,0.06), transparent 60%);
}

/* Faint paper grain — fixed, own layer, no blend mode (cheap during scroll) */
.grain {
  position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  opacity: 0.035; transform: translateZ(0);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--ink); color: var(--bg); }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; letter-spacing: -0.015em; font-variation-settings: "opsz" 44; }

/* ===================== Top bar ===================== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem 1.6rem;
  background: linear-gradient(180deg, rgba(244,240,232,0.98), rgba(244,240,232,0.92));
  backdrop-filter: blur(7px) saturate(1.15);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,0.5), 0 10px 30px -28px rgba(20,26,46,0.5);
}
.brand { display: flex; align-items: center; gap: 0.85rem; }
.aperture {
  width: 34px; height: 34px; border-radius: 50%; position: relative; flex: none;
  background: conic-gradient(from 20deg, var(--amber-deep), var(--amber) 40%, var(--amber-2) 50%, var(--amber-deep) 75%, var(--amber-deep));
  box-shadow: 0 2px 10px -2px var(--glow), inset 0 0 0 3px var(--bg-2);
}
.aperture::after { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--bg-2); box-shadow: inset 0 0 5px rgba(40,30,15,0.25); }
.wordmark { font-size: 1.45rem; line-height: 1; font-variation-settings: "opsz" 60; letter-spacing: -0.02em; }
.kicker { display: block; font-size: 0.66rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-3); margin-top: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.readout { font-size: 0.68rem; color: var(--amber-deep); letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; }

/* ===================== Layout ===================== */
.app {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 330px 1fr; gap: 1.4rem;
  max-width: 1500px; margin: 0 auto; padding: 1.6rem; align-items: start;
}
.sidebar { position: sticky; top: 86px; display: flex; flex-direction: column; gap: 1.4rem; max-height: calc(100vh - 100px); overflow-y: auto; padding-right: 4px; }
.main { display: flex; flex-direction: column; gap: 1.4rem; min-width: 0; }

/* ===================== Panels ===================== */
.panel {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 1.15rem 1.2rem 1.3rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 20px 46px -32px rgba(20,26,46,0.45), 0 2px 7px -4px rgba(20,26,46,0.08);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1rem; padding-bottom: 0.7rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1.18rem; }
.count { font-size: 0.66rem; color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 100px; padding: 2px 9px; letter-spacing: 0.1em; }
.hint { font-size: 0.7rem; line-height: 1.5; color: var(--ink-3); margin: 0.85rem 0 0; }
.hint em { color: var(--amber-deep); font-style: normal; }
.empty { font-size: 0.78rem; color: var(--ink-3); padding: 1.6rem 0.3rem; text-align: center; line-height: 1.6; }

.reveal { opacity: 0; transform: translateY(14px); animation: reveal 0.7s var(--ease) forwards; animation-delay: calc(var(--d, 1) * 0.08s); }
@keyframes reveal { to { opacity: 1; transform: none; } }

/* ===================== Buttons ===================== */
.btn {
  font-family: var(--mono); font-size: 0.78rem; font-weight: 500; letter-spacing: 0.05em; color: var(--ink);
  border: 1px solid var(--line); background: var(--bg-3);
  padding: 0.6rem 1rem; border-radius: var(--radius-sm); cursor: pointer;
  transition: all 0.2s var(--ease); display: inline-flex; align-items: center; gap: 0.5rem;
}
.btn:hover { border-color: var(--amber); color: var(--amber-deep); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: transparent; }
.btn.tiny { font-size: 0.68rem; padding: 0.4rem 0.7rem; }
.btn.full-btn { width: 100%; justify-content: center; }
.btn.primary {
  background: linear-gradient(180deg, #2c2c2c, #080808); color: #fff;
  border-color: #000; font-weight: 600;
  box-shadow: 0 12px 26px -14px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.14);
}
.btn.primary:hover { color: #fff; filter: brightness(1.18); transform: translateY(-1px); box-shadow: 0 16px 32px -14px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.18); }
.btn.tiny.primary { box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; filter: grayscale(0.3); }
.generate { justify-content: center; font-size: 0.92rem; padding: 0.95rem; text-transform: uppercase; letter-spacing: 0.16em; }
.generate-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber-2); }
.btn.is-loading .generate-dot { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.2; transform: scale(0.6); } }

.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--ink-2); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 0.85rem; transition: all 0.2s var(--ease); display: grid; place-items: center; }
.icon-btn:hover { color: var(--amber-deep); border-color: var(--amber); transform: rotate(90deg); }

/* ===================== Form controls ===================== */
textarea, select, input[type="text"], input[type="file"] {
  width: 100%; font-family: var(--mono); font-size: 0.82rem; color: var(--ink);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem; transition: border-color 0.2s, box-shadow 0.2s; resize: vertical;
}
textarea:focus, select:focus, input[type="text"]:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(44,75,134,0.16); }
textarea { line-height: 1.55; min-height: 84px; }
select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231f3a6b' fill='none' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.8rem center; padding-right: 2rem;
}

.prompt-wrap { position: relative; }
.prompt-tools { display: flex; align-items: center; justify-content: space-between; margin-top: 0.7rem; }

.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 0.9rem 1rem; margin-top: 1.2rem; }
.control { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
.control label { font-size: 0.62rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); }

.seg { display: flex; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.seg-btn { flex: 1; text-align: center; font-size: 0.72rem; padding: 0.42rem 0.2rem; border-radius: 6px; cursor: pointer; color: var(--ink-2); transition: all 0.18s var(--ease); border: none; background: transparent; text-transform: capitalize; letter-spacing: 0.04em; }
.seg-btn:hover { color: var(--amber-deep); }
.seg-btn.active { background: linear-gradient(180deg, var(--amber-2), var(--amber)); color: var(--on-amber); font-weight: 600; box-shadow: 0 3px 10px -5px var(--glow); }

.switch { display: inline-flex; align-items: center; gap: 0.55rem; cursor: pointer; user-select: none; }
.switch input { display: none; }
.slider { width: 38px; height: 21px; border-radius: 100px; background: var(--bg-4); border: 1px solid var(--line-2); position: relative; transition: all 0.25s var(--ease); flex: none; }
.slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--ink-3); transition: all 0.25s var(--ease); }
.switch input:checked + .slider { background: linear-gradient(180deg, var(--amber-2), var(--amber)); border-color: var(--amber); }
.switch input:checked + .slider::after { left: 19px; background: var(--on-amber); }
.switch-label { font-size: 0.7rem; color: var(--ink-2); letter-spacing: 0.06em; }

/* ===================== Products ===================== */
.product-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.7rem; }
.product { border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--bg-3); transition: all 0.18s var(--ease); }
.product.selected { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber), 0 8px 20px -14px var(--glow); background: #fcf8f0; }
.product-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 0.7rem; cursor: pointer; }
.product-check { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: 0.58rem; color: transparent; flex: none; }
.product.selected .product-check { background: var(--amber); border-color: var(--amber); color: var(--on-amber); }
.product-name { flex: 1; font-size: 0.76rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-meta { font-size: 0.6rem; color: var(--ink-3); letter-spacing: 0.06em; }
.product-thumbs { display: flex; flex-wrap: wrap; gap: 0.3rem; padding: 0 0.7rem 0.7rem; }
.pthumb { position: relative; width: 42px; height: 42px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line-2); background: var(--bg-2); }
.pthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pthumb-del { position: absolute; top: 1px; right: 1px; width: 15px; height: 15px; border-radius: 50%; background: rgba(255,255,255,0.88); border: none; color: var(--red); font-size: 0.55rem; cursor: pointer; display: none; place-items: center; }
.pthumb:hover .pthumb-del { display: grid; }
.pthumb.add { display: grid; place-items: center; cursor: pointer; color: var(--amber-deep); font-size: 1rem; border-style: dashed; }
.pthumb.add:hover { border-color: var(--amber); color: var(--amber); }

/* ===================== References ===================== */
.uploader { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 1.1rem; border: 1px dashed var(--line); border-radius: var(--radius-sm); color: var(--ink-2); font-size: 0.74rem; cursor: pointer; text-align: center; transition: all 0.2s var(--ease); background: var(--bg-3); }
.uploader:hover, .uploader.drag { border-color: var(--amber); color: var(--amber-deep); background: #faf5eb; }
.uploader.small { padding: 0.7rem; font-size: 0.72rem; }
.uploader-plus { font-size: 1.3rem; line-height: 1; color: var(--amber); }
.ref-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.55rem; margin-top: 0.9rem; }
.ref { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line-2); cursor: pointer; transition: all 0.2s var(--ease); background: var(--bg-2); }
.ref img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s var(--ease); }
.ref:hover img { transform: scale(1.06); }
.ref.selected { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber); }
.ref .check { position: absolute; top: 5px; left: 5px; width: 18px; height: 18px; border-radius: 50%; background: var(--amber); color: var(--on-amber); font-size: 0.6rem; display: none; place-items: center; font-weight: 700; }
.ref.selected .check { display: grid; }
.ref .del { position: absolute; top: 5px; right: 5px; width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,0.85); color: var(--red); border: none; cursor: pointer; font-size: 0.7rem; display: none; place-items: center; }
.ref:hover .del { display: grid; }
.ref .del:hover { background: var(--red); color: #fff; }

/* ===================== Lists (prompts / combinations) ===================== */
.lib-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 300px; overflow-y: auto; }
.lib-item { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.6rem 0.7rem; border: 1px solid var(--line-2); border-radius: var(--radius-sm); cursor: pointer; transition: all 0.18s var(--ease); background: var(--bg-3); }
.lib-item:hover { border-color: var(--amber); transform: translateX(2px); }
.lib-body { flex: 1; min-width: 0; }
.lib-name { font-size: 0.75rem; color: var(--ink); margin-bottom: 2px; }
.lib-snippet { font-size: 0.66rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-del { background: none; border: none; color: var(--ink-3); cursor: pointer; font-size: 0.8rem; padding: 0 2px; }
.lib-del:hover { color: var(--amber-deep); }

/* ===================== Component axes ===================== */
.axes { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1.3rem; }
.axis { border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--bg-3); overflow: hidden; }
.axis.has-sel { border-color: var(--amber); }
.axis-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.65rem; cursor: pointer; }
.axis-head:hover { background: rgba(0,0,0,0.025); }
.chev { font-size: 0.66rem; color: var(--ink-3); width: 12px; flex: none; text-align: center; }
.axis-name { font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--amber-deep); white-space: nowrap; flex: none; }
.axis-summary { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.axis-none { font-size: 0.68rem; color: var(--ink-3); }
.sel-pill { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.64rem; background: linear-gradient(180deg, var(--amber-2), var(--amber)); color: var(--on-amber); border-radius: 100px; padding: 1px 7px; cursor: pointer; max-width: 200px; }
.sel-pill-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-pill .x { opacity: 0.55; font-size: 0.58rem; }
.sel-pill:hover .x { opacity: 1; }
.axis-tools { display: flex; align-items: center; gap: 0.3rem; flex: none; }
.axis-body { padding: 0.1rem 0.65rem 0.7rem; }
.axis-empty { font-size: 0.66rem; color: var(--ink-3); font-style: italic; }
.add-axis { margin-top: 0.7rem; }
.assistant-mode { max-width: 360px; }
.fills { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.7rem; padding-top: 0.6rem; border-top: 1px dashed var(--line); }
.fill-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.fill-title { font-size: 0.58rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber-deep); min-width: 96px; }
.fill-row input { flex: 1; min-width: 150px; font-size: 0.74rem; padding: 0.45rem 0.6rem; }

.comp-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip-c { position: relative; display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.34rem 0.6rem; border: 1px solid var(--line-2); border-radius: 100px; background: var(--bg-2); cursor: pointer; transition: all 0.16s var(--ease); font-size: 0.72rem; color: var(--ink-2); }
.chip-c:hover { border-color: var(--amber); color: var(--ink); }
.chip-c.selected { background: linear-gradient(180deg, var(--amber-2), var(--amber)); color: var(--on-amber); border-color: var(--amber); box-shadow: 0 3px 10px -5px var(--glow); }
.chip-c img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(40,30,15,0.18); }
.chip-name { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.chip-mini { width: 16px; height: 16px; border-radius: 50%; border: none; background: transparent; color: inherit; opacity: 0; cursor: pointer; font-size: 0.62rem; display: grid; place-items: center; transition: opacity 0.15s; }
.chip-c:hover .chip-mini { opacity: 0.55; }
.chip-mini:hover { opacity: 1; }
.chip-mini.del:hover { color: var(--red); }

.icon-mini { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--ink-3); cursor: pointer; font-size: 0.62rem; display: grid; place-items: center; transition: all 0.18s var(--ease); }
.icon-mini:hover { color: var(--red); border-color: var(--red); }

/* ===================== Build bar ===================== */
.build-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.3rem; flex-wrap: wrap; }
.build-count { font-size: 0.84rem; color: var(--amber-deep); letter-spacing: 0.04em; font-weight: 500; }
.build-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===================== Queue ===================== */
.queue-tools { display: flex; gap: 0.5rem; }
.queue-list { display: flex; flex-direction: column; gap: 0.4rem; }
.queue-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.7rem; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--bg-3); font-size: 0.74rem; }
.q-idx { width: 20px; height: 20px; border-radius: 50%; background: var(--bg-4); color: var(--amber-deep); display: grid; place-items: center; font-size: 0.62rem; flex: none; }
.q-label { flex: 1; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-n { color: var(--ink-3); font-size: 0.66rem; }
.progress { margin-bottom: 0.9rem; }
.progress-track { height: 6px; border-radius: 100px; background: var(--bg-4); overflow: hidden; border: 1px solid var(--line-2); }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--amber-deep), var(--amber-2)); transition: width 0.5s var(--ease); }
.progress-text { font-size: 0.66rem; color: var(--ink-2); letter-spacing: 0.06em; margin-top: 0.45rem; text-transform: uppercase; }

/* ===================== Results & history ===================== */
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.8rem; }
.readout-mini { font-size: 0.64rem; color: var(--ink-3); letter-spacing: 0.1em; text-transform: uppercase; }
.tile { position: relative; border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; border: 1px solid var(--line-2); background: var(--bg-3); aspect-ratio: 1; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.developing img { animation: develop 1.3s var(--ease) forwards; }
@keyframes develop {
  0%   { filter: blur(14px) brightness(1.18) saturate(0.7); opacity: 0; transform: scale(1.03); }
  60%  { filter: blur(4px) brightness(1.06); opacity: 1; }
  100% { filter: none; opacity: 1; transform: none; }
}
.tile-actions { position: absolute; inset: auto 0 0 0; display: flex; gap: 0.4rem; padding: 0.5rem; background: linear-gradient(0deg, rgba(255,255,255,0.95), transparent); opacity: 0; transition: opacity 0.2s var(--ease); }
.tile:hover .tile-actions { opacity: 1; }
.mini { font-size: 0.62rem; padding: 0.3rem 0.5rem; border-radius: 6px; border: 1px solid var(--line); background: rgba(255,255,255,0.92); color: var(--ink-2); cursor: pointer; text-decoration: none; letter-spacing: 0.05em; transition: all 0.15s var(--ease); }
.mini:hover { color: var(--amber-deep); border-color: var(--amber); }
.mini.danger:hover { color: var(--red); border-color: var(--red); }

.hcard { display: flex; flex-direction: column; gap: 0.45rem; }
.hmeta { display: flex; flex-direction: column; gap: 0.3rem; }
.hmeta .hprompt { font-size: 0.66rem; color: var(--ink-2); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.chip { font-size: 0.56rem; letter-spacing: 0.06em; color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; text-transform: uppercase; }
.chip.amber { color: var(--amber-deep); border-color: var(--amber); }
.count-badge { position: absolute; top: 6px; right: 6px; font-size: 0.58rem; background: rgba(255,255,255,0.9); border: 1px solid var(--line); color: var(--amber-deep); border-radius: 5px; padding: 1px 6px; letter-spacing: 0.08em; }
.tile.skeleton { display: grid; place-items: center; }
.tile.skeleton::before { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 20%, rgba(44,75,134,0.16) 50%, transparent 80%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.tile.skeleton span { font-size: 0.62rem; color: var(--ink-3); letter-spacing: 0.16em; text-transform: uppercase; z-index: 1; }

/* ===================== Drawer / scrim / modal ===================== */
.scrim { position: fixed; inset: 0; background: rgba(30, 24, 14, 0.4); backdrop-filter: blur(3px); z-index: 80; animation: fade 0.25s var(--ease); }
.scrim.center { display: grid; place-items: center; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 92vw); z-index: 90; background: var(--bg-2); border-left: 1px solid var(--line); padding: 1.5rem 1.6rem; display: flex; flex-direction: column; gap: 0.9rem; box-shadow: -30px 0 60px -30px rgba(40,30,15,0.4); animation: slidein 0.35s var(--ease); }
@keyframes slidein { from { transform: translateX(100%); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { font-size: 1.4rem; }
.drawer textarea { flex: 1; min-height: 280px; }
.drawer-actions { display: flex; align-items: center; justify-content: space-between; }
.saved-at { font-size: 0.64rem; color: var(--ink-3); letter-spacing: 0.08em; }

.modal { width: min(440px, 92vw); background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; display: flex; flex-direction: column; gap: 0.7rem; box-shadow: 0 30px 70px -30px rgba(40,30,15,0.5); animation: pop 0.3s var(--ease); }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } }
.modal h3 { font-size: 1.2rem; }
.modal .hint { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.3rem; }
.field-label { font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); margin-top: 0.2rem; }
.comp-image-preview { display: flex; align-items: center; gap: 0.8rem; }
.comp-image-preview img { width: 64px; height: 64px; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--bg-3); padding: 4px; }

/* ===================== Lightbox ===================== */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(239, 233, 223, 0.94); backdrop-filter: blur(8px); display: grid; place-items: center; animation: fade 0.25s var(--ease); }
.lightbox-inner { max-width: 94vw; max-height: 90vh; display: flex; flex-direction: row; gap: 1.4rem; align-items: stretch; }
.lightbox-inner img { max-width: 64vw; max-height: 86vh; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--line); box-shadow: 0 30px 80px -28px rgba(40,30,15,0.5); background: #fff; }
.lightbox-meta { width: 360px; flex: none; font-size: 0.74rem; color: var(--ink-2); text-align: left; line-height: 1.65; white-space: pre-wrap; overflow-y: auto; max-height: 86vh; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.lightbox-meta .chips { justify-content: flex-start; margin-top: 0.7rem; }
@media (max-width: 820px) { .lightbox-inner { flex-direction: column; align-items: center; } .lightbox-inner img { max-width: 92vw; max-height: 58vh; } .lightbox-meta { width: 100%; max-height: 28vh; } }
.lightbox-close { position: fixed; top: 1.4rem; right: 1.4rem; background: var(--bg-2); }

/* ===================== Toasts ===================== */
.toast-wrap { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; }
.toast { font-size: 0.74rem; padding: 0.7rem 1.1rem; border-radius: var(--radius-sm); letter-spacing: 0.04em; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink); box-shadow: 0 16px 40px -18px rgba(40,30,15,0.4); animation: toastin 0.3s var(--ease); max-width: 80vw; }
.toast.error { border-color: var(--red); color: #8f2d18; }
.toast.success { border-color: var(--amber); color: var(--amber-deep); }
@keyframes toastin { from { transform: translateY(12px); opacity: 0; } }

/* ===================== Scrollbars ===================== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--amber); }

/* ===================== Nav + pages ===================== */
.nav { display: flex; gap: 0.3rem; }
.nav-btn { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.04em; color: var(--ink-2); background: transparent; border: none; border-radius: 8px; padding: 0.5rem 0.9rem; cursor: pointer; transition: all 0.18s var(--ease); display: inline-flex; align-items: center; gap: 0.4rem; }
.nav-btn:hover { color: var(--ink); background: var(--bg-3); }
.nav-btn.active { color: var(--on-amber); background: linear-gradient(180deg, var(--amber-2), var(--amber)); font-weight: 600; }
.nav-count { font-size: 0.6rem; background: rgba(0,0,0,0.12); border-radius: 100px; padding: 1px 6px; }

.page { max-width: 1180px; margin: 0 auto; padding: 1.6rem; display: flex; flex-direction: column; gap: 1.2rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-head h2 { font-size: 1.7rem; }
.page-head .hint { margin-top: 0.3rem; max-width: 64ch; }
.panel-link { font-size: 0.64rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber-deep); cursor: pointer; text-decoration: none; }
.panel-link:hover { color: var(--amber); }
.library-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; align-items: start; }
.lib-list.tall { max-height: none; }
.product-manage { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.product.manage { background: var(--bg-2); padding-bottom: 0.4rem; }
.product.manage .product-thumbs { padding: 0 0.7rem 0.7rem; }
/* Studio product picker: compact, selectable */
#productPicker .product-thumbs { padding: 0 0.6rem 0.55rem; }
#productPicker .pthumb { width: 34px; height: 34px; }

/* ===================== Assistant chat ===================== */
.prompt-tools-left { display: flex; gap: 0.5rem; }
.chat-page { max-width: 920px; }
.chat-log { display: flex; flex-direction: column; gap: 0.9rem; min-height: 42vh; max-height: 64vh; overflow-y: auto; padding: 0.5rem; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--bg); }
.chat-msg { max-width: 80%; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.assistant { align-self: flex-start; }
.chat-text { padding: 0.7rem 0.95rem; border-radius: var(--radius); font-size: 0.82rem; line-height: 1.55; white-space: pre-wrap; }
.chat-msg.user .chat-text { background: linear-gradient(180deg, var(--amber-2), var(--amber)); color: var(--on-amber); border-bottom-right-radius: 4px; }
.chat-msg.assistant .chat-text { background: var(--bg-2); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 4px; }
.proposals { align-self: flex-start; max-width: 94%; display: flex; flex-direction: column; gap: 0.5rem; background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem; }
.proposal { display: flex; gap: 0.6rem; align-items: flex-start; cursor: pointer; padding: 0.5rem 0.55rem; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--bg-2); }
.proposal input { margin-top: 3px; accent-color: var(--amber); }
.proposal-body { flex: 1; min-width: 0; }
.proposal-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; flex-wrap: wrap; }
.proposal-name { font-size: 0.76rem; color: var(--ink); font-weight: 500; }
.proposal-text { font-size: 0.72rem; color: var(--ink-2); line-height: 1.5; }
.proposal-actions { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.2rem; }
.added-note { font-size: 0.72rem; color: var(--amber-deep); }
.chat-input { display: flex; gap: 0.6rem; align-items: flex-end; }
.chat-input textarea { flex: 1; min-height: 52px; }
.chat-input .btn { flex: none; padding: 0.8rem 1.4rem; }

/* Floating assistant bubble + popover */
.assistant-bubble { position: fixed; bottom: 1.4rem; right: 1.4rem; z-index: 150; width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer; background: linear-gradient(180deg, var(--amber-2), var(--amber)); color: var(--on-amber); font-size: 1.4rem; box-shadow: 0 12px 30px -10px var(--glow), 0 4px 10px rgba(40,30,15,0.22); transition: transform 0.2s var(--ease); }
.assistant-bubble:hover { transform: scale(1.08); }
.assistant-bubble.active { transform: scale(0.92); }
.assistant-panel { position: fixed; bottom: 5.8rem; right: 1.4rem; z-index: 150; width: min(440px, 94vw); height: min(660px, 76vh); display: flex; flex-direction: column; gap: 0.7rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 30px 70px -28px rgba(40,30,15,0.55); padding: 1rem; animation: pop 0.25s var(--ease); }
.assistant-panel-head { display: flex; align-items: center; justify-content: space-between; }
.assistant-panel-head h2 { font-size: 1.15rem; }
.assistant-panel-tools { display: flex; align-items: center; gap: 0.5rem; }
.assistant-panel .chat-log { flex: 1; min-height: 0; max-height: none; }
.assistant-panel .chat-input textarea { min-height: 46px; }
.assistant-pick { display: flex; align-items: center; gap: 0.5rem; }
.assistant-pick select { flex: 1; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.btn.danger:hover { color: var(--red); border-color: var(--red); }
@media (max-width: 600px) { .assistant-panel { right: 0.6rem; left: 0.6rem; width: auto; bottom: 5rem; height: 70vh; } }

/* ===================== Responsive ===================== */
@media (max-width: 980px) {
  .topbar { flex-wrap: wrap; padding: 0.7rem 1rem; gap: 0.6rem; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .kicker { display: none; }
  .readout { display: none; }
}
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .library-cols { grid-template-columns: 1fr; }
  .build-bar { flex-direction: column; align-items: stretch; }
  .build-actions { justify-content: stretch; }
}

/* ===================== Login + user chip ===================== */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; overflow: hidden; }
.login-aura { position: fixed; inset: 0; z-index: 0; pointer-events: none; display: grid; place-items: center; }
.login-aura::before { content: ""; width: min(140vh, 1300px); aspect-ratio: 1; border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 41px, rgba(44,75,134,0.06) 41px 42px);
  -webkit-mask: radial-gradient(circle, #000 22%, transparent 70%); mask: radial-gradient(circle, #000 22%, transparent 70%); }
.login-card { position: relative; z-index: 1; width: min(404px, 92vw); background: linear-gradient(180deg, #ffffff, #fdfbf7);
  border: 1px solid var(--line); border-radius: 20px; padding: 2.8rem 2.2rem 1.9rem; text-align: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), 0 44px 90px -42px rgba(20,26,46,0.5), 0 10px 28px -18px rgba(20,26,46,0.22);
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem; animation: loginIn 0.6s var(--ease) both; }
@keyframes loginIn { from { opacity: 0; transform: translateY(16px) scale(0.985); } }
.lens { width: 58px; height: 58px; border-radius: 50%; position: relative; margin-bottom: 0.9rem;
  background: conic-gradient(from 220deg, var(--amber-deep), var(--amber) 35%, var(--amber-2) 50%, var(--amber-deep) 72%, var(--amber-deep));
  box-shadow: 0 10px 24px -8px var(--glow), inset 0 0 0 5px #fff, inset 0 0 0 6px rgba(44,75,134,0.22); }
.lens::after { content: ""; position: absolute; inset: 18px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 8px rgba(20,26,46,0.35); }
.lens::before { content: ""; position: absolute; inset: 23px; border-radius: 50%; background: radial-gradient(circle at 38% 32%, var(--amber-2), var(--amber-deep)); }
.login-card .wordmark { font-size: 1.95rem; font-variation-settings: "opsz" 72; letter-spacing: -0.02em; }
.login-sub { font-size: 0.62rem; letter-spacing: 0.28em; text-transform: uppercase; color: var(--amber-deep); margin: 0.25rem 0 1.7rem; }
.login-msg { display: none; font-size: 0.74rem; color: #8f2d18; background: rgba(192,73,47,0.08); border: 1px solid var(--red); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; margin: 0 0 1rem; width: 100%; box-sizing: border-box; }
.login-msg.show { display: block; }
.google-btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.7rem; width: 100%; box-sizing: border-box; font-family: var(--mono); font-size: 0.82rem; font-weight: 500; color: var(--ink); background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 0.92rem 1rem; cursor: pointer; text-decoration: none; transition: all 0.22s var(--ease); box-shadow: 0 6px 16px -10px rgba(20,26,46,0.4); }
.google-btn:hover { border-color: var(--amber); box-shadow: 0 14px 28px -12px var(--glow); transform: translateY(-2px); }
.google-btn:active { transform: translateY(0); }
.login-foot { font-size: 0.64rem; color: var(--ink-3); line-height: 1.55; margin: 1.4rem 0 0; }

.user-chip { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.72rem; color: var(--ink-2); }
.user-chip img { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); object-fit: cover; }
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-logout { font-size: 0.64rem; color: var(--amber-deep); text-decoration: none; border: 1px solid var(--line); border-radius: 100px; padding: 2px 8px; }
.user-logout:hover { border-color: var(--amber); color: var(--amber); }
