/* ---- ElektroLab shell ---- */
:root {
    --color-bg: #f7f8fa;
    --color-surface: #ffffff;
    --color-text: #1c2430;
    --color-muted: #4a5565;
    --color-primary: #0b5cad;
    --color-primary-contrast: #ffffff;
    --color-header: #12263f;
    --color-header-text: #ffffff;
    --color-border: #d4d9e1;
    /* Edges of controls (buttons, fields, the board) need 3:1 against the page (WCAG 1.4.11); --color-border is for decoration. */
    --color-control-border: #6b7686;
    /* Dark ring on light content, yellow ring on the dark header: both above the 3:1 WCAG AA non-text contrast. */
    --focus-ring: 3px solid #0b5cad;
    --focus-ring-on-dark: 3px solid #f2b705;
    --content-width: 64rem;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--color-primary);
}

:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -3rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-primary);
    background: var(--color-surface);
    color: var(--color-primary);
    font: inherit;
    cursor: pointer;
    z-index: 100;
}

    .skip-link:focus {
        top: 0.5rem;
    }

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem max(1rem, calc((100% - var(--content-width)) / 2));
    background: var(--color-header);
    color: var(--color-header-text);
}

    .app-header :focus-visible {
        outline: var(--focus-ring-on-dark);
    }

.app-header__brand {
    color: var(--color-header-text);
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
}

.language-switcher {
    display: flex;
    gap: 0.25rem;
}

.language-switcher__option {
    min-width: 2.75rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--color-header-text);
    border-radius: 0.375rem;
    background: transparent;
    color: var(--color-header-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

    .language-switcher__option[aria-pressed="true"] {
        background: var(--color-header-text);
        color: var(--color-header);
        cursor: default;
    }

.app-main {
    flex: 1;
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 2rem 1rem;
}

    .app-main:focus {
        outline: none;
    }

.app-footer {
    padding: 1rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-muted);
    font-size: 0.875rem;
    text-align: center;
}

.hero {
    padding: 2rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-surface);
}

    .hero h1 {
        margin-top: 0;
    }

.hero__lead {
    font-size: 1.15rem;
}

.app-header__nav {
    display: flex;
    gap: 1.25rem;
    margin-right: auto;
}

    .app-header__nav a {
        color: var(--color-header-text);
        font-weight: 600;
        text-decoration: none;
    }

        .app-header__nav a:hover {
            text-decoration: underline;
        }

.button {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 0;
    border-radius: 0.375rem;
    background: var(--color-primary);
    color: var(--color-primary-contrast);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

/* ---- Catalog ---- */
.page-lead {
    color: var(--color-muted);
    font-size: 1.1rem;
}

.loading {
    color: var(--color-muted);
}

.load-error {
    padding: 1rem 1.25rem;
    border: 1px solid #a1171c;
    border-radius: 0.5rem;
    background: #fdf1f1;
}

.series {
    margin-top: 2rem;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.book-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    height: 100%;
    padding: 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
}

    .book-card:hover {
        border-color: var(--color-primary);
    }

.book-card__code {
    align-self: flex-start;
    padding: 0.1rem 0.5rem;
    border-radius: 0.25rem;
    background: var(--color-header);
    color: var(--color-header-text);
    font-size: 0.8rem;
    font-weight: 700;
}

.book-card__title {
    color: var(--color-primary);
    font-size: 1.15rem;
    font-weight: 700;
}

.book-card__stats {
    color: var(--color-muted);
    font-size: 0.9rem;
}

/* ---- Progress summary (ADR-0015) ---- */
/* In a book card the summary sits at the bottom, so the bars of cards in one row line up. */
.book-progress {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-width: 24rem;
    margin-top: auto;
    padding-top: 0.35rem;
}

.book-progress__text {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.book-progress__bar {
    width: 100%;
    height: 0.5rem;
    accent-color: #1d6b34;
}

.progress-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    border: 1px solid #e0b25c;
    border-radius: 0.5rem;
    background: #fdf6e7;
}

    .progress-note p {
        margin: 0;
    }

.badge--unreadable {
    background: #fdf1f1;
    color: #a1171c;
}

.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--color-muted);
    font-size: 0.9rem;
}

    .breadcrumb li + li::before {
        content: "›";
        margin-right: 0.25rem;
    }

