/* Scale — components */

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.main {
  min-width: 0;
  position: relative;
}

.main:focus {
  outline: none;
}

.mobile-bar {
  display: none;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 12px 12px;
  background: var(--shell);
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 8px 14px;
  font-size: var(--fs-14);
  font-weight: 600;
  letter-spacing: -0.005em;
}

.sb-brand .os-mark {
  width: 22px;
  height: 22px;
}

/* The wordmark: the lowercase word beside the mark (together: /scale). Lowercase has its optical middle at the
   x-height, below the middle of the line, so it is lifted onto the middle of the tile. */
.brand-word {
  position: relative;
  top: -0.06em;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.sb-brand .brand-word {
  font-size: 15px;
}

.sb-toggle {
  margin-left: auto;
  color: var(--muted);
}

.sb-toggle:hover {
  color: var(--ink);
}

/* Collapsed rail (desktop only) */
@media (min-width: 861px) {
  .app {
    transition: grid-template-columns var(--d-slow) var(--ease-out);
  }

  body.sb-collapsed {
    --sidebar-w: 64px;
  }

  .sb-collapsed .sidebar {
    padding: 14px 10px 12px;
  }

  .sb-collapsed .sb-text {
    display: none !important;
  }

  .sb-collapsed .sb-brand {
    flex-direction: column;
    gap: 10px;
    padding: 2px 0 12px;
  }

  .sb-collapsed .sb-toggle {
    margin-left: 0;
  }

  .sb-collapsed .sb-ws {
    justify-content: center;
    padding: 6px 0;
    border-color: transparent;
    background: transparent;
  }

  .sb-collapsed .sb-search {
    justify-content: center;
    padding: 0;
  }

  .sb-collapsed .nav-item,
  .sb-collapsed .sb-agent,
  .sb-collapsed .heartbeat,
  .sb-collapsed .sb-user {
    position: relative;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .sb-collapsed .nav-count {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
  }

  .sb-collapsed .nav-count.is-quiet {
    display: none;
  }

  .sb-collapsed .nav-flag {
    position: absolute;
    top: 6px;
    right: 8px;
    margin: 0;
  }

  .sb-collapsed .sb-label {
    justify-content: center;
    padding: 14px 0 8px;
  }

  .sb-collapsed .sb-label::before {
    content: "";
    width: 20px;
    height: 1px;
    background: var(--rule-2);
  }

  .sb-collapsed .sb-agent.is-working::after {
    content: "";
    position: absolute;
    top: 3px;
    right: 10px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--positive);
    box-shadow: 0 0 0 2px var(--shell);
  }

  .sb-collapsed .record-btn {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    padding: 0;
  }

  .sb-collapsed .record-btn.is-recording {
    justify-content: center;
    padding: 0;
  }

  .sb-collapsed .record-btn.is-recording .rec-dot {
    display: none;
  }

  .sb-collapsed .rec-stop {
    width: 28px;
    height: 28px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    background: var(--record);
  }
}

.sb-ws {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--sheet);
  text-align: left;
  transition: border-color var(--d-fast) var(--ease-out);
}

.sb-ws:hover {
  border-color: var(--rule-2);
}

.ws-tile {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: #1D3B34;
  color: #F3EFE6;
  font-size: var(--fs-13);
  font-weight: 650;
  flex: none;
}

.sb-ws-name {
  display: block;
  font-size: var(--fs-14);
  font-weight: 600;
  line-height: 1.2;
}

.sb-ws-sub {
  display: block;
  font-size: var(--fs-12);
  color: var(--muted);
  line-height: 1.3;
}

.sb-ws .icon {
  margin-left: auto;
  color: var(--faint);
}

.sb-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  margin: 10px 0 12px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--sheet) 70%, var(--shell));
  color: var(--muted);
  font-size: var(--fs-13);
  text-align: left;
  transition: border-color var(--d-fast) var(--ease-out), background-color var(--d-fast) var(--ease-out);
}

.sb-search:hover {
  border-color: var(--rule-2);
  background: var(--sheet);
}

.sb-search kbd {
  margin-left: auto;
}

.sb-nav {
  display: grid;
  gap: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 8px 0 10px;
  border-radius: 7px;
  color: var(--ink-2);
  font-size: var(--fs-14);
  font-weight: 500;
  transition: background-color var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out);
}

