:root {
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --brand-soft: #eaf1ff;
    --surface-page: #f5f7fb;
    --surface-card: #ffffff;
    --surface-soft: #f8fafc;
    --text-strong: #172033;
    --text-body: #334155;
    --text-muted: #748094;
    --border-soft: #e1e7ef;
    --border-medium: #cfd8e5;
    --pupil-bubble: #f1f5f9;
    --pst-bubble: #eaf1ff;
    --shadow-card: 0 12px 30px rgba(24, 39, 75, 0.07);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text-body);
    background: var(--surface-page);
}

body {
    min-width: 320px;
}

button,
textarea,
input {
    font: inherit;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.25);
    outline-offset: 2px;
}

a {
    color: var(--brand-dark);
}

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

h1:focus {
    outline: none;
}

.simulation-page {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: clamp(1.1rem, 2.5vw, 2rem) clamp(1rem, 3vw, 2.5rem) 2.5rem;
}

.simulation-intro {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 1.15rem;
}

.simulation-intro h1 {
    margin-bottom: 0.45rem;
    font-size: clamp(1.65rem, 3vw, 2.35rem);
    line-height: 1.08;
    color: var(--text-strong);
}

.simulation-intro p {
    max-width: 780px;
    margin-bottom: 0;
    line-height: 1.6;
    color: var(--text-muted);
}

.eyebrow,
.panel-kicker,
.scenario-label {
    display: block;
    margin-bottom: 0.28rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--brand-dark);
}

.simulation-actions {
    flex: 0 0 auto;
}

/* Hover help works even for disabled Finish buttons, which do not receive
   pointer events consistently in browsers. */
.simulation-finish-tooltip {
    display: inline-flex;
    max-width: 100%;
    cursor: help;
}
.simulation-finish-tooltip button:disabled {
    pointer-events: none;
}
.simulation-finish-bottom {
    display: flex;
    justify-content: center;
    margin-top: 1.8rem;
    padding: 1rem 0 0.25rem;
}


.btn-secondary-mathai,
.btn-send {
    border: 0;
    border-radius: 10px;
    min-height: 42px;
    padding: 0.65rem 1rem;
    font-weight: 750;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn-secondary-mathai {
    background: white;
    color: var(--text-strong);
    border: 1px solid var(--border-medium);
}

.btn-send {
    background: var(--brand);
    color: white;
    text-decoration: none;
}

.btn-send:hover:not(:disabled),
.btn-secondary-mathai:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(24, 39, 75, 0.1);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.scenario-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(140px, 1fr)) auto;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: white;
    box-shadow: 0 5px 16px rgba(24, 39, 75, 0.035);
}

.scenario-strip strong {
    display: block;
    color: var(--text-strong);
    font-size: 0.92rem;
}

.scenario-status {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: #166534;
    font-size: 0.82rem;
    font-weight: 750;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 4px #dcfce7;
}

.simulation-grid {
    display: grid;
    grid-template-columns: minmax(330px, 0.92fr) minmax(430px, 1.35fr);
    gap: 1rem;
    align-items: stretch;
}

.conversation-column {
    min-width: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0.75rem;
}

.chat-panel,
.whiteboard-panel,
.chat-input-card,
.not-found-card {
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    background: var(--surface-card);
    box-shadow: var(--shadow-card);
}

.chat-panel,
.whiteboard-panel {
    min-height: 585px;
    overflow: hidden;
}

.panel-heading {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border-soft);
}

.panel-heading h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-strong);
}

.panel-kicker {
    color: var(--text-muted);
}

.chat-history {
    height: 513px;
    overflow-y: auto;
    padding: 1.1rem;
    scroll-behavior: smooth;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}

.chat-message {
    width: min(86%, 560px);
    margin-bottom: 1rem;
}

.chat-message--pst {
    margin-left: auto;
}

.chat-message--pupil {
    margin-right: auto;
}

.chat-message__meta {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.3rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chat-message--pst .chat-message__meta {
    justify-content: flex-end;
}

.chat-message__speaker {
    font-weight: 800;
    color: var(--text-body);
}

.chat-message__bubble {
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-message--pst .chat-message__bubble {
    background: var(--pst-bubble);
    border-bottom-right-radius: 4px;
}

.chat-message--pupil .chat-message__bubble {
    background: var(--pupil-bubble);
    border-bottom-left-radius: 4px;
}

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 62px;
    min-height: 40px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.chat-input-card {
    padding: 0.8rem;
}

.chat-input {
    width: 100%;
    resize: vertical;
    min-height: 78px;
    max-height: 180px;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border-medium);
    border-radius: 11px;
    background: white;
    color: var(--text-strong);
}

.chat-input::placeholder {
    color: #9aa5b4;
}

.chat-input-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-top: 0.65rem;
}

