:root {
    --accent: #0c74ba; /* modrá z loga MARKtime */
    --accent-soft: #e8f2fa;
    --text: #1f2430;
    --muted: #6b7280;
    --border: #dfe2ea;
    --bg: #ffffff;
    --bg-side: #f7f8fb;
    --tree-width: 300px;
    --topbar-height: 56px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--accent);
}

/* ------------------------------------------------------------ horní lišta */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .04);
}

.brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

    .brand img {
        display: block;
        height: 24px;
        width: auto;
    }

.nav-toggle {
    display: none;
    background: none;
    border: 0;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
}

.search {
    position: relative;
    flex: 1;
    max-width: 640px;
    margin-left: auto;
    display: flex;
    gap: 6px;
}

    .search input {
        flex: 1;
        height: 36px;
        padding: 0 12px;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--bg-side);
        font: inherit;
    }

        .search input:focus {
            outline: none;
            border-color: var(--accent);
            background: #fff;
            box-shadow: 0 0 0 3px var(--accent-soft);
        }

    .search > button {
        height: 36px;
        padding: 0 14px;
        border: 0;
        border-radius: 6px;
        background: var(--accent);
        color: #fff;
        font: inherit;
        cursor: pointer;
    }

.search-results {
    position: absolute;
    top: 42px;
    left: 0;
    right: 0;
    max-height: 70vh;
    overflow: auto;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .15);
}

    .search-results a {
        display: block;
        padding: 10px 14px;
        border-bottom: 1px solid var(--border);
        color: inherit;
        text-decoration: none;
    }

        .search-results a:hover, .search-results a:focus {
            background: var(--accent-soft);
            outline: none;
        }

    .search-results .hit-title {
        font-weight: 600;
        color: var(--accent);
    }

    .search-results .hit-crumb {
        font-size: 12px;
        color: var(--muted);
    }

    .search-results .hit-snippet {
        font-size: 13px;
        margin-top: 2px;
    }

    .search-results .note {
        padding: 10px 14px;
        font-size: 13px;
        color: var(--muted);
        background: #fffbea;
    }

/* ------------------------------------------------------- přepínač AI / Bez AI */

.ai-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    font-size: 13px;
    color: var(--muted);
}

    .ai-toggle input {
        position: absolute;
        opacity: 0;
        width: 1px;
        height: 1px;
    }

.ai-track {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: 11px;
    background: #c9ced8;
    transition: background .15s;
}

.ai-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: left .15s;
}

.ai-toggle input:checked + .ai-track {
    background: var(--accent);
}

    .ai-toggle input:checked + .ai-track .ai-thumb {
        left: 19px;
    }

.ai-toggle input:focus-visible + .ai-track {
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.ai-label {
    min-width: 44px;
}

body.ai-mode .ai-label {
    color: var(--accent);
    font-weight: 600;
}

.ai-toggle + .search {
    margin-left: 0;
}

body.ai-mode .search input {
    border-color: var(--accent);
}

/* ------------------------------------------------------------- AI odpověď */

.ai-box {
    padding: 12px 16px 14px;
}

.ai-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--accent);
    margin-bottom: 6px;
}

.ai-close {
    border: 0;
    background: none;
    font-size: 20px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 2px;
}

    .ai-close:hover {
        color: var(--text);
    }

.ai-answer {
    font-size: 14px;
}

    .ai-answer p {
        margin: 0 0 8px;
    }

    .ai-answer ol, .ai-answer ul {
        margin: 0 0 8px;
        padding-left: 22px;
    }

    .ai-answer li {
        margin: 2px 0;
    }

.ai-wait {
    color: var(--muted);
    font-style: italic;
}

.search-results a.ai-cite {
    display: inline-block;
    min-width: 16px;
    padding: 0 4px;
    margin: 0 1px;
    border: 0;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
    vertical-align: 2px;
}

    .search-results a.ai-cite:hover {
        background: var(--accent);
        color: #fff;
    }

.ai-sources {
    margin-top: 10px;
    border-top: 1px solid var(--border);
}

.ai-sources-title {
    font-size: 12px;
    color: var(--muted);
    padding: 8px 0 2px;
}

.ai-sources a {
    padding: 6px 4px;
}

    .ai-sources a:last-child {
        border-bottom: 0;
    }

.ai-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
}

    .ai-rating button {
        border: 1px solid var(--border);
        background: #fff;
        border-radius: 6px;
        padding: 2px 8px;
        cursor: pointer;
        font-size: 15px;
    }

        .ai-rating button:hover {
            background: var(--accent-soft);
        }

/* ----------------------------------------------------------------- rozvržení */

.layout {
    display: grid;
    grid-template-columns: var(--tree-width) minmax(0, 1fr);
    min-height: calc(100vh - var(--topbar-height));
}

