/* ============================================================
   env.computer — Component Library
   Built on tokens.css. Class prefix: ec-
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  color: var(--ink-800);
  /* Canvas with faint ambient brand/amber auras — theme-tuned via tokens */
  background:
    radial-gradient(1100px 700px at 85% -10%, var(--aura-brand), transparent 55%),
    radial-gradient(900px 600px at -10% 110%, var(--aura-accent), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }
/* Anchors styled as buttons must keep their button text color — the global
   link hover color would otherwise bleed through (teal text on teal fill). */
a.ec-btn:hover, a.ec-btn:active { color: var(--ink-900); }
a.ec-btn--primary, a.ec-btn--primary:hover, a.ec-btn--primary:active { color: var(--on-primary); }
a.ec-btn--accent, a.ec-btn--accent:hover, a.ec-btn--accent:active { color: #241701; }
hr { border: 0; border-top: var(--border-subtle); margin: var(--s-6) 0; }
::selection { background: var(--brand-200); color: var(--brand-900); }

/* Accessible focus ring for keyboard users (kept off mouse clicks) */
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

html { scroll-behavior: smooth; }

/* Refined, quiet scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); background-clip: padding-box; }

/* ---------- Typography ---------- */
.ec-display {
  font-size: var(--fs-56);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
  color: var(--ink-900);
}
.ec-h1 {
  font-size: var(--fs-32);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-snug);
  line-height: var(--lh-tight);
  color: var(--ink-900);
}
.ec-h2 {
  font-size: var(--fs-24);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-snug);
  line-height: var(--lh-snug);
  color: var(--ink-900);
}
.ec-h3 {
  font-size: var(--fs-18);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  color: var(--ink-900);
}
.ec-h4 {
  font-size: var(--fs-15);
  font-weight: var(--fw-semibold);
  color: var(--ink-900);
}
.ec-body { font-size: var(--fs-14); color: var(--ink-700); }
.ec-body-lg { font-size: var(--fs-16); color: var(--ink-700); line-height: var(--lh-relaxed); }
.ec-muted { color: var(--ink-500); }
.ec-mono { font-family: var(--font-mono); }
.ec-eyebrow {
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--ink-500);
}
.ec-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ---------- Layout primitives ---------- */
.ec-app {
  display: grid;
  grid-template-columns: var(--rail-w) var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  grid-template-rows: 100dvh;
  background: transparent; /* let the body aura glow through */
}
.ec-app--no-sidebar {
  grid-template-columns: var(--rail-w) 1fr;
}
.ec-stack { display: flex; flex-direction: column; }
.ec-row { display: flex; align-items: center; }
.ec-spread { display: flex; align-items: center; justify-content: space-between; }
.ec-gap-1 { gap: var(--s-1); }
.ec-gap-2 { gap: var(--s-2); }
.ec-gap-3 { gap: var(--s-3); }
.ec-gap-4 { gap: var(--s-4); }
.ec-gap-5 { gap: var(--s-5); }
.ec-gap-6 { gap: var(--s-6); }
.ec-gap-8 { gap: var(--s-8); }

/* ---------- Side rail (app switcher / brand) ---------- */
.ec-rail {
  background: linear-gradient(180deg, #0a0f0d 0%, #0c1310 100%);
  color: var(--ink-600);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--s-3) 0;
  gap: var(--s-2);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}
/* Rail is a fixed dark brand anchor in BOTH themes — hexes intentional. */
.ec-rail__logo {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #3fbfa0, #1f8a6b 60%, #12684f);
  display: grid;
  place-items: center;
  color: #06231b;
  font-weight: var(--fw-bold);
  font-size: var(--fs-14);
  letter-spacing: -0.02em;
  margin-bottom: var(--s-3);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1) inset;
}
/* Logo doubles as the Home link — keep its fixed-dark text through link states. */
a.ec-rail__logo, a.ec-rail__logo:hover, a.ec-rail__logo:active { color: #06231b; text-decoration: none; }

/* Screen-reader-only utility (labels for icon/placeholder-only controls) */
.ec-visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ec-rail__btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: transparent;
  border: 0;
  color: #7c8f86;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
}
.ec-rail__btn:hover { background: rgba(255,255,255,0.06); color: #ecf3ef; transform: translateY(-1px); }
.ec-rail__btn--active {
  background: rgba(74, 211, 178, 0.12);
  color: #63e3c6;
  box-shadow: inset 2px 0 0 #f0b429;
}
.ec-rail__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #0a0f0d, 0 0 0 4px #f0b429;
}
.ec-rail__btn--active:focus-visible {
  box-shadow: inset 2px 0 0 #f0b429, 0 0 0 2px #0a0f0d, 0 0 0 4px #f0b429;
}
.ec-rail__bottom { margin-top: auto; display: flex; flex-direction: column; gap: var(--s-2); align-items: center; }

/* ---------- Sidebar ---------- */
.ec-sidebar {
  background: var(--surface-2);
  border-right: var(--border-subtle);
  padding: var(--s-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
/* Keep fixed chrome (button, search, headers) at full height — let the list
   scroll instead of flex-compressing items when the sidebar overflows. */
.ec-sidebar > * { flex-shrink: 0; }
.ec-sidebar__header {
  padding: var(--s-2) var(--s-3);
}
.ec-sidebar__title {
  font-size: var(--fs-13);
  font-weight: var(--fw-semibold);
  color: var(--ink-900);
}
.ec-sidebar__sub {
  font-size: var(--fs-12);
  color: var(--ink-500);
  margin-top: 2px;
}
.ec-sidebar__section { display: flex; flex-direction: column; gap: 2px; }
.ec-sidebar__label {
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  padding: var(--s-2) var(--s-3) var(--s-1);
}
.ec-nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px var(--s-3);
  border-radius: var(--r-sm);
  color: var(--ink-700);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
  text-decoration: none;
}
.ec-nav-item:hover { background: var(--hover-tint-brand); color: var(--ink-900); }
.ec-nav-item--active {
  background: var(--brand-50);
  color: var(--brand-700);
}
.ec-nav-item__icon { color: var(--ink-500); display: inline-flex; }
.ec-nav-item--active .ec-nav-item__icon { color: var(--brand-600); }
.ec-nav-item__badge {
  margin-left: auto;
  font-size: var(--fs-11);
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}

/* ---------- Topbar ---------- */
.ec-topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  padding: 0 var(--s-5);
  gap: var(--s-4);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
.ec-topbar__crumbs {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-13);
  color: var(--ink-500);
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.ec-topbar__crumbs > .ec-ico { flex-shrink: 0; }
.ec-topbar__crumbs strong {
  color: var(--ink-900);
  font-weight: var(--fw-semibold);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ec-topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); flex-shrink: 0; flex-wrap: nowrap; }