/* v11.8: keyboard hint next to the Send button. */
.chat-input-hint {
    margin-right: auto;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.whiteboard-toolbar {
    min-height: 48px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-soft);
}

.whiteboard-toolbar button {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.55rem;
    border-radius: 8px;
    border: 1px solid var(--border-medium);
    background: white;
    color: var(--text-body);
}

.whiteboard-surface {
    min-height: 465px;
    display: grid;
    place-items: center;
    padding: 2rem;
    background-color: #fff;
    background-image:
        linear-gradient(#edf1f6 1px, transparent 1px),
        linear-gradient(90deg, #edf1f6 1px, transparent 1px);
    background-size: 24px 24px;
}

.whiteboard-placeholder {
    width: min(440px, 100%);
    padding: 1.5rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-soft);
    text-align: center;
    box-shadow: 0 8px 26px rgba(24, 39, 75, 0.08);
}

.whiteboard-placeholder__icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 0.8rem;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 1.55rem;
    font-weight: 800;
}

.whiteboard-placeholder strong {
    display: block;
    color: var(--text-strong);
}

.whiteboard-placeholder p {
    margin: 0.5rem 0 0;
    line-height: 1.55;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.not-found-card {
    width: min(620px, calc(100% - 2rem));
    margin: 4rem auto;
    padding: 2rem;
}

#mathai-update-ui {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1100;
    max-width: 440px;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    background: #172033;
    color: white;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
}

#mathai-update-ui[hidden] {
    display: none;
}

#mathai-update-ui button {
    flex: 0 0 auto;
    border: 0;
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    background: white;
    color: #172033;
    font-weight: 750;
}

#blazor-error-ui {
    color-scheme: light only;
    background: #fff7ed;
    bottom: 0;
    box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.12);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.75rem 3rem 0.8rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1200;
    color: #7c2d12;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.9rem;
    top: 0.65rem;
}

.blazor-error-boundary {
    padding: 1rem;
    background: #b91c1c;
    color: white;
}

.blazor-error-boundary::after {
    content: "Det oppstod en feil.";
}

.mathai-loading {
    min-height: 100vh;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.9rem;
    background: var(--surface-page);
}

.loading-progress {
    position: relative;
    display: block;
    width: 7rem;
    height: 7rem;
}

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

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

.loading-progress-text {
    margin-top: -5.25rem;
    min-height: 1.5rem;
    text-align: center;
    font-weight: 800;
    color: var(--text-strong);
}

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

.mathai-loading-message {
    margin-top: 2.8rem;
    color: var(--text-muted);
}

@media (max-width: 980px) {
    .simulation-grid {
        grid-template-columns: 1fr;
    }

    .chat-panel,
    .whiteboard-panel {
        min-height: auto;
    }

    .chat-history {
        height: 460px;
    }

    .whiteboard-surface {
        min-height: 420px;
    }
}

@media (max-width: 700px) {
    .simulation-intro {
        align-items: stretch;
        flex-direction: column;
        gap: 1rem;
    }

    .simulation-actions .btn-secondary-mathai {
        width: 100%;
    }

    .scenario-strip {
        grid-template-columns: 1fr 1fr;
    }

    .scenario-status {
        justify-self: start;
    }

    .chat-input-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .chat-input-hint {
        display: none;
    }

    .btn-send {
        width: 100%;
    }

    .chat-message {
        width: 92%;
    }
}

@media (max-width: 460px) {
    .scenario-strip {
        grid-template-columns: 1fr;
    }

    .whiteboard-toolbar button span {
        display: none;
    }
}


.scenario-status--error {
    color: #b91c1c;
}

.scenario-status--error .status-dot {
    background: #ef4444;
    box-shadow: 0 0 0 4px #fee2e2;
}

.api-error {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: -0.25rem 0 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid #fecaca;
    border-radius: 12px;
    background: #fff7f7;
    color: #991b1b;
    font-size: 0.86rem;
}

