/*
 * SPS IA, the assistant: the document sheet's drawer (dialog.src-drawer, its
 * slide and its reduced-motion rule) with a conversation inside.
 * Identity: the jade bead, never a generic "AI" glyph; inside the sheet it is
 * alive (the living orb below): its gel turns faster while SPS IA works.
 * Colour keeps its meaning: viridian = act (send, open a page, show me) and
 * "SPS IA is at work"; red = a problem. Motion: transform and opacity only,
 * all of it off with reduced motion.
 */
dialog.ai-panel { width: min(468px, calc(100vw - 1.25rem)); }
/* minmax(0, 1fr): long one-line texts (the status) shorten with an ellipsis instead of widening the sheet. */
.ai { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; height: 100%; }

/* ---------- SPS IA's face: the living jade orb (ui/ia-orb.js, "Living orb" below) ----------
 * The same orb everywhere SPS IA appears: the floating button, the sheet's
 * header, the welcome, the signature of each answer, its settings and the help
 * centre. Its glass rim is see-through, so it sits as well on the dark theme
 * as on the light one. */
.ai-by b { white-space: nowrap; }
.ai-by > b + span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- SPS IA's light: the user's photographs (assets/photos) ----------
 * SPS IA lives in one soft green light: ia-clair (light theme) and ia-sombre
 * (dark theme), CSS backgrounds so only the current theme's file loads. The
 * welcome opens on it as a window the bead floats out of; the help centre
 * card and Settings › SPS IA carry a slice of it on their right edge, fading
 * into the surface so text never sits on the photo. Never behind the
 * conversation, figures or statuses. */
.ai-hero .ai-cover { position: relative; justify-self: stretch; height: 152px; margin-bottom: 52px; border-radius: var(--r-l); isolation: isolate; }
.ai-cover::before, :is(.ia-ask, .ia-intro)::before { content: ""; position: absolute; z-index: -1; border-radius: inherit; background: url("../assets/photos/ia-clair.webp") center 45% / cover no-repeat; }
.ai-cover::before { inset: 0; corner-shape: inherit; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.1); }
html[data-theme="dark"] :is(.ai-cover, .ia-ask, .ia-intro)::before { background-image: url("../assets/photos/ia-sombre.webp"); filter: brightness(0.76) saturate(0.86); }
.ai-cover .ai-orb { position: absolute; left: 20px; bottom: -48px; }
@media (max-width: 640px), (max-height: 760px) { .ai-hero .ai-cover { height: 112px; } }
:is(.ia-ask, .ia-intro)::before { inset: 0 0 0 auto; width: 44%; -webkit-mask-image: linear-gradient(to right, transparent, #000 72%); mask-image: linear-gradient(to right, transparent, #000 72%); }
@media (max-width: 640px) { :is(.ia-ask, .ia-intro)::before { display: none; } }

/* ---------- SPS IA's bead outside the sheet: Settings › SPS IA and the help centre ---------- */
.ia-intro { position: relative; isolation: isolate; display: flex; align-items: center; gap: 1rem; margin: 0 0 0.75rem; padding: 0.9rem 1rem; border-radius: var(--r-m); background: var(--fill-3); box-shadow: inset 0 0 0 1px var(--sep); overflow: hidden; }
.ia-intro .ia-orb { --size: 64px; }
/* A soft shadow under the bead (a box-shadow: a filter over the turning gel would cost a repaint). */
:is(.ia-intro, .ia-ask) .ia-orb-disc { box-shadow: 0 10px 16px -8px rgb(8 64 44 / 0.34); }
.ia-intro p { margin: 0; max-width: 46ch; color: var(--label-2); font-size: var(--t-callout); line-height: 1.5; }
.ia-ask { position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: center; gap: 1rem; width: 100%; margin: 0 0 1.5rem; padding: 0.85rem 1.1rem 0.85rem 0.9rem; border: 0; border-radius: var(--r-l); background: var(--surface); box-shadow: var(--card-shadow); color: var(--label); font: inherit; text-align: left; cursor: pointer; transition: box-shadow var(--m-150) var(--ease), transform 0.5s var(--ease-spring); }
.ia-ask:hover { transform: translateY(-1px); box-shadow: var(--card-shadow), 0 14px 28px -18px rgb(var(--shade, 6 33 41) / 0.38); }
.ia-ask .ia-orb { --size: 56px; transition: transform 0.6s var(--ease-spring); }
.ia-ask:is(:hover, :focus-visible) .ia-orb { transform: translateY(-3px) rotate(-6deg); }
.ia-ask > span:not(.ia-orb) { display: grid; gap: 0.15rem; flex: 1; min-width: 0; max-width: 54ch; margin-right: auto; }
.ia-intro p { margin-right: auto; }
/* The chevron sits on the photo: a small glass disc keeps it legible. */
.ia-ask > .i { box-sizing: content-box; padding: 7px; border-radius: 50%; background: color-mix(in srgb, var(--surface) 82%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.ia-ask b { font-size: var(--t-body); font-weight: 650; }
.ia-ask small { color: var(--label-2); font-size: var(--t-foot); line-height: 1.45; }
.ia-ask > .i { color: var(--accent-text); }
html[data-theme="dark"] :is(.ia-intro, .ia-ask) .ia-orb-disc { box-shadow: 0 10px 18px -6px rgb(0 0 0 / 0.55); }
@media (prefers-reduced-motion: reduce) { .ia-ask, .ia-ask .ia-orb { transition: none; } }
html.reduce-motion :is(.ia-ask, .ia-ask .ia-orb) { transition: none; }

/* ---------- Settings › SPS IA: what it can do, then its settings ---------- */
.ia-can { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr)); gap: 0.5rem; margin: 0 0 1.25rem; padding: 0; list-style: none; }
.ia-can li { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.75rem 0.85rem; border-radius: var(--r-m); background: var(--fill-3); box-shadow: inset 0 0 0 1px var(--sep); }
.ia-can li > .i { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--accent-text); }
.ia-can li span { display: grid; gap: 0.15rem; }
.ia-can b { font-size: var(--t-callout); font-weight: 600; }
.ia-can small { color: var(--label-2); font-size: var(--t-foot); line-height: 1.45; }
.ia-note { display: grid; gap: 0.35rem; margin: 0.75rem 0 0.5rem; }
.settings-sub { margin: 1.5rem 0 0.25rem; font-size: var(--t-foot); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--label-3); }

