/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: var(--sh-1);
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  user-select: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-4); }
.btn:active { transform: translateY(0.5px); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(61, 95, 214, 0.2), inset 0 1px 0 rgba(255,255,255,0.1); }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.ai { background: var(--ai); border-color: var(--ai); color: #fff; }
.btn.ai:hover { background: var(--ai-ink); border-color: var(--ai-ink); }
.btn.ai-soft { background: var(--ai-soft); border-color: transparent; color: var(--ai); box-shadow: none; }
.btn.ai-soft:hover { background: var(--ai-soft-2); }
.btn.subtle { background: transparent; border-color: transparent; color: var(--ink-2); box-shadow: none; }
.btn.subtle:hover { background: var(--paper-2); color: var(--ink); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); box-shadow: none; }
.btn.soft:hover { background: var(--accent-soft-2); }
.btn.danger { color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { filter: brightness(1.06); }
.btn.sm { height: 28px; padding: 0 9px; font-size: var(--fs-12); border-radius: 7px; gap: 4px; }
.btn.lg { height: 40px; padding: 0 18px; font-size: var(--fs-14); border-radius: var(--r-md); }
.btn.icon-only { width: 32px; padding: 0; }
.btn.sm.icon-only { width: 28px; }
.btn.block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-group .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.btn-group .btn.primary:not(:first-child) { border-left-color: rgba(255,255,255,0.25); }

.link { color: var(--accent); cursor: pointer; font-weight: 500; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- chips & badges ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--r-full);
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
button.chip:hover, .chip.clickable:hover { background: var(--paper-3); cursor: pointer; }
.chip.outline { background: transparent; border-color: var(--line-2); }
.chip.on { background: var(--accent-soft-2); color: var(--accent-ink); }
.chip.ai { background: var(--ai-soft); color: var(--ai); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.stale { background: var(--stale-soft); color: var(--stale); }
.chip.sq { border-radius: 6px; height: 21px; padding: 0 7px; font-size: 11.5px; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  font-size: var(--fs-11);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--paper-3);
  color: var(--ink-2);
}
.badge.accent { background: var(--accent-soft-2); color: var(--accent-ink); }
.badge.bad { background: var(--bad); color: #fff; }
.badge.warn { background: var(--paper-3); color: var(--ink-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--ink-4); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.accent { background: var(--accent); }
.dot.stale { background: var(--stale); }
.dot.ring { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-4); }


.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 4px;
  font-size: var(--fs-11);
  font-family: var(--font-ui);
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
}

/* lifecycle pill */
.life {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
.life::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-4); }
.life.drafting::before { background: var(--accent-2); }
.life.in_review::before { background: var(--warn); }
.life.changes_requested::before { background: var(--bad); }
.life.approved::before { background: var(--ok); }
.life.delivered::before { background: var(--ink); }
.life.archived::before { background: var(--ink-4); }

/* classification chip */
.cls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  border: 0;
  white-space: nowrap;
}
.cls.public { color: var(--ok); background: var(--ok-soft); }
.cls.internal { color: var(--ink-2); background: var(--paper-2); }
.cls.confidential { color: var(--warn); background: var(--warn-soft); }
.cls.restricted { color: var(--bad); background: var(--bad-soft); }

/* ---------- avatar ---------- */
.avatar {
  --c: var(--accent);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  background: var(--c);
  letter-spacing: -0.02em;
  position: relative;
}
.avatar.xs { width: 18px; height: 18px; font-size: 9px; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.lg { width: 36px; height: 36px; font-size: 13px; }
.avatar.agent { border-radius: 6px; background: var(--ink); }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; background: var(--paper-2); }
.avatar.live::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid var(--surface);
}
.avatars { display: inline-flex; }
.avatars .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatars .avatar + .avatar { margin-left: -6px; }
.avatars .more { background: var(--paper-3); color: var(--ink-2); }

