/* ==========================================================================
   OpenBAS app shell — dashboard, generator, library, standard, billing.

   Loads after styles.css and reuses its tokens. The screens come from
   design/Component Studio.dc.html (02–05); the palette is the dark
   control-room direction the storefront already ships.
   ========================================================================== */

:root {
  --rail:       264px;
  --agent:      448px;
  --topbar-h:   61px;
}

/* ================================================================ shell == */

.app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  background: var(--bg-alt);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px 16px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.rail__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 0;
  color: var(--text);
}
.rail__brand:hover { color: var(--text); }

.rail__group { display: flex; flex-direction: column; gap: 8px; }

.rail__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .14em;
  color: var(--text-muted);
  padding: 0 8px;
}

.rail__nav { display: flex; flex-direction: column; gap: 2px; }

.rail__link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-muted);
  transition: background-color .15s ease, color .15s ease;
}
.rail__link svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; }
.rail__link:hover { background: var(--surface); color: var(--text-dim); }
.rail__link[aria-current="page"],
.rail__link[aria-current="true"] {
  background: var(--accent-tint-3);
  color: var(--accent-light);
}
.rail__link .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.rail__link[aria-current="page"] .count,
.rail__link[aria-current="true"] .count { color: var(--accent-light); }

.rail__foot { margin-top: auto; }

.plan-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.plan-card__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.plan-card__name { font-size: 14px; font-weight: 600; }
.plan-card__count { font-family: var(--font-mono); font-size: 11px; color: var(--accent-light); }
.plan-card__note { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); letter-spacing: .04em; }

/* Usage meter */
.meter {
  height: 5px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.meter__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.meter--lg { height: 8px; }

/* ------------------------------------------------------------- main ---- */

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 26px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--line);
  min-height: var(--topbar-h);
}

.crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  min-width: 0;
}
.crumb__sep { color: var(--line-strong); }
.crumb__parent { color: var(--text-muted); }
.crumb__current { font-weight: 600; }
.crumb__id { font-family: var(--font-mono); font-size: 14px; }

.topbar__meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.topbar__actions { display: flex; align-items: center; gap: 10px; flex: none; }

.page { padding: 26px; display: flex; flex-direction: column; gap: 24px; }
.page--flush { padding: 0; gap: 0; flex: 1; min-height: 0; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.page-title { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.page-sub { font-size: 14px; color: var(--text-muted); margin-top: 5px; }

/* ============================================================= widgets == */

.tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.tile {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 7px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.tile__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--text-muted);
}
.tile__value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.tile__value small { font-size: 15px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; }

/* "62 / 300" — the allowance rides at the same baseline as the count but
   reads as context, not as part of the figure. */
.tile__of {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0;
}
.tile__note { font-size: 13px; color: var(--text-muted); }

.panel {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
}
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel__title { font-size: 15px; font-weight: 600; }
.panel__body { padding: 18px; }
.panel__body--flush { padding: 0; }

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

/* Lists */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
}
.row:last-child { border-bottom: 0; }
a.row:hover { background: var(--surface-2); color: var(--text); }
.row__main { min-width: 0; flex: 1; }
.row__name { display: block; font-size: 14px; font-weight: 500; }
.row__meta { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); letter-spacing: .04em; margin-top: 3px; }
.row__side { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); flex: none; }

.thumb {
  width: 76px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 4px;
  flex: none;
  padding: 4px;
  background: var(--surface-2);
}
.thumb svg { width: 100%; height: 100%; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  padding: 4px 9px;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--text-dim);
}
.badge--ok { background: var(--accent-tint-2); color: var(--accent-light); }
.badge--warn { background: var(--amber-tint); color: var(--amber); }
.badge--alarm { background: var(--alarm-tint); color: #FF8D82; }

/* Buttons sized for the app chrome */
.btn--app { font-size: 14px; padding: 9px 15px; border-radius: 6px; }

/* ============================================================ generator == */

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--agent);
  flex: 1;
  min-height: 0;
}

