/* ============================================================
   Character Turnaround Studio — DARK ONLY
   Vibe: Ethereal Glass (OLED black, glass cards, hairlines)
   No light theme exists. Premium agency-tier dark surface.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ---------- Design tokens ---------- */
:root {
  color-scheme: dark;

  --bg:            #0d0f12;
  --bg-deep:       #090a0d;
  --surface:       #16191f;
  --surface-2:     #1c2027;
  --surface-3:     #23272f;
  --hairline:      rgba(255, 255, 255, 0.07);
  --hairline-soft: rgba(255, 255, 255, 0.045);
  --hairline-strong: rgba(255, 255, 255, 0.12);

  --text:          #f2f4f7;
  --text-soft:     #b6bcc6;
  --text-mute:     #7c828d;
  --text-faint:    #565b64;

  --accent:        #7c83ff;
  --accent-2:      #9a8bff;
  --accent-soft:   rgba(124, 131, 255, 0.14);
  --accent-line:   rgba(124, 131, 255, 0.35);

  --ok:            #4ade80;
  --ok-soft:       rgba(74, 222, 128, 0.13);
  --warn:          #fbbf24;
  --warn-soft:     rgba(251, 191, 36, 0.13);
  --err:           #f87171;
  --err-soft:      rgba(248, 113, 113, 0.13);

  --radius-xl:     26px;
  --radius-lg:     20px;
  --radius-md:     14px;
  --radius-sm:     10px;
  --radius-pill:   999px;

  --shadow-soft:   0 1px 0 rgba(255,255,255,0.03) inset,
                   0 18px 50px -24px rgba(0,0,0,0.85);
  --shadow-float:  0 24px 70px -28px rgba(0,0,0,0.9),
                   0 2px 0 rgba(255,255,255,0.03) inset;
  --inset-hi:      inset 0 1px 1px rgba(255,255,255,0.08);

  --ease:          cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out:      cubic-bezier(0.16, 1, 0.3, 1);
  --dur:           0.55s;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Ambient mesh glow — fixed, pointer-events none (perf guardrail) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 50% at 18% 0%, rgba(124,131,255,0.12), transparent 60%),
    radial-gradient(50% 45% at 92% 8%, rgba(154,139,255,0.09), transparent 60%),
    radial-gradient(60% 55% at 60% 100%, rgba(60,72,140,0.10), transparent 65%);
}
/* faint film grain for physical depth */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 999px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #2f343d; }

/* ---------- Typography ---------- */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-2);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.22em;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.03em; }
.muted { color: var(--text-mute); }
.tiny  { font-size: 12px; }

/* ============================================================
   AUTH (login / register) — centered island card
   ============================================================ */
.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  /* bound the column so the card never exceeds the viewport on phones
     (an auto track grows to the card's max-content width otherwise) */
  grid-template-columns: min(100%, 420px);
  justify-content: center;
  align-items: center;
  padding: 24px;
}
@media (max-width: 460px) { .auth-shell { padding: 20px 14px; } }
.auth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 8px;
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-float);
  animation: rise var(--dur) var(--ease-out) both;
}
.auth-card__inner {
  padding: 38px 34px 34px;
  border-radius: calc(var(--radius-xl) - 8px);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 40%),
    var(--surface);
  border: 1px solid var(--hairline-soft);
  box-shadow: var(--inset-hi);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}
.auth-brand .logo { width: 40px; height: 40px; }
.auth-brand b { font-size: 16px; letter-spacing: -0.02em; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card p.sub { color: var(--text-mute); font-size: 14px; margin: 0 0 26px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}
.input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease), background .25s var(--ease);
}
.input::placeholder, textarea::placeholder { color: var(--text-faint); }
.input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-line);
  background: #0b0c10;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%237c828d' stroke-width='1.5'%3E%3Cpath d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  cursor: pointer;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }

.auth-error,
.form-msg {
  display: none;
  margin-bottom: 16px;
  padding: 11px 14px;
  font-size: 13px;
  border-radius: var(--radius-md);
  background: var(--err-soft);
  border: 1px solid rgba(248,113,113,0.3);
  color: #fca5a5;
}
.auth-error.show, .form-msg.show { display: block; }

.auth-foot {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline-soft);
  font-size: 13.5px;
  color: var(--text-mute);
  text-align: center;
}
.auth-foot a { color: var(--accent-2); font-weight: 600; }
.auth-foot a:hover { text-decoration: underline; }

