:root {
    --bg: #0b0f14;
    --surface: #141a22;
    --surface-2: #1c2530;
    --border: #2a3542;
    --text: #d6dde6;
    --muted: #8b98a8;
    --accent: #ff6a00;
    --accent-hover: #ff8533;
    --error: #e06c75;
    --hit: #98c379;
    --topbar-height: 2.75rem;
    --footer-height: 1.75rem;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    color-scheme: dark;
    font-family: "IBM Plex Mono", "Cascadia Mono", "Consolas", ui-monospace, monospace;
    font-size: 13px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

button,
input,
textarea {
    font: inherit;
}

input[type="checkbox"] {
    accent-color: var(--accent);
}

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

.page {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--topbar-height);
    padding: 0 0.75rem;
    border-bottom: 2px solid var(--accent);
    background: var(--surface);
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.04em;
    color: var(--accent);
}

.brand:hover {
    color: var(--accent-hover);
}

.topbar .user {
    margin-left: auto;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 2rem;
    height: 2rem;
    padding: 0.4rem;
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 4px;
    cursor: pointer;
}

.hamburger span {
    display: block;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

.hamburger:hover {
    border-color: var(--accent);
}

.hamburger:hover span {
    background: var(--accent);
}

.shell {
    flex: 1;
    display: flex;
    min-height: 0;
}

.sidebar {
    width: 14.5rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.55rem 0.45rem;
    gap: 0.15rem;
}

.sidebar .nav-group {
    padding: 0.75rem 0.65rem 0.2rem;
    color: var(--muted);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar nav a {
    color: var(--text);
    padding: 0.5rem 0.65rem;
    border-radius: 4px;
    border-left: 2px solid transparent;
}

.sidebar nav a:hover {
    background: var(--surface-2);
    color: var(--accent);
}

.sidebar nav a.active {
    color: #0b0f14;
    border-left-color: var(--accent);
    background: var(--accent);
}

.sidebar nav a.nav-external {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sidebar .nav-external-icon {
    width: 0.85rem;
    height: 0.85rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar .logout {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
}

.sidebar .logout:hover {
    color: var(--accent);
}

.nav-backdrop {
    display: none;
}

main {
    flex: 1;
    min-width: 0;
    overflow: auto;
    padding: 0.75rem 1rem 1.5rem;
}

.footer {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    height: var(--footer-height);
    padding: 0 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 840px) {
    .page.nav-toggled .sidebar {
        width: 0;
        border-right: 0;
    }
}

@media (max-width: 839px) {
    .sidebar {
        position: fixed;
        top: var(--topbar-height);
        bottom: var(--footer-height);
        left: 0;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform 0.18s ease;
    }

    .page.nav-toggled .sidebar {
        transform: none;
    }

    .page.nav-toggled .nav-backdrop {
        display: block;
        position: fixed;
        inset: var(--topbar-height) 0 var(--footer-height) 0;
        z-index: 15;
        margin: 0;
        padding: 0;
        border: 0;
        background: rgba(0, 0, 0, 0.55);
        cursor: pointer;
    }
}

.not-authorized {
    color: var(--muted);
}

.toolbar {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    margin-bottom: 0.75rem;
    color: var(--muted);
}

.query-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.query-table th,
.query-table td {
    text-align: left;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.query-table .col-time {
    width: calc(12ch + 1rem);
}

.query-table .col-cache {
    width: calc(5ch + 1rem);
}

.query-table .col-source {
    width: calc(6ch + 1rem);
}

.query-table th {
    color: var(--muted);
    font-weight: 600;
    position: sticky;
    top: 0;
    background: var(--bg);
}

.query-table .col-wrap {
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.query-table .col-answers {
    width: 28%;
}

.query-table tr.error td {
    color: var(--error);
}

.query-table tbody tr:hover {
    background: var(--surface);
}

.settings {
    max-width: 52rem;
}

.settings h1 {
    font-size: 1.15rem;
    margin: 0 0 1rem;
}

.settings h2 {
    font-size: 0.95rem;
    margin: 0 0 0.6rem;
    color: var(--accent);
}

.settings section {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.settings label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.65rem;
    color: var(--muted);
}

.settings label.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
}

.settings input,
.settings select,
.settings textarea {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.4rem 0.5rem;
}

.settings input:focus,
.settings select:focus,
.settings textarea:focus {
    border-color: var(--accent);
}

.settings .card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.settings button {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.35rem 0.7rem;
    cursor: pointer;
}

.settings button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.settings button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--bg);
}

.settings button.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--bg);
}

.settings button.danger {
    color: var(--error);
    border-color: var(--error);
}

.settings button.danger:hover {
    background: var(--surface-2);
}

.form-error {
    color: var(--error);
}

.form-saved {
    color: var(--hit);
}

.components-reconnect-first-attempt-visible,
.components-reconnect-repeated-attempt-visible,
.components-reconnect-failed-visible,
.components-pause-visible,
.components-resume-failed-visible,
.components-rejoining-animation {
    display: none;
}

#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible {
    display: block;
}