.stage-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line);
}

.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-alt);
  flex-wrap: wrap;
}

.seg { display: flex; gap: 4px; }
.seg button {
  font-size: 13px;
  padding: 7px 13px;
  border-radius: 5px;
  color: var(--text-muted);
  transition: background-color .15s ease, color .15s ease;
}
.seg button:hover { color: var(--text-dim); }
.seg button[aria-selected="true"],
.seg button[aria-pressed="true"] { background: var(--accent-tint-3); color: var(--accent-light); }
.seg button[aria-selected="true"][data-state-value="alarm"] { background: var(--alarm-tint); color: #FF8D82; }
.seg--ghost button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }

.seg__add {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 7px 11px;
  border: 1px dashed var(--line-strong);
  border-radius: 5px;
  color: var(--text-muted);
}
.seg__add:hover { color: var(--text-dim); border-color: var(--text-muted); }

.stage {
  flex: 1;
  min-height: 300px;
  padding: 30px 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.stage svg { width: 100%; max-width: 900px; height: auto; }
.stage__render { max-width: min(100%, 620px); height: auto; display: block; }

.msg--pending .msg__bubble { color: var(--accent-light); border-color: var(--accent-edge); }
.msg--pending .msg__bubble::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .25 } 50% { opacity: 1 } }

.msg--error .msg__bubble { border-color: var(--alarm); color: #FF8D82; background: var(--alarm-tint); }

.stage-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg-alt);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* Draw-style variants applied to the canvas. Geometry is unchanged — these
   are the same four treatments the variant strip offers. */
[data-variant="thin"] .dw-body,
[data-variant="thin"] .dw-coil { fill: none; }
[data-variant="thin"] svg [stroke-width] { stroke-width: 1.2; }
[data-variant="thin"] .dw-hair { opacity: .5; }

[data-variant="shaded"] .dw-body { fill: #1B2126; }
[data-variant="shaded"] .dw-hair { stroke: #333B41; }

.variants {
  border-top: 1px solid var(--line);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-alt);
}
.variants__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.variants__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.variant {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  transition: border-color .15s ease;
}
.variant:hover { border-color: var(--line-strong); }
.variant[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint-4); }
.variant svg { width: 100%; height: auto; }
.variant__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--text-muted);
}
.variant[aria-pressed="true"] .variant__label { color: var(--accent-light); }

/* Agent panel */

.agent {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-alt);
}

.agent__tabs {
  display: flex;
  gap: 2px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.agent__tabs button {
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 5px;
  color: var(--text-muted);
}
.agent__tabs button:hover { color: var(--text-dim); }
.agent__tabs button[aria-selected="true"] { background: var(--surface-3); color: var(--text); }

.agent__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.msg { display: flex; flex-direction: column; gap: 8px; max-width: 100%; }
.msg__bubble {
  font-size: 14px;
  line-height: 1.55;
  padding: 12px 14px;
  border-radius: 8px;
}
.msg--user .msg__bubble {
  background: var(--surface-3);
  color: var(--text);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.msg--agent .msg__bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-bottom-left-radius: 3px;
}
.msg--user { align-items: flex-end; }


.msg__actions { display: flex; gap: 8px; }
.msg__actions button {
  font-size: 12px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--text-dim);
}
.msg__actions button:hover { border-color: var(--text-muted); color: var(--text); }
.msg__actions button.is-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.msg__actions button.is-primary:hover { background: var(--accent-light); }

.composer {
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.composer__opts {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
}
.composer__opt {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--text-muted);
}
/* Shown to Starter in place of the size controls it does not have. */
.composer__lock {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--text-dim);
  align-self: center;
}
.composer__lock a { color: var(--accent); }

.composer__opt input[type="number"] {
  width: 62px;
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 6px;
}

.composer__opt select {
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 8px;
}