/* ============================================================
   BUTTONS — island / button-in-button
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  transition: transform .4s var(--ease), background .3s var(--ease),
              border-color .3s var(--ease), box-shadow .3s var(--ease);
  will-change: transform;
}
.btn:hover { background: var(--surface-3); border-color: var(--hairline-strong); }
.btn:active { transform: scale(0.975); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.btn--full { width: 100%; }
.btn--ghost { background: transparent; }
.btn--sm { padding: 8px 14px; font-size: 13px; }

.btn--primary {
  color: #0b0c10;
  background: linear-gradient(180deg, #9aa0ff, var(--accent));
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 10px 30px -10px rgba(124,131,255,0.6),
              inset 0 1px 0 rgba(255,255,255,0.35);
  font-weight: 700;
}
.btn--primary:hover {
  background: linear-gradient(180deg, #a8adff, #888fff);
  border-color: rgba(255,255,255,0.28);
}

/* nested trailing icon circle */
.btn__ico {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: -2px -8px -2px 2px;
  border-radius: var(--radius-pill);
  background: rgba(0,0,0,0.18);
  transition: transform .4s var(--ease);
}
.btn--primary .btn__ico { background: rgba(0,0,0,0.16); }
.btn:hover .btn__ico { transform: translate(2px, -1px) scale(1.06); }
.btn__ico svg { width: 13px; height: 13px; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 10px;
  gap: 16px;
  padding: 14px 26px;
  background: rgba(13,15,18,0.72);
  backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--hairline-soft);
}
.topbar .brand { display: flex; align-items: center; gap: 11px; }
.topbar .brand .logo { width: 30px; height: 30px; }
.topbar .brand b { font-size: 15px; letter-spacing: -0.02em; }
.topbar .brand span { color: var(--text-faint); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .who {
  display: flex; align-items: center; gap: 9px;
  font-size: 13.5px; color: var(--text-soft);
}
.avatar {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-2);
  font-size: 12px; font-weight: 700;
}
/* action cluster — inline on desktop, collapses behind burger on phones */
.topbar__menu { display: flex; align-items: center; gap: 16px; }
.topbar__burger {
  display: none;                 /* shown only on phones (see @media 640) */
  width: 40px; height: 40px;
  place-items: center;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--hairline);
  color: var(--text-soft);
  cursor: pointer;
}
.topbar__burger svg { width: 22px; height: 22px; }
.topbar__burger[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-2);
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 388px 1fr;
  gap: 22px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 26px 26px 80px;
  align-items: start;
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; padding: 18px 16px 64px; gap: 18px; }
}

/* ---------- Card (double-bezel) ---------- */
.panel {
  padding: 7px;
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,0.028);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-soft);
}
.panel__inner {
  padding: 24px 22px;
  border-radius: calc(var(--radius-xl) - 7px);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), transparent 30%),
    var(--surface);
  border: 1px solid var(--hairline-soft);
  box-shadow: var(--inset-hi);
}
.panel--sticky { position: sticky; top: 86px; }
@media (max-width: 1000px) { .panel--sticky { position: static; } }

.panel__head { margin-bottom: 20px; }
.panel__head h2 { font-size: 18px; margin-top: 12px; }
.panel__head p { color: var(--text-mute); font-size: 13px; margin: 4px 0 0; }

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-faint);
  margin: 22px 0 12px;
}

/* ---------- Control grid ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Segmented toggle (hands / variations) ---------- */
.segment {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
}
.segment button {
  flex: 1;
  padding: 8px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mute);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: all .35s var(--ease);
}
.segment button:hover { color: var(--text-soft); }
.segment button.active {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--hairline);
  box-shadow: var(--inset-hi);
}

/* ---------- Prompt preview ---------- */
.preview {
  margin-top: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  background: var(--bg-deep);
  overflow: hidden;
  animation: rise .45s var(--ease-out) both;
}
.preview__bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline-soft);
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-faint);
}
.preview__bar .spacer { flex: 1; }
.preview__body {
  padding: 14px;
  font-size: 13px;
  line-height: 1.62;
  color: var(--text-soft);
  white-space: pre-wrap;
  max-height: 230px;
  overflow: auto;
}
.preview__body code { color: var(--accent-2); }

.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  transition: all .3s var(--ease);
}
.copy-btn:hover { color: var(--text); border-color: var(--hairline-strong); }
.copy-btn.copied { color: var(--ok); border-color: rgba(74,222,128,0.35); }
.copy-btn svg { width: 12px; height: 12px; }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }

/* ============================================================
   GALLERY
   ============================================================ */
.stage__head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 18px;
}
.stage__head h2 { font-size: 19px; }
.stage__head .spacer { flex: 1; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background:
    linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform .5s var(--ease), border-color .4s var(--ease), box-shadow .4s var(--ease);
  animation: rise .5s var(--ease-out) both;
}
.tile:hover {
  transform: translateY(-4px);
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-float);
}
.tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .6s var(--ease-out);
}
.tile img.loaded { opacity: 1; }

