/* ==========================================================================
   Section 4 — Principles · "Four things we won't compromise on"
   A bento grid where each principle proves itself with a small working
   demo (js/sections/principles.js). Background ported from the original
   site's #why (grain + soft blue wash). Prefixed .pr- and scoped to
   .principles.

   Microinteraction rules used throughout:
   - only real controls get hover/focus/active states (no decorative tile hover)
   - UI transitions 150–300ms, ease-out entering
   - every control has a visible state change and an accessible state
   ========================================================================== */

.principles {
  --pr-bg:        #F8FAFD;
  --pr-wash-a:    rgba(197,220,247,0.22);
  --pr-wash-b:    rgba(147,190,240,0.13);
  --pr-grain:     0.038;
  --pr-tile:      #ffffff;
  --pr-well:      #F4F7FB;        /* demo surface inside a tile */
  --pr-well-edge: rgba(10,47,107,0.06);
  --pr-dot:       rgba(10,47,107,0.13);
  --pr-chip:      #ffffff;
  --pr-shadow:    0 1px 2px rgba(10,47,107,0.04), 0 18px 40px -28px rgba(10,47,107,0.28);

  position: relative;
  overflow: hidden;
  padding: clamp(72px, 9vw, 120px) var(--page-px);
  background: var(--pr-bg);
}

:root[data-theme="dark"] .principles {
  --pr-bg:        #071733;
  --pr-wash-a:    rgba(55,138,221,0.14);
  --pr-wash-b:    rgba(55,138,221,0.08);
  --pr-grain:     0.05;
  --pr-tile:      #0B1F42;
  --pr-well:      #08193A;
  --pr-well-edge: rgba(255,255,255,0.05);
  --pr-dot:       rgba(147,190,240,0.12);
  --pr-chip:      #10294F;
  --pr-shadow:    0 18px 40px -28px rgba(0,0,0,0.6);
}

/* Noise grain */
.principles::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--pr-grain);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}
/* Soft blue wash */
.principles::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 65% 75% at 98% 50%, var(--pr-wash-a) 0%, transparent 70%),
    radial-gradient(ellipse 40% 50% at 82% 12%, var(--pr-wash-b) 0%, transparent 60%);
}

.pr-inner {
  position: relative;
  z-index: 1;
  max-width: var(--container);
  margin: 0 auto;
}

/* ─── Head ────────────────────────────────────────────────────────────── */
.pr-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: clamp(32px, 4vw, 48px);
}
.pr-headline {
  max-width: 640px;
  font-size: var(--fs-section-title);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.pr-headline em { font-style: normal; color: var(--accent); }
.pr-body {
  max-width: 560px;
  font-size: var(--fs-section-sub);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ─── Bento grid ──────────────────────────────────────────────────────── */
.pr-bento {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.pr-tile {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  background: var(--pr-tile);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--pr-shadow);
}
.pr-tile--wide { grid-column: span 2; }

/* Copy */
.pr-copy { display: flex; flex-direction: column; padding: 0 4px 4px; }
/* Wide tiles: the same title → kicker → text stack, above a full-width demo */
.pr-copy--wide { padding: 4px 4px 0; }
.pr-copy--wide .pr-text { max-width: 620px; }
.pr-kicker { margin-bottom: 0; }
.pr-kicker {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-text);
}
.pr-title {
  margin-bottom: 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.pr-text {
  font-size: 14px;
  font-weight: 300;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* Demo surface */
.pr-demo {
  position: relative;
  flex: 1;
  min-height: 200px;
  padding: 18px;
  background: var(--pr-well);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--pr-well-edge);
  font-variant-numeric: tabular-nums;
  isolation: isolate;           /* keeps the dot layer behind the content */
}
/* Considered dot grid: fine, low-contrast, strongest in the middle and
   fading out toward the edges so it never competes with the content */
.pr-demo::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--pr-dot) 0.9px, transparent 1.3px);
  background-size: 14px 14px;
  background-position: 7px 7px;
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 45%, #000 30%, transparent 85%);
          mask-image: radial-gradient(ellipse 75% 70% at 50% 45%, #000 30%, transparent 85%);
}

