/* Winston V3 — Universe editor (Power mode). Strategy lab. */

#screen-universe .universe-header h1 { margin: 0; }

#screen-universe .universe-sleeves {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-5) 0 var(--space-3);
  border-bottom: 1px solid var(--border);
}
#screen-universe .universe-sleeve-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: var(--space-2) var(--space-4);
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: var(--type-sm);
  font-weight: var(--weight-medium);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
#screen-universe .universe-sleeve-tab-name {
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
#screen-universe .universe-sleeve-tab-sub {
  font-size: var(--type-xs);
  text-transform: none;
  letter-spacing: 0;
  margin-top: 2px;
}
#screen-universe .universe-sleeve-tab:hover { color: var(--ink); }
#screen-universe .universe-sleeve-tab.is-active {
  color: var(--ai);
  border-bottom-color: var(--ai);
  font-weight: var(--weight-semi);
}
/* Dirty-dot must NOT be the danger / mode-live red — that color is
   reserved for Emergency Stop. Use the brand teal so the operator's
   color-pattern stays coherent (dirty = "needs your attention", not
   "danger"). */
#screen-universe .universe-dirty-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ai);
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Resolved-universe panel (top of tab) ─────────────────────── */
#screen-universe .uv-resolved {
  margin-bottom: var(--space-4);
}
#screen-universe .uv-resolved-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
#screen-universe .uv-resolved-eyebrow {
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  font-size: var(--type-xs);
  font-weight: var(--weight-bold);
  color: var(--ink-muted);
}
#screen-universe .uv-resolved-stale {
  font-size: var(--type-xs);
  color: var(--ink-faint);
}
#screen-universe .uv-resolved-stale[data-state="stale"] {
  color: var(--money-up);
  background: var(--money-up-soft);
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
}
#screen-universe .uv-resolved-counts {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
#screen-universe .uv-resolved-stat {
  display: flex;
  flex-direction: column;
}
#screen-universe .uv-resolved-stat-num {
  font-size: var(--type-xl);
  font-weight: var(--weight-bold);
  line-height: 1;
}
#screen-universe .uv-resolved-stat-label {
  font-size: var(--type-xs);
  color: var(--ink-muted);
  margin-top: 2px;
}
#screen-universe .uv-resolved-rej {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
  font-size: var(--type-xs);
  color: var(--ink-muted);
  margin-bottom: var(--space-3);
}
#screen-universe .uv-resolved-rej-chip {
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--ink-muted);
  font-family: var(--font-mono);
}
#screen-universe .uv-resolved-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--type-sm);
}
#screen-universe .uv-resolved-table th {
  text-align: left;
  font-size: var(--type-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-muted);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--hairline);
}
#screen-universe .uv-resolved-table th.num,
#screen-universe .uv-resolved-table td.num { text-align: right; }
#screen-universe .uv-resolved-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--hairline);
}
#screen-universe .uv-resolved-table tr:last-child td { border-bottom: none; }
#screen-universe .uv-resolved-symbols {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}
#screen-universe .uv-resolved-symbols .uv-chip[data-readonly] {
  background: var(--surface-2);
  color: var(--ink);
}

/* ── Form ─────────────────────────────────────────────────────── */
#screen-universe .uv-field {
  margin-bottom: var(--space-5);
}
#screen-universe .uv-label {
  display: block;
  font-size: var(--type-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--ink-muted);
  margin-bottom: var(--space-2);
}
#screen-universe .uv-hint {
  display: block;
  font-weight: var(--weight-regular);
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--type-xs);
  color: var(--ink-faint);
  margin-top: 2px;
}
#screen-universe .uv-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-3);
}
#screen-universe .uv-row .uv-label { margin: 0; }

#screen-universe .ticket-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--type-sm);
  background: var(--surface);
  font-family: var(--font-mono);
}
#screen-universe .ticket-input:focus {
  outline: 2px solid var(--ai-soft);
  border-color: var(--ai);
}

/* Sector chip picker (multi-select) */
#screen-universe .uv-sector-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 44px;
}
#screen-universe .uv-sector-chip {
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--ink-muted);
  font-size: var(--type-xs);
  font-weight: var(--weight-medium);
  border: 1px solid transparent;
  cursor: pointer;
}
#screen-universe .uv-sector-chip:hover {
  background: var(--ai-soft);
  color: var(--ai);
}
#screen-universe .uv-sector-chip.is-active {
  background: var(--ai-soft);
  color: var(--ai);
  border-color: var(--ai);
  font-weight: var(--weight-semi);
}

