/* Janus components for farmhub: square, flat, ruled. Ink chrome (sidebar,
 * page header), light content. Status is always a square plus a word. */

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}
a { color: var(--text); }
a:hover { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; border-radius: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }
.meta { font-family: var(--mono); font-size: 11px; line-height: 14px; }
.label { font-family: var(--mono); font-size: 10px; line-height: 13px; letter-spacing: 1.2px; text-transform: uppercase; }
.muted { color: var(--muted); }
.dash { color: var(--muted); }
.sr { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.grow { flex-grow: 1; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- shell ---------------------------------------------------------------- */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.nav {
  flex: 1 1 var(--sidebar); max-width: 100%;
  padding: 24px 0; background: var(--ink); color: var(--ink-text);
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 24px 24px; color: var(--ink-text); text-decoration: none; }
.brand:hover { color: var(--ink-text); }
.brand-mark { width: 14px; height: 14px; background: var(--accent); }
.brand-logo { display: block; height: 32px; width: auto; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -0.3px; }
/* wide screens: the sidebar stays in view; the menu scrolls, the foot (backends, account, theme) does not */
@media (min-width: 761px) {
  .nav { position: sticky; top: 0; height: 100vh; align-self: flex-start; }
  .nav-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--ink-divider) transparent; }
  .nav-foot { flex: 0 0 auto; }
  .nav-links.folded { display: none; }
}
.nav-group {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 0 24px 8px; color: var(--ink-muted); background: none; border: 0; cursor: pointer; text-align: left;
}
.nav-group:hover { color: var(--ink-text); }
.nav-group:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-caret { font-size: 10px; transition: transform .12s; }
.nav-group[aria-expanded="false"] .nav-caret { transform: rotate(-90deg); }
.nav-group[aria-expanded="false"] { padding-bottom: 12px; }
@media (prefers-reduced-motion: reduce) { .nav-caret { transition: none; } }
.nav-group + .nav-links { margin-bottom: 12px; }
.nav-links { display: flex; flex-direction: column; }
.nav a.nav-link {
  display: flex; align-items: center; min-height: 44px; padding: 0 24px;
  color: var(--ink-nav); font-weight: 500; text-decoration: none;
}
.nav a.nav-link:hover { color: var(--ink-text); background: var(--ink-surface); }
.nav a.nav-link[aria-current="page"] { background: var(--ink-surface); color: var(--ink-text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-foot {
  margin-top: auto; padding: 16px 24px 0; border-top: 1px solid var(--ink-divider);
  display: flex; flex-direction: column; gap: 10px; font-family: var(--mono); font-size: 11px; line-height: 14px;
}
.be { display: flex; align-items: center; gap: 8px; }
.be .v { margin-left: auto; color: var(--ink-dim); max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-switch { display: flex; gap: 0; margin-top: 6px; }
.theme-switch button {
  flex: 1; min-height: 32px; background: transparent; border: 1px solid var(--ink-divider); color: var(--ink-dim);
  font-family: var(--mono); font-size: 10px; letter-spacing: 1.2px; cursor: pointer;
}
.theme-switch button + button { border-left: 0; }
.theme-switch button[aria-pressed="true"] { background: var(--ink-surface); color: var(--ink-text); }
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }

/* ---- page header (ink band) -------------------------------------------- */
.hdr { background: var(--ink); color: var(--ink-text); padding: 24px 32px 28px; display: flex; flex-direction: column; gap: 24px; }
.hdr-top { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.hdr-title { flex-grow: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.kicker { color: var(--ink-muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hdr h1 { margin: 0; font-size: 30px; line-height: 30px; font-weight: 800; letter-spacing: -0.9px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); column-gap: 20px; row-gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--ink-divider); padding-top: 10px; min-width: 0; }
.kpi .k-label { color: var(--ink-muted); }
.kpi .k-value { font-family: var(--mono); font-size: 24px; line-height: 26px; font-weight: 500; letter-spacing: -0.48px; }
.kpi .k-value.unknown { color: var(--ink-dim); }
.kpi .k-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); }
.kpi .k-sub.warn { color: var(--warn); }
.kpi .k-sub.crit { color: var(--ink-down); }

/* ---- buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 14px; background: transparent; border: 1px solid var(--rule); color: var(--text);
  font-weight: 800; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--tint); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.danger { border-color: var(--down); color: var(--down-ink); }
.btn.ghost { border-color: var(--divider); font-weight: 600; }
.btn.link { border: 0; padding: 0 0 0 12px; text-decoration: underline; }
.btn.link:hover { background: transparent; color: var(--accent-ink); }
.btn.small { height: 32px; padding: 0 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.hdr .btn { border-color: var(--ink-divider); color: var(--ink-text); }
.hdr .btn:hover { background: var(--ink-surface); color: var(--ink-text); }
.hdr .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.hdr .btn.primary:hover { background: var(--accent-hover); }
.hdr .btn[aria-pressed="true"] { background: var(--ink-text); color: var(--ink); border-color: var(--ink-text); }

/* chips and toggles (filters) */
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  height: 44px; padding: 0 14px; background: transparent; border: 1px solid var(--divider); color: var(--text);
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--tint); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.size { min-width: 44px; padding: 0; }
.tabs { display: inline-flex; margin-left: auto; }
.tab { height: 44px; padding: 0 14px; background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.tab[aria-pressed="true"] { border-bottom-color: var(--accent); color: var(--text); }
.find {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border: 1px solid var(--divider);
  font-family: var(--mono); font-size: 11px; color: var(--muted); min-width: 0;
}
.find input { width: 200px; max-width: 100%; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); font: inherit; }
.bar-right { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- content and sections ---------------------------------------------- */
.content { padding: 32px 32px 48px; display: flex; flex-direction: column; gap: 32px; min-width: 0; }
.content.tight { padding-top: 24px; gap: 16px; }
.cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.cols > * { flex: 1 1 360px; min-width: 0; }
.sec { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sec.flush { gap: 0; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 16px; border-bottom: 2px solid var(--rule); padding-bottom: 8px; min-height: 30px; }
.sec-head.center { align-items: center; padding-bottom: 0; }
.sec-head h2 { margin: 0; flex-grow: 1; font-size: 15px; line-height: 20px; font-weight: 800; letter-spacing: -0.2px; }
.sec-head .meta { color: var(--muted); }
.note { margin: 0; color: var(--muted); }
.empty { margin: 0; padding: 12px; border: 1px dashed var(--divider); font-family: var(--mono); font-size: 11px; line-height: 16px; color: var(--muted); }
.banner { padding: 10px 12px; background: var(--warn-tint); font-family: var(--mono); font-size: 11px; line-height: 16px; }
.banner.crit { background: var(--down-tint); }

/* status: square + word */
.st { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; line-height: 14px; font-weight: 500; text-transform: uppercase; white-space: nowrap; }
.sq { display: inline-block; width: 8px; height: 8px; flex: none; background: var(--empty); }
.st.ok { color: var(--accent-ink); } .st.ok .sq, .sq.ok { background: var(--accent); }
.st.warn { color: var(--warn-ink); } .st.warn .sq, .sq.warn { background: var(--warn); }
.st.crit { color: var(--down-ink); } .st.crit .sq, .sq.crit { background: var(--down); }
.st.off { color: var(--muted); } .st.off .sq, .sq.off { background: var(--empty); }
.st.busy { color: var(--text); } .st.busy .sq, .sq.busy { background: var(--text); }
.nav .sq.off, .hdr .sq.off { background: #3b3e3c; }
.live .sq { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .live .sq { animation: none; } }

/* meter */
.meter { display: block; height: 6px; background: var(--track); }
.meter > span { display: block; height: 6px; background: var(--text); }
.meter.inline { display: inline-block; width: 48px; vertical-align: middle; }

/* data table */
.tbl-wrap { border-top: 2px solid var(--rule); overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; }
.dt th { padding: 12px 12px 12px 0; font-family: var(--mono); font-size: 10px; letter-spacing: 1.2px; color: var(--muted); font-weight: 400; text-align: left; border-bottom: 1px solid var(--divider); white-space: nowrap; }
.dt td { padding: 0 12px 0 0; height: 44px; border-bottom: 1px solid var(--divider); }
.dt th:first-child, .dt td:first-child { padding-left: 8px; }
.dt tr.click { cursor: pointer; }
.dt tr.click:hover td { background: var(--tint); }
.dt tr.sel td { background: var(--tint); }
.dt tr.sel td:first-child { box-shadow: inset 2px 0 0 var(--rule); }
.dt tr.warn td { background: var(--warn-tint); }
.dt tr.crit td { background: var(--down-tint); }
.dt td.num, .dt th.num { text-align: right; }
.dt input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--text); }
.cell-m { font-family: var(--mono); font-size: 11px; }
.strong { font-weight: 600; }

/* rows (lists) */
.lrow { display: flex; align-items: center; gap: 12px; min-height: 42px; border-bottom: 1px solid var(--divider); min-width: 0; }
.lrow.mono { font-family: var(--mono); font-size: 11px; line-height: 14px; }
.lrow.warn { background: var(--warn-tint); }
.lrow.crit { background: var(--down-tint); }
.lrow .t { color: var(--muted); min-width: 44px; }
.lrow .w { overflow-wrap: anywhere; min-width: 0; }

/* tiles */
.rack { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; }
.ptile {
  display: flex; flex-direction: column; gap: 6px; min-height: 72px; padding: 10px 12px; background: var(--surface);
  color: var(--text); text-decoration: none; outline-offset: -2px; min-width: 0;
}
.ptile:hover { color: var(--text); background: var(--tint); }
.ptile.running { outline: 2px solid var(--rule); }
.ptile.review { background: var(--warn-tint); }
.ptile.offline { background: var(--down-tint); }
.ptile.free { background: transparent; outline: 1px dashed var(--divider); }
.ptile .top { display: flex; align-items: center; gap: 8px; }
.ptile .top .ip { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.stages { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stage { background: var(--surface); padding: 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stage .v { font-family: var(--mono); font-size: 24px; line-height: 26px; font-weight: 500; }
.stage .label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* screens */
.screens { border-top: 2px solid var(--rule); padding-top: 16px; display: grid; gap: 16px 12px; grid-template-columns: repeat(auto-fill, minmax(var(--tile-min, 148px), 1fr)); }
.screens.s { --tile-min: 104px; }
.screens.l { --tile-min: 220px; }
.stile { display: flex; flex-direction: column; gap: 8px; padding: 8px; color: var(--text); text-decoration: none; outline-offset: -2px; min-width: 0; }
.stile:hover { background: var(--tint); color: var(--text); }
.stile.running { outline: 2px solid var(--rule); }
.stile.review { background: var(--warn-tint); }
.stile.offline { background: var(--down-tint); }
.stile .shot {
  position: relative; aspect-ratio: 9 / 16; background: var(--ink); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; padding: 8px; text-align: center; color: var(--ink-muted); overflow: hidden;
}
.stile .shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--ink); }
.stile .shot .age { position: absolute; right: 0; bottom: 0; padding: 2px 6px; background: rgba(16, 20, 18, 0.72); color: var(--ink-text); font-family: var(--mono); font-size: 10px; }
.wall { position: fixed; inset: 0; z-index: 50; background: var(--ink); overflow: auto; padding: 8px; }
.wall .screens { border-top: 0; padding-top: 0; gap: 6px; }
.wall .stile { padding: 0; color: var(--ink-text); gap: 2px; }
.wall .stile:hover { background: transparent; color: var(--ink-text); }
.wall .stile .cap { font-family: var(--mono); font-size: 10px; color: var(--ink-dim); display: flex; gap: 6px; align-items: center; }
.wall-exit { position: fixed; right: 12px; top: 12px; z-index: 51; }

/* key/value */
dl.kv { margin: 0; display: grid; grid-template-columns: 76px minmax(0, 1fr); row-gap: 8px; column-gap: 8px; font-family: var(--mono); font-size: 11px; line-height: 16px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.code { background: var(--surface); padding: 12px 16px; font-family: var(--mono); font-size: 12px; line-height: 19px; overflow-x: auto; }
.code .ln { display: flex; gap: 16px; white-space: nowrap; }
.code .n { color: var(--muted); min-width: 16px; text-align: right; }
.code .op { font-weight: 500; min-width: 96px; }
.code .off { opacity: 0.45; text-decoration: line-through; }
.tag { font-family: var(--mono); font-size: 11px; padding: 6px 10px; background: var(--surface); display: inline-flex; gap: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.spark { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; }
.spark > a, .spark > span { display: block; height: 28px; background: var(--track); }
.spark .ok { background: var(--accent); } .spark .warn { background: var(--warn); } .spark .crit { background: var(--down); } .spark .busy { background: var(--text); } .spark .off { background: var(--empty); }
.sample { display: inline-flex; align-items: center; padding: 2px 6px; background: var(--warn); color: var(--on-accent); font-family: var(--mono); font-size: 10px; letter-spacing: 1.2px; font-weight: 500; }

/* library list (automations) */
.lib-item { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-bottom: 1px solid var(--divider); color: var(--text); text-decoration: none; cursor: pointer; background: transparent; border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%; }
.lib-item:hover { background: var(--tint); color: var(--text); }
.lib-item[aria-current="true"] { background: var(--tint); box-shadow: inset 2px 0 0 var(--rule); }
.lib-item .nm { flex-grow: 1; font-weight: 800; font-size: 14px; overflow-wrap: anywhere; }

/* clips */
.pipeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 24px; align-items: start; }
.ccard { background: var(--surface); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ccard.review { background: var(--warn-tint); }
.ccard .thumb { height: 88px; background: var(--ink); display: flex; align-items: center; justify-content: center; color: var(--ink-muted); }
.topic-in { flex: 1 1 320px; min-width: 0; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px; background: var(--ink-surface); border: 1px solid var(--ink-divider); font-family: var(--mono); }
.topic-in .p { color: var(--accent); }
.topic-in input { flex-grow: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--ink-text); font: inherit; font-size: 13px; }
.hdr .chip { border-color: var(--ink-divider); color: var(--ink-text); }
.hdr .chip:hover { background: var(--ink-surface); }
.hdr .chip[aria-pressed="true"] { background: var(--ink-text); border-color: var(--ink-text); color: var(--ink); }
.hdr .label { color: var(--ink-muted); }

/* drawer and dialog (overlays: the only place for shadows) */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(16, 20, 18, 0.45); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(var(--rail-wide), 100vw); background: var(--bg);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
}
.drawer-head { background: var(--ink); color: var(--ink-text); padding: 20px 24px; display: flex; align-items: flex-start; gap: 12px; }
.drawer-head h2 { margin: 0; font-size: 20px; line-height: 24px; font-weight: 800; letter-spacing: -0.4px; overflow-wrap: anywhere; }
.drawer-head .x { margin-left: auto; height: 36px; width: 36px; background: transparent; border: 1px solid var(--ink-divider); color: var(--ink-text); cursor: pointer; flex: none; }
.drawer-body { padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 24px; }
.dialog {
  position: fixed; z-index: 42; left: 50%; top: 8vh; transform: translateX(-50%); width: min(520px, calc(100vw - 32px));
  max-height: 84vh; overflow-y: auto; background: var(--bg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
}
.dialog .drawer-body { gap: 16px; }
.dialog-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 0 24px 24px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span:first-child { font-family: var(--mono); font-size: 10px; letter-spacing: 1.2px; color: var(--muted); text-transform: uppercase; }
.field input, .field select, .field textarea {
  min-height: 44px; padding: 8px 10px; background: transparent; border: 1px solid var(--divider); color: var(--text); width: 100%;
}
.field textarea { min-height: 88px; font-family: var(--mono); font-size: 12px; }
.field .hint { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.field.err input, .field.err select, .field.err textarea { border-color: var(--down); }
.field .msg { font-family: var(--mono); font-size: 11px; color: var(--down-ink); }
.checks { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; border: 1px solid var(--divider); padding: 8px; }
.checks label { display: flex; gap: 8px; align-items: center; min-height: 32px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--ink-text); padding: 12px 16px; box-shadow: var(--shadow-sm); font-family: var(--mono); font-size: 11px; max-width: calc(100vw - 32px); }
.toast.crit { box-shadow: inset 3px 0 0 var(--down), var(--shadow-sm); }
.toast.ok { box-shadow: inset 3px 0 0 var(--accent), var(--shadow-sm); }
.apicall { font-family: var(--mono); font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }

/* ---- narrow screens (390 px) --------------------------------------------- */
@media (max-width: 760px) {
  .nav { padding: 12px 0 0; flex-basis: 100%; }
  .brand { padding: 0 16px 12px; }
  .nav-group { display: none; }
  .nav-links { flex-direction: row; overflow-x: auto; }
  .nav-group + .nav-links { margin-bottom: 0; }
  .nav a.nav-link { padding: 0 14px; white-space: nowrap; }
  .nav a.nav-link[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
  .nav-foot { flex-direction: row; flex-wrap: wrap; gap: 6px 14px; padding: 10px 16px 12px; margin-top: 0; }
  .nav-foot .label { display: none; }
  .be .v { margin-left: 0; }
  .theme-switch { margin-top: 0; margin-left: auto; }
  .theme-switch button { min-height: 28px; padding: 0 8px; }
  .hdr { padding: 20px 16px 24px; gap: 20px; }
  .hdr h1 { font-size: 26px; line-height: 28px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .k-value { font-size: 20px; line-height: 22px; }
  .content { padding: 24px 16px 40px; gap: 24px; }
  .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabs { margin-left: 0; }
  .find { flex: 1 1 100%; }
  .find input { width: 100%; }
  .bar-right { margin-left: 0; }
  .hdr-top .btn { flex: 1 1 auto; }
  .drawer-body { padding: 16px; }
  .drawer-head { padding: 16px; }
}

/* ---- embedded backend views (pages/embed.js) ----------------------------- */
.nav a.nav-link[hidden] { display: none; }
.embed-wrap { display: flex; flex-direction: column; height: 100vh; min-height: 480px; }
.embed-hdr { background: var(--ink); color: var(--ink-text); padding: 14px 32px 16px; display: flex; align-items: flex-end; gap: 12px; }
.embed-hdr .hdr-title { gap: 6px; }
.embed-hdr h1 { margin: 0; font-size: 22px; line-height: 24px; font-weight: 800; letter-spacing: -0.6px; overflow-wrap: anywhere; }
.embed-stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; background: var(--bg); }
.embed-frame { flex: 1 1 auto; width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }
.embed-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 24px 32px; background: var(--bg); }
.embed-state .banner { max-width: 640px; }
.embed-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.4px; color: var(--ink-muted); }
.embed-crumbs a { color: var(--ink-text); text-decoration: underline; text-underline-offset: 3px; }
.embed-crumbs .sep { color: var(--ink-muted); }
.embed-related { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 55%; }
.embed-related .btn { background: transparent; color: var(--ink-text); border-color: var(--ink-divider); }
.livepanel { position: fixed; right: 16px; bottom: 16px; z-index: 45; width: min(420px, calc(100vw - 32px)); height: min(820px, calc(100vh - 32px)); background: var(--bg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; }
.livepanel .drawer-head { padding: 10px 14px; align-items: center; }
.livepanel iframe { flex: 1 1 auto; border: 0; width: 100%; background: var(--bg); }
@media (max-width: 760px) {
  .embed-wrap { height: calc(100vh - 120px); }
  .embed-hdr { padding: 12px 16px; flex-wrap: wrap; }
  .embed-related { max-width: none; justify-content: flex-start; }
  .embed-state { padding: 16px; }
}

/* ---- v0.4: sign-in, account ---------------------------------------------- */
.shell.bare { display: block; }
.login { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; }
.login-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0 0 4px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card .field { display: flex; flex-direction: column; gap: 4px; }
.login-card .brand-logo { margin-bottom: 12px; }
.qr { display: block; width: 200px; height: 200px; image-rendering: pixelated; background: #fff; border: 1px solid var(--line, #d0d5d2); }
.secret-key { font-family: var(--font-mono, monospace); letter-spacing: .04em; word-break: break-all; }
.recovery { columns: 2; font-family: var(--font-mono, monospace); padding-left: 24px; }
.acct { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.acct-name { color: inherit; font-weight: 600; text-decoration: none; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-name:hover { text-decoration: underline; }
.acct-role { font-size: 11px; letter-spacing: .08em; color: var(--ink-dim); }
.capchips { display: flex; flex-wrap: wrap; gap: 4px; }
.capchip { font-size: 11px; padding: 2px 6px; border: 1px solid var(--line, #d0d5d2); border-radius: 2px; font-family: var(--font-mono, monospace); }
.form-grid { display: grid; gap: 12px; max-width: 520px; }
.form-grid .field { display: flex; flex-direction: column; gap: 4px; }
.banner.ok { background: rgba(0, 229, 160, 0.14); }
.login-card .brand-logo { background: var(--ink); padding: 12px 16px; box-sizing: content-box; margin-bottom: 4px; align-self: flex-start; flex: none; height: 36px; width: auto; aspect-ratio: 816 / 192; }
.login-card .kicker { color: var(--muted); }

/* ---- the Run dialog (lib/run-dialog.js) ----------------------------------- */
.run-dialog { width: min(760px, calc(100vw - 32px)); max-height: 90vh; top: 5vh; }
.run-dialog .drawer-body { overflow: visible; }
.run-dialog h3 { margin: 0; font-family: var(--mono); font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.run-dialog .dialog-foot { position: sticky; bottom: 0; background: var(--bg); padding-top: 12px; border-top: 1px solid var(--divider); }
.run-sec { display: flex; flex-direction: column; gap: 10px; }
.run-sec:empty { display: none; }
.run-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; justify-content: space-between; }
.run-dialog .bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.phone-row { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.phone-row input { flex: none; }
.var-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--divider); }
.var-box.err { border-color: var(--down); }
.var-box.off input { opacity: 0.5; }
.var-box input[type="text"], .var-box input[type="password"], .var-box input[type="number"], .var-box input[type="url"], .var-box input:not([type]), .var-box select, .var-box textarea { min-height: 44px; padding: 8px 10px; background: transparent; border: 1px solid var(--divider); color: var(--text); width: 100%; }
.var-box textarea { font-family: var(--mono); font-size: 12px; }
.var-box .bar select { width: auto; }
.var-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.var-name { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.tagline { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.tagline.req { color: var(--down-ink); }
.var-box .msg { font-family: var(--mono); font-size: 11px; color: var(--down-ink); }
.pp-rows { display: flex; flex-direction: column; gap: 8px; }
.pp-row { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.pp-row > span { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.pp-row > input { flex: 2 1 180px; }
.run-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; padding-top: 12px; }
.run-options > summary { cursor: pointer; font-family: var(--mono); font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); min-height: 32px; display: flex; align-items: center; }
.tbl-wrap { overflow-x: auto; }
table.pv { border-collapse: collapse; width: 100%; font-size: 13px; }
table.pv th, table.pv td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--divider); white-space: nowrap; }
table.pv th { font-size: 10px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
table.pv td.unres { color: var(--down-ink); }
table.pv td.muted { color: var(--muted); }
@media (max-width: 760px) {
  .run-dialog { width: calc(100vw - 16px); top: 2vh; max-height: 96vh; }
  .run-dialog .drawer-body { padding: 16px; }
  .run-dialog .dialog-foot { padding: 12px 16px; }
}
.chip.size-sm { height: 32px; padding: 0 10px; font-size: 12px; }

/* friendly automations: titles, icons, labelled variables, the Details editor */
.ico { display: inline-flex; flex: none; color: var(--muted); }
.ico svg { display: block; }
.ico-default { opacity: 0.45; }
.auto-title { display: inline-flex; align-items: center; gap: 10px; }
.auto-sel { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; }
.lib-filter { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--divider); }
.lib-filter input[type="search"] { min-height: 40px; padding: 6px 10px; background: transparent; border: 1px solid var(--divider); color: var(--text); width: 100%; }
.auto-vars { display: flex; flex-direction: column; gap: 8px; }
.auto-var { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--divider); }
.var-label { font-weight: 800; font-size: 14px; overflow-wrap: anywhere; }
.var-help { font-size: 13px; color: var(--muted); }
.run-adv > summary { cursor: pointer; font-family: var(--mono); font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); min-height: 36px; display: flex; align-items: center; }
.run-adv-body { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }
.assign-vars { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 8px; }
.details-dialog { width: min(820px, calc(100vw - 32px)); }
.det-head { display: flex; flex-direction: column; gap: 12px; }
.det-vars-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.det-vars-head h3 { margin: 0; }
.det-rows { display: flex; flex-direction: column; gap: 16px; }
.det-var { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--divider); }
.det-var.err { border-color: var(--down); }
.det-var-head { display: flex; align-items: center; gap: 6px; }
.det-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.det-flags { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.det-flags .check { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; }
.det-flags .check input { width: 18px; height: 18px; min-height: 0; }
.det-prev { opacity: 0.9; }
.det-prev .var-box { border-style: dashed; }
.det-var .field.err input, .det-var .field.err select, .det-var .field.err textarea, .det-head .field.err input { border-color: var(--down); }
.det-var .msg, .det-head .msg { font-family: var(--mono); font-size: 11px; color: var(--down-ink); }
.details-dialog textarea { width: 100%; padding: 8px 10px; background: transparent; border: 1px solid var(--divider); color: var(--text); font: inherit; }
#details-snippet { font-family: var(--mono); font-size: 12px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icon-pick { min-height: 44px; display: flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--divider); color: var(--text); cursor: pointer; padding: 0; }
.icon-pick .ico { color: inherit; }
.icon-pick.on { border-color: var(--rule); box-shadow: inset 0 0 0 1px var(--rule); background: var(--tint); }
.val-row { align-items: baseline; flex-wrap: wrap; }
.val-row .val { overflow-wrap: anywhere; text-align: right; }
.val-multi { text-align: right; overflow-wrap: anywhere; }