#components-reconnect-modal {
    background: var(--surface);
    color: var(--text);
    width: 20rem;
    margin: 20vh auto;
    padding: 1.5rem 1.25rem;
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 0.5rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: display 0.5s allow-discrete, overlay 0.5s allow-discrete;
    animation: components-reconnect-modal-fadeOutOpacity 0.5s both;
}

#components-reconnect-modal[open] {
    animation: components-reconnect-modal-slideUp 1.5s cubic-bezier(.05, .89, .25, 1.02) 0.3s,
        components-reconnect-modal-fadeInOpacity 0.5s ease-in-out 0.3s;
    animation-fill-mode: both;
}

#components-reconnect-modal::backdrop {
    background-color: rgba(10, 8, 6, 0.72);
    animation: components-reconnect-modal-fadeInOpacity 0.5s ease-in-out;
    opacity: 1;
}

@keyframes components-reconnect-modal-slideUp {
    0% {
        transform: translateY(30px) scale(0.95);
    }

    100% {
        transform: translateY(0);
    }
}

@keyframes components-reconnect-modal-fadeInOpacity {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

@keyframes components-reconnect-modal-fadeOutOpacity {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.components-reconnect-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#components-reconnect-modal p {
    margin: 0;
    text-align: center;
    color: var(--muted);
}

#components-reconnect-modal button {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--bg);
    padding: 0.4rem 1.25rem;
    border-radius: 4px;
    cursor: pointer;
}

#components-reconnect-modal button:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.components-rejoining-animation {
    position: relative;
    width: 80px;
    height: 80px;
}

.components-rejoining-animation div {
    position: absolute;
    border: 3px solid var(--accent);
    opacity: 1;
    border-radius: 50%;
    animation: components-rejoining-animation 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.components-rejoining-animation div:nth-child(2) {
    animation-delay: -0.5s;
}

@keyframes components-rejoining-animation {
    0% {
        top: 40px;
        left: 40px;
        width: 0;
        height: 0;
        opacity: 0;
    }

    4.9% {
        top: 40px;
        left: 40px;
        width: 0;
        height: 0;
        opacity: 0;
    }

    5% {
        top: 40px;
        left: 40px;
        width: 0;
        height: 0;
        opacity: 1;
    }

    100% {
        top: 0;
        left: 0;
        width: 80px;
        height: 80px;
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    #components-reconnect-modal,
    #components-reconnect-modal::backdrop,
    .components-rejoining-animation div {
        animation: none;
        transition: none;
    }

    #components-reconnect-modal[open] {
        opacity: 1;
    }
}

.landing {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-size: 16px;
    line-height: 1.55;
}

.landing-topbar {
    display: flex;
    align-items: center;
    height: 2.75rem;
    padding: 0 1.25rem;
    border-bottom: 2px solid var(--accent);
    background: var(--surface);
}

.landing-main {
    width: min(42rem, calc(100% - 2.5rem));
    margin: 0 auto;
    padding: 3.5rem 0 4rem;
    flex: 1;
}

.landing h1 {
    margin: 0 0 1rem;
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.landing .lead {
    margin: 0;
    color: var(--muted);
    font-size: 1.05rem;
}

.landing h2 {
    margin: 2.75rem 0 0.75rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

.landing-resolvers {
    display: grid;
    gap: 0.75rem;
}

@media (min-width: 720px) {
    .landing-resolvers {
        grid-template-columns: 1fr 1fr;
    }
}

.landing-resolver {
    margin: 0;
    padding: 1rem 1rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
}

.landing-resolver h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    font-weight: 700;
}

.landing-resolver dl {
    margin: 0;
}

.landing-resolver div {
    display: grid;
    grid-template-columns: 4.5rem 1fr;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.35rem;
}

.landing-resolver dt {
    color: var(--muted);
}

.landing-resolver dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.landing-protocols {
    margin: 0.85rem 0 0;
    padding: 0.75rem 0 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.85rem;
}

.landing-footer {
    padding: 0.85rem 1.25rem 1.25rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
}

.landing-footer .landing-coffee {
    display: inline-block;
}

.landing-footer .landing-coffee img {
    display: block;
}

.landing-legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin: 0.85rem 0 0;
}

.landing-legal > * {
    padding: 0 0.7rem;
    line-height: 1.4;
}

.landing-legal > * + * {
    border-left: 1px solid var(--border);
}