/* ---------- Voice: the capsule becomes a waveform while SPS IA listens ----------
 * The row (attach, text, send) gives way to the words being said (final words
 * in ink, the ones still being recognised lighter) over a waveform that follows
 * the voice, the time spoken, Cancel and Finish. Finish lands the words in the
 * field to read again before sending: a misheard question costs no answer. */
.ai-mic { flex: none; width: 38px; height: 38px; border-radius: var(--r-l); }
.ai-capsule.is-voice { box-shadow: inset 0 0 0 1.25px var(--accent-text), 0 0 0 4px var(--accent-soft); }
.ai-capsule.is-voice > :is(.ai-row, .ai-files, .ai-pstat) { display: none; }
.ai-voice { display: grid; gap: 0.2rem; animation: ai-voice-in 420ms var(--ease-out) both; }
.ai-voice[hidden] { display: none; }
@keyframes ai-voice-in { from { opacity: 0; transform: translateY(6px) scale(0.985); } }
.ai-voice-text { min-height: 2.9em; max-height: 7.3em; overflow-y: auto; padding: 0.45rem 0.6rem 0.1rem; color: var(--label); font-size: var(--t-callout); line-height: 1.45; overflow-wrap: anywhere; }
.ai-voice-text.is-hint, .ai-voice-part { color: var(--label-3); }
.ai-voice-row { display: flex; align-items: center; gap: 0.55rem; }
.ai-voice-btn { flex: none; width: 38px; height: 38px; border-radius: var(--r-l); }
/* The bars: the newest on the right, the oldest fading out on the left. */
.ai-wave { flex: 1; display: flex; align-items: center; justify-content: space-between; min-width: 0; height: 30px; -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%, #000 88%, transparent); mask-image: linear-gradient(90deg, transparent, #000 22%, #000 88%, transparent); }
.ai-wave i { flex: none; width: 3px; height: 100%; border-radius: 999px; background: var(--accent-text); transform: scaleY(0.08); transition: transform 90ms linear; will-change: transform; }
.ai-wave.is-still i { transform: scaleY(0.3); transition: none; }
.ai-voice-time { flex: none; min-width: 2.4em; color: var(--label-2); font-size: var(--t-foot); font-weight: 560; font-variant-numeric: tabular-nums; text-align: right; }
/* The words land in the field, ready to read again. */
textarea.ai-input.is-landed { animation: ai-land 520ms var(--ease-out); }
@keyframes ai-land { from { opacity: 0.25; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .ai-voice, textarea.ai-input.is-landed { animation: none; } .ai-wave i { transition: none; } }
html.reduce-motion :is(.ai-voice, textarea.ai-input.is-landed) { animation: none; }
html.reduce-motion .ai-wave i { transition: none; }

/* ---------- History: past conversations, to open again or forget ---------- */
.ai-past { padding: 0.25rem 1.25rem 1rem; }
.ai-past h3 { margin: 0.5rem 0 0.75rem; font-size: var(--t-foot); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--label-3); }
.ai-past ul { display: grid; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.ai-past li { display: flex; align-items: center; gap: 0.25rem; animation: ai-rise 420ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 30ms); }
.ai-past-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.75rem; border: 0; border-radius: var(--r-m); background: var(--fill-3); box-shadow: inset 0 0 0 1px var(--sep); color: var(--label); text-align: left; font: inherit; cursor: pointer; transition: background var(--m-150) var(--ease); }
.ai-past-open:hover { background: var(--fill-2); }
.ai-past-open.is-current { box-shadow: inset 0 0 0 1.5px var(--accent-text); }
.ai-past-open > .i { color: var(--label-3); }
.ai-past-open span { display: grid; gap: 0.1rem; min-width: 0; }
.ai-past-open b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--t-callout); font-weight: 600; }
.ai-past-open small { color: var(--label-3); font-size: var(--t-cap); }
.ai-past-empty { margin: 0; color: var(--label-2); font-size: var(--t-callout); line-height: 1.5; }
.ai-head [aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }
@media (prefers-reduced-motion: reduce) { .ai-past li { animation: none; } }

/* ---------- Sky orb: SPS IA floats bottom right of every page ----------
 * SPS IA's living orb (jade gel turning in a glass bead, "Living orb" below).
 * The bead drifts up and down as if it hung in the air (its shadow breathes
 * with it) while its gel turns slowly and the light on the glass slides.
 * Transforms only, slow cycles (6 to 33 s): no repaint, almost no CPU. Pointed at or focused, the bead
 * quivers like jelly once (frame.css pace) and lights a little; pressed, it
 * gives. Still under reduced motion. Built once by ui/sky-orb.js. */
.sky-orb {
  --o: 60px;
  position: fixed; z-index: 90; right: max(1.5rem, calc(env(safe-area-inset-right) + 1rem)); bottom: max(1.5rem, calc(env(safe-area-inset-bottom) + 1rem));
  width: var(--o); height: var(--o); padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sky-orb:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 5px; }
