/* embiri UI: components. Plain CSS on the --lf-* tokens (tokens.css),
   no framework, no build. The living style guide is /design. */

/* --- base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--lf-bg);
  color: var(--lf-ink);
  font-family: var(--lf-font);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:not([class]) { color: var(--lf-accent-ink); }
a:not([class]):hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--lf-ring); border-radius: 4px; }
h1, h2, h3, h4 { margin: 0; font-weight: 300; }
p { margin: 0 0 12px; }
ul, ol { margin: 0 0 12px; padding-left: 20px; }
code, pre, kbd, samp { font-family: var(--lf-mono); font-size: 12.5px; }
code { padding: 1px 5px; border-radius: var(--lf-r-sm); background: var(--lf-side); box-shadow: inset 0 0 0 1px var(--lf-line); }
pre { white-space: pre-wrap; margin: 0; padding: 14px; border-radius: 10px; background: var(--lf-side); font-family: var(--lf-font); font-size: 13.5px; }
blockquote {
  margin: 0; padding: 14px 16px; border-radius: 10px; background: var(--lf-side);
  font-size: 17px; font-weight: 300; letter-spacing: -0.01em; line-height: 1.45;
}
q { quotes: "“" "”"; }
details > summary { cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--lf-line); margin: 16px 0; }
svg.icon { flex: none; display: inline-block; vertical-align: middle; }
[hidden] { display: none !important; }

/* utilities */
.muted { color: var(--lf-muted); }
.mono { font-family: var(--lf-mono); font-size: 12px; }
.num { font-family: var(--lf-mono); font-size: 12.5px; text-align: right; white-space: nowrap; }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.ok { color: var(--lf-ok); }
.error { color: var(--lf-danger); }
.flags { color: var(--lf-attention); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.is-tight { gap: 8px; }
.spacer { margin-left: auto; }
.grow { flex: 1; min-width: 0; }
.mb-16 { margin-bottom: 16px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }

/* --- type ---------------------------------------------------------------- */

.display { font-size: 44px; font-weight: 300; letter-spacing: -0.03em; line-height: 1.1; }
.title { font-size: 32px; font-weight: 300; letter-spacing: -0.025em; line-height: 1.15; }
.section-title { font-size: 22px; font-weight: 300; letter-spacing: -0.02em; line-height: 1.25; margin: 32px 0 6px; }
.card-title { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; margin: 0 0 12px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-head .sub { margin: 4px 0 0; color: var(--lf-muted); max-width: 760px; }

/* --- app shell ----------------------------------------------------------- */

.app { display: flex; min-height: 100vh; }
.app-nav {
  width: 240px; flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 14px 12px;
  background: var(--lf-side); border-right: 1px solid var(--lf-line);
}
.app-nav-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.wordmark {
  font-family: var(--lf-font); font-weight: 500; font-size: 17px; line-height: 1;
  letter-spacing: -0.012em; font-kerning: normal; font-optical-sizing: auto;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1; text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
.wordmark.is-display { font-size: 56px; letter-spacing: -0.03em; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--lf-accent); color: var(--lf-on-accent);
}
.app-nav .app-nav-toggle { display: none; margin-left: auto; }
.app-nav-body { display: flex; flex-direction: column; flex: 1; }
.app-nav-group { padding-bottom: 16px; }
.app-nav-group > span { display: block; padding: 0 10px 6px; font-size: 11.5px; color: var(--lf-muted); }
.app-nav-group > div { display: flex; flex-direction: column; gap: 2px; }
.app-nav-item {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px;
  border-radius: var(--lf-r-md); font-size: 13.5px; color: var(--lf-muted);
}
.app-nav-item > span:first-of-type { flex: 1; }
.app-nav-item:hover { background: var(--lf-hover); color: var(--lf-ink); }
.app-nav-item.is-active { background: var(--lf-bg); color: var(--lf-ink); font-weight: 500; box-shadow: var(--lf-shadow-lift); }
.app-nav-count {
  font-family: var(--lf-mono); font-size: 11px; font-weight: 400; min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: var(--lf-r-pill); display: inline-grid; place-items: center;
  background: var(--lf-hover); color: var(--lf-muted);
}
.app-nav-item.is-active .app-nav-count { background: var(--lf-accent); color: var(--lf-on-accent); }
.app-nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.app-nav-tools { display: flex; justify-content: space-between; align-items: center; padding: 0 2px; }
.help-link { font: inherit; font-size: 12px; color: var(--lf-muted); display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; cursor: pointer; }
.help-link:hover { color: var(--lf-ink); }

.run-card { padding: 12px; border-radius: var(--lf-r-lg); background: var(--lf-bg); box-shadow: 0 0 0 1px var(--lf-line); }
.run-card-head { display: flex; gap: 8px; align-items: center; font-size: 12px; }
.run-card-head strong { font-weight: 500; }
.run-card-head .mono { margin-left: auto; font-size: 11px; color: var(--lf-muted); }
.run-card-sub { font-size: 12px; color: var(--lf-muted); margin: 4px 0 10px; overflow-wrap: anywhere; }
.run-card .btn { width: 100%; justify-content: center; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--lf-muted); display: inline-block; }
.dot-ok { background: var(--lf-ok); }
.dot-danger { background: var(--lf-danger); }
.dot-accent { background: var(--lf-accent); }
.dot-attention { background: var(--lf-attention); }
.dot-running { background: var(--lf-accent); animation: lf-pulse 1.2s ease-in-out infinite; }
@keyframes lf-pulse { 50% { opacity: .3; } }

.theme-switch { position: relative; display: inline-flex; padding: 2px; border-radius: var(--lf-r-pill); background: var(--lf-hover); }
/* the pill behind the active button; it slides when the theme changes */
.theme-switch::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 26px; height: 24px; border-radius: var(--lf-r-pill);
  background: var(--lf-bg); box-shadow: 0 1px 2px rgba(20, 18, 12, .08);
}
.theme-switch:has(button:last-child.is-on)::before { transform: translateX(26px); }
.theme-switch:not(:has(.is-on))::before { opacity: 0; }
.theme-switch button {
  position: relative; display: inline-grid; place-items: center; width: 26px; height: 24px; border: 0; border-radius: var(--lf-r-pill);
  background: transparent; color: var(--lf-muted); cursor: pointer; padding: 0;
}
.theme-switch button.is-on { color: var(--lf-ink); }

.app-main { flex: 1; min-width: 0; padding: 32px 36px 48px; }
.app-main.is-flush { padding: 0 0 48px; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .app-nav {
    width: auto; height: auto; position: sticky; z-index: 20; padding: 8px 12px;
    border-right: 0; border-bottom: 1px solid var(--lf-line); overflow: visible;
  }
  .app-nav-brand { padding: 2px 4px; }
  .app-nav .app-nav-toggle { display: inline-flex; }
  .app-nav-body { display: none; padding-top: 12px; }
  .app-nav.is-open .app-nav-body { display: flex; }
  .app-main { padding: 20px 16px 40px; }
  .app-main.is-flush { padding: 0 0 40px; }
  .display { font-size: 34px; }
}

