/* ===================================================
   CloudAura RAG — Editorial / Technical-Journal Theme
   Instrument Serif · IBM Plex Mono · IBM Plex Sans
   =================================================== */

:root {
    --bg:          #0c0b0a;
    --bg-raised:   #141312;
    --bg-surface:  #1a1918;
    --bg-input:    #1e1d1b;
    --amber:       #d4a245;
    --amber-dim:   rgba(212, 162, 69, 0.12);
    --amber-glow:  rgba(212, 162, 69, 0.06);
    --text:        #e8e4de;
    --text-2:      #a09a90;
    --text-3:      #6b665e;
    --green:       #5cb87a;
    --red:         #cf6565;
    --yellow:      #d4a245;
    --border:      #2a2724;
    --border-light:#1f1d1a;
    --radius:      6px;
    --max-w:       1080px;
}

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'IBM Plex Sans', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Grain overlay */
.grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px;
}

.hidden { display: none !important; }

/* ── Topbar ─────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(12, 11, 10, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
}

.topbar-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 32px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-mark {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    color: var(--amber);
    border: 1px solid var(--amber);
    padding: 2px 8px;
    border-radius: 3px;
}

.logo-divider {
    width: 1px;
    height: 18px;
    background: var(--border);
}

.logo-text {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: 0.88rem;
    color: var(--text-2);
    letter-spacing: 0.02em;
}

.topbar-links {
    display: flex;
    gap: 24px;
    margin-left: auto;
}

.topbar-links a {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    text-decoration: none;
    transition: color 0.2s;
}

.topbar-links a:hover {
    color: var(--text);
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 24px;
    flex-shrink: 0;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-3);
    transition: background 0.3s;
}

.status-dot.online { background: var(--green); box-shadow: 0 0 6px rgba(92, 184, 122, 0.4); }
.status-dot.degraded { background: var(--yellow); }
.status-dot.offline { background: var(--red); }

.status-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-3);
    letter-spacing: 0.04em;
}

/* ── Hero ───────────────────────────────────────── */
.hero {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

.hero-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 80px 32px 72px;
    position: relative;
    z-index: 1;
}

.hero-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--amber);
    margin-bottom: 24px;
}

.hero h1 {
    font-family: 'Instrument Serif', serif;
    font-size: clamp(2.4rem, 5vw, 3.6rem);
    font-weight: 400;
    line-height: 1.15;
    color: var(--text);
    margin-bottom: 20px;
}

.hero h1 em {
    font-style: italic;
    color: var(--amber);
}

.hero-desc {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-2);
    max-width: 560px;
    margin-bottom: 32px;
}

.hero-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-2);
    background: var(--amber-glow);
}

.hero-decoration {
    position: absolute;
    right: 5%;
    top: 50%;
    transform: translateY(-50%);
    width: 220px;
    height: 220px;
    opacity: 0.5;
    pointer-events: none;
}

.hero-svg {
    width: 100%;
    height: 100%;
    animation: hero-rotate 60s linear infinite;
}

@keyframes hero-rotate {
    to { transform: rotate(360deg); }
}

/* ── Sections ───────────────────────────────────── */
.section {
    padding: 72px 0;
}

.section-alt {
    background: var(--bg-raised);
}

.section-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 32px;
}

.section-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 32px;
}

.section-title {
    font-family: 'Instrument Serif', serif;
    font-size: 2rem;
    font-weight: 400;
    color: var(--text);
    margin-bottom: 40px;
}

.subsection-title {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    margin: 48px 0 20px;
}

/* ── Query Form ─────────────────────────────────── */
.query-layout {
    max-width: 720px;
}

.query-form {
    width: 100%;
}

.input-wrap textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.95rem;
    padding: 16px 18px;
    resize: vertical;
    transition: border-color 0.2s;
    line-height: 1.6;
}

.input-wrap textarea::placeholder {
    color: var(--text-3);
    font-style: italic;
}

.input-wrap textarea:focus {
    outline: none;
    border-color: var(--amber);
    box-shadow: 0 0 0 2px var(--amber-dim);
}

.input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    gap: 16px;
}

.topk-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--text-3);
    text-transform: uppercase;
}

.topk-label input[type="number"] {
    width: 52px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.82rem;
    padding: 5px 8px;
    text-align: center;
}

.topk-label input[type="number"]:focus {
    outline: none;
    border-color: var(--amber);
}

#ask-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1px solid var(--amber);
    color: var(--amber);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.76rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 10px 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

#ask-btn:hover {
    background: var(--amber);
    color: var(--bg);
}

#ask-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#ask-btn:disabled:hover {
    background: transparent;
    color: var(--amber);
}

.btn-arrow {
    font-size: 1.1rem;
    transition: transform 0.2s;
}

#ask-btn:hover .btn-arrow {
    transform: translateX(3px);
}

/* ── Loading ────────────────────────────────────── */
.loading {
    padding: 40px 0;
    text-align: center;
}

.loading-bar {
    width: 120px;
    height: 2px;
    background: var(--border);
    margin: 0 auto 16px;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    background: var(--amber);
    animation: loading-slide 1.2s ease-in-out infinite;
}

@keyframes loading-slide {
    0%   { left: -40%; }
    100% { left: 100%; }
}

.loading p {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-3);
    letter-spacing: 0.04em;
}