.composer__box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 10px 10px 14px;
}
.composer__box:focus-within { border-color: var(--accent); }
.composer__box textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  max-height: 140px;
  min-height: 22px;
  overflow-y: hidden;      /* JS sizes it; the bar only returns at max-height */
}
.composer__box textarea.is-full { overflow-y: auto; }
.composer__box textarea::placeholder { color: var(--text-muted); }
.composer__send {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex: none;
}
.composer__send:hover { background: var(--accent-light); }

.composer__modes { display: flex; gap: 6px; }
.composer__modes button {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--text-muted);
}
.composer__modes button[aria-pressed="true"] { border-color: var(--line-strong); color: var(--text); }

.composer__hint {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-left: auto;
}

/* Properties tab panes */
.pane { display: flex; flex-direction: column; gap: 16px; }
.pane[hidden] { display: none; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--text-muted);
}
.field input[type="text"],
.field input[type="number"],
.field select {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  width: 100%;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }

.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px 14px;
  font-size: 13px;
}
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--font-mono); font-size: 12px; }

/* ============================================================== library == */

.lib-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.search {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 8px 12px;
  flex: 1;
  min-width: 200px;
  max-width: 380px;
}
.search:focus-within { border-color: var(--accent); }
.search input {
  border: 0;
  outline: none;
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  width: 100%;
}
.search input::placeholder { color: var(--text-muted); }
.search svg { width: 15px; height: 15px; stroke: var(--text-muted); fill: none; stroke-width: 1.6; flex: none; }

.select {
  font: inherit;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 11px;
}
.select:focus { outline: none; border-color: var(--accent); }

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.asset {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 7px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
  transition: border-color .15s ease;
}
.asset:hover { border-color: var(--line-strong); }
.asset[hidden] { display: none; }
.asset__art { padding: 18px; border-bottom: 1px solid var(--line); }
.asset__art svg { width: 100%; height: auto; }
.asset__body { padding: 13px 15px; display: flex; flex-direction: column; gap: 6px; }
.asset__name {
  font-size: 14px;
  font-weight: 500;
  /* A generated component's name is whatever the engineer typed, which can be
     a full sentence. Clamp it so one long prompt cannot set the row height. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.asset__art { display: flex; align-items: center; justify-content: center; min-height: 120px; }
.asset__art img { max-height: 150px; width: auto; max-width: 100%; }
.asset__meta { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); letter-spacing: .04em; }

.asset--new {
  border: 1px dashed var(--line-strong);
  background: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 20px;
  text-align: center;
  min-height: 190px;
  color: var(--text-muted);
}
.asset--new .plus {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--accent-light);
}
.asset--new:hover { border-color: var(--accent); color: var(--text-dim); }

/* ================================================== option chips == */
/* Used by the catalogue picker's per-item options. */

.chip-set { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-toggle {
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.chip-toggle:hover { border-color: var(--line-strong); color: var(--text-dim); }
.chip-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-tint-4);
  color: var(--text);
}
.chip-toggle .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
}
.chip-toggle[aria-pressed="true"] .dot { background: var(--accent); }


/* ============================================================== billing == */

.invoice-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.invoice-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .1em;
  color: var(--text-muted);
  padding: 0 18px 10px;
  border-bottom: 1px solid var(--line);
}
.invoice-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--text-dim);
}
.invoice-table tr:last-child td { border-bottom: 0; }
.invoice-table td:last-child, .invoice-table th:last-child { text-align: right; }
.invoice-table .amount { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.callout {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.callout--accent { border-color: var(--accent-edge); background: var(--accent-tint); }
.callout__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--accent-light);
}
.callout__title { font-size: 17px; font-weight: 600; }
.callout p { font-size: 14px; line-height: 1.6; color: var(--text-muted); }

.card-line {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}
.card-line__chip {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  letter-spacing: .1em;
}

/* ========================================================== breakpoints == */

