/* Steiger Bean palette: Midnight Burgundy #2E0F15, Champagne Gold #C9A96E (dark surfaces only),
   Magenta Burgundy #70163C (light surfaces), Warm Ivory #FAF8F5. Every other tone below is a mix of those,
   except good/warn/bad, which the app needs to tell states apart. */
:root {
  --sans: Montserrat, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --serif: "Cormorant Garamond", Garamond, Georgia, serif;
  --bg: #faf8f5;
  --panel: #ffffff;
  --panel2: #f3f0ed;
  --ink: #2e0f15;
  --ink2: #634c4f;
  --ink3: #735e61;
  --line: #e2dcda;
  --accent: #70163c;
  --accent-soft: #f4ecef;
  --primary: #2e0f15;         /* filled buttons: Midnight with Ivory text, Magenta on hover */
  --primary-hover: #70163c;
  --on-primary: #faf8f5;
  --warn: #8a4b12;
  --warn-soft: #fbf0e4;
  --bad: #a3302a;
  --good: #2e6b4c;
  --sel: var(--accent);
  --focus: 0 0 0 3px rgba(112, 22, 60, .22);
  --scrim: rgba(46, 15, 21, .32);
  --shadow: 0 1px 2px rgba(46, 15, 21, .05), 0 1px 3px rgba(46, 15, 21, .07);
  --shadow-lg: 0 12px 32px rgba(46, 15, 21, .18);
  --radius: 6px;
  --r-sm: 3px;
  --card-w: 184px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #24090d; --panel: #2e0f15; --panel2: #3b1b22; --ink: #faf8f5; --ink2: #b9aeab; --ink3: #a49697;
    --line: #4b3034; --accent: #c9a96e; --accent-soft: #472823; --primary: #c9a96e; --primary-hover: #d4b98a; --on-primary: #2e0f15;
    --warn: #e8a468; --warn-soft: #48261a; --good: #8cc5a0; --bad: #f2948a;
    --focus: 0 0 0 3px rgba(201, 169, 110, .4); --scrim: rgba(18, 4, 7, .55);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #24090d; --panel: #2e0f15; --panel2: #3b1b22; --ink: #faf8f5; --ink2: #b9aeab; --ink3: #a49697;
  --line: #4b3034; --accent: #c9a96e; --accent-soft: #472823; --primary: #c9a96e; --primary-hover: #d4b98a; --on-primary: #2e0f15;
  --warn: #e8a468; --warn-soft: #48261a; --good: #8cc5a0; --bad: #f2948a;
  --focus: 0 0 0 3px rgba(201, 169, 110, .4); --scrim: rgba(18, 4, 7, .55);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .45); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 300 13px/1.45 var(--sans); letter-spacing: .02em;
  background: var(--bg); color: var(--ink); overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
strong, b { font-weight: 400; }
.hidden { display: none !important; }
.spacer { flex: 1; }
kbd { font: 12px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--panel); }

