:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #5f6b7a;
    --line: #dce2ea;
    --accent: #176b87;
    --accent-dark: #104f63;
    --ok: #1f7a4d;
    --warn: #b85c00;
    --code: #101820;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

.topbar {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 28px;
}

.brand {
    color: var(--accent-dark);
    font-weight: 800;
    text-decoration: none;
}

.topbar nav {
    align-items: center;
    display: flex;
    gap: 18px;
}

.topbar nav a {
    color: var(--muted);
    text-decoration: none;
}

.container {
    margin: 0 auto;
    max-width: 1180px;
    padding: 34px 24px 60px;
}

.login-layout,
.dashboard-head,
.challenge-head,
.workspace {
    display: grid;
    gap: 28px;
}

.login-layout {
    align-items: start;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.dashboard-head,
.challenge-head {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
}

.workspace {
    align-items: start;
    grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.2fr);
}

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

h1 {
    font-size: 42px;
    letter-spacing: 0;
    line-height: 1.08;
    margin-bottom: 14px;
}

h2 {
    font-size: 20px;
    margin-bottom: 14px;
}

.lead {
    color: var(--muted);
    font-size: 18px;
    line-height: 1.6;
    max-width: 720px;
}

.eyebrow,
.tag {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.panel,
.card,
.rules,
.scorebox,
.flash {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.panel,
.rules,
.scorebox,
.flash {
    padding: 22px;
}

.rules ul {
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 0;
    padding-left: 20px;
}

label {
    color: var(--muted);
    display: grid;
    font-size: 14px;
    gap: 8px;
    margin-bottom: 16px;
}

input,
textarea {
    background: #ffffff;
    border: 1px solid #cbd5df;
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 44px;
    padding: 10px 12px;
    width: 100%;
}

textarea {
    resize: vertical;
}

button,
.button {
    align-items: center;
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    text-decoration: none;
}

button:hover,
.button:hover {
    background: var(--accent-dark);
}

.button.disabled,
.button.disabled:hover {
    background: #d6dde5;
    color: #637083;
    cursor: not-allowed;
}

.button.ghost {
    background: #eaf1f4;
    color: var(--accent-dark);
}

.button.compact {
    min-height: 34px;
    padding: 7px 10px;
}

button.danger {
    background: #a33a2b;
}

button.danger:hover {
    background: #7e2c21;
}

.hint {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

code {
    background: #edf1f5;
    border-radius: 4px;
    padding: 2px 5px;
}

.flash {
    border-color: #f1c27d;
    color: var(--warn);
    margin-bottom: 18px;
}

.flash.success {
    border-color: #91c9ad;
    color: var(--ok);
}

.flash.timer {
    align-items: center;
    display: flex;
    gap: 10px;
}

.toast-stack {
    display: grid;
    gap: 10px;
    pointer-events: none;
    position: fixed;
    right: 20px;
    top: 84px;
    width: min(360px, calc(100vw - 24px));
    z-index: 1200;
}

.toast {
    align-items: start;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(16, 24, 32, 0.12);
    color: var(--text);
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    opacity: 1;
    padding: 14px 14px 14px 16px;
    pointer-events: auto;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-info {
    border-left: 4px solid var(--accent);
}

.toast-success {
    border-left: 4px solid var(--ok);
}

.toast-hide {
    opacity: 0;
    transform: translateY(-6px);
}

.toast-body {
    font-size: 14px;
    line-height: 1.5;
}

.toast-close {
    align-items: center;
    background: #eef3f7;
    border: 0;
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    height: 24px;
    justify-content: center;
    min-height: 24px;
    min-width: 24px;
    padding: 0;
    width: 24px;
}

.toast-close:hover {
    background: #dde6ed;
    color: var(--text);
}

.scorebox {
    min-width: 180px;
    text-align: right;
}

.scorebox span,
.scorebox small {
    color: var(--muted);
    display: block;
}

.scorebox strong {
    display: block;
    font-size: 34px;
    margin: 4px 0;
}

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

.card {
    display: flex;
    flex-direction: column;
    gap: 20px;
    justify-content: space-between;
    min-height: 230px;
    padding: 22px;
}

.card.done {
    border-color: #91c9ad;
}

.card p {
    color: var(--muted);
    line-height: 1.6;
}

.output {
    min-height: 260px;
    overflow: auto;
}

pre {
    background: var(--code);
    border-radius: 6px;
    color: #e8eef5;
    overflow: auto;
    padding: 14px;
    white-space: pre-wrap;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

.guestbook {
    border-left: 4px solid var(--accent);
    padding-left: 14px;
}

.spaced {
    margin-bottom: 18px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.narrow {
    margin: 0 auto;
    max-width: 680px;
}

.answer-list {
    display: grid;
    gap: 18px;
}

.answer-head {
    align-items: start;
    display: flex;
    gap: 18px;
    justify-content: space-between;
}

.answer-status {
    align-items: end;
    display: grid;
    gap: 8px;
    justify-items: end;
}

.challenge-state {
    position: relative;
}

.challenge-state.state-rule {
    background: #f5f9ff;
    border-color: #c8daf9;
}

.challenge-state.state-llm {
    background: #fff9ef;
    border-color: #efd6a0;
}

.challenge-state.state-final {
    background: #f2fbf6;
    border-color: #bfe3cb;
}

.challenge-state.state-rule.state-llm {
    background: linear-gradient(180deg, #f5f9ff 0%, #fff9ef 100%);
    border-color: #d7d7c1;
}

.challenge-state.state-rule.state-final {
    background: linear-gradient(180deg, #f5f9ff 0%, #f2fbf6 100%);
    border-color: #c6ddd2;
}

.challenge-state.state-llm.state-final {
    background: linear-gradient(180deg, #fff9ef 0%, #f2fbf6 100%);
    border-color: #d7dfbd;
}

.challenge-state.state-rule.state-llm.state-final {
    background: linear-gradient(180deg, #f5f9ff 0%, #fff9ef 52%, #f2fbf6 100%);
    border-color: #cfdacb;
}

.challenge-state::before {
    background: transparent;
    border-radius: 8px 8px 0 0;
    content: "";
    height: 4px;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
}

.challenge-state.state-rule::before {
    background: #2d6cdf;
}

.challenge-state.state-llm::before {
    background: #d18a00;
}

.challenge-state.state-final::before {
    background: #1f7a4d;
}

.challenge-state.state-rule.state-llm::before {
    background: linear-gradient(90deg, #2d6cdf 0 50%, #d18a00 50% 100%);
}

.challenge-state.state-rule.state-final::before {
    background: linear-gradient(90deg, #2d6cdf 0 50%, #1f7a4d 50% 100%);
}

.challenge-state.state-llm.state-final::before {
    background: linear-gradient(90deg, #d18a00 0 50%, #1f7a4d 50% 100%);
}

.challenge-state.state-rule.state-llm.state-final::before {
    background: linear-gradient(90deg, #2d6cdf 0 34%, #d18a00 34% 67%, #1f7a4d 67% 100%);
}

.stage-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.stage-badge {
    background: #eef2f6;
    border: 1px solid #d5dee7;
    border-radius: 999px;
    color: #758295;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 7px 10px;
}

.stage-badge.is-on.is-rule {
    background: #e8f0ff;
    border-color: #bfd3ff;
    color: #1f4ea7;
}

.stage-badge.is-on.is-llm {
    background: #fff3da;
    border-color: #f1d18d;
    color: #8f5d00;
}

.stage-badge.is-on.is-final {
    background: #e7f6ee;
    border-color: #b7dfc6;
    color: #16633f;
}

.member-row {
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(140px, 0.7fr) minmax(0, 1.3fr);
}

.start-bar {
    margin-top: 18px;
}

.uniform-picker {
    border-top: 1px solid var(--line);
    margin-top: 10px;
    padding-top: 14px;
}

dl {
    display: grid;
    gap: 8px 18px;
    grid-template-columns: 180px minmax(0, 1fr);
    margin: 0;
}

dt {
    color: var(--muted);
    font-weight: 700;
}

dd {
    margin: 0;
}

.report-block {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 18px;
}

.report-block h3 {
    font-size: 18px;
    margin-top: 0;
}

.assessment-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hybrid-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 16px 0;
}

.hybrid-card {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 16px;
}

.hybrid-card h4,
.report-block h4 {
    font-size: 16px;
    margin: 0 0 12px;
}

.assessment-grid .full-width {
    grid-column: 1 / -1;
}

.assessment-footer {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

@media (max-width: 760px) {
    .topbar,
    .topbar nav {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        gap: 10px;
        padding: 16px 20px;
    }

    .container {
        padding: 24px 16px 42px;
    }

    .login-layout,
    .dashboard-head,
    .challenge-head,
    .workspace,
    .grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 32px;
    }

    .scorebox {
        text-align: left;
    }

    .answer-head,
    .inline-form {
        display: grid;
    }

    .answer-status {
        justify-items: start;
    }

    .stage-badges {
        justify-content: flex-start;
    }

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

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

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

    .assessment-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    dl {
        grid-template-columns: 1fr;
    }

    .toast-stack {
        left: 12px;
        right: 12px;
        top: 76px;
        width: auto;
    }
}