.tile__skeleton {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  gap: 12px;
  color: var(--text-faint);
}
.spinner {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.tile__skeleton small { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }

/* status badge */
.badge {
  position: absolute;
  top: 10px; left: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: var(--radius-pill);
  background: rgba(9,10,13,0.7);
  backdrop-filter: blur(6px);
  border: 1px solid var(--hairline);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge--done  { color: var(--ok);   border-color: rgba(74,222,128,0.35); }
.badge--done  .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.badge--run   { color: var(--accent-2); border-color: var(--accent-line); }
.badge--run   .dot { background: var(--accent); animation: pulse 1.3s ease-in-out infinite; }
.badge--fail  { color: var(--err); border-color: rgba(248,113,113,0.35); }
.badge--fail  .dot { background: var(--err); }
.badge--4k {
  left: auto; right: 10px;
  color: var(--accent-2); border-color: var(--accent-line);
  background: var(--accent-soft);
}

.tile__err {
  position: absolute; inset: 0;
  display: grid; place-items: center; padding: 18px; text-align: center;
  color: var(--err); font-size: 12px;
}

/* empty state */
.empty {
  grid-column: 1 / -1;
  display: grid; place-items: center; gap: 14px;
  padding: 70px 24px; text-align: center;
  border-radius: var(--radius-xl);
  border: 1px dashed var(--hairline);
  background: rgba(255,255,255,0.015);
}
.empty .glyph {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-2);
}
.empty h3 { font-size: 16px; }
.empty p { color: var(--text-mute); font-size: 13.5px; max-width: 320px; margin: 0; }

/* ============================================================
   MODAL — image card (§12)
   ============================================================ */
.modal {
  position: fixed; inset: 0; z-index: 80;
  display: none;
  align-items: center; justify-content: center;
  padding: 28px;
}
.modal.open { display: flex; }
.modal__veil {
  position: absolute; inset: 0;
  background: rgba(6,7,9,0.74);
  backdrop-filter: blur(10px);
  animation: fade .3s var(--ease-out) both;
}
.modal__card {
  position: relative;
  width: 100%; max-width: 1040px;
  max-height: 90dvh;
  display: grid;
  grid-template-columns: 1.2fr 0.95fr;
  padding: 8px;
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-float);
  overflow: hidden;
  animation: pop .5s var(--ease-out) both;
}
@media (max-width: 820px) {
  .modal__card { grid-template-columns: 1fr; max-height: 92dvh; overflow: auto; }
}
.modal__media {
  position: relative;
  border-radius: calc(var(--radius-xl) - 8px);
  background: var(--bg-deep);
  border: 1px solid var(--hairline-soft);
  display: grid; place-items: center;
  overflow: hidden;
  min-height: 320px;
}
.modal__media img { width: 100%; height: 100%; object-fit: contain; max-height: 84dvh; }

/* Zoom/pan viewer: the .modal-media__zoom layer is the single transformed
   element. Promote it to its own GPU layer so wheel-zoom only re-composites
   an existing texture (matches the lineage-graph pan layer contract). */
.modal-media__zoom {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  transform-origin: 0 0;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  cursor: grab;
}
.modal-media__zoom img {
  /* image can drive the layer's box; keep it self-contained for the viewer */
  -webkit-user-drag: none; user-select: none; pointer-events: none;
}
/* grab affordance only once the image is actually zoomed (panning is useful) */
.modal__media.is-zoomed .modal-media__zoom { cursor: grab; }
.modal__media.grabbing,
.modal__media.grabbing .modal-media__zoom { cursor: grabbing; }
.modal__side {
  display: flex; flex-direction: column;
  padding: 24px 22px;
  overflow: auto;
  max-height: 84dvh;
}
.modal__close {
  position: absolute; top: 18px; right: 18px; z-index: 2;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--radius-pill);
  background: rgba(9,10,13,0.6);
  border: 1px solid var(--hairline);
  color: var(--text-soft);
  backdrop-filter: blur(6px);
  transition: all .3s var(--ease);
}
.modal__close:hover { color: var(--text); transform: rotate(90deg); border-color: var(--hairline-strong); }

.modal__side h3 { font-size: 18px; margin-bottom: 4px; }
.modal__btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 6px; }

