/* ============================================================
   ai.css — the agentic surface, plus the newer form primitives.

   Everything here obeys the same performance contract as the rest:
     · no new backdrop-filter layers — the dock and the spotlight are
       solid or plain-alpha, never blurred
     · no persistent infinite animations — the only looping keyframe
       is .pulsering, and it exists solely while an agent is actually
       working
     · only transform / opacity animate
   ============================================================ */

/* ============================================================
   1. AI DOCK — present on every lender screen
   ============================================================ */
.aidock{ position:fixed; right:20px; bottom:20px; z-index:110; display:flex; flex-direction:column; align-items:flex-end; gap:12px; }

.aifab{
  display:flex; align-items:center; gap:10px;
  height:46px; padding:0 18px 0 14px; cursor:pointer;
  border-radius:var(--r-pill); border:1px solid var(--accent-line);
  background:var(--panel-solid); color:var(--ink);
  font:inherit; font-size:13px; font-weight:650;
  box-shadow:var(--shadow-pop);
  transition:transform var(--fast) var(--ease), border-color var(--fast);
}
.aifab:hover{ transform:translateY(-2px); border-color:var(--accent); }
.aifab .fmk{
  width:24px; height:24px; flex:none; border-radius:50%; display:grid; place-items:center;
  background:linear-gradient(150deg, var(--accent), var(--brass)); color:var(--accent-ink); font-size:12px;
}
.aifab .fcnt{
  margin-left:2px; font-size:10.5px; font-weight:700; color:var(--accent-ink);
  background:var(--accent); border-radius:var(--r-pill); padding:2px 7px;
}

.aipanel{
  width:min(420px, calc(100vw - 40px)); max-height:min(640px, calc(100vh - 120px));
  display:flex; flex-direction:column; overflow:hidden;
  background:var(--panel-solid); border:1px solid var(--line);
  box-shadow:var(--shadow-pop);
}
.aipanel .aphead{
  display:flex; align-items:center; gap:11px; padding:15px 17px;
  border-bottom:1px solid var(--line-2); flex:none;
}
.aipanel .apmark{
  width:30px; height:30px; flex:none; border-radius:9px; display:grid; place-items:center;
  background:linear-gradient(150deg, var(--accent), var(--brass)); color:var(--accent-ink); font-size:14px;
}
.aipanel .aptitle{ font-weight:700; font-size:13.5px; }
.aipanel .apsub{ font-size:11px; color:var(--ink-3); margin-top:2px; }
.aipanel .apbody{ overflow:auto; padding:16px 17px; display:flex; flex-direction:column; gap:13px; flex:1 1 auto; }
.aipanel .apfoot{ flex:none; padding:13px 17px; border-top:1px solid var(--line-2); }

.aimsg{ font-size:12.5px; line-height:1.65; }
.aimsg.you{
  align-self:flex-end; max-width:86%;
  background:var(--accent-soft); border:1px solid var(--accent-line);
  border-radius:var(--r-md); padding:9px 12px;
}
.aimsg.bot{ color:var(--ink-2); }
.aimsg.bot b{ color:var(--ink); }

.aisuggests{ display:flex; flex-direction:column; gap:7px; }
.aisuggest{
  text-align:left; font:inherit; font-size:12px; cursor:pointer; color:var(--ink-2);
  padding:9px 12px; border-radius:var(--r-sm);
  background:var(--panel-3); border:1px solid var(--line-2);
  transition:background var(--fast), border-color var(--fast), color var(--fast);
}
.aisuggest:hover{ background:var(--panel-2); border-color:var(--accent-line); color:var(--ink); }

.askrow{ display:flex; gap:8px; }
.askrow .inp{ flex:1; height:36px; font-size:12.5px; }

/* ============================================================
   2. AI STRIP — the one-line read under a section heading
   ============================================================ */
.aistrip{
  display:flex; gap:11px; align-items:flex-start;
  padding:12px 15px; margin:0 0 15px;
  border-radius:var(--r-md);
  background:var(--accent-soft); border:1px solid var(--accent-line);
}
.aistrip .asmk{ flex:none; color:var(--accent); font-size:13px; line-height:1.5; }
.aistrip .astext{ font-size:12.5px; line-height:1.6; color:var(--ink-2); min-width:0; }
.aistrip .astext b{ color:var(--ink); font-weight:650; }
.aistrip .asmeta{ flex:none; display:flex; gap:6px; align-items:center; }