@media (max-width: 700px) {
    .api-error {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Phase 3: KaTeX expression shown separately from the pupil's natural-language message. */
.chat-message__text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-message__math {
    margin-top: 0.65rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(100, 116, 139, 0.18);
    overflow-x: auto;
    overflow-y: hidden;
    color: var(--text-strong);
}

.chat-message__math .katex-display {
    margin: 0.15rem 0;
    text-align: left;
}

.chat-message__math-fallback {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.86rem;
}

/* Phase 3.1 developer-only pupil-state diagnostics. */
.pupil-state-debug {
    margin: 0 0 1rem;
    padding: .8rem 1rem;
    border: 1px dashed rgba(84, 102, 124, .45);
    border-radius: 12px;
    background: rgba(245, 247, 250, .8);
    font-size: .9rem;
}

.pupil-state-debug summary {
    cursor: pointer;
    font-weight: 700;
}

.pupil-state-debug__grid {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    gap: .35rem 1rem;
    margin-top: .75rem;
}

.pupil-state-debug__grid strong {
    text-align: right;
}

/* Phase 3.2: PST-editable pupil profile. */
.pupil-settings {
    margin: 0 0 1rem;
    padding: .8rem 1rem;
    border: 1px solid rgba(67, 97, 238, .2);
    border-radius: 12px;
    background: rgba(255, 255, 255, .86);
    font-size: .92rem;
}

.pupil-settings summary {
    cursor: pointer;
    font-weight: 800;
    color: var(--text-strong);
}

.pupil-settings__content {
    display: grid;
    gap: .65rem;
    margin-top: .8rem;
}

.pupil-settings__content label {
    font-weight: 800;
    color: var(--text-strong);
}

.pupil-settings__help {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.45;
}

.pupil-prompt-editor {
    width: 100%;
    min-height: 10rem;
    resize: vertical;
    padding: .85rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: var(--text-strong);
    font: inherit;
    line-height: 1.45;
}

.pupil-prompt-editor:focus {
    outline: 2px solid rgba(37, 99, 235, .2);
    border-color: #60a5fa;
}

.pupil-prompt-editor:disabled {
    background: #f8fafc;
    color: #64748b;
}

.pupil-settings__actions {
    display: flex;
    align-items: center;
    gap: .8rem;
    flex-wrap: wrap;
}

.pupil-settings__actions span {
    color: var(--text-muted);
    font-size: .84rem;
}

.btn-secondary-mathai--small {
    padding: .5rem .75rem;
    font-size: .84rem;
}

@media (max-width: 700px) {
    .pupil-settings__actions {
        align-items: stretch;
        flex-direction: column;
    }

    .btn-secondary-mathai--small {
        width: 100%;
    }
}

/* Phase 3.3: browser-local pupil profile persistence status. */
.pupil-storage-status {
    padding: .55rem .7rem;
    border-radius: 8px;
    background: rgba(241, 245, 249, .9);
    color: var(--text-muted);
    font-size: .82rem;
    line-height: 1.35;
}

/* Phase 4: interactive local vector whiteboard. */
.whiteboard-toolbar button {
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease, transform .12s ease;
}

.whiteboard-toolbar button:hover:not(:disabled) {
    border-color: #94a3b8;
    background: #f8fafc;
}

.whiteboard-toolbar button:active:not(:disabled) {
    transform: translateY(1px);
}

.whiteboard-toolbar button:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.whiteboard-toolbar button.whiteboard-tool--active {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .12);
}

.whiteboard-toolbar__separator {
    width: 1px;
    height: 26px;
    margin: 0 .15rem;
    background: var(--border-medium);
}

.whiteboard-surface--interactive {
    position: relative;
    display: block;
    min-height: 465px;
    padding: 0;
    overflow: hidden;
}

.mathai-whiteboard-svg {
    display: block;
    width: 100%;
    height: 465px;
    min-height: 465px;
    cursor: crosshair;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.whiteboard-empty-hint {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: grid;
    gap: .25rem;
    width: min(360px, calc(100% - 3rem));
    padding: 1rem 1.15rem;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    background: rgba(255, 255, 255, .86);
    color: var(--text-muted);
    text-align: center;
    pointer-events: none;
}

.whiteboard-empty-hint strong {
    color: var(--text-strong);
}

.whiteboard-status {
    display: flex;
    align-items: center;
    gap: .8rem 1.2rem;
    flex-wrap: wrap;
    padding: .55rem .75rem;
    border-top: 1px solid var(--border-soft);
    background: #fbfcfe;
    color: var(--text-muted);
    font-size: .78rem;
}

.whiteboard-status strong {
    color: var(--text-strong);
}

@media (max-width: 980px) {
    .mathai-whiteboard-svg {
        height: 420px;
        min-height: 420px;
    }
}

@media (max-width: 700px) {
    .whiteboard-toolbar__separator {
        display: none;
    }

    .whiteboard-status {
        align-items: flex-start;
        flex-direction: column;
        gap: .25rem;
    }
}


/* Phase 6.1 gesture recognizer diagnostics */
.whiteboard-gesture-debug {
    flex-basis: 100%;
    padding-top: .15rem;
    font-variant-numeric: tabular-nums;
}

/* Phase 5B.1 development diagnostics */
.scene-action-debug-list {
    display: grid;
    gap: 0.45rem;
    margin-top: 0.75rem;
}

.scene-action-debug-list code {
    display: block;
    padding: 0.55rem 0.7rem;
    border: 1px solid #dbe3ee;
    border-radius: 0.55rem;
    background: #f8fafc;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Phase 7: structured pupil scenarios. */
.pupil-preset-row {
    display: grid;
    grid-template-columns: minmax(170px, 240px) minmax(240px, 1fr);
    gap: .75rem 1rem;
    align-items: center;
    padding: .8rem;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    background: #f8fafc;
}

.pupil-preset-row label,
.pupil-field label {
    font-weight: 800;
    color: var(--text-strong);
}

.pupil-preset-row select,
.pupil-field input,
.pupil-field select,
.pupil-field textarea {
    width: 100%;
    padding: .65rem .75rem;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    color: var(--text-strong);
    font: inherit;
}

.pupil-field textarea {
    resize: vertical;
    line-height: 1.4;
}

.pupil-preset-row select:focus,
.pupil-field input:focus,
.pupil-field select:focus,
.pupil-field textarea:focus {
    outline: 2px solid rgba(37, 99, 235, .18);
    border-color: #60a5fa;
}

.pupil-scenario-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .8rem 1rem;
}

.pupil-field {
    display: grid;
    gap: .35rem;
}

.pupil-field--wide {
    grid-column: 1 / -1;
}

@media (max-width: 760px) {
    .pupil-preset-row,
    .pupil-scenario-grid {
        grid-template-columns: 1fr;
    }

    .pupil-field--wide {
        grid-column: auto;
    }
}

/* Phase 7.6/7.6.3: paint/erase affordance for semantic fraction models. */
.mathai-whiteboard-svg[data-tool="shade"] {
    cursor: crosshair;
}

.mathai-whiteboard-svg[data-tool="unshade"] {
    cursor: cell;
}

/* Phase 7.6.1: visible raster paint overlay above the semantic SVG board. */
.mathai-whiteboard-svg {
    position: relative;
    z-index: 1;
}

.mathai-whiteboard-paint {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: block;
    width: 100%;
    height: 465px;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.whiteboard-empty-hint {
    z-index: 3;
}

@media (max-width: 980px) {
    .mathai-whiteboard-paint {
        height: 420px;
    }
}

/* Phase 7.8: PST text placement + object selection/movement/deletion. */
.mathai-whiteboard-svg[data-tool="text"] {
    cursor: text;
}

.mathai-whiteboard-svg[data-tool="select"] {
    cursor: move;
}

/* Phase 8: semantic data/graph editor. */
.whiteboard-graph-editor {
    display: grid;
    gap: .75rem;
    padding: .85rem .9rem 1rem;
    border-bottom: 1px solid var(--border-soft);
    background: #f8fafc;
}

.whiteboard-graph-editor__heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.whiteboard-graph-editor__heading > div {
    display: grid;
    gap: .15rem;
}

.whiteboard-graph-editor__heading strong {
    color: var(--text-strong);
    font-size: .95rem;
}

.whiteboard-graph-editor__heading span {
    color: var(--text-muted);
    font-size: .78rem;
    line-height: 1.4;
}

.whiteboard-graph-editor__help {
    color: #94a3b8;
    font-size: .78rem;
    line-height: 1.4;
}

.whiteboard-graph-editor__close {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.whiteboard-graph-editor__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .6rem;
}

.whiteboard-graph-editor label {
    display: grid;
    gap: .28rem;
    color: var(--text-body);
    font-size: .78rem;
    font-weight: 600;
}

.whiteboard-graph-editor__wide {
    grid-column: span 3;
}

.whiteboard-graph-editor__full {
    grid-column: span 4;
}

.whiteboard-graph-editor__full small {
    color: var(--text-muted);
    font-size: .74rem;
    font-weight: 400;
    line-height: 1.4;
}

.whiteboard-graph-editor input,
.whiteboard-graph-editor select,
.whiteboard-graph-editor textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    background: white;
    color: var(--text-body);
    font: inherit;
    font-weight: 400;
    padding: .5rem .55rem;
}

.whiteboard-graph-editor textarea {
    resize: vertical;
    min-height: 7.5rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8rem;
    line-height: 1.45;
}

.whiteboard-graph-editor input::placeholder,
.whiteboard-graph-editor textarea::placeholder {
    color: #b8c2cf;
    opacity: 1;
}


.whiteboard-graph-editor input:focus,
.whiteboard-graph-editor select:focus,
.whiteboard-graph-editor textarea:focus {
    outline: 2px solid rgba(37, 99, 235, .18);
    border-color: #60a5fa;
}

.whiteboard-graph-editor__data {
    display: grid;
}

.whiteboard-graph-editor__error {
    padding: .55rem .65rem;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: #991b1b;
    font-size: .8rem;
}

.whiteboard-graph-editor__actions {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: .5rem;
}

.whiteboard-graph-editor__actions button {
    min-height: 34px;
    padding: .4rem .65rem;
    border-radius: 8px;
    border: 1px solid var(--border-medium);
    background: white;
    color: var(--text-body);
    cursor: pointer;
}

.whiteboard-graph-editor__actions button:hover {
    background: #f1f5f9;
}

.whiteboard-graph-editor__actions .whiteboard-graph-editor__primary {
    border-color: #2563eb;
    background: #2563eb;
    color: white;
}

.whiteboard-graph-editor__actions .whiteboard-graph-editor__primary:hover {
    background: #1d4ed8;
}

@media (max-width: 760px) {
    .whiteboard-graph-editor__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .whiteboard-graph-editor__wide {
        grid-column: span 1;
    }

    .whiteboard-graph-editor__full {
        grid-column: span 2;
    }

    .whiteboard-graph-editor__actions {
        grid-template-columns: 1fr 1fr;
    }

    .whiteboard-graph-editor__actions > span {
        display: none;
    }
}

/* v43.7: data series as tabs in the graph editor */
.wb-series {
    display: grid;
    gap: .5rem;
}

.wb-series__tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .25rem;
    border-bottom: 1px solid var(--border-medium);
}

.whiteboard-graph-editor .wb-series__tab,
.whiteboard-graph-editor .wb-series__add {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .38rem .7rem;
    border: 1px solid var(--border-medium);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: #f1f5f9;
    color: var(--text-body);
    font: inherit;
    font-size: .82rem;
    cursor: pointer;
    margin-bottom: -1px;
}

.whiteboard-graph-editor .wb-series__tab--active {
    background: white;
    font-weight: 600;
    border-bottom: 1px solid white;
}

.whiteboard-graph-editor .wb-series__add {
    background: transparent;
    border-style: dashed;
    color: #2563eb;
    font-weight: 600;
}

.wb-series__dot {
    width: .7rem;
    height: .7rem;
    border-radius: 3px;
    flex: none;
}

.wb-series__panel {
    display: grid;
    gap: .45rem;
}

.wb-series__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: .6rem;
    align-items: end;
}