/* ---------- Main area ---------- */
.ec-main {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.ec-main__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-6) var(--s-8);
}
.ec-main__body--flush { padding: 0; }

/* ---------- Buttons ---------- */
.ec-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  height: 36px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink-800);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.ec-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ec-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.ec-btn:not(:disabled):active { transform: translateY(0.5px); }

.ec-btn--primary {
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
  font-weight: var(--fw-semibold);
  box-shadow: var(--sh-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.ec-btn--primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--sh-sm);
  transform: translateY(-1px);
}
.ec-btn--primary:not(:disabled):active { background: var(--primary-active); transform: translateY(0) scale(0.98); }

.ec-btn--secondary {
  background: var(--surface);
  border-color: var(--ink-200);
}
.ec-btn--secondary:hover { background: var(--surface-3); border-color: var(--ink-300); transform: translateY(-1px); }

.ec-btn--ghost {
  background: transparent;
  color: var(--ink-700);
}
.ec-btn--ghost:hover { background: var(--hover-veil); color: var(--ink-900); }

.ec-btn--accent {
  background: var(--accent-500);
  color: #241701;
  font-weight: var(--fw-semibold);
  box-shadow: var(--sh-xs), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.ec-btn--accent:hover { background: var(--accent-400); box-shadow: var(--sh-sm); transform: translateY(-1px); }

.ec-btn--danger {
  color: var(--danger);
  border-color: var(--ink-200);
  background: var(--surface);
}
.ec-btn--sm { height: 28px; padding: 0 var(--s-3); font-size: var(--fs-12); border-radius: var(--r-sm); }
.ec-btn--lg { height: 44px; padding: 0 var(--s-5); font-size: var(--fs-14); }
.ec-btn--icon { width: 36px; padding: 0; }
.ec-btn--icon.ec-btn--sm { width: 28px; }
.ec-btn--block { width: 100%; }

/* ---------- Inputs ---------- */
.ec-input, .ec-textarea, .ec-select {
  width: 100%;
  height: 36px;
  padding: 0 var(--s-3);
  border-radius: var(--r-md);
  border: 1px solid var(--ink-200);
  background: var(--surface);
  font-size: var(--fs-13);
  color: var(--ink-900);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.ec-textarea { height: auto; padding: var(--s-3); resize: vertical; min-height: 96px; line-height: var(--lh-relaxed); }
.ec-input:focus, .ec-textarea:focus, .ec-select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--sh-glow);
}
.ec-input::placeholder, .ec-textarea::placeholder { color: var(--ink-400); }

.ec-search {
  position: relative;
}
.ec-search .ec-input { padding-left: 36px; }
.ec-search__icon {
  position: absolute;
  left: var(--s-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
}

/* ---------- Cards ---------- */
.ec-card {
  background: var(--surface);
  border: var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--sh-xs);
}
.ec-card--soft { background: var(--surface-2); border: 0; box-shadow: none; }
.ec-card--bordered { border: var(--border-default); }
.ec-card--ink {
  background: var(--surface-inv);
  color: var(--ink-100);
  border: 0;
}
.ec-card__title { font-size: var(--fs-15); font-weight: var(--fw-semibold); color: var(--ink-900); }
.ec-card__sub { font-size: var(--fs-13); color: var(--ink-500); margin-top: 2px; }
.ec-card__hr { border-top: var(--border-subtle); margin: var(--s-4) calc(var(--s-5) * -1); }

/* ---------- Badges / chips ---------- */
.ec-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 2px var(--s-2);
  border-radius: var(--r-full);
  font-size: var(--fs-11);
  font-weight: var(--fw-medium);
  background: var(--ink-100);
  color: var(--ink-700);
  line-height: 1.4;
  white-space: nowrap;
}
.ec-badge--brand { background: var(--brand-50); color: var(--brand-700); }
.ec-badge--accent { background: var(--accent-100); color: var(--accent-700); }
.ec-badge--success { background: var(--success-bg); color: var(--success); }
.ec-badge--warning { background: var(--warning-bg); color: var(--warning); }
.ec-badge--danger { background: var(--danger-bg); color: var(--danger); }
.ec-badge--info { background: var(--info-bg); color: var(--info); }
.ec-badge--solid {
  background: var(--primary); color: var(--on-primary);
}

.ec-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-400);
}
.ec-dot--success { background: var(--success); }
.ec-dot--warning { background: var(--warning); }
.ec-dot--danger { background: var(--danger); }
.ec-dot--brand { background: var(--brand-500); }
.ec-dot--accent { background: var(--accent-500); }
.ec-dot--pulse { animation: ec-pulse 1.8s infinite; }

@keyframes ec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--pulse-ring); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

/* ---------- Category accents ---------- */
.ec-cat--env  { color: var(--cat-env);  background: var(--cat-env-bg); }
.ec-cat--ehs  { color: var(--cat-ehs);  background: var(--cat-ehs-bg); }
.ec-cat--esg  { color: var(--cat-esg);  background: var(--cat-esg-bg); }
.ec-cat--reg  { color: var(--cat-reg);  background: var(--cat-reg-bg); }