/* ---------- agent trace: how the answer was reached ---------- */
.agenttrace{ margin-top:10px; border-top:1px solid var(--line-2); padding-top:10px; }
.agenttrace summary{
  cursor:pointer; list-style:none; font-size:11px; color:var(--ink-3);
  letter-spacing:.09em; text-transform:uppercase;
}
.agenttrace summary::-webkit-details-marker{ display:none; }
.agenttrace summary::before{ content:'▸ '; }
.agenttrace[open] summary::before{ content:'▾ '; }
.agenttrace summary:hover{ color:var(--ink-2); }
.atsteps{ margin-top:9px; display:flex; flex-direction:column; gap:6px; }
.atstep{
  display:grid; grid-template-columns:auto 1fr auto; gap:10px; align-items:baseline;
  font-family:var(--font-mono); font-size:11px; color:var(--ink-3);
}
.atstep .atool{ color:var(--accent); }
.atstep .atms{ font-variant-numeric:tabular-nums; }

/* ---------- a working indicator that stops when work stops ---------- */
.pulsering{
  position:relative; width:9px; height:9px; border-radius:50%;
  background:var(--accent); flex:none;
}
.pulsering::after{
  content:''; position:absolute; inset:-5px; border-radius:50%;
  border:1.5px solid var(--accent-line);
  animation:pulsering 1400ms var(--ease) infinite;
}
@keyframes pulsering{
  0%   { transform:scale(.6); opacity:1; }
  100% { transform:scale(1.25); opacity:0; }
}

/* ============================================================
   3. VOICE AGENT
   ============================================================ */
.voice{
  --panel-bg: var(--panel-2);
  padding:20px 22px; margin-top:8px;
  background:var(--panel-bg); border:1px solid var(--accent-line);
}
.vhead{ display:flex; align-items:center; gap:12px; }
.vmark{
  width:34px; height:34px; flex:none; border-radius:10px; display:grid; place-items:center;
  background:linear-gradient(150deg, var(--accent), var(--brass)); color:var(--accent-ink); font-size:15px;
}
.vtitle{ font-weight:700; font-size:14px; }
.vsub{ font-size:11.5px; color:var(--ink-3); margin-top:2px; }
.vbody{ margin-top:18px; }
.vprompt{ font-size:13.5px; line-height:1.65; margin:0; max-width:56ch; }
.vprompt .dim{ display:block; color:var(--ink-3); font-size:12.5px; margin-top:5px; }
.vlangs{ display:flex; gap:7px; flex-wrap:wrap; margin-top:16px; }
.vactions{ display:flex; gap:11px; align-items:center; flex-wrap:wrap; margin-top:18px; }
.vnote{ font-size:11.5px; color:var(--ink-3); margin-top:14px; line-height:1.55; }

.micbtn{
  display:flex; align-items:center; gap:11px; cursor:pointer; font:inherit;
  height:46px; padding:0 20px; border-radius:var(--r-pill);
  background:var(--accent); color:var(--accent-ink); border:1px solid var(--accent);
  font-size:13.5px; font-weight:650;
  transition:transform var(--fast) var(--ease), filter var(--fast);
}
.micbtn:hover{ transform:translateY(-1px); filter:brightness(1.07); }
.micico{ font-size:15px; }

/* ---------- waveform: scaleY written by one RAF loop ---------- */
.wave{
  display:flex; align-items:center; justify-content:center; gap:5px;
  height:84px; padding:0 4px;
}
.wave i{
  display:block; width:5px; height:64px; border-radius:99px;
  background:linear-gradient(180deg, var(--accent), var(--brass));
  transform:scaleY(.2); transform-origin:center;
  will-change:transform;
}
.vlive{ display:flex; align-items:center; justify-content:center; gap:9px; font-size:12px; color:var(--ink-2); }
.vlive .rec{ width:9px; height:9px; border-radius:50%; background:var(--high); flex:none; }
.vlive .dim{ color:var(--ink-3); font-variant-numeric:tabular-nums; }

.vtranscript{
  font-size:14px; line-height:1.75; color:var(--ink);
  padding:15px 17px; border-radius:var(--r-md);
  background:var(--panel-3); border:1px solid var(--line-2);
  min-height:80px;
}
.vtranscript.quiet{ color:var(--ink-2); font-size:13px; }
.vmeta{ display:flex; gap:7px; flex-wrap:wrap; margin-top:11px; }

