:root {
    --background: #f6f8fb;
    --surface: #ffffff;
    --surface-muted: #f9fafb;
    --border: #e5e7eb;
    --border-strong: #d1d5db;

    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #eff6ff;

    --success: #15803d;
    --success-soft: #f0fdf4;

    --warning: #b45309;
    --warning-soft: #fffbeb;

    --danger: #b91c1c;
    --danger-soft: #fef2f2;

    --shadow-sm:
        0 1px 2px rgba(15, 23, 42, 0.05);

    --shadow-md:
        0 10px 30px rgba(15, 23, 42, 0.07);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;

    --page-width: 1180px;
}


/* ---------------------------------
   Base
---------------------------------- */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(
            180deg,
            #f8fafc 0%,
            var(--background) 100%
        );
    color: var(--text-primary);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    line-height: 1.6;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3 {
    line-height: 1.2;
}

.hidden {
    display: none !important;
}


/* ---------------------------------
   Header
---------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgba(229, 231, 235, 0.85);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(14px);
}

.header-content {
    width: min(
        calc(100% - 40px),
        var(--page-width)
    );
    min-height: 70px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--text-primary);
    color: #ffffff;
    font-size: 0.88rem;
    letter-spacing: -0.04em;
    box-shadow: var(--shadow-sm);
}

.brand-text {
    font-size: 1rem;
}

.header-label {
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 650;
}


/* ---------------------------------
   Page and hero
---------------------------------- */

.page-container {
    width: min(
        calc(100% - 40px),
        var(--page-width)
    );
    margin: 0 auto;
    padding: 68px 0 80px;
}

.hero-section {
    max-width: 820px;
    margin-bottom: 34px;
}

.eyebrow {
    margin-bottom: 10px;
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.hero-section h1 {
    max-width: 800px;
    margin-bottom: 18px;
    font-size: clamp(
        2.4rem,
        6vw,
        4.8rem
    );
    letter-spacing: -0.055em;
}

.hero-description {
    max-width: 760px;
    margin-bottom: 0;
    color: var(--text-secondary);
    font-size: 1.08rem;
}


/* ---------------------------------
   Shared cards and headings
---------------------------------- */

.card,
.stat-card {
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.card {
    border-radius: var(--radius-lg);
    padding: 28px;
}

.section-heading-row,
.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.section-heading-row h2,
.panel-heading h2,
.repository-section h2 {
    margin-bottom: 0;
    font-size: 1.35rem;
    letter-spacing: -0.025em;
}

.section-description,
.repository-subtitle,
.form-hint,
.relevant-files-heading p,
.stat-description {
    color: var(--text-muted);
}

.section-description {
    margin-bottom: 0;
}

.panel-heading {
    margin-bottom: 24px;
}


/* ---------------------------------
   Repository form
---------------------------------- */

.repository-section {
    margin-bottom: 34px;
}

.repository-form-heading {
    margin-bottom: 24px;
}

.repository-form-heading h2 {
    margin-bottom: 8px;
}

label {
    display: inline-block;
    margin-bottom: 9px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 700;
}

.input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}

input {
    min-height: 48px;
    padding: 0 15px;
}

textarea {
    min-height: 150px;
    padding: 14px 15px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #9ca3af;
}

input:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow:
        0 0 0 4px rgba(37, 99, 235, 0.12);
}

.primary-button {
    min-height: 48px;
    padding: 0 20px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #ffffff;
    font-weight: 750;
    box-shadow:
        0 8px 18px rgba(37, 99, 235, 0.18);
    transition:
        transform 0.15s ease,
        background 0.2s ease,
        box-shadow 0.2s ease;
}

.primary-button:hover {
    background: var(--accent-hover);
    box-shadow:
        0 10px 22px rgba(37, 99, 235, 0.24);
    transform: translateY(-1px);
}

.primary-button:active {
    transform: translateY(0);
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
    transform: none;
}

.full-width-button {
    width: 100%;
    margin-top: 10px;
}

.status-message {
    min-height: 24px;
    margin: 16px 0 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 650;
}


/* ---------------------------------
   Workspace
---------------------------------- */

.workspace {
    display: grid;
    gap: 24px;
}

.repository-header-card {
    background:
        linear-gradient(
            135deg,
            #ffffff 0%,
            #f8fbff 100%
        );
}