.unit-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.unit {
    padding: 1rem 0;
    border-top: 1px solid var(--color-border);
}

.unit__title {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
}

.unit__empty {
    margin: 0;
    color: var(--color-muted);
    font-size: 0.9rem;
}

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

.experiment-link {
    display: block;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
}

    .experiment-link:hover {
        border-color: var(--color-primary);
    }

.experiment-link__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.experiment-link__label {
    color: var(--color-primary);
    font-weight: 700;
}

/* Two lines are enough to recognise the experiment; the experiment card shows all of it. */
.experiment-link__summary {
    display: -webkit-box;
    margin-top: 0.25rem;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    color: var(--color-muted);
}

.badge {
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge--simulated {
    background: #e3eefb;
    color: #0b4a8a;
}

.badge--task {
    background: #eef0f3;
    color: #3a4452;
}

/* ---- Blazor template ---- */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        padding: 0;
        border: 0;
        background: none;
        font: inherit;
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}
/* ---- Diagnostics (developer page) ---- */
.diagnostics__environment {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
}

    .diagnostics__environment dt {
        font-weight: 600;
    }

    .diagnostics__environment dd {
        margin: 0;
    }

.diagnostics__results {
    display: block;
    overflow-x: auto;
    margin-top: 1rem;
    border-collapse: collapse;
    background: var(--color-surface);
}

    .diagnostics__results th,
    .diagnostics__results td {
        padding: 0.4rem 0.75rem;
        border: 1px solid var(--color-border);
        text-align: left;
    }

.diagnostics__pass {
    color: #1a6b2f;
    font-weight: 600;
}

.diagnostics__fail {
    color: #a1171c;
    font-weight: 600;
    white-space: pre-wrap;
}

.diagnostics__run {
    padding: 0.5rem 1rem;
    border: 0;
    border-radius: 0.25rem;
    background: var(--color-primary);
    color: var(--color-primary-contrast);
    font: inherit;
    cursor: pointer;
}

    .diagnostics__run:disabled {
        opacity: 0.6;
        cursor: progress;
    }

/* ---- Experiment card ---- */
.experiment-card {
    margin: 1rem 0 1.5rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-surface);
}

.experiment-card__header h1 {
    display: inline-block;
    margin: 0 0.5rem 0 0;
}

.experiment-card__unit {
    margin: 0 0 0.25rem;
    color: var(--color-muted);
    font-weight: 600;
}

.experiment-card__kind-note {
    margin: 0.5rem 0 0;
    color: var(--color-muted);
}

.experiment-card__section {
    margin-top: 1.5rem;
}

    .experiment-card__section h2 {
        margin: 0 0 0.5rem;
        font-size: 1.1rem;
    }

/* Book texts keep their line breaks: a blank line separates paragraphs. */
.book-text {
    white-space: pre-line;
}

.experiment-card__instructions {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.6;
}

.warning {
    margin: 0 0 0.5rem;
    padding: 0.75rem 1rem;
    border-left: 4px solid #b45309;
    border-radius: 0.375rem;
    background: #fff7e6;
    color: #4a2a04;
}

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

/* Formulas keep the book's spacing, which sets apart two formulas written on one line. */
.formula {
    padding: 0.5rem 1rem;
    overflow-x: auto;
    border-radius: 0.375rem;
    background: var(--color-bg);
    font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
    font-size: 1.05rem;
    white-space: pre;
}

.goal-list {
    margin: 0;
    padding-left: 1.25rem;
}