.vchips{ display:grid; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); gap:9px; margin-top:11px; }
.vchip{
  padding:10px 12px; border-radius:var(--r-sm);
  background:var(--panel-3); border:1px solid var(--line-2);
}
.vchip .vk{ font-size:9.5px; letter-spacing:.13em; text-transform:uppercase; color:var(--ink-3); }
.vchip .vv{ font-size:12.5px; margin-top:4px; line-height:1.45; }

/* ============================================================
   4. QUESTION FURNITURE
   ============================================================ */
.qhard{
  display:inline-flex; align-items:center; gap:4px; vertical-align:middle;
  font-size:9px; letter-spacing:.1em; text-transform:uppercase;
  color:var(--brass); border:1px solid var(--warn-line); background:var(--warn-soft);
  border-radius:var(--r-pill); padding:2px 7px; margin-left:7px;
}
.qwhy{
  border:0; background:none; cursor:pointer; font:inherit; padding:0 0 0 6px;
  color:var(--ink-3); font-size:12px; line-height:1;
}
.qwhy:hover{ color:var(--accent); }
.qexplain{
  margin-top:7px; padding:11px 13px; border-radius:var(--r-sm);
  background:var(--info-soft); border:1px solid var(--info-line);
  font-size:12.5px; line-height:1.6; color:var(--ink-2);
}
.qexplain .qehead{
  display:flex; align-items:center; gap:7px; margin-bottom:6px;
  font-size:10px; letter-spacing:.12em; text-transform:uppercase; color:var(--info);
}

.groupbox{ margin-top:30px; }
.groupbox:first-child{ margin-top:22px; }
.grouphead{ display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; }
.grouphead .gh{ font-family:var(--font-display); font-size:21px; font-weight:500; }
.groupnote{ font-size:12.5px; color:var(--ink-3); margin:7px 0 0; line-height:1.6; max-width:70ch; }

/* ---------- repeater ---------- */
.repeater{ display:flex; flex-direction:column; gap:11px; margin-top:16px; }
.ritem{
  border:1px solid var(--line-2); border-radius:var(--r-md);
  background:var(--panel-3); padding:15px 16px;
}
.rhead{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px; }
.rhead .rn{ font-size:10.5px; letter-spacing:.13em; text-transform:uppercase; color:var(--ink-3); }
.rfields{ display:grid; grid-template-columns:repeat(auto-fit,minmax(168px,1fr)); gap:12px; }
.rempty{
  padding:18px; text-align:center; border:1px dashed var(--line); border-radius:var(--r-md);
  color:var(--ink-3); font-size:12.5px; background:var(--panel-3);
}
.rdel{
  border:0; background:none; cursor:pointer; color:var(--ink-3); font:inherit; font-size:12px;
  padding:3px 7px; border-radius:var(--r-sm);
}
.rdel:hover{ color:var(--high); background:var(--high-soft); }

/* ============================================================
   5. POLICY SCREEN — the decline / refer surface
   ============================================================ */
.verdict{ --panel-bg: var(--panel); padding:30px 32px; }
.verdict.declined{ border-left:4px solid var(--high); }
.verdict.referred{ border-left:4px solid var(--warn); }
.verdict.cleared{ border-left:4px solid var(--ok); }
.verdict .vstamp{
  display:inline-flex; align-items:center; gap:8px;
  font-size:10.5px; letter-spacing:.16em; text-transform:uppercase; font-weight:700;
  padding:6px 13px; border-radius:var(--r-pill);
}
.verdict.declined .vstamp{ color:var(--high); background:var(--high-soft); border:1px solid var(--high-line); }
.verdict.referred .vstamp{ color:var(--warn); background:var(--warn-soft); border:1px solid var(--warn-line); }
.verdict.cleared  .vstamp{ color:var(--ok);   background:var(--ok-soft);   border:1px solid var(--ok-line); }
.verdict h1, .verdict h2{ font-family:var(--font-display); font-weight:500; font-size:clamp(25px,3vw,33px); line-height:1.15; margin:18px 0 0; }
.verdict .vreason{ font-size:14px; line-height:1.72; color:var(--ink-2); margin:14px 0 0; max-width:66ch; }
.verdict .vclause{
  margin-top:20px; padding:13px 15px; border-radius:var(--r-sm);
  background:var(--panel-3); border:1px solid var(--line-2);
  font-family:var(--font-mono); font-size:11.5px; color:var(--ink-2); line-height:1.6;
}
.vbasis{ margin:16px 0 0; padding:0; list-style:none; display:flex; flex-direction:column; gap:7px; }
.vbasis li{ display:flex; gap:9px; font-size:12.5px; color:var(--ink-2); }
.vbasis li::before{ content:'·'; color:var(--accent); font-weight:700; }