#screen-universe .uv-chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 44px;
}
#screen-universe .uv-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--ai-soft);
  color: var(--ai);
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  font-weight: var(--weight-semi);
}
#screen-universe .uv-chip button {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: transparent;
  color: var(--ai);
  font-size: 14px;
  line-height: 1;
}
#screen-universe .uv-chip button:hover { background: var(--ai); color: var(--ink-inverse); }
#screen-universe .uv-chip-text {
  flex: 1;
  min-width: 100px;
  border: none;
  background: transparent;
  padding: 2px;
  font-family: var(--font-mono);
  font-size: var(--type-sm);
}
#screen-universe .uv-chip-text:focus { outline: none; }

#screen-universe .uv-inline-warn {
  color: var(--money-down);
  font-size: var(--type-xs);
  margin: 0;
}

#screen-universe .uv-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

/* Stored-config collapsible */
#screen-universe .uv-raw {
  margin-top: var(--space-4);
}
#screen-universe .uv-raw-summary {
  cursor: pointer;
  font-size: var(--type-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--ink-muted);
  padding: var(--space-2) 0;
  list-style: none;
}
#screen-universe .uv-raw-summary::-webkit-details-marker { display: none; }
#screen-universe .uv-raw-summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s;
}
#screen-universe .uv-raw[open] .uv-raw-summary::before {
  transform: rotate(90deg);
}
#screen-universe .uv-json {
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  background: var(--surface-2);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  overflow-x: auto;
  margin: 0;
  max-height: 400px;
  overflow-y: auto;
}

/* Save-confirm diff — rendered inside the modal body */
.uv-diff {
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow-x: auto;
}
.uv-diff-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 180px) 1fr auto 1fr;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  align-items: baseline;
  border-bottom: 1px solid var(--hairline);
}
.uv-diff-row:last-child { border-bottom: none; }
.uv-diff-row[data-kind="add"]    { background: var(--money-up-soft); }
.uv-diff-row[data-kind="remove"] { background: var(--money-down-soft); }
.uv-diff-row[data-kind="change"] { background: var(--mode-live-soft); }
.uv-diff-mark { font-weight: var(--weight-bold); }
.uv-diff-row[data-kind="add"]    .uv-diff-mark { color: var(--money-up); }
.uv-diff-row[data-kind="remove"] .uv-diff-mark { color: var(--money-down); }
.uv-diff-row[data-kind="change"] .uv-diff-mark { color: var(--mode-live); }

.uv-diff-row.uv-diff-list {
  grid-template-columns: 16px minmax(0, 180px) 1fr;
}
.uv-diff-list-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-family: var(--font-body);
}
.uv-diff-list-counts {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.uv-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--type-xs);
  font-weight: var(--weight-semi);
}
.uv-pill[data-kind="add"]    { background: var(--money-up-soft);   color: var(--money-up); }
.uv-pill[data-kind="remove"] { background: var(--money-down-soft); color: var(--money-down); }
.uv-pill[data-kind="keep"]   { background: var(--surface-2);       color: var(--ink-muted); }
.uv-diff-list-samples {
  font-size: var(--type-xs);
  line-height: var(--leading-base);
  word-break: break-word;
}

/* Mobile: collapse 2-column form rows to stacked. Below ~480px the
   200px label column eats >50% of the viewport. */
@media (max-width: 480px) {
  #screen-universe .uv-row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
  #screen-universe .uv-resolved-counts {
    gap: var(--space-3);
  }
  #screen-universe .uv-resolved-stat-num {
    font-size: var(--type-lg);
  }
  #screen-universe .universe-sleeve-tab {
    padding: var(--space-2) var(--space-3);
  }
  #screen-universe .universe-sleeve-tab-sub {
    display: none;
  }
}

/* Tracker #141 M3 — saved presets strip above the form. */
#screen-universe .uv-presets {
  padding: var(--space-2) var(--space-3);
}
#screen-universe .uv-preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
#screen-universe .uv-preset-x {
  padding: 4px 8px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-size: 14px;
  cursor: pointer;
}
#screen-universe .uv-preset-x:hover { background: var(--surface-hover); color: var(--money-down); }

/* ── Universe FORM classes, un-scoped (2026-06-01) ──────────────────────────────
   The per-playbook universe editor now renders OUTSIDE #screen-universe — in
   Engines → Playbook (#screen-engines, engine/universe-editor.js) and the full
   editor (#screen-playbooks, screens/playbooks.js). The rules above are
   #screen-universe-scoped, so the chips / sector picker / rows / inputs were
   unstyled in those homes. Re-declare the FORM classes un-scoped: lower
   specificity than the scoped rules, so the standalone screen is unaffected. */