/* --- buttons ------------------------------------------------------------- */

.btn {
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1;
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 16px;
  border: 0; border-radius: var(--lf-r-pill); cursor: pointer; white-space: nowrap;
  background: var(--lf-bg); color: var(--lf-ink); box-shadow: inset 0 0 0 1px var(--lf-line-strong);
  transition: background-color .12s, opacity .12s;
}
.btn:hover { background: var(--lf-hover); }
.btn:focus-visible { box-shadow: inset 0 0 0 1px var(--lf-line-strong), 0 0 0 3px var(--lf-ring); border-radius: var(--lf-r-pill); }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--lf-accent); color: var(--lf-on-accent); box-shadow: none; }
.btn-primary:hover { background: var(--lf-accent-hover); }
.btn-primary:focus-visible { box-shadow: 0 0 0 3px var(--lf-ring); }
.btn-dark { background: var(--lf-ink); color: var(--lf-bg); box-shadow: none; }
.btn-dark:hover { background: var(--lf-ink); opacity: .86; }
.btn-dark:focus-visible { box-shadow: 0 0 0 3px var(--lf-ring); }
.btn-ghost { background: transparent; box-shadow: none; padding: 0 12px; }
.btn-ghost:hover { background: var(--lf-hover); }
.btn-ghost:focus-visible, .btn-danger:focus-visible { box-shadow: 0 0 0 3px var(--lf-ring); }
.btn-ghost.is-accent { color: var(--lf-accent-ink); }
.btn-danger { background: transparent; color: var(--lf-danger); box-shadow: none; padding: 0 12px; }
.btn-danger:hover { background: var(--lf-danger-soft); }
/* text in the canvas colour: white on the light theme's red, dark on the dark theme's */
.btn-danger-solid { background: var(--lf-danger); color: var(--lf-bg); box-shadow: none; }
.btn-danger-solid:hover { background: var(--lf-danger); opacity: .88; }
.btn-danger-solid:focus-visible { box-shadow: 0 0 0 3px var(--lf-ring); }
.btn-sm { height: 28px; padding: 0 12px; font-size: 12.5px; gap: 6px; }
.btn-ghost.btn-sm, .btn-danger.btn-sm { padding: 0 10px; }
.btn-icon { width: 32px; padding: 0; justify-content: center; }
.btn-icon.btn-sm { width: 28px; padding: 0; }
.btn .kbd { margin-right: -6px; }
.btn-primary .kbd { background: rgba(255, 255, 255, .18); color: inherit; box-shadow: none; }

/* busy: hx-disable keeps it disabled, .htmx-request (the button that asked)
   or .is-busy (set by base.html, e.g. on a form's submit button) shows the
   spinner in the icon's place. Only on the button itself: a list being
   reloaded (hx-indicator) must not spin every button in it. */
.spinner {
  display: none; width: 13px; height: 13px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; animation: lf-spin .7s linear infinite;
}
.btn.htmx-request .spinner, .htmx-request.spinner, .is-busy .spinner, .spinner.is-on { display: inline-block; }
.btn.htmx-request, .btn.is-busy { cursor: progress; }
.btn.htmx-request[disabled], .btn.is-busy[disabled] { opacity: .75; }
.btn.htmx-request > .spinner + .icon, .is-busy > .spinner + .icon { display: none; }
@keyframes lf-spin { to { transform: rotate(360deg); } }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }

/* --- fields -------------------------------------------------------------- */

.label { display: block; font-size: 12px; color: var(--lf-muted); margin-bottom: 6px; }
.help { display: block; margin-top: 5px; font-size: 12px; color: var(--lf-muted); }
.field, .input, .select, .textarea {
  font: inherit; color: var(--lf-ink); background: var(--lf-bg);
  border: 1px solid var(--lf-line-strong); border-radius: var(--lf-r-md);
  transition: border-color .12s, box-shadow .12s;
}
.field { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px 0 12px; }
.field > .icon { color: var(--lf-muted); }
.field > input, .field > select {
  font: inherit; flex: 1; min-width: 0; border: 0; padding: 0; background: transparent; color: var(--lf-ink); outline: none;
  box-shadow: none; /* the field draws the ring (focus-within), not the input */
}
.field > input[type=search]::-webkit-search-cancel-button { display: none; }
.field-search .spinner { width: 13px; height: 13px; margin: 0 1px; color: var(--lf-muted); }
.field-search.is-searching > .search-icon { display: none; }
.field-search.is-searching > .spinner { display: inline-block; }
.field-clear {
  display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: var(--lf-hover); color: var(--lf-muted); cursor: pointer; flex: none;
}
.field-clear:hover { color: var(--lf-ink); }
/* empty: the clear button leaves the layout, so the key hint sits at the end */
.field-search:has(input:placeholder-shown) .field-clear { display: none; }
.field-search:not(:has(input:placeholder-shown)) .kbd { display: none; }
.field > .field-key { color: var(--lf-muted); white-space: nowrap; }
.field > input[type=number] { font-family: var(--lf-mono); text-align: right; width: 3ch; appearance: textfield; -moz-appearance: textfield; }
.field > input[type=number]::-webkit-inner-spin-button,
.field > input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
/* number stepper in place of the native spin buttons (base.html, data-step) */
.field-stepper { display: flex; flex-direction: column; flex: none; margin-right: -4px; }
.field-stepper button {
  display: grid; place-items: center; width: 18px; height: 13px; padding: 0; border: 0; border-radius: 4px;
  background: transparent; color: var(--lf-muted); cursor: pointer;
}
.field-stepper button:hover { color: var(--lf-ink); background: var(--lf-hover); }
.field-stepper button:disabled { opacity: .35; cursor: default; background: transparent; }
.input, .select { height: 32px; padding: 0 12px; width: 100%; }
.input.is-narrow { max-width: 300px; }
.textarea { width: 100%; min-height: 76px; padding: 8px 12px; resize: vertical; display: block; line-height: 1.5; }
.textarea.is-code { font-family: var(--lf-mono); font-size: 12.5px; min-height: 260px; }
.select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B6860' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.field:hover, .input:hover, .select:hover, .textarea:hover { border-color: var(--lf-muted); }
.field:focus-within, .input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--lf-accent); box-shadow: 0 0 0 3px var(--lf-ring); border-radius: var(--lf-r-md);
}
.field.is-error, .input.is-error { border-color: var(--lf-danger); }
.field.is-error + .help, .input.is-error + .help { color: var(--lf-danger); }
.field.is-disabled, .input:disabled, .select:disabled, .textarea:disabled { background: var(--lf-side); opacity: .6; cursor: not-allowed; }
.field.is-mono input { font-family: var(--lf-mono); font-size: 12.5px; }