/* ---------- the visible rule audit ---------- */
.screenchecks{ display:flex; flex-direction:column; gap:1px; margin-top:16px; background:var(--line-2); border:1px solid var(--line-2); border-radius:var(--r-md); overflow:hidden; }
.screencheck{
  display:grid; grid-template-columns:22px 1fr auto; gap:12px; align-items:center;
  padding:11px 14px; background:var(--panel-solid); font-size:12.5px;
}
.screencheck .scmk{ text-align:center; font-size:12px; }
.screencheck.pass  .scmk{ color:var(--ok); }
.screencheck.fail  .scmk{ color:var(--high); }
.screencheck.refer .scmk{ color:var(--warn); }
.screencheck.watch .scmk{ color:var(--brass); }
.screencheck.skip  .scmk{ color:var(--ink-3); }
.screencheck .scnote{ font-size:11.5px; color:var(--ink-3); }

/* ============================================================
   6. SIDE PANELS — demo evidence and fault injection
   ============================================================ */
.withside{ display:grid; grid-template-columns:minmax(0,1fr) 300px; gap:24px; align-items:start; }
.sidepanel{
  position:sticky; top:22px;
  border:1px solid var(--line-2); border-radius:var(--r-md);
  background:var(--panel-3); padding:15px 16px;
}
.sidepanel + .sidepanel{ margin-top:14px; }

/* how far through the document list the borrower is */
.covbar{
  height:5px; border-radius:999px; background:var(--line-2);
  overflow:hidden; margin:10px 0 2px;
}
.covbar i{
  display:block; height:100%; background:var(--accent); border-radius:999px;
  transition:width 420ms cubic-bezier(.2,.7,.3,1);
}
.sidepanel .sphead{ display:flex; align-items:center; gap:8px; }
.sidepanel .sptitle{ font-size:12.5px; font-weight:700; }
.sidepanel .spnote{ font-size:11.5px; color:var(--ink-3); margin-top:6px; line-height:1.55; }
.splist{ display:flex; flex-direction:column; gap:6px; margin-top:12px; max-height:340px; overflow:auto; }
.spitem{
  display:grid; grid-template-columns:1fr auto; gap:9px; align-items:center;
  padding:8px 10px; border-radius:var(--r-sm); text-align:left; font:inherit; cursor:pointer;
  background:var(--panel-2); border:1px solid var(--line-2); color:var(--ink-2);
  transition:background var(--fast), border-color var(--fast), color var(--fast);
}
.spitem:hover{ background:var(--raise); border-color:var(--accent-line); color:var(--ink); }
.spitem[disabled]{ opacity:.45; pointer-events:none; }
.spitem .spn{ font-size:11.5px; font-weight:600; line-height:1.35; word-break:break-word; }
.spitem .spd{ font-size:10.5px; color:var(--ink-3); margin-top:2px; line-height:1.4; }
.spitem .spadd{ font-size:15px; color:var(--accent); flex:none; }

/* ============================================================
   7. EVIDENCE CHECKLIST
   ============================================================ */
.checklist{ display:flex; flex-direction:column; gap:20px; margin-top:18px; }
.clgroup .clcat{
  font-size:10px; letter-spacing:.16em; text-transform:uppercase; color:var(--ink-3);
  padding-bottom:8px; border-bottom:1px solid var(--line-2); margin-bottom:10px;
}
.clrows{ display:flex; flex-direction:column; gap:7px; }
.clrow{
  display:grid; grid-template-columns:20px 1fr auto; gap:12px; align-items:start;
  padding:10px 12px; border-radius:var(--r-sm);
  background:var(--panel-3); border:1px solid var(--line-2);
}
.clrow.met{ background:var(--ok-soft); border-color:var(--ok-line); }
.clrow .clmk{ text-align:center; font-size:12px; color:var(--ink-3); line-height:1.5; }
.clrow.met .clmk{ color:var(--ok); }
.clrow .cln{ font-size:12.5px; font-weight:600; }
.clrow .clw{ font-size:11.5px; color:var(--ink-3); margin-top:3px; line-height:1.5; }
.clrow .cldriver{ font-size:10px; color:var(--ink-3); margin-top:5px; letter-spacing:.04em; }
.clrow .cldriver b{ color:var(--accent); font-weight:600; }

