:root {
    --paper: #f2f3f1;
    --paper-2: #e7eae8;
    --ink: #17191a;
    --muted: #687274;
    --line: #98a5a5;
    --accent: #9278bd;
    --accent-deep: #5b437d;
    --font-mono: "IBM Plex Mono", "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --font-display: "Arial Narrow", "Aptos Display", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html {
    min-height: 100%;
    color-scheme: light;
    background: var(--paper);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(rgba(23, 25, 26, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23, 25, 26, .035) 1px, transparent 1px),
        var(--paper);
    background-size: 44px 44px;
    font-family: var(--font-mono);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

::selection {
    color: var(--ink);
    background: var(--accent);
}

a { color: inherit; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.lab-shell {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
}

.lab-header,
.lab-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(calc(100% - 64px), 1320px);
    margin-inline: auto;
}

.lab-header {
    min-height: 64px;
    border-bottom: 1px dashed var(--line);
}

.lab-brand,
.lab-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    text-decoration: none;
}

.lab-brand {
    gap: 10px;
    font-size: .73rem;
    font-weight: 700;
}

.lab-brand::before {
    flex: none;
    width: 34px;
    height: 34px;
    content: "";
    background: url("../assets/e3xplolt-mark.png") center / contain no-repeat;
    filter: saturate(.86) contrast(1.04);
}

.lab-brand span {
    padding-left: 10px;
    border-left: 1px solid var(--line);
    color: var(--muted);
    font-size: .64rem;
    font-weight: 400;
    letter-spacing: .09em;
}

.lab-back {
    color: var(--muted);
    font-size: .67rem;
    text-underline-offset: 5px;
}

.lab-back:hover { color: var(--ink); }

.lab-main {
    display: grid;
    place-items: center;
    width: min(calc(100% - 64px), 1120px);
    margin-inline: auto;
    padding-block: clamp(64px, 10vw, 140px);
}

.challenge-panel {
    width: 100%;
    border: 1px solid var(--ink);
    background: color-mix(in srgb, var(--paper) 94%, transparent);
}

.challenge-panel__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding-inline: 18px;
    color: #9ca8a7;
    background: var(--ink);
    font-size: .64rem;
    letter-spacing: .08em;
}

.challenge-panel__bar .online {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
}

.challenge-panel__bar .online::before {
    width: 6px;
    height: 6px;
    content: "";
    border-radius: 50%;
    background: currentColor;
}

.challenge-panel__body {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(250px, .6fr);
}

.challenge-copy {
    min-height: 460px;
    padding: clamp(32px, 6vw, 72px);
}

.challenge-index {
    display: block;
    margin-bottom: clamp(60px, 9vw, 110px);
    color: var(--accent-deep);
    font-size: .66rem;
    letter-spacing: .1em;
}

.challenge-copy h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(4rem, 9vw, 8.5rem);
    font-weight: 300;
    line-height: .86;
    letter-spacing: -.06em;
    text-transform: uppercase;
}

.challenge-copy h1 em {
    display: block;
    margin-top: 15px;
    color: var(--accent-deep);
    font-family: var(--font-mono);
    font-size: .1em;
    font-style: normal;
    font-weight: 400;
    letter-spacing: .14em;
}

.challenge-copy__lead {
    max-width: 680px;
    margin: 38px 0 0;
    font-family: var(--font-display);
    font-size: clamp(1.35rem, 2.5vw, 2.2rem);
    font-weight: 300;
    line-height: 1.25;
}

.challenge-copy__sub {
    max-width: 650px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: .78rem;
}

.challenge-side {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-left: 1px dashed var(--line);
    background: var(--paper-2);
}

.challenge-side__block {
    padding: 28px;
}

.challenge-side__block + .challenge-side__block {
    border-top: 1px dashed var(--line);
}

.challenge-side__block:last-child {
    margin-top: auto;
}

.challenge-side h2 {
    margin: 0 0 17px;
    color: var(--accent-deep);
    font-size: .64rem;
    font-weight: 500;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.challenge-side p,
.challenge-side li {
    color: var(--muted);
    font-size: .73rem;
    line-height: 1.75;
}

.challenge-side p { margin: 0; }

.challenge-side ol {
    margin: 0;
    padding-left: 20px;
}

.challenge-side code,
.challenge-result code {
    padding: .15em .4em;
    color: var(--ink);
    background: #d7ddda;
    font-family: inherit;
}

.challenge-result {
    grid-column: 1 / -1;
    padding: 24px clamp(28px, 6vw, 72px);
    border-top: 1px dashed var(--line);
    color: var(--ink);
    background: var(--accent);
    overflow-wrap: anywhere;
}

.challenge-result:empty { display: none; }
.challenge-result p { margin: 6px 0; }

.challenge-result--quiet {
    color: var(--muted);
    background: var(--paper-2);
}

.source-output {
    grid-column: 1 / -1;
    max-height: 620px;
    padding: 28px;
    border-top: 1px dashed var(--line);
    color: #dce3e1;
    background: var(--ink);
    overflow: auto;
    font-size: .73rem;
    line-height: 1.65;
}

.source-output pre {
    margin: 0;
}

.source-output code {
    display: block;
    width: max-content;
    min-width: 100%;
    color: #dce3e1 !important;
    white-space: pre-wrap;
}

/* PHP highlight_file() writes fixed light-theme inline colours. Remap them for this dark source panel. */
.source-output code[style*="#000000"],
.source-output span[style*="#000000"] { color: #dce3e1 !important; }
.source-output span[style*="#0000BB"] { color: #b7a2da !important; }
.source-output span[style*="#007700"] { color: #9eaaa8 !important; }
.source-output span[style*="#DD0000"] { color: #eef2f0 !important; }

.lab-footer {
    min-height: 64px;
    border-top: 1px dashed var(--line);
    color: var(--muted);
    font-size: .64rem;
    letter-spacing: .08em;
}

@media (max-width: 760px) {
    .lab-header,
    .lab-footer,
    .lab-main {
        width: calc(100% - 32px);
    }

    .lab-brand span { display: none; }

    .lab-main {
        place-items: start stretch;
        padding-block: 42px 72px;
    }

    .challenge-panel__body {
        grid-template-columns: 1fr;
    }

    .challenge-copy {
        min-height: 410px;
        padding: 30px 24px 48px;
    }

    .challenge-index { margin-bottom: 64px; }

    .challenge-copy h1 {
        font-size: clamp(3.9rem, 21vw, 6.5rem);
    }

    .challenge-side {
        border-top: 1px dashed var(--line);
        border-left: 0;
    }

    .challenge-result,
    .source-output {
        padding-inline: 24px;
    }

    .lab-footer {
        align-items: flex-start;
        flex-direction: column;
        justify-content: center;
        gap: 3px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation: none !important;
        transition: none !important;
    }
}