/* ---------- Avatar ---------- */
.ec-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-200);
  color: var(--brand-800);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  flex-shrink: 0;
}
.ec-avatar--lg { width: 36px; height: 36px; font-size: var(--fs-12); }
.ec-avatar--ai {
  background: linear-gradient(135deg, #e5a83c, #c98f1b);
  color: #241701;
  box-shadow: var(--sh-xs);
}

/* ---------- Skill cards ---------- */
.ec-skill {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  background: var(--surface);
  border: var(--border-subtle);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  cursor: pointer;
}
.ec-skill:hover {
  border-color: var(--brand-300);
  box-shadow: var(--sh-md), var(--glow-card-hover);
  transform: translateY(-2px);
}
.ec-skill__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ec-skill__title { font-size: var(--fs-14); font-weight: var(--fw-semibold); color: var(--ink-900); }
.ec-skill__desc { font-size: var(--fs-12); color: var(--ink-500); line-height: var(--lh-relaxed); }

/* ---------- Tabs ---------- */
.ec-tabs {
  display: flex;
  border-bottom: var(--border-subtle);
  gap: var(--s-1);
}
.ec-tab {
  padding: var(--s-2) var(--s-3);
  font-size: var(--fs-13);
  color: var(--ink-500);
  font-weight: var(--fw-medium);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.ec-tab:hover { color: var(--ink-800); }
.ec-tab--active {
  color: var(--ink-900);
  border-bottom-color: var(--brand-600);
}

/* ---------- Tables ---------- */
.ec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-13);
}
.ec-table th, .ec-table td {
  padding: var(--s-3) var(--s-3);
  text-align: left;
  border-bottom: var(--border-subtle);
}
.ec-table th {
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  background: var(--surface-2);
}
.ec-table tr:hover td { background: var(--surface-3); }

/* ---------- KBD ---------- */
.ec-kbd {
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--surface);
  border: 1px solid var(--ink-200);
  color: var(--ink-600);
  box-shadow: 0 1px 0 var(--ink-200);
}

/* ---------- Chat / messages ---------- */
.ec-msg {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-4) 0;
}
.ec-msg__body { flex: 1; min-width: 0; }
.ec-msg__head {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  margin-bottom: var(--s-1);
}
.ec-msg__name { font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--ink-900); }
.ec-msg__time { font-size: var(--fs-11); color: var(--ink-500); }
.ec-msg__content { font-size: var(--fs-14); color: var(--ink-800); line-height: var(--lh-relaxed); }
.ec-msg__content p { margin: 0 0 var(--s-3); }
.ec-msg__content p:last-child { margin-bottom: 0; }

.ec-prose ul { margin: var(--s-2) 0 var(--s-3); padding-left: var(--s-5); }
.ec-prose li { margin-bottom: 4px; }
.ec-prose code { font-family: var(--font-mono); background: var(--surface-2); padding: 1px 6px; border-radius: var(--r-xs); font-size: 0.92em; }
.ec-prose .ec-tablewrap { overflow-x: auto; margin: var(--s-2) 0 var(--s-3); border: var(--border-subtle); border-radius: var(--r-md); }
/* Markdown headings from live replies (mdLite ## → h3, ### → h4) — document
   hierarchy instead of flat bold paragraphs */
.ec-prose h3.ec-md-h { font-size: var(--fs-15); font-weight: var(--fw-semibold); color: var(--ink-900); margin: var(--s-5) 0 var(--s-2); }
.ec-prose h4.ec-md-h { font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--ink-800); margin: var(--s-4) 0 var(--s-2); text-transform: none; }
/* Live-reply chart widget (rendered from ```enviclaw-chart blocks) */
.ec-chart { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 132px; padding: var(--s-2) 0; }
.ec-chart__bar { flex: 1; min-width: 2px; background: var(--brand-400); border-radius: 2px 2px 0 0; transition: opacity 0.15s ease; }
.ec-chart__bar--over { background: var(--danger); }
.ec-chart__bar:hover { opacity: 0.75; }
.ec-chart__limit { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--accent-500); pointer-events: none; }
.ec-chart__limitlabel { position: absolute; right: 0; transform: translateY(-115%); font-family: var(--font-mono); font-size: var(--fs-10); color: var(--accent-600); }
.ec-chart-x { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--fs-11); color: var(--ink-500); margin-top: 2px; }
.ec-chart-x b { color: var(--ink-800); font-weight: var(--fw-medium); }

/* Citation chips inside tables: compact, never ballooning the row */
.ec-prose td .ec-cite, .ec-prose th .ec-cite {
  display: inline-flex; align-items: center; white-space: nowrap;
  font-size: var(--fs-10); padding: 1px 6px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}