.repository-subtitle {
    max-width: 650px;
    margin: 10px 0 0;
}

.status-badge,
.confidence-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
}

.status-badge {
    padding: 8px 12px;
    border: 1px solid #bbf7d0;
    background: var(--success-soft);
    color: var(--success);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(
        4,
        minmax(0, 1fr)
    );
    gap: 16px;
}

.stat-card {
    border-radius: var(--radius-md);
    padding: 20px;
}

.stat-label {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stat-value {
    margin-bottom: 6px;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.stat-description {
    margin-bottom: 0;
    font-size: 0.86rem;
}


/* ---------------------------------
   Overview and question panels
---------------------------------- */

.workspace-grid {
    display: grid;
    grid-template-columns:
        minmax(0, 1.55fr)
        minmax(320px, 0.85fr);
    gap: 24px;
    align-items: start;
}

.repository-overview,
.question-panel {
    min-width: 0;
}

.question-panel {
    position: sticky;
    top: 94px;
}

.repository-summary {
    display: grid;
    gap: 18px;
}

.repository-summary section {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
}

.repository-summary section h3 {
    margin-bottom: 8px;
    font-size: 0.98rem;
}

.repository-summary section p,
.repository-summary section ul {
    margin-bottom: 0;
    color: var(--text-secondary);
}

.repository-summary section ul {
    padding-left: 20px;
}

.repository-summary section li + li {
    margin-top: 5px;
}

.form-hint {
    margin: 10px 0 0;
    font-size: 0.84rem;
}


/* ---------------------------------
   Answer panel
---------------------------------- */

.answer-panel {
    min-width: 0;
}

.answer-heading {
    margin-bottom: 22px;
}

.confidence-badge {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.answer-content {
    min-height: 150px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.answer-content.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
}

.relevant-files {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.relevant-files-heading {
    margin-bottom: 14px;
}

.relevant-files-heading h3 {
    margin-bottom: 5px;
    font-size: 1rem;
}

.relevant-files-heading p {
    margin-bottom: 0;
    font-size: 0.86rem;
}

.relevant-files ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.relevant-files li {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text-secondary);
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        monospace;
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}

.relevant-files li::before {
    content: "⌘";
    margin-right: 7px;
    color: var(--accent);
    font-family: inherit;
}


/* ---------------------------------
   Confidence states
---------------------------------- */

.confidence-badge.high {
    border-color: #bbf7d0;
    background: var(--success-soft);
    color: var(--success);
}

.confidence-badge.medium {
    border-color: #fde68a;
    background: var(--warning-soft);
    color: var(--warning);
}

.confidence-badge.low {
    border-color: #fecaca;
    background: var(--danger-soft);
    color: var(--danger);
}


/* ---------------------------------
   Footer
---------------------------------- */

.site-footer {
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.75);
}

.footer-content {
    width: min(
        calc(100% - 40px),
        var(--page-width)
    );
    min-height: 110px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.footer-content p {
    margin-bottom: 0;
}


/* ---------------------------------
   Responsive
---------------------------------- */

@media (max-width: 940px) {
    .stats-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .question-panel {
        position: static;
    }
}

@media (max-width: 680px) {
    .header-content,
    .page-container,
    .footer-content {
        width: min(
            calc(100% - 24px),
            var(--page-width)
        );
    }

    .page-container {
        padding-top: 44px;
    }

    .header-label {
        display: none;
    }

    .brand-text {
        font-size: 0.92rem;
    }

    .hero-section h1 {
        font-size: 2.45rem;
    }

    .input-row {
        grid-template-columns: 1fr;
    }

    .primary-button {
        width: 100%;
    }

    .card {
        padding: 22px;
        border-radius: var(--radius-md);
    }

    .section-heading-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .footer-content {
        padding: 28px 0;
        flex-direction: column;
        align-items: flex-start;
    }
}


/* ---------------------------------
   Evidence strength
---------------------------------- */

.evidence-strength {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: end;
    gap: 6px 8px;
    max-width: 360px;
}

.evidence-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 750;
}

.evidence-reason {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.45;
    text-align: right;
}

@media (max-width: 680px) {
    .evidence-strength {
        justify-content: start;
        max-width: 100%;
    }

    .evidence-reason {
        text-align: left;
    }
}