/* ═══ Shared controls ═══════════════════════════════════════════════════ */
.pr-switch {
  position: relative;
  flex-shrink: 0;
  width: 34px; height: 20px;
  padding: 0;
  background: var(--border-strong);
  border: none;
  border-radius: 99px;
  cursor: pointer;
  transition: background-color 0.18s ease-out;
}
.pr-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(10,47,107,0.3);
  transition: transform 0.18s ease-out, width 0.12s ease-out;
}
.pr-switch[aria-checked="true"] { background: var(--accent); }
.pr-switch[aria-checked="true"]::after { transform: translateX(14px); }
.pr-switch:active::after { width: 19px; }
.pr-switch[aria-checked="true"]:active::after { transform: translateX(11px); }

/* ═══ Configurable · pipeline ═══════════════════════════════════════════ */
.pr-cfg { display: flex; flex-direction: column; gap: 22px; }
.pr-cfg-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
}
.pr-ctl {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-primary);
}
.pr-ctl--seg { margin-left: auto; }
.pr-ctl--seg > span { color: var(--text-secondary); }

/* Segmented control with a sliding thumb */
.pr-seg {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  background: var(--pr-tile);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.pr-seg button {
  position: relative;
  z-index: 1;
  padding: 4px 10px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.18s ease-out;
}
.pr-seg button[aria-checked="true"] { color: #fff; }
:root[data-theme="dark"] .pr-seg button[aria-checked="true"] { color: #061530; }
.pr-seg-thumb {
  position: absolute;
  top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 3px);
  background: var(--text-primary);
  border-radius: 6px;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.pr-seg[data-value="field"] .pr-seg-thumb { transform: translateX(100%); }

/* The track: nodes on a line. Turning a step off collapses its node and
   the rest of the track closes the gap. */
.pr-track {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 0 4px;
}
.pr-track::before {
  content: '';
  position: absolute;
  top: 17px; left: 24px; right: 24px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-line), var(--accent));
  opacity: 0.55;
}
.pr-node {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: flex-grow 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease-out;
}
.pr-node-dot {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  color: var(--text-primary);
  background: var(--pr-tile);
  border: 1.5px solid var(--border-strong);
  border-radius: 11px;
  box-shadow: 0 4px 10px -6px rgba(10,47,107,0.35);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.2s, border-color 0.2s, color 0.2s;
}
.pr-node-dot i { font-size: 17px; }
.pr-node-label {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  color: var(--text-secondary);
  white-space: nowrap;
}
.pr-node-label small { display: block; font-size: 10.5px; font-weight: 400; color: var(--text-muted); }

.pr-node.is-opt .pr-node-dot { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.pr-node.is-opt .pr-node-label { color: var(--accent-text); }
.pr-node.is-var .pr-node-dot { border-style: dashed; border-color: var(--accent); }

.pr-node.is-off { flex-grow: 0.0001; opacity: 0; }
.pr-node.is-off .pr-node-dot { transform: scale(0.4); }
.pr-node.is-off .pr-node-label { visibility: hidden; }
.pr-node.is-swap .pr-node-dot { animation: pr-swap 0.36s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes pr-swap { 40% { transform: scale(0.82) rotate(-6deg); } }

.pr-cfg-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}
.pr-count { font-weight: 600; color: var(--text-primary); }
.pr-count.is-tick { animation: pr-tick 0.3s ease-out; }
@keyframes pr-tick { from { opacity: 0.2; transform: translateY(3px); } }
.pr-legend-mini { display: inline-flex; align-items: center; gap: 6px; }
.pr-k { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.pr-k--opt { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.pr-k--var { margin-left: 8px; box-shadow: inset 0 0 0 1px var(--accent); border: 1px dashed var(--accent); }

/* ═══ Modern · branch web app + DFA ════════════════════════════════════ */
.pr-modern { min-height: 210px; overflow: hidden; }
.pr-browser {
  position: absolute;
  top: 16px; left: 16px;
  width: calc(100% - 112px);   /* the DFA phone only overlaps its edge */
  background: var(--pr-tile);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 10px 24px -16px rgba(10,47,107,0.35);
  overflow: hidden;
}
.pr-browser-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 9px;
  background: var(--pr-well);
  border-bottom: 1px solid var(--border);
}
.pr-browser-bar i { width: 6px; height: 6px; border-radius: 50%; }
/* macOS window controls: close · minimise · zoom */
.pr-browser-bar i:nth-child(1) { background: #FF5F57; }
.pr-browser-bar i:nth-child(2) { background: #FEBC2E; }
.pr-browser-bar i:nth-child(3) { background: #28C840; }
.pr-browser-bar span { margin-left: 8px; font-size: 9.5px; color: var(--text-muted); }
.pr-browser-body { padding: 10px 11px 12px; }
.pr-kpi { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.pr-kpi small { display: block; font-size: 9.5px; color: var(--text-muted); }
.pr-kpi b {
  display: block;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.pr-spark { width: 64px; height: 24px; }
.pr-spark path { fill: none; stroke: var(--good); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.pr-rows { margin-top: 10px; display: grid; gap: 4px; }
.pr-rows li {
  display: flex;
  justify-content: space-between;
  padding: 5px 7px;
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--pr-well);
  border-radius: 5px;
}
.pr-rows li span:last-child { color: var(--text-primary); font-weight: 500; }
.pr-rows li.is-new { animation: pr-row-in 1.6s ease-out; }
@keyframes pr-row-in {
  0%   { opacity: 0; transform: translateY(-6px); background: var(--good-soft); }
  15%  { opacity: 1; transform: none; background: var(--good-soft); }
  70%  { background: var(--good-soft); }
}

.pr-arc { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.pr-arc path { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; opacity: 0.55; }
.pr-packet {
  position: absolute;
  top: 0; left: 0;
  width: 9px; height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 0 12px var(--accent);
  opacity: 0;
}

.pr-dfa {
  position: absolute;
  right: 16px; bottom: -22px;
  width: 92px;
  height: 172px;
  padding: 22px 6px 6px;
  background: #0C0F14;
  border-radius: 20px;
  box-shadow: 0 0 0 1px #3A414B, 0 18px 30px -14px rgba(10,47,107,0.55);
}
.pr-dfa::before {
  content: '';
  position: absolute;
  inset: 4px;
  background: var(--pr-tile);
  border-radius: 16px;
}
.pr-dfa > * { position: relative; }
.pr-dfa-cam {
  position: absolute;
  top: 9px; left: 50%;
  width: 6px; height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: #0C0F14;
}
.pr-dfa-head { font-size: 8.5px; font-weight: 600; color: var(--text-muted); padding: 0 3px; }
.pr-dfa-card {
  margin-top: 6px;
  padding: 7px;
  font-size: 9px;
  line-height: 1.3;
  background: var(--pr-well);
  border: 1px solid var(--border);
  border-radius: 7px;
  transition: border-color 0.3s ease-out;
}
.pr-dfa-card small { display: block; font-weight: 600; color: var(--accent-text); }
.pr-dfa-card b { display: block; font-weight: 600; color: var(--text-primary); }
.pr-dfa-amt { display: block; margin-top: 2px; font-family: var(--font-display); font-size: 12px; font-weight: 600; color: var(--text-primary); }
.pr-dfa-state {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 6px;
  padding: 2px 6px;
  font-size: 8.5px;
  font-weight: 600;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 99px;
  transition: color 0.25s ease-out, background-color 0.25s ease-out;
}
.pr-dfa-state i { font-size: 9px; }
.pr-dfa-card.is-synced { border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.pr-dfa-card.is-synced .pr-dfa-state { color: var(--good); background: var(--good-soft); }

/* ═══ Cost-effective · modules → meter (+ confetti) ════════════════════ */
.pr-cost { display: flex; flex-direction: column; gap: 14px; overflow: visible; }
.pr-mods { display: flex; flex-wrap: wrap; gap: 6px; }
.pr-mod {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px 6px 7px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--pr-tile);
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  cursor: pointer;
  transition: color 0.15s ease-out, background-color 0.15s ease-out, border-color 0.15s ease-out, transform 0.1s ease-out;
}
.pr-mod > i { font-size: 13px; color: var(--accent-text); }
.pr-mod small { font-size: 10.5px; font-weight: 400; color: var(--text-muted); }
.pr-mod:hover:not(:disabled) { border-color: var(--accent-line); color: var(--text-primary); }
.pr-mod:active:not(:disabled) { transform: scale(0.96); }
.pr-mod:disabled { cursor: default; }
.pr-mod[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-line); }

.pr-check {
  display: grid;
  place-items: center;
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  transition: background-color 0.15s ease-out, border-color 0.15s ease-out;
}
.pr-check svg { width: 10px; height: 10px; }
.pr-check path {
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 12;
  stroke-dashoffset: 12;
  transition: stroke-dashoffset 0.22s ease-out 0.05s;
}
.pr-mod[aria-pressed="true"] .pr-check { background: var(--accent); border-color: var(--accent); }
.pr-mod[aria-pressed="true"] .pr-check path { stroke-dashoffset: 0; }

.pr-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pr-meter i {
  height: 6px;
  border-radius: 3px;
  background: var(--border-strong);
  transition: background-color 0.25s ease-out;
}
.pr-meter i.is-on { background: var(--accent); }
.pr-cost.is-full .pr-meter i { background: var(--good); }

/* Plan summary: one line per selected module */
.pr-plan {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  padding: 12px 14px;
  background: var(--pr-tile);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.pr-plan-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.pr-cost-line { letter-spacing: 0; text-transform: none; font-weight: 600; color: var(--text-primary); }
.pr-cost.is-full .pr-cost-line { color: var(--good); }
.pr-plan-lines { display: grid; gap: 6px; flex: 1; align-content: start; }
.pr-plan-lines li {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-primary);
  animation: pr-line-in 0.24s ease-out both;
}
.pr-plan-lines li span:last-child { font-size: 11.5px; color: var(--text-muted); }
@keyframes pr-line-in { from { opacity: 0; transform: translateY(-4px); } }
.pr-cost-zero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border-strong);
}
.pr-cost-zero b { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--good); }

/* Confetti pieces are created by JS inside this layer */
.pr-confetti { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; z-index: 3; }
.pr-confetti i { position: absolute; display: block; border-radius: 2px; }

/* ═══ AI-driven · ongoing conversation ═════════════════════════════════ */
.pr-ai { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.pr-chat-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--pr-tile);
}
.pr-chat-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 24px; height: 24px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-700));
  border-radius: 9px;
}
.pr-chat-avatar i { font-size: 13px; }
.pr-chat-id { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
.pr-chat-id b { font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.pr-chat-id small { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-chat-id small i { flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
/* Conversation controls: step dots (progress + jump) and play/pause */
.pr-chat-ctrl { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }
.pr-steps { display: flex; align-items: center; gap: 5px; }
.pr-step {
  position: relative;
  width: 8px; height: 8px;
  padding: 0;
  overflow: hidden;
  background: var(--border-strong);
  border: none;
  border-radius: 99px;
  cursor: pointer;
  transition: width 0.25s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.2s ease-out;
}
.pr-step::before {                 /* hit area ≥ 24px */
  content: '';
  position: absolute;
  inset: -8px;
}
.pr-step::after {                  /* progress fill while this answer is shown */
  content: '';
  position: absolute;
  inset: 0;
  width: calc(var(--p, 0) * 100%);
  background: var(--accent);
  border-radius: inherit;
}
.pr-step:hover { background: var(--accent-line); }
.pr-step.is-done { background: var(--accent); }
.pr-step.is-current { width: 22px; background: var(--accent-soft); }

.pr-play {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  padding: 0;
  color: var(--text-primary);
  background: var(--pr-well);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.15s ease-out, border-color 0.15s ease-out, transform 0.1s ease-out;
}
.pr-play:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.pr-play:active { transform: scale(0.92); }
.pr-play i { font-size: 13px; }

.pr-chat {
  position: relative;
  flex: 1 1 auto;
  height: 272px;               /* grows to fill the tile if the row is taller */
  min-height: 272px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  overflow: hidden;
  scroll-behavior: smooth;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22px, #000 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 22px, #000 100%);
}
.pr-chat.is-fading { opacity: 0; transition: opacity 0.35s ease-in; }
.pr-fine {
  position: absolute;
  top: 10px; right: 14px;
  z-index: 2;
  font-size: 10.5px;
  color: var(--text-muted);
}
.pr-ai { position: relative; }

.pr-msg {
  flex-shrink: 0;
  max-width: 78%;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  border-radius: 14px;
  animation: pr-msg-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes pr-msg-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.pr-msg--me {
  align-self: flex-end;
  color: #fff;
  background: var(--blue-600);
  border-bottom-right-radius: 4px;
}
.pr-msg--ai {
  align-self: flex-start;
  width: min(78%, 360px);   /* charts keep their designed scale */
  color: var(--text-primary);
  background: var(--pr-tile);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 6px 16px -12px rgba(10,47,107,0.35);
}
.pr-msg--ai > b { display: block; margin-bottom: 10px; font-weight: 600; }
.pr-msg--ai.pr-typing { display: inline-flex; gap: 4px; width: auto; padding: 12px 14px; }
.pr-typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); animation: pr-dot 0.9s ease-in-out infinite; }
.pr-typing i:nth-child(2) { animation-delay: 0.15s; }
.pr-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pr-dot { 0%, 60%, 100% { opacity: 0.3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }

/* Charts inside answers */
.pr-chart { display: block; width: 100%; height: auto; overflow: visible; }
.pr-chart text { font-family: var(--font-body); font-size: 9px; fill: var(--text-muted); }
.pr-chart .v { font-family: var(--font-display); font-weight: 600; fill: var(--text-primary); }
.pr-chart .track { fill: var(--pr-well); }
.pr-chart .bar { transform-box: fill-box; transform-origin: left; animation: pr-grow-x 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }
.pr-chart .bar.ok   { fill: var(--good); }
.pr-chart .bar.high { fill: var(--warn); }
.pr-chart .limit { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.pr-chart .area { fill: url(#pr-area-grad); opacity: 0; animation: pr-fade 0.6s ease-out 0.4s forwards; }
.pr-chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 400; stroke-dashoffset: 400; animation: pr-draw 0.9s ease-out forwards; }
.pr-chart .dip { fill: var(--warn); stroke: var(--pr-tile); stroke-width: 2; opacity: 0; animation: pr-fade 0.3s ease-out 0.9s forwards; }
.pr-chart .grid { stroke: var(--border); stroke-width: 1; }
.pr-chart .seg { fill: none; stroke-width: 9; transform: rotate(-90deg); transform-origin: 30px 30px; animation: pr-draw 0.8s ease-out both; }
@keyframes pr-grow-x { from { transform: scaleX(0); } }
@keyframes pr-draw   { to { stroke-dashoffset: 0; } }
@keyframes pr-fade   { to { opacity: 1; } }

.pr-donut-wrap { display: flex; align-items: center; gap: 14px; }
.pr-donut-wrap svg { width: 64px; height: 64px; flex-shrink: 0; }
.pr-legend { display: grid; gap: 4px; font-size: 11px; color: var(--text-secondary); }
.pr-legend span { display: flex; align-items: center; gap: 6px; }
.pr-legend i { width: 8px; height: 8px; border-radius: 2px; }
.pr-legend b { margin-left: auto; padding-left: 10px; font-weight: 600; color: var(--text-primary); }

.pr-pts { display: grid; gap: 5px; margin: 0 0 10px; font-size: 12px; color: var(--text-secondary); }
.pr-pts li { display: flex; gap: 7px; }
.pr-pts li::before { content: ''; flex-shrink: 0; width: 5px; height: 5px; margin-top: 6px; border-radius: 50%; background: var(--accent); }
.pr-chip-src, .pr-chip-ok {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 500;
  border-radius: 6px;
}
.pr-chip-src { color: var(--text-secondary); background: var(--pr-well); border: 1px solid var(--border); }
.pr-chip-ok  { color: var(--good); background: var(--good-soft); }
.pr-chip-src i, .pr-chip-ok i { font-size: 12px; }

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .pr-bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .pr-bento { grid-template-columns: minmax(0, 1fr); }
  .pr-tile--wide { grid-column: auto; }
  .pr-tile:not(.pr-tile--wide) .pr-copy { order: 2; }
  .pr-ctl--seg { margin-left: 0; }
  /* Pipeline turns vertical on phones */
  .pr-track { flex-direction: column; align-items: stretch; padding: 0; }
  .pr-track::before { top: 18px; bottom: 18px; left: 17px; right: auto; width: 2px; height: auto; background: linear-gradient(180deg, var(--accent-line), var(--accent)); }
  .pr-node { flex-direction: row; gap: 12px; transition: max-height 0.28s ease-out, opacity 0.2s ease-out, margin 0.28s ease-out; max-height: 48px; margin-bottom: 8px; }
  .pr-node-label { text-align: left; }
  .pr-node-label small { display: inline; margin-left: 4px; }
  .pr-node.is-off { max-height: 0; margin-bottom: 0; }
  .pr-msg, .pr-msg--ai { max-width: 92%; width: auto; }
  .pr-msg--ai { width: min(92%, 360px); }
}

@media (max-width: 520px) {
  .pr-chat-id small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pr-msg, .pr-chart .bar, .pr-chart .line, .pr-chart .area, .pr-chart .dip, .pr-chart .seg, .pr-rows li.is-new { animation: none; }
  .pr-chart .line { stroke-dashoffset: 0; }
  .pr-chart .area, .pr-chart .dip { opacity: 1; }
  .pr-chat { overflow-y: auto; }
}