/* Interactive clarification form (rendered from ```enviclaw-ask blocks) */
.ec-ask { margin: var(--s-2) 0 var(--s-1); }
.ec-ask__label { font-size: var(--fs-11); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-500); margin: var(--s-3) 0 var(--s-2); }
.ec-ask__chips { display: flex; flex-wrap: wrap; gap: 6px; }
/* free-text / numeric ask fields (Jul 2026 — whole-part BRSR forms) */
.ec-ask__input {
  display: block; width: 100%; max-width: 460px;
  padding: 7px var(--s-3);
  font-size: var(--fs-13); font-family: var(--font-sans);
  color: var(--ink-900); background: var(--surface);
  border: 1px solid var(--ink-200); border-radius: var(--r-sm);
}
.ec-ask__input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ec-ask__input--area { resize: vertical; min-height: 56px; line-height: 1.45; }
.ec-ask__chip {
  border: 1px solid var(--ink-200); background: var(--surface); color: var(--ink-700);
  border-radius: 999px; padding: 5px 14px; font-size: var(--fs-13); cursor: pointer;
  transition: all 0.12s ease; font-family: inherit;
}
.ec-ask__chip:hover { border-color: var(--brand-400); color: var(--brand-700); }
.ec-ask__chip--on {
  background: var(--brand-600); border-color: var(--brand-600); color: var(--on-primary, #fff);
  font-weight: var(--fw-medium);
}
.ec-ask__rangewrap { display: flex; align-items: center; gap: var(--s-3); max-width: 420px; }
.ec-ask__range { flex: 1; accent-color: var(--brand-600); cursor: pointer; }
.ec-ask__rangeval { font-family: var(--font-mono); font-size: var(--fs-12); color: var(--ink-900); font-weight: var(--fw-medium); white-space: nowrap; min-width: 86px; text-align: right; }
.ec-ask__cal {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex-shrink: 0; border: 1px solid var(--ink-200);
  background: var(--surface); color: var(--ink-500); border-radius: var(--r-sm);
  cursor: pointer; transition: all 0.12s ease;
}
.ec-ask__cal:hover { border-color: var(--brand-400); color: var(--brand-700); }
.ec-ask__cal--on { background: var(--brand-50); border-color: var(--brand-300); color: var(--brand-700); }
.ec-ask__dates { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.ec-ask__datelabel { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-12); color: var(--ink-500); }
.ec-ask__date {
  border: 1px solid var(--ink-200); background: var(--surface); color: var(--ink-900);
  border-radius: var(--r-sm); padding: 5px 8px; font-family: var(--font-mono);
  font-size: var(--fs-12); color-scheme: inherit;
}
.ec-ask__date:focus-visible { outline: none; border-color: var(--brand-500); }
.ec-ask__actions { margin-top: var(--s-4); }
.ec-ask--done { opacity: 0.55; pointer-events: none; }
.ec-ask--done .ec-ask__actions { display: none; }

/* ---- phase-B ask wizard: intro + grouped screens (flat form = phase A) ---- */
.ec-ask__wizprog { height: 4px; background: var(--ink-100); border-radius: var(--r-full); overflow: hidden; margin: var(--s-2) 0 var(--s-3); }
.ec-ask__wizfill { display: block; height: 100%; background: var(--brand-500); border-radius: inherit; transition: width 0.25s ease; }
.ec-ask__screen { animation: ec-ask-screen 0.2s ease; }
@keyframes ec-ask-screen { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ec-ask__wizsec { font-size: var(--fs-11); font-family: var(--font-mono); color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.05em; margin-top: var(--s-2); }
.ec-ask__wiztitle { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-16); font-weight: var(--fw-semibold); color: var(--ink-900); margin: var(--s-2) 0 var(--s-1); }
.ec-ask__wiznum { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: var(--r-sm); background: var(--brand-600); color: var(--on-primary, #fff); font-size: var(--fs-12); font-weight: var(--fw-semibold); flex-shrink: 0; }
.ec-ask__wizblurb { font-size: var(--fs-13); color: var(--ink-600); line-height: var(--lh-relaxed); margin: var(--s-2) 0 var(--s-2); }
.ec-ask__wiznav { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-4); }
.ec-ask__wizspacer { flex: 1; }
.ec-ask__wizhint { font-size: var(--fs-11); color: var(--ink-400); }
.ec-ask--wiz .ec-ask__wiznav .ec-ask__actions { margin-top: 0; }
@media (prefers-reduced-motion: reduce) {
  .ec-ask__screen { animation: none; }
  .ec-ask__wizfill { transition: none; }
}

/* right-bar sub-outline for the active ask wizard (reports page) */
.rp-subask { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 var(--s-2) 26px; padding-left: var(--s-3); border-left: var(--border-subtle); }
.rp-subask__row { display: flex; align-items: center; gap: var(--s-2); padding: 4px 6px; border: 0; background: transparent; border-radius: var(--r-sm); cursor: pointer; font: inherit; color: inherit; text-align: left; }
.rp-subask__row:hover { background: var(--hover-veil); }
.rp-subask__row--cur .rp-subask__label { color: var(--accent-600); font-weight: var(--fw-medium); }
.rp-subask__dot { width: 9px; height: 9px; border-radius: var(--r-full); flex-shrink: 0; box-sizing: border-box; }
.rp-subask__dot--none { border: 1.5px dashed var(--ink-300); }
.rp-subask__dot--part { background: var(--accent-500); }
.rp-subask__dot--full { background: var(--brand-600); }
.rp-subask__dot--cur { background: transparent; border: 2px solid var(--accent-500); box-shadow: 0 0 6px 1px color-mix(in srgb, var(--accent-500) 55%, transparent); animation: rp-subask-glow 1.6s ease-in-out infinite; }
@keyframes rp-subask-glow {
  0%, 100% { box-shadow: 0 0 4px 0 color-mix(in srgb, var(--accent-500) 45%, transparent); }
  50% { box-shadow: 0 0 8px 2px color-mix(in srgb, var(--accent-500) 70%, transparent); }
}
.rp-subask__label { font-size: var(--fs-12); color: var(--ink-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.rp-subask__count { font-size: var(--fs-10); font-family: var(--font-mono); color: var(--ink-400); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .rp-subask__dot--cur { animation: none; } }

/* Delete affordance on live conversation items (hover to reveal, click twice) */
.wk-conv-item { position: relative; }
.wk-conv-del {
  position: absolute; top: 8px; right: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border: none; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-400); cursor: pointer;
  opacity: 0; transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.wk-conv-item:hover .wk-conv-del, .wk-conv-del:focus-visible { opacity: 1; }
.wk-conv-del:hover { background: var(--hover-veil); color: var(--ink-700); }
.wk-conv-del--arm { opacity: 1; color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.wk-conv-del--arm:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 20%, transparent); }
.ec-prose table { border-collapse: collapse; width: 100%; font-size: var(--fs-13); }
.ec-prose th { text-align: left; font-size: var(--fs-11); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-500); background: var(--surface-2); padding: 8px 12px; border-bottom: var(--border-subtle); white-space: nowrap; }
.ec-prose td { padding: 7px 12px; border-bottom: var(--border-subtle); color: var(--ink-800); }
.ec-prose tr:last-child td { border-bottom: none; }
.ec-prose td:first-child, .ec-prose th:first-child { padding-left: 14px; }

/* ---------- Composer (chat input) ---------- */
.ec-composer {
  border: 1px solid var(--ink-200);
  border-radius: var(--r-xl);
  background: var(--surface);
  padding: var(--s-3) var(--s-3) var(--s-2);
  box-shadow: var(--sh-sm);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.ec-composer:focus-within { border-color: var(--brand-400); box-shadow: var(--sh-glow); }
.ec-composer__field:focus-visible { box-shadow: none; border-radius: 0; }
.ec-composer__field {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
  min-height: 24px;
  max-height: 200px;
  font-size: var(--fs-14);
  color: var(--ink-900);
  line-height: var(--lh-relaxed);
}
.ec-composer__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--s-2);
}

/* Send button flips to a Stop control while a reply is generating */
.wk-send--stop,
.wk-send--stop:hover {
  background: var(--ink-900);
  border-color: var(--ink-900);
  color: var(--on-primary, #fff);
}

/* ---------- Citation chip ---------- */
.ec-cite {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 6px;
  border-radius: var(--r-full);
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  border: 1px solid var(--brand-100);
  cursor: default;
  transition: background var(--dur-fast);
}
.ec-cite:hover { background: var(--brand-100); }

/* Stop bar — shown at the top of a workspace thread when a report-builder run
   is still generating inside that conversation */
.wk-stopbar {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-4);
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--r-md);
  font-size: var(--fs-12);
  color: var(--ink-800);
}
.wk-stopbar__text { flex: 1; min-width: 0; }