/* ============================================================
   7b. FINDINGS, TILED

   A finding is a card of roughly constant height, so they tile. Down a
   narrow column they do not — you get one file of cards and a column of
   nothing beside it.
   ============================================================ */
.findinggrid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(340px, 1fr));
  gap:10px; align-items:start;
}
.findinggrid .finding{ margin:0; }

/* ============================================================
   8. GUIDED TOUR — spotlight
   ============================================================ */
.tourmask{
  /* below the bar, above everything else — the bar must never be dimmed
     by the mask it owns */
  position:fixed; inset:0; z-index:140; pointer-events:none;
  opacity:0; transition:opacity var(--med) var(--ease);
}
.tourmask.on{ opacity:1; }
.tourhole{
  position:absolute; border-radius:var(--r-md);
  box-shadow:0 0 0 9999px var(--tour-dim), 0 0 0 2px var(--accent);
  transition:top var(--med) var(--ease), left var(--med) var(--ease),
             width var(--med) var(--ease), height var(--med) var(--ease);
}
:root{ --tour-dim: rgba(38,26,14,.62); }
html[data-theme='lamplight']{ --tour-dim: rgba(0,0,0,.76); }

.tourbar{ z-index:160; overflow:hidden; }

/* Room for the bar is reserved by the LAYOUT, not by padding bolted onto
   <body> — the two portals scroll differently and each knows its own. */
html.tour-on .canvas{ padding-bottom:190px; }
html.tour-on .portal{ padding-bottom:210px; }

/* progress along the top edge of the bar */
.tourbar .tprog{
  position:absolute; left:0; right:0; top:0; height:2px; background:var(--line-2);
}
.tourbar .tprog i{
  display:block; height:100%; background:var(--accent);
  transition:width 260ms cubic-bezier(.2,.7,.3,1);
}

/* A step whose subject is genuinely not on screen says so, instead of
   quietly dropping the spotlight and leaving the presenter mid-sentence. */
.tourbar.nofocus::after{
  content:'Not on this screen';
  position:absolute; right:14px; top:9px;
  font-size:9.5px; letter-spacing:.14em; text-transform:uppercase;
  color:var(--ink-3);
}

.tourdone{ z-index:160; }
.tourdone .ttitle{ font-family:var(--font-display); font-size:20px; font-weight:500; }
.tourbar .texplain{ font-size:13px; color:var(--ink-2); margin-top:5px; line-height:1.6; }
.tourbar .texplain b{ color:var(--ink); font-weight:650; }
.tourbar .tchapter{
  font-size:9.5px; letter-spacing:.16em; text-transform:uppercase; color:var(--accent);
  margin-bottom:4px;
}

/* ============================================================
   9. NEXT BEST ACTION
   ============================================================ */
.nba{
  display:flex; align-items:center; gap:13px; flex-wrap:wrap;
  padding:13px 16px; border-radius:var(--r-md); margin-bottom:18px;
  background:var(--panel-2); border:1px solid var(--accent-line);
}
.nba .nbamk{ color:var(--accent); font-size:14px; flex:none; }
.nba .nbatext{ font-size:12.5px; color:var(--ink-2); flex:1 1 320px; min-width:0; line-height:1.55; }
.nba .nbatext b{ color:var(--ink); }

/* ============================================================
   10. RESPONSIVE
   ============================================================ */
@media (max-width:1100px){
  .withside{ grid-template-columns:minmax(0,1fr); }
  .sidepanel{ position:static; }
}
@media (max-width:640px){
  .aidock{ right:12px; bottom:12px; }
  .aifab span:not(.fmk):not(.fcnt){ display:none; }
  .aifab{ padding:0 14px; }
  .vchips{ grid-template-columns:minmax(0,1fr); }
}

@media (prefers-reduced-motion: reduce){
  .pulsering::after{ animation:none; }
  .tourhole{ transition:none; }
}