.nav-item .icon {
  color: var(--muted);
  transition: color var(--d-fast) var(--ease-out);
}

.nav-item:hover {
  background: var(--wash-2);
  color: var(--ink);
}

.nav-item[aria-current="page"] {
  background: var(--tint);
  color: var(--accent-ink);
}

.nav-item[aria-current="page"] .icon {
  color: var(--accent);
}

.nav-count {
  margin-left: auto;
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: #fff;
  font-size: var(--fs-11);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.nav-count.is-quiet {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.sb-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 10px 6px;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--muted);
}

.sb-agent {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 32px;
  padding: 4px 8px 4px 10px;
  border-radius: 7px;
  font-size: var(--fs-13);
  color: var(--ink-2);
  text-align: left;
  transition: background-color var(--d-fast) var(--ease-out);
}

.sb-agent:hover {
  background: var(--wash-2);
}

.sb-agent-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-agent-status {
  font-size: var(--fs-11);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sb-agent-status.is-working {
  color: var(--ink);
  font-weight: 550;
}

.sb-foot {
  margin-top: auto;
  padding-top: 16px;
  display: grid;
  gap: 10px;
}

.heartbeat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  font-size: var(--fs-12);
  color: var(--muted);
  text-align: left;
  line-height: 1.35;
}

.heartbeat:hover {
  color: var(--ink);
}

.record-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 38px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-full);
  background: var(--sheet);
  font-size: var(--fs-14);
  font-weight: 600;
  transition: border-color var(--d-fast) var(--ease-out), background-color var(--d-fast) var(--ease-out);
}

.record-btn:hover {
  border-color: #C2C2BB;
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--record);
  flex: none;
}

.record-btn.is-recording {
  justify-content: space-between;
  padding: 0 6px 0 14px;
  border-color: color-mix(in srgb, var(--record) 45%, var(--rule-2));
}

.record-btn.is-recording .rec-dot {
  animation: rec-pulse 1.6s var(--ease-in-out) infinite;
}

.rec-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.rec-stop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-full);
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-13);
  font-weight: 550;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 7px;
  text-align: left;
}

.sb-user:hover {
  background: var(--wash-2);
}

.sb-user-name {
  display: block;
  font-size: var(--fs-13);
  font-weight: 550;
  line-height: 1.25;
}

.sb-user-sub {
  display: block;
  font-size: var(--fs-12);
  color: var(--muted);
  line-height: 1.25;
}

.sb-demo {
  padding: 0 10px;
  font-size: var(--fs-11);
  color: var(--muted);
  line-height: 1.4;
}

/* ---------- Page ---------- */
.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 32px 40px 72px;
}

.page.is-wide {
  max-width: none;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.page-title {
  font-size: var(--fs-24);
  letter-spacing: -0.018em;
}

.page-title:focus {
  outline: none;
}

.page-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: var(--fs-14);
}

.page-sub a {
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-color: var(--rule-2);
  text-underline-offset: 3px;
}

.page-sub a:hover {
  text-decoration-color: currentColor;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  font-size: var(--fs-13);
  color: var(--muted);
}

.crumbs a:hover {
  color: var(--ink);
}

.crumbs .icon {
  width: 13px;
  height: 13px;
  color: var(--faint);
}

.section-title {
  font-size: var(--fs-17);
  letter-spacing: -0.008em;
}

.sub-title {
  font-size: var(--fs-15);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: var(--fs-13);
}

.xsmall {
  font-size: var(--fs-12);
}

.strong {
  font-weight: 600;
}

.demo-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 18px;
  font-size: var(--fs-12);
  color: var(--muted);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-md);
  background: var(--sheet);
  color: var(--ink);
  font-size: var(--fs-14);
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  transition: background-color var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out), transform var(--d-fast) var(--ease-out);
}

.btn:hover {
  background: var(--wash);
  border-color: #C8C8C1;
}