/* Fineprint footnote — small muted disclaimer line skills append to
   calculation replies (e.g. GHG data-accuracy note via [[fineprint:…]]). */
.ec-fineprint {
  display: block;
  margin-top: var(--s-2);
  padding-top: var(--s-2);
  border-top: 1px solid var(--ink-100);
  font-size: var(--fs-11);
  line-height: 1.5;
  color: var(--ink-500);
}

.ec-cite__num {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--cite-num-bg);
  color: var(--brand-700);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--brand-200);
}

/* ---------- Data widget (embedded in chat) ---------- */
.ec-widget {
  border: 1px solid var(--ink-200);
  border-radius: var(--r-lg);
  background: var(--surface);
  margin: var(--s-3) 0;
  overflow: hidden;
}
.ec-widget__head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-bottom: var(--border-subtle);
  background: var(--surface-2);
}
.ec-widget__title { font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--ink-900); }
.ec-widget__sub { font-size: var(--fs-11); color: var(--ink-500); margin-left: auto; }
.ec-widget__body { padding: var(--s-4); }

/* ---------- Metric ---------- */
.ec-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ec-metric__label { font-size: var(--fs-11); color: var(--ink-500); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.ec-metric__value {
  font-size: var(--fs-24);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--ink-900);
  letter-spacing: var(--tracking-snug);
}
.ec-metric__delta { font-size: var(--fs-12); display: inline-flex; align-items: center; gap: 4px; }
.ec-metric__delta--up { color: var(--success); }
.ec-metric__delta--down { color: var(--danger); }

/* ---------- Bar chart (CSS only, luminous telemetry style) ---------- */
.ec-bars { display: flex; align-items: flex-end; gap: 4px; height: 64px; }
.ec-bars__bar {
  flex: 1;
  background: linear-gradient(to top, var(--brand-400), var(--brand-600));
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  transform-origin: bottom;
  animation: ec-bar-grow var(--dur-slower) var(--ease-out-expo) backwards;
  transition: filter var(--dur-fast) var(--ease-out);
}
.ec-bars__bar:hover { filter: brightness(1.25) saturate(1.1); }
.ec-bars__bar:nth-child(2)  { animation-delay: 40ms; }
.ec-bars__bar:nth-child(3)  { animation-delay: 80ms; }
.ec-bars__bar:nth-child(4)  { animation-delay: 120ms; }
.ec-bars__bar:nth-child(5)  { animation-delay: 160ms; }
.ec-bars__bar:nth-child(6)  { animation-delay: 200ms; }
.ec-bars__bar:nth-child(7)  { animation-delay: 240ms; }
.ec-bars__bar:nth-child(8)  { animation-delay: 280ms; }
.ec-bars__bar:nth-child(9)  { animation-delay: 320ms; }
.ec-bars__bar:nth-child(10) { animation-delay: 360ms; }
.ec-bars__bar:nth-child(n+11) { animation-delay: 400ms; }
.ec-bars__bar--alt { background: linear-gradient(to top, var(--accent-400), var(--accent-600)); }

/* ---------- Progress ---------- */
.ec-progress {
  height: 6px;
  background: var(--ink-100);
  border-radius: var(--r-full);
  overflow: hidden;
}
.ec-progress__fill {
  height: 100%;
  background: var(--brand-500);
  border-radius: var(--r-full);
  transition: width var(--dur-slow) var(--ease-out);
}
.ec-progress__fill--accent { background: var(--accent-500); }

/* ---------- Pill toggle ---------- */
.ec-pills {
  display: inline-flex;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--r-full);
  border: var(--border-subtle);
}
.ec-pill {
  padding: 4px var(--s-3);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  color: var(--ink-600);
  border-radius: var(--r-full);
  cursor: pointer;
  border: 0;
  background: transparent;
}
.ec-pill--active {
  background: var(--surface-3);
  color: var(--ink-900);
  box-shadow: var(--sh-sm), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* ---------- Empty state ---------- */
.ec-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--s-16) var(--s-6);
  color: var(--ink-500);
  max-width: 440px;
  margin: 0 auto;
}
.ec-empty .ec-ico { color: var(--ink-300); }

/* ---------- Tooltip (CSS only) ---------- */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink-900);
  color: var(--bg);
  font-size: var(--fs-11);
  font-weight: var(--fw-medium);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  z-index: var(--z-overlay);
  box-shadow: var(--sh-md);
  animation: ec-fade-in var(--dur-fast) var(--ease-out) backwards;
}
/* Topbar sits flush at the top inside `.ec-main` (overflow:hidden), so an
   upward tooltip gets clipped in half. Drop topbar tooltips below the button. */
.ec-topbar [data-tip]:hover::after {
  bottom: auto;
  top: calc(100% + 6px);
}

/* ---------- Utility ---------- */
.ec-divider { border-top: var(--border-subtle); margin: var(--s-4) 0; }
.ec-flex { display: flex; }
.ec-flex-1 { flex: 1; min-width: 0; }
.ec-grid { display: grid; }
.ec-pad-6 { padding: var(--s-6); }
.ec-pad-5 { padding: var(--s-5); }
.ec-mt-2 { margin-top: var(--s-2); }
.ec-mt-3 { margin-top: var(--s-3); }
.ec-mt-4 { margin-top: var(--s-4); }
.ec-mt-6 { margin-top: var(--s-6); }
.ec-mt-8 { margin-top: var(--s-8); }
.ec-mb-2 { margin-bottom: var(--s-2); }
.ec-mb-4 { margin-bottom: var(--s-4); }
.ec-mb-6 { margin-bottom: var(--s-6); }
.ec-text-center { text-align: center; }
.ec-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ec-scroll { overflow-y: auto; }
.ec-hidden { display: none !important; }