:where(.sky-orb-float, .sky-orb-bead, .sky-orb-bead > span) { position: absolute; inset: 0; border-radius: 50%; }
.sky-orb-float { animation: sky-float 6.4s ease-in-out infinite; transition: scale 0.25s var(--ease-out); }
.sky-orb:active .sky-orb-float { scale: 0.93; }
.sky-orb-shadow { position: absolute; left: 16%; right: 16%; bottom: -15px; height: 11px; border-radius: 50%; background: radial-gradient(closest-side, rgb(6 46 33 / 0.3), transparent); animation: sky-shadow 6.4s ease-in-out infinite; }
/* The living orb fills the bead. */
.sky-orb-bead { box-shadow: 0 14px 24px -14px rgb(8 64 44 / 0.6); }
.sky-orb .ia-orb { --size: 100%; }
.sky-orb-bead::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 50% 40%, rgb(214 255 236 / 0.45), transparent 62%); opacity: 0; transition: opacity 0.45s var(--ease-out); }
.sky-orb:is(:hover, :focus-visible) .sky-orb-bead::after { opacity: 1; }
html[data-theme="dark"] .sky-orb-bead { box-shadow: 0 14px 26px -12px rgb(0 0 0 / 0.85); }
/* Pointed at: one jelly quiver, played to its end (gel.js). */
.sky-orb .sky-orb-bead.i-mark.is-acting { animation: sky-jelly var(--ic-move-2, 720ms) var(--ic-ease, ease-out); }
html[data-theme="dark"] .sky-orb-shadow { background: radial-gradient(closest-side, rgb(0 0 0 / 0.55), transparent); }
@keyframes sky-float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes sky-shadow { 0%, 100% { transform: scaleX(1); opacity: 1; } 50% { transform: scaleX(0.76); opacity: 0.55; } }
@keyframes sky-jelly { 18% { transform: scale(1.13, 0.89); } 38% { transform: scale(0.93, 1.08); } 58% { transform: scale(1.04, 0.97); } 78% { transform: scale(0.99, 1.01); } }
@media (prefers-reduced-motion: reduce) { .sky-orb, .sky-orb * { animation: none !important; transition: none !important; } }
html.reduce-motion :is(.sky-orb, .sky-orb *) { animation: none !important; transition: none !important; }
@media print { .sky-orb { display: none !important; } }
/* ---------- Pour: the SPS IA sheet comes out of the orb ----------
 * A circle of gel opens from the bead (--ox, --oy, set by sky-orb.js) to the
 * farthest corner (--of); a jade wave runs ahead of the edge and clears to
 * glass; the conversation then settles in. Closing draws the sheet back into
 * the bead. The orb rests (fades) while the sheet is open. */
.sky-orb { transition: opacity 0.35s var(--ease-out); }
.sky-orb.is-poured { opacity: 0; pointer-events: none; }
dialog.ai-panel.is-pouring[open]:not(.is-closing) { animation: ai-pour 700ms cubic-bezier(0.22, 1, 0.36, 1); }
dialog.ai-panel.is-pouring.is-closing { animation: ai-unpour 150ms cubic-bezier(0.7, 0, 0.84, 0) forwards; }
dialog.ai-panel.is-pouring::after {
  content: ""; position: absolute; z-index: 5; pointer-events: none; border-radius: 50%; opacity: 0;
  left: calc(var(--ox) - var(--of)); top: calc(var(--oy) - var(--of)); width: calc(var(--of) * 2); height: calc(var(--of) * 2);
  background: radial-gradient(circle, rgb(196 232 210 / 0.3), rgb(116 178 141 / 0.16) 50%, rgb(116 178 141 / 0.3) 62%, rgb(214 245 228 / 0.7) 68%, rgb(116 178 141 / 0) 71%);
  animation: ai-wave 820ms cubic-bezier(0.22, 1, 0.36, 1);
}
dialog.ai-panel.is-pouring[open]:not(.is-closing) .ai { animation: ai-settle 640ms var(--ease-out) 140ms backwards; }
@keyframes ai-pour { from { clip-path: circle(26px at var(--ox) var(--oy)); } to { clip-path: circle(var(--of) at var(--ox) var(--oy)); } }
@keyframes ai-unpour { to { clip-path: circle(26px at var(--ox) var(--oy)); opacity: 0.4; } }
@keyframes ai-wave { from { transform: scale(0.04); opacity: 1; } 75% { opacity: 0.85; } to { transform: scale(1); opacity: 0; } }
@keyframes ai-settle { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) { dialog.ai-panel.is-pouring, dialog.ai-panel.is-pouring::after, dialog.ai-panel.is-pouring .ai { animation: none !important; } }
/* The last lines of a page stay clear of the orb. */
.has-sky-orb .page { padding-bottom: calc(4rem + 56px); }
@media (max-width: 560px) { .sky-orb { --o: 54px; } }

/* ---------- Living orb: SPS IA's face inside the sheet (ui/ia-orb.js) ----------
 * Rebuilt from SmoothUI's "Siri Orb" (MIT, (c) 2024 Eduardo Calvo; notice in
 * THIRD-PARTY-NOTICES.md), in our jades. Seven conic layers of gel, each turning
 * about its own point at its own pace (20 s / 0.6 / k at rest, k = 2, 1, 2, 1.5, 3, 2, 2),
 * blurred and pushed in contrast; a light drifts on the glass, a lit rim on top,
 * a shaded one below. The original's dotted grain is left out: over jade it turns
 * the gel neon, and the bead is smooth glass. Every move is a transform (compositor only); the state
 * changes pace by playback rate (ia-orb.js), size, colour and glow here.
 * Rest breathes; thinking turns 2.4 times faster; listening swells with the voice;
 * done swells once; error loses its colour and shakes once. Glow only means a
 * state, never at rest. Still under reduced motion. */