/* ---- Circuit editor: schematic canvas ---- */
.schematic-canvas {
    --grid-minor: #e3e7ee;
    --grid-major: #c3cad6;
    --canvas-origin: #8a94a6;
    --canvas-snap: #0b5cad;
    --symbol-stroke: #1c2430;
    --symbol-selected: #0b5cad;
    --canvas-error: #a4161a;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.schematic-canvas__toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.schematic-canvas__tool {
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.5rem;
    border: 1px solid var(--color-control-border);
    border-radius: 0.375rem;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
}

    .schematic-canvas__tool--text {
        font-size: 1rem;
    }

    .schematic-canvas__tool:hover:not([aria-disabled="true"]) {
        border-color: var(--color-primary);
        color: var(--color-primary);
    }

    .schematic-canvas__tool[aria-disabled="true"] {
        color: var(--color-muted);
        cursor: not-allowed;
        opacity: 0.6;
    }

.schematic-canvas__zoom {
    min-width: 3.5rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* touch-action and user-select: dragging pans the canvas instead of scrolling the page or selecting text. */
.schematic-canvas__surface {
    display: block;
    width: 100%;
    height: clamp(20rem, 65vh, 48rem);
    border: 1px solid var(--color-control-border);
    border-radius: 0.5rem;
    background: var(--color-surface);
    cursor: grab;
    touch-action: none;
    user-select: none;
}

    .schematic-canvas__surface.is-panning {
        cursor: grabbing;
    }

.schematic-canvas__grid {
    pointer-events: none;
}

.schematic-canvas__grid-minor,
.schematic-canvas__grid-major {
    fill: none;
}

.schematic-canvas__grid-minor {
    stroke: var(--grid-minor);
}

.schematic-canvas__grid-major {
    stroke: var(--grid-major);
}

.schematic-canvas__origin {
    fill: none;
    stroke: var(--canvas-origin);
    pointer-events: none;
}

.schematic-canvas__snap {
    fill: var(--canvas-snap);
    pointer-events: none;
}

.schematic-canvas__status,
.schematic-canvas__help {
    margin: 0;
    color: var(--color-muted);
    font-size: 0.9rem;
}

.schematic-canvas__status {
    font-variant-numeric: tabular-nums;
}

.schematic-canvas__separator {
    width: 1px;
    height: 1.5rem;
    margin: 0 0.25rem;
    background: var(--color-border);
}

.schematic-canvas__surface.is-placing {
    cursor: crosshair;
}

.schematic-canvas__surface.is-dragging {
    cursor: move;
}

.schematic-canvas__surface.is-wiring,
.schematic-canvas__surface.is-wiring .schematic-component,
.schematic-canvas__surface.is-wiring .schematic-wire {
    cursor: crosshair;
}

.schematic-canvas__wiring {
    margin: 0;
    color: var(--symbol-selected);
    font-weight: 600;
}

.schematic-canvas__error {
    margin: 0;
    color: var(--canvas-error);
    font-weight: 600;
}

/* ---- Circuit editor: components on the board ---- */
.schematic-component {
    cursor: pointer;
}

.schematic-canvas__surface.is-placing .schematic-component {
    cursor: crosshair;
}

/* Transparent but hit-testable: the whole symbol area picks the component up, not only its thin lines. */
.schematic-component__hit {
    fill: transparent;
    stroke: none;
}

.schematic-component.is-selected .schematic-component__hit {
    fill: rgb(11 92 173 / 0.08);
    stroke: var(--symbol-selected);
    stroke-width: 1;
    stroke-dasharray: 4 3;
}

.schematic-component.is-ghost {
    opacity: 0.45;
    pointer-events: none;
}

.schematic-component__pin {
    fill: var(--symbol-stroke);
    pointer-events: none;
}

.schematic-component__pin.is-wiring-start {
    fill: var(--symbol-selected);
}

/* Transparent but hit-testable; it lights up under the pointer to show that a wire can start or end here. */
.schematic-component__pin-hit {
    fill: transparent;
    stroke: none;
    cursor: crosshair;
}

.schematic-component__pin-hit:hover {
    fill: rgb(11 92 173 / 0.18);
    stroke: var(--symbol-selected);
    stroke-width: 1;
}

.schematic-canvas__surface.is-placing .schematic-component__pin-hit {
    pointer-events: none;
}

/* ---- Circuit editor: wires ---- */
.schematic-wire {
    cursor: pointer;
}

.schematic-wire__line,
.schematic-wire--draft {
    fill: none;
    stroke: var(--symbol-stroke, #1c2430);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

/* A wide invisible stroke, so a thin wire can be clicked without pixel-perfect aim. Its width is set in the markup,
   divided by the zoom, so it stays the same on screen. */
.schematic-wire__hit {
    fill: none;
    stroke: transparent;
}

.schematic-wire.is-selected .schematic-wire__line {
    stroke: var(--symbol-selected);
    stroke-width: 3;
}

.schematic-wire--draft {
    stroke: var(--symbol-selected);
    stroke-dasharray: 6 4;
    pointer-events: none;
}

.schematic-component__label {
    fill: var(--color-muted);
    font-size: 12px;
    pointer-events: none;
}

.schematic-component.is-selected .schematic-component__label {
    fill: var(--symbol-selected);
    font-weight: 600;
}

.schematic-symbol__line,
.schematic-symbol__body {
    stroke: var(--symbol-stroke, #1c2430);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.schematic-symbol__line {
    fill: none;
}

    .schematic-symbol__line--plate {
        stroke-width: 4;
    }

.schematic-symbol__body {
    fill: var(--color-surface);
}

.schematic-symbol__fill,
.schematic-symbol__terminal {
    fill: var(--symbol-stroke, #1c2430);
}

.schematic-component.is-selected .schematic-symbol__line,
.schematic-component.is-selected .schematic-symbol__body {
    stroke: var(--symbol-selected);
}

/* ---- Circuit editor: layout and palette ---- */
.lab__experiment {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    align-items: baseline;
    margin: 0 0 0.5rem;
    font-weight: 600;
}

/* Saving the student's circuit: why it is not saved, and starting again (asked twice, as it cannot be undone). */
.lab__storage {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 0.75rem;
}

.lab__notice {
    flex: 1 1 20rem;
    margin: 0;
    padding: 0.5rem 0.75rem;
    border-left: 4px solid #8a5a00;
    background: #fff7e6;
}

.lab__start-over {
    margin-left: auto;
}

.lab__reset {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-left: auto;
}

.button--secondary {
    border: 1px solid var(--color-primary);
    background: transparent;
    color: var(--color-primary);
}

.button--danger {
    background: #a1171c;
    color: #fff;
}

.button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.lab__editor {
    display: grid;
    grid-template-columns: minmax(10rem, 13rem) minmax(0, 1fr) minmax(12rem, 15rem);
    gap: 1rem;
    align-items: start;
}

/* Too narrow for three columns: the property panel moves under the board. */
@media (max-width: 60rem) {
    .lab__editor {
        grid-template-columns: minmax(10rem, 13rem) minmax(0, 1fr);
    }

    .lab__editor > .properties-panel {
        grid-column: 2;
    }
}

@media (max-width: 48rem) {
    .lab__editor {
        grid-template-columns: minmax(0, 1fr);
    }

    .lab__editor > .properties-panel {
        grid-column: auto;
    }
}

.component-palette {
    margin-top: 1rem;
    --symbol-stroke: #1c2430;
}

.component-palette__heading {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.component-palette__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
    gap: 0.375rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.component-palette__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    width: 100%;
    padding: 0.375rem 0.25rem;
    border: 1px solid var(--color-control-border);
    border-radius: 0.375rem;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

    .component-palette__item:hover {
        border-color: var(--color-primary);
    }

    .component-palette__item[aria-pressed="true"] {
        border-color: var(--color-primary);
        background: var(--color-primary);
        color: var(--color-primary-contrast);
        --symbol-stroke: var(--color-primary-contrast);
    }

        .component-palette__item[aria-pressed="true"] .schematic-symbol__body {
            fill: var(--color-primary);
        }

.component-palette__preview {
    width: 3rem;
    height: 3rem;
}

.component-palette__hint {
    margin: 0.5rem 0 0;
    color: var(--color-muted);
    font-size: 0.85rem;
}

/* ---- Circuit editor: property panel ---- */
.properties-panel {
    margin-top: 1rem;
    --properties-error: #a4161a;
}

.properties-panel__heading {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.properties-panel__component {
    margin: 0 0 0.75rem;
    font-weight: 600;
}

.properties-panel__list {
    display: grid;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.properties-panel__field {
    display: grid;
    gap: 0.25rem;
}

.properties-panel__label {
    font-size: 0.9rem;
}

.properties-panel__input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--color-control-border);
    border-radius: 0.375rem;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
}

    .properties-panel__input:focus-visible {
        outline: var(--focus-ring);
        outline-offset: 1px;
    }

    .properties-panel__input[aria-invalid="true"] {
        border-color: var(--properties-error);
        box-shadow: 0 0 0 1px var(--properties-error);
    }

.properties-panel__value {
    font-weight: 600;
}

.properties-panel__error {
    margin: 0;
    color: var(--properties-error);
    font-size: 0.85rem;
    font-weight: 600;
}

.properties-panel__empty,
.properties-panel__hint {
    margin: 0.75rem 0 0;
    color: var(--color-muted);
    font-size: 0.85rem;
}

/* ---- Simulation: running it from the lab and why a circuit cannot be simulated ---- */
.simulation-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
    margin: 0 0 0.75rem;
}

.simulation-panel__heading {
    margin: 0;
    font-size: 1.1rem;
}

.simulation-panel__status,
.simulation-panel__failure {
    flex: 1 1 20rem;
    margin: 0;
    padding: 0.5rem 0.75rem;
    border-left: 4px solid #5a6b7d;
    background: #f1f4f7;
}

.simulation-panel__status.is-succeeded {
    border-left-color: #1d6b35;
    background: #ecf7ef;
}

.simulation-panel__status.is-outdated {
    border-left-color: #8a5a00;
    background: #fff7e6;
}

.simulation-panel__failure {
    border-left-color: #a1171c;
    background: #fdeeee;
}

.simulation-panel__failure p,
.simulation-panel__failure ul,
.simulation-panel__warnings p,
.simulation-panel__warnings ul {
    margin: 0;
}

.simulation-panel__failure ul,
.simulation-panel__warnings ul {
    padding-left: 1.25rem;
}

.simulation-panel__lit {
    flex: 1 1 100%;
    margin: 0;
}

/* Exceeded limits (M4.4): the circuit is solved, but a real component would burn. */
.simulation-panel__warnings {
    flex: 1 1 100%;
    margin: 0;
    padding: 0.5rem 0.75rem;
    border-left: 4px solid #b45309;
    background: #fff4e5;
}

.simulation-panel__warnings p {
    font-weight: 600;
}

/* The multimeter (M4.2): dial, two probes and a display, like a handheld meter. */
.multimeter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #c9d1da;
    border-radius: 6px;
}

.multimeter__heading {
    flex: 1 0 100%;
    margin: 0;
    font-size: 1.1rem;
}

.multimeter__modes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin: 0;
    padding: 0.25rem 0.5rem;
    border: 1px solid #c9d1da;
    border-radius: 4px;
}

.multimeter__modes legend {
    padding: 0 0.25rem;
    font-size: 0.85rem;
}

.multimeter__mode {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

.multimeter__probes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.multimeter__probe,
.voltage-chart-panel__probe {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding-left: 0.5rem;
    border-left: 4px solid #a1171c;
    font-size: 0.9rem;
}

.multimeter__probe.is-black,
.voltage-chart-panel__probe.is-black {
    border-left-color: #1f1f1f;
}

.multimeter__readout {
    flex: 1 1 12rem;
}

.multimeter__display {
    display: inline-block;
    min-width: 9rem;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    background: #1f2a1f;
    color: #c8f7c5;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 1.5rem;
    text-align: right;
}

.multimeter__message {
    margin: 0;
    padding: 0.5rem 0.75rem;
    border-left: 4px solid #5a6b7d;
    background: #f1f4f7;
}

.multimeter__hint {
    flex: 1 0 100%;
    margin: 0;
    color: #4a5561;
    font-size: 0.85rem;
}

/* Measurement goals (M5.1): what the experiment expects and, after a run, whether the circuit meets it. */
.goals {
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #c9d1da;
    border-left: 4px solid #5a6b7d;
    border-radius: 6px;
}

.goals.is-all-met {
    border-left-color: #2e7d32;
    background: #eef7ee;
}

.goals.is-not-all-met {
    border-left-color: #b45309;
    background: #fff8ef;
}

.goals__heading {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
}

.goals__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.goals__goal {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    align-items: baseline;
}

.goals__mark {
    width: 1.25rem;
    font-weight: 700;
    text-align: center;
}

.goals__goal.is-met .goals__mark {
    color: #2e7d32;
}

.goals__goal.is-not-met .goals__mark,
.goals__goal.is-not-measurable .goals__mark {
    color: #b45309;
}

.goals__measured {
    color: #4a5561;
}

.goals__status {
    margin: 0.25rem 0 0;
    font-weight: 600;
}

/* The voltage chart (M4.3): two probes, a duration and the voltage over time on graph paper. */
.voltage-chart-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #c9d1da;
    border-radius: 6px;
}

.voltage-chart-panel__heading {
    margin: 0;
    font-size: 1.1rem;
}

.voltage-chart-panel__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: flex-end;
}

.voltage-chart-panel__stop-time {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    font-size: 0.9rem;
}

.voltage-chart-panel__stop-time input {
    width: 7rem;
}

.voltage-chart-panel__hint {
    margin: 0;
    color: #4a5561;
    font-size: 0.85rem;
}

.voltage-chart-panel__message {
    margin: 0;
    padding: 0.5rem 0.75rem;
    border-left: 4px solid #5a6b7d;
    background: #f1f4f7;
}

.voltage-chart-panel__message.is-outdated {
    border-left-color: #8a5a00;
    background: #fff7e6;
}

.voltage-chart-panel__message.is-error {
    border-left-color: #a1171c;
    background: #fdeeee;
}

.voltage-chart-panel__chart {
    max-width: 48rem;
}

.voltage-chart-panel__chart.is-outdated {
    opacity: 0.55;
}

.voltage-chart {
    display: block;
    width: 100%;
    height: auto;
    background: #ffffff;
}

.voltage-chart__grid line {
    stroke: #e1e6ec;
    stroke-width: 1;
}

.voltage-chart__frame {
    fill: none;
    stroke: #5a6b7d;
    stroke-width: 1;
}

.voltage-chart__zero {
    stroke: #5a6b7d;
    stroke-dasharray: 4 3;
}

.voltage-chart__labels text {
    fill: #4a5561;
    font-size: 12px;
}

.voltage-chart__labels .voltage-chart__axis-title {
    fill: #1c2430;
    font-style: italic;
    font-weight: 700;
}

.voltage-chart__trace {
    fill: none;
    stroke: #0b5cad;
    stroke-width: 2;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

/* A component the simulation found at fault, e.g. not connected to ground. */
.schematic-component.is-faulty .schematic-symbol__line,
.schematic-component.is-faulty .schematic-symbol__body {
    stroke: #c62828;
}

.schematic-component.is-faulty .schematic-component__label {
    fill: #c62828;
    font-weight: 700;
}

/* A component beyond its limits (M4.4), e.g. a resistor that would overheat. */
.schematic-component.is-overloaded .schematic-symbol__line,
.schematic-component.is-overloaded .schematic-symbol__body {
    stroke: #b45309;
    stroke-width: 3;
}

.schematic-component.is-overloaded .schematic-component__label {
    fill: #b45309;
    font-weight: 700;
}

/* An LED with enough current to glow: a filled body, bright arrows and a soft halo. */
.schematic-component.is-lit .schematic-symbol__body {
    fill: #ff3b30;
    filter: drop-shadow(0 0 6px rgba(255, 59, 48, 0.85));
}

.schematic-component.is-lit .schematic-symbol__line--light {
    stroke: #ff3b30;
}

/* A lamp with enough power (M4.5): a warm yellow bulb, a glowing filament and a wide halo. */
.schematic-component.is-lit .schematic-symbol__body--bulb {
    fill: #ffe082;
    filter: drop-shadow(0 0 8px rgba(255, 193, 7, 0.9));
}

.schematic-component.is-lit .schematic-symbol__line--filament {
    stroke: #e65100;
}

/* The student's progress on the experiment card (M5.3): status, notes and "done". */
.progress-panel {
    margin: 0 0 1.5rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-surface);
}

    .progress-panel h2 {
        margin: 0 0 0.75rem;
        font-size: 1.1rem;
    }

.progress-panel__status {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    align-items: center;
    margin: 0 0 1rem;
}

.progress-panel__done-at {
    color: var(--color-muted);
}

.badge--not-started {
    background: #eef0f3;
    color: #3a4452;
}

.badge--in-progress {
    background: #fdf1dc;
    color: #8a4b06;
}

.badge--done {
    background: #e2f4e7;
    color: #1d6b34;
}

.progress-panel__label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.progress-panel__notes {
    box-sizing: border-box;
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--color-control-border);
    border-radius: 0.375rem;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    line-height: 1.5;
    resize: vertical;
}

    .progress-panel__notes:focus-visible {
        outline: var(--focus-ring);
        outline-offset: 1px;
    }

.progress-panel__hint {
    margin: 0.25rem 0 1rem;
    color: var(--color-muted);
    font-size: 0.85rem;
}

.progress-panel__actions {
    display: flex;
    gap: 0.5rem;
}

.progress-panel__feedback {
    margin: 0.75rem 0 0;
    min-height: 1.5em;
    font-weight: 600;
}

    .progress-panel__feedback.is-error,
    .progress-panel__error p {
        color: #a3261b;
    }

.progress-panel__error p {
    margin: 0 0 0.5rem;
}

/* Export and import of the student's data (M5.5, ADR-0016). */
.user-data__section {
    margin: 0 0 1.5rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-surface);
}

    .user-data__section h2 {
        margin: 0 0 0.75rem;
        font-size: 1.1rem;
    }

.user-data__label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.user-data__file {
    max-width: 100%;
}

.user-data__confirm {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1rem;
}

    .user-data__confirm p {
        flex-basis: 100%;
        margin: 0;
    }

.user-data__feedback {
    margin: 0.75rem 0 0;
    min-height: 1.5em;
    font-weight: 600;
}

    .user-data__feedback.is-error {
        color: #a3261b;
    }

/* ---- Circuit editor: wiring from the keyboard ---- */
.wire-connector {
    margin: 0;
}

.wire-connector__fields {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 1rem;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.wire-connector__heading {
    margin-bottom: 0.5rem;
    padding: 0;
    font-weight: 700;
}

.wire-connector__field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.9rem;
}

    .wire-connector__field select {
        min-width: 12rem;
        padding: 0.35rem;
        border: 1px solid var(--color-control-border);
        border-radius: 0.375rem;
        background: var(--color-surface);
        color: var(--color-text);
        font: inherit;
    }

.wire-connector__error {
    margin: 0.5rem 0 0;
    color: var(--canvas-error);
    font-weight: 600;
}