/* ---------- Icons (size helper) ---------- */
.ec-ico { width: 16px; height: 16px; display: inline-block; flex-shrink: 0; }
.ec-ico--14 { width: 14px; height: 14px; }
.ec-ico--18 { width: 18px; height: 18px; }
.ec-ico--20 { width: 20px; height: 20px; }
.ec-ico--24 { width: 24px; height: 24px; }
.ec-ico--32 { width: 32px; height: 32px; }

/* ============================================================
   Motion layer — 2026 micro-interactions
   Entrances use `backwards` fill so they also play when demo.js
   injects new nodes (messages, filtered cards re-appearing).
   ============================================================ */
@keyframes ec-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes ec-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes ec-scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes ec-bar-grow {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}
@keyframes ec-shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}

/* Entrances — cards, skills, widgets, chat messages (fast, purposeful) */
.ec-card, .ec-skill { animation: ec-rise 0.32s var(--ease-out-expo) backwards; }
.ec-widget          { animation: ec-scale-in 0.3s var(--ease-out-expo) backwards; }
.ec-msg             { animation: ec-rise 0.3s var(--ease-out-expo) backwards; }

/* Gentle stagger for siblings (caps at 8) */
.ec-card:nth-child(2), .ec-skill:nth-child(2) { animation-delay: 40ms; }
.ec-card:nth-child(3), .ec-skill:nth-child(3) { animation-delay: 80ms; }
.ec-card:nth-child(4), .ec-skill:nth-child(4) { animation-delay: 120ms; }
.ec-card:nth-child(5), .ec-skill:nth-child(5) { animation-delay: 160ms; }
.ec-card:nth-child(6), .ec-skill:nth-child(6) { animation-delay: 200ms; }
.ec-card:nth-child(7), .ec-skill:nth-child(7) { animation-delay: 240ms; }
.ec-card:nth-child(n+8), .ec-skill:nth-child(n+8) { animation-delay: 280ms; }

/* Card hover lift — quiet depth */
.ec-card {
  transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.ec-card:hover { border-color: var(--ink-200); box-shadow: var(--sh-md); }

/* AI shimmer — for "thinking" strips */
.ec-shimmer {
  background: linear-gradient(90deg, var(--ink-100) 25%, var(--ink-150) 50%, var(--ink-100) 75%);
  background-size: 200% 100%;
  animation: ec-shimmer 1.6s linear infinite;
}

/* ---------- Respect reduced-motion preferences ---------- */
/* ============================================================
   GEO MAP — shared SVG network map (sites.html + map.html)
   Rendered by stMapSVG() in demo.js; colors are all tokens.
   ============================================================ */
.st-map { position: relative; }
.st-map__svg { display: block; width: 100%; height: auto; }
.st-map__grid line { stroke: var(--ink-100); stroke-width: 1; opacity: 0.4; }
.st-map__land {
  fill: var(--brand-50); fill-opacity: 0.85;
  stroke: var(--brand-200); stroke-opacity: 0.6; stroke-width: 1; stroke-linejoin: round;
}
.st-map__sea { fill: var(--ink-300); opacity: 0.8; font-family: var(--font-mono); font-size: 9.5px; font-style: italic; letter-spacing: 0.08em; text-anchor: middle; }
.st-map__region { fill: var(--ink-300); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-anchor: middle; }
.st-map__name { fill: var(--ink-800); font-size: 11px; font-weight: 600; text-anchor: middle; }
.st-map__site { cursor: pointer; outline: none; }
.st-map__halo { opacity: 0.15; transition: opacity var(--dur-fast) var(--ease-out); }
.st-map__dot { stroke: var(--surface); stroke-width: 1.5; }
.st-map__site:hover .st-map__halo, .st-map__site:focus-visible .st-map__halo { opacity: 0.4; }
.st-map__site:focus-visible .st-map__dot { stroke: var(--brand-400); stroke-width: 2.5; }
.st-map__site--dim { opacity: 0.38; }
.st-map__ping { fill: none; stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: stPing 2.4s var(--ease-out) infinite; }
@keyframes stPing {
  0% { transform: scale(0.5); opacity: 0.9; }
  70% { transform: scale(2); opacity: 0; }
  100% { transform: scale(2); opacity: 0; }
}
.st-map--mini { pointer-events: none; border: var(--border-subtle); border-radius: var(--r-md); background: var(--surface-2); margin-bottom: var(--s-4); overflow: hidden; }
.st-map--sheet { border: var(--border-subtle); border-radius: var(--r-md); background: var(--surface-2); overflow: hidden; }
.st-map__tip {
  position: absolute; z-index: 6; pointer-events: none; min-width: 176px;
  background: var(--surface); border: var(--border-default); border-radius: var(--r-md);
  box-shadow: var(--sh-lg); padding: var(--s-2) var(--s-3);
}
.st-map__tip-name { font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--ink-900); }
.st-map__tip-sub { font-size: var(--fs-11); color: var(--ink-500); margin-bottom: 4px; }
.st-map__tip-row { font-size: var(--fs-12); color: var(--ink-600); }
.st-map__tip-row b { font-weight: var(--fw-semibold); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}


/* ============================================================
   Modern polish pass (Sohil, 30 Jul 2026) — subtle, token-based,
   works in BOTH themes. Landing-page DNA at app volume: a faint
   cursor spotlight on the main interactive cards, a soft brand
   glow on primary buttons, gentler input focus. Nothing moves
   that did not move before.
   ============================================================ */

/* primary buttons: soft brand-tinted glow on hover */
.ec-btn--primary:not(:disabled):hover {
  box-shadow: var(--sh-sm), 0 8px 24px -10px color-mix(in srgb, var(--brand-600) 55%, transparent);
}