/* variation switcher — thumbnails of every image in the open generation */
.var-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 2px;
}
.var-thumb {
  position: relative;
  width: 54px; height: 54px;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
  display: grid; place-items: center;
  color: var(--text-faint); font-size: 13px; font-weight: 700;
  transition: border-color .15s, transform .15s;
}
.var-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.var-thumb:hover { transform: translateY(-1px); border-color: var(--accent-line); }
.var-thumb.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.var-thumb--pending { color: var(--text-faint); }

.meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  margin-top: 18px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--hairline-soft);
  background: var(--hairline-soft);
}
.meta div { background: var(--surface); padding: 11px 13px; }
.meta dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-faint); }
.meta dd { margin: 3px 0 0; font-size: 13px; color: var(--text-soft); word-break: break-word; }

.detail {
  margin-top: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  background: var(--bg-deep);
  overflow: hidden;
}
.detail summary {
  list-style: none;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-soft);
  cursor: pointer;
}
.detail summary::-webkit-details-marker { display: none; }
.detail summary .spacer { flex: 1; }
.detail[open] summary { border-bottom: 1px solid var(--hairline-soft); }
.detail__body {
  padding: 13px 14px;
  font-size: 12.5px; line-height: 1.6;
  color: var(--text-soft);
  white-space: pre-wrap; word-break: break-word;
  max-height: 240px; overflow: auto;
}

/* ---------- Character description (free-text fields) ---------- */
.char-desc { margin-top: 18px; }
.char-desc__list { display: flex; flex-direction: column; gap: 10px; }
.char-desc__item {
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  background: var(--bg-deep);
  overflow: hidden;
}
.char-desc__bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline-soft);
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-faint);
}
.char-desc__bar .spacer { flex: 1; }
.char-desc__bar .char-desc__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-desc__val {
  padding: 12px 14px;
  font-size: 13.5px; line-height: 1.6;
  color: var(--text-soft);
  white-space: pre-wrap; word-break: break-word;
}

/* ============================================================
   HISTORY
   ============================================================ */
.history { margin-top: 40px; position: relative; z-index: 1; max-width: 1480px; margin-left: auto; margin-right: auto; padding: 0 26px; }
.history__head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.history__head h2 { font-size: 17px; }
.history__list { display: flex; flex-direction: column; gap: 10px; }
.hrow {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  transition: border-color .3s var(--ease), background .3s var(--ease);
  animation: rise .4s var(--ease-out) both;
}
.hrow:hover { border-color: var(--hairline); background: var(--surface-2); }
.hrow__main { flex: 1; min-width: 0; }
.hrow__prompt {
  font-size: 13.5px; color: var(--text-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hrow__meta { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }
.hrow__del {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--hairline-soft);
  color: var(--text-mute);
  transition: all .3s var(--ease);
}
.hrow__del:hover { color: var(--err); border-color: rgba(248,113,113,0.3); background: var(--err-soft); }
.hrow__del svg { width: 15px; height: 15px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  border: 1px solid var(--hairline);
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.status-pill[data-s="done"]    { color: var(--ok); border-color: rgba(74,222,128,0.3); }
.status-pill[data-s="done"] .dot { background: var(--ok); }
.status-pill[data-s="partial"] { color: var(--warn); border-color: rgba(251,191,36,0.3); }
.status-pill[data-s="partial"] .dot { background: var(--warn); }
.status-pill[data-s="failed"]  { color: var(--err); border-color: rgba(248,113,113,0.3); }
.status-pill[data-s="failed"] .dot { background: var(--err); }
.status-pill[data-s="pending"],
.status-pill[data-s="running"] { color: var(--accent-2); border-color: var(--accent-line); }
.status-pill[data-s="pending"] .dot,
.status-pill[data-s="running"] .dot { background: var(--accent); animation: pulse 1.3s ease-in-out infinite; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 10px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  background: rgba(22,25,31,0.92);
  backdrop-filter: blur(14px);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-float);
  font-size: 13.5px; color: var(--text);
  animation: toastin .4s var(--ease-out) both;
}
.toast--ok  { border-color: rgba(74,222,128,0.35); }
.toast--err { border-color: rgba(248,113,113,0.35); }

/* ---------- Animations ---------- */
@keyframes rise   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop    { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
@keyframes fade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin   { to { transform: rotate(360deg); } }
@keyframes pulse  { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes toastin{ from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   NEW CONTRACT ADDITIONS — category switch, managers, editors
   (same Ethereal-Glass language, dark-only)
   ============================================================ */

/* ---------- danger button ---------- */
.btn--danger {
  color: #fca5a5;
  background: var(--err-soft);
  border-color: rgba(248,113,113,0.28);
}
.btn--danger:hover {
  color: #fecaca;
  background: rgba(248,113,113,0.18);
  border-color: rgba(248,113,113,0.45);
}

/* ---------- topbar category switcher ---------- */
.cat-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 8px;
  padding: 5px 6px 5px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--hairline);
}
.cat-switch__label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-faint);
}
.cat-select-wrap { position: relative; }
.cat-select {
  width: auto; min-width: 150px; max-width: 240px;
  padding: 8px 34px 8px 12px;
  font-size: 13.5px; font-weight: 600;
  border-radius: var(--radius-pill);
  background-color: var(--bg-deep);
  background-position: right 12px center;
}
@media (max-width: 900px) {
  .cat-switch { order: 5; width: 100%; margin: 4px 0 0; }
  .cat-select { max-width: none; min-width: 0; flex: 1; }
}

