/* Styly chatu asistenta.
   Nejsou to scoped .razor.css: v téhle RCL se scoped styly nenačítají, takže se
   registrují v App.razor hostitele jako _content/2ndSide.Blazor.Ai/css/secondside-blazor-ai.css

   Barvy jdou výhradně z proměnných MudBlazoru (--mud-palette-*, --mud-elevation-*),
   ať okno sedí se světlým i tmavým tématem hostitele. */

.ai-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    gap: 8px;
}

/* Obal seznamu zpráv — kvůli pilulce „Nové zprávy“, která plave nad ním. */
.ai-chat__feed {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.ai-chat__messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px 2px;
    /* Bez smooth: JS během streamu nastavuje scrollTop každých 80 ms a plynulá
       animace nikdy nedoběhla — delší odpovědi se kvůli tomu trhaly. */
    scroll-behavior: auto;
}

.ai-chat__new-messages {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px 4px 8px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: .78rem;
    cursor: pointer;
    color: var(--mud-palette-primary-text);
    background: var(--mud-palette-primary);
    box-shadow: var(--mud-elevation-4);
    animation: ai-message-in .16s ease-out;
}

.ai-chat__new-messages[hidden] {
    display: none;
}

.ai-chat__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    padding: 24px 16px;
}

.ai-chat__empty .mud-typography {
    opacity: .75;
}

.ai-chat__suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 4px;
}

/* Návrhy po odpovědi. Text místo obrysu schválně — pod hotovou odpovědí by výrazné
   chipy přetahovaly pozornost z toho, co model právě napsal. */
.ai-chat__followups {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    padding: .25rem .5rem .75rem;
}

/* Proužek s kontextem stránky nad vstupem. Decentní — je to informace, ne akce. */
.ai-chat__context {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px 0;
    color: var(--mud-palette-text-secondary);
    font-size: .72rem;
    min-width: 0;
}

.ai-chat__context-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat__composer {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--mud-palette-divider);
}

.ai-chat__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

/* ============================================================
   Přiložený soubor: sponka, přetažení, štítek s akcemi
   ============================================================ */

.ai-chat {
    position: relative;
}

/* Přes celý panel během tažení souboru. Neviditelné InputFile nahoře soubor převezme samo. */
.ai-chat__drop {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px dashed var(--mud-palette-primary);
    border-radius: 8px;
    background: color-mix(in srgb, var(--mud-palette-surface) 90%, transparent);
    color: var(--mud-palette-primary);
    font-weight: 500;
}

.ai-chat__drop-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: copy;
}

.ai-chat__attach {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--mud-palette-action-default);
}

.ai-chat__attach:hover {
    background: var(--mud-palette-action-default-hover);
}

.ai-chat__attach-input {
    display: none;
}

.ai-chat__attachment {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.ai-chat__attachment .mud-chip {
    max-width: 100%;
}

.ai-chat__attachment-error {
    color: var(--mud-palette-error);
    font-size: .75rem;
}

.ai-message__files {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    margin-bottom: 4px;
}

.ai-message__file {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--mud-palette-action-default-hover);
    font-size: .75rem;
}

.ai-message__file-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   Bubliny
   ============================================================ */

.ai-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.ai-message--user {
    align-items: flex-end;
}

.ai-message--user .ai-message__body {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border-radius: 14px 14px 4px 14px;
}

.ai-message--assistant .ai-message__body {
    background: var(--mud-palette-background-gray);
    color: var(--mud-palette-text-primary);
    border-radius: 14px 14px 14px 4px;
}

.ai-message__body {
    /* Strop v znacích, ne v procentech: v širokém okně měla řádka odpovědi přes sto
       znaků a oko na dalším řádku ztrácelo začátek. Tabulky a grafy si šířku berou
       zpátky níž (.ai-message__body > .ai-visual). */
    max-width: min(92%, 78ch);
    min-width: 0;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-wrap: anywhere;
}

.ai-message__retry {
    display: flex;
    justify-content: flex-start;
}

/* Vizualizace se z textové míry vymaňuje — graf ani tabulka nejsou text ke čtení
   po řádcích a v 78 znacích se nakreslí zbytečně malé. */
.ai-message--assistant .ai-message__body:has(.ai-visual) {
    max-width: 96%;
    width: 100%;
}

/* Čas, kopírování a hodnocení: skryté, dokud se na zprávu nenajede (nebo nedostane fokus). */
.ai-message__meta {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 4px;
    font-size: .7rem;
    color: var(--mud-palette-text-secondary);
    opacity: 0;
    transition: opacity .15s ease;
}

.ai-message:hover .ai-message__meta,
.ai-message:focus-within .ai-message__meta {
    opacity: 1;
}

/* Už udělené hodnocení musí být vidět i bez najetí — jinak nejde poznat,
   co jsem hodnotil a co ne. */
.ai-message__meta:has(.ai-message__rate--on) {
    opacity: 1;
}

.ai-message__meta .mud-icon-button {
    padding: 2px;
}

.ai-message__meta .mud-icon-button .mud-icon-root {
    font-size: 1rem;
    width: 1rem;
    height: 1rem;
}

.ai-message__time {
    font-variant-numeric: tabular-nums;
}

/* --- krok nástroje (řádek v podrobnostech procesu) --- */

.ai-tool-call {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    font-size: .8rem;
    opacity: .85;
}

.ai-tool-call--running {
    opacity: 1;
}

.ai-tool-call__title {
    flex: 1 1 auto;
}

.ai-tool-call__duration {
    opacity: .6;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   Scéna — co asistent zrovna dělá
   Velká Sponka hraje stav, k ní dvě tři slova. Dřív tu stály tři řádky s týmž
   titulkem; teď nese význam animace a text je jen potvrzení. Co přesně se dělo,
   je schované pod „podrobnosti“.
   ============================================================ */

/* Pódium: měkká záře za Sponkou a stín pod ní. Stín dýchá proti pohybu těla, takže
   sponka působí, že stojí na zemi, a ne že je nalepená na pozadí. Sdílí ho scéna
   v bublině i úvodní obrazovka prázdné konverzace. */
.ai-podium {
    position: relative;
    flex: 0 0 auto;
    isolation: isolate;
}

.ai-podium::before {
    content: "";
    position: absolute;
    /* Tělo sponky je ve viewBoxu vlevo od středu (vpravo je místo na rekvizity). */
    inset: -14% -6% -10% -22%;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(closest-side,
        color-mix(in srgb, var(--ai-stage-tint, var(--mud-palette-primary)) 26%, transparent) 0%,
        color-mix(in srgb, var(--ai-stage-tint, var(--mud-palette-primary)) 9%, transparent) 55%,
        transparent 100%);
    animation: ai-podium-glow 3.6s ease-in-out infinite;
}

.ai-podium::after {
    content: "";
    position: absolute;
    left: 12%;
    width: 70%;
    bottom: -3%;
    height: 9%;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(15, 23, 42, .28), transparent);
    animation: ai-podium-shadow 3.6s ease-in-out infinite;
}

@keyframes ai-podium-glow {
    0%, 100% { opacity: .75; transform: scale(.94); }
    50%      { opacity: 1; transform: scale(1.04); }
}

@keyframes ai-podium-shadow {
    0%, 100% { opacity: .9; transform: scaleX(1); }
    50%      { opacity: .55; transform: scaleX(.86); }
}

/* Úvodní obrazovka: Sponka jako hostitel, ne jako ikonka nad textem. */
.ai-chat__hero {
    width: 112px;
    margin: 10px 0 8px;
}

.ai-stage {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.ai-stage__row {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

/* Velikost Sponky řídí jen tahle šířka, takže přechod do kompaktní podoby je plynulý. */
.ai-stage__mascot {
    width: 100px;
    margin: 10px 4px 8px 8px;
    transition: width .45s cubic-bezier(.2, .8, .2, 1), margin .45s cubic-bezier(.2, .8, .2, 1);
}

.ai-stage__side {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    animation: ai-stage-side-in .3s ease-out;
}

/* Popisek s přejíždějícím leskem: říká „pořád se něco děje“ bez dalšího pohyblivého prvku.
   Barvy z palety, takže lesk sedí ve světlém i tmavém tématu. */
.ai-stage__caption {
    align-self: flex-start;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -.005em;
    line-height: 1.25;
    color: var(--mud-palette-text-secondary);
    background: linear-gradient(100deg,
        var(--mud-palette-text-secondary) 0%,
        var(--mud-palette-text-secondary) 38%,
        var(--mud-palette-primary) 50%,
        var(--mud-palette-text-secondary) 62%,
        var(--mud-palette-text-secondary) 100%);
    background-size: 250% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: ai-stage-caption-in .35s cubic-bezier(.2, .8, .2, 1), ai-stage-shimmer 2.6s linear infinite;
}

@keyframes ai-stage-caption-in {
    from { opacity: 0; transform: translateY(7px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes ai-stage-shimmer {
    from { background-position: 115% 0; }
    to   { background-position: -15% 0; }
}

@keyframes ai-stage-side-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}

.ai-stage__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 18px;
    font-size: .72rem;
    color: var(--mud-palette-text-secondary);
}

/* Tečky kroků: hotový krok tlumená, běžící plná s rozbíhajícím se kroužkem. */
.ai-stage__dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ai-stage__dots-more {
    font-variant-numeric: tabular-nums;
    opacity: .7;
}

.ai-stage__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--mud-palette-primary) 42%, transparent);
    animation: ai-stage-dot-in .3s cubic-bezier(.3, 1.5, .5, 1);
}

.ai-stage__dot--running {
    background: var(--mud-palette-primary);
    animation: ai-stage-dot-in .3s cubic-bezier(.3, 1.5, .5, 1), ai-stage-ping 1.5s ease-out .3s infinite;
}

.ai-stage__dot--error {
    background: var(--mud-palette-error);
}

@keyframes ai-stage-dot-in {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

@keyframes ai-stage-ping {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mud-palette-primary) 55%, transparent); }
    100% { box-shadow: 0 0 0 7px transparent; }
}

/* Vteřiny počítá prohlížeč: registrovaná celočíselná vlastnost se animuje lineárně
   a counter() ji vypíše. Ze serveru by to bylo překreslení a SignalR zpráva každou
   vteřinu. Prvních pár vteřin je schovaný — u rychlé odpovědi je to údaj navíc. */
@property --ai-stage-seconds {
    syntax: "<integer>";
    initial-value: 0;
    inherits: false;
}

.ai-stage__timer {
    font-variant-numeric: tabular-nums;
    counter-reset: ai-stage-seconds var(--ai-stage-seconds);
    opacity: 0;
    animation: ai-stage-count 3600s linear forwards, ai-stage-timer-in .5s ease-out 4s forwards;
}

.ai-stage__timer::after {
    content: counter(ai-stage-seconds) " s";
}

@keyframes ai-stage-count {
    to { --ai-stage-seconds: 3600; }
}

@keyframes ai-stage-timer-in {
    to { opacity: .8; }
}

.ai-stage__more {
    display: inline-flex;
    align-items: center;
    gap: 0;
    margin-left: -2px;
    padding: 0 2px;
    border: 0;
    border-radius: 6px;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
    opacity: .8;
    transition: opacity .15s ease, color .15s ease;
}

.ai-stage__more:hover,
.ai-stage__more:focus-visible {
    opacity: 1;
    color: var(--mud-palette-primary);
}

.ai-stage__more .mud-icon-root {
    font-size: 1rem;
    width: 1rem;
    height: 1rem;
}

.ai-stage__details {
    animation: ai-stage-details-in .22s ease-out;
}

@keyframes ai-stage-details-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Kompaktní podoba: odpověď už teče (nebo právě doběhla), zbývá malá píšící Sponka
   pod textem. Popisek mizí — bublina se hýbe sama. */
.ai-stage--compact .ai-stage__mascot {
    width: 40px;
    margin: 0 2px 2px 2px;
}

.ai-stage--compact .ai-stage__side {
    display: none;
}

.ai-stage--compact .ai-podium::before {
    opacity: .6;
    animation: none;
}

/* Hotovo: záře se na okamžik rozsvítí do žluta spolu se žárovkou. */
.ai-stage--done {
    --ai-stage-tint: var(--mud-palette-warning);
}

/* Dokud je scéna v bublině sama, bublina ustoupí: Sponka stojí volně ve feedu,
   ne v šedém rámečku. Jakmile přiteče první obsah, pozadí se vrátí. */
