/* Fimuro Ad Studio — UI
   Palette from the Fimuro brand: indigo #4338CA + coral #E8613C on a deep indigo-black. One family: Manrope. */
:root {
  --ink: #0c0c14;
  --panel: #12121c;
  --raised: #191926;
  --raised-2: #212131;
  --line: rgba(170, 170, 255, 0.08);
  --line-2: rgba(170, 170, 255, 0.15);
  --text: #eeeef6;
  --muted: #9696ae;
  --faint: #66667e;
  --accent: #7c74ff;
  --brand: #4338ca;
  --coral: #e8613c;
  --ok: #3ddc97;
  --danger: #ff7a7a;
  --r-lg: 18px;
  --r: 12px;
  --r-sm: 9px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
::selection { background: rgba(124, 116, 255, 0.35); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 58px; display: flex; align-items: center; gap: 28px;
  padding: 0 20px;
  background: rgba(12, 12, 20, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.015em; font-size: 15px; }
.tabs { display: flex; gap: 2px; }
.tabs a {
  position: relative; padding: 8px 13px; color: var(--muted); font-weight: 600; font-size: 13.5px; border-radius: 9px;
  transition: color .15s, background .15s;
}
.tabs a:hover { color: var(--text); background: var(--raised); }
.tabs a.active { color: var(--text); }
.tabs a.active::after { content: ''; position: absolute; left: 13px; right: 13px; bottom: -11px; height: 2px; border-radius: 2px; background: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.queue-pill {
  font-size: 12px; font-weight: 700; color: #d6d3ff;
  padding: 5px 11px; border-radius: 999px; background: rgba(124, 116, 255, 0.14);
  display: inline-flex; gap: 7px; align-items: center;
}
.queue-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px;
}
.icon-btn:hover { color: var(--text); background: var(--raised); }

/* ---------------------------------------------------------------- shared controls */
.label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0 0 7px; }
.hint { font-weight: 500; color: var(--faint); margin-left: 4px; }
.muted { color: var(--muted); }
.sm { font-size: 12.5px; }

input[type=text], input[type=password], textarea, select {
  width: 100%;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, background .15s;
}
textarea { resize: vertical; min-height: 44px; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { border-color: rgba(124, 116, 255, 0.55); background: var(--raised-2); }
select {
  appearance: none; cursor: pointer; padding-right: 30px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239696ae' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
select option, select optgroup { background: var(--raised); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--raised); cursor: pointer;
  font-weight: 700; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--raised-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: #8d86ff; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--raised); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 9px; }
.btn.danger { color: var(--danger); }
.btn.loading, .generate.loading, .improve.loading { pointer-events: none; opacity: .75; }
.btn.loading::after, .generate.loading::after, .improve.loading::after {
  content: ''; width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link-btn { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; padding: 0; cursor: pointer; color: #b4afff; font-weight: 700; font-size: 12.5px; }
.link-btn:hover { color: #d4d1ff; }

.chips { display: flex; gap: 8px; }
.chips.wrap { flex-wrap: wrap; }
.chips.scroll-x { overflow-x: auto; scrollbar-width: none; }
.chips.scroll-x::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  height: 32px; padding: 0 13px; border-radius: 999px;
  background: transparent; border: 1px solid var(--line-2); color: var(--muted);
  font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: color .15s, background .15s, border-color .15s;
}
.chip:hover { color: var(--text); }
.chip.on { color: var(--text); background: var(--raised-2); border-color: rgba(124, 116, 255, 0.55); }

.seg { display: flex; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; height: 42px; }
.seg button { flex: 1; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; transition: background .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--raised-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

.check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; }

/* ---------------------------------------------------------------- studio layout */
.studio { display: grid; grid-template-columns: 392px minmax(0, 1fr); height: calc(100vh - 58px); height: calc(100dvh - 58px); }
.composer { min-width: 0; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
.composer-scroll { flex: 1; overflow-y: auto; padding: 6px 20px 10px; scrollbar-width: thin; scrollbar-color: var(--raised-2) transparent; }
.composer-foot { padding: 14px 20px 18px; border-top: 1px solid var(--line); }

.sect { padding: 16px 0; border-bottom: 1px solid var(--line); }
.sect:last-child { border-bottom: 0; }
.sect-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 11px; font-size: 13px; font-weight: 700; color: var(--text);
}
.sect-head b { font-weight: 600; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* collapsible sections */
.fold > summary { list-style: none; cursor: pointer; margin-bottom: 0; user-select: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary b::after {
  content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 9px; vertical-align: 2px;
  border-right: 1.8px solid var(--faint); border-bottom: 1.8px solid var(--faint); transform: rotate(45deg); transition: transform .15s;
}
.fold[open] > summary { margin-bottom: 12px; }
.fold[open] > summary b::after { transform: rotate(-135deg); vertical-align: -1px; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* brand avatars */
.avatars { display: flex; flex-wrap: wrap; gap: 10px; }
.avatar {
  position: relative; width: 42px; height: 42px; border-radius: 50%; flex: none; cursor: pointer;
  border: 0; padding: 0; display: grid; place-items: center; overflow: hidden;
  font-weight: 800; font-size: 15px; color: #fff; letter-spacing: -0.02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: transform .12s;
}
.avatar img { width: 72%; height: 72%; object-fit: contain; }
.avatar.has-logo { background: #f4f4f8; }
.avatar.none { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-2); color: var(--faint); }
.avatar:hover { transform: translateY(-1px); }
.avatar.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }

/* prompt box */
.promptbox {
  background: var(--raised); border: 1px solid var(--line-2); border-radius: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.promptbox:focus-within { border-color: rgba(124, 116, 255, 0.55); box-shadow: 0 0 0 4px rgba(124, 116, 255, 0.08); }
.promptbox.drag { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 116, 255, 0.14); }
.promptbox textarea {
  display: block; border: 0; background: transparent; padding: 14px 14px 4px; min-height: 104px; resize: none; font-size: 14px;
}
.promptbox textarea:focus { background: transparent; }
.refs { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px 2px; }
.ref { position: relative; width: 46px; height: 46px; border-radius: 9px; overflow: hidden; background: var(--raised-2) center/cover no-repeat; box-shadow: inset 0 0 0 1px var(--line-2); }
.ref button {
  position: absolute; inset: 0; border: 0; background: rgba(8, 8, 14, 0.62); color: #fff; cursor: pointer;
  font-size: 18px; opacity: 0; transition: opacity .15s;
}
.ref:hover button, .ref button:focus-visible { opacity: 1; }
.ref-add {
  height: 30px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px;
  border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 12.5px; font-weight: 700;
  transition: color .15s, background .15s;
}
.ref-add:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.ref-add[aria-disabled=true] { opacity: .4; pointer-events: none; }
.promptbar { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 6px; }
.improve {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: 8px; border: 0; background: rgba(124, 116, 255, 0.14); color: #c9c6ff;
  font-weight: 700; font-size: 12.5px; cursor: pointer; transition: background .15s;
}
.improve:hover { background: rgba(124, 116, 255, 0.24); }

/* formats */
.formats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.fmt {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 0;
  height: 66px; padding: 0 0 10px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line); cursor: pointer; color: var(--muted);
  transition: color .15s, border-color .15s, background .15s;
}
.fmt:hover { color: var(--text); }
.fmt.on { color: var(--text); background: var(--raised-2); border-color: rgba(124, 116, 255, 0.6); }
.fmt .shape { display: block; flex: none; margin: auto 0; border: 1.6px solid currentColor; border-radius: 3px; }
.fmt.on .shape { background: rgba(124, 116, 255, 0.25); border-color: #a9a4ff; }
.fmt .r { font-size: 11px; font-weight: 700; line-height: 1; }

/* style menu */
.menu-wrap { position: relative; }
.select-btn {
  width: 100%; display: flex; align-items: baseline; gap: 10px; text-align: left;
  height: 42px; padding: 0 34px 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--raised);
  cursor: pointer; font-weight: 600;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239696ae' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  line-height: 40px; overflow: hidden;
}
.select-btn small { font-size: 12px; color: var(--faint); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.select-btn[aria-expanded=true] { border-color: rgba(124, 116, 255, 0.55); }
.menu {
  margin-top: 6px; background: var(--raised); border: 1px solid var(--line-2); border-radius: 12px; padding: 5px;
  animation: pop .14s ease;
}
.menu button {
  width: 100%; display: block; text-align: left; border: 0; background: transparent; cursor: pointer;
  padding: 8px 10px; border-radius: 8px;
}
.menu button:hover, .menu button:focus-visible { background: rgba(255, 255, 255, 0.05); outline: none; }
.menu button.on { background: rgba(124, 116, 255, 0.16); }
.menu button strong { display: block; font-size: 13px; font-weight: 700; }
.menu button span { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; margin-top: 1px; }

/* settings grid */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; }
.fieldbox { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.fieldbox > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.fieldbox select { height: 42px; padding-top: 0; padding-bottom: 0; }

#finalPrompt { font-size: 12.5px; line-height: 1.6; color: #c9c9da; }
#resetPrompt { margin-top: 8px; }

/* generate */
.generate {
  width: 100%; height: 50px; border: 0; border-radius: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -0.01em;
  background: linear-gradient(100deg, var(--brand) 0%, #6a5cff 52%, var(--coral) 120%);
  box-shadow: 0 10px 30px rgba(67, 56, 202, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: filter .15s, transform .08s;
}
.generate:hover { filter: brightness(1.08); }
.generate:active { transform: translateY(1px); }
.generate kbd { font: 700 11px var(--font); color: rgba(255, 255, 255, 0.7); background: rgba(255, 255, 255, 0.14); padding: 2px 7px; border-radius: 6px; }

/* ---------------------------------------------------------------- results */
.canvas { overflow-y: auto; padding: 26px 30px 60px; min-height: 0; }
.empty { max-width: 400px; margin: 13vh auto 0; text-align: center; }
.empty h2 { font-size: 21px; letter-spacing: -0.02em; margin: 28px 0 8px; }
.empty p { color: var(--muted); margin: 0; }
.empty.small { margin-top: 40px; }
.empty-art { display: flex; justify-content: center; align-items: flex-end; gap: 10px; height: 112px; }
.empty-art span { display: block; border-radius: 12px; background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-2); }
.empty-art span:nth-child(1) { width: 64px; height: 80px; transform: rotate(-8deg) translateY(4px); }
.empty-art span:nth-child(2) { width: 70px; height: 108px; background: linear-gradient(160deg, var(--brand), #6a5cff 55%, var(--coral)); box-shadow: 0 20px 50px rgba(67, 56, 202, 0.4); }
.empty-art span:nth-child(3) { width: 64px; height: 64px; transform: rotate(8deg) translateY(4px); }

.job { margin-bottom: 36px; }
.job-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-width: 0; }
.job-title { font-weight: 700; font-size: 14.5px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 0 1 auto; margin-right: 4px; }
.tag { font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--raised); padding: 3px 9px; border-radius: 999px; white-space: nowrap; flex: none; }
.job-head .time { margin-left: auto; padding-left: 12px; color: var(--faint); font-size: 12px; white-space: nowrap; flex: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

.tile {
  position: relative; border-radius: var(--r); overflow: hidden; background: var(--raised); cursor: zoom-in;
  box-shadow: inset 0 0 0 1px var(--line);
}
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; animation: fadein .45s ease; }
@keyframes fadein { from { opacity: 0; } }
.tile .ov {
  position: absolute; inset: auto 0 0 0; padding: 10px; display: flex; gap: 6px; justify-content: flex-end;
  background: linear-gradient(transparent, rgba(5, 5, 10, 0.7)); opacity: 0; transition: opacity .15s;
}
.tile:hover .ov, .tile:focus-within .ov { opacity: 1; }
.ov button { height: 30px; padding: 0 11px; border-radius: 8px; border: 0; cursor: pointer; background: #fff; color: #0c0c14; font-weight: 700; font-size: 12px; }
.ov button.dark { background: rgba(18, 18, 28, 0.85); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.tile .fav { position: absolute; top: 9px; left: 10px; font-size: 14px; color: #ffd166; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.tile.pending { cursor: default; display: grid; place-items: center; }
.tile.pending::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(124, 116, 255, 0.07) 50%, transparent 70%);
  background-size: 250% 100%; animation: shimmer 1.8s linear infinite;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.pending-inner { position: relative; text-align: center; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.pending-inner .spinner { width: 24px; height: 24px; margin: 0 auto 10px; border-radius: 50%; border: 2.5px solid var(--raised-2); border-top-color: var(--accent); animation: spin .9s linear infinite; }
.tile.err { cursor: default; display: grid; place-items: center; padding: 18px; box-shadow: inset 0 0 0 1px rgba(255, 122, 122, 0.3); background: rgba(255, 122, 122, 0.05); }
.tile.err p { margin: 0; color: #ffadad; font-size: 12.5px; text-align: center; word-break: break-word; }

/* ---------------------------------------------------------------- pages */
.page { max-width: 1280px; margin: 0 auto; padding: 30px 24px 80px; }
.page.narrow { max-width: 860px; }
.page-head { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; letter-spacing: -0.03em; margin: 0; }
.page-head .chips { flex: 1; min-width: 0; }
.lead { margin: -8px 0 22px; max-width: 70ch; }
.center { text-align: center; margin-top: 22px; }

.masonry { columns: 4 250px; column-gap: 14px; }
.masonry .tile { break-inside: avoid; margin-bottom: 14px; display: block; }
.masonry .tile img { height: auto; }

.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.brand-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px;
  display: flex; flex-direction: column; gap: 14px; cursor: pointer; transition: border-color .15s;
}
.brand-card:hover { border-color: var(--line-2); }
.bc-top { display: flex; align-items: center; gap: 12px; }
.bc-logo { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff; overflow: hidden; flex: none; }
.bc-logo img { width: 72%; height: 72%; object-fit: contain; }
.bc-name { font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }
.bc-desc { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.swatches { display: flex; gap: 6px; }
.swatches span { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; margin-bottom: 16px; }
.card h3 { margin: 0 0 4px; font-size: 16px; letter-spacing: -0.01em; }
.card > .muted { margin: 0 0 18px; font-size: 13px; }
.card .label { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.api-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.api-grid .label:first-child { margin-top: 0; }
.key-state { font-size: 12px; color: var(--faint); margin-top: 6px; }
.key-state.ok { color: var(--ok); }
.actions { margin-top: 18px; display: flex; justify-content: flex-end; }

.model-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.model-row { display: grid; grid-template-columns: auto 1fr auto auto auto; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.model-row:first-child { border-top: 0; }
.model-row .mname { font-weight: 700; font-size: 13.5px; }
.model-row .mid { font-size: 12px; color: var(--faint); }
.model-row .result { font-size: 12px; min-width: 0; }
.model-row .result.ok { color: var(--ok); }
.model-row .result.bad { color: var(--danger); }
.prov { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--raised); color: var(--muted); }
.prov.gemini { color: #8fd6ff; }
.default-btn { font-size: 12px; font-weight: 700; color: var(--faint); background: none; border: 0; cursor: pointer; }
.default-btn:hover { color: var(--muted); }
.default-btn.on { color: #ffd166; }
.toggle { position: relative; width: 36px; height: 21px; flex: none; }
.toggle input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; inset: 0; z-index: 1; }
.toggle span { position: absolute; inset: 0; background: var(--raised-2); border-radius: 999px; transition: background .15s; }
.toggle span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(15px); }
.add-model { display: grid; grid-template-columns: 1fr 190px auto; gap: 8px; margin-top: 12px; }

/* ---------------------------------------------------------------- modal / lightbox */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 5, 10, 0.8); backdrop-filter: blur(6px); animation: fadein .2s; }
.lightbox {
  position: relative; display: grid; grid-template-columns: 1fr 340px; width: min(1300px, 100%); height: min(880px, calc(100dvh - 40px));
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow);
  animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.985); } }
.lb-stage { background: #07070c; display: grid; place-items: center; padding: 22px; min-height: 0; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px; }
.lb-side { padding: 22px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; border-left: 1px solid var(--line); }
.lb-head { display: flex; justify-content: space-between; gap: 10px; }
.lb-title { font-weight: 800; font-size: 16px; letter-spacing: -0.01em; }
.dl-box { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 14px; background: var(--raised); }
.dl-box .label { margin: 0; color: var(--text); font-weight: 700; font-size: 13px; }
.dl-box select { background-color: var(--raised-2); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.logo-size { display: flex; align-items: center; gap: 10px; }
.logo-size input { flex: 1; accent-color: var(--accent); }
.lb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lb-prompt summary { cursor: pointer; font-weight: 700; font-size: 13px; }
.lb-prompt pre {
  white-space: pre-wrap; word-break: break-word; font: 12.5px/1.6 var(--font); color: var(--muted);
  background: var(--raised); border-radius: 10px; padding: 12px; margin: 10px 0 8px; max-height: 280px; overflow: auto;
}

.sheet {
  position: relative; width: min(560px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); animation: pop .2s ease;
}
.sheet .label { margin-top: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h3 { margin: 0; font-size: 17px; }
.sheet-foot { display: flex; justify-content: space-between; margin-top: 22px; }
.logo-up { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.logo-up label.btn { margin-right: 8px; }
.logo-prev { width: 64px; height: 64px; border-radius: 50%; background: #f4f4f8 center/62% no-repeat; flex: none; }
.logo-prev:not([style*="url"]) { background: var(--raised); box-shadow: inset 0 0 0 1px var(--line-2); }
.colors { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.color-item { position: relative; width: 38px; height: 38px; border-radius: 50%; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16); }
.color-item input { position: absolute; inset: -8px; width: 54px; height: 54px; border: 0; padding: 0; cursor: pointer; background: none; opacity: 0; }
.color-item button { position: absolute; top: 0; right: 0; width: 16px; height: 16px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.75); color: #fff; font-size: 10px; line-height: 1; cursor: pointer; opacity: 0; z-index: 2; }
.color-item:hover button { opacity: 1; }
.color-add { width: 38px; height: 38px; border-radius: 50%; border: 1.5px dashed var(--line-2); background: none; color: var(--muted); cursor: pointer; font-size: 18px; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  background: var(--raised-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow); animation: rise .25s ease;
  display: flex; gap: 10px; align-items: flex-start;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-top: 6px; flex: none; }
.toast.error::before { background: var(--danger); }

/* ---------------------------------------------------------------- login */
.login-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(60vmax 50vmax at 12% -10%, rgba(67, 56, 202, 0.28), transparent 60%),
    radial-gradient(50vmax 40vmax at 110% 110%, rgba(232, 97, 60, 0.16), transparent 60%),
    var(--ink);
}
.login-card { width: min(380px, 100%); background: rgba(18, 18, 28, 0.85); border: 1px solid var(--line-2); border-radius: 22px; padding: 34px 28px; box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.login-card h1 { font-size: 22px; letter-spacing: -0.025em; margin: 18px 0 4px; }
.login-card p { margin: 0 0 22px; color: var(--muted); }
.login-card .label { margin-top: 14px; }
.login-card .btn { width: 100%; margin-top: 22px; height: 46px; background: linear-gradient(100deg, var(--brand), #6a5cff 60%, var(--coral) 130%); border: 0; }
.login-err { color: var(--danger); font-size: 13px; font-weight: 600; margin-top: 12px; min-height: 18px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .studio { grid-template-columns: 350px minmax(0, 1fr); }
  .lightbox { grid-template-columns: 1fr 300px; }
}
@media (max-width: 860px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .brandmark span { display: none; }
  .tabs a { padding: 7px 10px; font-size: 13px; }
  .tabs a.active::after { bottom: -12px; left: 10px; right: 10px; }
  .studio { grid-template-columns: minmax(0, 1fr); height: auto; }
  .composer { border-right: 0; border-bottom: 1px solid var(--line); }
  .composer-scroll { overflow: visible; padding: 4px 16px 6px; }
  .composer-foot { position: sticky; bottom: 0; z-index: 10; background: rgba(18, 18, 28, 0.94); backdrop-filter: blur(10px); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .generate kbd { display: none; }
  .canvas { overflow: visible; padding: 22px 16px 60px; }
  .empty { margin-top: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile .ov { opacity: 1; }
  .ov button { height: 28px; padding: 0 9px; font-size: 11.5px; }
  .job-head { flex-wrap: wrap; }
  .job-title { flex-basis: 100%; }
  .job-head .time { margin-left: 0; padding-left: 4px; }
  .page { padding: 22px 16px 60px; }
  .api-grid { grid-template-columns: 1fr; }
  .masonry { columns: 2; column-gap: 10px; }
  .masonry .tile { margin-bottom: 10px; }
  .lightbox { grid-template-columns: 1fr; grid-template-rows: minmax(0, 50%) 1fr; }
  .lb-side { border-left: 0; border-top: 1px solid var(--line); }
  .model-row { grid-template-columns: auto 1fr auto; }
  .model-row .default-btn { grid-column: 2; justify-self: start; }
  .add-model { grid-template-columns: 1fr; }
  .modal { padding: 10px; }
}
@media (max-width: 420px) {
  .tabs a { padding: 6px 7px; }
  .ov button.dark { display: none; }
}