@media (max-width: 1240px) {
  :root { --agent: 380px; }
  .variants__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 20px;
  }
  .rail__group--secondary { display: none; }
  .rail__nav { flex-direction: row; flex-wrap: wrap; }
  .rail__label { display: none; }
  .rail__foot { margin-top: 0; margin-left: auto; }
  .plan-card { flex-direction: row; align-items: center; gap: 14px; padding: 9px 14px; }
  .plan-card .meter, .plan-card__note { display: none; }

  .studio { grid-template-columns: 1fr; }
  .stage-col { border-right: 0; border-bottom: 1px solid var(--line); }
  .agent { min-height: 520px; }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 12px 18px; }
  .topbar__meta { order: 3; flex-basis: 100%; }
  .page { padding: 18px; }
  .variants__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invoice-table th:nth-child(2), .invoice-table td:nth-child(2) { display: none; }
}

/* ============================================================== empty == */

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 44px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.empty__title { font-size: 19px; font-weight: 600; }
.empty__body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-muted);
  max-width: 460px;
  text-wrap: pretty;
}
.empty__body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--text-dim);
}
.empty .btn { margin-top: 6px; }
.empty--warn { border-color: var(--amber); }
.empty--warn .empty__title { color: var(--amber); }

.stage-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: var(--text-muted);
  padding: 40px 24px;
}
.stage-empty__title { font-size: 16px; font-weight: 500; color: var(--text-dim); }
.stage-empty__body { font-size: 14px; max-width: 340px; line-height: 1.6; }


/* =========================================================== references == */

.composer__attach {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: border-color .15s ease, color .15s ease;
}
.composer__attach svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; }
.composer__attach:hover { border-color: var(--line-strong); color: var(--text-dim); }
.composer__attach[aria-disabled="true"] { opacity: .4; cursor: not-allowed; }

.refs { display: flex; gap: 8px; flex-wrap: wrap; }

.ref {
  position: relative;
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
  flex: none;
}
.ref img { width: 100%; height: 100%; object-fit: contain; }
.ref__del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(8, 9, 11, .85);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ref__del:hover { background: var(--alarm); color: #fff; }
.ref__badge {
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .08em;
  text-align: center;
  padding: 2px 0;
  background: rgba(8, 9, 11, .8);
  color: var(--accent-light);
}

.composer.is-dropping .composer__box {
  border-color: var(--accent);
  background: var(--accent-tint-4);
}

.msg__refs { display: flex; gap: 6px; flex-wrap: wrap; }
.msg__refs img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-2);
}

/* ====================================================== fixed workspace == */
/* The generator is a workspace, not a document: the shell is pinned to the
   viewport and each pane scrolls inside it. Without this the panes have no
   bounded parent, so `overflow-y: auto` never engages — the transcript just
   grows and drags the whole page down with it.
   Only above the stacking breakpoint; below it the studio is a normal column
   and the page should scroll as usual. */

@media (min-width: 1081px) {
  .app--fixed { height: 100vh; min-height: 0; overflow: hidden; }
  .app--fixed .main,
  .app--fixed .page--flush,
  .app--fixed .studio,
  .app--fixed .agent { min-height: 0; }

  /* Stage column carries the canvas, tools and variant strip. */
  .app--fixed .stage-col { min-height: 0; overflow-y: auto; }

  /* A flex child defaults to min-height:auto, which refuses to shrink below
     its content — the transcript needs the explicit 0 to become scrollable. */
  .app--fixed .agent__scroll { min-height: 0; }
}

/* ============================================================== picker == */

.picker {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 320px;
}
.picker .search { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; max-width: none; }

.picker__list { overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 1px; }

.picker__group {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--text-muted);
  padding: 10px 8px 4px;
}
.picker__item {
  text-align: left;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 10px;
}
.picker__item:hover, .picker__item:focus-visible { background: var(--surface-3); color: var(--text); }
.picker__item .view {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}
.picker__none { padding: 16px 10px; font-size: 13px; color: var(--text-muted); text-align: center; }

