/* ============================================================
   WORKFLOW — full-screen pinned teaching diagrams (redesign)
   ============================================================ */
.flow { position: relative; background: var(--bg); }
.flow-stage {
  position: sticky; top: 0; height: 100svh;
  display: flex; align-items: stretch; overflow: hidden;
  border-top: 1px solid var(--line);
}
.flow-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  background: linear-gradient(180deg, rgba(10,11,13,.88) 0%, transparent 100%);
  padding-bottom: 28px;
}
.flow-head .wrap { display: flex; justify-content: space-between; align-items: center; padding-top: 20px; }
.flow-head .t { font-family: var(--mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-mute); }

/* progress rail */
.flow-rail { display: flex; gap: 10px; }
.flow-rail .seg { width: 46px; height: 3px; background: var(--line-2); border-radius: 2px; overflow: hidden; position: relative; }
.flow-rail .seg i { position: absolute; inset: 0; background: var(--accent); transform-origin: left; transform: scaleX(0); }

/* main grid */
.flow-grid { flex: 1; position: relative; }
.stage-visual { position: absolute; inset: 0; }
.diagram { position: absolute; inset: 0; opacity: 0; transition: opacity .4s ease; pointer-events: none; }
.diagram.on { opacity: 1; pointer-events: auto; }

/* Copy overlay — frosted glass card, bottom-left */
.stage-copy { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.copy {
  position: absolute; bottom: 72px; left: clamp(20px, 5vw, 64px);
  width: min(480px, 90vw); pointer-events: auto;
  opacity: 0; transform: translateY(14px);
  transition: opacity .38s ease, transform .38s cubic-bezier(.16,1,.3,1);
  padding: 28px 32px; border-radius: 14px;
  border: 1px solid var(--line-2);
  background: color-mix(in oklch, var(--bg) 84%, transparent);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.copy.on { opacity: 1; transform: none; }
.copy .num { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: .18em; margin-bottom: 10px; }
.copy h3 { font-family: var(--display); font-size: clamp(22px, 2.8vw, 34px); line-height: 1.1; margin-bottom: 12px; }
.copy p { font-size: clamp(14px, 1.4vw, 16px); color: var(--ink-soft); line-height: 1.6; max-width: 44ch; }
.copy .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.copy .tags span { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); border: 1px solid var(--line-2); padding: 4px 9px; border-radius: 4px; white-space: nowrap; }

/* ============================================================
   D1 — CLIENT PORTAL / WEB APP (full screen)
   ============================================================ */
.d1-full {
  position: absolute; inset: 0; background: var(--bg-1); overflow: hidden;
  display: grid; grid-template-columns: 200px 1fr;
}

.d1-sidebar {
  background: var(--bg-2); border-right: 1px solid var(--line-2);
  padding: 80px 14px 320px; display: flex; flex-direction: column; gap: 3px; overflow: hidden;
}
.d1-sidebar-brand {
  font-family: var(--display); font-size: 14px; color: var(--accent);
  padding: 0 8px 14px; margin-bottom: 8px; border-bottom: 1px solid var(--line);
  opacity: calc(clamp(0, var(--p) * 9, 1));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.d1-nav-item {
  font-size: 13px; color: var(--ink-mute); padding: 8px 10px; border-radius: 6px;
  opacity: calc(clamp(0, (var(--p) - var(--ni) * 0.04) * 10, 1));
  transform: translateX(calc((1 - clamp(0, (var(--p) - var(--ni) * 0.04) * 10, 1)) * -14px));
  white-space: nowrap;
}
.d1-nav-item.active {
  background: color-mix(in oklch, var(--accent) 10%, var(--bg-3));
  color: var(--accent);
}

.d1-main {
  padding: 80px clamp(16px, 2.5vw, 28px) 320px;
  display: flex; flex-direction: column; gap: 14px; overflow: hidden;
}

.d1-url-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg-3);
  font-family: var(--mono); font-size: 11px; color: var(--ink-mute);
  opacity: calc(clamp(0, var(--p) * 8, 1));
  transform: translateY(calc((1 - clamp(0, var(--p) * 8, 1)) * -6px));
  flex: none;
}
.d1-url-dots { display: flex; gap: 5px; }
.d1-url-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); flex: none; }

