:root {
    --bg-0: #f2efe8;
    --bg-1: #fffaf0;
    --ink-0: #1e2328;
    --ink-1: #52606d;
    --brand-0: #0f7a6a;
    --brand-1: #0c5f53;
    --warn: #b25f1f;
    --error: #9f3131;
    --ok: #1f7a46;
    --card: rgba(255, 255, 255, 0.78);
    --border: rgba(19, 35, 49, 0.12);
    --shadow: 0 14px 40px rgba(17, 38, 53, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Manrope", "Avenir Next", sans-serif;
    color: var(--ink-0);
    background:
        radial-gradient(circle at 10% 0%, #d6efe2 0%, transparent 38%),
        radial-gradient(circle at 90% 15%, #f7d8c8 0%, transparent 30%),
        linear-gradient(155deg, var(--bg-0), var(--bg-1));
}

.page-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(to right, rgba(15, 122, 106, 0.08) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(15, 122, 106, 0.08) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: radial-gradient(circle at center, black 40%, transparent 100%);
}

.layout {
    width: min(980px, calc(100% - 2rem));
    margin: 2rem auto 3rem;
    display: grid;
    gap: 1rem;
}

.hero h1 {
    margin: 0.4rem 0;
    font-size: clamp(1.7rem, 3.2vw, 2.8rem);
    letter-spacing: -0.03em;
}

.kicker {
    margin: 0;
    color: var(--brand-1);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
    font-size: 0.72rem;
}

.subtitle {
    margin: 0;
    color: var(--ink-1);
    max-width: 64ch;
}

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    padding: 1rem;
    animation: rise 420ms ease both;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-form {
    display: grid;
    gap: 0.9rem;
}

.mode-toggle {
    display: inline-flex;
    width: fit-content;
    border-radius: 999px;
    background: rgba(15, 122, 106, 0.08);
    padding: 0.2rem;
}

.performance-note {
    margin: 0;
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    border: 1px solid rgba(178, 95, 31, 0.24);
    background: rgba(252, 232, 207, 0.5);
    color: #74431a;
    font-size: 0.84rem;
    line-height: 1.35;
}

.mode-btn {
    border: 0;
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    font-weight: 700;
    color: var(--brand-1);
    background: transparent;
    cursor: pointer;
}

.mode-btn.active {
    color: #ffffff;
    background: var(--brand-0);
}

.mode-panel {
    display: none;
    gap: 0.5rem;
}

.mode-panel.active {
    display: grid;
}

label {
    font-weight: 700;
}

textarea,
input[type="file"] {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.7rem;
    background: rgba(255, 255, 255, 0.9);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.88rem;
}

textarea:focus,
input[type="file"]:focus {
    outline: 2px solid rgba(15, 122, 106, 0.4);
    border-color: var(--brand-0);
}

.primary-btn {
    justify-self: start;
    border: 0;
    border-radius: 12px;
    padding: 0.72rem 1.2rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: #ffffff;
    background: linear-gradient(120deg, var(--brand-0), #0f9680);
    cursor: pointer;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.secondary-btn {
    border: 1px solid rgba(19, 35, 49, 0.18);
    border-radius: 12px;
    padding: 0.72rem 1rem;
    font-weight: 700;
    color: var(--ink-0);
    background: rgba(255, 255, 255, 0.82);
    cursor: pointer;
}

.secondary-btn:hover {
    background: rgba(245, 248, 250, 0.95);
}

.hint {
    margin: 0;
    font-size: 0.86rem;
    color: var(--ink-1);
}

.status-badge {
    width: fit-content;
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    font-weight: 700;
    text-transform: capitalize;
}

.status-badge.idle {
    background: #e8edf0;
    color: #384854;
}

.status-badge.started {
    background: #fce8cf;
    color: var(--warn);
}

.status-badge.completed {
    background: #d8f2e3;
    color: var(--ok);
}

.status-badge.error {
    background: #f6d7d7;
    color: var(--error);
}

.status-message {
    margin: 0.55rem 0 0;
    color: var(--ink-1);
    display: grid;
    gap: 0.3rem;
}

.status-main {
    font-weight: 700;
    color: var(--ink-0);
}

.status-detail {
    color: var(--ink-1);
    line-height: 1.35;
}

.status-debug {
    border: 1px solid rgba(19, 35, 49, 0.16);
    border-radius: 10px;
    padding: 0.35rem 0.5rem;
    background: rgba(255, 255, 255, 0.82);
}

.status-debug summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--ink-1);
    font-weight: 600;
}

.status-debug pre {
    margin: 0.4rem 0 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.76rem;
    color: #3b4854;
}

.summary-grid {
    display: block;
}

.summary-grid.empty {
    display: block;
    color: var(--ink-1);
}

.summary-layout {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-stat,
.summary-section {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.85);
    padding: 0.75rem;
}

.summary-label {
    margin: 0;
    color: var(--ink-1);
    font-size: 0.82rem;
}

.summary-value {
    margin: 0.3rem 0 0.45rem;
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.1;
}

.summary-value.text-case {
    font-size: 1.05rem;
    line-height: 1.25;
}

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
}

.pill.positive {
    background: #d8f2e3;
    color: #15643a;
}

.pill.negative {
    background: #f6d7d7;
    color: #8a2f2f;
}

/* OOD Severity indicator */
.ood-severity {
    display: inline-flex;
    align-items: center;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.3rem 0.6rem;
    text-transform: capitalize;
}

.ood-severity-low {
    background: #d8f2e3;
    color: #15643a;
}

.ood-severity-moderate {
    background: #fef3cd;
    color: #856404;
}

.ood-severity-severe {
    background: #f6d7d7;
    color: #8a2f2f;
}

.summary-section h3 {
    margin: 0 0 0.7rem;
    font-size: 0.95rem;
}

.summary-section-top {
    min-height: 100%;
}

.summary-mini-grid {
    grid-column: span 2;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.summary-stat-compact .summary-value {
    font-size: 1.15rem;
}

.segment-chart {
    display: grid;
    gap: 0.65rem;
}

.segment-row {
    display: grid;
    gap: 0.35rem;
}

.segment-row-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
}

.segment-name {
    font-size: 0.87rem;
    color: var(--ink-0);
    font-weight: 700;
}

.segment-score {
    font-size: 0.85rem;
    color: var(--ink-1);
    font-weight: 700;
}

.segment-bar-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #e8edf0;
    overflow: hidden;
}

.segment-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0f7a6a, #1ca887);
}