/* The jades of SPS IA's first bead (the reference photo): soft, never neon; the contrast and saturation passes below lift them. */
.ia-orb {
  --bg: oklch(94% 0.02 160);   /* the glass */
  --c1: oklch(66% 0.09 158);   /* jade */
  --c2: oklch(74% 0.07 175);   /* sea jade, also the glow */
  --c3: oklch(46% 0.07 160);   /* deep jade */
  --c4: oklch(86% 0.07 140);   /* light through the jade */
  --s: 0.94; --glow: 0; --sat: 0.75; --hue: 0deg; --r: 0;
  position: relative; display: block; flex: none; width: var(--size); height: var(--size);
}
html[data-theme="dark"] .ia-orb { --bg: oklch(84% 0.05 165); }
.ia-orb-sm { --size: 22px; --blur: 1px; --con: 1.1; --shadow: 0.5px; --rim: 1.5px; }
.ia-orb-md { --size: 34px; --blur: 1px; --con: 1.44; --shadow: 0.5px; --rim: 2px; }
.ia-orb-bead { --size: 56px; --blur: 4px; --con: 1.5; --shadow: 2px; --rim: 3.5px; } /* 54 to 64 px, set by its place */
.ia-orb-lg { --size: 104px; --blur: 4px; --con: 1.5; --shadow: 2px; --rim: 6.24px; }
.ia-orb[data-state="listening"] { --s: 1.06; --glow: 0.6; --sat: 1.05; --r: 1; }
.ia-orb[data-state="thinking"] { --s: 1; --glow: 0.35; --sat: 1; --hue: 18deg; --r: 0.15; }
.ia-orb[data-state="streaming"] { --s: 1.02; --glow: 0.45; --sat: 1; --hue: -10deg; --r: 0.6; }
.ia-orb[data-state="done"] { --s: 1.1; --glow: 0.7; --sat: 1; }
.ia-orb[data-state="error"] { --s: 0.96; --sat: 0.3; }
.ia-orb-bloom { position: absolute; inset: -30%; border-radius: 50%; background: radial-gradient(closest-side, var(--c2), transparent); opacity: calc(var(--glow) * 0.7); transition: opacity 250ms var(--ease-out); pointer-events: none; }
.ia-orb-body { position: absolute; inset: 0; scale: calc(var(--s) + var(--amp, 0) * var(--r) * 0.12); transition: scale 250ms var(--ease-out); }
.ia-orb[data-state="idle"] .ia-orb-body { animation: ia-orb-breathe 5.5s cubic-bezier(0.645, 0.045, 0.355, 1) infinite; }
.ia-orb[data-state="error"] .ia-orb-body { animation: ia-orb-fault 180ms cubic-bezier(0.645, 0.045, 0.355, 1); }
.ia-orb-disc { position: absolute; inset: 0; overflow: hidden; border-radius: 50%; isolation: isolate; }
.ia-orb-disc > * { position: absolute; inset: 0; border-radius: 50%; }
/* A jade ground under the layers, so the page never shows through the gel. */
.ia-orb-mesh { overflow: hidden; background: var(--c1); filter: blur(var(--blur)) contrast(var(--con)) saturate(1.4) saturate(var(--sat)) hue-rotate(var(--hue)); transition: filter 250ms var(--ease-out); }
.ia-orb-mesh::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 var(--shadow) calc(var(--shadow) * 0.2) var(--bg); }
/* Each layer is three orbs wide, centred on its point, so it covers the bead whatever its angle. */
.ia-orb-mesh > span { position: absolute; width: 300%; height: 300%; left: calc(var(--x) - 150%); top: calc(var(--y) - 150%); background: conic-gradient(var(--k), transparent var(--a) var(--b), var(--k)); animation: ia-orb-turn var(--t) linear infinite; }
.ia-orb-mesh > span:nth-child(1) { --x: 85%; --y: 10%; --k: var(--c3); --a: 20%; --b: 80%; --t: 16.667s; animation-direction: reverse; }
.ia-orb-mesh > span:nth-child(2) { --x: 20%; --y: 80%; --k: var(--c1); --a: 10%; --b: 90%; --t: 33.333s; }
.ia-orb-mesh > span:nth-child(3) { --x: 15%; --y: 5%; --k: var(--c2); --a: 10%; --b: 90%; --t: 16.667s; }
.ia-orb-mesh > span:nth-child(4) { --x: 60%; --y: 35%; --k: var(--c4); --a: 25%; --b: 75%; --t: 22.222s; }
.ia-orb-mesh > span:nth-child(5) { --x: 80%; --y: 20%; --k: var(--c1); --a: 40%; --b: 60%; --t: 11.111s; animation-direction: reverse; }
.ia-orb-mesh > span:nth-child(6) { --x: 45%; --y: 75%; --k: var(--c2); --a: 30%; --b: 60%; --t: 16.667s; }
.ia-orb-mesh > span:nth-child(7) { --x: 25%; --y: 70%; --k: var(--c3); --a: 20%; --b: 80%; --t: 16.667s; }
.ia-orb-sheen { background: radial-gradient(circle at 30% 24%, rgb(255 255 255 / 0.32), transparent 34%), radial-gradient(circle at 72% 80%, rgb(255 255 255 / 0.07), transparent 48%); mix-blend-mode: screen; animation: ia-orb-drift 15s ease-in-out infinite alternate; }
.ia-orb-rim { pointer-events: none; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.16), inset 0 var(--rim) calc(var(--rim) * 2) rgb(255 255 255 / 0.22), inset 0 calc(var(--rim) * -1.2) calc(var(--rim) * 2.4) rgb(4 38 28 / 0.4); }
/* A signed past answer keeps one still frame. */
.ia-orb.is-still :is(.ia-orb-body, .ia-orb-mesh > span, .ia-orb-sheen) { animation: none; }
@keyframes ia-orb-turn { to { transform: rotate(1turn); } }
@keyframes ia-orb-drift { from { transform: translate(-6%, -4%) scale(1.05); } to { transform: translate(7%, 6%) scale(1.12); } }
@keyframes ia-orb-breathe { 50% { transform: scale(1.035); } }
@keyframes ia-orb-fault { 33% { transform: translateX(-3px); } 66% { transform: translateX(3px); } }
@keyframes ai-orbit { to { transform: rotate(360deg); } }
/* Where it sits: the header, and the welcome where it floats out of SPS IA's light. */
.ai-orb { position: relative; display: grid; place-items: center; flex: none; width: 38px; height: 38px; }
.ai-hero .ai-orb { width: 104px; height: 104px; animation: sky-float 6.4s ease-in-out infinite; }
.ai-hero .ia-orb-disc { box-shadow: 0 16px 28px -12px rgb(8 64 44 / 0.42); }
html[data-theme="dark"] .ai-hero .ia-orb-disc { box-shadow: 0 16px 30px -10px rgb(0 0 0 / 0.6); }
@media (prefers-reduced-motion: reduce) { .ia-orb *, .ai-hero .ai-orb { animation: none !important; transition: none !important; } }
html.reduce-motion :is(.ia-orb *, .ai-hero .ai-orb) { animation: none !important; transition: none !important; }

.ai-head > div { min-width: 0; }
/* The state in one word and a dot: green ready, viridian at work (writing, listening). */
.ai-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color 200ms var(--ease-out); }
.ai-status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 0.4rem; border-radius: 50%; background: var(--good); vertical-align: 0.04em; }
.ai-status:is([data-state="busy"], [data-state="listening"]) { color: var(--accent-text); }
.ai-status:is([data-state="busy"], [data-state="listening"])::before { background: var(--accent-text); animation: ai-dot 1.2s ease-in-out infinite; }
@keyframes ai-dot { 50% { opacity: 0.35; transform: scale(0.75); } }