.d1-main-head { display: flex; align-items: center; gap: 12px; }
.d1-main-title {
  font-family: var(--display); font-size: 20px; color: var(--ink);
  opacity: calc(clamp(0, (var(--p) - 0.10) * 10, 1));
}
.d1-main-badge {
  font-family: var(--mono); font-size: 11px; color: var(--accent);
  border: 1px solid var(--accent); padding: 3px 9px; border-radius: 20px;
  opacity: calc(clamp(0, (var(--p) - 0.13) * 10, 1));
}

.d1-stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; flex: none; }
.d1-stat {
  padding: 14px 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2);
  opacity: calc(clamp(0, (var(--p) - 0.16 - var(--si) * 0.05) * 10, 1));
  transform: translateY(calc((1 - clamp(0, (var(--p) - 0.16 - var(--si) * 0.05) * 10, 1)) * 14px));
}
.d1-stat-l { font-family: var(--mono); font-size: 9px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.d1-stat-v { font-family: var(--display); font-size: clamp(18px, 2vw, 26px); color: var(--ink); }

.d1-table { border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; flex: none; }
.d1-table-head {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr;
  padding: 9px 16px; background: var(--bg-3); border-bottom: 1px solid var(--line-2);
  font-family: var(--mono); font-size: 10px; color: var(--ink-mute); letter-spacing: .1em; text-transform: uppercase;
  opacity: calc(clamp(0, (var(--p) - 0.36) * 10, 1));
}
.d1-table-row {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--ink-soft); align-items: center;
  opacity: calc(clamp(0, (var(--p) - 0.40 - var(--ri) * 0.05) * 10, 1));
  transform: translateX(calc((1 - clamp(0, (var(--p) - 0.40 - var(--ri) * 0.05) * 10, 1)) * 18px));
}
.d1-table-row:last-child { border-bottom: none; }
.d1-row-client { font-weight: 600; color: var(--ink); }
.d1-row-status {
  font-family: var(--mono); font-size: 10px; padding: 3px 7px; border-radius: 3px;
  border: 1px solid var(--line-2); color: var(--ink-mute); width: fit-content;
}
.d1-row-status.active { border-color: var(--accent); color: var(--accent); background: color-mix(in oklch, var(--accent) 8%, transparent); }
.d1-row-status.new { border-color: var(--accent-2); color: var(--accent-2); background: color-mix(in oklch, var(--accent-2) 8%, transparent); }
.d1-row-value { font-weight: 600; color: var(--ink); }
.d1-row-due { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); }

/* ============================================================
   D2 — EMAIL AUTOMATION (full screen, 2-col)
   ============================================================ */