/* ---------- readiness strip ---------- */
.strip { display: inline-flex; gap: 2px; align-items: center; padding: 3px; border-radius: var(--r-full); background: var(--paper-2); }
.strip i {
  width: 12px;
  height: 6px;
  border-radius: 3px;
  background: var(--paper-3);
  display: block;
}
.strip i.ok { background: var(--ok); }
.strip i.warn { background: #d9a85a; }
.strip i.block { background: var(--bad); }
.strip i.none { background: var(--paper-3); }
.strip.sm i { width: 9px; height: 5px; }
.strip.lg i { width: 16px; height: 7px; }

.rlist { display: flex; flex-direction: column; }
.rline {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  font-size: var(--fs-13);
  color: var(--ink-2);
}
.rline.clickable { cursor: pointer; }
.rline.clickable:hover { background: var(--paper-2); }
.rline .ico { display: inline-flex; }
.rline.ok .ico { color: var(--ok); }
.rline.warn .ico { color: var(--warn); }
.rline.block .ico { color: var(--bad); }
.rline.none .ico { color: var(--ink-4); }
.rline .val { font-size: var(--fs-12); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rline.block .val { color: var(--bad); font-weight: 600; }
.rline .lock { color: var(--ink-4); margin-left: 4px; }
.rline .lock.on { color: var(--bad); }

/* ---------- state label (honest states) ---------- */
.state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-12);
  font-weight: 500;
  white-space: nowrap;
}
.state::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: currentColor; }
.state.supported { color: var(--ok); }
.state.partial { color: var(--warn); }
.state.contradicted { color: var(--bad); }
.state.none, .state.uncited { color: var(--mute); }
.state.stale { color: var(--stale); }
.state.unavailable { color: var(--ink-3); }
.state.needs_recheck { color: var(--accent); }
.state.judgment { color: var(--ink-2); }
.state.available { color: var(--ok); }
.state.changed { color: var(--stale); }
.state.restricted { color: var(--warn); }
.state.removed { color: var(--bad); }

/* severity */
.sev { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-11); font-weight: 600; }
.sev::before { content: ""; width: 8px; height: 8px; border-radius: 2px; }
.sev.blocking { color: var(--bad); }
.sev.blocking::before { background: var(--bad); }
.sev.should_fix { color: var(--warn); }
.sev.should_fix::before { background: #d9a85a; }
.sev.consider { color: var(--ink-3); }
.sev.consider::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-4); }

/* ---------- tabs & segmented ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; }
.tab {
  position: relative;
  height: 40px;
  padding: 0 10px;
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--t-fast) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); }
.tab.on::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.tab .badge { background: var(--paper-3); color: var(--ink-2); }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--paper-2);
  border-radius: var(--r-md);
  border: 0;
}
.seg button {
  height: 26px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--t-fast) var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.seg button[disabled] { opacity: 0.4; pointer-events: none; }
.seg.sm button { height: 22px; padding: 0 8px; font-size: var(--fs-12); }

/* ---------- form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .flabel { font-size: var(--fs-12); font-weight: 600; color: var(--ink-3); }
.input, .textarea, .select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  font-size: var(--fs-13);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; line-height: 1.6; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft-2); }
.input.ghost, .textarea.ghost { border-color: transparent; background: transparent; padding-left: 0; }
.input.ghost:hover, .textarea.ghost:hover { background: var(--surface-2); }
.input.ghost:focus, .textarea.ghost:focus { background: var(--surface); padding-left: 8px; }
.select { appearance: none; padding-right: 28px; background-image: 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='%237a8091' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs-13); }
.check input { appearance: none; width: 16px; height: 16px; margin: 0; border-radius: 4px; border: 1.5px solid var(--ink-4); background: var(--surface); display: grid; place-content: center; flex: none; transition: all var(--t-fast) var(--ease); cursor: pointer; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { content: ""; width: 8px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]:checked::after { width: 6px; height: 6px; border: 0; border-radius: 50%; background: #fff; transform: none; }

.switch { position: relative; width: 30px; height: 18px; border-radius: 10px; background: var(--line-2); transition: background var(--t-fast) var(--ease); flex: none; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform var(--t-fast) var(--ease); }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(12px); }

/* ---------- table ---------- */
.table { width: 100%; font-size: var(--fs-13); }
.table th { text-align: left; font-size: var(--fs-12); font-weight: 600; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; z-index: 1; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }

