* {
    box-sizing: border-box;
}
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    color: #1f2937;
    line-height: 1.5;
}
header {
    background: #111827;
    color: #fff;
    padding: 0.75rem 1.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}
header a {
    color: inherit;
    text-decoration: none;
}
header .logout {
    float: right;
}
header .logout button {
    background: transparent;
    border: 1px solid #4b5563;
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    cursor: pointer;
}
nav {
    border-bottom: 1px solid #e5e7eb;
    padding: 0.5rem 1.5rem;
}
nav a {
    color: #2563eb;
    text-decoration: none;
    margin-right: 1rem;
}
main {
    padding: 1.5rem;
    max-width: 800px;
}
h2 {
    font-size: 1.25rem;
    margin: 0 0 0.5rem 0;
}
ul {
    list-style: disc;
    padding-left: 1.25rem;
    margin: 0.5rem 0 1rem 0;
}
li {
    margin: 0.25rem 0;
}
.error-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0.375rem;
}
.error-box .path {
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

a {
    color: #2563eb;
    text-decoration: underline;
}

tier,
.tier {
    display: inline-block;
    background: #e5e7eb;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
}

.briefing {
    margin: 1rem 0;
}

.briefing code {
    background: #f3f4f6;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.875rem;
}

.link-type {
    font-size: 0.75rem;
    color: #6b7280;
    font-family: ui-monospace, SFMono-Regular, monospace;
}

.result-ok,
.result-error {
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    margin-top: 0.75rem;
}
.result-ok {
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}
.result-error {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.points {
    font-size: 0.875rem;
    font-weight: 400;
    color: #6b7280;
}

.sandbox {
    margin: 1rem 0;
}
.sandbox-status {
    display: inline-block;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 0.875rem;
    color: #374151;
    margin-right: 0.75rem;
}
.sandbox-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    margin: 1rem 0;
}
.solved {
    color: #166534;
    font-weight: 600;
}
.unsolved {
    color: #9ca3af;
    font-size: 0.875rem;
}

/* ===== Two-column challenge page layout ===== */
/* <main> caps width at 800px; the two-column page needs the full viewport */
main:has(> .challenge-page) {
    max-width: none;
    padding: 0;
}

.challenge-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(400px, 700px);
    gap: 2rem;
    max-width: none;
    padding: 1.5rem;
    height: calc(100vh - 100px); /* header + nav height */
    min-height: 600px;
}

.challenge-left {
    overflow-y: auto;
    padding-right: 1rem;
}

.challenge-right {
    position: relative;
    height: 100%;
    min-height: 500px;
    background: #1e1e1e;
    border-radius: 0.5rem;
    overflow: hidden;
}

.terminal-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6b7280;
    font-size: 1rem;
    padding: 2rem;
    text-align: center;
}

.terminal {
    height: 100%;
    width: 100%;
}

/* Breadcrumb */
.breadcrumb {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 1rem;
}
.breadcrumb a {
    color: #6b7280;
    text-decoration: none;
}
.breadcrumb a:hover {
    text-decoration: underline;
}
.breadcrumb span {
    margin: 0 0.5rem;
}
.breadcrumb span[aria-current="page"] {
    color: #1f2937;
    font-weight: 500;
}

/* Challenge header */
.challenge-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.challenge-header h1 {
    margin: 0;
    font-size: 1.75rem;
}
.challenge-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Badges */
.solved-badge {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.875rem;
}
.unsolved-badge {
    background: #f3f4f6;
    color: #6b7280;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

/* Links */
.links {
    list-style: none;
    padding-left: 0;
}
.links li {
    margin: 0.5rem 0;
}

/* Sections */
.answer-section,
.flag-section,
.sandbox-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}
.answer-section h3,
.flag-section h3,
.sandbox-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

/* Answer button */
.answer-btn {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
}
.answer-btn:hover {
    background: #e5e7eb;
}
.answer {
    margin-top: 1rem;
    padding: 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
}

/* Flag form */
.flag-section form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.flag-section input {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-family: ui-monospace, SFMono-Regular, monospace;
}
.flag-section button {
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
}
.flag-section button:hover {
    background: #1d4ed8;
}

/* Sandbox controls */
.sandbox form {
    display: inline-flex;
    gap: 0.5rem;
    margin-right: 0.5rem;
}
.sandbox button {
    padding: 0.375rem 0.75rem;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
}
.sandbox button:hover {
    background: #f3f4f6;
}
.sandbox button[type="submit"]:first-of-type {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}
.sandbox button[type="submit"]:first-of-type:hover {
    background: #dc2626;
}

/* Module list (kept narrow) */
.module {
    margin-bottom: 2rem;
}
.module h2 {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}
.module .points {
    font-weight: 600;
    color: #374151;
}

/* Responsive: stack on narrow (though spec says desktop only >= 1100px) */
@media (max-width: 1100px) {
    .challenge-page {
        grid-template-columns: 1fr;
        height: auto;
    }
    .challenge-right {
        min-height: 400px;
    }
}