.tree {
    position: sticky;
    top: var(--topbar-height);
    height: calc(100vh - var(--topbar-height));
    overflow: auto;
    padding: 16px 10px 40px 6px;
    background: var(--bg-side);
    border-right: 1px solid var(--border);
    font-size: 14px;
}

    .tree ul {
        list-style: none;
        margin: 0;
        padding-left: 14px;
    }

    .tree > ul {
        padding-left: 18px;
    }

    .tree li {
        margin: 1px 0;
    }

    .tree summary {
        cursor: pointer;
        list-style-position: outside;
    }

    .tree a, .tree .tree-label {
        display: inline-block;
        padding: 2px 6px;
        border-radius: 4px;
        color: var(--text);
        text-decoration: none;
    }

        .tree a:hover, .tree summary:hover .tree-label {
            background: var(--accent-soft);
        }

        .tree a.current, .tree .tree-label.current {
            background: var(--accent);
            color: #fff;
        }

    .tree .node-document > details > summary .tree-label {
        font-weight: 700;
        user-select: none;
    }

    .tree .node-section > details > summary .tree-label {
        font-weight: 600;
        user-select: none;
    }

.content {
    padding: 28px 40px 60px;
    max-width: 1120px;
}

.breadcrumb {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
}

    .breadcrumb a {
        color: var(--muted);
        text-decoration: none;
    }

        .breadcrumb a:hover {
            text-decoration: underline;
        }

    .breadcrumb .sep {
        margin: 0 6px;
    }

/* ----------------------------------------------------------------- obsah */

.note h1 {
    font-size: 28px;
    margin: 0 0 18px;
    color: #16204f;
}

.note h2 {
    font-size: 21px;
    margin: 32px 0 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
    color: #16204f;
}

.note h3 {
    font-size: 17px;
    margin: 24px 0 8px;
}

.note :target {
    scroll-margin-top: calc(var(--topbar-height) + 12px);
    background: #fff7d1;
}

.note table {
    border-collapse: collapse;
    margin: 12px 0 18px;
    font-size: 14px;
}

.note th, .note td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
}

.note th {
    background: var(--bg-side);
}

.note kbd {
    font-family: Consolas, monospace;
    font-size: 12px;
    padding: 1px 6px;
    border: 1px solid #c3c8d4;
    border-bottom-width: 2px;
    border-radius: 4px;
    background: #f5f6f9;
}

.note code {
    font-family: Consolas, monospace;
    font-size: 13px;
    background: #f1f2f6;
    padding: 1px 4px;
    border-radius: 3px;
}

.help-figure {
    margin: 16px 0 8px;
}

    .help-figure img {
        cursor: zoom-in;
        max-width: 100%;
        height: auto;
        border: 1px solid var(--border);
        border-radius: 4px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
    }

.note img[src^="http"] {
    height: 16px;
    vertical-align: -3px;
    margin-right: 4px;
}

/* callouty */
.callout {
    border-left: 4px solid var(--accent);
    background: var(--accent-soft);
    padding: 10px 14px;
    margin: 14px 0;
    border-radius: 0 6px 6px 0;
}

.callout-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.callout-content > :last-child {
    margin-bottom: 0;
}

.callout-tip {
    border-color: #1a9a6a;
    background: #eef8f3;
}

.callout-warning, .callout-caution, .callout-danger {
    border-color: #d0821a;
    background: #fdf5ea;
}

.callout-important {
    border-color: #c03a3a;
    background: #fbeeee;
}

/* sbalené popisy obrázků – pro vyhledávání, čtenáři je mají schované */
details.callout {
    background: transparent;
    border-left-color: var(--border);
    padding: 4px 12px;
    margin-top: 0;
    font-size: 13px;
    color: var(--muted);
}

    details.callout > summary {
        cursor: pointer;
        font-weight: 400;
    }

    details.callout[open] {
        background: var(--bg-side);
    }

.children {
    padding-left: 20px;
}

    .children li {
        margin: 4px 0;
    }

.pager {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 48px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

    .pager a {
        text-decoration: none;
    }

    .pager .next {
        margin-left: auto;
        text-align: right;
    }

/* ----------------------------------------------------------------- mobil */

@media (max-width: 860px) {
    .nav-toggle {
        display: block;
    }

    .brand img {
        height: 20px;
    }

    .topbar {
        gap: 10px;
        padding: 0 12px;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .tree {
        display: none;
        position: fixed;
        z-index: 15;
        width: 85%;
        max-width: 340px;
        box-shadow: 4px 0 20px rgba(0, 0, 0, .15);
    }

    body.nav-open .tree {
        display: block;
    }

    .content {
        padding: 20px 16px 48px;
    }
}

/* zvětšení obrázku po kliknutí */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 20, 35, .85);
    cursor: zoom-out;
}

    .lightbox img {
        max-width: 100%;
        max-height: 100%;
        background: #fff;
        border-radius: 4px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, .4);
    }

/* --------------------------------------------------------- historie dotazů */

.search .history-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 9px;
    background: var(--bg-side);
    color: var(--muted);
    border: 1px solid var(--border);
}

    .search .history-button:hover {
        color: var(--accent);
        border-color: var(--accent);
    }

.history-title {
    padding: 10px 14px 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.history-mode {
    display: inline-block;
    min-width: 54px;
    margin-right: 4px;
    padding: 0 6px;
    border-radius: 8px;
    background: var(--bg-side);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    vertical-align: 1px;
}

    .history-mode.is-ai {
        background: var(--accent-soft);
        border-color: transparent;
        color: var(--accent);
    }

.search-results .history-item .hit-title {
    color: var(--text);
    font-weight: 500;
}

.search .history-clear {
    display: block;
    width: 100%;
    height: auto;
    padding: 8px 14px;
    border: 0;
    border-radius: 0;
    background: none;
    color: var(--muted);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}

    .search .history-clear:hover {
        color: #b42318;
    }