.d2-full { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; background: var(--bg-2); }
.d2-inbox { padding: 80px 32px 420px; border-right: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 14px; overflow: hidden; background: color-mix(in oklch, var(--bg-1) 60%, var(--bg-2)); }
.d2-inbox-header { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; flex-shrink: 0; }
.d2-inbox-icon { font-size: 22px; }
.d2-inbox-name { font-weight: 600; font-size: 15px; }
.d2-inbox-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); }
.d2-email { padding: 16px 18px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg-3); position: relative; overflow: hidden; flex-shrink: 0; }
/* D2: email is always visible — it's the "before" state. The AI scan glow is the animation. */
.d2-email.new { border-color: var(--accent); box-shadow: 0 0 24px color-mix(in oklch, var(--accent) 12%, transparent); }
.d2-email.read { opacity: .28; }
.d2-badge { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; color: var(--accent); margin-bottom: 8px; }
.d2-from { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.d2-subject { font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.d2-preview { font-size: 13px; color: var(--ink-mute); line-height: 1.5; }
.d2-scan-glow {
  position: absolute; left: 0; right: 0; height: 56%;
  background: linear-gradient(180deg, transparent 0%, color-mix(in oklch, var(--accent) 16%, transparent) 50%, transparent 100%);
  top: calc(-56% + var(--p) * 280%);
  opacity: calc(clamp(0, (var(--p) - 0.18) * 6, 1) * clamp(0, 1 - (var(--p) - 0.48) * 7, 1));
  pointer-events: none;
}
.d2-replied {
  position: absolute; top: 12px; right: 14px;
  font-family: var(--mono); font-size: 10.5px; color: var(--accent);
  border: 1px solid var(--accent); padding: 3px 8px; border-radius: 4px;
  opacity: calc(clamp(0, (var(--p) - 0.88) * 10, 1));
}
.d2-log { padding: 80px 32px 40px; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.d2-log-header { font-family: var(--display); font-size: 17px; color: var(--accent); padding-bottom: 16px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; flex-shrink: 0; }
.d2-steps { display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.d2-step {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 12px 14px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--line-2);
  opacity: calc(clamp(0, (var(--p) - var(--t)) * 9, 1));
  transform: translateY(calc((1 - clamp(0, (var(--p) - var(--t)) * 9, 1)) * 12px));
}
.d2-step-icon { font-size: 18px; flex: none; }
.d2-step-label { font-size: 14px; font-weight: 600; color: var(--ink); }
.d2-step-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); margin-top: 3px; }
.d2-reply-card {
  margin-top: 6px; padding: 16px 18px; border-radius: 10px; flex-shrink: 0;
  border: 1px solid var(--accent);
  background: color-mix(in oklch, var(--accent) 5%, var(--bg-2));
  opacity: calc(clamp(0, (var(--p) - 0.57) * 6, 1));
}
.d2-reply-label { font-family: var(--mono); font-size: 10.5px; color: var(--accent); letter-spacing: .1em; margin-bottom: 10px; }
.d2-reply-body { font-size: 13px; color: var(--ink-soft); line-height: 1.65; white-space: pre-wrap; min-height: 60px; }

/* ============================================================
   D3 — DASHBOARD (full screen)
   ============================================================ */
.d3-full {
  position: absolute; inset: 0;
  display: grid; grid-template-rows: auto 1fr auto;
  gap: 14px; padding: 84px clamp(20px, 4vw, 52px) 420px;
  background: var(--bg-2); overflow: hidden;
}
.d3-kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
/* D3: tiles start at base opacity 0.28 ("empty dashboard"), count up to full opacity */
.d3-kpi {
  padding: 18px 20px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--bg-3);
  opacity: max(0.28, calc(clamp(0, (var(--p) - var(--kd)) * 10, 1)));
  transform: translateY(calc((1 - clamp(0, (var(--p) - var(--kd)) * 10, 1)) * 10px));
}
.d3-kpi.urgent { border-color: var(--accent-2); background: color-mix(in oklch, var(--accent-2) 4%, var(--bg-2)); }
.d3-kpi-label { font-family: var(--mono); font-size: 10px; color: var(--ink-mute); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 8px; }
.d3-kpi-value { font-family: var(--display); font-size: clamp(24px, 2.8vw, 38px); color: var(--ink); margin-bottom: 6px; }
.d3-kpi-delta { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.d3-kpi.urgent .d3-kpi-delta { color: var(--accent-2); }
.d3-chart-row { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; min-height: 0; }
.d3-line-panel, .d3-bars-panel { padding: 18px 22px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg-3); overflow: hidden; }
.d3-line-panel { opacity: max(0.28, calc(clamp(0, (var(--p) - 0.30) * 5, 1))); }
.d3-bars-panel { opacity: max(0.28, calc(clamp(0, (var(--p) - 0.40) * 5, 1))); }
.d3-panel-label { font-family: var(--mono); font-size: 10px; color: var(--ink-mute); letter-spacing: .06em; margin-bottom: 14px; text-transform: uppercase; }
.d3-line-panel svg { width: 100%; display: block; overflow: visible; }
.d3-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 13px; color: var(--ink-soft); }
.d3-bar-row em { color: var(--accent); font-style: normal; font-size: 11px; }
.d3-bar-name { flex: 0 0 110px; }
.d3-bar-track { flex: 1; height: 7px; background: var(--line-2); border-radius: 4px; overflow: hidden; }
.d3-bar-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), color-mix(in oklch, var(--accent) 55%, var(--accent-2)));
  transform-origin: left;
  transform: scaleX(calc(var(--bw) * clamp(0, (var(--p) - 0.44) * 5, 1)));
}
.d3-insight {
  padding: 20px 26px; border-radius: 14px;
  border: 1px solid var(--accent);
  background: color-mix(in oklch, var(--accent) 5%, var(--bg-2));
  box-shadow: 0 0 48px color-mix(in oklch, var(--accent) 10%, transparent);
  opacity: calc(clamp(0, (var(--p) - 0.72) * 6, 1));
  transform: translateY(calc((1 - clamp(0, (var(--p) - 0.72) * 6, 1)) * 22px));
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-shrink: 0;
}
.d3-insight-label { font-family: var(--mono); font-size: 10px; color: var(--accent); letter-spacing: .12em; margin-bottom: 8px; text-transform: uppercase; }
.d3-insight-body { font-size: 14.5px; color: var(--ink-soft); line-height: 1.55; }
.d3-insight-body strong { color: var(--accent); font-weight: 700; }
.d3-insight-cta { flex: none; font-family: var(--mono); font-size: 13px; color: var(--accent); border: 1px solid var(--accent); padding: 10px 16px; border-radius: 6px; white-space: nowrap; }

