/* build screens (claude.ai/design). Uses tokens.css and the shared classes in app.css. */

.build { max-width: none; } /* full page width, like Contacts */
.build .page-head .sub { max-width: 68ch; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.title-badge { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.title-badge .badge { font-size: var(--text-xs); letter-spacing: 0; }
.build .panel h2 { margin: 0 0 var(--space-xs); }
.build .panel-head h2 { margin: 0; }
.build .page-head .row > form { margin: 0; }

/* Row lists: icon, name and sub-line, then right-hand meta. */
.tpl-icon { color: var(--color-ink-3); display: flex; }
.tpl-name { font-weight: 500; }
a.tpl-name { color: var(--color-ink); text-decoration: none; }
a.tpl-name:hover { text-decoration: underline; }
.r-sub { display: block; font-size: var(--text-xs); color: var(--color-ink-3); overflow-wrap: anywhere; }
.r-meta { font-size: var(--text-xs); color: var(--color-ink-3); }
.r-meta.used { flex: 0 1 11rem; }
.r-meta.when { flex: 0 0 5.5rem; text-align: right; }
.rows.flush { border: 0; border-radius: 0; margin: 0; }
@media (max-width: 40rem) {
  .r-meta.used, .r-meta.when { flex: 1 1 auto; text-align: left; }
}

/* Dashed "add" controls: + Condition, Add step. */
.add-dashed { display: inline-flex; align-items: center; gap: 6px; min-height: var(--control-h); padding: 0 var(--space-sm); border: 1px dashed var(--color-rule-strong); border-radius: var(--radius); background: var(--color-surface); color: var(--color-ink-2); font-weight: 400; cursor: pointer; }
.add-dashed:hover { background: var(--color-paper-2); color: var(--color-ink); border-color: var(--color-rule-strong); }
button.add-dashed.sm { min-height: 28px; font-size: var(--text-sm); }

/* ---------- template editor ---------- */
.tpl-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 0 var(--space-md); align-items: end; }
.tpl-fields label.check { min-height: var(--control-h); margin-bottom: var(--space-md); }
.tpl-editor { display: flex; flex-direction: column; overflow: hidden; }
.tpl-bar { display: flex; flex-wrap: wrap; gap: var(--space-xs); align-items: center; padding: var(--space-xs) var(--space-sm); border-bottom: var(--rule); }
.tpl-bar .grow { flex: 1; }
.tpl-bar-label { font-size: var(--text-xs); color: var(--color-ink-3); }
.seg { display: inline-flex; padding: 2px; border: var(--rule); border-radius: var(--radius-lg); background: var(--color-paper-2); }
.seg[hidden] { display: none; }
.seg button { min-height: 28px; padding: 0 var(--space-sm); gap: 6px; border: 0; background: transparent; color: var(--color-ink-2); font-weight: 400; font-size: var(--text-sm); }
.seg button:hover { background: transparent; color: var(--color-ink); }
.seg button[aria-checked="true"] { background: var(--color-surface); color: var(--color-ink); font-weight: 500; box-shadow: var(--shadow-1); }
.tpl-editor .tpl-html { flex: 1; min-height: 26rem; border: 0; border-radius: 0; padding: var(--space-sm); font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.6; resize: vertical; margin: 0; }
.tpl-html[hidden] { display: none; }
.tpl-editor #gjs { height: 32rem; border: 0; border-radius: 0; }
.tpl-editor #gjs[hidden] { display: none; }
.tpl-note { margin: 0; padding: var(--space-xs) var(--space-sm); border-top: var(--rule); display: block; }
.tpl-as { justify-content: flex-start; flex-wrap: wrap; padding: var(--space-xs) var(--space-sm); }
.tpl-as label { margin: 0; font-weight: 600; font-size: var(--text-sm); }
.tpl-as select { flex: 1 1 9rem; width: auto; min-width: 0; min-height: 28px; }
.tpl-preview .panel-body { display: flex; flex-direction: column; gap: var(--space-sm); }
.tpl-preview .notice { margin: 0; }
.tpl-subject span { display: block; font-size: var(--text-xs); color: var(--color-ink-3); }
.tpl-subject b { font-weight: 600; overflow-wrap: anywhere; }
.tpl-preview .preview { min-height: 26rem; }
.tpl-editor .tpl-html:focus-visible { outline-offset: -2px; }
.mono-input { font-family: var(--font-mono); font-size: var(--text-sm); }
.wa-vars { padding: var(--space-sm) var(--space-md) var(--space-md); }
.wa-var { flex-wrap: wrap; padding-bottom: var(--space-xs); border-bottom: var(--rule); }
.wa-n { width: 3.25rem; flex: none; font-weight: 500; }
.wa-var > select { flex: 1 1 12rem; }
.wa-var > input { flex: 1 1 10rem; }
.wa-screen { padding: 1.25rem var(--space-md); background: var(--color-paper-2); min-height: 18rem; display: flex; flex-direction: column; gap: var(--space-sm); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.wa-screen .bubble { align-self: flex-start; max-width: 90%; background: var(--color-surface); border: var(--rule); border-radius: 12px 12px 12px 4px; padding: var(--space-xs) var(--space-sm); }

/* ---------- workflow builder: a vertical list of step cards ---------- */
.wf-split > .main-part { flex-basis: 34rem; max-width: 45rem; }
.wf-flow { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.wf-flow .step { box-shadow: none; border-radius: var(--radius-lg); padding: var(--space-sm) 0.875rem; }
.wf-flow .step + .step, #steps > .step:first-child, .wf-add, .wf-save { margin-top: var(--space-md); }
.wf-flow .step + .step::before, #steps > .step:first-child::before, .wf-add::before { content: ""; position: absolute; left: 28px; top: calc(var(--space-md) * -1); height: var(--space-md); border-left: 1px solid var(--color-rule-strong); }
#steps > .step:first-child { position: relative; }
#steps:empty { display: none; }
.wf-trigger { display: flex; flex-direction: column; gap: var(--space-sm); }
.wf-trigger > .row { margin: 0; }
.step-kind-label { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--color-ink-3); }
.wf-conds { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2xs); padding-top: var(--space-sm); border-top: var(--rule); }
.wf-conds .rowitem { width: 100%; margin: 0; }
.step-num { background: var(--color-paper-2); color: var(--color-ink-2); border: var(--rule); width: 24px; height: 24px; }
.step-kind { display: flex; color: var(--color-ink-3); }
.step-kind > [hidden] { display: none; }
.step-head { margin-bottom: var(--space-xs); gap: var(--space-xs); }
.step-head select { border-color: transparent; background-color: transparent; padding-left: var(--space-2xs); }
.step-head select:hover { border-color: var(--color-rule-strong); }
.step-head .badge { text-decoration: none; }
.step-tools button.icon { min-height: 28px; width: 28px; color: var(--color-ink-3); }
.step-body .row { margin: 0; }
.wf-add { position: relative; align-self: flex-start; margin-left: var(--space-md); display: inline-block; }
.wf-add[hidden] { display: none; }
.wf-add > summary { cursor: pointer; }
.wf-add-pop { left: 0; right: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; width: min(22rem, calc(100vw - 3rem)); }
.wf-add-pop button { gap: var(--space-xs); font-size: var(--text-sm); }
.wf-save { margin-bottom: 0; }
.wf-save .form-actions { margin-top: var(--space-xs); }
.wf-log-head { flex-direction: column; align-items: stretch; }
.wf-find { margin: 0; }
.wf-find .search-box { margin: 0; max-width: none; font-weight: 400; }
.wf-filter { margin: 0; padding: var(--space-xs) var(--space-md); background: var(--color-paper-2); border-bottom: var(--rule); color: var(--color-ink-2); }
.wf-runs { list-style: none; margin: 0; padding: 0 var(--space-md); }
.wf-runs > li { border-bottom: var(--rule); }
.wf-runs > li:last-child { border-bottom: 0; }
.wf-runs details { padding: var(--space-xs) 0; font-size: var(--text-sm); }
.wf-runs summary { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; list-style: none; }
.wf-runs summary::-webkit-details-marker { display: none; }
.wf-runs summary .grow { flex: 1; min-width: 0; }
.wf-runs .runlog { padding-left: calc(20px + var(--space-sm)); color: var(--color-ink-2); }
.wf-runs details form { margin: var(--space-2xs) 0 0 calc(20px + 10px); }
.wf-run-ic { width: 20px; flex: none; display: flex; padding-top: 2px; }
.build .tone-ok { color: var(--color-ok); } .build .tone-warn { color: var(--color-warn); } .build .tone-bad { color: var(--color-bad); } .build .tone-info { color: var(--color-info); }
.wf-none { margin: 0; padding: var(--space-md); }

/* ---------- automations ---------- */
.auto-row { padding-block: var(--space-sm); }
.auto-row > form { display: flex; align-items: center; min-height: var(--control-h); }
.auto-rule { font-size: var(--text-sm); color: var(--color-ink-2); }
.auto-edit { font-size: var(--text-sm); font-weight: 500; }
.auto-bad { color: var(--color-bad); }
/* On/off switch: a submit button, so it works without JS. */
button.switch { width: 36px; min-height: 20px; height: 20px; padding: 2px; border: 0; border-radius: var(--radius-pill); background: var(--color-rule-strong); justify-content: flex-start; }
button.switch i { width: 16px; height: 16px; border-radius: 50%; background: var(--color-surface); box-shadow: var(--shadow-1); transition: translate var(--dur-short, 140ms) var(--ease-out, ease-out); }
button.switch[aria-checked="true"] { background: var(--color-accent); }
button.switch[aria-checked="true"] i { translate: 16px 0; }
button.switch:hover { background: var(--color-ink-3); }
button.switch[aria-checked="true"]:hover { background: var(--color-accent-hover); }
.auto-name { max-width: 26rem; }
.auto-parts { list-style: none; margin: 0 0 var(--space-md); padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 10px; }
.auto-parts > li { border: var(--rule); border-radius: var(--radius-lg); padding: var(--space-sm); background: var(--color-paper-2); display: flex; flex-direction: column; gap: var(--space-xs); min-width: 0; }
.auto-parts > li.part-wide { grid-column: 1 / -1; }
.auto-parts label { margin: 0; }
.auto-parts label[hidden] { display: none; }
.auto-parts .rowitem { margin: 0; }
.auto-parts .add-dashed { align-self: flex-start; }
.auto-parts .hint { margin: 0; }
.part-k { font-size: var(--text-xs); color: var(--color-ink-3); }
.auto-reads { font-size: var(--text-sm); color: var(--color-ink-2); margin: 0 0 var(--space-md); }
.auto-reads b { font-weight: 600; color: var(--color-ink); }

/* ---------- campaign scraper ---------- */
.scr-filters { display: flex; flex-wrap: wrap; gap: var(--space-xs); align-items: center; margin-bottom: var(--space-sm); }
.scr-filters select { width: auto; }
.scr-table table { min-width: 60rem; }
.scr-table td { padding-block: 6px; }
.build .num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.build td.strong { font-weight: 500; }
.build td.muted2 { color: var(--color-ink-2); }
.scr-name { color: var(--color-ink) !important; }
.scr-pct { width: 10rem; }
.scr-bar { display: flex; align-items: center; gap: var(--space-xs); }
.scr-bar .bar { flex: 1; }
.scr-bar .bar.full > i { background: var(--color-ok); }
.scr-bar .num { width: 2.75rem; font-size: var(--text-sm); }
.scr-err { max-width: 16rem; white-space: normal; }
.tablewrap.flush { border: 0; border-radius: 0; box-shadow: none; margin: 0; }
.tablewrap.flush tr:last-child td { border-bottom: 0; }