.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input {
  appearance: none; -webkit-appearance: none; margin: 0; width: 16px; height: 16px; border-radius: var(--lf-r-sm);
  box-shadow: inset 0 0 0 1px var(--lf-line-strong); background: var(--lf-bg); display: grid; place-items: center; cursor: pointer;
}
.check input:checked {
  background: var(--lf-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center no-repeat;
  box-shadow: none;
}
.check input:focus-visible { box-shadow: 0 0 0 3px var(--lf-ring); }

.kbd {
  font-family: var(--lf-mono); font-size: 11px; font-weight: 400; line-height: 1;
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: var(--lf-r-kbd); background: var(--lf-side); color: var(--lf-ink);
  box-shadow: inset 0 0 0 1px var(--lf-line), inset 0 -1px 0 var(--lf-line-strong);
}

/* select drawn as a small button (reject-with-reason) */
.select-btn {
  font: inherit; font-size: 12.5px; font-weight: 500; appearance: none; -webkit-appearance: none;
  height: 28px; padding: 0 26px 0 12px; border: 0; border-radius: var(--lf-r-pill); cursor: pointer;
  background: var(--lf-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6860' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 9px center no-repeat;
  color: var(--lf-ink); box-shadow: inset 0 0 0 1px var(--lf-line-strong);
}
.select-btn { display: inline-flex; align-items: center; gap: 6px; }
.select-btn:hover { background-color: var(--lf-hover); }
.select-btn:focus-visible, .select-btn:focus { outline: none; box-shadow: inset 0 0 0 1px var(--lf-line-strong), 0 0 0 3px var(--lf-ring); }
.select-btn.is-lg { height: 32px; font-size: 13px; padding-left: 16px; }

/* --- menu ---------------------------------------------------------------- */

/* ui.dropdown(): a trigger button and a popover menu. The popover lives in the
   top layer, so a table's overflow can't clip it; base.html places it. */
.dd-trigger { display: inline-flex; align-items: center; gap: 6px; text-align: left; }
.dd-trigger .dd-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.dd-trigger.is-busy { cursor: progress; }
.dd-trigger.select-btn.is-icon.is-busy .dd-label, .dd-trigger.btn-icon.is-busy .dd-label { display: none; }
.select.dd-trigger { display: flex; }
.select.dd-trigger .dd-label { flex: 1; }
.select-btn.dd-trigger[aria-expanded="true"], .btn.dd-trigger[aria-expanded="true"] { background-color: var(--lf-hover); }
.select.dd-trigger[aria-expanded="true"] { border-color: var(--lf-accent); box-shadow: 0 0 0 3px var(--lf-ring); }
.tag-select.dd-trigger .spinner { width: 10px; height: 10px; border-width: 1.5px; }

.menu {
  min-width: 200px; padding: 4px; border-radius: var(--lf-r-lg); background: var(--lf-bg);
  box-shadow: var(--lf-shadow-menu); display: flex; flex-direction: column; gap: 1px;
}
/* it inherits from wherever it sits in the page (a mono .num cell, a muted
   row), so it sets its own type */
.menu[popover] {
  position: fixed; inset: auto; margin: 0; border: 0; color: var(--lf-ink);
  font-family: var(--lf-font); font-size: 13px; font-weight: 400; line-height: 1.5;
  text-align: left; white-space: nowrap; text-decoration: none; letter-spacing: normal;
  max-height: min(380px, calc(100vh - 16px)); overflow-y: auto;
}
.menu[popover]:not(:popover-open) { display: none; }
.menu-head { padding: 6px 10px 4px; font-size: 11.5px; color: var(--lf-muted); }
.menu-item {
  font: inherit; font-size: 13px; display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 10px; width: 100%;
  border: 0; border-radius: var(--lf-r-md); background: transparent; color: var(--lf-ink); cursor: pointer; text-align: left;
}
.menu-item > span { flex: 1; }
.menu-item > .icon { color: var(--lf-muted); }
.menu-item:hover, .menu-item:focus-visible, .menu-item:focus { background: var(--lf-hover); box-shadow: none; outline: none; border-radius: var(--lf-r-md); }
.menu-item.is-selected { font-weight: 500; }
.menu-item.is-selected > .icon { color: var(--lf-accent-ink); }

/* --- segmented control and status chips ---------------------------------- */

.seg { display: inline-flex; padding: 3px; border-radius: var(--lf-r-pill); background: var(--lf-side); box-shadow: inset 0 0 0 1px var(--lf-line); }
.seg > a, .seg > button {
  font: inherit; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px;
  border: 0; border-radius: var(--lf-r-pill); background: transparent; color: var(--lf-muted); cursor: pointer; white-space: nowrap;
}
.seg > a:hover, .seg > button:hover { color: var(--lf-ink); }
.seg > .is-on { background: var(--lf-bg); color: var(--lf-ink); font-weight: 500; box-shadow: var(--lf-shadow-lift); }
.seg .mono { font-size: 11px; color: var(--lf-muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px 0 14px;
  border-radius: var(--lf-r-pill); font-size: 13px; color: var(--lf-muted); box-shadow: inset 0 0 0 1px var(--lf-line);
}
.chip:hover { color: var(--lf-ink); background: var(--lf-side); }
.chip-count {
  font-family: var(--lf-mono); font-size: 11.5px; min-width: 22px; height: 20px; padding: 0 6px;
  border-radius: var(--lf-r-pill); display: inline-grid; place-items: center; background: var(--lf-hover); color: var(--lf-muted);
}
.chip.is-active { background: var(--lf-ink); color: var(--lf-bg); font-weight: 500; box-shadow: none; }
.chip.is-active .chip-count { background: var(--lf-accent); color: var(--lf-on-accent); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 12px; }
.toolbar .field-search { flex: 0 1 300px; }
.toolbar .field-min { width: 140px; }

/* --- tags, score, flags -------------------------------------------------- */

.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px;
  font-size: 12px; font-weight: 500; line-height: 1; border-radius: var(--lf-r-pill); white-space: nowrap;
  background: var(--lf-hover); color: var(--lf-muted);
}
.tag-plain { background: transparent; font-weight: 400; color: var(--lf-muted); box-shadow: inset 0 0 0 1px var(--lf-line); }
.tag-new, .tag-draft { background: var(--lf-st-new-bg); color: var(--lf-st-new-fg); }
.tag-shortlisted { background: transparent; color: var(--lf-st-short-fg); box-shadow: inset 0 0 0 1px var(--lf-st-short-fg); }
.tag-contacted { background: var(--lf-st-contacted-bg); color: var(--lf-st-contacted-fg); }
.tag-replied, .tag-reply { background: var(--lf-st-replied-bg); color: var(--lf-st-replied-fg); }
.tag-call_booked { background: var(--lf-st-call-bg); color: var(--lf-st-call-fg); }
.tag-won { background: var(--lf-st-won-bg); color: var(--lf-st-won-fg); }
.tag-rejected { background: transparent; color: var(--lf-st-rejected-fg); box-shadow: inset 0 0 0 1px var(--lf-line); text-decoration: line-through; }
.tag-archived { background: var(--lf-st-archived-bg); color: var(--lf-st-archived-fg); }
.tag-sent, .tag-ok, .tag-confirmed { background: var(--lf-ok-soft); color: var(--lf-ok); }
.tag-failed, .tag-bounce, .tag-bounced, .tag-danger, .tag-contradicted { background: var(--lf-danger-soft); color: var(--lf-danger); }
.tag-auto_reply { background: var(--lf-side); color: var(--lf-muted); }
.tag-warn, .tag-unverified, .tag-unclear { background: var(--lf-attention-soft); color: var(--lf-attention); }
.tag-prospect { color: var(--lf-attention); background: transparent; box-shadow: inset 0 0 0 1px currentColor; font-weight: 400; }
.tag-posting { color: var(--lf-muted); background: transparent; box-shadow: inset 0 0 0 1px var(--lf-line); font-weight: 400; }

/* a status <select> drawn as its tag */
.tag-select {
  font: inherit; font-size: 12px; font-weight: 500; appearance: none; -webkit-appearance: none;
  height: 22px; padding: 0 22px 0 9px; border: 0; border-radius: var(--lf-r-pill); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238A877F' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center;
}
.tag-select:focus-visible, .tag-select:focus { outline: none; box-shadow: 0 0 0 3px var(--lf-ring); }
.tag-select.tag-shortlisted:focus { box-shadow: inset 0 0 0 1px var(--lf-st-short-fg), 0 0 0 3px var(--lf-ring); }
.tag-select { display: inline-flex; align-items: center; gap: 5px; line-height: 1; }

.score {
  display: inline-flex; align-items: center; justify-content: center; height: 22px; min-width: 30px; padding: 0 8px;
  border-radius: var(--lf-r-pill); font-family: var(--lf-mono); font-size: 12.5px;
  background: var(--lf-hover); color: var(--lf-muted);
}
.score.is-hi { background: var(--lf-accent); color: var(--lf-on-accent); font-weight: 500; }

.flag { display: inline-flex; align-items: center; gap: 4px; color: var(--lf-attention); font-size: 12px; }

/* --- notices, cards, stats, empty, toast, avatar ------------------------- */

.notice { display: flex; gap: 10px; padding: 10px 14px; border-radius: var(--lf-r-lg); background: var(--lf-side); color: var(--lf-ink); font-size: 13px; }
.notice > .icon { margin-top: 2px; }
.notice > div, .notice > span { flex: 1; min-width: 0; }
.notice a { text-decoration: underline; color: inherit; }
.notice-warn { background: var(--lf-attention-soft); color: var(--lf-attention); }
.notice-ok { background: var(--lf-ok-soft); color: var(--lf-ok); }
.notice-danger { background: var(--lf-danger-soft); color: var(--lf-danger); }
.notice strong { font-weight: 500; }

.card { padding: 18px 20px; border-radius: var(--lf-r-lg); background: var(--lf-bg); box-shadow: inset 0 0 0 1px var(--lf-line); min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.card-head .card-title { margin: 0; }
.card-head > .small, .card-head > .muted { font-size: 12px; color: var(--lf-muted); }
.card.is-sunk { background: var(--lf-side); }
.card > :last-child { margin-bottom: 0; }

.stats {
  display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  border-radius: var(--lf-r-lg); box-shadow: inset 0 0 0 1px var(--lf-line); overflow: hidden;
}
.stat { padding: 12px 16px; box-shadow: inset 1px 0 0 var(--lf-line); min-width: 0; }
.stat:first-child { box-shadow: none; }
.stat-label { font-size: 12px; color: var(--lf-muted); }
.stat-value { margin-top: 2px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.stat-value > b { font-weight: 400; font-size: 20px; letter-spacing: -0.01em; white-space: nowrap; }
.stat-value > .score { font-size: 15px; height: 24px; }
.stat-sub { font-size: 11.5px; color: var(--lf-muted); }
.stat-bar { height: 4px; border-radius: var(--lf-r-pill); background: var(--lf-hover); margin-top: 8px; overflow: hidden; }
.stat-bar > i { display: block; height: 100%; border-radius: var(--lf-r-pill); background: var(--lf-accent); }
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { box-shadow: inset 1px 0 0 var(--lf-line), inset 0 1px 0 var(--lf-line); }
}

.empty { padding: 22px; border-radius: var(--lf-r-lg); box-shadow: inset 0 0 0 1px var(--lf-line); text-align: center; }
.empty strong { display: block; font-weight: 500; }
.empty span { color: var(--lf-muted); font-size: 12.5px; }

.toast {
  display: inline-flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-radius: var(--lf-r-lg);
  background: var(--lf-ink); color: var(--lf-bg); box-shadow: 0 12px 32px rgba(20, 18, 12, .18);
}
.toast button { font: inherit; font-weight: 500; height: 26px; padding: 0 10px; border-radius: var(--lf-r-pill); border: 0; background: rgba(255, 255, 255, .14); color: inherit; cursor: pointer; }
.toast button[aria-label] { width: 26px; padding: 0; display: inline-grid; place-items: center; background: transparent; opacity: .7; }
.toast button[aria-label]:hover { opacity: 1; background: rgba(255, 255, 255, .14); }
/* the toast is ink on either theme, so tones show by icon (check, warn), not colour */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 90; pointer-events: none;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.toasts .toast { pointer-events: auto; max-width: min(440px, calc(100vw - 32px)); font-size: 13px; }
.toasts .toast > span { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { .toasts { left: 16px; align-items: stretch; } }

.avatar {
  width: 28px; height: 28px; flex: none; border-radius: var(--lf-r-md); display: grid; place-items: center;
  font-size: 11.5px; font-weight: 500; background: var(--lf-side); color: var(--lf-ink); box-shadow: inset 0 0 0 1px var(--lf-line);
  position: relative;
}
/* a lead site's favicon over the initials, on white, since most are drawn
   for a light browser tab. In the dark theme it sits on the tile instead,
   unless lfIconTone() (base.html) found dark ink on a transparent ground,
   which would vanish there: .needs-plate keeps the white. */
.avatar > img {
  position: absolute; inset: 0; width: 100%; height: 100%; padding: 5px; object-fit: contain;
  border-radius: inherit; background: #fff; box-shadow: inset 0 0 0 1px var(--lf-line);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .avatar > img:not(.needs-plate) { background: var(--lf-side); }
}
:root[data-theme="dark"] .avatar > img:not(.needs-plate) { background: var(--lf-side); }

/* --- tables -------------------------------------------------------------- */

/* a real border, not an inset shadow: cells with a background (head, group
   rows, hover, cursor) would paint over a shadow and cut the outline */
.table-wrap { position: relative; overflow-x: auto; border-radius: var(--lf-r-lg); border: 1px solid var(--lf-line); }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--lf-muted); background: var(--lf-side);
  height: 34px; padding: 0 12px; white-space: nowrap;
}
.table td { padding: 6px 12px; height: 40px; vertical-align: middle; border-top: 1px solid var(--lf-line); }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table th.num, .table td.num { text-align: right; }
.table th.num { font-family: var(--lf-font); font-size: 12px; }
.table tbody tr:hover > td { background: var(--lf-hover); }
.table tbody tr.is-cursor > td { background: var(--lf-cursor); }
.table tr.is-muted > td { color: var(--lf-muted); }
.table .group-row > td { height: 30px; padding-top: 0; padding-bottom: 0; font-size: 12px; color: var(--lf-muted); background: var(--lf-bg); }
.table .group-row:hover > td { background: var(--lf-bg); }
.table.is-top td { vertical-align: top; padding-top: 10px; padding-bottom: 10px; }
.table.is-compact td { height: 36px; }
.table.is-wide { min-width: 900px; }
.table .sub { display: block; font-size: 12px; color: var(--lf-muted); }
.table .clip { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table caption { caption-side: bottom; text-align: left; padding: 8px 16px; font-size: 12px; color: var(--lf-muted); }
th a.sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
th a.sort:hover { color: var(--lf-ink); }
th a.sort.active { color: var(--lf-ink); }
/* one arrow per sortable header: faint on hover, solid when active; it turns
   when the order flips (the morph keeps the element, so it can animate) */
.sort-arrow { display: inline-grid; opacity: 0; }
.sort-arrow.is-down { transform: rotate(180deg); }
th a.sort:hover .sort-arrow { opacity: .45; }
th a.sort.active .sort-arrow { opacity: 1; }

/* a row a filter just removed, fading out over the list (base.html) */
.row-ghost { position: fixed; z-index: 5; pointer-events: none; margin: 0; table-layout: fixed; background: var(--lf-bg); }
.row-ghost td { border-top-color: transparent; }

/* the active chip's pill sliding to its new place (base.html) */
.chips, .seg { position: relative; }
.chips > *, .seg > * { position: relative; z-index: 1; }
.pill-ghost { position: absolute; z-index: 0; pointer-events: none; }
.chip.is-sliding, .seg > .is-sliding { background: transparent !important; box-shadow: none !important; }

/* leads list */
.lead-table { min-width: 980px; }
.lead-table td { height: 44px; }
.lead-cell { display: flex; gap: 10px; align-items: center; min-width: 0; }
.lead-cell > span { min-width: 0; }
.lead-title { display: block; font-weight: 500; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-title:hover { text-decoration: underline; }
.lead-meta { display: block; font-size: 12px; color: var(--lf-muted); max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.why { max-width: 300px; }
.why .clip { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.why.has-flags .clip:first-child { color: var(--lf-attention); }
.why .mono { display: block; font-size: 11px; color: var(--lf-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-actions { display: inline-flex; gap: 6px; align-items: center; }
.dup-badge { display: inline-flex; margin-left: 6px; vertical-align: middle; }
.shortcut-bar { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; color: var(--lf-muted); font-size: 12px; }

/* key/value tables (estimate, register) */
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv th { text-align: left; font-weight: 400; color: var(--lf-muted); padding: 7px 0; vertical-align: top; }
.kv td { padding: 7px 0 7px 12px; text-align: right; vertical-align: top; }
.kv tr + tr > * { border-top: 1px solid var(--lf-line); }
.kv .num { font-size: 12px; }
.kv .note { display: block; font-size: 12px; color: var(--lf-muted); font-family: var(--lf-font); white-space: normal; }
.kv-box { border-radius: 10px; box-shadow: inset 0 0 0 1px var(--lf-line); overflow: hidden; }
.kv-box .kv th, .kv-box .kv td { padding: 9px 14px; }
.kv-box .kv td.num { width: 30%; }
.kv-box .kv td.note-cell { text-align: left; color: var(--lf-muted); font-size: 12px; }

dl.facts { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 10px 20px; margin: 0; }
dl.facts dt { color: var(--lf-muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* --- lead page ----------------------------------------------------------- */

.crumbs {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 36px; border-bottom: 1px solid var(--lf-line); font-size: 12.5px; color: var(--lf-muted);
}
.crumbs .sep { opacity: .5; margin: 0 4px; }
.crumbs .here { color: var(--lf-ink); }
.crumbs a:hover { color: var(--lf-ink); }
.lead-head { padding: 28px 36px 0; }
.lead-head-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 16px; }
.lead-head-top > div:first-child { min-width: 0; flex: 1 1 480px; }
.lead-head .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.lead-head .meta { margin: 6px 0 0; color: var(--lf-muted); overflow-wrap: anywhere; }
.lead-head .stats { margin-top: 22px; --cols: 6; }
.lead-head .stats-note { margin: 6px 0 0; font-size: 11.5px; color: var(--lf-muted); }
.lead-body { display: flex; flex-wrap: wrap; gap: 20px; padding: 20px 36px 0; align-items: flex-start; }
.lead-main { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.lead-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
#sidebar { display: flex; flex-direction: column; gap: 16px; }
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.activity li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.activity li .dot { margin-top: 7px; }
.activity li > span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.activity li strong { font-weight: 500; }
.activity .mono { font-size: 11px; color: var(--lf-muted); white-space: nowrap; margin-top: 2px; }
@media (max-width: 900px) {
  .crumbs, .lead-head, .lead-body { padding-left: 16px; padding-right: 16px; }
}

/* mail editor */
.mail { border-radius: 10px; border: 1px solid var(--lf-line-strong); overflow: hidden; background: var(--lf-bg); }
.mail:focus-within { border-color: var(--lf-accent); box-shadow: 0 0 0 3px var(--lf-ring); }
.mail-row { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 14px; border-bottom: 1px solid var(--lf-line); }
.mail-row > span:first-child { width: 56px; flex: none; color: var(--lf-muted); font-size: 12.5px; }
.mail-row input { font: inherit; flex: 1; min-width: 0; border: 0; padding: 0; background: transparent; color: var(--lf-ink); outline: none; }
.mail-row input[name=subject] { font-weight: 500; }
.mail textarea {
  font: inherit; font-size: 14px; line-height: 1.6; width: 100%; min-height: 260px; padding: 14px;
  border: 0; background: transparent; color: var(--lf-ink); display: block; resize: vertical; outline: none;
}
.mail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; align-items: center; }
.mail-actions .btn-danger { margin-left: auto; }
.mail-sent { border-radius: 10px; box-shadow: inset 0 0 0 1px var(--lf-line); }
.mail-sent > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; }
.mail-sent > pre { margin: 0 14px 14px; }

/* --- outreach ------------------------------------------------------------ */

.replies-card .row { gap: 8px; }
.reply-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--lf-line); }
.reply-line:first-child { margin-top: 10px; }
.reply-line a { font-weight: 500; }
.reply-line .clip { color: var(--lf-muted); flex: 1; min-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- sync, quality ------------------------------------------------------- */

.run-details { margin-top: 12px; border-radius: var(--lf-r-lg); box-shadow: inset 0 0 0 1px var(--lf-line); }
.run-details > summary { padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.run-details > summary strong { font-weight: 500; font-family: var(--lf-mono); font-size: 12.5px; }
.run-details > .run-body { padding: 0 16px 16px; }
.run-details .facts-line { font-size: 12.5px; margin-bottom: 12px; }
.run-details .facts-line strong { font-weight: 500; }
details.query { margin: 0 0 6px; border-top: 1px solid var(--lf-line); padding-top: 6px; }
details.query > summary { font-size: 13px; padding: 4px 0; }
details.query .query-meta { font-size: 12px; color: var(--lf-muted); margin: 4px 0 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cell-small { font-size: 12px; }
.cell-small strong { font-weight: 500; }

/* --- register chart (strip chart from charts.py) ------------------------- */

.viz-root svg.chart { width: 100%; max-width: 960px; height: auto; display: block; overflow: visible; }
.viz-root text { fill: var(--ink-2); font-size: 12px; font-family: var(--lf-font); }
.viz-root .lane-label { fill: var(--lf-ink); font-size: 13px; }
.viz-root .grid { stroke: var(--grid); stroke-width: 1; }
.viz-root .dot { fill: var(--series-1); stroke: var(--lf-bg); stroke-width: 2; cursor: pointer; }
.viz-root .dot.flagged { fill: var(--critical); }
.viz-root .dot:hover, .viz-root a:focus .dot { stroke: var(--lf-ink); }
.viz-root .median { stroke: var(--lf-ink); stroke-width: 2; }
.viz-root .hit { fill: transparent; cursor: pointer; }
#viz-tip {
  position: fixed; pointer-events: none; display: none; z-index: 40; max-width: 22rem;
  background: var(--lf-bg); color: var(--lf-ink); border-radius: var(--lf-r-md); padding: 6px 10px; font-size: 12.5px;
  box-shadow: var(--lf-shadow-menu);
}
.legend { display: flex; gap: 16px; font-size: 12.5px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.legend i.is-series { background: var(--series-1); }
.legend i.is-critical { background: var(--critical); }
.legend .median-mark { display: inline-block; width: 2px; height: 14px; background: currentColor; margin-right: 6px; vertical-align: middle; }

/* --- dialog -------------------------------------------------------------- */

/* ui.modal(): a <dialog> opened with showModal(). No padding on the dialog
   itself, so a click on it is a click on the backdrop (base.html closes it). */
dialog.modal {
  border: 0; padding: 0; border-radius: var(--lf-r-xl); background: var(--lf-bg); color: var(--lf-ink);
  box-shadow: 0 0 0 1px var(--lf-line), 0 24px 64px rgba(20, 18, 12, .22);
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; overscroll-behavior: contain;
}
dialog.modal.modal-sm { width: min(420px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(20, 18, 12, .38); backdrop-filter: blur(2px); }
body:has(dialog.modal[open]) { overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 14px 0 24px; }
.modal-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 20px; font-weight: 300; letter-spacing: -0.02em; }
.modal-icon {
  width: 32px; height: 32px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: var(--lf-accent-soft); color: var(--lf-accent-ink);
}
.modal.is-danger .modal-icon { background: var(--lf-danger-soft); color: var(--lf-danger); }
.modal-close { align-self: flex-start; color: var(--lf-muted); }
.modal-body { padding: 14px 24px 0; }
.modal-body > :last-child { margin-bottom: 0; }
.export-options fieldset { border: 0; padding: 0; margin: 0 0 20px; }
.export-options legend { font-weight: 600; margin-bottom: 8px; }
.export-options .check { display: flex; margin-bottom: 10px; }
.export-options input[type=radio] { border-radius: 50%; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 20px 24px; }
.confirm-field {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--lf-r-md);
  background: var(--lf-side); box-shadow: inset 0 0 0 1px var(--lf-line); font-size: 12.5px;
}
.confirm-field > span { color: var(--lf-muted); }
.confirm-field > b { font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  /* a sheet docked to the bottom */
  dialog.modal, dialog.modal.modal-sm {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--lf-r-xl) var(--lf-r-xl) 0 0;
  }
  .modal-foot > .btn { flex: 1; justify-content: center; }
}

/* a numbered list of steps (the run modal) */
.steps { list-style: none; margin: 16px 0; padding: 0; display: flex; flex-direction: column; gap: 12px; counter-reset: step; }
.steps > li { display: flex; gap: 12px; align-items: flex-start; counter-increment: step; }
.steps > li::before {
  content: counter(step); flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--lf-mono); font-size: 11px; color: var(--lf-accent-ink); background: var(--lf-accent-soft);
}
.steps strong { display: block; font-weight: 500; }
.steps strong + span { display: block; color: var(--lf-muted); font-size: 12.5px; }
.keys { width: 100%; border-collapse: collapse; }
.keys td { padding: 6px 0; border-top: 1px solid var(--lf-line); }
.keys td:first-child { width: 90px; }
.keys .kbd + .kbd { margin-left: 4px; }

/* --- design page --------------------------------------------------------- */

.ds-section { padding-top: 40px; }
.ds-section > p.muted { max-width: 640px; margin-bottom: 20px; }
.ds-grid { display: grid; gap: 12px; }
.ds-swatch > div:first-child { height: 56px; border-radius: var(--lf-r-lg); box-shadow: inset 0 0 0 1px var(--lf-line); }
.ds-swatch b { display: block; margin-top: 8px; font-weight: 500; }
.ds-states { border-collapse: collapse; }
.ds-states th { text-align: left; font-weight: 400; color: var(--lf-muted); padding: 10px 22px 10px 0; font-size: 12.5px; }
.ds-states td { padding: 12px 22px 12px 0; }
.ds-states tr + tr > * { border-top: 1px solid var(--lf-line); }
.ds-type { width: 100%; border-collapse: collapse; }
.ds-type td { padding: 10px 0; border-top: 1px solid var(--lf-line); vertical-align: baseline; }
.ds-type td:first-child { width: 170px; }
.ds-forced-hover.btn { background: var(--lf-hover); }
.ds-forced-hover.btn-primary { background: var(--lf-accent-hover); }
.ds-forced-hover.btn-dark { opacity: .86; background: var(--lf-ink); }
.ds-forced-hover.btn-ghost { background: var(--lf-hover); }
.ds-forced-hover.btn-danger { background: var(--lf-danger-soft); }
.ds-forced-focus { box-shadow: 0 0 0 3px var(--lf-ring) !important; }
.btn.ds-forced-focus:not(.btn-primary):not(.btn-dark):not(.btn-ghost):not(.btn-danger) { box-shadow: inset 0 0 0 1px var(--lf-line-strong), 0 0 0 3px var(--lf-ring) !important; }
.field.ds-forced-hover { border-color: var(--lf-muted); }
.field.ds-forced-focus { border-color: var(--lf-accent); }
.ds-principles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; padding-bottom: 28px; border-bottom: 1px solid var(--lf-line); }
.ds-principles strong { font-weight: 500; }
.ds-swatches { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.ds-signals { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ds-signals .card { padding: 12px; flex-wrap: nowrap; }
.ds-signals b, .ds-radii b { font-weight: 500; }
.ds-chip { width: 44px; height: 44px; flex: none; border-radius: 10px; }
.ds-split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 48px; }
.ds-split.is-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.ds-split.is-nav { grid-template-columns: 280px minmax(0, 1fr); }
.ds-radii { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ds-radius { height: 56px; background: var(--lf-side); box-shadow: inset 0 0 0 1px var(--lf-line-strong); margin-bottom: 6px; }
.ds-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; align-items: start; }
.ds-fields label { display: block; }
.section-title.is-flat { margin: 0; }
.is-faint { opacity: .6; }
@media (max-width: 1100px) {
  .ds-split, .ds-split.is-even, .ds-split.is-nav { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .ds-swatches { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ds-signals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .ds-principles, .ds-fields, .ds-radii { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-swatches { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ds-signals { grid-template-columns: minmax(0, 1fr); }
}
/* the row's reject menu: a round ✕ with a chevron */
.select-btn.is-icon { width: 40px; padding: 0 0 0 11px; gap: 0; background-position: right 7px center; background-size: 10px; }

.crumbs a:not([class]) { color: var(--lf-muted); }
.crumbs a:not([class]):hover { color: var(--lf-ink); text-decoration: none; }

/* --- loading ------------------------------------------------------------- */

/* the bar on top while a request runs (base.html sets html.is-loading); shown
   only after 150ms, so fast responses don't flicker */
.page-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 100; overflow: hidden;
  pointer-events: none; opacity: 0; transition: opacity var(--lf-dur);
}
.page-progress::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 100%; background: var(--lf-accent); opacity: .7; }
.is-loading .page-progress { opacity: 1; transition-delay: 150ms; }

/* a list being re-sorted or filtered, a row changing status. No scroll
   anchoring: the browser would follow the anchored row to its new place. */
.swap-region { overflow-anchor: none; }
.swap-region .table-wrap { transition: opacity var(--lf-dur); }
.swap-region.htmx-request .table-wrap { opacity: .5; pointer-events: none; transition-delay: 150ms; }
.table tr:has(.htmx-request) > td { opacity: .5; }

/* notes autosave */
.saving { display: none; font-size: 11.5px; color: var(--lf-muted); }
.saving.htmx-request { display: inline; }
.saving.htmx-request + .saved { display: none; }
.saved small { animation: lf-fade-out 2.4s ease forwards; }
.saved-mark { display: inline-flex; align-items: center; gap: 4px; }
.saved-mark path { stroke-dasharray: 1; }
@keyframes lf-fade-out { 70% { opacity: 1; } to { opacity: 0; } }

/* --- motion -------------------------------------------------------------- */

/* the theme switch's circular reveal: base.html animates the new snapshot */
:root.is-theming::view-transition-old(root),
:root.is-theming::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
:root.is-theming *:not(.theme-switch), :root.is-theming *:not(.theme-switch)::before { transition: none !important; }

@media (prefers-reduced-motion: no-preference) {
  .is-loading .page-progress::before { width: 40%; opacity: 1; animation: lf-progress 1.1s var(--lf-ease) infinite; }
  @keyframes lf-progress { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

  .theme-switch::before { transition: transform var(--lf-dur) var(--lf-ease), opacity var(--lf-dur); }
  .theme-switch button { transition: color var(--lf-dur); }

  .chip, .seg > a, .seg > button, .app-nav-item, .select-btn, .tag-select, .menu-item,
  th a.sort, .table tbody tr > td, .field-clear, .field-stepper button, .help-link, .crumbs a {
    transition: background-color var(--lf-dur-fast), color var(--lf-dur-fast), box-shadow var(--lf-dur-fast),
                opacity var(--lf-dur-fast), transform var(--lf-dur-fast) var(--lf-ease);
  }
  /* the clear button pops in when the search gets text */
  @starting-style { .field-clear { opacity: 0; transform: scale(.6); } }

  /* buttons: a soft lift on hover, a press on click, focus ring fades in */
  .btn {
    transition: background-color var(--lf-dur-fast), box-shadow var(--lf-dur-fast), opacity var(--lf-dur-fast),
                transform var(--lf-dur-fast) var(--lf-ease);
  }
  .btn-primary:not([disabled]):hover { box-shadow: 0 6px 16px -6px var(--lf-accent); }
  .btn-dark:not([disabled]):hover, .btn-danger-solid:not([disabled]):hover { box-shadow: 0 6px 16px -8px rgba(20, 18, 12, .5); }
  .btn:not([disabled]):active, .chip:active, .seg > a:active, .seg > button:active,
  .select-btn:active, .tag-select:active, .theme-switch button:active { transform: scale(.96); }
  .menu-item:active { transform: scale(.985); }
  .btn .icon { transition: transform var(--lf-dur) var(--lf-ease); }
  .btn:not([disabled]):hover > .icon-refresh { transform: rotate(-90deg); }
  .btn:not([disabled]):hover > .icon-send, .btn:not([disabled]):hover > .icon-play { transform: translateX(2px); }
  /* the spinner fades in where the icon was */
  .btn .spinner { animation: lf-spin .7s linear infinite, lf-fade-in var(--lf-dur) ease; }
  @keyframes lf-fade-in { from { opacity: 0; } }

  /* nav: the icon nudges, the active item's pill fades in */
  .app-nav-item > .icon { transition: transform var(--lf-dur-fast) var(--lf-ease); }
  .app-nav-item:hover > .icon { transform: translateX(1px) scale(1.06); }
  .app-nav-item.is-active { animation: lf-fade-in var(--lf-dur) ease; }

  /* sort arrow turns with the order, appears on hover */
  .sort-arrow { transition: transform var(--lf-dur) var(--lf-ease), opacity var(--lf-dur-fast); }
  th a.sort:hover .sort-arrow:not(.is-down) { transform: translateY(-1px); }

  /* search: the clear button pops in */
  .field-clear { transition: opacity var(--lf-dur-fast), transform var(--lf-dur-fast) var(--lf-ease), color var(--lf-dur-fast); }
  .field-search .spinner { animation: lf-spin .7s linear infinite, lf-fade-in var(--lf-dur) ease; }

  /* the running dot sends out a ring */
  .dot-running { position: relative; }
  .dot-running::after {
    content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid var(--lf-accent);
    animation: lf-ring 1.6s var(--lf-ease) infinite;
  }
  @keyframes lf-ring { from { transform: scale(.4); opacity: .9; } to { transform: scale(1.4); opacity: 0; } }

  /* menu: items come in one after another, the selected one's check pops */
  .menu[popover]:popover-open > .menu-item, .menu[popover]:popover-open > .menu-head { animation: lf-enter-sm var(--lf-dur) var(--lf-ease) backwards; }
  .menu[popover]:popover-open > :nth-child(2) { animation-delay: 15ms; }
  .menu[popover]:popover-open > :nth-child(3) { animation-delay: 30ms; }
  .menu[popover]:popover-open > :nth-child(4) { animation-delay: 45ms; }
  .menu[popover]:popover-open > :nth-child(5) { animation-delay: 60ms; }
  .menu[popover]:popover-open > :nth-child(6) { animation-delay: 75ms; }
  .menu[popover]:popover-open > :nth-child(n+7) { animation-delay: 90ms; }
  .menu-item.is-selected > .icon { animation: lf-pop var(--lf-dur-slow) var(--lf-ease) 80ms backwards; }
  @keyframes lf-enter-sm { from { opacity: 0; transform: translateY(-3px); } }
  @keyframes lf-pop { from { opacity: 0; transform: scale(.4); } 60% { transform: scale(1.15); } }

  /* toasts slide up; leaving, they slide right */
  .toasts .toast { animation: lf-toast-in var(--lf-dur) var(--lf-ease); }
  .toasts .toast.is-leaving { animation: lf-toast-out var(--lf-dur) ease forwards; }
  .toast > .icon { animation: lf-pop var(--lf-dur-slow) var(--lf-ease) 60ms backwards; }
  @keyframes lf-toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
  @keyframes lf-toast-out { to { opacity: 0; transform: translateX(24px); } }

  /* the notes autosave check draws itself */
  .saved-mark path { animation: lf-draw var(--lf-dur-slow) var(--lf-ease) both; }
  @keyframes lf-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

  /* stat bars grow, empty states rise in */
  .stat-bar > i { transform-origin: left; animation: lf-grow var(--lf-dur-slow) var(--lf-ease) 100ms backwards; }
  @keyframes lf-grow { from { transform: scaleX(0); } }
  .empty { animation: lf-enter var(--lf-dur) var(--lf-ease); }

  /* details (sync runs, sent mails, estimate scope) open smoothly (Chrome) */
  @supports (interpolate-size: allow-keywords) {
    :root { interpolate-size: allow-keywords; }
    details::details-content {
      block-size: 0; overflow: clip;
      transition: block-size var(--lf-dur) var(--lf-ease), content-visibility var(--lf-dur) allow-discrete;
    }
    details[open]::details-content { block-size: auto; }
  }

  /* register chart dots grow under the pointer */
  .viz-root .dot { transform-box: fill-box; transform-origin: center; transition: transform var(--lf-dur-fast) var(--lf-ease); }
  .viz-root .dot:hover, .viz-root a:focus .dot { transform: scale(1.35); }

  /* a full page load: its parts rise in one after another (html.is-booting,
     set for the first 900ms by base.html, so swaps never replay it) */
  .is-booting .app-main > *, .is-booting .lead-main > *, .is-booting .lead-side > * {
    animation: lf-enter var(--lf-dur-slow) var(--lf-ease) backwards;
  }
  .is-booting .app-main > :nth-child(2), .is-booting .lead-main > :nth-child(2), .is-booting .lead-side > :nth-child(2) { animation-delay: 40ms; }
  .is-booting .app-main > :nth-child(3), .is-booting .lead-main > :nth-child(3), .is-booting .lead-side > :nth-child(3) { animation-delay: 80ms; }
  .is-booting .app-main > :nth-child(n+4), .is-booting .lead-main > :nth-child(n+4), .is-booting .lead-side > :nth-child(n+4) { animation-delay: 120ms; }

  /* swapped-in content (base.html adds the class after a swap) */
  .is-entering { animation: lf-enter var(--lf-dur) var(--lf-ease); }
  @keyframes lf-enter { from { opacity: 0; transform: translateY(4px); } }
  tr.is-changed > td { animation: lf-flash 1s ease-out; }
  @keyframes lf-flash { from { background-color: var(--lf-accent-soft); } }

  /* menus and modals open with a short fade and scale, and close the same way */
  .menu[popover], dialog.modal::backdrop {
    transition: opacity var(--lf-dur-fast) ease, transform var(--lf-dur-fast) var(--lf-ease),
                display var(--lf-dur-fast) allow-discrete, overlay var(--lf-dur-fast) allow-discrete;
  }
  .menu[popover] { opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top left; }
  .menu[popover]:popover-open { opacity: 1; transform: none; }
  @starting-style { .menu[popover]:popover-open { opacity: 0; transform: translateY(-4px) scale(.98); } }
  dialog.modal {
    transition: opacity var(--lf-dur) ease, transform var(--lf-dur) var(--lf-ease),
                display var(--lf-dur) allow-discrete, overlay var(--lf-dur) allow-discrete;
    opacity: 0; transform: translateY(8px) scale(.97);
  }
  dialog.modal[open] { opacity: 1; transform: none; }
  dialog.modal::backdrop { opacity: 0; transition-duration: var(--lf-dur); }
  dialog.modal[open]::backdrop { opacity: 1; }
  @starting-style {
    dialog.modal[open] { opacity: 0; transform: translateY(8px) scale(.97); }
    dialog.modal[open]::backdrop { opacity: 0; }
  }
  @media (max-width: 600px) {
    dialog.modal { transform: translateY(100%); }
    @starting-style { dialog.modal[open] { transform: translateY(100%); } }
  }
  /* the run modal's steps come in one by one */
  dialog.modal[open] .steps > li { animation: lf-enter var(--lf-dur) var(--lf-ease) backwards; }
  dialog.modal[open] .steps > li:nth-child(1) { animation-delay: 60ms; }
  dialog.modal[open] .steps > li:nth-child(2) { animation-delay: 100ms; }
  dialog.modal[open] .steps > li:nth-child(3) { animation-delay: 140ms; }
  dialog.modal[open] .steps > li:nth-child(4) { animation-delay: 180ms; }
}

/* Wiki (/wiki): page lists, editor beside its preview, rendered markdown. */
.wiki-home { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.wiki-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13.5px; }
.wiki-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.wiki-editor { min-height: 60vh; }
.wiki-pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto; }
.prose { font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.prose h1 { font-size: 20px; margin: 0 0 12px; letter-spacing: -0.01em; }
.prose h2 { font-size: 15px; margin: 20px 0 8px; }
.prose h3 { font-size: 14px; margin: 16px 0 6px; }
.prose ul, .prose ol { padding-left: 20px; }
.prose code { font-family: var(--lf-mono); font-size: 12.5px; }
.wikilink { text-decoration: underline; text-decoration-color: var(--lf-line-strong); text-underline-offset: 2px; }
.wikilink.is-missing { color: var(--lf-muted); text-decoration-style: dashed; cursor: help; }
@media (max-width: 900px) {
  .wiki-home, .wiki-split { grid-template-columns: minmax(0, 1fr); }
}