/* ---- topbar on phones: brand + burger on top row, rest behind burger ---- */
@media (max-width: 640px) {
  .topbar { gap: 10px; padding: 10px 14px; }
  .topbar .brand span { display: none; }       /* hide "turnaround engine" tagline */
  .topbar__burger { display: grid; }

  /* the action cluster becomes a dropdown panel under the topbar */
  .topbar__menu {
    position: absolute;
    top: 100%; right: 10px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    min-width: 200px;
    margin-top: 8px;
    padding: 12px;
    border-radius: var(--radius-lg, 16px);
    background: var(--surface);
    border: 1px solid var(--hairline);
    box-shadow: var(--shadow-float);
    display: none;               /* hidden until burger toggles .is-open */
  }
  .topbar__menu.is-open { display: flex; }
  .topbar__menu .who { order: -1; padding-bottom: 4px; border-bottom: 1px solid var(--hairline-soft); }
  .topbar__menu .lang-switch { align-self: flex-start; }
  .topbar__menu .btn { width: 100%; justify-content: space-between; }
  .topbar__menu #logout-form .btn { width: 100%; }
}

/* count badge on feed tile */
.badge--count {
  left: auto; right: 10px;
  color: var(--text-soft);
  background: rgba(9,10,13,0.7);
  backdrop-filter: blur(6px);
}

/* ============================================================
   SHEET MODALS (managers / editors / edit)
   ============================================================ */
.sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  padding: 8px;
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-float);
  overflow: hidden;
  animation: pop .5s var(--ease-out) both;
}
.sheet--wide { max-width: 920px; }
.sheet--xl   { max-width: 1080px; }
.sheet__inner {
  padding: 30px 28px 26px;
  border-radius: calc(var(--radius-xl) - 8px);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), transparent 26%),
    var(--surface);
  border: 1px solid var(--hairline-soft);
  box-shadow: var(--inset-hi);
  max-height: calc(90dvh - 16px);
  overflow: auto;
}
@media (max-width: 640px) {
  .sheet { max-height: 94dvh; }
  .sheet__inner { padding: 24px 18px; }
}

/* image-card modal footer (move category) */
.modal__foot {
  display: flex; align-items: flex-end; gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline-soft);
}

/* ============================================================
   ROWS (model catalog / category manager)
   ============================================================ */
.cat-create {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin: 18px 0 6px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
}
.rows { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--hairline-soft);
  animation: rise .4s var(--ease-out) both;
}
.row:hover { border-color: var(--hairline); }
.row__cell { flex: 1 1 130px; min-width: 0; padding: 9px 11px; font-size: 13.5px; }
.row__cell--num { flex: 0 0 78px; width: 78px; padding: 9px 10px; font-size: 13.5px; }
.row__btn { flex: 0 0 auto; }
.row__chk {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-soft);
  flex: 0 0 auto;
}
.row__chk input { accent-color: var(--accent); }

/* category order controls */
.row--cat .row__order {
  display: flex; align-items: center; gap: 4px; flex: 0 0 auto;
}
.ord {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-size: 11px;
  color: var(--text-mute);
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  transition: all .3s var(--ease);
}
.ord:hover:not([disabled]) { color: var(--text); border-color: var(--hairline-strong); }
.ord[disabled] { opacity: .35; cursor: not-allowed; }

/* ============================================================
   IMAGE-EDIT dropzone + reference grid
   ============================================================ */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 26px 18px;
  text-align: center;
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--hairline-strong);
  background: rgba(255,255,255,0.015);
  color: var(--text-mute);
  cursor: pointer;
  transition: border-color .3s var(--ease), background .3s var(--ease), color .3s var(--ease);
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--text-soft);
}
.dropzone svg { color: var(--accent-2); }
.dropzone span { font-size: 13px; }

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.ref-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--hairline);
  background: var(--bg-deep);
  animation: pop .35s var(--ease-out) both;
}
.ref-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-rm {
  position: absolute; top: 5px; right: 5px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: var(--radius-pill);
  background: rgba(9,10,13,0.78);
  border: 1px solid var(--hairline);
  color: var(--text-soft);
  transition: all .25s var(--ease);
}
.ref-rm:hover { color: var(--err); border-color: rgba(248,113,113,0.4); }