.btn:active {
  background: var(--wash-2);
  transform: translateY(0.5px);
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.btn-primary:hover {
  background: #313236;
  border-color: #313236;
}

.btn-primary:active {
  background: #000;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--wash);
  border-color: transparent;
}

.btn-danger {
  color: var(--critical);
}

.btn-danger:hover {
  background: var(--critical-tint);
  border-color: color-mix(in srgb, var(--critical) 30%, var(--rule-2));
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: var(--fs-13);
  border-radius: 7px;
  gap: 6px;
}

.btn-sm .icon {
  width: 14px;
  height: 14px;
}

.btn-lg {
  height: 40px;
  padding: 0 18px;
  font-size: var(--fs-15);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.btn-icon.btn-sm {
  width: 28px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: .45;
  pointer-events: none;
}

.btn.is-loading {
  pointer-events: none;
  opacity: .85;
}

.btn.is-loading::before {
  content: "";
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin .7s linear infinite;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-2);
  font-weight: 500;
  font-size: var(--fs-13);
  border-radius: var(--r-xs);
  transition: color var(--d-fast) var(--ease-out);
}

.text-btn:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--rule-2);
}

.text-btn .icon {
  width: 14px;
  height: 14px;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  flex: none;
  color: var(--muted);
  font-size: var(--fs-14);
  font-weight: 500;
  transition: color var(--d-fast) var(--ease-out);
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected="true"],
.tab[aria-current="page"] {
  color: var(--ink);
}

.tab[aria-selected="true"]::after,
.tab[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--ink);
}

.tab .icon {
  width: 16px;
  height: 16px;
}

.tab-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- State markers ---------- */
.state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
  font-size: var(--fs-13);
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.3;
}

.state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}

.state[data-tone="caution"]::before {
  background: #C58716;
}

.state[data-tone="accent"]::before {
  background: var(--accent);
}

.state[data-tone="working"]::before {
  background: var(--ink);
}

.state[data-tone="positive"]::before {
  background: #3B8B5E;
}

.state[data-tone="critical"]::before {
  background: var(--critical);
}

.state[data-tone="quiet"] {
  color: var(--muted);
}

.state[data-tone="quiet"]::before {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--faint);
}

.state.is-dotless::before {
  display: none;
}

.state.is-needs-you {
  padding: 3px 10px 3px 9px;
  border-radius: var(--r-full);
  background: var(--tint);
  color: var(--accent-ink);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  background: var(--wash-2);
  color: var(--ink-2);
  font-size: var(--fs-11);
  font-weight: 550;
  white-space: nowrap;
  line-height: 1;
}

.badge .icon {
  width: 11px;
  height: 11px;
  stroke-width: 2.2;
}

.badge-accent {
  background: var(--tint);
  color: var(--accent-ink);
}

.badge-caution {
  background: var(--caution-tint);
  color: var(--caution);
}

.badge-positive {
  background: var(--positive-tint);
  color: var(--positive);
}

.badge-critical {
  background: var(--critical-tint);
  color: var(--critical);
}

.badge-outline {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--rule-2);
  color: var(--muted);
}

/* ---------- Evidence marks: fill encodes how a claim is known ---------- */
.ev-mark {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  flex: none;
}

.ev-mark[data-kind="observed"] {
  background: var(--ink);
}

.ev-mark[data-kind="calculated"] {
  background: radial-gradient(circle at center, var(--ink) 0 1.9px, transparent 2.4px);
}

.ev-mark[data-kind="inferred"] {
  background: linear-gradient(90deg, var(--ink) 50%, transparent 50%);
}

.ev-mark[data-kind="asserted"] {
  background: transparent;
}

.ev-mark[data-kind="hypothesis"] {
  border-style: dashed;
  border-color: var(--muted);
}

.ev-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: var(--fs-12);
  color: var(--muted);
}

.ev-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Avatars: circles are people, rounded squares are agents ---------- */
.av {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .02em;
  color: var(--ink-2);
  line-height: 1;
}

.av-person {
  border-radius: 50%;
  background: var(--person-1);
}

.av-person[data-hue="2"] { background: var(--person-2); }
.av-person[data-hue="3"] { background: var(--person-3); }
.av-person[data-hue="4"] { background: var(--person-4); }
.av-person[data-hue="5"] { background: var(--person-5); }

.av-agent {
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
}

.av-agent .icon {
  width: 13px;
  height: 13px;
  stroke: #fff;
  stroke-width: 1.8;
}