.uv-field { margin-bottom: var(--space-5); }
.uv-label {
  display: block;
  font-size: var(--type-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  color: var(--ink-muted);
  margin-bottom: var(--space-2);
}
.uv-hint {
  display: block;
  font-weight: var(--weight-regular);
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--type-xs);
  color: var(--ink-faint);
  margin-top: 2px;
}
.uv-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-3);
}
.uv-row .uv-label { margin: 0; }
.uv-sector-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 44px;
}
.uv-sector-chip {
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--ink-muted);
  font-size: var(--type-xs);
  font-weight: var(--weight-medium);
  border: 1px solid transparent;
  cursor: pointer;
}
.uv-sector-chip:hover { background: var(--ai-soft); color: var(--ai); }
.uv-sector-chip.is-active {
  background: var(--ai-soft);
  color: var(--ai);
  border-color: var(--ai);
  font-weight: var(--weight-semi);
}
.uv-chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-height: 44px;
}
.uv-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--ai-soft);
  color: var(--ai);
  font-family: var(--font-mono);
  font-size: var(--type-xs);
  font-weight: var(--weight-semi);
}
.uv-chip button {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: transparent;
  color: var(--ai);
  font-size: 14px;
  line-height: 1;
}
.uv-chip button:hover { background: var(--ai); color: var(--ink-inverse); }
.uv-chip-text {
  flex: 1;
  min-width: 100px;
  border: none;
  background: transparent;
  padding: 2px;
  font-family: var(--font-mono);
  font-size: var(--type-sm);
}
.uv-chip-text:focus { outline: none; }
.uv-inline-warn { color: var(--money-down); font-size: var(--type-xs); margin: 0; }
/* Mobile: collapse the 200px-label uv-row to a single column (mirrors the
   #screen-universe rule, which doesn't reach the editor in its new homes —
   Engines → Playbook + the full editor). Without this the label column squeezes
   the inputs on a phone. */
@media (max-width: 480px) {
  .uv-row { grid-template-columns: 1fr; gap: var(--space-1); }
}

/* Side-by-side universe config | Morning-screen output (Engines swing playbook).
   auto-fit + minmax is container-responsive: two columns when there's room
   (~720px+), collapsing to a single stacked column on a narrow pane/phone without
   a viewport media query (the sidebar eats real width, so container-relative is
   more honest than a viewport breakpoint). align-items:start keeps the shorter
   card its natural height instead of stretching to match the taller one. */
.uv-split {
  display: grid;
  /* min(360px, 100%) — NOT a bare 360px — so the single column on a narrow pane
     (390px phone, content < 360px) shrinks to fit instead of forcing horizontal
     overflow. The 360px floor only applies when there's room for it. */
  grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  gap: var(--space-4);
  align-items: start;
}
.uv-split-col { min-width: 0; }   /* let long rows wrap instead of blowing out the track */

/* Equal-height split with internal scroll (swing + scalp Playbook → Universe).
   Side-by-side, the config card and the morning-screen card grow to different
   heights, leaving one with a long trail of whitespace. Pin them to one shared
   height cap so they read as a single balanced row, and let the long content —
   the universe field list on the left, the screen's picked names on the right —
   scroll INSIDE each card instead of stretching the whole section.

   The cap + scroll apply ONLY while the two columns are actually side-by-side: a
   container query on the same ~736px (2×360px + 16px gap) threshold the auto-fit
   grid above collapses at. Below it the layout is a single stacked column, where
   capping each card and nesting a scroll would be hostile on a phone — so there
   the cards keep their natural height and the page scrolls as before. */
.uv-split { container-type: inline-size; container-name: uv-split; }

@container uv-split (min-width: 736px) {
  /* Override the base `align-items: start` so both columns take the row height. */
  .uv-split { align-items: stretch; }

  .uv-split-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: min(66vh, 600px);   /* the shared height cap both columns honor */
  }

  /* The card fills its column; its title (and, on the right, the screen toolbar)
     stay pinned while the body scrolls. overflow:hidden clips the card to its
     rounded box so the inner body owns the single scrollbar. */
  .uv-split-col > .pbk-group {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .uv-split-col > .pbk-group > .pbk-group-title { flex: 0 0 auto; }

  /* Universe (left): the field list scrolls; the Save/Reset bar stays pinned below. */
  .uv-split-col .pbk-universe-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .uv-split-col > .pbk-actions { flex: 0 0 auto; }

  /* Morning screen (right): the summary + Run-screener button stay pinned at the
     top, the picked-names list scrolls, and the swing rejection breakdown (when
     present) stays pinned below it. */
  .uv-split-col .pb-screen-toolbar { flex: 0 0 auto; }
  .uv-split-col .pb-screen-selected { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .uv-split-col .pb-screen-rejected { flex: 0 0 auto; }
}