/* ============================================================
   PROMPT-CONFIG VISUAL EDITOR
   ============================================================ */
.cfg-error {
  display: none;
  margin: 16px 0 4px;
  padding: 11px 14px;
  font-size: 13px;
  border-radius: var(--radius-md);
  background: var(--err-soft);
  border: 1px solid rgba(248,113,113,0.3);
  color: #fca5a5;
  white-space: pre-wrap;
}
.cfg-error.show { display: block; }

.cfg-tabs {
  display: flex; gap: 4px;
  margin: 18px 0 18px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
  width: fit-content;
}
.cfg-tab {
  padding: 8px 18px;
  font-size: 13px; font-weight: 600;
  color: var(--text-mute);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: all .35s var(--ease);
}
.cfg-tab:hover { color: var(--text-soft); }
.cfg-tab.active {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--hairline);
  box-shadow: var(--inset-hi);
}

.cfg-pane { animation: fade .3s var(--ease-out) both; }
.cfg-field { margin-bottom: 14px; }
.cfg-field > label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 7px;
}
.cfg-field textarea { min-height: 84px; }
.input.mono, textarea.mono {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px; letter-spacing: 0;
}

.cfg-axis {
  margin: 18px 0;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
}
.cfg-axis__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.cfg-axis__list { display: flex; flex-direction: column; gap: 10px; }
.cfg-pair {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 8px;
  align-items: start;
}
.cfg-pair__key { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.cfg-pair__text { min-height: 64px; }
.cfg-pair__del { align-self: stretch; padding: 0 12px; }
@media (max-width: 640px) {
  .cfg-pair { grid-template-columns: 1fr; }
  .cfg-pair__del { justify-self: end; }
}

.cfg-order { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.cfg-order__row { display: flex; align-items: center; gap: 6px; }
.cfg-order__row .input { flex: 1; }
.cfg-order__add { display: flex; gap: 8px; margin-top: 12px; }
.cfg-order__add .input { flex: 1; }

/* ============================================================
   LANGUAGE SWITCHER (RU | EN) — dark theme, matches segmented toggle
   ============================================================ */
.lang-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
}
.lang-opt {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-mute);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color .25s var(--ease), background .25s var(--ease), border-color .25s var(--ease);
}
.lang-opt:hover { color: var(--text-soft); }
.lang-opt.active {
  color: var(--accent-2);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

/* auth pages: brand row + lang switch on one line */
.auth-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

/* ============================================================
   PROMPT-CONFIG · axis labels editor (Подписи / Labels tab)
   ============================================================ */
.cfg-label-row {
  display: grid;
  grid-template-columns: 160px 1fr 1fr;
  gap: 8px;
  align-items: center;
}
.cfg-label-row__key {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cfg-label-row__field { display: flex; align-items: center; gap: 7px; }
.cfg-label-row__lang {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  min-width: 22px;
}
.cfg-label-row__field .input { flex: 1; min-width: 0; }
@media (max-width: 640px) {
  .cfg-label-row { grid-template-columns: 1fr; }
}

/* ============================================================
   GENERIC PROMPT-CONFIG EDITOR (dynamic fields)
   ============================================================ */
.cfg-add {
  display: grid;
  grid-template-columns: 130px 1fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin: 14px 0 18px;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
}
@media (max-width: 640px) {
  .cfg-add { grid-template-columns: 1fr; }
}

.cfg-fields { display: flex; flex-direction: column; gap: 14px; }

.cfg-card {
  border-radius: var(--radius-lg);
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
  overflow: hidden;
}
.cfg-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline-soft);
  background: var(--accent-soft);
}
.cfg-card__ord { display: flex; flex-direction: column; gap: 2px; }
.cfg-card__badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.cfg-card__keywrap { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; }
.cfg-card__keylab {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--text-faint); text-transform: uppercase;
}
.cfg-card__key { flex: 1; min-width: 0; font-size: 12.5px; }
.cfg-card__body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.cfg-chk {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-soft); cursor: pointer;
}
.cfg-card__opthead {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
}