.av-16 { width: 16px; height: 16px; font-size: 7.5px; letter-spacing: 0; }
.av-16.av-agent { border-radius: 4px; }
.av-16.av-agent .icon { width: 10px; height: 10px; stroke-width: 2; }
.av-18 { width: 18px; height: 18px; font-size: 8.5px; }
.av-18.av-agent { border-radius: 5px; }
.av-18.av-agent .icon { width: 11px; height: 11px; }
.av-20 { width: 20px; height: 20px; font-size: 9px; }
.av-20.av-agent { border-radius: 5px; }
.av-20.av-agent .icon { width: 12px; height: 12px; }
.av-28 { width: 28px; height: 28px; font-size: 11px; }
.av-28.av-agent { border-radius: 7px; }
.av-28.av-agent .icon { width: 15px; height: 15px; }
.av-32 { width: 32px; height: 32px; font-size: 12px; }
.av-32.av-agent { border-radius: 8px; }
.av-32.av-agent .icon { width: 17px; height: 17px; }

.owner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: var(--fs-13);
  color: var(--ink-2);
}

.owner-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Sheet ---------- */
.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
}

.sheet-pad {
  padding: 20px 22px;
}

/* ---------- Key/value ---------- */
.kv {
  display: grid;
  gap: 9px;
}

.kv > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-size: var(--fs-13);
  line-height: 1.4;
}

.kv dt {
  color: var(--muted);
  flex: none;
}

.kv dd {
  text-align: right;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
}

/* ---------- Table ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-14);
}

.table th {
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
  font-size: var(--fs-12);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr.is-link {
  cursor: pointer;
  transition: background-color var(--d-fast) var(--ease-out);
}

.table tbody tr.is-link:hover {
  background: color-mix(in srgb, var(--wash) 60%, var(--sheet));
}

.table .num {
  text-align: right;
}

/* ---------- Forms ---------- */
.field {
  display: grid;
  gap: 6px;
}

.label {
  font-size: var(--fs-13);
  font-weight: 550;
  color: var(--ink);
}

.hint {
  font-size: var(--fs-12);
  color: var(--muted);
  line-height: 1.45;
}

.error-text {
  font-size: var(--fs-12);
  color: var(--critical);
  font-weight: 500;
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-sm);
  background: var(--sheet);
  font-size: var(--fs-14);
  line-height: 1.4;
  transition: border-color var(--d-fast) var(--ease-out), box-shadow var(--d-fast) var(--ease-out);
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: #C4C4BD;
}

.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--tint-2);
  outline: none;
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--critical);
  box-shadow: 0 0 0 3px var(--critical-tint);
}

.textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.5;
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2365686E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: var(--fs-13);
  line-height: 1.45;
  cursor: pointer;
}

.check input {
  margin-top: 2px;
}

.choices {
  display: grid;
  gap: 6px;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  background: var(--sheet);
  cursor: pointer;
  transition: border-color var(--d-fast) var(--ease-out), background-color var(--d-fast) var(--ease-out);
}

.choice:hover {
  border-color: var(--rule-2);
}

.choice:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--rule-2));
  background: var(--tint);
}

.choice input {
  margin-top: 2px;
}

.choice-title {
  display: block;
  font-size: var(--fs-14);
  font-weight: 550;
  line-height: 1.35;
}

.choice-desc {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-12);
  color: var(--muted);
  line-height: 1.4;
}

.switch {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: var(--r-full);
  background: var(--rule-2);
  flex: none;
  transition: background-color var(--d-base) var(--ease-out);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(23, 23, 23, .2);
  transition: transform var(--d-base) var(--ease-out);
}

.switch[aria-checked="true"] {
  background: var(--accent);
}

.switch[aria-checked="true"]::after {
  transform: translateX(14px);
}

.switch:disabled {
  opacity: .5;
}

/* ---------- Chips (filters) ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-full);
  background: var(--sheet);
  color: var(--ink-2);
  font-size: var(--fs-13);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out);
}

.chip:hover {
  border-color: #C4C4BD;
}

.chip[aria-pressed="true"] {
  background: var(--tint);
  border-color: var(--tint-2);
  color: var(--accent-ink);
}

.chip .icon {
  width: 14px;
  height: 14px;
}

/* ---------- Notices ---------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--wash);
  color: var(--ink-2);
  font-size: var(--fs-13);
  line-height: 1.45;
}

.notice .icon {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  color: var(--muted);
}

.notice-accent {
  background: var(--tint);
  color: var(--accent-ink);
}

.notice-accent .icon {
  color: var(--accent);
}

.notice-caution {
  background: var(--caution-tint);
  color: #6F470C;
}

.notice-caution .icon {
  color: var(--caution);
}

.notice-positive {
  background: var(--positive-tint);
  color: #215A3B;
}

.notice-positive .icon {
  color: var(--positive);
}

.notice-body {
  flex: 1;
  min-width: 0;
}

.notice-title {
  font-weight: 600;
  color: inherit;
}

.notice-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ---------- Empty states ---------- */
.empty {
  padding: 28px 28px 26px;
  border: 1px dashed var(--rule-2);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--sheet) 55%, transparent);
}