/* ---------- Conversation ---------- */
.ai-log { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; padding: 1.15rem 1.25rem 1.4rem; scroll-behavior: smooth; }
/* One exchange after another: the question on the right, the answer in its own column under SPS IA's
 * name, its actions always in the same place. A new question opens a new exchange (more air above). */
.ai-items, .ai-live { display: flex; flex-direction: column; gap: 0.9rem; }
.ai-items:not(:empty) + .ai-live:not(:empty) { margin-top: 0.9rem; }
.ai-msg { max-width: 88%; color: var(--label); font-size: var(--t-callout); line-height: 1.6; overflow-wrap: anywhere; }
.ai-msg.is-new { animation: ai-rise 380ms var(--ease-out) both; }
@keyframes ai-rise { from { opacity: 0; transform: translateY(8px); } }
.ai-msg.is-user { align-self: flex-end; padding: 0.55rem 0.9rem; border-radius: var(--r-l) var(--r-l) var(--r-xs) var(--r-l); background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--sep); white-space: pre-wrap; }
.ai-msg.is-bot + .ai-msg.is-user { margin-top: 0.85rem; }
.ai-msg.is-bot { position: relative; align-self: stretch; max-width: none; }
.ai-by { display: flex; align-items: center; gap: 0.5rem; min-width: 0; margin-bottom: 0.3rem; color: var(--label-3); font-size: var(--t-cap); }
.ai-by b { flex: none; color: var(--label); font-size: var(--t-foot); font-weight: 650; letter-spacing: 0.01em; }
.ai-by > b + span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-by > b + span::before { content: "· "; }
.ai-body { padding-left: calc(22px + 0.5rem); } /* under the name, not under the bead */
.ai-acts { display: flex; flex-wrap: wrap; gap: 0.15rem; margin: 0.55rem 0 0 -0.5rem; }
.ai-act { display: inline-flex; align-items: center; gap: 0.3rem; height: 28px; padding: 0 0.55rem; border: 0; border-radius: var(--r-s); background: none; color: var(--label-3); font: inherit; font-size: var(--t-cap); font-weight: 580; cursor: pointer; transition: background 160ms var(--ease-out), color 160ms var(--ease-out); }
.ai-act .i { width: 14px; height: 14px; }
.ai-act:hover { background: var(--fill-2); color: var(--label); }
.ai-act.is-done { color: var(--accent-text); }
/* Taking back the last exchange: "Régénérer" under the last answer, the pen beside the last question,
 * never while SPS IA is writing (markLast, assistant-panel.js). Follow-ups stay under the last answer. */
.ai-regen, .ai-edit { display: none; }
.ai-msg.is-bot.is-last .ai-regen { display: inline-flex; }
.ai-items > .ai-msg.is-bot:not(:last-child) .ai-next, .ai-log[aria-busy="true"] .ai-next { display: none; }
.ai-msg.is-user { position: relative; }
.ai-msg.is-user.is-last .ai-edit {
  position: absolute; top: 50%; right: calc(100% + 0.35rem); display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--label-3); cursor: pointer; opacity: 0; translate: 4px -50%; transition: opacity 160ms var(--ease-out), translate 160ms var(--ease-out), background 160ms var(--ease-out), color 160ms var(--ease-out);
}
.ai-msg.is-user.is-last .ai-edit .i { width: 16px; height: 16px; }
.ai-msg.is-user.is-last:hover .ai-edit, .ai-msg.is-user.is-last .ai-edit:focus-visible { opacity: 1; translate: 0 -50%; }
.ai-msg.is-user.is-last .ai-edit:hover { background: var(--fill-2); color: var(--label); }
.ai-msg.is-user.is-last .ai-edit:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
@media (hover: none) { .ai-msg.is-user.is-last .ai-edit { opacity: 1; translate: 0 -50%; } }
.ai-act.is-on { color: var(--accent-text); background: var(--accent-soft); }
.ai-act:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.ai-by-mark { width: 14px; height: 14px; flex: none; color: var(--accent-text); }
.ai-answer > :first-child { margin-top: 0; }
.ai-answer p + p, .ai-answer p + ul, .ai-answer p + ol, .ai-answer ul + p, .ai-answer ol + p, .ai-answer .ai-table + p { margin-top: 0.6rem; }
.ai-answer ul, .ai-answer ol, .ai-guide ol { display: grid; gap: 0.35rem; margin: 0.4rem 0 0; padding-left: 1.2rem; }
.ai-answer ul { list-style: disc; }
.ai-answer ol, .ai-guide ol { list-style: decimal; }
.ai-answer li::marker, .ai-guide li::marker { color: var(--label-3); font-weight: 600; }
.ai-answer b { font-weight: 620; }
.ai-answer .ai-h { margin: 0.95rem 0 0.3rem; color: var(--label); font-size: var(--t-body); font-weight: 640; letter-spacing: -0.005em; }
.ai-cut { margin-top: 0.4rem; color: var(--label-3); font-size: var(--t-foot); }
/* The answer being written: a soft viridian caret after the last line. */
.ai-answer.is-writing > :last-child::after { content: ""; display: inline-block; width: 7px; height: 1em; margin-left: 3px; border-radius: 2px; background: var(--accent-text); vertical-align: -0.15em; animation: ai-caret 1s steps(2, jump-none) infinite; }
@keyframes ai-caret { 50% { opacity: 0; } }

/* ---------- Streaming reply (ia-motion.js, after the "Streaming reply" study) ----------
 * Until the first words, a pill says what SPS IA is doing (a light passes over its
 * label; its width follows the label on a spring). Then the words rise one after
 * another, each on its own spring (a CSS animation whose easing is that spring),
 * while the answer's height follows the newest line and the pill fades out. Words
 * waiting their turn hold their place, unseen. Transform and opacity only. */
