:root {
    --bg: #fafafa;
    --card: #fff;
    --fg: #18181b;
    --muted: #71717a;
    --border: #e4e4e7;
    --accent: #18181b;
    --radius: 12px;
}
* {
    box-sizing: border-box;
}
html {
    scroll-behavior: smooth;
}
body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font:
        15px/1.6 Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        sans-serif;
}
body.modal-open {
    overflow: hidden;
}
.topbar {
    height: 58px;
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(250, 250, 250, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 14px;
}
.brand {
    font-weight: 750;
    color: var(--fg);
    text-decoration: none;
}
.brand span {
    font-weight: 450;
    color: var(--muted);
    margin-left: 7px;
}
#chat-toggle {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 7px;
}
.layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    max-width: 1600px;
    margin: auto;
    min-height: calc(100vh - 58px);
}
.sidebar {
    border-right: 1px solid var(--border);
    padding: 28px 18px;
    position: sticky;
    top: 58px;
    height: calc(100vh - 58px);
    overflow: auto;
}
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    margin: 0 10px 14px;
}
.nav-link {
    display: block;
    padding: 8px 10px;
    margin: 2px 0;
    border-radius: 8px;
    color: #3f3f46;
    text-decoration: none;
    font-size: 14px;
}
.nav-link:hover,
.nav-link.active {
    color: var(--fg);
    background: #f0f0f1;
    text-decoration: none;
}
main {
    padding: 44px clamp(24px, 5vw, 76px);
    min-width: 0;
}
main:focus {
    outline: none;
}
.status-card {
    min-height: 50vh;
    display: grid;
    place-content: center;
    text-align: center;
    color: var(--muted);
}
.markdown-body {
    max-width: 820px;
    margin: auto;
}
.markdown-body h2 {
    font-size: 2rem;
    letter-spacing: -0.03em;
    margin: 0 0 28px;
}
.markdown-body h3 {
    font-size: 1.35rem;
    margin-top: 38px;
    scroll-margin-top: 80px;
}
.markdown-body h4 {
    font-size: 1.05rem;
    margin-top: 30px;
    scroll-margin-top: 80px;
}
.markdown-body p,
.markdown-body li {
    color: #3f3f46;
}
.markdown-body a {
    color: #18181b;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.markdown-body table {
    width: 100%;
    display: block;
    overflow: auto;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 22px 0;
}
.markdown-body th,
.markdown-body td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    min-width: 140px;
}
.markdown-body tr:last-child td {
    border-bottom: 0;
}
.markdown-body th {
    background: #f4f4f5;
}
.markdown-body pre {
    background: #18181b;
    color: #fafafa;
    border-radius: var(--radius);
    padding: 16px;
    overflow: auto;
}
.markdown-body code {
    font-size: 0.88em;
}
.markdown-body blockquote {
    border-left: 3px solid #a1a1aa;
    padding-left: 18px;
    color: var(--muted);
}
.chat-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
}
.chat-modal[hidden] {
    display: none;
}
.chat-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(24, 24, 27, 0.58);
}
.chat-panel {
    position: relative;
    width: min(620px, 100%);
    height: min(760px, calc(100vh - 48px));
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--card);
    box-shadow: 0 24px 70px #0005;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-panel:focus {
    outline: none;
}
.chat-header {
    height: 70px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: none;
}
.chat-header small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.clear-chat-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    padding: 7px 9px;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.clear-chat-button:hover:not(:disabled) {
    background: #fef2f2;
    color: #b91c1c;
}
.clear-chat-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.icon-button {
    border: 0;
    background: transparent;
    border-radius: 8px;
    padding: 7px;
    color: var(--muted);
    cursor: pointer;
}
.icon-button:hover {
    background: #f4f4f5;
    color: var(--fg);
}
.icon-button:focus-visible,
.clear-chat-button:focus-visible,
#chat-toggle:focus-visible {
    outline: 2px solid var(--fg);
    outline-offset: 2px;
}
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 18px;
}
.chat-empty {
    text-align: center;
    color: var(--muted);
    padding: 50px 22px;
}
.message {
    max-width: 92%;
    padding: 10px 13px;
    border-radius: 12px;
    margin-bottom: 12px;
    overflow-wrap: anywhere;
}
.message.user {
    margin-left: auto;
    background: #18181b;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.message.assistant {
    background: #f4f4f5;
    border-bottom-left-radius: 4px;
}
.message.assistant p {
    margin: 0 0 8px;
}
.message.assistant p:last-child {
    margin-bottom: 0;
}
.message.assistant table {
    display: block;
    overflow: auto;
    border-collapse: collapse;
}
.message.assistant td,
.message.assistant th {
    border: 1px solid #d4d4d8;
    padding: 5px;
}
.chat-form {
    padding: 14px;
    border-top: 1px solid var(--border);
    flex: none;
}
.chat-form textarea {
    width: 100%;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}
.chat-form textarea:focus {
    border-color: #71717a;
    box-shadow: 0 0 0 3px #e4e4e7;
}
.chat-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 9px;
}
.chat-actions small {
    color: var(--muted);
}
.uk-button {
    border-radius: 9px;
    text-transform: none;
}
.uk-button-primary {
    background: #18181b;
}
.loading-message {
    color: var(--muted);
    display: flex;
    gap: 8px;
    align-items: center;
}
.mobile-only {
    display: none;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}
.uk-offcanvas-bar {
    background: #fff;
    color: var(--fg);
}
.uk-offcanvas-bar a {
    color: var(--fg);
}
@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 230px minmax(0, 1fr);
    }
}
@media (max-width: 720px) {
    .desktop-only {
        display: none;
    }
    .mobile-only {
        display: block;
    }
    .layout {
        display: block;
    }
    main {
        padding: 28px 18px;
    }
    .markdown-body h2 {
        font-size: 1.65rem;
    }
    .topbar {
        padding: 0 12px;
    }
    .markdown-body th,
    .markdown-body td {
        padding: 9px 10px;
    }
    .chat-modal {
        padding: 8px;
        align-items: end;
    }
    .chat-panel {
        width: 100%;
        height: min(720px, calc(100dvh - 16px));
        border-radius: 16px;
    }
    .chat-header {
        padding: 12px 14px;
    }
    .chat-messages {
        padding: 14px;
    }
    .chat-form {
        padding: 12px;
    }
}