/* cursor spotlight on key cards — demo.js feeds --mx/--my; the light is a
   background-image so it composes over each card's own background and can
   never clip shadows or tooltips */
.sk-card:hover, .hm-q:hover, .hm-rep:hover, .lib-card:hover, .rp-card:hover {
  background-image: radial-gradient(
    230px circle at var(--mx, 50%) var(--my, 50%),
    color-mix(in srgb, var(--brand-500) 7%, transparent),
    transparent 72%
  );
}

/* inputs: calmer, brand-tinted focus (mouse focus included, not just kbd) */
.ec-input:focus, .ec-textarea:focus, .ec-select:focus {
  border-color: var(--brand-300);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 14%, transparent);
}

/* smooth in-page scrolling where motion is welcome */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}


/* ============================================================
   Level-2 motion experiment (Sohil-approved trial, 30 Jul 2026).
   Gentle entrances only - short, once, never blocking a task.
   REVERT POINT: design-archive/checkpoint-2026-07-30-loved/
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  /* chat bubbles rise in - also reads as a soft transition on thread switch */
  .ec-msg { animation: ec-enter 0.22s var(--ease-out) backwards; }

  /* catalog grids: quick staggered entrance (skills + vault) */
  .sk-card, .lib-card { animation: ec-enter 0.26s var(--ease-out) backwards; }
  .sk-card:nth-child(2), .lib-card:nth-child(2) { animation-delay: 0.04s; }
  .sk-card:nth-child(3), .lib-card:nth-child(3) { animation-delay: 0.08s; }
  .sk-card:nth-child(4), .lib-card:nth-child(4) { animation-delay: 0.12s; }
  .sk-card:nth-child(5), .lib-card:nth-child(5) { animation-delay: 0.16s; }
  .sk-card:nth-child(n+6), .lib-card:nth-child(n+6) { animation-delay: 0.2s; }

  /* report canvas: 200ms fade-rise on section switch (class re-armed in demo.js) */
  .rp-doc-in { animation: ec-enter 0.2s var(--ease-out); }
}
@keyframes ec-enter {
  from { opacity: 0; transform: translateY(6px); }
}


/* ---- level-2 motion: scroll reveals (paired with scrollReveals in demo.js).
   .ec-srv cancels the element's load animation so the systems never
   double-fire; the reveal is transition-based, transform/opacity only. ---- */
.ec-srv {
  animation: none !important;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 0.8, 0.32, 1);
  will-change: transform, opacity;
}
.ec-srv.ec-srv-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .ec-srv { opacity: 1; transform: none; transition: none; }
}


/* ---- shared MapLibre bits: status pins + token-styled popups/controls
   (map.html full view + sites.html sheet locator, 30 Jul 2026) ---- */
.mp-pin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid var(--surface);
  padding: 0; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s var(--ease-out);
}
.mp-pin:hover { transform: scale(1.35); }
.mp-pin:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.mp-pin--good { background: var(--success); }
.mp-pin--warn { background: var(--warning); }
.mp-pin--bad  { background: var(--danger); animation: mpPinPulse 1.8s ease-in-out infinite; }
.mp-pin--here {
  transform: scale(1.45);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 45%, transparent), 0 2px 10px rgba(0, 0, 0, 0.4);
  z-index: 2;
}
.mp-pin--here:hover { transform: scale(1.55); }
@keyframes mpPinPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(0,0,0,0.15), 0 0 0 0 color-mix(in srgb, var(--danger) 55%, transparent); }
  50% { box-shadow: 0 0 0 1px rgba(0,0,0,0.15), 0 0 0 9px color-mix(in srgb, var(--danger) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .mp-pin--bad { animation: none; } }
.st-gl { height: 210px; border-radius: var(--r-md); overflow: hidden; }
.st-gl-main { height: clamp(380px, 48vh, 520px); border-radius: var(--r-md); overflow: hidden; }
/* hidden until the map MOUNTS (is-live) — an :empty hide made the map
   construct at zero size and compute a zoom-0 world view (3 Aug) */
.st-gl-main:not(.is-live) { display: none; }
/* attribution: quiet collapsed (i); expands on click only (license requires it) */
.maplibregl-ctrl-attrib.maplibregl-compact { background: color-mix(in srgb, var(--surface) 82%, transparent); }
.maplibregl-ctrl-attrib.maplibregl-compact-show { font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--ink-600); }
/* parent-scoped selectors so these WIN regardless of whether maplibre-gl.css
   loads before or after app.css (it loads after on sites.html — its default
   white popup made light text unreadable, observed 3 Aug) */
.maplibregl-popup .maplibregl-popup-content {
  background: var(--surface); color: var(--ink-900);
  border: var(--border-subtle); border-radius: var(--r-md);
  box-shadow: var(--sh-lg); padding: 10px 12px;
  font-family: var(--font-sans); font-size: var(--fs-12); line-height: 1.5;
}
.maplibregl-popup .maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.maplibregl-ctrl .maplibregl-ctrl-group, .maplibregl-ctrl-group { background: var(--surface); border: var(--border-subtle); box-shadow: var(--sh-sm); }
.maplibregl-ctrl-group button + button { border-top: var(--border-subtle); }

/* ============================================================
   Mini sidebar - collapse the left panel to a 64px icon rail
   (reference: CSS-Script smooth collapsible nav; Sohil, 5 Aug).
   Pages define their own collapsed grid via .ec-app--minileft;
   these rules transform the sidebar contents per surface.
   ============================================================ */
/* grid-template-columns transitions FREEZE in Chrome with var() track lists,
   and `width` on the stretched grid item is ignored while MAX-width is
   honored (both hit live 5 Aug) — so the collapse animates MAX-WIDTH over an
   `auto` column; pages set the expanded width+max-width, mini clamps to 64px */