.empty-title {
  font-size: var(--fs-15);
  font-weight: 600;
}

.empty p {
  margin-top: 6px;
  max-width: 56ch;
  color: var(--muted);
  font-size: var(--fs-14);
}

.empty .btn {
  margin-top: 16px;
}

/* ---------- Progress ---------- */
.progress {
  height: 4px;
  border-radius: var(--r-full);
  background: var(--wash-2);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
  transform: scaleX(var(--p, 0));
  transform-origin: left center;
  transition: transform var(--d-slow) var(--ease-out);
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin .7s linear infinite;
  flex: none;
}

/* ---------- Popover and menu ---------- */
.pop {
  position: fixed;
  z-index: 70;
  min-width: 240px;
  max-width: min(380px, calc(100vw - 24px));
  max-height: min(480px, calc(100vh - 24px));
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--sheet);
  box-shadow: var(--shadow-pop);
  animation: pop-in var(--d-base) var(--ease-out);
}

.pop-head {
  padding: 8px 10px 6px;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--muted);
}

.pop-body {
  padding: 6px 10px 10px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: var(--fs-14);
  text-align: left;
  color: var(--ink);
  transition: background-color var(--d-fast) var(--ease-out);
}

.menu-item:hover,
.menu-item[aria-selected="true"] {
  background: var(--wash);
}

.menu-item .icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.menu-item-sub {
  display: block;
  font-size: var(--fs-12);
  color: var(--muted);
  line-height: 1.3;
}

.menu-item-meta {
  margin-left: auto;
  font-size: var(--fs-12);
  color: var(--muted);
  white-space: nowrap;
}

.menu-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--rule);
}

/* ---------- Dialog ---------- */
dialog.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--shadow-dialog);
  overflow: auto;
}

dialog.dialog[open] {
  animation: dialog-in var(--d-slow) var(--ease-out);
}

dialog.dialog::backdrop {
  background: rgba(23, 23, 23, .30);
  animation: fade-in var(--d-base) var(--ease-out);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 4px;
}

.dialog-title {
  font-size: var(--fs-17);
}

.dialog-body {
  display: grid;
  gap: 16px;
  padding: 12px 22px 20px;
  font-size: var(--fs-14);
}

.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px 16px;
  border-top: 1px solid var(--rule);
  background: color-mix(in srgb, var(--canvas) 60%, var(--sheet));
}

.dialog-foot .foot-note {
  margin-right: auto;
  font-size: var(--fs-12);
  color: var(--muted);
}

/* ---------- Drawer ---------- */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  display: flex;
  flex-direction: column;
  width: min(440px, 100vw);
  background: var(--sheet);
  border-left: 1px solid var(--rule);
  box-shadow: var(--shadow-pop);
  transform: translateX(104%);
  visibility: hidden;
  transition: transform var(--d-slow) var(--ease-out), visibility 0s linear var(--d-slow);
}

.drawer.is-open {
  transform: none;
  visibility: visible;
  transition: transform var(--d-slow) var(--ease-out), visibility 0s;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 12px 10px 20px;
  border-bottom: 1px solid var(--rule);
}

.drawer-title {
  font-size: var(--fs-15);
  font-weight: 600;
  line-height: 1.3;
}

.drawer-sub {
  font-size: var(--fs-12);
  color: var(--muted);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

.drawer-foot {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--rule);
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 90;
  display: grid;
  justify-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  max-width: min(600px, calc(100vw - 32px));
  padding: 9px 9px 9px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-14);
  line-height: 1.4;
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  animation: toast-in var(--d-slow) var(--ease-out);
}

.toast.is-leaving {
  animation: toast-out var(--d-base) var(--ease-out) forwards;
}

.toast .icon {
  width: 16px;
  height: 16px;
  color: #C9CCD1;
}

.toast-text {
  flex: 1;
}