.whiteboard-graph-editor .wb-series__remove {
    min-height: 34px;
    padding: .4rem .65rem;
    border-radius: 8px;
    border: 1px solid #fecaca;
    background: white;
    color: #991b1b;
    font: inherit;
    font-size: .82rem;
    cursor: pointer;
}

.wb-series__ticks {
    display: grid;
    gap: .3rem;
}

.wb-series__ticks-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.wb-series__ticklist {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    max-height: 4.6rem;
    overflow-y: auto;
    padding: .1rem;
}

.whiteboard-graph-editor .wb-series__tick {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .5rem;
    border: 1px solid var(--border-medium);
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 400;
    cursor: pointer;
    background: white;
}

.whiteboard-graph-editor .wb-series__tick--on {
    border-color: #2563eb;
    background: #eff6ff;
}

.whiteboard-graph-editor .wb-series__tick input {
    width: auto;
    margin: 0;
}

@media (max-width: 760px) {
    .wb-series__row {
        grid-template-columns: 1fr;
    }
}


/* Evidence-confirmed understanding change: browser top-layer modal, not a dismissible toast. */
.understanding-dialog {
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    width: min(94vw, 560px);
    max-height: min(90vh, 800px);
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    background: #fff;
    color: #172033;
    box-shadow: 0 24px 90px rgba(4, 20, 43, .32);
    overflow-y: auto;
}
.understanding-dialog::backdrop {
    background: rgba(11, 26, 47, .72);
}
.understanding-dialog__content {
    display: flex;
    flex-direction: column;
    gap: .8rem;
    padding: clamp(1.2rem, 4vw, 2rem);
}
.understanding-dialog__content h2,
.understanding-dialog__content p { margin: 0; }
.understanding-dialog__symbol {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e4f5ed;
    color: #146c45;
    font-size: 1.5rem;
    font-weight: 700;
}
.understanding-dialog__belief {
    padding: .75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #f8fafc;
    overflow-wrap: anywhere;
}
.understanding-dialog__belief span {
    display: block;
    margin-bottom: .28rem;
    font-size: .78rem;
    font-weight: 700;
    color: #475569;
}
.understanding-dialog__note {
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.understanding-dialog__qualification {
    font-size: .83rem;
    color: #475569;
}
.understanding-dialog__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: .35rem;
}
.understanding-dialog__actions button {
    flex: 1 1 180px;
    min-height: 44px;
}
.understanding-dialog__actions button:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 3px;
}


