/* Styling for the KBase viewer, matching index.html and the documentation pages. */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --blue-900: #0a1628;
    --blue-700: #112952;
    --blue-600: #1a3a6e;
    --blue-500: #1e4d9b;
    --blue-400: #2563eb;
    --blue-300: #3b82f6;
    --blue-100: #dbeafe;
    --blue-50: #eff6ff;
    --accent: #38bdf8;
    --white: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --card-bg: #ffffff;
    --card-border: #bfdbfe;
    --shadow: 0 2px 12px 0 rgba(30,77,155,0.10);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--blue-50);
    color: var(--text);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.hero {
    background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-700) 60%, var(--blue-500) 100%);
    color: var(--white);
    padding: 1.5rem;
    text-align: center;
}

.site-title {
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.site-subtitle {
    font-size: 0.8rem;
    opacity: 0.75;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

main {
    flex: 1;
    padding: 1.25rem;
}

footer {
    background: var(--blue-900);
    color: var(--blue-100);
    text-align: center;
    padding: 1rem;
    font-size: 0.85rem;
}

    footer a {
        color: var(--accent);
        text-decoration: none;
    }

/* ── Forms and messages ─────────────────────────────────────── */
.field {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

    .field label {
        font-weight: 600;
        font-size: 0.9rem;
        margin-bottom: 0.3rem;
    }

input[type="password"],
input[type="text"],
select,
textarea {
    font: inherit;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    background: var(--white);
    color: var(--text);
}

button {
    font: inherit;
    font-weight: 600;
    background: var(--blue-400);
    color: var(--white);
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.2rem;
    cursor: pointer;
}

    button:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

    button.secondary {
        background: var(--blue-100);
        color: var(--blue-700);
    }

.hint {
    font-size: 0.8rem;
    color: var(--muted);
}

.msg {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

    .msg:empty {
        display: none;
    }

    .msg.error {
        color: #b91c1c;
    }

    .msg.success {
        color: #15803d;
    }

    .msg.info {
        color: var(--blue-500);
    }

/* ── Setup dialog ───────────────────────────────────────────── */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10,22,40,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 10;
    overflow: auto;
}

    .dialog-backdrop[hidden] {
        display: none;
    }

.dialog {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 1.75rem;
    max-width: 32rem;
    width: 100%;
}

    .dialog h1 {
        font-size: 1.3rem;
        margin-bottom: 0.5rem;
    }

.intro {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

    .intro a {
        color: var(--blue-400);
    }

/* ── Panes ──────────────────────────────────────────────────── */
.panes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    max-width: 1500px;
    margin: 0 auto;
}

@media (max-width: 900px) {
    .panes {
        grid-template-columns: 1fr;
    }
}

.pane {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 70vh;
}

.pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

    .pane-head h2 {
        font-size: 1.05rem;
    }

.pane-actions {
    display: flex;
    gap: 0.5rem;
}

    .pane-actions button {
        padding: 0.35rem 0.8rem;
        font-size: 0.85rem;
    }

/* ── Graph ──────────────────────────────────────────────────── */
.graph-host {
    position: relative;
    flex: 1;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--blue-50);
}

#graph {
    width: 100%;
    height: 100%;
    min-height: 55vh;
}

.waiting {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--blue-500);
}

    .waiting[hidden] {
        display: none;
    }

.graph-host .waiting {
    position: absolute;
    inset: 0;
    justify-content: center;
    background: rgba(239,246,255,0.85);
}

.spinner {
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid var(--blue-100);
    border-top-color: var(--blue-400);
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 3s;
    }
}

/* ── Chat ───────────────────────────────────────────────────── */
.chat-log {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.75rem;
    background: var(--blue-50);
    min-height: 45vh;
}

.bubble {
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.6rem;
    max-width: 90%;
    font-size: 0.92rem;
    overflow-wrap: anywhere;
}

    .bubble.user {
        background: var(--blue-400);
        color: var(--white);
        margin-left: auto;
    }

    .bubble.assistant {
        background: var(--white);
        border: 1px solid var(--card-border);
    }

    .bubble.error {
        background: #fef2f2;
        border: 1px solid #fecaca;
        color: #b91c1c;
    }

    .bubble p {
        margin-bottom: 0.5rem;
    }

    .bubble p:last-child,
    .bubble ul:last-child,
    .bubble ol:last-child,
    .bubble pre:last-child {
        margin-bottom: 0;
    }

    .bubble h1, .bubble h2, .bubble h3, .bubble h4, .bubble h5, .bubble h6 {
        font-size: 1rem;
        margin-bottom: 0.35rem;
    }

    .bubble ul, .bubble ol {
        margin: 0 0 0.5rem 1.1rem;
    }

    .bubble code {
        font-family: 'Consolas', 'Menlo', monospace;
        font-size: 0.85em;
        background: var(--blue-100);
        border-radius: 4px;
        padding: 0.05rem 0.25rem;
    }

    .bubble pre {
        background: var(--blue-900);
        color: var(--blue-100);
        border-radius: 8px;
        padding: 0.6rem;
        overflow-x: auto;
        margin-bottom: 0.5rem;
    }

        .bubble pre code {
            background: none;
            color: inherit;
            padding: 0;
        }

    .bubble.user a {
        color: var(--white);
    }

    .bubble a {
        color: var(--blue-400);
    }

#chat-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

#chat-input {
    flex: 1;
    resize: vertical;
}