.segment-foot {
    display: flex;
    justify-content: flex-end;
}

.reason-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.55rem;
}

.reason-item {
    display: grid;
    gap: 0.18rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed rgba(19, 35, 49, 0.16);
}

.reason-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.reason-code {
    font-size: 0.76rem;
    font-weight: 800;
    color: var(--brand-1);
    letter-spacing: 0.01em;
}

.reason-desc {
    font-size: 0.84rem;
    color: var(--ink-1);
    line-height: 1.35;
}

.reason-more,
.reason-empty {
    margin: 0.45rem 0 0;
    font-size: 0.82rem;
    color: var(--ink-1);
}

.card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.85);
    padding: 0.75rem;
}

.card-title {
    margin: 0;
    color: var(--ink-1);
    font-size: 0.86rem;
}

.card-value {
    margin: 0.35rem 0 0;
    font-size: 1.02rem;
    font-weight: 800;
}

.response-details {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.8);
}

.response-details summary {
    cursor: pointer;
    font-weight: 700;
}

.response-json {
    overflow-x: auto;
    padding: 0.75rem;
    border-radius: 10px;
    background: #111a23;
    color: #d8f1ff;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.82rem;
}

@media (max-width: 760px) {
    .layout {
        width: calc(100% - 1rem);
        margin-top: 1rem;
    }

    .summary-layout {
        grid-template-columns: 1fr;
    }

    .summary-mini-grid {
        grid-column: auto;
        grid-template-columns: 1fr;
    }
}