.cfg-opts { display: flex; flex-direction: column; gap: 8px; }
.cfg-opt {
  display: grid;
  grid-template-columns: 160px 1fr 1.4fr auto;
  gap: 8px;
  align-items: start;
}
.cfg-opt__val { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
.cfg-opt__prompt { min-height: 56px; }
@media (max-width: 640px) {
  .cfg-opt { grid-template-columns: 1fr; }
}

/* dynamic generation form */
.gen-field { margin: 0 0 14px; }
.gen-field:last-child { margin-bottom: 0; }
.req-star { color: var(--accent-2); }

/* ============================================================
   PROJECTS — category = grid of project tiles
   ============================================================ */
/* leading icon variant (arrow before label) */
.btn__ico--lead { margin: -2px 2px -2px -8px; }
.btn:hover .btn__ico--lead { transform: translate(-2px, 0) scale(1.06); }

/* inline create-project form */
.proj-create {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin: 0 0 18px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
  animation: rise .35s var(--ease-out) both;
}

.proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
}

/* project tile: cover image + meta footer */
.proj-tile {
  position: relative;
  display: flex; flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform .5s var(--ease), border-color .4s var(--ease), box-shadow .4s var(--ease);
  animation: rise .5s var(--ease-out) both;
}
.proj-tile:hover {
  transform: translateY(-4px);
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-float);
}
.proj-tile__cover {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-deep);
  overflow: hidden;
}
.proj-tile__cover img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  opacity: 0;
  transition: opacity .6s var(--ease-out);
}
.proj-tile__cover img.loaded { opacity: 1; }
.proj-tile__placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-faint);
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.02) 0 12px, transparent 12px 24px),
    var(--bg-deep);
}
.proj-tile__placeholder svg { width: 34px; height: 34px; color: var(--text-faint); }
.proj-tile__foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--hairline-soft);
}
.proj-tile__name {
  flex: 1; min-width: 0;
  font-size: 14px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proj-tile__count {
  flex: 0 0 auto;
  padding: 3px 10px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--text-soft);
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  border: 1px solid var(--hairline);
}

/* project header bar (inside a project) */
.proj-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.proj-head .spacer { flex: 1; }

/* ============================================================
   PHASE 2 — operations, presets, lineage graph (dark theme)
   ============================================================ */

/* ----- operations block (image modal) ----- */
.ops { margin-top: 8px; }
.ops-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 6px 0 4px;
}
.ops-grid .ops-btn {
  padding: 8px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-pill);
  transition: transform .3s var(--ease), background .3s var(--ease), border-color .3s var(--ease);
}
.ops-grid .ops-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.ops-grid .ops-btn:active { transform: scale(0.97); }
.ops-grid .ops-btn[disabled] { opacity: .5; cursor: not-allowed; }
.ops-empty { font-size: 12.5px; color: var(--text-faint); padding: 4px 0; }

/* ----- clothing chips ----- */
.clothing { margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 5px 12px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
}
/* clickable clothing chip -> runs the "extract" operation */
.chip--action {
  display: inline-flex; align-items: center; gap: 7px;
  cursor: pointer; font-family: inherit; line-height: 1.2;
  transition: border-color .25s var(--ease), background .25s var(--ease), transform .2s var(--ease);
}
.chip--action:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--text);
  transform: translateY(-1px);
}
.chip--action:active { transform: translateY(0); }
.chip--action:disabled { opacity: .55; cursor: default; transform: none; }
.chip__action {
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--accent-2);
  padding-left: 7px;
  border-left: 1px solid var(--hairline);
}

/* ----- preset manager rows ----- */
.preset-create {
  display: grid;
  grid-template-columns: 150px 1fr 90px auto;
  gap: 8px; align-items: start;
  margin-top: 16px;
}
.preset-create textarea { grid-column: 1 / -1; min-height: 64px; }
.preset-create #new-catpre-prompt,
.preset-create #new-projpre-prompt { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .preset-create { grid-template-columns: 1fr; }
}
.row--preset { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; align-items: center; }
.row--preset .preset-prompt { grid-column: 1 / -1; min-height: 56px; }
.row--preset .preset-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.preset-tag {
  display: inline-block;
  padding: 2px 9px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  border-radius: var(--radius-pill);
  margin-left: 8px;
}
.preset-tag--inherited { color: var(--text-mute); border: 1px solid var(--hairline); }
.preset-tag--override  { color: var(--accent-2); border: 1px solid var(--accent-line); background: var(--accent-soft); }
.preset-tag--project   { color: var(--ok); border: 1px solid rgba(74,222,128,0.35); }
.row--preset.is-inherited { opacity: .85; }