/* ============================================================
   D4 — DOCUMENT SEARCH (full screen, 3-col)
   ============================================================ */
.d4-full { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1.15fr 1fr; background: var(--bg-2); }
.d4-docs-col { padding: 80px 22px 420px; border-right: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; justify-content: center; position: relative; overflow: hidden; }
.d4-col-label { font-family: var(--mono); font-size: 10px; color: var(--ink-soft); letter-spacing: .14em; margin-bottom: 8px; text-transform: uppercase; }
/* D4: doc list starts visible so users see "years of documents" before searching */
.d4-doc {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--bg-3);
  opacity: max(0.32, calc(clamp(0, (var(--p) - var(--dt)) * 10, 0.55)));
}
.d4-doc.match {
  border-color: var(--accent);
  background: color-mix(in oklch, var(--accent) 6%, var(--bg-2));
  box-shadow: 0 0 20px color-mix(in oklch, var(--accent) 14%, transparent);
  opacity: max(0.32, calc(clamp(0, (var(--p) - 0.05) * 8, 0.5) + clamp(0, (var(--p) - 0.44) * 6, 0.5)));
}
.d4-doc-icon { font-size: 15px; flex: none; }
.d4-doc-name { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }
.d4-doc-pages { font-family: var(--mono); font-size: 10px; color: var(--ink-mute); margin-top: 2px; }
.d4-match-tag { margin-left: auto; flex: none; font-family: var(--mono); font-size: 10px; color: var(--accent); border: 1px solid var(--accent); padding: 2px 6px; border-radius: 3px; opacity: calc(clamp(0, (var(--p) - 0.60) * 7, 1)); }
.d4-scan-bar {
  position: absolute; left: 22px; right: 22px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 14px var(--accent);
  top: calc(80px + clamp(0, (var(--p) - 0.44) * 4.5, 1) * 60%);
  opacity: calc(clamp(0, (var(--p) - 0.44) * 10, 1) * clamp(0, 1 - (var(--p) - 0.64) * 10, 1));
  pointer-events: none;
}
.d4-center-col { padding: 80px 24px 40px; display: flex; flex-direction: column; gap: 20px; justify-content: center; border-right: 1px solid var(--line-2); }
.d4-center-label { font-family: var(--mono); font-size: 10px; color: var(--ink-mute); letter-spacing: .12em; text-transform: uppercase; }
.d4-question-box {
  padding: 18px 20px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--bg-3);
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 14.5px; color: var(--ink); line-height: 1.55; min-height: 90px;
  opacity: max(0.4, calc(clamp(0, (var(--p) - 0.12) * 8, 1)));
}
.d4-q-prefix { font-size: 17px; flex: none; }
.d4-q-text-wrap { flex: 1; }
.d4-q-text { white-space: pre-wrap; }
.d4-cursor {
  display: inline-block; width: 2px; height: 1.1em;
  background: var(--accent); margin-left: 1px;
  animation: blink4 1s step-end infinite;
  opacity: calc(clamp(0, (var(--p) - 0.12) * 8, 1) * clamp(0, 1 - (var(--p) - 0.44) * 8, 1));
  vertical-align: text-bottom;
}
@keyframes blink4 { 0%,100%{opacity:1} 50%{opacity:0} }
.d4-thinking { display: flex; align-items: center; gap: 8px; opacity: calc(clamp(0, (var(--p) - 0.44) * 9, 1) * clamp(0, 1 - (var(--p) - 0.64) * 9, 1)); }
.d4-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: dpulse4 1.2s ease-in-out infinite; }
.d4-dot:nth-child(2) { animation-delay: .2s; }
.d4-dot:nth-child(3) { animation-delay: .4s; }
@keyframes dpulse4 { 0%,100%{opacity:.25;transform:scale(.8)} 50%{opacity:1;transform:scale(1.15)} }
.d4-thinking-label { font-family: var(--mono); font-size: 12px; color: var(--ink-mute); }
.d4-found-label { font-family: var(--mono); font-size: 12px; color: var(--accent); opacity: calc(clamp(0, (var(--p) - 0.63) * 8, 1)); }
.d4-answer-col { padding: 80px 26px 40px; display: flex; flex-direction: column; gap: 18px; justify-content: center; }
.d4-answer-header { font-family: var(--display); font-size: 17px; color: var(--accent); padding-bottom: 14px; border-bottom: 1px solid var(--line-2); opacity: calc(clamp(0, (var(--p) - 0.63) * 8, 1)); }
.d4-answer-body { font-size: 15px; color: var(--ink); line-height: 1.65; white-space: pre-wrap; min-height: 80px; }
.d4-source-card { padding: 16px 18px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); opacity: calc(clamp(0, (var(--p) - 0.88) * 9, 1)); transform: translateY(calc((1 - clamp(0, (var(--p) - 0.88) * 9, 1)) * 12px)); }
.d4-source-title { font-family: var(--mono); font-size: 10px; color: var(--ink-mute); letter-spacing: .12em; margin-bottom: 8px; text-transform: uppercase; }
.d4-source-file { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); margin-bottom: 10px; }
.d4-source-quote { font-size: 13px; color: var(--ink-mute); font-style: italic; line-height: 1.55; }
.d4-source-quote mark { background: color-mix(in oklch, var(--accent) 22%, transparent); color: var(--accent); border-radius: 2px; padding: 0 3px; font-style: normal; }

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 700px) {
  .d2-full { grid-template-columns: 1fr; }
  .d2-inbox { display: none; }
  .d2-log { padding-top: 80px; }
  .d4-full { grid-template-columns: 1fr; }
  .d4-docs-col, .d4-center-col { display: none; }
  .d4-answer-col { padding: 80px 24px 200px; justify-content: flex-start; padding-top: 100px; }
  .d3-kpi-row { grid-template-columns: 1fr 1fr; }
  .d3-chart-row { grid-template-columns: 1fr; }
  .d1-island { min-width: 120px; padding: 12px 14px; }
  .d1-icon { font-size: 20px; }
  .d1-val { font-size: 18px; }
}