/* ---------- popover / menu ---------- */
.pop {
  position: fixed;
  z-index: var(--z-pop);
  min-width: 180px;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  animation: fade-up var(--t-fast) var(--ease) both;
  overflow: hidden;
}
.menu { padding: 4px; display: flex; flex-direction: column; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-13);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  width: 100%;
}
.menu-item:hover, .menu-item.active { background: var(--paper-2); }
.menu-item .icon { color: var(--ink-3); }
.menu-item .hint { margin-left: auto; font-size: var(--fs-12); color: var(--ink-4); }
.menu-item.on { color: var(--accent); }
.menu-item.on .icon { color: var(--accent); }
.menu-item[disabled] { opacity: 0.45; pointer-events: none; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.menu-head { padding: 8px 10px 4px; font-size: var(--fs-11); font-weight: 600; color: var(--ink-4); letter-spacing: 0.04em; }

/* ---------- tooltip ---------- */
.tip {
  position: fixed;
  z-index: var(--z-tip);
  max-width: 280px;
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--ink);
  color: #f1f2f4;
  font-size: var(--fs-12);
  line-height: 1.45;
  pointer-events: none;
  animation: fade-in var(--t-fast) var(--ease) both;
  box-shadow: var(--sh-2);
}

/* ---------- modal / drawer ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(16, 24, 40, 0.28);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 24px 24px;
  animation: fade-in var(--t-med) var(--ease) both;
}
.modal {
  width: 560px;
  max-width: 100%;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  animation: fade-up var(--t-med) var(--ease) both;
  overflow: hidden;
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: var(--fs-16); font-weight: 600; flex: 1; }
.modal-body { padding: 20px; overflow: auto; min-height: 0; flex: 1; }
.modal-foot { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }

.drawer-scrim { position: fixed; inset: 0; z-index: var(--z-drawer); background: rgba(27, 35, 49, 0.18); animation: fade-in var(--t-med) var(--ease) both; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  z-index: var(--z-drawer);
  background: var(--surface);
  box-shadow: var(--sh-3);
  display: flex;
  flex-direction: column;
  animation: slide-in var(--t-med) var(--ease) both;
}
@keyframes slide-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------- toast ---------- */
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: #f1f2f4;
  font-size: var(--fs-13);
  box-shadow: var(--sh-3);
  animation: fade-up var(--t-med) var(--ease) both;
}
.toast .icon { color: #9fd3b8; }
.toast button { color: #b4c4f2; font-weight: 500; }
.toast.out { opacity: 0; transform: translateY(6px); transition: all var(--t-med) var(--ease); }

/* ---------- empty state ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--ink-3);
  font-size: var(--fs-13);
  text-align: center;
}
.empty .icon { width: 28px; height: 28px; color: var(--ink-4); stroke-width: 1.4; }

/* ---------- banner (honest notices) ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-13);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.banner.warn { background: var(--warn-soft); color: #6f4507; }
.banner.bad { background: var(--bad-soft); color: #7a2618; }
.banner.stale { background: var(--stale-soft); color: #45306f; }
.banner.ok { background: var(--ok-soft); color: #1d5237; }
.banner .grow { min-width: 0; }

/* origin icon tile */
.otile {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--paper-2);
  color: var(--ink-2);
}
.otile.wiki { background: var(--accent-soft); color: var(--accent); }
.otile.card { background: var(--ok-soft); color: var(--ok); }
.otile.coll { background: var(--warn-soft); color: var(--warn); }
.otile.file { background: var(--paper-2); color: var(--ink-2); }
.otile.web { background: var(--stale-soft); color: var(--stale); }
.otile.page { background: var(--accent); color: #fff; }
.otile.sm { width: 22px; height: 22px; border-radius: 6px; }
.otile.sm .icon { width: 13px; height: 13px; }

/* progress bar */
.bar { height: 4px; border-radius: 4px; background: var(--paper-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width var(--t-med) var(--ease); }
.bar.ok > i { background: var(--ok); }