/* ----- lineage graph ----- */
.graph-wrap {
  display: flex; flex-direction: column;
  margin-top: 18px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--hairline);
  background:
    radial-gradient(1200px 500px at 30% -10%, rgba(124,131,255,0.07), transparent 60%),
    var(--bg-deep);
  overflow: hidden;
}
.graph-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline-soft);
}
.graph-bar .spacer { flex: 1; }
.graph-canvas {
  position: relative;
  height: 62vh; min-height: 380px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;            /* we handle pan/pinch ourselves via Pointer Events */
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 32px 32px;
}
.graph-canvas.grabbing { cursor: grabbing; }
.graph-pan {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0;
  /* GPU compositing: promote the pan layer so zoom/pan only re-composites an
     existing texture instead of re-rasterising the heavy node images each step.
     JS writes translate3d(...) which keeps this layer hot. */
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}
.graph-svg {
  position: absolute; top: 0; left: 0;
  overflow: visible;
  pointer-events: none;
}
.graph-edge {
  fill: none;
  stroke: var(--accent-line);
  stroke-width: 2;
}
.graph-nodes { position: absolute; top: 0; left: 0; }
/* a generation BLOCK: header bar + a grid of variation thumbnails inside */
.graph-node {
  position: absolute;
  /* size (width/height) set inline by JS from blockGeom */
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform .35s var(--ease), border-color .3s var(--ease), box-shadow .3s var(--ease);
}
.graph-node:hover {
  transform: translateY(-3px);
  border-color: var(--accent-line);
  box-shadow: var(--shadow-float);
}
.graph-node.is-root { border-color: var(--accent-line); }
.graph-node.is-failed { border-color: rgba(255,107,107,0.4); }

.gnode__head {
  position: absolute; left: 0; right: 0; top: 0; height: 30px;
  display: flex; align-items: center; gap: 7px;
  padding: 0 12px;
  font-size: 11px;
}
.gnode__num { font-weight: 800; letter-spacing: 0.04em; color: var(--text); }
.gnode__count {
  font-weight: 700; color: var(--text-soft);
  padding: 1px 7px; border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.05); border: 1px solid var(--hairline);
}
.gnode__status {
  margin-left: auto;
  padding: 1px 8px; border-radius: var(--radius-pill);
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: lowercase;
  color: var(--text-soft); background: rgba(9,10,13,0.6); border: 1px solid var(--hairline);
}
.gnode__status.is-failed { color: var(--fail, #ff6b6b); border-color: rgba(255,107,107,0.4); background: rgba(40,12,12,0.6); }
.gnode__root {
  margin-left: auto;
  padding: 1px 8px; border-radius: var(--radius-pill);
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-2); background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.gnode__count + .gnode__root, .gnode__count + .gnode__status { margin-left: auto; }

.gnode-thumb {
  position: absolute;
  border-radius: 9px;
  overflow: hidden;
  background: var(--bg-deep);
  border: 1px solid var(--hairline);
  display: grid; place-items: center;
}
.gnode-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .45s var(--ease-out); }
.gnode-thumb img.loaded { opacity: 1; }
.gnode-thumb:hover { border-color: var(--accent-line); }
.gnode-thumb__ph { color: var(--text-faint); font-size: 13px; font-weight: 700; display: grid; place-items: center; }
/* a variation that has descendants: accent ring + outgoing port dot */
.gnode-thumb--parent { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 14px -2px var(--accent); }
.gnode-thumb__port {
  position: absolute; right: -6px; top: 50%; transform: translateY(-50%);
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
  z-index: 3; pointer-events: none;
}
.gnode-thumb.is-failed { border-color: rgba(255,107,107,0.4); }
.gnode-thumb.is-failed .gnode-thumb__ph { color: var(--fail, #ff6b6b); }
.graph-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-faint); font-size: 14px;
  text-align: center; padding: 24px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===== breadcrumbs + clickable logo ===== */
.brand[role="button"] { cursor: pointer; user-select: none; }
.brand[role="button"]:hover .logo { filter: brightness(1.15); }
.brand[role="button"]:focus-visible { outline: 2px solid var(--accent, #7c83ff); outline-offset: 3px; border-radius: 10px; }
.crumbs {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 14px; font-size: 13px; line-height: 1;
}
.crumbs__link {
  background: none; border: 0; padding: 4px 6px; margin: 0; cursor: pointer;
  color: var(--muted, #8b90a0); font: inherit; border-radius: 7px;
  transition: color .15s, background .15s;
}
.crumbs__link:hover { color: var(--text, #e7e9f0); background: rgba(255,255,255,.05); }
.crumbs__current { color: var(--text, #e7e9f0); font-weight: 600; padding: 4px 2px; }
.crumbs__sep { color: var(--muted, #555a68); opacity: .6; }