.ai-message--assistant .ai-message__body {
    transition: background-color .3s ease;
}

.ai-message--assistant .ai-message__body:has(> .ai-stage:only-child) {
    background: transparent;
    padding-left: 0;
}

/* --- chyba --- */

.ai-stage--error {
    --ai-stage-tint: var(--mud-palette-error);
}

.ai-stage--error .ai-stage__mascot {
    width: 58px;
    margin: 4px 2px 4px 4px;
}

.ai-stage--error .ai-stage__side {
    gap: 2px;
}

.ai-stage__error-text {
    font-size: .88rem;
    line-height: 1.4;
}

.ai-stage--error .ai-message__retry .mud-button-root {
    margin-left: -6px;
}

/* Starší chyba v konverzaci: tvář zůstává, pohyb ne. Kapka má jinak průhlednost
   jen z animace, tak ji tu rozsvítíme staticky. */
.ai-stage--still .ai-mascot,
.ai-stage--still .ai-mascot *,
.ai-stage--still .ai-podium::before,
.ai-stage--still .ai-podium::after {
    animation: none !important;
}

.ai-stage--still .ai-mascot__sweat path {
    opacity: .9;
}

/* --- stopa hotového procesu ---
   Jeden tichý řádek místo rámečku: počet kroků a čas. Je to záznam, ne obsah —
   nesmí se prát s odpovědí o pozornost. */