.toast-action {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: var(--fs-13);
  font-weight: 550;
  white-space: nowrap;
}

.toast-action:hover {
  background: rgba(255, 255, 255, .2);
}

/* ---------- Command palette ---------- */
dialog.cmdk {
  width: min(620px, calc(100vw - 24px));
  margin-top: 12vh;
}

.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
}

.cmdk-input-wrap .icon {
  color: var(--muted);
}

.cmdk-input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: var(--fs-15);
  outline: none;
}

.cmdk-list {
  max-height: min(420px, 60vh);
  overflow-y: auto;
  padding: 6px;
}

.cmdk-group {
  padding: 10px 10px 4px;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--muted);
}

.cmdk-empty {
  padding: 22px 16px;
  color: var(--muted);
  font-size: var(--fs-14);
}

.cmdk-foot {
  display: flex;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--rule);
  font-size: var(--fs-12);
  color: var(--muted);
}

.cmdk-foot span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ---------- Tooltip ---------- */
.tip {
  position: fixed;
  z-index: 75;
  max-width: 280px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-12);
  line-height: 1.45;
  box-shadow: var(--shadow-pop);
  pointer-events: none;
  animation: fade-in var(--d-fast) var(--ease-out);
}

.tip strong {
  display: block;
  font-size: var(--fs-13);
  font-weight: 600;
  margin-bottom: 3px;
}

.tip .tip-meta {
  color: #C9CCD1;
}

/* ---------- Mini spine: the case file's lifecycle, one node per stage ---------- */
.mini-spine {
  display: inline-flex;
  align-items: center;
  flex: none;
}

.mini-spine i {
  position: relative;
  width: 7px;
  height: 7px;
  border: 1.25px solid var(--faint);
  border-radius: 50%;
  background: var(--sheet);
  flex: none;
}

.mini-spine i + i {
  margin-left: 5px;
}

.mini-spine i + i::before {
  content: "";
  position: absolute;
  top: 50%;
  right: calc(100% + 1px);
  width: 5px;
  height: 1px;
  background: var(--rule-2);
}

.mini-spine i.is-done {
  border: 0;
  background: var(--ink);
}

.mini-spine i.is-done + i::before {
  background: var(--ink);
}

.mini-spine i.is-current {
  width: 9px;
  height: 9px;
  border: 2px solid var(--ink);
  background: var(--sheet);
}

.mini-spine i.is-current.is-working {
  background: radial-gradient(circle, var(--ink) 0 1.5px, var(--sheet) 2px);
}

.mini-spine i.is-current.is-needs {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 0 1.5px, var(--sheet) 2px);
}

.mini-spine i.is-current.is-blocked {
  border-color: #D9A441;
  background: var(--caution-tint);
}

.mini-spine i.is-current.is-stopped {
  border-color: var(--faint);
  background: var(--wash-2);
}

/* ---------- Motion ---------- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(.985); }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px); }
}

@keyframes work-pulse {
  0% { box-shadow: 0 0 0 0 rgba(23, 23, 23, .35); }
  70% { box-shadow: 0 0 0 6px rgba(23, 23, 23, 0); }
  100% { box-shadow: 0 0 0 0 rgba(23, 23, 23, 0); }
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============ Imports that spend credits: the message that asks first ============ */
.import-asks {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 89;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
}

.import-ask {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-lg);
  background: var(--sheet);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-13);
  line-height: 1.45;
  color: var(--ink-2);
}

.import-ask-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.import-ask-title {
  color: var(--ink);
  font-size: var(--fs-14);
  font-weight: 600;
  line-height: 1.35;
}

.import-ask-cost b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.import-ask-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.import-ask-actions .link {
  margin-left: auto;
}

.conn-imports {
  display: grid;
  gap: 14px;
}

.import-check {
  display: grid;
  gap: 6px;
  padding-left: 18px;
  list-style: disc;
  font-size: var(--fs-13);
  line-height: 1.45;
  color: var(--ink-2);
}

.import-wait .notice-body {
  display: grid;
  gap: 6px;
}

.import-more {
  display: grid;
  gap: 6px;
}

.import-more-row {
  display: flex;
  gap: 8px;
}

.import-more-row .input {
  flex: 1;
  min-width: 0;
}

@media (max-width: 720px) {
  .import-asks {
    right: 16px;
    bottom: 72px;
  }
}