/* Evidence-confirmed understanding change: browser top-layer modal, not a dismissible toast. */
.understanding-dialog {
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    width: min(94vw, 560px);
    max-height: min(90vh, 800px);
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    background: #fff;
    color: #172033;
    box-shadow: 0 24px 90px rgba(4, 20, 43, .32);
    overflow-y: auto;
}
.understanding-dialog::backdrop {
    background: rgba(11, 26, 47, .72);
}
.understanding-dialog__content {
    display: flex;
    flex-direction: column;
    gap: .8rem;
    padding: clamp(1.2rem, 4vw, 2rem);
}
.understanding-dialog__content h2,
.understanding-dialog__content p { margin: 0; }
.understanding-dialog__symbol {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e4f5ed;
    color: #146c45;
    font-size: 1.5rem;
    font-weight: 700;
}
.understanding-dialog__belief {
    padding: .75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #f8fafc;
    overflow-wrap: anywhere;
}
.understanding-dialog__belief span {
    display: block;
    margin-bottom: .28rem;
    font-size: .78rem;
    font-weight: 700;
    color: #475569;
}
.understanding-dialog__note {
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.understanding-dialog__qualification {
    font-size: .83rem;
    color: #475569;
}
.understanding-dialog__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: .35rem;
}
.understanding-dialog__actions button {
    flex: 1 1 180px;
    min-height: 44px;
}
.understanding-dialog__actions button:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 3px;
}

/* Centre the green tick and the pupil's name together in the FIRST row.
   This is shared by instructor preview and real PST lessons. */
.understanding-dialog__header {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: .85rem;
    min-height: 48px;
    width: 100%;
}
.understanding-dialog__header .understanding-dialog__symbol {
    flex: 0 0 44px;
}
.understanding-dialog__pupil {
    min-width: 0;
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    font-weight: 800;
    line-height: 1.3;
    color: #146c45;
    overflow-wrap: anywhere;
}
.understanding-dialog__content > h2 {
    text-align: center;
}

/* Colleague-provided graph templates live in their own flexible row, not in
   the 4-column Save/Cancel grid: additional presets must never move Save. */
.whiteboard-graph-editor__presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .65rem;
    margin: .55rem 0;
}
.whiteboard-graph-editor__presets button {
    min-height: 34px;
    padding: .4rem .7rem;
    border-radius: 8px;
    border: 1px solid var(--border-medium);
    background: var(--surface-soft, #f4f6fa);
    color: var(--text-body);
    cursor: pointer;
}
.whiteboard-graph-editor__presets button:hover,
.whiteboard-graph-editor__presets button:focus-visible {
    background: #e8f1fc;
    border-color: #8badde;
}