.ai-stream { position: relative; min-height: 28px; }
.ai-think { position: absolute; z-index: 1; left: 0; top: 0; display: inline-flex; align-items: center; height: 28px; padding: 0 0.75rem; overflow: hidden; border-radius: 999px; background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--sep); font-size: var(--t-foot); font-weight: 560; white-space: nowrap; pointer-events: none; }
.ai-think.is-gone { visibility: hidden; }
.ai-think.is-gone .ia-shine-light { display: none; } /* faded out: the light stops passing */
.ai-answer.is-growing { overflow: hidden; }
span.ai-wd { display: inline-block; }
.ai-wd.is-wait { opacity: 0; }
.ai-wd.is-in { animation: ai-word var(--wd-dur, 540ms) var(--wd-ease, ease-out) backwards; }
@keyframes ai-word { from { opacity: 0; transform: translateY(6px); } }
.ai-spin { display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent-text); animation: ai-orbit 0.8s linear infinite; }

/* A page the answer points to: a small viridian pill, opened in one click. */
.ai-link { display: inline-flex; align-items: center; gap: 0.15rem; padding: 0.05rem 0.35rem 0.05rem 0.55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-weight: 580; text-decoration: none; white-space: nowrap; transition: box-shadow 160ms var(--ease-out); }
.ai-link .i { width: 14px; height: 14px; transition: transform 200ms var(--ease-out); }
.ai-link:hover { box-shadow: inset 0 0 0 1px var(--accent-text); }
.ai-link:hover .i { transform: translateX(2px); }

/* Figures side by side: the platform's table look, numbers on the right. */
.ai-table { margin-top: 0.6rem; overflow-x: auto; border-radius: var(--r-m); box-shadow: inset 0 0 0 1px var(--sep); }
.ai-table table { width: 100%; border-collapse: collapse; font-size: var(--t-foot); font-variant-numeric: tabular-nums; }
.ai-table th, .ai-table td { padding: 0.45rem 0.55rem; text-align: left; vertical-align: top; }
.ai-table td:first-child { min-width: 7rem; }
.ai-table .is-num, .ai-table th { white-space: nowrap; }
.ai-table th { background: var(--fill-2); color: var(--label-2); font-weight: 600; }
.ai-table tbody td { border-top: 1px solid var(--sep); }
.ai-table .is-num { text-align: right; }

/* Follow-up questions under an answer, one under the other, introduced by a hairline. */
.ai-next { display: grid; justify-items: start; gap: 0.35rem; margin-top: 0.85rem; padding-top: 0.75rem; border-top: 1px solid var(--sep); }
.ai-next .ai-chip { max-width: 100%; }
.ai-next .ai-chip .i { width: 12px; height: 12px; transition: transform 200ms var(--ease-out); }
.ai-next .ai-chip:hover .i { transform: translateX(2px); }

/* "Me montrer": the guided walk SPS IA prepared, started in one click. */
.ai-guide { display: grid; gap: 0.6rem; margin-top: 0.85rem; padding: 0.85rem 0.95rem 0.95rem; border-radius: var(--r-l); background: var(--surface); box-shadow: inset 0 0 0 1px var(--sep), 0 14px 28px -24px rgba(6, 33, 41, 0.55); }
.ai-guide-title { display: flex; align-items: center; gap: 0.45rem; }
.ai-guide-title .i { color: var(--accent-text); }
.ai-guide-title small { margin-left: auto; color: var(--label-3); font-size: var(--t-cap); }
.ai-guide ol { margin: 0; font-size: var(--t-foot); color: var(--label-2); }
.ai-guide li { padding-left: 0.1rem; }
.ai-guide-page { margin-right: 0.35rem; color: var(--label); font-weight: 600; }
.ai-guide-page + b::before { content: "› "; color: var(--label-3); font-weight: 400; }
.ai-guide li small { display: block; margin-top: 0.1rem; color: var(--label-3); font-size: var(--t-cap); line-height: 1.4; }
.ai-guide .btn { justify-self: start; }
.ai-guide .btn .i { width: 14px; height: 14px; }

/* SPS IA prepares, the person applies: each change before → after, the effect on the bilan, then « Appliquer ». */
.ai-prop { display: grid; gap: 0.65rem; margin-top: 0.85rem; padding: 0.85rem 0.95rem 0.9rem; border-radius: var(--r-l); background: var(--surface); box-shadow: inset 0 0 0 1px var(--sep), 0 14px 28px -24px rgba(6, 33, 41, 0.55); }
.ai-prop-rows { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; font-size: var(--t-foot); color: var(--label-2); }
.ai-prop-rows li { display: grid; gap: 0.15rem; padding-top: 0.5rem; border-top: 1px solid var(--sep); }
.ai-prop-rows li:first-child { padding-top: 0; border-top: 0; }
.ai-prop-rows .ai-guide-page { margin: 0; font-size: var(--t-cap); color: var(--label-3); font-weight: 580; }
.ai-prop-what { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.2rem 0.75rem; color: var(--label); font-weight: 600; }
.ai-prop-diff { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.ai-prop-diff span { color: var(--label-3); }
.ai-prop-diff .i { width: 12px; height: 12px; color: var(--label-3); }
.ai-prop-diff b { color: var(--label); font-weight: 650; }
.ai-prop-quote { color: var(--label); }
.ai-prop .ai-guide-title { align-items: flex-start; }
.ai-prop .ai-guide-title small { flex: none; padding-top: 0.15rem; white-space: nowrap; }
.ai-prop-rows small { color: var(--label-3); font-size: var(--t-cap); line-height: 1.4; }
.ai-prop-effect { margin: 0; padding: 0.5rem 0.65rem; border-radius: var(--r-s); background: var(--fill-3); color: var(--label-2); font-size: var(--t-cap); line-height: 1.45; font-variant-numeric: tabular-nums; }
.ai-prop-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.ai-prop-acts .btn .i, .ai-prop-state .i { width: 14px; height: 14px; }
.ai-prop-state { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--label-2); font-size: var(--t-foot); font-weight: 580; }
.ai-prop-state.is-good { color: var(--good); }
.ai-prop-state.is-warn { color: var(--orange); }
.ai-prop:is(.is-applied, .is-dismissed, .is-stale) .ai-prop-rows { opacity: 0.72; }

.ai-msg.is-error { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem; padding: 0.6rem 0.75rem; border-radius: var(--r-s); background: var(--red-soft); color: var(--red); font-size: var(--t-foot); font-weight: 560; }
.ai-msg.is-error > .i { flex: none; margin-top: 0.1rem; }
.ai-msg.is-error > span { flex: 1; min-width: 12rem; }