/* ---------- top bar ---------- */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.wordmark { font-weight: 200; font-size: 13px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink); }
.wordmark .dot { font-style: normal; color: var(--accent); letter-spacing: 0; }
.product { font: 400 20px/24px var(--serif); letter-spacing: .01em; padding-left: 12px; border-left: 1px solid var(--line); }
.searchwrap { flex: 1; max-width: 760px; position: relative; }
.searchwrap .slash { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--ink2); pointer-events: none; }
#q:focus + .slash, #q:not(:placeholder-shown) + .slash { display: none; }
#q {
  width: 100%; height: 36px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 14px;
  background: var(--panel2); outline: none;
}
#q:focus { border-color: var(--accent); background: var(--panel); box-shadow: var(--focus); }
/* Keyboard focus is always visible (mouse clicks don't draw rings). */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.grid:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.grid:focus-visible .card.sel { box-shadow: 0 0 0 2px var(--sel), 0 0 0 5px color-mix(in srgb, var(--sel) 25%, transparent); }
.searchnote { margin: 8px 16px 0; padding: 7px 12px; border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn); font-size: 12.5px; }
.status { font-size: 12px; color: var(--ink2); white-space: nowrap; max-width: 300px; overflow: hidden; text-overflow: ellipsis; border: 0; background: none; padding: 4px; }
.status:hover { color: var(--accent); }
.status.busy::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Buttons read as engraved labels: uppercase, tracked, never bold. */
.ghost, .primary, .chip, .chips button {
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-sm); padding: 6px 10px; line-height: 1.2;
}
.ghost, .primary { font-size: 10.5px; font-weight: 400; letter-spacing: .1em; text-transform: uppercase; padding: 7px 11px; white-space: nowrap; }
.chip, .chips button { font-size: 12px; }
.ghost:hover, .chip:hover, .chips button:hover { border-color: var(--accent); color: var(--accent); }
.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.primary:disabled { opacity: .6; cursor: progress; }
.chip.on, .chips button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- workspace ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 34%); grid-template-rows: minmax(0, 1fr); height: calc(100% - 56px); }
.library { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.tabs, .filters { display: flex; align-items: center; gap: 8px; padding: 10px 16px 0; flex-wrap: wrap; }
.tab {
  border: 0; border-bottom: 1px solid transparent; background: none; border-radius: 0; padding: 6px 2px 5px; margin-right: 8px;
  font-size: 11px; font-weight: 400; letter-spacing: .18em; text-transform: uppercase; color: var(--ink3);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.count { color: var(--ink3); font-size: 12px; }
.filters { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.filters select { height: 30px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); padding: 0 8px; max-width: 220px; }
.chips { display: flex; gap: 4px; }
.upload { font-size: 10.5px; }
.fillbar { margin: 8px 16px 0; padding: 8px 12px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent); display: flex; gap: 8px; align-items: center; }
.fillbar button { margin-left: auto; }

.grid {
  flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 14px 16px 40px; outline: none;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr)); gap: 12px; align-content: start;
}
.card {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: grab; user-select: none;
  content-visibility: auto; contain-intrinsic-size: 184px 160px;
  transition: border-color .1s, box-shadow .1s;
}
.card:hover { border-color: var(--ink3); }
.card.sel { border-color: var(--sel); box-shadow: 0 0 0 2px var(--sel); }
.card .thumb { aspect-ratio: 16 / 9; background: var(--panel2); border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card .meta { padding: 7px 9px 9px; }
.card .t { font-weight: 400; font-size: 12.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.9em; }
.card .s { color: var(--ink3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.card .badges { position: absolute; top: 0; right: 0; left: 0; display: flex; gap: 3px; justify-content: flex-end; padding: 4px; aspect-ratio: var(--ar, 1.778); align-items: flex-end; pointer-events: none; }
/* Badges sit on slide thumbnails, so they look the same in both themes. */
.badge { font-size: 10px; background: rgba(46, 15, 21, .78); color: #faf8f5; padding: 0 5px; border-radius: var(--r-sm); line-height: 16px; }
.badge.star { background: #c9a96e; color: #2e0f15; }
.card .add {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: var(--primary); color: var(--on-primary); font-size: 18px; line-height: 28px; opacity: 0; transition: opacity .1s;
}
.card:hover .add, .card.sel .add, .card:focus-within .add { opacity: 1; }
.card.visual .thumb { aspect-ratio: 4 / 3; }
.sentinel { height: 1px; }
.empty { padding: 40px; text-align: center; color: var(--ink2); }

/* drag feedback */
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: var(--shadow-lg); }
.deck.droptarget .decklist { outline: 1px dashed var(--accent); outline-offset: -6px; background: var(--accent-soft); }

/* ---------- deck pane ---------- */
.deck { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; position: relative; }
.deckhead, .deckmeta, .decktools { display: flex; gap: 8px; padding: 10px 14px 0; align-items: center; }
.deckhead select { flex: 1; min-width: 0; height: 32px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); padding: 0 8px; font-weight: 400; }
.deckmeta input { flex: 1; min-width: 0; height: 30px; border: 1px solid transparent; border-radius: var(--r-sm); padding: 0 8px; background: var(--panel2); }
.deckmeta input:focus { border-color: var(--accent); outline: none; }
#deckName { font-weight: 400; flex: 1.6; }
.decktools { padding-bottom: 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; row-gap: 8px; }  /* a narrow deck pane puts Export on a second row */
.decktools #exportBtn { margin-left: auto; }
.decklist { flex: 1 1 0; overflow-y: auto; padding: 10px 12px 80px; min-height: 0; }
.deckempty { position: absolute; top: 290px; left: 24px; right: 24px; color: var(--ink2); text-align: center; pointer-events: none; line-height: 1.7; }
.deckfoot { border-top: 1px solid var(--line); padding: 8px 14px; font-size: 12px; color: var(--ink2); display: flex; gap: 10px; }

.ditem {
  display: grid; grid-template-columns: 22px 128px minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 7px 8px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  cursor: grab;
}
.ditem:hover { border-color: var(--ink3); }
.ditem.sel { border-color: var(--sel); box-shadow: 0 0 0 1px var(--sel); }
.ditem .num { color: var(--ink3); font: 300 15px/1 var(--serif); text-align: right; padding-top: 2px; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ditem .grip { font-style: normal; font-size: 15px; line-height: 1; color: var(--ink3); opacity: .5; }
.ditem:hover .grip { opacity: 1; color: var(--ink2); }
.ditem .dthumb { aspect-ratio: 16 / 9; background: var(--panel2); border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); }
.ditem .dthumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.ditem .dbody { min-width: 0; }
.ditem .dt { font-weight: 400; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ditem .ds { color: var(--ink3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ditem textarea {
  width: 100%; margin-top: 5px; resize: none; border: 1px solid transparent; background: var(--panel2);
  border-radius: var(--r-sm); padding: 4px 6px; font-size: 12px; min-height: 26px; height: 26px; cursor: text;
}
.ditem textarea:focus { border-color: var(--accent); outline: none; height: 60px; background: var(--panel); }
.ditem textarea:not(:focus):placeholder-shown { background: transparent; }
.ditem .acts { display: grid; grid-template-columns: repeat(2, 24px); gap: 2px; align-content: start; }
.ditem .acts button { border: 0; background: transparent; color: var(--ink3); padding: 0; height: 24px; border-radius: var(--r-sm); font-size: 13px; filter: grayscale(1); opacity: .75; }
.ditem .acts button:hover { opacity: 1; filter: none; }
.ditem .acts button:hover { background: var(--panel2); color: var(--ink); }
.ditem .acts button.on { color: var(--good); }
.keeptag { display: inline-block; font-size: 10px; color: var(--good); border: 1px solid currentColor; border-radius: var(--r-sm); padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
.ditem.placeholder { border-style: dashed; background: var(--panel2); }
.ditem.placeholder .dthumb { display: flex; align-items: center; justify-content: center; color: var(--ink3); font-size: 11px; text-align: center; padding: 6px; background: repeating-linear-gradient(45deg, transparent 0 6px, var(--line) 6px 7px); }
.ditem.section {
  grid-template-columns: 22px minmax(0, 1fr) auto; background: transparent; border: 0; border-bottom: 1px solid var(--accent);
  border-radius: 0; padding: 14px 4px 4px; margin-bottom: 10px;
}
.ditem.section input { border: 0; background: transparent; font-weight: 400; text-transform: uppercase; letter-spacing: .18em; font-size: 11px; width: 100%; padding: 0; min-height: 24px; }
.ditem.section input:focus { outline: none; }
.ditem.retired .ds::after { content: " · source changed"; color: var(--warn); }
.cands { grid-column: 2 / -1; display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; }
.cand { flex: 0 0 104px; width: 104px; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); padding: 0; position: relative; text-align: left; }
.cand img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; display: block; border-radius: 2px 2px 0 0; background: var(--panel2); }
.cand span { display: block; font-size: 10.5px; padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand .fit { position: absolute; top: 3px; left: 3px; background: rgba(46, 15, 21, .8); color: #faf8f5; font-size: 10px; padding: 0 4px; border-radius: 2px; }
.cand:hover { border-color: var(--accent); }
.cand.current { border-color: var(--good); box-shadow: 0 0 0 1px var(--good); }
.candtoggle { grid-column: 2 / -1; justify-self: start; font-size: 11.5px; border: 0; background: none; color: var(--accent); padding: 0 6px; margin-left: -6px; min-height: 24px; }

/* ---------- review: buttons, suggestions ---------- */
.reviewbar { display: flex; gap: 8px; padding: 8px 14px 0; }
.review { flex: 1; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-sm); padding: 7px 10px; font-weight: 400; color: var(--ink); }
.review:hover { border-color: var(--accent); color: var(--accent); }
.review:disabled { opacity: .6; cursor: progress; }
.deckviews { display: flex; gap: 4px; align-items: center; padding: 8px 14px 8px; border-bottom: 1px solid var(--line); }
.dview {
  border: 0; border-bottom: 1px solid transparent; background: none; padding: 4px 2px 3px; margin-right: 10px; border-radius: 0; color: var(--ink3);
  font-size: 11px; font-weight: 400; letter-spacing: .18em; text-transform: uppercase;
}
.dview:hover { color: var(--ink); }
.dview.on { color: var(--ink); border-bottom-color: var(--accent); }
.pill { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 10.5px; line-height: 16px; text-align: center; letter-spacing: 0; }
.dview.on .pill { background: var(--primary); color: var(--on-primary); }
.runstatus { margin-left: auto; font-size: 12px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.runstatus.busy::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.sbadge { border: 0; background: var(--accent-soft); color: var(--accent); border-radius: var(--r-sm); font-size: 10.5px; padding: 0 8px; margin: -4px 0 -4px 6px; min-height: 24px; vertical-align: 1px; font-weight: 400; }
.suggpanel { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 10px 12px 60px; }
.sfilters { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.sfilters button { border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-sm); padding: 2px 10px; font-size: 12px; min-height: 26px; }
.sfilters button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.sfilters .hint { font-size: 11.5px; color: var(--ink3); margin-left: auto; }
.sgroup { margin-bottom: 14px; }
.sgroup h4 { margin: 0 0 6px; font-size: 12px; font-weight: 400; color: var(--ink2); display: flex; gap: 6px; align-items: center; }
.sgroup h4 img { width: 54px; aspect-ratio: 16/9; object-fit: contain; border: 1px solid var(--line); border-radius: 2px; background: var(--panel2); }
.scard { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 6px; background: var(--panel); }
.scard.accepted { border-color: var(--good); }
.scard.dismissed { opacity: .55; }
.scard .stags { display: flex; gap: 4px; margin-bottom: 3px; flex-wrap: wrap; }
/* Tags tell kinds apart by fill and outline, not by extra hues. */
.stag { font-size: 10.5px; border-radius: var(--r-sm); padding: 0 6px; background: var(--panel2); border: 1px solid var(--line); color: var(--ink2); }
.stag.research { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.stag.tailor { background: transparent; border-color: color-mix(in srgb, var(--ink) 40%, transparent); color: var(--ink); }
.stag.update { background: transparent; border-color: var(--accent); color: var(--accent); }
.stag.outdated { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.scard .st { font-weight: 400; font-size: 13px; }
.scard .sb { font-size: 12.5px; color: var(--ink2); white-space: pre-wrap; margin-top: 3px; line-height: 1.6; }
.scard .sb.clamp { max-height: 4.8em; overflow: hidden; }
.scard .more { border: 0; background: none; color: var(--accent); font-size: 11.5px; padding: 0; }
.scard .links { margin: 5px 0 0; padding: 0; list-style: none; font-size: 12px; }
.scard .links li { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scard .links a { color: var(--accent); text-decoration: none; display: inline-block; padding: 4px 0; }
.scard .links .warn { color: var(--warn); font-size: 11px; }
.swap { margin-top: 5px; font-size: 12px; padding: 5px 7px; background: var(--panel2); border-radius: var(--r-sm); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.swap del { color: var(--bad); } .swap ins { color: var(--good); text-decoration: none; }
.swap label { margin-left: auto; display: flex; gap: 4px; align-items: center; color: var(--ink2); }
.sacts { display: flex; gap: 6px; margin-top: 6px; }
.sacts button { font-size: 12px; padding: 3px 9px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel); }
.sacts button.ok:hover { border-color: var(--good); color: var(--good); }
.sacts button.no:hover { border-color: var(--bad); color: var(--bad); }
.sempty { color: var(--ink2); text-align: center; padding: 30px 10px; font-size: 13px; line-height: 1.7; }
.form { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px 12px; align-items: start; margin-top: 8px; }
.form label { font-size: 12px; color: var(--ink2); padding-top: 6px; display: block; }
.form input, .form textarea, .form select { width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 8px; background: var(--panel); font: 300 13px/1.4 var(--sans); }
.form textarea { min-height: 54px; resize: vertical; }
.form input[type=radio], .form input[type=checkbox] { width: auto; margin: 0 6px 0 0; vertical-align: -1px; }
.modalbox .form textarea { min-height: 54px; font: 300 13px/1.4 var(--sans); background: var(--panel); padding: 6px 8px; }
.profilebox { background: var(--panel2); border-radius: var(--r-sm); padding: 8px 10px; font-size: 12.5px; white-space: pre-wrap; max-height: 180px; overflow: auto; color: var(--ink2); }
.copybox { display: flex; gap: 6px; } .copybox code { flex: 1; background: var(--panel2); padding: 8px; border-radius: var(--r-sm); font-size: 12.5px; }
.metric { display: inline-block; margin: 0 18px 10px 0; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink3); }
.metric b { display: block; font: 300 30px/1.1 var(--serif); letter-spacing: 0; text-transform: none; color: var(--ink); }
.health h3 { font-size: 10.5px; font-weight: 400; letter-spacing: .18em; text-transform: uppercase; color: var(--ink3); margin: 16px 0 6px; }
.health ul { margin: 0; padding-left: 18px; font-size: 13px; }
.health ul.hiddenlist { padding-left: 0; list-style: none; }
.hiddenlist li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 4px 0; }
.hiddenlist li button { margin-left: auto; }

/* ---------- drawer ---------- */
.drawer { position: fixed; inset: 56px 34% 0 0; background: var(--scrim); z-index: 20; display: flex; justify-content: flex-end; }
.drawerbody { width: min(980px, 100%); background: var(--panel); height: 100%; overflow-y: auto; box-shadow: var(--shadow-lg); padding: 18px 22px 40px; }
.dhead { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.dhead h2 { font: 400 24px/1.2 var(--serif); letter-spacing: .01em; margin: 0; flex: 1; }
.preview { width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel2); display: block; }
.dgrid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; margin-top: 14px; }
.dgrid h3 { font-size: 10.5px; font-weight: 400; text-transform: uppercase; letter-spacing: .18em; color: var(--ink3); margin: 16px 0 6px; }
.dgrid h3:first-child { margin-top: 0; }
.textblock { white-space: pre-wrap; font-size: 13px; line-height: 1.7; color: var(--ink2); max-height: 260px; overflow: auto; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.vgrid > p { grid-column: 1 / -1; margin: 0; color: var(--ink3); }
.vcard { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px; cursor: grab; background: var(--panel); }
.vcard img { width: 100%; height: 90px; object-fit: contain; display: block; }
.vcard span { font-size: 11px; color: var(--ink3); }
.note { border-left: 2px solid var(--accent); padding: 4px 8px; margin-bottom: 8px; font-size: 13px; background: var(--panel2); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.note .by { color: var(--ink3); font-size: 11px; display: flex; justify-content: space-between; }
.note .by { align-items: center; }
.note .by button { border: 0; background: none; color: var(--ink3); padding: 0; width: 24px; height: 24px; border-radius: var(--r-sm); margin: -4px -4px -4px 0; }
.note .by button:hover { background: var(--panel); color: var(--bad); }
.notebox textarea { width: 100%; min-height: 64px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 8px; background: var(--panel); }
.ai { background: var(--accent-soft); border-radius: var(--r-sm); padding: 8px 10px; font-size: 13px; }
.tag { display: inline-block; font-size: 11px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 7px; margin: 2px 2px 0 0; }
ul.plain { list-style: none; padding: 0; margin: 0; font-size: 13px; }
ul.plain li { padding: 2px 0; }
a.link { color: var(--accent); cursor: pointer; text-decoration: none; }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; background: var(--scrim); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modalbox { width: min(720px, 100%); max-height: 90vh; overflow-y: auto; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 22px 24px; }
.modalbox h2 { margin: 0 0 6px; font: 300 28px/1.15 var(--serif); letter-spacing: .01em; }
.modalbox p.sub { margin: 0 0 12px; color: var(--ink2); }
.modalbox textarea { width: 100%; min-height: 260px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0; background: var(--panel2); }
.modalbox .row { display: flex; gap: 14px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.modalbox label { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.modalbox .warns { margin: 10px 0; padding: 0; list-style: none; }
.modalbox .warns li { padding: 6px 10px; border-radius: var(--r-sm); margin-bottom: 6px; font-size: 13px; }
.modalbox .warns li[data-item] { cursor: pointer; }
.modalbox .warns li[data-item]:hover { text-decoration: underline; }
.ditem.flash, .sgroup.flash { animation: flash 1.6s ease-out; border-radius: var(--radius); }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--warn); } 100% { box-shadow: none; } }
.warns li.warn, .warns li.error { background: var(--warn-soft); color: var(--warn); }
.warns li.info { background: var(--panel2); color: var(--ink2); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 9px 16px; border-radius: var(--r-sm); z-index: 60; box-shadow: var(--shadow-lg); font-size: 13px; }
.toast button { margin-left: 10px; background: none; border: 0; color: inherit; text-decoration: underline; }
.dropcatch { position: fixed; inset: 0; z-index: 70; background: color-mix(in srgb, var(--accent) 12%, transparent); border: 2px dashed var(--accent); display: flex; align-items: center; justify-content: center; font: 300 30px/1.2 var(--serif); color: var(--accent); }
.spin { display: inline-block; width: 14px; height: 14px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; vertical-align: -2px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- narrow screens: stack panes ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; }
  .searchwrap { order: 3; flex-basis: 100%; }
  .workspace { display: block; height: auto; }
  .library { height: 70vh; }
  .deck { border-left: 0; border-top: 1px solid var(--line); min-height: 60vh; }
  .drawer { inset: 0; }
  .dgrid { grid-template-columns: 1fr; }
  :root { --card-w: 150px; }
  .ditem { grid-template-columns: 18px 110px minmax(0, 1fr) auto; }
  .decktools { flex-wrap: wrap; }
  .reviewbar { flex-direction: column; }
  .form { grid-template-columns: 1fr; }
  .suggpanel { min-height: 50vh; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .filters > * { flex: 0 0 auto; }
  .filters select { max-width: 160px; }
  .tabs .upload { padding: 6px 10px; }
  .searchwrap .slash { display: none; }
}

/* insights */
.badge.reuse { background: #70163c; }  /* sits on a slide thumbnail: same in both themes */
.modalbox:has(.insights) { width: min(960px, 100%); }
.insights .ihead { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.insights .ihead h2 { margin: 0 8px 0 0; }
.insights h4 { font-size: 10.5px; margin: 16px 0 6px; color: var(--ink3); font-weight: 400; letter-spacing: .18em; text-transform: uppercase; }
.insights .muted, .modalbox .muted { color: var(--ink3); font-weight: 300; letter-spacing: .02em; text-transform: none; }
.insights .icols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
@media (max-width: 720px) {
  .insights .icols { grid-template-columns: 1fr; }
  .bar { grid-template-columns: minmax(0, 1fr) 38px; row-gap: 2px; }
  .bar .bl { white-space: normal; }
  .bar .bt { grid-column: 1 / -1; grid-row: 2; }
}
.bars { display: grid; gap: 4px; }
.bar { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(60px, 1fr) 38px; gap: 8px; align-items: center; font-size: 12.5px; }
.bar .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .bt { height: 6px; background: var(--panel2); border: 0; border-radius: 1px; overflow: hidden; }
.bar .bt i { display: block; height: 100%; background: var(--accent); }
.bar .bv { text-align: right; color: var(--ink2); font-variant-numeric: tabular-nums; }
.irow { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.ithumb { display: flex; flex-direction: column; gap: 3px; text-align: left; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px; background: var(--panel); cursor: pointer; font-size: 11.5px; }
.ithumb:hover { border-color: var(--accent); }
.ithumb img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 2px; background: var(--panel2); }
.ithumb span { color: var(--accent); font-weight: 400; }
.ithumb em { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ilist { list-style: none; padding: 0 !important; margin: 0; font-size: 12.5px; }
.ilist li { padding: 3px 0; border-bottom: 1px solid var(--line); }
.ilist a, .insights a { color: var(--accent); text-decoration: none; display: inline-block; padding: 3px 0; }
.ilist a:hover, .insights a:hover { text-decoration: underline; }
.ilist li:last-child { border-bottom: 0; }
.iphr { margin-top: 8px; }
.iphr .chip b { color: var(--ink3); font-weight: 300; margin-left: 4px; }
.memo { white-space: pre-wrap; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; margin: 0; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.insights .chips { flex-wrap: wrap; }
.behind { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 6px; }
.behind > summary { cursor: pointer; font-weight: 400; font-size: 13.5px; padding: 6px 0; }
.behind > summary .muted { font-weight: 300; font-size: 12.5px; }

/* AI: dismiss reasons, estimates, slide anatomy, proposals */
.sreason { margin-top: 6px; font-size: 12px; color: var(--ink2); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.sreason button { font-size: 11.5px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-sm); padding: 2px 8px; cursor: pointer; color: var(--ink2); }
.sreason button:hover { border-color: var(--accent); color: var(--accent); }
.estimate { font-size: 13px; color: var(--ink2); }
.anatomy { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 10px; background: var(--panel2); font-size: 13px; }
.anatomy h3 { margin-top: 0 !important; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.anatomy ul { margin: 4px 0; padding-left: 18px; }
.anatomy .figs div { padding: 2px 0; }
.anatomy .muted, #aiInsights .muted { color: var(--ink3); }
.proposal { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 8px 10px; margin: 6px 0; font-size: 13px; }

/* live collaboration: who's here, what they're typing in, what just changed */
.people { display: flex; gap: 4px; align-items: center; }
.avatar { --who: var(--accent); width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--panel); background: var(--who);
  color: #fff; font: 400 10.5px/24px var(--sans); letter-spacing: .06em; text-align: center; padding: 0; box-shadow: 0 0 0 1px var(--line); flex: none; }
.avatar.here { box-shadow: 0 0 0 2px var(--who); }
.avatar.sm { width: 20px; height: 20px; font-size: 9px; line-height: 16px; letter-spacing: 0; display: inline-block; box-shadow: none; }
.live { width: 7px; height: 7px; border-radius: 50%; background: var(--ink3); flex: none; }
.live.on { background: var(--good); }
.livelabel { font-size: 12px; color: var(--warn); white-space: nowrap; }
.livelabel:empty { display: none; }
.collab { display: flex; gap: 12px; align-items: center; padding: 6px 14px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--ink2); flex-wrap: wrap; }
.collab:not(:has(.herechip, .activity:not(.hidden))) { display: none; }
.deckpeople { display: inline-flex; gap: 10px; }
.herechip { display: inline-flex; gap: 6px; align-items: center; color: var(--ink); font-weight: 400; }
.activity { display: inline-flex; gap: 6px; align-items: center; transition: opacity .6s; }
.activity.fade { opacity: .6; }
.ditem.remote { animation: remote 2.4s ease-out; }
@keyframes remote { 0%, 55% { box-shadow: 0 0 0 2px var(--who); } 100% { box-shadow: none; } }
.ditem[data-editor] { box-shadow: 0 0 0 2px var(--who); position: relative; }
.ditem[data-editor]::after { content: attr(data-editor); position: absolute; top: -9px; right: 10px; background: var(--who); color: #fff;
  font-size: 10px; padding: 0 6px; border-radius: var(--r-sm); line-height: 16px; pointer-events: none; }
.deckmeta input[data-editor] { box-shadow: 0 0 0 2px var(--who); }
@media (prefers-reduced-motion: reduce) { .ditem.remote { animation: none; } .activity { transition: none; } }

/* ---------- drafts written in the deck, other clients' names, wording changes ---------- */
.ditem .dtitle {
  width: calc(100% - 4px); border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; padding: 2px 5px; margin-left: -5px;
  font: 400 12.5px/1.4 var(--sans); color: var(--ink); min-height: 26px;
}
.ditem .dtitle:hover { border-color: var(--line); background: var(--panel); }
.ditem .dtitle:focus { border-color: var(--accent); background: var(--panel); outline: none; }
.ditem textarea.dbullets { height: auto; min-height: 44px; background: var(--panel); border-color: var(--line); line-height: 1.45; }
.ditem textarea.dbullets:focus { height: auto; }
.ditem textarea.dbullets:placeholder-shown { background: var(--panel); }
.ditem.placeholder:has(.dbullets:not(:placeholder-shown)) { border-style: solid; background: var(--panel); }
.dflags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.leaktag, .swaptag {
  border: 1px solid currentColor; background: var(--panel); border-radius: var(--r-sm); font-size: 10.5px; line-height: 1.5; padding: 1px 7px;
  min-height: 22px; font-weight: 400; letter-spacing: .01em; cursor: pointer;
}
.leaktag { color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--panel)); }
.dbody > .leaktag { margin-left: 6px; }
.swaptag { color: var(--good); }
.leaktag:hover, .swaptag:hover { text-decoration: underline; }
.deckviews { flex-wrap: wrap; row-gap: 2px; }
.runstatus:not(:empty) { flex-basis: 100%; max-width: 100%; margin-left: 0; order: 5; }

/* the storyboard: the whole deck in order */
.board { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 10px 12px 60px; }
.bsum { margin: 0 0 8px; font-size: 12px; color: var(--ink2); }
.bsum .bad { color: var(--bad); }
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px 8px; }
.bsec { grid-column: 1 / -1; font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink2); border-bottom: 1px solid var(--accent); padding: 8px 2px 3px; }
.bcard { position: relative; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); padding: 0; overflow: hidden; text-align: left; cursor: pointer; }
.bcard:hover { border-color: var(--accent); }
.bcard.leak { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.bcard.draft { border-style: dashed; }
.bthumb { display: block; width: 100%; background: var(--panel2); }
.bthumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.bdraft { display: flex; flex-direction: column; gap: 3px; height: 100%; padding: 22px 7px 6px; font-size: 10px; line-height: 1.3; overflow: hidden; color: var(--ink2);
  background: repeating-linear-gradient(45deg, transparent 0 6px, var(--line) 6px 7px); }
.bcard.written .bdraft { background: var(--panel); }
.bdraft b { font-weight: 400; color: var(--ink); font-size: 10.5px; }
.bdraft em { color: var(--ink3); }
.bnum { position: absolute; top: 3px; left: 3px; background: rgba(46, 15, 21, .82); color: #faf8f5; font-size: 10px; line-height: 15px; padding: 0 5px; border-radius: 2px; }
.bflag { position: absolute; bottom: 3px; right: 3px; background: var(--bad); color: #fff; font-size: 9.5px; line-height: 15px; padding: 0 5px; border-radius: 2px; }

/* wording changes */
.swaptext { margin: 0 0 10px; max-height: 150px; padding: 8px 10px; background: var(--panel2); border-radius: var(--r-sm); font-size: 12.5px; }
.swaptext mark { background: color-mix(in srgb, var(--warn) 22%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.swaps { display: grid; gap: 6px; }
.swaprow { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.swaprow input { height: 34px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 9px; background: var(--panel); min-width: 0; }
.swaprow input:focus { border-color: var(--accent); outline: none; box-shadow: var(--focus); }
.swaprow.missing [data-sw="find"] { border-color: var(--warn); background: var(--warn-soft); }
.modalbox label.swall { margin-top: 10px; align-items: flex-start; line-height: 1.4; }
.modalbox label.swall input { margin-top: 2px; }

/* export pre-flight, grouped */
.pfhead { margin: 12px 0 4px; font-size: 12px; font-weight: 400; letter-spacing: .12em; text-transform: uppercase; color: var(--ink2); }
.pfhead.bad { color: var(--bad); }
.pfok { color: var(--good); margin: 8px 0; }
.pfmore { cursor: pointer; color: var(--ink2); font-size: 13px; margin-top: 8px; }
.modalbox .warns li .fixbtn { margin-left: 8px; min-height: 26px; padding: 0 10px; font-size: 11.5px; }
.modalbox .warns li a.link { cursor: pointer; }
.modalbox p.warnline { color: var(--warn); background: var(--warn-soft); border-radius: var(--r-sm); padding: 6px 10px; margin: 10px 0 0; font-size: 12.5px; }

/* ---------- how slides fit together: runs kept from one deck, each slide's place in its own deck ---------- */
.ditem { position: relative; }
.ditem.flows::before { content: ""; position: absolute; left: 20px; top: -10px; height: 11px; border-left: 2px solid var(--accent); }
.flowin { color: var(--accent); margin-right: 4px; }
.cand .follows { position: absolute; top: 3px; right: 3px; background: var(--accent); color: var(--on-primary); font-size: 10px; padding: 0 4px; border-radius: 2px; }
.gonetag { font-size: 10.5px; border: 1px solid var(--warn); color: var(--warn); background: var(--warn-soft); border-radius: var(--r-sm); padding: 0 6px; min-height: 20px; margin-right: 6px; }
.bjoin { position: absolute; top: 3px; right: 3px; background: var(--accent); color: var(--on-primary); font-size: 9.5px; line-height: 15px; padding: 0 5px; border-radius: 2px; }
.storyhead { margin: 14px 0 6px; }
.storyhead span { text-transform: none; letter-spacing: 0; color: var(--ink3); }
.story { display: flex; gap: 6px; overflow-x: auto; padding: 3px 2px 8px; scroll-snap-type: x proximity; }
.storyslide { flex: 0 0 92px; width: 92px; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); overflow: hidden; position: relative; cursor: pointer; scroll-snap-align: center; }
.storyslide img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; display: block; background: var(--panel2); }
.storyslide span { position: absolute; bottom: 2px; left: 2px; background: rgba(46, 15, 21, .78); color: #faf8f5; font-size: 9.5px; line-height: 13px; padding: 0 4px; border-radius: 2px; }
.storyslide:hover { border-color: var(--accent); }
.storyslide.here { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.storyslide.generic { opacity: .55; }
.storyslide.picked { border-color: var(--good); box-shadow: 0 0 0 2px var(--good); opacity: 1; }
.runhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.runhead .storyhead { flex: 1 1 260px; min-width: 0; }
.runhead button { white-space: nowrap; }
/* other decks: the same point in other words, and what came next */
.conns { margin-top: 2px; }
.connstrip { display: flex; gap: 8px; overflow-x: auto; padding: 3px 2px 8px; }
.conncard { flex: 0 0 132px; width: 132px; padding: 0; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); overflow: hidden; text-align: left; cursor: pointer; }
.conncard img { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; display: block; background: var(--panel2); }
.conncard b, .conncard small { display: block; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conncard b { font-size: 11.5px; font-weight: 600; padding-top: 4px; }
.conncard small { font-size: 10.5px; color: var(--ink3); padding-bottom: 5px; }
.conncard:hover { border-color: var(--accent); }
.cand .rel { position: absolute; top: 3px; left: 3px; background: rgba(46, 15, 21, .8); color: #faf8f5; font-size: 10px; padding: 0 4px; border-radius: 2px; }
.modalbox.wide { width: min(1080px, 100%); }
.althead { display: flex; gap: 14px; align-items: flex-start; }
.alttitle { flex: 1; min-width: 0; }
.alttitle h2 { text-wrap: balance; }
.altnav { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 12.5px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.altnav button { min-width: 34px; font-size: 18px; line-height: 1; }
.altmain { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; margin-top: 6px; }
.altside { min-width: 0; font-size: 13px; }
.altside h3 { margin: 10px 0 4px; }
.altside .textblock { max-height: 220px; }
.altfit { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 2px; background: var(--panel2); color: var(--ink); margin-left: 4px; vertical-align: 1px; }
.altwhy { color: var(--ink2); margin: 0 0 8px; }
.altflow { color: var(--accent); margin: 0 0 8px; }
.altwarn { color: var(--warn); margin: 0 0 8px; }
.altnow { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 4px 8px; align-items: center; font-size: 12px; color: var(--ink2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px; margin: 0 0 8px; }
.altnow span:first-child { grid-column: 1 / -1; text-transform: uppercase; letter-spacing: .12em; font-size: 10px; color: var(--ink3); }
.altnow img { width: 72px; aspect-ratio: 16 / 9; object-fit: contain; background: var(--panel2); border-radius: 2px; }
.alt:focus { outline: none; }
.hthumb { width: 64px; aspect-ratio: 16 / 9; object-fit: contain; background: var(--panel2); border-radius: 2px; }
@media (max-width: 760px) { .altmain { grid-template-columns: 1fr; } .althead { flex-wrap: wrap; } }