.ai-trace {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.ai-trace__toggle {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 4px;
    margin: -2px 0 -2px -4px;
    padding: 1px 4px;
    border: 0;
    border-radius: 6px;
    background: none;
    font: inherit;
    font-size: .72rem;
    font-variant-numeric: tabular-nums;
    color: var(--mud-palette-text-secondary);
    cursor: pointer;
    opacity: .75;
    transition: opacity .15s ease, background-color .15s ease;
}

.ai-trace__toggle:hover,
.ai-trace__toggle:focus-visible,
.ai-trace__toggle[aria-expanded="true"] {
    opacity: 1;
    background: var(--mud-palette-action-default-hover);
}

.ai-trace__clip {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    fill: none;
    stroke: var(--mud-palette-primary);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ai-trace--error .ai-trace__clip {
    stroke: var(--mud-palette-error);
}

.ai-trace__toggle .mud-icon-root {
    font-size: .95rem;
    width: .95rem;
    height: .95rem;
    margin-left: -2px;
}

/* --- podrobnosti procesu: poznámky z uvažování a kroky, v pořadí --- */

.ai-process {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-left: 3px;
    padding: 2px 0 2px 11px;
    border-left: 2px solid color-mix(in srgb, var(--mud-palette-primary) 28%, transparent);
    font-size: .78rem;
    color: var(--mud-palette-text-secondary);
    animation: ai-stage-details-in .22s ease-out;
}

.ai-process__note {
    white-space: pre-wrap;
    font-style: italic;
    line-height: 1.45;
    padding: 2px 0;
}

/* Právě tekoucí uvažování je náhled do práce, ne obsah: jen posledních pár řádků,
   nahoře do ztracena. */
.ai-process__note--streaming {
    max-height: 5.8em;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 1.4em);
    mask-image: linear-gradient(to bottom, transparent 0, #000 1.4em);
}

@media (prefers-reduced-motion: reduce) {
    .ai-podium::before,
    .ai-podium::after,
    .ai-stage__side,
    .ai-stage__dot,
    .ai-stage__details,
    .ai-process {
        animation: none;
    }

    .ai-stage__mascot {
        transition: none;
    }

    /* Bez lesku zůstane čitelný jednobarevný popisek. Vteřiny běží dál — je to údaj,
       ne ozdoba. */
    .ai-stage__caption {
        animation: none;
        background: none;
        -webkit-text-fill-color: currentColor;
    }
}

/* --- soubor --- */

.ai-artifact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 10px;
    border: 1px solid var(--mud-palette-divider);
    border-radius: 10px;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    min-width: 0;
}

/* Soubor z dřívější relace: karta zůstává jako stopa, ale vizuálně ustoupí. */
.ai-artifact--expired {
    opacity: .65;
}

.ai-artifact__icon {
    flex: 0 0 auto;
}

.ai-artifact__meta {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.ai-artifact__name {
    font-size: .85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-artifact__size {
    font-size: .75rem;
    opacity: .6;
    white-space: nowrap;
}

.ai-artifact__spinner {
    flex: 0 0 auto;
    margin: 4px;
    width: 20px !important;
    height: 20px !important;
}

/* --- markdown --- */

/* Během streamování se kreslí prostý text, takže je potřeba zachovat zalomení. */
.ai-markdown--plain {
    white-space: pre-wrap;
}

.ai-markdown {
    min-width: 0;
}

.ai-markdown > *:first-child {
    margin-top: 0;
}

.ai-markdown > *:last-child {
    margin-bottom: 0;
}

/* Tabulka v obalu s vodorovným posuvem — široká tabulka nesmí roztáhnout okno. */
.ai-markdown__table {
    overflow-x: auto;
    max-width: 100%;
    margin: 4px 0;
    border-radius: 8px;
    border: 1px solid var(--mud-palette-divider);
}

.ai-markdown table {
    border-collapse: collapse;
    width: 100%;
    font-size: .85rem;
    background: var(--mud-palette-surface);
}

.ai-markdown th,
.ai-markdown td {
    border-bottom: 1px solid var(--mud-palette-divider);
    padding: 4px 8px;
    text-align: left;
    white-space: nowrap;
}

.ai-markdown th {
    background: var(--mud-palette-background-gray);
    font-weight: 600;
}

.ai-markdown tr:last-child td {
    border-bottom: 0;
}

.ai-markdown pre {
    overflow-x: auto;
    padding: 8px;
    border-radius: 8px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-divider);
}

.ai-markdown code {
    font-size: .85em;
}

/* Text jen pro odečítač. Knihovna nemůže spoléhat na to, že hostitel nějaký takový
   pomocník má. */
.ai-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   Sponka — maskot
   Barvy jdou z MudBlazor proměnných, ať sedí s tématem aplikace.

   Nálada není jen tempo: ke každé patří i rekvizita (bublina, lupa, blok
   s tužkou, žárovka, Zzz). Uživatel tak z pohledu pozná, jestli se přemýšlí,
   čte z databáze, nebo se jen čeká na něj.

   Dlouhé nálady mají několikataktovou smyčku — sponka po chvíli změní, co dělá,
   místo aby donekonečna opakovala jeden pohyb. Procenta v keyframes proto
   odpovídají jednotlivým „hereckým“ aktům a jsou u nich komentáře.
   ============================================================ */

.ai-mascot {
    display: inline-block;
    flex: 0 0 auto;
    line-height: 0;
    vertical-align: middle;
}

.ai-mascot svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Bez pevné velikosti: šířku dává rodič (scéna v bublině), poměr stran drží viewBox.
   Díky tomu jde Sponku zmenšit CSS přechodem — inline rozměr by ho přebil. */
.ai-mascot--fluid {
    display: block;
    width: 100%;
    aspect-ratio: 64 / 72;
}

.ai-mascot__wire {
    stroke: var(--mud-palette-primary);
}

/* Bělmo bílé a zornice tmavá NATVRDO, ne z palety: v tmavém režimu je
   --mud-palette-surface tmavá a --mud-palette-text-primary světlá, takže maskot
   koukal s bílými zornicemi v tmavém oku. */
.ai-mascot__eye-white {
    fill: #fff;
    stroke: var(--mud-palette-primary);
    stroke-width: 1.4;
}

.ai-mascot__pupil {
    fill: #1f2430;
    transition: transform .18s ease;
}

.ai-mascot__brow {
    stroke: var(--mud-palette-primary);
    opacity: 0;
    transition: opacity .2s ease;
}

/* Oči i rekvizity se zmenšují a natáčejí samy kolem sebe. Bez fill-box míří
   transform-origin doprostřed viewBoxu, takže se mrknutí měnilo v posun oka dolů. */
.ai-mascot__eye-white,
.ai-mascot__pupil,
.ai-mascot__brow,
.ai-mascot__thought,
.ai-mascot__lens,
.ai-mascot__note,
.ai-mascot__pencil,
.ai-mascot__bulb,
.ai-mascot__zzz,
.ai-mascot__zzz path,
.ai-mascot__sweat path,
.ai-mascot__chart,
.ai-mascot__chart-point,
.ai-mascot__doc,
.ai-mascot__doc-stamp {
    transform-box: fill-box;
    transform-origin: center;
}

/* Sloupce grafu rostou od paty, ne ze středu. */
.ai-mascot__chart-bar {
    transform-box: fill-box;
    transform-origin: 50% 100%;
}

/* --- rekvizity ---
   Všechny jsou schované; rozsvítí je teprve nálada, která je potřebuje. */

.ai-mascot__thought,
.ai-mascot__lens,
.ai-mascot__note,
.ai-mascot__bulb,
.ai-mascot__zzz,
.ai-mascot__sweat,
.ai-mascot__chart,
.ai-mascot__doc {
    opacity: 0;
}

.ai-mascot__thought > circle {
    fill: var(--mud-palette-primary);
    opacity: 0;
}

/* Lupa: sklo musí zůstat průhledné, jinak by pod ní sponka zmizela. */
.ai-mascot__lens-glass {
    fill: var(--mud-palette-primary);
    fill-opacity: .12;
    stroke: var(--mud-palette-primary);
    stroke-width: 2.4;
}

.ai-mascot__lens-grip {
    fill: none;
    stroke: var(--mud-palette-primary);
    stroke-width: 3;
}

.ai-mascot__lens-shine {
    fill: none;
    stroke: #fff;
    stroke-width: 1.6;
    opacity: .85;
}

/* Blok: papír bílý natvrdo ze stejného důvodu jako bělmo — v tmavém tématu by
   se z palety stal černý lístek s neviditelnými řádky. */
.ai-mascot__note-paper {
    fill: #fff;
    stroke: var(--mud-palette-primary);
    stroke-width: 2;
}

.ai-mascot__note-line {
    fill: none;
    stroke: #9aa3b2;
    stroke-width: 1.6;
    stroke-linecap: round;
    /* Řádek se „píše“ odkrýváním čáry; delší než nejdelší řádek, ať dojede celý. */
    stroke-dasharray: 14;
    stroke-dashoffset: 14;
}

/* Tužka schválně NENÍ v barvě sponky: v barvě drátu splývala v šipku. Žlutá se
   se žárovkou nepotká — ta patří k hotovo, tužka k psaní. */
.ai-mascot__pencil-body {
    fill: var(--mud-palette-warning);
}

/* Objímka pod gumou. Kvůli ní je i v 26 px poznat, že je to tužka, a ne šipka. */
.ai-mascot__pencil-band {
    fill: #fff;
    fill-opacity: .55;
}

.ai-mascot__pencil-tip {
    fill: #1f2430;
}

.ai-mascot__bulb-glass {
    fill: var(--mud-palette-warning);
    fill-opacity: .3;
    stroke: var(--mud-palette-warning);
    stroke-width: 2.2;
}

.ai-mascot__bulb-base,
.ai-mascot__bulb-ray {
    fill: none;
    stroke: var(--mud-palette-warning);
    stroke-width: 2.2;
}

.ai-mascot__zzz path {
    fill: none;
    stroke: var(--mud-palette-primary);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
    opacity: 0;
}

.ai-mascot__sweat path {
    fill: var(--mud-palette-info);
    opacity: 0;
}

/* Tabule s grafem. Plocha bílá natvrdo jako papír bloku — v tmavém tématu by se
   z palety stala černá deska a sloupce v barvě sponky by na ní zanikly. */
.ai-mascot__chart-board {
    fill: #fff;
    stroke: var(--mud-palette-primary);
    stroke-width: 2;
}

.ai-mascot__chart-legs {
    fill: none;
    stroke: var(--mud-palette-primary);
    stroke-width: 2;
}

.ai-mascot__chart-bar {
    fill: var(--mud-palette-primary);
}

.ai-mascot__chart-bar--1 { fill-opacity: .4; }
.ai-mascot__chart-bar--2 { fill-opacity: .68; }

/* Trend ve žluté: přes sloupce v barvě sponky musí být vidět jako druhá řada. */
.ai-mascot__chart-trend {
    fill: none;
    stroke: var(--mud-palette-warning);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 22;
    stroke-dashoffset: 22;
}

.ai-mascot__chart-point {
    fill: var(--mud-palette-warning);
    stroke: #fff;
    stroke-width: .8;
}

.ai-mascot__doc-sheet {
    fill: #fff;
    stroke: var(--mud-palette-primary);
    stroke-width: 2;
    stroke-linejoin: round;
}

.ai-mascot__doc-fold {
    fill: none;
    stroke: var(--mud-palette-primary);
    stroke-width: 1.6;
    stroke-linejoin: round;
}

.ai-mascot__doc-title {
    fill: none;
    stroke: var(--mud-palette-primary);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-dasharray: 6;
    stroke-dashoffset: 6;
}

.ai-mascot__doc-line {
    fill: none;
    stroke: #9aa3b2;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-dasharray: 11;
    stroke-dashoffset: 11;
}

.ai-mascot__doc-stamp circle {
    fill: var(--mud-palette-success);
    stroke: #fff;
    stroke-width: 1;
}

.ai-mascot__doc-stamp path {
    fill: none;
    stroke: #fff;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Odznak nepřečtené odpovědi u maskota. Statický záměrně — je to informace,
   ne ozdoba, takže musí přežít i vypnutý pohyb. */
.ai-mascot__badge {
    fill: var(--mud-palette-error);
    stroke: var(--mud-palette-surface);
    stroke-width: 2.5;
    opacity: 0;
    transition: opacity .2s ease;
}

.ai-mascot--unread .ai-mascot__badge {
    opacity: 1;
}

/* Nepřečteno: sponka se zlehka pohupuje, ať si jí uživatel v appbaru všimne. */
.ai-mascot--unread .ai-mascot__body {
    animation: ai-mascot-nudge 1.6s ease-in-out infinite;
}

@keyframes ai-mascot-nudge {
    0%, 70%, 100% { transform: rotate(0deg); }
    80%           { transform: rotate(-8deg); }
    90%           { transform: rotate(8deg); }
}

.ai-mascot__body {
    transform-origin: 32px 40px;
}

/* Základní mrkání. Nálada, která má vlastní práci s víčky (klid, dřímota), si ho přebije. */
.ai-mascot__eye-white {
    animation: ai-mascot-blink 6s ease-in-out infinite;
}

@keyframes ai-mascot-blink {
    0%, 92%, 100% { transform: scaleY(1); }
    95%           { transform: scaleY(.1); }
}

/* --- klid: čeká na uživatele ---
   Skoro půlminutová smyčka, ve které se sponka postupně nudí: pohupuje se,
   rozhlédne se, protáhne, nakoukne k uživateli a nakonec usne. Smyčka se
   restartuje s každou změnou nálady, takže „usnutí“ přijde vždy až po tom,
   co uživatel doopravdy skoro půl minuty mlčí. */

.ai-mascot--idle .ai-mascot__body {
    animation: ai-mascot-idle-body 28s ease-in-out infinite;
}

.ai-mascot--idle .ai-mascot__pupil {
    animation: ai-mascot-idle-eyes 28s ease-in-out infinite;
}

.ai-mascot--idle .ai-mascot__eye-white {
    animation: ai-mascot-idle-lids 28s ease-in-out infinite;
}

.ai-mascot--idle .ai-mascot__brow {
    animation: ai-mascot-idle-brows 28s ease-in-out infinite;
}

.ai-mascot--idle .ai-mascot__zzz {
    opacity: 1;
}

.ai-mascot--idle .ai-mascot__zzz path {
    animation: ai-mascot-zzz 28s ease-out infinite;
}

/* Zpoždění posouvá celou smyčku, takže si Z vylétají po sobě a zůstávají v taktu. */
.ai-mascot--idle .ai-mascot__zzz path:nth-child(2) { animation-delay: .7s; }
.ai-mascot--idle .ai-mascot__zzz path:nth-child(3) { animation-delay: 1.4s; }

@keyframes ai-mascot-idle-body {
    /* pohupování */
    0%, 100% { transform: rotate(-1.5deg) translateY(0) scale(1, 1); }
    8%       { transform: rotate(1.5deg) translateY(0) scale(1, 1); }
    16%      { transform: rotate(-1.5deg) translateY(0) scale(1, 1); }
    24%      { transform: rotate(1.5deg) translateY(0) scale(1, 1); }
    /* rozhlédne se po místnosti */
    30%      { transform: rotate(-8deg) translateY(-1px) scale(1, 1); }
    36%      { transform: rotate(8deg) translateY(-1px) scale(1, 1); }
    41%      { transform: rotate(0deg) translateY(0) scale(1, 1); }
    /* protáhne se */
    47%      { transform: rotate(0deg) translateY(-3px) scale(.94, 1.1); }
    53%      { transform: rotate(0deg) translateY(1px) scale(1.05, .95); }
    57%      { transform: rotate(0deg) translateY(0) scale(1, 1); }
    /* nakoukne k uživateli, jestli už něco píše */
    64%      { transform: rotate(-3deg) translateY(-2px) scale(1.08, 1.08); }
    70%      { transform: rotate(3deg) translateY(-2px) scale(1.08, 1.08); }
    74%      { transform: rotate(0deg) translateY(0) scale(1, 1); }
    /* usíná */
    82%, 92% { transform: rotate(10deg) translateY(3px) scale(1, 1); }
    /* a lekne se, že pořád nic */
    95%      { transform: rotate(-4deg) translateY(-2px) scale(1.04, 1.04); }
    97%      { transform: rotate(0deg) translateY(0) scale(1, 1); }
}

@keyframes ai-mascot-idle-eyes {
    0%, 26%, 100% { transform: translate(0, 0); }
    30%           { transform: translate(-1.6px, .2px); }
    36%           { transform: translate(1.6px, .2px); }
    41%           { transform: translate(0, 0); }
    64%, 70%      { transform: translate(0, -1.2px) scaleY(1); }
    74%           { transform: translate(0, 0) scaleY(1); }
    /* zornice se zavírají s víčky */
    78%           { transform: translate(0, 1.4px) scaleY(1); }
    80%, 93%      { transform: translate(0, 1.4px) scaleY(.12); }
    95%           { transform: translate(0, 0) scaleY(1); }
    97%           { transform: translate(0, 0) scaleY(1); }
}

@keyframes ai-mascot-idle-lids {
    0%, 11%, 100% { transform: scaleY(1); }
    12.5%         { transform: scaleY(.1); }
    14%           { transform: scaleY(1); }
    44%           { transform: scaleY(1); }
    45.5%         { transform: scaleY(.1); }
    47%           { transform: scaleY(1); }
    /* zavřená očka po dobu dřímoty */
    78%           { transform: scaleY(1); }
    80%, 93%      { transform: scaleY(.12); }
    /* vykulené probuzení */
    95%           { transform: scaleY(1.12); }
    97%           { transform: scaleY(1); }
}

@keyframes ai-mascot-idle-brows {
    0%, 60%, 100% { opacity: 0; transform: translateY(0); }
    /* zvednuté obočí při nakouknutí */
    64%, 70%      { opacity: .85; transform: translateY(-1.8px); }
    74%           { opacity: 0; transform: translateY(0); }
    95%           { opacity: .85; transform: translateY(-2px); }
    97%           { opacity: 0; transform: translateY(0); }
}

@keyframes ai-mascot-zzz {
    0%, 76%   { opacity: 0; transform: translate(0, 0) scale(.6); }
    80%       { opacity: .9; transform: translate(0, -1px) scale(1); }
    90%       { opacity: .9; transform: translate(1px, -3px) scale(1.05); }
    95%, 100% { opacity: 0; transform: translate(2px, -6px) scale(1.1); }
}

/* --- poslouchá: uživatel má rozepsaný dotaz ---
   Jediná nálada, kterou spouští uživatel. Sponka se nakloní k němu, zvedne
   obočí a kouká dolů, kam se píše. */

.ai-mascot--listening .ai-mascot__body {
    animation: ai-mascot-listen 2.6s ease-in-out infinite;
}

.ai-mascot--listening .ai-mascot__pupil {
    animation: ai-mascot-listen-eyes 2.6s ease-in-out infinite;
}

.ai-mascot--listening .ai-mascot__brow {
    opacity: .85;
    transform: translateY(-1.8px);
}

@keyframes ai-mascot-listen {
    0%, 100% { transform: rotate(-4deg) translateY(0) scale(1.05); }
    50%      { transform: rotate(4deg) translateY(-1.5px) scale(1.05); }
}

@keyframes ai-mascot-listen-eyes {
    0%, 100% { transform: translate(-1px, 1.6px); }
    50%      { transform: translate(1px, 1.6px); }
}

/* --- přemýšlí ---
   Tři akty po čtyřech vteřinách: dumá ze strany na stranu, přechází sem a tam,
   a nakonec se soustředí (svraštěné obočí, zorničky krouží, bublina zmizí). */

.ai-mascot--thinking .ai-mascot__body {
    animation: ai-mascot-think-body 12s ease-in-out infinite;
}

.ai-mascot--thinking .ai-mascot__pupil {
    animation: ai-mascot-think-eyes 12s ease-in-out infinite;
}

.ai-mascot--thinking .ai-mascot__brow {
    animation: ai-mascot-think-brows 12s ease-in-out infinite;
}

.ai-mascot--thinking .ai-mascot__thought {
    animation: ai-mascot-think-bubble 12s ease-in-out infinite;
}

.ai-mascot--thinking .ai-mascot__thought > circle {
    animation: ai-mascot-thought 1.8s ease-in-out infinite;
}

.ai-mascot--thinking .ai-mascot__thought > circle:nth-child(2) { animation-delay: .25s; }
.ai-mascot--thinking .ai-mascot__thought > circle:nth-child(3) { animation-delay: .5s; }

@keyframes ai-mascot-think-body {
    /* akt 1 — dumá */
    0%, 100% { transform: rotate(-5deg) translate(0, 0) scale(1); }
    8%       { transform: rotate(5deg) translate(0, -1px) scale(1); }
    17%      { transform: rotate(-5deg) translate(0, 0) scale(1); }
    25%      { transform: rotate(4deg) translate(0, -1px) scale(1); }
    /* akt 2 — přechází */
    33%      { transform: rotate(-9deg) translate(-3px, 0) scale(1); }
    42%      { transform: rotate(9deg) translate(3px, 0) scale(1); }
    50%      { transform: rotate(-9deg) translate(-3px, 0) scale(1); }
    58%      { transform: rotate(0deg) translate(0, 0) scale(1); }
    /* akt 3 — soustředí se, až se chvěje */
    64%      { transform: rotate(-2deg) translate(0, 0) scale(1.05); }
    68%      { transform: rotate(2deg) translate(0, 0) scale(1.05); }
    72%      { transform: rotate(-2deg) translate(0, 0) scale(1.05); }
    76%      { transform: rotate(2deg) translate(0, 0) scale(1.05); }
    /* nadechnutí, než začne znovu */
    84%      { transform: rotate(0deg) translate(0, -2px) scale(1.02); }
    92%      { transform: rotate(0deg) translate(0, 0) scale(1); }
}

@keyframes ai-mascot-think-eyes {
    0%, 100% { transform: translate(-1.4px, -1.2px); }
    12%      { transform: translate(1.4px, -1.2px); }
    25%      { transform: translate(-1.4px, -1.2px); }
    33%      { transform: translate(-1.8px, 0); }
    42%      { transform: translate(1.8px, 0); }
    50%      { transform: translate(-1.8px, 0); }
    58%      { transform: translate(0, 0); }
    /* zorničky krouží dokola */
    64%      { transform: translate(0, -1.6px); }
    70%      { transform: translate(1.6px, 0); }
    76%      { transform: translate(0, 1.4px); }
    82%      { transform: translate(-1.6px, 0); }
    88%      { transform: translate(0, -1.6px); }
    94%      { transform: translate(0, 0); }
}

@keyframes ai-mascot-think-brows {
    0%, 60%, 100% { opacity: 0; transform: translateY(0); }
    66%, 86%      { opacity: .85; transform: translateY(1.8px); }
    92%           { opacity: 0; transform: translateY(0); }
}

/* Ve třetím aktu bublina zeslábne, ale nezmizí — jinak by čtyři vteřiny nebylo
   podle čeho poznat, že se pořád přemýšlí. */
@keyframes ai-mascot-think-bubble {
    0%, 58%   { opacity: 1; }
    64%, 88%  { opacity: .35; }
    95%, 100% { opacity: 1; }
}

@keyframes ai-mascot-thought {
    0%, 100% { opacity: 0; transform: translateY(2px); }
    40%      { opacity: .9; transform: translateY(0); }
}

/* --- pracuje s daty ---
   Osmivteřinová smyčka ve dvou půlkách: první prohledává lupou, druhou zapisuje
   do bloku. Přesně to, co v tu chvíli dělá nástroj na druhé straně. */

.ai-mascot--working .ai-mascot__body {
    animation: ai-mascot-work-body 8s ease-in-out infinite;
}

.ai-mascot--working .ai-mascot__pupil {
    animation: ai-mascot-work-eyes 8s ease-in-out infinite;
}

.ai-mascot--working .ai-mascot__lens {
    animation: ai-mascot-work-lens 8s ease-in-out infinite;
}

.ai-mascot--working .ai-mascot__note {
    animation: ai-mascot-work-note 8s ease-in-out infinite;
}

.ai-mascot--working .ai-mascot__note-line {
    animation: ai-mascot-work-line 8s ease-in-out infinite;
}

.ai-mascot--working .ai-mascot__note-line--2 { animation-delay: .35s; }
.ai-mascot--working .ai-mascot__note-line--3 { animation-delay: .7s; }

.ai-mascot--working .ai-mascot__pencil {
    animation: ai-mascot-scribble 1.1s ease-in-out infinite;
}

@keyframes ai-mascot-work-body {
    /* naklání se k lupě a prohledává */
    0%, 100% { transform: rotate(0deg) translate(0, 0); }
    8%       { transform: rotate(7deg) translate(1px, 0); }
    20%      { transform: rotate(3deg) translate(0, 1px); }
    32%      { transform: rotate(8deg) translate(1px, 0); }
    44%      { transform: rotate(2deg) translate(0, 0); }
    /* zapisuje — drobné pokyvování do rytmu tužky */
    56%      { transform: rotate(-2deg) translate(0, -1px); }
    64%      { transform: rotate(3deg) translate(0, 1px); }
    72%      { transform: rotate(-2deg) translate(0, -1px); }
    80%      { transform: rotate(3deg) translate(0, 1px); }
    90%      { transform: rotate(-1deg) translate(0, 0); }
}

@keyframes ai-mascot-work-eyes {
    0%, 100% { transform: translate(1.2px, .6px); }
    20%      { transform: translate(1.8px, 1.4px); }
    40%      { transform: translate(1.2px, .2px); }
    60%      { transform: translate(1.6px, 1.6px); }
    80%      { transform: translate(1.9px, 1.2px); }
}

@keyframes ai-mascot-work-lens {
    0%        { opacity: 0; transform: translate(4px, -3px) scale(.8); }
    6%        { opacity: 1; transform: translate(0, 0) scale(1); }
    14%       { opacity: 1; transform: translate(-3px, 3px) scale(1); }
    24%       { opacity: 1; transform: translate(2px, 6px) scale(1); }
    34%       { opacity: 1; transform: translate(-2px, -1px) scale(1); }
    42%       { opacity: 1; transform: translate(0, 0) scale(1.06); }
    48%       { opacity: 0; transform: translate(5px, -3px) scale(.8); }
    100%      { opacity: 0; transform: translate(5px, -3px) scale(.8); }
}

@keyframes ai-mascot-work-note {
    0%, 48%   { opacity: 0; transform: translate(3px, 3px) scale(.82); }
    56%       { opacity: 1; transform: translate(0, 0) scale(1); }
    92%       { opacity: 1; transform: translate(0, 0) scale(1); }
    98%, 100% { opacity: 0; transform: translate(3px, 3px) scale(.82); }
}

@keyframes ai-mascot-work-line {
    0%, 54%  { stroke-dashoffset: 14; }
    66%      { stroke-dashoffset: 0; }
    100%     { stroke-dashoffset: 0; }
}

@keyframes ai-mascot-scribble {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25%      { transform: translate(-3px, 1.5px) rotate(-7deg); }
    50%      { transform: translate(1.5px, 3px) rotate(5deg); }
    75%      { transform: translate(-2px, 4.5px) rotate(-4deg); }
}

/* --- píše odpověď ---
   Blok je vidět celou dobu, řádky přibývají a tužka po nich jede. */

.ai-mascot--writing .ai-mascot__body {
    animation: ai-mascot-write-body 3s ease-in-out infinite;
}

.ai-mascot--writing .ai-mascot__pupil {
    animation: ai-mascot-write-eyes 3s ease-in-out infinite;
}

.ai-mascot--writing .ai-mascot__note {
    opacity: 1;
}

.ai-mascot--writing .ai-mascot__note-line {
    animation: ai-mascot-write-line 3s ease-in-out infinite;
}

.ai-mascot--writing .ai-mascot__note-line--2 { animation-delay: .25s; }
.ai-mascot--writing .ai-mascot__note-line--3 { animation-delay: .5s; }

.ai-mascot--writing .ai-mascot__pencil {
    animation: ai-mascot-scribble 1s ease-in-out infinite;
}

@keyframes ai-mascot-write-body {
    0%, 100% { transform: rotate(4deg) translateY(0); }
    25%      { transform: rotate(6deg) translateY(1px); }
    50%      { transform: rotate(3deg) translateY(0); }
    75%      { transform: rotate(6deg) translateY(1px); }
}

@keyframes ai-mascot-write-eyes {
    0%, 100% { transform: translate(1.2px, 1.4px); }
    50%      { transform: translate(1.9px, 1.4px); }
}

@keyframes ai-mascot-write-line {
    0%        { stroke-dashoffset: 14; }
    24%       { stroke-dashoffset: 0; }
    78%       { stroke-dashoffset: 0; }
    88%, 100% { stroke-dashoffset: 14; }
}

/* --- kreslí přehled ---
   Tabule stojí po celou dobu; v šestivteřinové smyčce na ní vyrostou sloupce, přes ně
   se natáhne trend a na jeho konci blikne bod — v tu chvíli sponka povyskočí. Pak se
   tabule smaže a kreslí se znovu. */

.ai-mascot--charting .ai-mascot__body {
    animation: ai-mascot-chart-body 6s ease-in-out infinite;
}

.ai-mascot--charting .ai-mascot__pupil {
    animation: ai-mascot-chart-eyes 6s ease-in-out infinite;
}

.ai-mascot--charting .ai-mascot__brow {
    animation: ai-mascot-chart-brows 6s ease-in-out infinite;
}

.ai-mascot--charting .ai-mascot__chart {
    opacity: 1;
    animation: ai-mascot-prop-in .4s ease-out 1;
}

.ai-mascot--charting .ai-mascot__chart-bar {
    animation: ai-mascot-chart-bar 6s cubic-bezier(.3, 1.35, .5, 1) infinite;
}

.ai-mascot--charting .ai-mascot__chart-bar--2 { animation-delay: .28s; }
.ai-mascot--charting .ai-mascot__chart-bar--3 { animation-delay: .56s; }

.ai-mascot--charting .ai-mascot__chart-trend {
    animation: ai-mascot-chart-trend 6s ease-in-out infinite;
}

.ai-mascot--charting .ai-mascot__chart-point {
    animation: ai-mascot-chart-point 6s ease-out infinite;
}

@keyframes ai-mascot-prop-in {
    from { opacity: 0; transform: translate(5px, 4px) scale(.8); }
    to   { opacity: 1; transform: translate(0, 0) scale(1); }
}

@keyframes ai-mascot-chart-body {
    0%, 100% { transform: rotate(3deg) translate(0, 0) scale(1); }
    /* sleduje, jak rostou sloupce */
    20%      { transform: rotate(6deg) translate(1px, 1px) scale(1); }
    40%      { transform: rotate(4deg) translate(0, 0) scale(1); }
    57%      { transform: rotate(6deg) translate(1px, 1px) scale(1); }
    /* bod na konci trendu — povyskočí */
    63%      { transform: rotate(0deg) translate(0, -3.5px) scale(1.06); }
    70%      { transform: rotate(4deg) translate(0, .5px) scale(.99); }
    86%      { transform: rotate(3deg) translate(0, 0) scale(1); }
}

@keyframes ai-mascot-chart-eyes {
    0%, 100% { transform: translate(1.6px, 1.7px); }
    26%      { transform: translate(1.8px, .8px); }
    58%      { transform: translate(1.9px, -.4px); }
    70%      { transform: translate(1.7px, .2px); }
    88%      { transform: translate(1.6px, 1.4px); }
}

@keyframes ai-mascot-chart-brows {
    0%, 58%, 100% { opacity: 0; transform: translateY(0); }
    63%, 80%      { opacity: .85; transform: translateY(-1.9px); }
    88%           { opacity: 0; transform: translateY(0); }
}

@keyframes ai-mascot-chart-bar {
    0%, 7%    { transform: scaleY(0); }
    26%, 86%  { transform: scaleY(1); }
    95%, 100% { transform: scaleY(0); }
}

@keyframes ai-mascot-chart-trend {
    0%, 40%   { stroke-dashoffset: 22; opacity: 1; }
    58%, 86%  { stroke-dashoffset: 0; opacity: 1; }
    94%       { stroke-dashoffset: 0; opacity: 0; }
    100%      { stroke-dashoffset: 22; opacity: 0; }
}

@keyframes ai-mascot-chart-point {
    0%, 57%   { opacity: 0; transform: scale(0); }
    63%       { opacity: 1; transform: scale(1.9); }
    69%, 86%  { opacity: 1; transform: scale(1); }
    94%, 100% { opacity: 0; transform: scale(0); }
}

/* --- skládá soubor ---
   List přiletí, zaplní se nadpisem a řádky, sponka se napřáhne a dá na něj razítko —
   a hotový list odletí nahoru. Řádky mají vlastní keyframes místo zpoždění: zpožděná
   smyčka by přetekla do dalšího kola a na novém listu by chvíli svítil starý řádek. */

.ai-mascot--reporting .ai-mascot__body {
    animation: ai-mascot-report-body 5.5s ease-in-out infinite;
}

.ai-mascot--reporting .ai-mascot__pupil {
    animation: ai-mascot-report-eyes 5.5s ease-in-out infinite;
}

.ai-mascot--reporting .ai-mascot__brow {
    animation: ai-mascot-report-brows 5.5s ease-in-out infinite;
}

.ai-mascot--reporting .ai-mascot__doc {
    animation: ai-mascot-report-sheet 5.5s ease-in-out infinite;
}

.ai-mascot--reporting .ai-mascot__doc-title {
    animation: ai-mascot-report-title 5.5s ease-in-out infinite;
}

.ai-mascot--reporting .ai-mascot__doc-line--1 { animation: ai-mascot-report-line-1 5.5s ease-in-out infinite; }
.ai-mascot--reporting .ai-mascot__doc-line--2 { animation: ai-mascot-report-line-2 5.5s ease-in-out infinite; }
.ai-mascot--reporting .ai-mascot__doc-line--3 { animation: ai-mascot-report-line-3 5.5s ease-in-out infinite; }

.ai-mascot--reporting .ai-mascot__doc-stamp {
    animation: ai-mascot-report-stamp 5.5s cubic-bezier(.3, 1.4, .5, 1) infinite;
}

@keyframes ai-mascot-report-body {
    0%, 100% { transform: rotate(4deg) translate(0, 0); }
    /* pokyvuje do rytmu přibývajících řádků */
    18%      { transform: rotate(6deg) translate(0, 1px); }
    30%      { transform: rotate(3deg) translate(0, 0); }
    42%      { transform: rotate(6deg) translate(0, 1px); }
    /* napřáhne se… */
    58%      { transform: rotate(-3deg) translate(-1px, -3.5px); }
    /* …a razítko */
    64%      { transform: rotate(10deg) translate(2px, 2px); }
    72%      { transform: rotate(3deg) translate(0, 0); }
    90%      { transform: rotate(2deg) translate(0, -1px); }
}

@keyframes ai-mascot-report-eyes {
    0%, 100% { transform: translate(1.2px, 1.3px); }
    20%      { transform: translate(1.9px, 1.1px); }
    30%      { transform: translate(1.2px, 1.5px); }
    42%      { transform: translate(1.9px, 1.5px); }
    58%      { transform: translate(1.6px, .4px); }
    64%, 80% { transform: translate(1.8px, 1.9px); }
    /* dívá se za odlétajícím listem */
    94%      { transform: translate(1.4px, -1.4px); }
}

@keyframes ai-mascot-report-brows {
    0%, 62%, 100% { opacity: 0; transform: translateY(0); }
    66%, 84%      { opacity: .85; transform: translateY(-1.9px); }
    90%           { opacity: 0; transform: translateY(0); }
}

@keyframes ai-mascot-report-sheet {
    0%        { opacity: 0; transform: translate(7px, 5px) rotate(9deg); }
    10%, 86%  { opacity: 1; transform: translate(0, 0) rotate(0deg); }
    96%, 100% { opacity: 0; transform: translate(1px, -11px) rotate(-5deg); }
}

@keyframes ai-mascot-report-title {
    0%, 12%   { stroke-dashoffset: 6; }
    19%, 100% { stroke-dashoffset: 0; }
}

@keyframes ai-mascot-report-line-1 {
    0%, 20%   { stroke-dashoffset: 11; }
    30%, 100% { stroke-dashoffset: 0; }
}

@keyframes ai-mascot-report-line-2 {
    0%, 31%   { stroke-dashoffset: 11; }
    41%, 100% { stroke-dashoffset: 0; }
}

@keyframes ai-mascot-report-line-3 {
    0%, 42%   { stroke-dashoffset: 11; }
    50%, 100% { stroke-dashoffset: 0; }
}

@keyframes ai-mascot-report-stamp {
    0%, 61%   { opacity: 0; transform: scale(0) rotate(-25deg); }
    65%       { opacity: 1; transform: scale(1.4) rotate(-8deg); }
    71%, 100% { opacity: 1; transform: scale(1) rotate(-8deg); }
}

/* --- hotovo ---
   Kývnutí a nad hlavou se rozsvítí žárovka; obojí proběhne jednou a zhasne. */

.ai-mascot--done .ai-mascot__body {
    animation: ai-mascot-nod .6s ease-out 1;
}

.ai-mascot--done .ai-mascot__brow {
    opacity: .9;
}

.ai-mascot--done .ai-mascot__bulb {
    animation: ai-mascot-bulb 1.4s ease-out 1;
}

.ai-mascot--done .ai-mascot__bulb-ray {
    animation: ai-mascot-bulb-ray .5s ease-out 2;
}

@keyframes ai-mascot-nod {
    0%   { transform: translateY(0) scale(1); }
    35%  { transform: translateY(-4px) scale(1.06); }
    70%  { transform: translateY(1px) scale(.98); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes ai-mascot-bulb {
    0%   { opacity: 0; transform: translateY(5px) scale(.6); }
    22%  { opacity: 1; transform: translateY(0) scale(1.12); }
    40%  { opacity: 1; transform: translateY(0) scale(1); }
    78%  { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-3px) scale(.92); }
}

@keyframes ai-mascot-bulb-ray {
    0%, 100% { opacity: 1; }
    50%      { opacity: .25; }
}

/* --- chyba ---
   Převrácené obočí, vykulené oči a kapka potu. Sponka se nehýbe do rytmu,
   jen pomalu klesá — má to vypadat rozpačitě, ne vesele. */

.ai-mascot--error .ai-mascot__body {
    animation: ai-mascot-droop 3.4s ease-in-out infinite;
}

.ai-mascot--error .ai-mascot__wire,
.ai-mascot--error .ai-mascot__eye-white {
    stroke: var(--mud-palette-error);
}

.ai-mascot--error .ai-mascot__brow {
    opacity: .9;
    stroke: var(--mud-palette-error);
    transform: rotate(180deg);
}

.ai-mascot--error .ai-mascot__eye-white {
    animation: none;
}

.ai-mascot--error .ai-mascot__sweat {
    opacity: 1;
}

.ai-mascot--error .ai-mascot__sweat path {
    animation: ai-mascot-sweat 2.8s ease-in infinite;
}

@keyframes ai-mascot-droop {
    0%, 100% { transform: rotate(7deg) translateY(1px); }
    50%      { transform: rotate(4.5deg) translateY(-1px); }
}

@keyframes ai-mascot-sweat {
    0%, 8%    { opacity: 0; transform: translate(0, -3px) scale(.7); }
    24%       { opacity: .9; transform: translate(0, 0) scale(1); }
    56%       { opacity: .9; transform: translate(0, 4px) scale(1); }
    70%, 100% { opacity: 0; transform: translate(0, 8px) scale(.8); }
}

/* Kdo nechce pohyb, ten ho nedostane — ani u sponky. Vypíná se plošně, aby na to
   nešlo zapomenout u další přidané rekvizity; co nese informaci, se pak vrátí staticky. */
/* ---------- Další postavičky (AiMascotKind): stejné nálady a rekvizity, jiné tělo ----------
   Výplň v hlavní barvě tématu (branding instalace), obrys tmavší; obočí na barevném těle tmavé, jinak by zaniklo. */
.ai-mascot__shell {
    fill: var(--mud-palette-primary);
    stroke: color-mix(in srgb, var(--mud-palette-primary) 65%, #000);
    stroke-width: 1.4;
    stroke-linejoin: round;
}

.ai-mascot--kind-bubble .ai-mascot__brow,
.ai-mascot--kind-pencil .ai-mascot__brow,
.ai-mascot--kind-note .ai-mascot__brow,
.ai-mascot--kind-spark .ai-mascot__brow {
    stroke: #1f2430;
}

.ai-mascot--kind-bubble .ai-mascot__eye-white,
.ai-mascot--kind-pencil .ai-mascot__eye-white,
.ai-mascot--kind-spark .ai-mascot__eye-white {
    stroke: color-mix(in srgb, var(--mud-palette-primary) 65%, #000);
}

.ai-mascot__eraser { fill: #f4a3b5; stroke: #1f2430; stroke-width: 1.1; }
.ai-mascot__ferrule { fill: #c9ced6; stroke: #1f2430; stroke-width: 1.1; }
.ai-mascot__wood { fill: #f1d3a2; stroke: #1f2430; stroke-width: 1.1; stroke-linejoin: round; }
.ai-mascot__lead { fill: #1f2430; transform-box: fill-box; transform-origin: 50% 0; }

.ai-mascot__paper {
    fill: #ffe27a;
    stroke: var(--mud-palette-primary);
    stroke-width: 2.2;
    stroke-linejoin: round;
}

.ai-mascot__corner {
    fill: #f2c94c;
    stroke: var(--mud-palette-primary);
    stroke-width: 1.8;
    stroke-linejoin: round;
    transform-box: fill-box;
    transform-origin: 0 0;
}

.ai-mascot__twinkle {
    fill: var(--mud-palette-primary);
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
}

.ai-mascot--kind-spark.ai-mascot--idle .ai-mascot__twinkle {
    animation: ai-mascot-twinkle 3.2s ease-in-out infinite;
}

.ai-mascot--kind-spark.ai-mascot--done .ai-mascot__twinkle {
    animation: ai-mascot-twinkle 1.1s ease-in-out infinite;
}

.ai-mascot--kind-spark .ai-mascot__twinkle--2 {
    animation-delay: 1.4s !important;
}

/* Jiskra při chybě pohasne. */
.ai-mascot--kind-spark.ai-mascot--error .ai-mascot__shell {
    fill: color-mix(in srgb, var(--mud-palette-primary) 35%, #8a8f98);
    transition: fill .4s ease;
}

/* Lístku se zvedá roh, když uživatel píše (a občas jen tak). */
.ai-mascot--kind-note.ai-mascot--listening .ai-mascot__corner {
    animation: ai-mascot-flap 1.2s ease-in-out infinite;
}

.ai-mascot--kind-note.ai-mascot--idle .ai-mascot__corner {
    animation: ai-mascot-flap 7s ease-in-out infinite;
}

/* Tužce se při chybě ulomí hrot. */
.ai-mascot--kind-pencil.ai-mascot--error .ai-mascot__lead {
    animation: ai-mascot-snap 3.4s ease-in infinite;
}

@keyframes ai-mascot-twinkle {
    0%, 100% { transform: scale(.4) rotate(0); opacity: .25; }
    50% { transform: scale(1) rotate(45deg); opacity: 1; }
}

@keyframes ai-mascot-flap {
    0%, 100% { transform: skewY(0); }
    50% { transform: skewY(-10deg) translateY(-1px); }
}

@keyframes ai-mascot-snap {
    0%, 25% { transform: translateY(0) rotate(0); opacity: 1; }
    45% { transform: translateY(5px) rotate(40deg); opacity: 1; }
    60%, 100% { transform: translateY(7px) rotate(60deg); opacity: 0; }
}

/* ---------- Plíšek (AiMascotKind.Sheet) ----------
   Díl vypálený z plechu. Ocel, otvory a laser mají barvy materiálu, ne tématu: v tmavém i světlém režimu
   je to pořád plech. Z tématu je jen akcent (pilotní bod laseru, bod trendu, hvězdičky).
   Kancelářské rekvizity ostatních postaviček Plíšek nemá — místo lupy laser, místo bloku gravírování,
   místo tabule vypálené sloupce, místo razítka razítko vypálené do listu. */

.ai-mascot--kind-sheet .ai-mascot__body { transform-origin: 24px 60px; }
.ai-mascot__steel-hi { stop-color: #f6f8fa; }
.ai-mascot__steel-mid { stop-color: #c4ccd5; }
.ai-mascot__steel-lo { stop-color: #86929f; }
.ai-mascot__floor { fill: #000; opacity: .12; }
.ai-mascot__plate-edge { fill: #465260; }
.ai-mascot__plate-face { stroke: #465260; stroke-width: .45; }
.ai-mascot__grain { fill: none; stroke: #86929f; stroke-width: .22; opacity: .5; }
.ai-mascot__glint { fill: #fff; opacity: 0; transform-box: fill-box; transform-origin: center; transform: skewX(-24deg); }
.ai-mascot__heat { opacity: 0; transition: opacity .6s ease; }
.ai-mascot__bend { fill: none; stroke: #465260; stroke-width: .35; stroke-dasharray: 1 .8; opacity: .6; }
.ai-mascot__hole { fill: #1a222b; }
.ai-mascot__engraving { font: 600 2.1px ui-monospace, monospace; fill: #465260; opacity: .6; text-anchor: middle; }

/* Jazýčky jsou obočí: nálady je zvedají a sklápějí stejně jako obočí ostatních, jen jsou vidět pořád. */
.ai-mascot__tab { fill: #c4ccd5; stroke: #465260; stroke-width: .45; }
.ai-mascot--kind-sheet .ai-mascot__brow { opacity: 1 !important; }
.ai-mascot--kind-sheet .ai-mascot__eye-white { stroke: none; }
.ai-mascot__lid { fill: none; stroke: #fff; stroke-width: 1.1; stroke-linecap: round; opacity: 0; }

/* Drážka úst ve čtyřech tvarech; nálada rozsvítí jeden. */
.ai-mascot__mouth { fill: none; stroke: #1a222b; stroke-width: 2.2; stroke-linecap: round; opacity: 0; transition: opacity .25s ease; }
.ai-mascot__mouth--smile { opacity: 1; }
.ai-mascot--listening .ai-mascot__mouth--smile,
.ai-mascot--thinking .ai-mascot__mouth--smile,
.ai-mascot--working .ai-mascot__mouth--smile,
.ai-mascot--done .ai-mascot__mouth--smile,
.ai-mascot--error .ai-mascot__mouth--smile { opacity: 0; }
.ai-mascot--listening .ai-mascot__mouth--flat,
.ai-mascot--thinking .ai-mascot__mouth--flat,
.ai-mascot--working .ai-mascot__mouth--flat,
.ai-mascot--done .ai-mascot__mouth--grin,
.ai-mascot--error .ai-mascot__mouth--frown { opacity: 1; }

/* Pilotní bod laseru dýchá; u nepřečtené odpovědi pulzuje, aby si ho uživatel v appbaru všiml. */
.ai-mascot__pilot { fill: var(--mud-palette-error); animation: ai-mascot-pilot 2.4s ease-in-out infinite; }
.ai-mascot__pilot-glow { fill: var(--mud-palette-error); opacity: .28; transform-box: fill-box; transform-origin: center; }
.ai-mascot--unread .ai-mascot__pilot-glow { opacity: .5; animation: ai-mascot-pilot-pulse 1.2s ease-in-out infinite; }

@keyframes ai-mascot-pilot {
    0%, 100% { opacity: 1; }
    50%      { opacity: .45; }
}

@keyframes ai-mascot-pilot-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(2); }
}

.ai-mascot--kind-sheet .ai-mascot__thought,
.ai-mascot--kind-sheet .ai-mascot__lens,
.ai-mascot--kind-sheet .ai-mascot__note,
.ai-mascot--kind-sheet .ai-mascot__bulb,
.ai-mascot--kind-sheet .ai-mascot__sweat,
.ai-mascot--kind-sheet .ai-mascot__chart,
.ai-mascot--kind-sheet .ai-mascot__doc { display: none; }

/* Klid: po kartáčovaném povrchu občas přejede odlesk. */
.ai-mascot--kind-sheet.ai-mascot--idle .ai-mascot__glint { animation: ai-mascot-glint 7s ease-in-out infinite; }

@keyframes ai-mascot-glint {
    0%, 70%   { opacity: 0; transform: translateX(0) skewX(-24deg); }
    73%       { opacity: .55; }
    86%       { opacity: .55; transform: translateX(46px) skewX(-24deg); }
    88%, 100% { opacity: 0; transform: translateX(46px) skewX(-24deg); }
}

/* Přemýšlí: nad hlavou se točí výpalky. */
.ai-mascot__slugs circle { fill: #f6f8fa; stroke: #465260; stroke-width: .4; opacity: 0; transform-box: fill-box; transform-origin: center; }
.ai-mascot--thinking .ai-mascot__slugs circle { animation: ai-mascot-slug 2.6s ease-in-out infinite; }
.ai-mascot--thinking .ai-mascot__slugs circle:nth-child(2) { animation-delay: .85s; }
.ai-mascot--thinking .ai-mascot__slugs circle:nth-child(3) { animation-delay: 1.7s; }

@keyframes ai-mascot-slug {
    0%   { opacity: 0; transform: translate(0, 4px) scaleX(1); }
    20%  { opacity: 1; }
    50%  { transform: translate(2px, -4px) scaleX(.15); }
    80%  { opacity: 1; }
    100% { opacity: 0; transform: translate(4px, -12px) scaleX(1); }
}

/* Společné části laseru. */
.ai-mascot__laser,
.ai-mascot__engrave,
.ai-mascot__cut,
.ai-mascot__burn { opacity: 0; transform-box: fill-box; transform-origin: center; }
.ai-mascot__sheet { fill: #c4ccd5; stroke: #465260; stroke-width: .45; }
.ai-mascot__nozzle-body { fill: #c4ccd5; stroke: #465260; stroke-width: .3; }
.ai-mascot__nozzle { fill: #86929f; stroke: #465260; stroke-width: .3; }
.ai-mascot__beam { stroke: #ff7a1a; stroke-width: .8; }
.ai-mascot__flare { fill: #ff7a1a; opacity: .5; }
.ai-mascot__core { fill: #fff8e1; }
.ai-mascot__sparks { fill: none; stroke: #ff9a3c; stroke-width: .45; stroke-linecap: round; animation: ai-mascot-sparks .18s steps(2) infinite; }

@keyframes ai-mascot-sparks {
    0%   { opacity: 1; }
    50%  { opacity: .2; }
}

/* Hledá: laser objede kruhový obrys, stopa žhne a chladne, výpalek vypadne a zůstane otvor. */
.ai-mascot--working .ai-mascot__laser { opacity: 1; animation: ai-mascot-prop-in .4s ease-out 1; }
.ai-mascot__kerf { fill: none; stroke: #1a222b; stroke-width: .75; stroke-dasharray: 1; stroke-dashoffset: 1; }
.ai-mascot--working .ai-mascot__kerf { animation: ai-mascot-kerf 3.4s linear infinite; }
.ai-mascot__slug-hole { fill: #1a222b; opacity: 0; }
.ai-mascot--working .ai-mascot__slug-hole { animation: ai-mascot-slug-drop 3.4s linear infinite; }
.ai-mascot__orbit { transform-origin: 53px 55.5px; }
.ai-mascot__head--orbit { transform-origin: 57px 55.5px; }
.ai-mascot--working .ai-mascot__orbit { animation: ai-mascot-orbit 3.4s linear infinite; }
.ai-mascot--working .ai-mascot__head--orbit { animation: ai-mascot-orbit-head 3.4s linear infinite; }

@keyframes ai-mascot-kerf {
    0%        { stroke-dashoffset: 1; stroke: #ff7a1a; }
    76%       { stroke-dashoffset: 0; stroke: #ff7a1a; }
    90%, 100% { stroke-dashoffset: 0; stroke: #1a222b; }
}

@keyframes ai-mascot-slug-drop {
    0%, 78%  { opacity: 0; }
    84%, 96% { opacity: 1; }
    100%     { opacity: 0; }
}

@keyframes ai-mascot-orbit {
    0%        { transform: rotate(0deg); }
    76%, 100% { transform: rotate(360deg); }
}

/* Hlava obíhá s kruhem, ale proti němu se otáčí zpátky, takže tryska míří pořád dolů. */
@keyframes ai-mascot-orbit-head {
    0%        { transform: rotate(0deg); opacity: 1; }
    76%       { transform: rotate(-360deg); opacity: 1; }
    82%, 100% { transform: rotate(-360deg); opacity: 0; }
}

/* Píše: laser gravíruje tři řádky a hlava jede s nimi. */
.ai-mascot--writing .ai-mascot__engrave { opacity: 1; }
.ai-mascot__engr { fill: none; stroke: #465260; stroke-width: 1.05; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.ai-mascot--writing .ai-mascot__engr--1 { animation: ai-mascot-engr-1 4.6s linear infinite; }
.ai-mascot--writing .ai-mascot__engr--2 { animation: ai-mascot-engr-2 4.6s linear infinite; }
.ai-mascot--writing .ai-mascot__engr--3 { animation: ai-mascot-engr-3 4.6s linear infinite; }
.ai-mascot--writing .ai-mascot__head--write { animation: ai-mascot-write-head 4.6s linear infinite; }

@keyframes ai-mascot-engr-1 {
    0%        { stroke-dashoffset: 1; opacity: 1; }
    28%, 90%  { stroke-dashoffset: 0; opacity: 1; }
    97%, 100% { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes ai-mascot-engr-2 {
    0%, 32%   { stroke-dashoffset: 1; opacity: 1; }
    60%, 90%  { stroke-dashoffset: 0; opacity: 1; }
    97%, 100% { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes ai-mascot-engr-3 {
    0%, 64%   { stroke-dashoffset: 1; opacity: 1; }
    84%, 90%  { stroke-dashoffset: 0; opacity: 1; }
    97%, 100% { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes ai-mascot-write-head {
    0%        { transform: translate(0, 0); opacity: 1; }
    28%       { transform: translate(14.5px, 0); }
    32%       { transform: translate(0, 5px); }
    60%       { transform: translate(14.5px, 5px); }
    64%       { transform: translate(0, 10px); }
    84%       { transform: translate(8.5px, 10px); opacity: 1; }
    88%, 100% { transform: translate(8.5px, 10px); opacity: 0; }
}

/* Kreslí graf: vypálí obrysy sloupců, vytlačí je z tabule a přes ně vygravíruje trend. */
.ai-mascot--charting .ai-mascot__cut { opacity: 1; animation: ai-mascot-prop-in .4s ease-out 1; }
.ai-mascot__bar-kerf { fill: none; stroke: #1a222b; stroke-width: .6; stroke-dasharray: 1; stroke-dashoffset: 1; }
.ai-mascot__bar-hole { fill: #1a222b; opacity: 0; }
.ai-mascot__bar-piece { fill: #f6f8fa; stroke: #465260; stroke-width: .4; opacity: 0; }
.ai-mascot__trend { stroke: var(--mud-palette-primary); }
.ai-mascot__trend-point { fill: var(--mud-palette-primary); opacity: 0; transform-box: fill-box; transform-origin: center; }
.ai-mascot--charting .ai-mascot__bar-kerf--1 { animation: ai-mascot-bar-kerf-1 5.6s linear infinite; }
.ai-mascot--charting .ai-mascot__bar-kerf--2 { animation: ai-mascot-bar-kerf-2 5.6s linear infinite; }
.ai-mascot--charting .ai-mascot__bar-kerf--3 { animation: ai-mascot-bar-kerf-3 5.6s linear infinite; }
.ai-mascot--charting .ai-mascot__bar-hole { animation: ai-mascot-bar-hole 5.6s ease-out infinite; }
.ai-mascot--charting .ai-mascot__bar-piece { animation: ai-mascot-bar-piece 5.6s ease-out infinite; }
.ai-mascot--charting .ai-mascot__trend { animation: ai-mascot-trend 5.6s linear infinite; }
.ai-mascot--charting .ai-mascot__trend-point { animation: ai-mascot-trend-point 5.6s ease-out infinite; }

@keyframes ai-mascot-bar-kerf-1 {
    0%        { stroke-dashoffset: 1; opacity: 1; }
    12%, 92%  { stroke-dashoffset: 0; opacity: 1; }
    100%      { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes ai-mascot-bar-kerf-2 {
    0%, 13%   { stroke-dashoffset: 1; opacity: 1; }
    25%, 92%  { stroke-dashoffset: 0; opacity: 1; }
    100%      { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes ai-mascot-bar-kerf-3 {
    0%, 26%   { stroke-dashoffset: 1; opacity: 1; }
    40%, 92%  { stroke-dashoffset: 0; opacity: 1; }
    100%      { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes ai-mascot-bar-hole {
    0%, 42%  { opacity: 0; }
    50%, 92% { opacity: 1; }
    100%     { opacity: 0; }
}

@keyframes ai-mascot-bar-piece {
    0%, 42%  { opacity: 0; transform: translate(0, 0); }
    44%      { opacity: 1; transform: translate(0, 0); }
    52%, 92% { opacity: 1; transform: translate(-.9px, -1.6px); }
    100%     { opacity: 0; transform: translate(-.9px, -1.6px); }
}

@keyframes ai-mascot-trend {
    0%, 54%  { stroke-dashoffset: 1; opacity: 1; }
    66%, 92% { stroke-dashoffset: 0; opacity: 1; }
    100%     { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes ai-mascot-trend-point {
    0%, 66%  { opacity: 0; transform: scale(0); }
    70%      { opacity: 1; transform: scale(1.9); }
    76%, 92% { opacity: 1; transform: scale(1); }
    100%     { opacity: 0; transform: scale(0); }
}

/* Skládá dokument: list přiletí, laser vypálí nadpis a řádky, objede kruh razítka a dovypálí fajfku.
   Takt drží s tělem (ai-mascot-report-body), které se při razítku napřáhne. */
.ai-mascot--reporting .ai-mascot__burn { opacity: 1; animation: ai-mascot-report-sheet 5.5s ease-in-out infinite; }
.ai-mascot__paper { fill: #fff; stroke: #465260; stroke-width: .55; }
.ai-mascot__paper-fold { fill: none; stroke: #465260; stroke-width: .55; }
.ai-mascot__burnt { fill: none; stroke: #7a4a24; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.ai-mascot__burnt--title { stroke-width: 1.8; }
.ai-mascot__burnt--ring,
.ai-mascot__burnt--check { stroke-width: .9; }
.ai-mascot--reporting .ai-mascot__burnt--title { animation: ai-mascot-burn-title 5.5s linear infinite; }
.ai-mascot--reporting .ai-mascot__burnt--1 { animation: ai-mascot-burn-1 5.5s linear infinite; }
.ai-mascot--reporting .ai-mascot__burnt--2 { animation: ai-mascot-burn-2 5.5s linear infinite; }
.ai-mascot--reporting .ai-mascot__burnt--3 { animation: ai-mascot-burn-3 5.5s linear infinite; }
.ai-mascot--reporting .ai-mascot__burnt--ring { animation: ai-mascot-burn-ring 5.5s linear infinite; }
.ai-mascot--reporting .ai-mascot__burnt--check { animation: ai-mascot-burn-check 5.5s linear infinite; }
.ai-mascot--reporting .ai-mascot__head--burn { animation: ai-mascot-burn-head 5.5s linear infinite; }

@keyframes ai-mascot-burn-title { 0%, 10% { stroke-dashoffset: 1; } 17%, 100% { stroke-dashoffset: 0; } }
@keyframes ai-mascot-burn-1 { 0%, 18% { stroke-dashoffset: 1; } 28%, 100% { stroke-dashoffset: 0; } }
@keyframes ai-mascot-burn-2 { 0%, 29% { stroke-dashoffset: 1; } 39%, 100% { stroke-dashoffset: 0; } }
@keyframes ai-mascot-burn-3 { 0%, 40% { stroke-dashoffset: 1; } 48%, 100% { stroke-dashoffset: 0; } }
@keyframes ai-mascot-burn-ring { 0%, 54% { stroke-dashoffset: 1; stroke: #ff7a1a; } 62% { stroke-dashoffset: 0; stroke: #ff7a1a; } 74%, 100% { stroke-dashoffset: 0; stroke: #7a4a24; } }
@keyframes ai-mascot-burn-check { 0%, 63% { stroke-dashoffset: 1; stroke: #ff7a1a; } 66% { stroke-dashoffset: 0; stroke: #ff7a1a; } 78%, 100% { stroke-dashoffset: 0; stroke: #7a4a24; } }

@keyframes ai-mascot-burn-head {
    0%, 8%    { transform: translate(0, 0); opacity: 0; }
    10%       { transform: translate(0, 0); opacity: 1; }
    17%       { transform: translate(6.5px, 0); }
    18%       { transform: translate(0, 5.5px); }
    28%       { transform: translate(15.5px, 5.5px); }
    29%       { transform: translate(0, 9.5px); }
    39%       { transform: translate(15.5px, 9.5px); }
    40%       { transform: translate(0, 13.5px); }
    48%       { transform: translate(10.5px, 13.5px); }
    54%       { transform: translate(15.1px, 20.5px); }
    56%       { transform: translate(11.5px, 24.1px); }
    58%       { transform: translate(7.9px, 20.5px); }
    60%       { transform: translate(11.5px, 16.9px); }
    62%       { transform: translate(15.1px, 20.5px); }
    63%       { transform: translate(9.8px, 20.6px); }
    66%       { transform: translate(13.3px, 19.3px); opacity: 1; }
    70%, 100% { transform: translate(13.3px, 19.3px); opacity: 0; }
}

/* Hotovo: ukloní se ohybem jazýčků, oči se usmějí a kolem bliknou hvězdičky. Jednou, jako kývnutí sponky. */
.ai-mascot--kind-sheet.ai-mascot--done .ai-mascot__eye-white,
.ai-mascot--kind-sheet.ai-mascot--done .ai-mascot__pupil { opacity: 0; }
.ai-mascot--kind-sheet.ai-mascot--done .ai-mascot__lid--happy { opacity: 1; }
.ai-mascot--kind-sheet.ai-mascot--done .ai-mascot__brow { animation: ai-mascot-bow 1.2s ease-in-out 1; }
.ai-mascot__stars path { fill: var(--mud-palette-primary); opacity: 0; transform-box: fill-box; transform-origin: center; }
.ai-mascot--done .ai-mascot__stars path { animation: ai-mascot-star 1.4s ease-out 1 both; }
.ai-mascot--done .ai-mascot__stars path:nth-child(2) { animation-delay: .15s; }
.ai-mascot--done .ai-mascot__stars path:nth-child(3) { animation-delay: .3s; }

@keyframes ai-mascot-bow {
    0%, 100% { transform: translateY(0); }
    30%, 55% { transform: translateY(2.4px); }
}

@keyframes ai-mascot-star {
    0%   { opacity: 0; transform: scale(0) rotate(0deg); }
    40%  { opacity: 1; transform: scale(1.2) rotate(45deg); }
    100% { opacity: 0; transform: scale(.6) rotate(90deg); }
}

/* Chyba: přehřeje se do náběhových barev, kroutí se, kouří a jazýčky se sklopí do starosti. */
.ai-mascot--kind-sheet.ai-mascot--error .ai-mascot__heat { opacity: .78; }
.ai-mascot__plate { transform-origin: 24px 60px; }
.ai-mascot--kind-sheet.ai-mascot--error .ai-mascot__plate { animation: ai-mascot-warp .9s ease-in-out infinite; }
.ai-mascot--kind-sheet.ai-mascot--error .ai-mascot__eye-white { stroke: none; }
.ai-mascot--kind-sheet.ai-mascot--error .ai-mascot__brow { stroke: #465260; }
.ai-mascot--kind-sheet.ai-mascot--error .ai-mascot__brow--left { transform: translateY(-1px) rotate(-14deg); }
.ai-mascot--kind-sheet.ai-mascot--error .ai-mascot__brow--right { transform: translateY(-1px) rotate(14deg); }
.ai-mascot__smoke path { fill: none; stroke: #8d9aa8; stroke-width: .9; stroke-linecap: round; opacity: 0; transform-box: fill-box; transform-origin: center; }
.ai-mascot--error .ai-mascot__smoke path { animation: ai-mascot-smoke 2.4s ease-out infinite; }
.ai-mascot--error .ai-mascot__smoke path:nth-child(2) { animation-delay: 1.2s; }

@keyframes ai-mascot-warp {
    0%, 100% { transform: skewX(0deg); }
    25%      { transform: skewX(-3deg); }
    75%      { transform: skewX(3deg); }
}

@keyframes ai-mascot-smoke {
    0%   { opacity: 0; transform: translateY(2px) scale(.8); }
    30%  { opacity: .8; }
    100% { opacity: 0; transform: translateY(-10px) scale(1.2); }
}

@media (prefers-reduced-motion: reduce) {
    /* Bez pohybu nese stav rekvizita: výpalky, vypálený obrys, vygravírované řádky, vytlačené sloupce, list s razítkem. */
    .ai-mascot--thinking .ai-mascot__slugs circle,
    .ai-mascot--charting .ai-mascot__bar-piece,
    .ai-mascot--charting .ai-mascot__bar-hole,
    .ai-mascot--charting .ai-mascot__trend-point,
    .ai-mascot--done .ai-mascot__stars path { opacity: 1; }
    .ai-mascot--charting .ai-mascot__bar-piece { transform: translate(-.9px, -1.6px); }
    .ai-mascot--working .ai-mascot__kerf,
    .ai-mascot--writing .ai-mascot__engr,
    .ai-mascot--charting .ai-mascot__bar-kerf,
    .ai-mascot--charting .ai-mascot__trend,
    .ai-mascot--reporting .ai-mascot__burnt { stroke-dashoffset: 0; }
    .ai-mascot__head { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .ai-mascot,
    .ai-mascot * {
        animation: none !important;
        transition: none !important;
    }

    /* Odznak nepřečtené odpovědi je informace, ne ozdoba — ten zůstává. */
    .ai-mascot--unread .ai-mascot__badge {
        opacity: 1;
    }

    /* Bez pohybu nese stav rekvizita: bublina, lupa, blok, tabule, list. */
    .ai-mascot--thinking .ai-mascot__thought,
    .ai-mascot--working .ai-mascot__lens,
    .ai-mascot--writing .ai-mascot__note,
    .ai-mascot--charting .ai-mascot__chart,
    .ai-mascot--reporting .ai-mascot__doc {
        opacity: 1;
    }

    .ai-mascot--charting .ai-mascot__chart-trend,
    .ai-mascot--reporting .ai-mascot__doc-title,
    .ai-mascot--reporting .ai-mascot__doc-line {
        stroke-dashoffset: 0;
    }

    .ai-mascot--thinking .ai-mascot__thought > circle {
        opacity: .9;
    }

    .ai-mascot--writing .ai-mascot__note-line {
        stroke-dashoffset: 0;
    }
}
/* ============================================================
   Okno asistenta
   ============================================================ */

.ai-window {
    position: fixed;
    /* Nad appbarem (1300) i nad popover vrstvou MudBlazoru (1200), aby se select
       nebo datum uvnitř okna nevykreslily pod ním. */
    z-index: 1401;
    display: flex;
    flex-direction: column;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border: 1px solid var(--mud-palette-divider);
    border-radius: 14px;
    box-shadow: var(--mud-elevation-12);
    overflow: hidden;
    animation: ai-window-in .18s ease-out;
    outline: none;
}

@keyframes ai-window-in {
    from { opacity: 0; transform: translateY(8px) scale(.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-window--floating {
    right: 24px;
    bottom: 24px;
    max-width: 100vw;
    max-height: 100vh;
}

/* Během tažení nesmí okno nic „doháněť“ animací — kurzor je pravda. */
.ai-window--dragging {
    transition: none;
    animation: none;
    user-select: none;
}

.ai-window--docked {
    top: 0;
    right: 0;
    bottom: 0;
    height: 100%;
    max-width: 60vw;
    border-radius: 0;
    border-right: 0;
    border-top: 0;
    border-bottom: 0;
    box-shadow: var(--mud-elevation-8);
}

/* Levá hrana ukotvené zásuvky: úchyt pro změnu šířky. */
.ai-window__dock-edge {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 6px;
    cursor: ew-resize;
    touch-action: none;
    z-index: 1;
}

.ai-window__dock-edge:hover {
    background: var(--mud-palette-primary);
    opacity: .35;
}

.ai-window__header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 6px 8px 12px;
    background: var(--mud-palette-surface);
    border-bottom: 1px solid var(--mud-palette-divider);
    flex: 0 0 auto;
}

.ai-window__handle {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.ai-window__handle:active {
    cursor: grabbing;
}

.ai-window--docked .ai-window__handle {
    cursor: default;
}

.ai-window__actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.ai-window__title {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.15;
}

.ai-window__title-main {
    font-weight: 600;
    font-size: .92rem;
}

.ai-window__title-sub {
    font-size: .72rem;
    color: var(--mud-palette-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-window__body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 8px 10px 10px;
}

/* Úchyt pro změnu velikosti: tři čárky v pravém dolním rohu. */
.ai-window__resize {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    touch-action: none;
    background:
        linear-gradient(135deg, transparent 0 46%, var(--mud-palette-divider) 46% 54%, transparent 54%),
        linear-gradient(135deg, transparent 0 66%, var(--mud-palette-divider) 66% 74%, transparent 74%);
}

/* Na úzkém displeji nemá plovoucí okno smysl — přes celou obrazovku. */
@media (max-width: 720px) {
    .ai-window--floating,
    .ai-window--docked {
        /* !important i na pozici: okno si pamatuje, kam ho uživatel na desktopu
           přetáhl, a ta pozice se zapisuje inline. Bez tohohle inline styl vyhrál
           a okno na telefonu viselo mimo obrazovku nebo smrsklé do rohu. */
        inset: 0 !important;
        left: 0 !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: auto !important;
        height: auto !important;
        max-width: none;
        border-radius: 0;
        border: 0;
    }

    /* Ovládání, které se na desktopu ukazuje až po najetí myší, musí být na dotyku
       vidět pořád — prstem se „najet“ nedá. */
    .ai-message__meta,
    .ai-history__tool,
    .ai-visual__actions {
        opacity: 1;
    }

    /* Roztažení nemá na telefonu smysl — okno je přes celou obrazovku vždycky. */
    .ai-window--expanded.ai-window--floating {
        inset: 0 !important;
    }

    .ai-window__resize,
    .ai-window__dock-edge {
        display: none;
    }

    .ai-window__handle {
        cursor: default;
    }
}

/* ============================================================
   Historie konverzací
   ============================================================ */

.ai-history {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.ai-history__state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    padding: 40px 16px;
}

.ai-history__state--empty {
    opacity: .7;
}

.ai-history__alert {
    margin-bottom: 6px;
}

.ai-history__item {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.ai-history__text {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.ai-history__title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-history__date {
    font-size: .72rem;
    color: var(--mud-palette-text-secondary);
}

.ai-history__confirm {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: .78rem;
    color: var(--mud-palette-error);
    white-space: nowrap;
}

/* Zprávy přilétají zespodu, ať je poznat, že přibyly. */
.ai-message {
    animation: ai-message-in .16s ease-out;
}

@keyframes ai-message-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .ai-window,
    .ai-message,
    .ai-chat__new-messages {
        animation: none;
    }

    .ai-chat__messages {
        scroll-behavior: auto;
    }
}

/* --- zdroje odpovědi (D4) ---------------------------------------------------
   Pod odpovědí visí pohledy, ze kterých se čerpalo. Je to obrana proti tomu, aby
   se číslo vyložilo jako fakt z jiného modulu, než ze kterého opravdu je. */

.ai-sources {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 2px 4px 0;
    font-size: .7rem;
    color: var(--mud-palette-text-secondary);
}

.ai-sources .mud-icon-root {
    font-size: .9rem;
    width: .9rem;
    height: .9rem;
}

.ai-sources__label {
    letter-spacing: .01em;
}

/* Čísla bez opory ve výsledcích nástrojů — tichá poznámka, ne varování. */
.ai-number-check {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 2px 4px 0;
    font-size: .7rem;
    color: var(--mud-palette-text-secondary);
}

.ai-number-check .mud-icon-root {
    font-size: .9rem;
    width: .9rem;
    height: .9rem;
}

.ai-answer-notes {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 2px 4px 0;
    font-size: .7rem;
    color: var(--mud-palette-text-secondary);
}

.ai-answer-notes__item {
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.ai-answer-notes .mud-icon-root {
    flex: none;
    font-size: .9rem;
    width: .9rem;
    height: .9rem;
    color: var(--mud-palette-info);
}

.ai-number-check__value {
    padding: 0 6px;
    border-radius: 8px;
    border: 1px dashed var(--mud-palette-warning);
    font-variant-numeric: tabular-nums;
}

.ai-sources__chip {
    padding: 1px 7px;
    border: 1px solid var(--mud-palette-divider);
    border-radius: 999px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .68rem;
    background: var(--mud-palette-background-gray);
}

.ai-sources__chip--link {
    text-decoration: none;
    cursor: pointer;
}

.ai-sources__chip--link:hover {
    text-decoration: underline;
}

.ai-sources__toggle {
    border: 0;
    background: none;
    padding: 0 2px;
    font: inherit;
    color: var(--mud-palette-primary);
    cursor: pointer;
    text-decoration: underline dotted;
}

.ai-sources__details {
    padding: 2px 4px 0;
}

.ai-sources__sql {
    margin: 4px 0 0;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--mud-palette-divider);
    background: var(--mud-palette-background-gray);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .72rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* --- vizualizace v bublině (D3) ---------------------------------------------
   Graf je SVG vyrobené na serveru; tabulka jsou data, která modelem neprošla. */

.ai-visual {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--mud-palette-divider);
    border-radius: 12px;
    background: var(--mud-palette-surface);
}

.ai-visual__title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-weight: 600;
    font-size: .85rem;
}

.ai-visual__actions {
    display: flex;
    align-items: center;
    gap: 0;
    opacity: .55;
    transition: opacity .15s ease;
}

.ai-visual:hover .ai-visual__actions,
.ai-visual:focus-within .ai-visual__actions {
    opacity: 1;
}

.ai-visual__actions .mud-icon-button {
    padding: 3px;
}

/* SVG přichází s pevným poměrem stran; necháme ho škálovat do šířky karty. */
.ai-visual__chart svg {
    width: 100%;
    height: auto;
    display: block;
}

.ai-visual__table-wrap {
    max-height: 420px;
    overflow: auto;
}

.ai-visual__table {
    width: 100%;
    border-collapse: collapse;
    font-size: .78rem;
    font-variant-numeric: tabular-nums;
}

.ai-visual__table th,
.ai-visual__table td {
    padding: 5px 9px;
    text-align: left;
    border-bottom: 1px solid var(--mud-palette-divider);
    white-space: nowrap;
}

/* Lepkavá hlavička: u dvou set řádků je jinak po prvním odscrollování ztracená. */
.ai-visual__table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--mud-palette-background-gray);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.ai-visual__table thead th .mud-icon-root {
    font-size: .8rem;
    width: .8rem;
    height: .8rem;
    vertical-align: -1px;
    margin-left: 2px;
}

.ai-visual__table tbody tr:nth-child(even) {
    background: color-mix(in srgb, var(--mud-palette-background-gray) 55%, transparent);
}

.ai-visual__table tfoot td {
    position: sticky;
    bottom: 0;
    background: var(--mud-palette-background-gray);
    font-weight: 600;
    border-top: 2px solid var(--mud-palette-divider);
    border-bottom: 0;
}

.ai-visual__num {
    text-align: right !important;
}

.ai-visual__thumb {
    display: block;
    max-width: 72px;
    max-height: 48px;
    border-radius: 4px;
    background: #ffffff;
}

.ai-visual__more {
    align-self: flex-start;
    border: 0;
    background: none;
    padding: 2px 0;
    font: inherit;
    font-size: .75rem;
    color: var(--mud-palette-primary);
    cursor: pointer;
}

.ai-visual__caption {
    margin: 0;
    font-size: .72rem;
    color: var(--mud-palette-text-secondary);
}

/* --- lišta volby modelu a hloubky (R3) --------------------------------------- */

.ai-window__tuning {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--mud-palette-divider);
    background: var(--mud-palette-background-gray);
    flex: 0 0 auto;
}

.ai-window__tuning-group {
    display: inline-flex;
    border: 1px solid var(--mud-palette-divider);
    border-radius: 999px;
    overflow: hidden;
    background: var(--mud-palette-surface);
}

.ai-window__tuning-button {
    border: 0;
    background: none;
    padding: 3px 11px;
    font: inherit;
    font-size: .72rem;
    color: var(--mud-palette-text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.ai-window__tuning-slot {
    display: inline-flex;
}

.ai-window__tuning-slot + .ai-window__tuning-slot {
    border-left: 1px solid var(--mud-palette-divider);
}

.ai-window__tuning-button:disabled {
    cursor: default;
    opacity: .55;
}

.ai-window__tuning-button--on {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font-weight: 600;
}

/* --- opakování po chybě API (R2) --------------------------------------------- */

.ai-chat__retry {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: center;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: .76rem;
    color: var(--mud-palette-text-secondary);
    background: var(--mud-palette-background-gray);
    border: 1px solid var(--mud-palette-divider);
}

/* --- historie: hledání, připnutí, přejmenování (U2) --------------------------- */

.ai-history__search {
    padding: 2px 2px 8px;
    flex: 0 0 auto;
}

.ai-history__tools {
    display: flex;
    align-items: center;
    gap: 0;
}

.ai-history__tool {
    opacity: 0;
    transition: opacity .15s ease;
    padding: 3px;
}

.ai-history__row:hover .ai-history__tool,
.ai-history__row:focus-within .ai-history__tool,
.ai-history__tool--on {
    opacity: 1;
}

.ai-history__pin-mark {
    font-size: .8rem !important;
    width: .8rem !important;
    height: .8rem !important;
    vertical-align: -1px;
    margin-right: 3px;
    color: var(--mud-palette-primary);
}

.ai-history__rename {
    width: 100%;
    padding: 3px 6px;
    font: inherit;
    font-size: .82rem;
    color: var(--mud-palette-text-primary);
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-primary);
    border-radius: 6px;
    outline: none;
}

/* --- roztažené okno ----------------------------------------------------------
   Vlastní režim, ne jen větší rozměry: pozice okna se ukládá inline, takže by ji
   pouhá změna šířky nepřebila. */

.ai-window--expanded.ai-window--floating {
    inset: 3vh 3vw !important;
    width: auto !important;
    height: auto !important;
    max-width: none;
}

/* --- upřesňující otázka s volbami --- */

.ai-choices {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 6px 0;
}

.ai-choices__question {
    font-size: .88rem;
    font-weight: 500;
}

.ai-choices__options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.ai-choices__chip {
    border: 1px solid var(--mud-palette-primary);
    border-radius: 999px;
    padding: 3px 12px;
    background: transparent;
    color: var(--mud-palette-primary);
    font: inherit;
    font-size: .82rem;
    line-height: 1.5;
    cursor: pointer;
    transition: background-color .12s ease, color .12s ease;
}

.ai-choices__chip:hover:not(:disabled),
.ai-choices__chip--on {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
}

.ai-choices__chip:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* Zodpovězeno (nebo konverzace šla dál): chipy zůstávají jako stopa, ale ustoupí. */
.ai-choices--done .ai-choices__chip {
    border-color: var(--mud-palette-divider);
    color: var(--mud-palette-text-secondary);
    cursor: default;
}

.ai-choices--done .ai-choices__chip--on {
    background: var(--mud-palette-action-disabled-background);
    color: var(--mud-palette-text-primary);
}

/* --- patička odpovědi pro správce: cena, volání, doba --- */

.ai-message__cost {
    font-size: .72rem;
    color: var(--mud-palette-text-disabled);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* --- nabídka pokračovat v nové konverzaci --- */

.ai-chat__carry-over {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    padding: 6px 6px 6px 10px;
    border: 1px solid var(--mud-palette-divider);
    border-radius: 10px;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-secondary);
    font-size: .8rem;
}

.ai-chat__carry-over > span {
    flex: 1;
}

/* --- shrnutá starší část konverzace (komprese) --- */

.ai-compaction {
    margin: 4px 0;
}

.ai-compaction__line {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
}

.ai-compaction__line::before,
.ai-compaction__line::after {
    content: "";
    flex: 1;
    border-top: 1px dashed var(--mud-palette-divider);
}

.ai-compaction__toggle {
    text-decoration: underline;
}

.ai-compaction__summary {
    margin-top: 6px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--mud-palette-background-gray);
    color: var(--mud-palette-text-secondary);
    font-size: .85rem;
    white-space: pre-wrap;
}

/* --- návrh na zapamatování --- */

.ai-memory {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 6px 0;
    padding: 6px 10px;
    border: 1px dashed var(--mud-palette-divider);
    border-radius: 10px;
    background: var(--mud-palette-surface);
}

.ai-memory__title {
    font-weight: 600;
    margin-right: 4px;
}

.ai-memory--saved {
    border-style: solid;
    border-color: var(--mud-palette-success);
}

.ai-memory--dismissed,
.ai-memory--expired {
    opacity: .65;
}

.ai-memory__icon {
    flex: 0 0 auto;
    margin-top: 2px;
    color: var(--mud-palette-warning);
}

.ai-memory__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    gap: 1px;
}

.ai-memory__label {
    font-size: .72rem;
    color: var(--mud-palette-text-secondary);
}

.ai-memory__text {
    font-size: .85rem;
    overflow-wrap: anywhere;
}

.ai-memory__error {
    font-size: .75rem;
    color: var(--mud-palette-error);
}

.ai-memory__actions {
    display: flex;
    flex: 0 0 auto;
    gap: 2px;
}

.ai-memory-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 2px;
}

.ai-memory-panel__hint {
    color: var(--mud-palette-text-secondary);
}

.ai-memory-panel__actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-memory-panel__status {
    font-size: .78rem;
    color: var(--mud-palette-text-secondary);
}

/* ── Upravitelná tabulka pod výsledkem nástroje (AiEditableTableCard) ─────────────────────
   Staví na .ai-visual (karta, tabulka); navíc vstupy v buňkách, pole nad tabulkou a patička
   s tlačítkem přepočtu. Přepočet běží v kódu bez modelu. */

.ai-message--assistant .ai-message__body:has(.ai-edit) {
    max-width: 96%;
    width: 100%;
}

.ai-edit__readonly {
    font-weight: 400;
    font-size: .72rem;
    color: var(--mud-palette-text-secondary);
}

.ai-edit__fields {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
}

.ai-edit__field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
}

.ai-edit__field-label {
    color: var(--mud-palette-text-secondary);
}

.ai-edit__suffix {
    color: var(--mud-palette-text-secondary);
}

.ai-edit__value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.ai-edit__input {
    width: 72px;
    padding: 2px 6px;
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: 6px;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.ai-edit__input:focus {
    outline: none;
    border-color: var(--mud-palette-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--mud-palette-primary) 25%, transparent);
}

.ai-edit__input:disabled {
    opacity: .6;
}

.ai-edit__input--field {
    width: 110px;
    text-align: left;
}

/* Přepsaná hodnota je vidět na první pohled — před přepočtem i po něm v popisu dotazu. */
.ai-edit__input--changed {
    border-color: var(--mud-palette-primary);
    background: color-mix(in srgb, var(--mud-palette-primary) 10%, var(--mud-palette-surface));
    font-weight: 600;
}

.ai-edit__input--invalid {
    border-color: var(--mud-palette-error);
    background: color-mix(in srgb, var(--mud-palette-error) 10%, var(--mud-palette-surface));
}

.ai-edit__table td {
    vertical-align: middle;
}

.ai-edit__table thead th {
    cursor: default;
}

.ai-edit__row--highlight td {
    background: color-mix(in srgb, var(--mud-palette-warning) 12%, transparent);
}

.ai-edit__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.ai-edit__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.ai-edit__error {
    color: var(--mud-palette-error);
}

@media (max-width: 600px) {
    .ai-edit__input {
        width: 60px;
    }

    .ai-edit__actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Obsah hostitele pod odpovědí (MessageFooter): návrh zásahu, souhrn. */
.ai-message__footer {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