/* ---------- Welcome ---------- */
.ai-hello { display: grid; gap: 0.75rem; margin-top: auto; color: var(--label-2); font-size: var(--t-callout); }
.ai-hello > *, .ai-cards > *, .ai-suggest > * { animation: ai-rise 520ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 55ms + 80ms); }
.ai-hero { display: grid; justify-items: start; gap: 0.5rem; margin-bottom: 0.35rem; }
.ai-hero .ai-orb { margin-bottom: 0.4rem; }
.ai-hello-title { color: var(--label); font-size: 1.45rem; font-weight: 660; letter-spacing: -0.02em; line-height: 1.15; }
.ai-hello-lead { max-width: 38ch; line-height: 1.55; }
.ai-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.ai-card { display: grid; align-content: start; gap: 0.2rem; padding: 0.75rem 0.7rem 0.8rem; border: 0; border-radius: var(--r-l); background: var(--surface); box-shadow: inset 0 0 0 1px var(--sep); color: var(--label); font: inherit; text-align: left; cursor: pointer; transition: transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out); }
.ai-card .i { width: 18px; height: 18px; margin-bottom: 0.35rem; color: var(--accent-text); transition: transform 300ms var(--ease-out); }
.ai-card b { font-size: var(--t-callout); font-weight: 620; }
.ai-card small { color: var(--label-3); font-size: var(--t-cap); line-height: 1.35; }
.ai-card:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px var(--sep-2), 0 16px 30px -22px rgba(6, 33, 41, 0.6); }
.ai-card:hover .i { transform: scale(1.1); }
.ai-sub { margin-top: 0.4rem; color: var(--label-3); font-size: var(--t-cap); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ai-chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.45rem 0.8rem; border: 0; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--sep); color: var(--label); font: inherit; font-size: var(--t-foot); font-weight: 540; text-align: left; cursor: pointer; transition: box-shadow 160ms var(--ease-out), transform 160ms var(--ease-out); }
.ai-chip:hover { box-shadow: inset 0 0 0 1px var(--sep-2); transform: translateY(-1px); }
.ai-chip .i { width: 14px; height: 14px; color: var(--accent-text); }

/* ---------- Question field: one capsule (attach, text, send) ---------- */
.ai-compose { position: relative; padding: 0.7rem 0.9rem 0.45rem; border-top: 1px solid var(--sep); }
/* Back to the latest message, floating over the end of the conversation when the person scrolled up. */
.ai-jump {
  position: absolute; z-index: 2; left: 50%; bottom: calc(100% + 0.7rem); display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: var(--surface); color: var(--label-2); cursor: pointer; translate: -50% 0;
  box-shadow: inset 0 0 0 1px var(--sep-2), 0 10px 22px -12px rgb(var(--shade) / 0.55);
  animation: ai-jump-in 320ms var(--ease-out) both; transition: color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.ai-jump[hidden] { display: none; }
.ai-jump .i { width: 16px; height: 16px; }
.ai-jump:hover { color: var(--label); box-shadow: inset 0 0 0 1px var(--sep-3), 0 12px 24px -12px rgb(var(--shade) / 0.6); }
.ai-jump:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
@keyframes ai-jump-in { from { opacity: 0; transform: translateY(6px) scale(0.9); } }
@media (prefers-reduced-motion: reduce) { .ai-jump { animation: none; } .ai-msg.is-user.is-last .ai-edit { transition: none; } }
.ai-capsule { display: grid; padding: 0.35rem; border-radius: var(--r-xl); background: var(--surface); box-shadow: inset 0 0 0 1px var(--sep-2); transition: box-shadow 200ms var(--ease-out); }
.ai-capsule:focus-within { box-shadow: inset 0 0 0 1.25px var(--accent-text), 0 0 0 4px var(--accent-soft); }
.ai-row { display: flex; align-items: flex-end; gap: 0.3rem; }
.ai-attach { flex: none; width: 38px; height: 38px; border-radius: var(--r-l); }
textarea.ai-input { flex: 1; min-height: 38px; max-height: 152px; padding: 0.55rem 0.3rem; border: 0; border-radius: 0; background: none; box-shadow: none; resize: none; line-height: 1.45; }
textarea.ai-input:focus { box-shadow: none; outline: none; }
.ai-send { position: relative; flex: none; width: 38px; height: 38px; padding: 0; border-radius: var(--r-l); transition: transform 200ms var(--ease-out), background 200ms var(--ease-out), box-shadow 200ms var(--ease-out); }
.ai-send:active { transform: scale(0.92); }
.ai-files { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.15rem 0.15rem 0; margin-bottom: 0.45rem; }
.ai-files[hidden] { display: none; }

/* ---------- Prompt box (ia-motion.js, after the "Prompt box" study) ----------
 * Send is calm until there is something to send, viridian then (act). While
 * SPS IA answers, the arrow turns away and shrinks as a stop square grows in its
 * place (one spring, the glyphs never replaced). A status line opens above the
 * text: "Réponse en cours" with a light passing over it and a breathing viridian
 * dot, then "Réponse prête" (green: good) or "Réponse arrêtée" for a moment
 * before it folds away. The field's height follows its text on a spring
 * (assistant-panel.js). The header's status says it aloud; this line is for the eyes. */
.ai-send > span { position: absolute; inset: 0; display: grid; place-items: center; }
.ai-send-stop { transform: scale(0); }
.ai-send-stop .i .t { fill-opacity: 0.9; } /* a stop reads as a solid square */
.ai-send.is-calm, .ai-send.is-calm:hover { background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--sep); color: var(--label-3); }
.ai-send.is-calm .i { color: var(--label-3); }
.ai-pstat { display: flex; align-items: center; gap: 0.45rem; height: 0; padding: 0 0.6rem; overflow: hidden; opacity: 0; color: var(--label-2); font-size: var(--t-foot); font-weight: 560; }
.ai-pstat-mark { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--label-3); transition: background 250ms var(--ease-out); }
.ai-pstat[data-kind="think"] .ai-pstat-mark { background: var(--accent-text); animation: ai-dot 1s ease-in-out infinite; }
.ai-pstat[data-kind="done"] .ai-pstat-mark { background: var(--good); }
.ai-pstat:not([data-kind="think"]) .ia-shine-light { display: none; }
.ai-pstat:not([data-kind="think"]) .ia-shine-text { color: var(--label-2); }