/* The chosen item, shown instead of a wall of prose */
.pick {
  border: 1px solid var(--accent-edge);
  border-radius: 8px;
  background: var(--accent-tint-4);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.pick__head { display: flex; align-items: center; gap: 10px; }
.pick__name { font-size: 14px; font-weight: 500; }
.pick__clear {
  margin-left: auto;
  width: 20px; height: 20px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
}
.pick__clear:hover { background: var(--alarm-tint); color: #FF8D82; }
.pick .chip-toggle { font-size: 12px; padding: 5px 10px; }
.pick .chip-toggle .dot { width: 6px; height: 6px; }

#tool-status { margin-left: 4px; }

/* =========================================================== lib viewer == */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.viewer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 9, .82);
  backdrop-filter: blur(2px);
}

.viewer__panel {
  position: relative;
  width: min(1080px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}

.viewer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.viewer__name {
  font-size: 17px;
  font-weight: 600;
  /* A free-text component carries whatever the engineer typed. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.viewer__meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-top: 5px;
}
.viewer__close {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  flex: none;
}
.viewer__close:hover { background: var(--surface-3); color: var(--text); }

.viewer__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 272px;
  min-height: 0;
  flex: 1;
}

.viewer__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  min-height: 320px;
  border-right: 1px solid var(--line);
}
.viewer__stage img {
  max-width: 100%;
  max-height: 56vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.viewer__side {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.viewer__side .seg { flex-wrap: wrap; }

.viewer__downloads {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.viewer__downloads .btn { margin-top: 0; }

@media (max-width: 860px) {
  .viewer { padding: 14px; }
  .viewer__body { grid-template-columns: 1fr; }
  .viewer__stage { border-right: 0; border-bottom: 1px solid var(--line); min-height: 240px; }
  .viewer__stage img { max-height: 38vh; }
}

/* The grid cards are buttons; make that legible. */
.asset[type="button"] { cursor: pointer; }

/* ============================================================== account == */
/* One card, centred, no rail — signing in is not part of the workspace. */

.account {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--bg);
}
.account__card {
  width: 100%;
  max-width: 420px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: visible;
}
.account__brand { align-self: flex-start; }
.account__modes { align-self: stretch; }
.account__modes button { flex: 1; }

.account__title { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.account__sub { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.account__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}
.account__form input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
}
.account__form input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.account__submit { width: 100%; }

.account__error { font-size: 13px; color: var(--danger, #ff6b6b); line-height: 1.5; }
.account__note  { font-size: 13px; color: var(--accent-light); line-height: 1.5; }

.account__link {
  align-self: flex-start;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.account__link:hover { color: var(--text); }

.account__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ----------------------------------------------------------------- offers --
   Two plans side by side, each with its own price and its own button. This
   replaced a segmented toggle, which was the wrong control once a plan became
   something bought: a toggle says "pick a side" and implies the switch is free
   and instant, and neither is true of a subscription.

   Called "offer" and not "plan-card" because .plan-card is already the live
   component counter in the sidebar of three pages — and the first version of
   this quietly restyled all of them. */
.offer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.offer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--edge);
  border-radius: 10px;
}

.offer--current { border-color: var(--accent-edge); background: var(--accent-tint); }

.offer__name { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }

.offer__price { font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.offer__price small {
  font-size: 13px; font-weight: 500; color: var(--text-muted); letter-spacing: 0;
}

.offer__note { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

.offer__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.offer__list li {
  font-size: 13px; line-height: 1.5; color: var(--text-muted);
  padding-left: 16px; position: relative;
}
.offer__list li::before {
  content: ""; position: absolute; left: 2px; top: 8px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}

.offer .btn { margin-top: auto; justify-content: center; }

/* --------------------------------------------------------------- iconbtn --
   A square, quiet button for an action that needs no label — sign out lives
   in the top right of every app page and an icon is enough. Given a real
   title and aria-label, because "an icon is enough" is only true for people
   who can see it. */
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}

.iconbtn:hover { color: var(--text); border-color: var(--edge-strong, var(--edge)); background: var(--surface-2, transparent); }
.iconbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.iconbtn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