.ec-sidebar { transition: max-width 0.25s ease; overflow-x: hidden; }
.ec-app--minileft .ec-sidebar { max-width: 64px !important; }
@media (prefers-reduced-motion: reduce) { .ec-sidebar { transition: none; } }
.ec-sidebar__header { display: flex; align-items: flex-start; gap: var(--s-2); }
.ec-sidebar__header > div:first-child { flex: 1; min-width: 0; }
.ec-sidebar__collapse { flex-shrink: 0; }
.ec-app--minileft .ec-sidebar { overflow: hidden; padding-left: var(--s-2); padding-right: var(--s-2); }
.ec-app--minileft .ec-sidebar__header { justify-content: center; padding: var(--s-2) 0; }
.ec-app--minileft .ec-sidebar__header > div:first-child { display: none; }
/* the collapsed rail is BLANK (Sohil, 6 Aug) — no letter/badge chips, just
   the expand chevron in the header; the list returns when the panel expands */
.ec-app--minileft .ec-sidebar > *:not(.ec-sidebar__header) { display: none; }

/* ============================================================
   Confirm modal (Keshav, 19 Aug) — destructive actions get a real
   centered dialog instead of a tooltip arm. One shared component,
   opened by ecConfirm() in demo.js. Cancel is always the focused
   default; Esc and the scrim both cancel.
   ============================================================ */
.ec-modal-scrim {
  position: fixed; inset: 0; z-index: 200;
  background: var(--scrim);
  display: grid; place-items: center;
  padding: var(--s-5);
  animation: ec-scrim-in 0.15s ease-out;
}
.ec-modal {
  background: var(--surface);
  border: var(--border-subtle);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  width: min(400px, 100%);
  padding: var(--s-8) var(--s-6) var(--s-6);
  text-align: center;
  animation: ec-modal-in 0.18s ease-out;
}
.ec-modal__icon {
  width: 64px; height: 64px; border-radius: var(--r-full);
  display: grid; place-items: center;
  margin: 0 auto var(--s-4);
}
.ec-modal__icon--danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.ec-modal__icon--brand { background: var(--brand-50); color: var(--brand-600); }
.ec-modal__title { font-size: var(--fs-15); font-weight: var(--fw-semibold); color: var(--ink-900); margin: 0 0 var(--s-2); }
.ec-modal__body { font-size: var(--fs-13); color: var(--ink-500); line-height: var(--lh-relaxed); margin: 0 0 var(--s-5); }
.ec-modal__body b { color: var(--ink-700); }
.ec-modal__actions { display: flex; gap: var(--s-3); }
.ec-modal__actions .ec-btn { flex: 1; justify-content: center; }
@keyframes ec-scrim-in { from { opacity: 0; } }
@keyframes ec-modal-in { from { opacity: 0; transform: scale(0.95) translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  .ec-modal-scrim, .ec-modal { animation: none; }
}

/* ---- Organisation setup bar (guided-journey phase 1, 20 Aug 2026) ----
   Injected by profile.js on any page holding [data-profile-banner], and only
   when the data service CONFIRMS the organisation profile is missing or
   partial. Its own class on purpose: demo.js fills the first `.hm-att` on the
   page with the live attention list, so this must not borrow that name. */
.ec-setupbar {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--surface-1);
  border: var(--border-subtle);
  border-left: 3px solid var(--accent-500);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  margin-bottom: var(--s-4);
  text-decoration: none; color: inherit;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.ec-setupbar:hover { border-color: var(--accent-400); box-shadow: var(--sh-md); color: inherit; }
.ec-setupbar__icon {
  width: 36px; height: 36px; border-radius: var(--r-md);
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--accent-100); color: var(--accent-700);
}
.ec-setupbar__body { flex: 1 1 auto; min-width: 0; display: block; }
.ec-setupbar__title { display: block; font-size: var(--fs-14); font-weight: var(--fw-semibold); color: var(--ink-900); }
.ec-setupbar__meta { display: block; font-size: var(--fs-12); color: var(--ink-500); margin-top: 2px; line-height: var(--lh-snug); }
.ec-setupbar__cta {
  flex-shrink: 0; font-size: var(--fs-13); font-weight: var(--fw-medium);
  color: var(--brand-700); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
@media (max-width: 720px) { .ec-setupbar__cta { display: none; } }

/* ---- Ask-form: help text, date and file fields (phase 4, 20 Aug 2026) ----
   `file` puts evidence INSIDE the form, so a document attaches to the answer it
   substantiates rather than to the conversation as a whole. The upload reuses
   the proven /api/uploads endpoint; this control only records which answer the
   document belongs to. */
.ec-ask__help { font-size: var(--fs-12); color: var(--ink-500); line-height: var(--lh-relaxed); margin: var(--s-1) 0 var(--s-2); }
.ec-ask__file { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; margin-top: 2px; }

/* Reuse offer (guided journey phase 8): "you answered this already, in your
   other report". Deliberately reads as an OFFER, not a warning or an error -
   it uses the accent (AI-moment) colour rather than amber, sits under the
   field it belongs to, and never fills anything until the button is pressed.
   It stays visible after use, restated as provenance, because a reused figure
   should not lose the fact that it came from somewhere else. */
.ec-reuse {
  display: flex; align-items: flex-start; gap: var(--s-2);
  margin: var(--s-2) 0 var(--s-3);
  padding: var(--s-2) var(--s-3);
  border: 1px dashed var(--accent-400);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent-500) 7%, transparent);
  animation: ec-rise 0.22s var(--ease-out);
}
.ec-reuse > .ec-ico { color: var(--accent-600); flex-shrink: 0; margin-top: 2px; }
.ec-reuse__text { flex: 1; min-width: 0; font-size: var(--fs-12); color: var(--ink-800); line-height: var(--lh-relaxed); }
.ec-reuse__text b { color: var(--ink-900); }
.ec-reuse__src { display: block; font-size: var(--fs-11); color: var(--ink-500); margin-top: 2px; }
.ec-reuse [data-ec-reuse-use] { flex-shrink: 0; }
.ec-reuse--used {
  border-style: solid;
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 8%, transparent);
}
.ec-reuse--used > .ec-ico { color: var(--success); }
@media (prefers-reduced-motion: reduce) { .ec-reuse { animation: none; } }
.ec-ask__filename { font-size: var(--fs-12); color: var(--ink-600); font-family: var(--font-mono); word-break: break-all; }
.ec-ask__filename--bad { color: var(--danger-600, #b42318); font-family: var(--font-sans); }