/* ── Error Panel ────────────────────────────────── */
.error-panel {
    background: rgba(207, 101, 101, 0.08);
    border: 1px solid rgba(207, 101, 101, 0.25);
    border-radius: var(--radius);
    padding: 16px 20px;
    color: var(--red);
    font-size: 0.88rem;
    margin-top: 20px;
}

/* ── Answer Panel ───────────────────────────────── */
.answer-panel {
    margin-top: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-raised);
    overflow: hidden;
}

.answer-meta-bar {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    background: var(--bg-surface);
}

.meta-chip {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    padding: 3px 10px;
    border-radius: 3px;
    background: var(--bg-input);
    color: var(--text-2);
    border: 1px solid var(--border-light);
}

.meta-chip.accent {
    color: var(--amber);
    border-color: rgba(212, 162, 69, 0.25);
    background: var(--amber-dim);
}

.answer-body {
    padding: 24px 20px;
}

.answer-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 12px;
}

.answer-text {
    color: var(--text);
    line-height: 1.8;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

/* ── Citations ──────────────────────────────────── */
.citations-section {
    border-top: 1px solid var(--border);
    padding: 20px;
}

.citations-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 16px;
}

.citation-grid {
    display: grid;
    gap: 10px;
}

.citation-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-left: 2px solid var(--amber);
    border-radius: 4px;
    padding: 14px 16px;
}

.citation-source {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    color: var(--amber);
    font-weight: 500;
    margin-bottom: 6px;
}

.citation-content {
    font-size: 0.84rem;
    color: var(--text-2);
    line-height: 1.55;
    max-height: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.citation-score {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    color: var(--text-3);
    margin-top: 8px;
}

/* ── Pipeline Track ─────────────────────────────── */
.pipeline-track {
    display: flex;
    align-items: stretch;
    gap: 0;
}

.pipeline-node {
    flex: 1;
    display: flex;
    gap: 14px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    opacity: 0;
    animation: node-in 0.5s ease forwards;
    animation-delay: calc(var(--delay) * 0.12s);
}

@keyframes node-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.node-index {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    color: var(--amber);
    font-weight: 600;
    flex-shrink: 0;
    padding-top: 2px;
}

.node-content h3 {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.node-content p {
    font-size: 0.78rem;
    color: var(--text-2);
    line-height: 1.5;
}

.pipeline-connector {
    width: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.pipeline-connector::after {
    content: '';
    width: 100%;
    height: 1px;
    background: var(--border);
}

/* ── Stats Row ──────────────────────────────────── */
.stats-row {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
}

.stat-block {
    flex: 1;
    min-width: 120px;
    padding: 20px 16px;
    text-align: center;
}

.stat-number {
    font-family: 'Instrument Serif', serif;
    font-size: 1.8rem;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1;
}

.stat-number.mono {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1.4;
    word-break: break-all;
}

.stat-desc {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
}

.stat-divider {
    width: 1px;
    height: 48px;
    background: var(--border);
    flex-shrink: 0;
}

/* ── Stack Table ────────────────────────────────── */
.stack-table {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.stack-row {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    gap: 16px;
}

.stack-row:last-child {
    border-bottom: none;
}

.stack-key {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    width: 140px;
    flex-shrink: 0;
}

.stack-val {
    flex: 1;
    font-size: 0.88rem;
    color: var(--text);
    font-weight: 500;
}

.stack-badge {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.04em;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-3);
    flex-shrink: 0;
}

/* ── Methods Table ──────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}

.methods-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.methods-table thead th {
    background: var(--bg-surface);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    font-weight: 500;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.methods-table tbody td {
    padding: 14px 16px;
    font-size: 0.85rem;
    color: var(--text-2);
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
}

.methods-table tbody tr:last-child td {
    border-bottom: none;
}

.method-name {
    font-weight: 600;
    color: var(--text) !important;
    white-space: nowrap;
}

.active-yes {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    color: var(--green);
    font-weight: 500;
}

.active-no {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-3);
    font-weight: 500;
}

.row-inactive td {
    opacity: 0.5;
}

/* ── Footer ─────────────────────────────────────── */
.footer {
    border-top: 1px solid var(--border);
    padding: 32px 0;
}

.footer-content {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--text-3);
}

.footer-brand {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    color: var(--text-2);
    letter-spacing: 0.04em;
}

.footer-sep {
    color: var(--border);
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 900px) {
    .pipeline-track {
        flex-direction: column;
    }

    .pipeline-connector {
        width: auto;
        height: 16px;
    }

    .pipeline-connector::after {
        width: 1px;
        height: 100%;
    }

    .stats-row {
        flex-wrap: wrap;
    }

    .stat-divider {
        display: none;
    }

    .stat-block {
        min-width: calc(33% - 8px);
    }

    .hero-decoration {
        display: none;
    }
}

@media (max-width: 640px) {
    .topbar-inner {
        padding: 0 16px;
    }

    .topbar-links {
        display: none;
    }

    .hero-inner {
        padding: 56px 16px 48px;
    }

    .section {
        padding: 48px 0;
    }

    .section-inner {
        padding: 0 16px;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .input-footer {
        flex-direction: column;
        align-items: stretch;
    }

    #ask-btn {
        justify-content: center;
    }

    .stat-block {
        min-width: calc(50% - 8px);
    }

    .stack-key {
        width: 100px;
    }
}