/* A label with a light passing over its letters (the pill and the status line): a window masked by a
 * gradient slides across while its copy of the text slides back, so only transforms move. */
.ia-shine { position: relative; display: inline-block; overflow: hidden; vertical-align: top; white-space: nowrap; }
.ia-shine-text { color: var(--label-3); }
.ia-shine-light { position: absolute; inset: 0; -webkit-mask-image: linear-gradient(90deg, transparent, #000 50%, transparent); mask-image: linear-gradient(90deg, transparent, #000 50%, transparent); animation: ia-shine 1.4s linear infinite; }
.ia-shine-light > span { display: block; color: var(--label); animation: ia-shine-back 1.4s linear infinite; }
@keyframes ia-shine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes ia-shine-back { from { transform: translateX(100%); } to { transform: translateX(-100%); } }
/* The fine print in one line; the rest opens on demand. */
.ai-note { padding: 0 1rem 0.6rem; color: var(--label-3); font-size: var(--t-cap); line-height: 1.4; }
.ai-note summary { display: flex; align-items: center; justify-content: center; gap: 0.35rem; min-height: 26px; list-style: none; cursor: pointer; border-radius: var(--r-xs); }
.ai-note summary::-webkit-details-marker { display: none; }
.ai-note summary:hover { color: var(--label-2); }
.ai-note summary:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.ai-note summary .i { flex: none; width: 12px; height: 12px; }
.ai-note summary .i:last-child { transform: rotate(90deg); transition: transform 240ms var(--ease-out); }
.ai-note[open] summary .i:last-child { transform: rotate(-90deg); }
.ai-note p { margin: 0.2rem 0.25rem 0; text-align: center; animation: ai-rise 260ms var(--ease-out) both; }

/* Attached files: chips in the capsule, and in the question once sent. */
.ai-file { display: inline-flex; align-items: center; gap: 0.5rem; max-width: 100%; padding: 0.35rem 0.35rem 0.35rem 0.6rem; border-radius: var(--r-m); background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--sep); color: var(--label); font-size: var(--t-foot); white-space: normal; animation: ai-rise 260ms var(--ease-out) both; }
.ai-file > .i { flex: none; color: var(--accent-text); }
.ai-file > span { display: grid; min-width: 0; }
.ai-file b { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.ai-file small { color: var(--label-3); font-size: var(--t-cap); }
.ai-file .btn-icon { width: 26px; height: 26px; }
.ai-file.is-reading { gap: 0.5rem; padding-right: 0.7rem; color: var(--label-3); }
.ai-msg-files { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; }

/* Files dragged over the sheet. */
.ai-drop { position: absolute; inset: 0.6rem; z-index: 2; display: grid; place-content: center; justify-items: center; gap: 0.35rem; border-radius: var(--r-l); background: color-mix(in oklab, var(--surface-raised) 90%, transparent); box-shadow: inset 0 0 0 2px var(--accent-text); color: var(--label-2); font-size: var(--t-foot); opacity: 0; pointer-events: none; transition: opacity 160ms var(--ease-out); }
.ai-drop .i { width: 26px; height: 26px; color: var(--accent-text); transform: translateY(4px); transition: transform 260ms var(--ease-out); }
.ai-drop b { color: var(--label); font-size: var(--t-callout); }
.ai.is-over .ai-drop { opacity: 1; }
.ai.is-over .ai-drop .i { transform: none; }

/* ---------- Narrow sheets (phones) ---------- */
@media (max-width: 420px) {
  .ai-cards { grid-template-columns: 1fr; }
  .ai-card { grid-template-columns: auto 1fr; column-gap: 0.6rem; align-items: center; }
  .ai-card .i { grid-row: span 2; margin: 0; }
}

/* ---------- Reduced motion: everything still, nothing lost ---------- */
@media (prefers-reduced-motion: reduce) {
  .ai-msg.is-new, .ai-file, .ai-hello > *, .ai-cards > *, .ai-suggest > *, .ai-spin, .ai-answer.is-writing > :last-child::after, .ai-status::before, .ai-note p, .ai-pstat-mark, .ai-wd { animation: none !important; }
  .ia-shine-light { display: none; }
  .ai-link, .ai-link .i, .ai-chip, .ai-chip .i, .ai-card, .ai-card .i, .ai-act, .ai-note summary .i, .ai-drop, .ai-drop .i, .ai-send, .ai-capsule { transition: none; }
  .ai-log { scroll-behavior: auto; }
}
html.reduce-motion :is(.ai-msg.is-new, .ai-file, .ai-hello > *, .ai-cards > *, .ai-suggest > *, .ai-spin, .ai-answer.is-writing > :last-child::after, .ai-status::before, .ai-note p, .ai-pstat-mark, .ai-wd) { animation: none !important; }
html.reduce-motion .ia-shine-light { display: none; }
html.reduce-motion :is(.ai-link, .ai-link .i, .ai-chip, .ai-chip .i, .ai-card, .ai-card .i, .ai-act, .ai-note summary .i, .ai-drop, .ai-drop .i, .ai-send, .ai-capsule) { transition: none; }
html.reduce-motion .ai-log { scroll-behavior: auto; }

/* Under a finger: links keep their place in the sentence at full touch height; nothing waits for a hover. */
@media (pointer: coarse) {
  .ai-link { min-height: var(--touch); margin-block: 0.15rem; padding-inline: 0.8rem 0.6rem; vertical-align: middle; }
  .ai-send, .ai-attach, .ai-mic, .ai-voice-btn { width: var(--touch); height: var(--touch); }
  .ai-act { height: var(--touch); padding-inline: 0.75rem; }
  .ai-msg.is-user.is-last .ai-edit, .ai-jump { width: var(--touch); height: var(--touch); }
  .ai-note summary { min-height: var(--touch); }
  .ai-file .btn-icon { width: var(--touch); height: var(--touch); }
  .ai-card { min-height: var(--touch); }
}
