/* Planrix - jediné okno pro rozhovor s Planrixem.
   Systémová písma, žádné externí zdroje (viz CSP v app.py). */

:root {
    --bg: #f6f3ec;
    --surface: #fffdf8;
    --surface-2: #efebe1;
    --ink: #16201d;
    --ink-2: #44504b;
    --muted: #737c77;
    --line: #e3ddd0;
    --brand: #0e3b31;
    --accent: #12876a;
    --accent-ink: #ffffff;
    --accent-soft: #e2efe9;
    --gold: #a87c12;
    --gold-soft: #f5ecd6;
    --user-bg: #e6eee9;
    --user-ink: #10241e;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --shadow: 0 1px 2px rgba(30, 26, 18, .05), 0 10px 30px rgba(30, 26, 18, .06);
    --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --maxw: 760px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1412;
        --surface: #151d1a;
        --surface-2: #1b2622;
        --ink: #e8eee9;
        --ink-2: #c2ccc7;
        --muted: #8c9892;
        --line: #26332e;
        --brand: #8fe3c9;
        --accent: #2cc497;
        --accent-ink: #06231b;
        --accent-soft: #15302a;
        --gold: #e2bf5f;
        --gold-soft: #2a2414;
        --user-bg: #1d3029;
        --user-ink: #e8f4ef;
        --danger: #ff8a80;
        --danger-soft: #3a1714;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .3);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.6 var(--sans);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- horní lišta ---------- */

.topbar {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-mark-bg { fill: var(--brand); }
.brand-mark-bar { fill: var(--bg); }
.brand-mark-dot { fill: var(--gold); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.28rem; letter-spacing: -.01em; }
.brand-tag { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.actions { display: flex; gap: 6px; flex: none; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border-radius: 999px;
    padding: 7px 14px;
    font-size: .86rem; font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    background: none;
    color: var(--ink-2);
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-outline { border-color: var(--line); background: var(--surface); }
.btn-outline:hover { border-color: var(--accent); color: var(--ink); }
.btn-support { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); background: var(--gold-soft); color: var(--gold); }
.btn-support:hover { border-color: var(--gold); }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- fáze konzultace ---------- */

.phases {
    flex: none;
    list-style: none;
    margin: 0 auto;
    padding: 4px 18px 12px;
    width: 100%;
    max-width: calc(var(--maxw) + 36px);
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--line);
}
/* popisky mají přirozenou šířku, roztahují se jen spojovací čáry */
.phases li {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 7px;
    font-size: .72rem;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
}
.phases li + li { flex: 1 1 auto; }
.phases li + li::before {
    content: "";
    flex: 1 1 auto;
    min-width: 10px;
    height: 1px;
    background: var(--line);
    margin-right: 4px;
}
.phase-dot {
    flex: none;
    width: 9px; height: 9px;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    background: var(--bg);
}
.phase-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phases li.done { color: var(--ink-2); }
.phases li.done .phase-dot { background: var(--accent); border-color: var(--accent); }
.phases li.current { color: var(--ink); font-weight: 700; }
.phases li.current .phase-dot {
    background: var(--gold); border-color: var(--gold);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 22%, transparent);
}

/* ---------- vlákno ---------- */

.chat {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 18px;
}

.thread {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 28px 0 18px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.msg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.msg-mark {
    width: 18px; height: 18px; border-radius: 6px;
    background: linear-gradient(135deg, var(--accent), var(--brand));
    position: relative;
}
.msg-mark::after {
    content: ""; position: absolute; right: -2px; top: -2px;
    width: 6px; height: 6px; border-radius: 50%; background: var(--gold);
}
.msg-name { font-family: var(--serif); font-weight: 700; font-size: .98rem; letter-spacing: .01em; }

.msg-assistant .msg-content { font-size: 1.02rem; line-height: 1.68; overflow-wrap: anywhere; }

.msg-user { display: flex; justify-content: flex-end; }
.msg-user .msg-bubble {
    max-width: min(560px, 88%);
    background: var(--user-bg);
    color: var(--user-ink);
    padding: 9px 15px;
    border-radius: 18px 18px 5px 18px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.msg-plan {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 3px solid var(--gold);
    border-radius: 14px;
    padding: 16px 20px 12px;
    box-shadow: var(--shadow);
}

.msg-content > :first-child { margin-top: 0; }
.msg-content > :last-child { margin-bottom: 0; }
.msg-content p { margin: 0 0 .75em; }
.msg-content ul, .msg-content ol { margin: 0 0 .85em; padding-left: 1.35em; }
.msg-content li { margin: .25em 0; }
.msg-content li::marker { color: var(--accent); }
.msg-content h2, .msg-content h3, .msg-content h4 { font-family: var(--serif); line-height: 1.25; letter-spacing: -.005em; }
.msg-content h2 { font-size: 1.5rem; margin: .1em 0 .6em; }
.msg-content h3 { font-size: 1.16rem; margin: 1.3em 0 .45em; color: var(--brand); }
.msg-content h4 { font-size: 1.02rem; margin: 1em 0 .4em; }
.msg-content strong { font-weight: 700; }
.msg-content a { color: var(--accent); text-underline-offset: 2px; }
.msg-content code {
    font: .88em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--surface-2);
    padding: .1em .35em; border-radius: 5px;
}
.msg-content pre { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; overflow-x: auto; }
.msg-content pre code { background: none; padding: 0; }
.msg-content blockquote {
    margin: 0 0 .85em; padding: 8px 14px;
    border-left: 3px solid var(--gold);
    background: var(--gold-soft);
    border-radius: 0 10px 10px 0;
}
.msg-content hr { border: 0; border-top: 1px solid var(--line); margin: 1.1em 0; }

/* bublina má overflow-wrap:anywhere (dlouhá slova), v tabulce by ale lámala
   slova uprostřed - tady jen mezi slovy, široká tabulka se posouvá */
.table-wrap { overflow-x: auto; margin: 0 0 .9em; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.msg-content table { border-collapse: collapse; width: 100%; font-size: .92rem; overflow-wrap: normal; word-break: normal; }
.msg-content th, .msg-content td { padding: 7px 11px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.msg-content th { background: var(--surface-2); font-weight: 650; }
.msg-content tr:last-child td { border-bottom: 0; }
.msg-content .num { text-align: right; font-variant-numeric: tabular-nums; }
.msg-content td.num { white-space: nowrap; }

.msg-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.tool {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: .8rem; font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
}
.tool:hover { border-color: var(--accent); color: var(--ink); }
.tool-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tool-primary:hover { color: var(--accent-ink); filter: brightness(1.06); }

.typing { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .92rem; }
.dots { display: inline-flex; gap: 4px; flex: none; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.notice {
    align-self: center;
    max-width: 100%;
    font-size: .86rem;
    color: var(--ink-2);
    background: var(--surface-2);
    padding: 6px 14px;
    border-radius: 999px;
    text-align: center;
}
.notice-error { background: var(--danger-soft); color: var(--danger); border-radius: 12px; }
.notice-resume { background: none; color: var(--muted); font-size: .8rem; letter-spacing: .02em; }

/* ---------- import přepisu ---------- */

.import-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1.5px dashed var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    transition: border-color .15s, background .15s;
}
.import-card.dragging { border-color: var(--accent); background: var(--accent-soft); }
.import-icon {
    width: 38px; height: 38px; border-radius: 11px;
    display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent);
}
.import-icon svg { width: 20px; height: 20px; }
.import-text { display: flex; flex-direction: column; gap: 1px; font-size: .9rem; color: var(--ink-2); line-height: 1.45; }
.import-text strong { color: var(--ink); font-size: .95rem; }

/* ---------- vstup ---------- */

.composer-wrap {
    flex: none;
    padding: 8px 18px max(10px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--bg);
}

/* tlačítka odpovědí - hlavní způsob odpovídání, proto výrazná a velká */
.quick-replies {
    max-width: var(--maxw);
    margin: 2px auto 12px;
    display: flex; flex-wrap: wrap; gap: 10px;
}
.quick {
    border: 2px solid var(--accent);
    background: var(--accent-soft);
    color: var(--brand);
    border-radius: 14px;
    padding: 11px 22px;
    font-size: 1.08rem; font-weight: 700;
    line-height: 1.25;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: background .15s, color .15s, transform .1s;
}
.quick:hover { background: var(--accent); color: var(--accent-ink); }
.quick:active { transform: scale(.97); }
.quick-scale {
    flex: 1 1 0;
    min-width: 44px; max-width: 64px; height: 52px;
    padding: 0;
    font-size: 1.2rem;
    font-variant-numeric: tabular-nums;
}

.composer {
    max-width: var(--maxw);
    margin: 0 auto;
    position: relative;
    display: flex; align-items: flex-end; gap: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 7px 7px 7px 16px;
    box-shadow: var(--shadow);
    transition: border-color .15s;
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
    flex: 1;
    border: 0; outline: 0; resize: none;
    background: transparent; color: var(--ink);
    font: inherit; line-height: 1.5;
    padding: 7px 0;
    max-height: 200px;
    min-height: 24px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-counter { position: absolute; right: 56px; top: -20px; font-size: .74rem; color: var(--muted); }
.composer-counter.over { color: var(--danger); font-weight: 700; }
.composer-send {
    flex: none;
    width: 38px; height: 38px;
    border: 0; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--accent); color: var(--accent-ink);
    cursor: pointer;
    transition: opacity .15s, transform .1s;
}
.composer-send svg { width: 19px; height: 19px; }
.composer-send:hover:not(:disabled) { transform: translateX(1px); }
.composer-send:disabled { opacity: .3; cursor: default; }

/* mikrofon v poli pro psaní; při poslouchání pulzuje */
.composer-mic {
    flex: none;
    width: 38px; height: 38px;
    border: 1.5px solid var(--line); border-radius: 12px;
    display: grid; place-items: center;
    background: var(--surface); color: var(--ink-2);
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.composer-mic svg { width: 19px; height: 19px; }
.composer-mic:hover { border-color: var(--accent); color: var(--accent); }
.composer-mic.listening {
    border-color: var(--accent); background: var(--accent); color: var(--accent-ink);
    animation: mic-pulse 1.4s infinite ease-out;
}
@keyframes mic-pulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
    100% { box-shadow: 0 0 0 12px transparent; }
}

/* výrazný překryv uprostřed obrazovky, když Planrix poslouchá */
.listen-overlay {
    position: fixed; inset: 0; z-index: 50;
    display: grid; place-items: center;
    padding: 16px;
    background: color-mix(in srgb, var(--bg) 55%, rgba(8, 16, 14, .55));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.listen-card {
    width: min(460px, 100%);
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 52px 26px 24px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
}
.listen-orb {
    width: 112px; height: 112px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--accent); color: var(--accent-ink);
    animation: orb-pulse 1.5s infinite ease-out;
}
.listen-orb svg { width: 52px; height: 52px; }
@keyframes orb-pulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent), 0 0 0 0 color-mix(in srgb, var(--accent) 30%, transparent); transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { box-shadow: 0 0 0 18px transparent, 0 0 0 34px transparent; transform: scale(1); }
}
.listen-card h2 { font-family: var(--serif); font-size: 1.7rem; margin: 0 0 10px; }
.listen-text {
    min-height: 2.6em;
    margin: 0 0 8px;
    font-size: 1.2rem; line-height: 1.45;
    color: var(--ink);
}
.listen-text.empty::before { content: "…"; color: var(--muted); }
.listen-hint { margin: 0 0 20px; color: var(--muted); font-size: .9rem; }
.listen-actions { display: flex; gap: 10px; justify-content: center; }
/* chyba: kruh zčervená a nepulzuje, rada je hlavní text */
.listen-overlay.is-error .listen-orb { background: var(--danger-soft); color: var(--danger); animation: none; }
.listen-overlay.is-error .listen-text { display: none; }
.listen-overlay.is-error .listen-hint { color: var(--ink-2); font-size: 1rem; line-height: 1.55; margin-bottom: 22px; }
.listen-actions .btn { padding: 11px 22px; font-size: 1rem; }
.listen-done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.listen-done:hover { filter: brightness(1.06); }

/* lišta "Planrix čte" nad polem pro psaní */
.speak-bar {
    max-width: var(--maxw);
    margin: 2px auto 10px;
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px 9px 16px;
    border-radius: 14px;
    background: var(--accent-soft);
    border: 1.5px solid var(--accent);
    color: var(--brand);
    font-weight: 600;
}
.speak-bar span:nth-child(2) { flex: 1; }
.speak-bar-wave { display: inline-flex; align-items: center; gap: 3px; height: 18px; }
.speak-bar-wave i { width: 3px; height: 100%; border-radius: 2px; background: var(--accent); animation: wave 1s infinite ease-in-out; }
.speak-bar-wave i:nth-child(2) { animation-delay: .15s; }
.speak-bar-wave i:nth-child(3) { animation-delay: .3s; }
.speak-bar-wave i:nth-child(4) { animation-delay: .45s; }
@keyframes wave { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
.speak-bar-stop {
    border: 0; border-radius: 10px;
    padding: 7px 14px;
    background: var(--accent); color: var(--accent-ink);
    font-weight: 700; cursor: pointer;
}

/* 🔊 u Planrixovy zprávy */
.msg-read {
    margin-left: 2px;
    width: 28px; height: 28px;
    display: inline-grid; place-items: center;
    border: 1px solid transparent; border-radius: 8px;
    background: none; color: var(--muted);
    cursor: pointer;
}
.msg-read svg { width: 17px; height: 17px; }
.msg-read:hover { color: var(--accent); border-color: var(--line); }
.msg-read.reading { color: var(--accent-ink); background: var(--accent); }

/* dialog Hlas a přednes */
.dialog-voice { width: min(520px, calc(100vw - 24px)); }
.field-label { display: block; margin: 16px 0 6px; font-weight: 700; color: var(--ink); font-size: .92rem; }
.field-select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--line); border-radius: 12px;
    background: var(--surface); color: var(--ink);
    font: inherit;
}
.field-select:focus { border-color: var(--accent); outline: none; }
.field-help { margin: 6px 0 0; font-size: .82rem !important; color: var(--muted) !important; }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; }
.preset {
    border: 1.5px solid var(--line); border-radius: 999px;
    padding: 7px 15px;
    background: var(--surface); color: var(--ink);
    font-weight: 600; cursor: pointer;
}
.preset:hover { border-color: var(--accent); }
.preset.active { border-color: var(--accent); background: var(--accent-soft); color: var(--brand); }
.slider-row {
    display: grid; grid-template-columns: 110px 1fr 64px;
    align-items: center; gap: 10px;
    margin-top: 12px;
    font-size: .9rem; color: var(--ink-2);
}
.slider-row input[type=range] { width: 100%; accent-color: var(--accent); }
.slider-row output { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.voice-dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.voice-dialog-actions .btn { padding: 10px 18px; font-size: .95rem; }

/* hlasový režim v hlavičce */
.btn-voice.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-voice.on:hover { color: var(--accent-ink); filter: brightness(1.06); }

.composer-meta {
    max-width: var(--maxw);
    margin: 6px auto 0;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
    gap: 4px 14px;
    font-size: .66rem;
    color: var(--muted);
    text-align: center;
}
.consent { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.consent input { accent-color: var(--accent); margin: 0; }
.consent-id { font-variant-numeric: tabular-nums; color: var(--ink-2); }
/* odkaz v patičce vypadá jako okolní text - jen při najetí podtržení */
.link-btn {
    background: none; border: 0; padding: 0;
    color: inherit; text-decoration: none;
    cursor: pointer; font: inherit;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- dialogy ---------- */

.dialog {
    width: min(620px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 24px 26px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
}
.dialog::backdrop { background: rgba(14, 20, 18, .5); }
.dialog h2 { font-family: var(--serif); margin: 0 34px 10px 0; font-size: 1.45rem; }
.dialog h3 { font-family: var(--serif); margin: 18px 0 6px; font-size: 1.05rem; color: var(--brand); }
.dialog p, .dialog li { color: var(--ink-2); font-size: .93rem; }
.dialog ul { padding-left: 1.2em; margin: 0; }
.dialog li { margin: 5px 0; }
.dialog a { color: var(--accent); }
.dialog-close-form { position: absolute; right: 12px; top: 10px; margin: 0; }
.dialog-close {
    border: 0; background: none; font-size: 1.6rem; line-height: 1;
    color: var(--muted); cursor: pointer; padding: 4px 9px; border-radius: 8px;
}
.dialog-close:hover { background: var(--surface-2); color: var(--ink); }
.dialog-meta { margin-top: 16px; font-size: .8rem !important; color: var(--muted) !important; }
.dialog h2:focus { outline: none; }
.dialog-kofi { width: min(460px, calc(100vw - 24px)); }
.btn-kofi-primary {
    display: flex; width: 100%; padding: 11px 16px; margin: 4px 0 12px;
    background: var(--gold); border-color: var(--gold); color: #fff;
    font-size: .95rem; text-decoration: none;
}
.btn-kofi-primary:hover { filter: brightness(1.06); }
.dialog .btn-kofi-primary { color: #fff; }
.kofi-frame { display: block; width: 100%; height: 540px; border: 0; border-radius: 12px; background: #f9f9f9; }

.noscript { position: fixed; inset: auto 0 0 0; padding: 12px; text-align: center; background: var(--danger-soft); color: var(--danger); }

/* ---------- 404 ---------- */

.notfound { margin: auto; padding: 32px 16px; text-align: center; }
.notfound h1 { font-family: var(--serif); }
.notfound a { color: var(--accent); }

/* ---------- mobil ---------- */

@media (max-width: 720px) {
    .brand-tag { display: none; }
    .actions .btn span { display: none; }
    .actions .btn-outline, .actions .btn-support { width: 36px; height: 36px; padding: 0; }
    .phases li:not(.current) .phase-label { display: none; }
    .quick-replies { gap: 6px; }
    .quick:not(.quick-scale) { flex: 1 1 auto; }
    .quick-scale { min-width: 28px; height: 46px; font-size: 1.05rem; border-radius: 10px; }
    .composer-meta { font-size: .64rem; }
    .import-card { grid-template-columns: auto 1fr; }
    .import-card .btn { grid-column: 1 / -1; }
    .msg-plan { padding: 14px 14px 10px; margin: 0 -6px; }
}

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

/* ---------- tisk finančního plánu ---------- */

@media print {
    :root { --ink: #000; --ink-2: #222; --line: #bbb; --surface: #fff; --surface-2: #f2f2f2; --brand: #0e3b31; --accent: #0b6b55; }
    body { display: block; background: #fff; color: #000; height: auto; }
    .topbar, .phases, .composer-wrap, .import-card, .msg-tools, .notice, .msg-typing, .dialog, .noscript, .listen-overlay, .msg-read { display: none !important; }
    .chat { overflow: visible; padding: 0; }
    .thread { padding: 0; display: block; max-width: none; }
    .msg { display: block; margin-bottom: 14px; }
    .msg-plan { box-shadow: none; border: 0; padding: 0; }
    .msg-user .msg-bubble { background: none; color: #000; font-style: italic; padding: 0; }
    body.printing .msg:not(.print-target) { display: none !important; }
    body.printing .msg-head { display: none; }
    .table-wrap { overflow: visible; }
    h2, h3 { break-after: avoid; }
    tr, li { break-inside: avoid; }
    .msg-content a::after { content: " (" attr(href) ")"; font-size: .85em; color: #444; }
}

/* souhrn konzultace */
.dialog-summary { width: min(560px, calc(100vw - 24px)); }
.summary-body { margin-top: 4px; }
.summary-body h2, .summary-body h3 { font-family: var(--serif); margin: 16px 0 6px; font-size: 1.05rem; color: var(--brand); }
.summary-body ul { padding-left: 1.2em; margin: 0; }
.summary-body li { margin: 6px 0; color: var(--ink-2); font-size: .95rem; }
.summary-loading, .summary-empty { color: var(--muted); font-size: .93rem; }
.summary-actions { margin-top: 14px; }

/* tabulka příjmů a výdajů */
.dialog-budget { width: min(680px, calc(100vw - 24px)); }
.budget-intro { margin: 0 0 6px; }
.budget-group h3 { margin: 16px 0 6px; }
.budget-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.4fr) 32px; gap: 6px; margin: 5px 0; align-items: center; }
.budget-row input { width: 100%; box-sizing: border-box; font: inherit; font-size: .9rem; padding: 7px 9px; border: 1px solid var(--line, #cfd8d4); border-radius: 8px; background: var(--surface, #fff); color: var(--ink); }
.budget-row input:focus { outline: none; border-color: var(--accent); }
.budget-row input.amount { text-align: right; }
.budget-row.edited input.name { border-left: 3px solid var(--accent); }
.budget-del { width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; cursor: pointer; border-radius: 8px; }
.budget-del:hover { background: var(--accent); color: var(--accent-ink); }
.budget-add { margin-top: 4px; font-size: .88rem; padding: 6px 12px; }
.budget-empty { color: var(--muted); font-size: .9rem; margin: 4px 0; }
.budget-totals { margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2, rgba(0,0,0,.04)); font-size: .93rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 18px; }
.budget-totals strong { color: var(--ink); }
.budget-totals .neg { color: var(--danger); }
.budget-status { margin-left: 10px; color: var(--muted); font-size: .9rem; }
@media (max-width: 560px) {
    .budget-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 32px; }
    .budget-row input.note { grid-column: 1 / 3; grid-row: 2; }
    .budget-row .budget-del { grid-row: 1; grid-column: 3; }
}

/* přiložené fotky */
.attach-strip { max-width: var(--maxw); margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.attach-thumb { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }
.attach-note { align-self: center; font-size: .82rem; color: var(--muted); }
.composer-attach { margin-right: -2px; }

/* otázka, na kterou má návštěvník odpovědět */
.msg-content p.ask {
    margin: 1.1em 0 0;
    padding: 12px 14px 12px 16px;
    border-left: 4px solid var(--accent);
    border-radius: 0 12px 12px 0;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    font-size: 1.08rem; line-height: 1.5; font-weight: 600; color: var(--ink);
}
.msg-content p.ask strong { font-weight: 700; }
