:root {
    --bg: #eef1f7;
    --card: #ffffff;
    --card-soft: #f8fbff;
    --panel: #f3f6fb;
    --panel-2: #edf2fa;
    --border: #d8e1ef;
    --border-strong: #c7d4e8;
    --text: #1d2740;
    --heading: #25314d;
    --muted: #6d7a91;
    --blue: #2c63ea;
    --blue-dark: #1f4fd1;
    --blue-soft: #dfe9ff;
    --green: #17834d;
    --green-soft: #eaf8f0;
    --amber: #c98a17;
    --amber-soft: #fff6e3;
    --red: #c45858;
    --red-soft: #fff0f0;
    --shadow: 0 18px 44px rgba(33, 47, 79, 0.08);
    --shadow-soft: 0 12px 28px rgba(33, 47, 79, 0.07);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.exam-page-body {
    min-height: 100vh;
}

.exam-page-shell {
    max-width: 1500px;
    margin: 0 auto;
    padding: 18px 22px 120px;
}

.exam-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
    padding: 0 2px;
}

.back-link {
    text-decoration: none;
    color: var(--muted);
    font-weight: 700;
    font-size: 15px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
}

.topbar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #f3f6fb;
    color: var(--heading);
    font-size: 11px;
}

.exam-main-card {
    background: var(--card);
    border-radius: 28px;
    box-shadow: var(--shadow);
    border: 1px solid #e3e9f4;
    overflow: hidden;
    min-height: 78vh;
}

.loading-card,
.error-card {
    margin: 22px;
    padding: 18px 20px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #f9fbfe;
    white-space: pre-wrap;
}

.error-card {
    background: #fff5f5;
    border-color: #f0d0d0;
    color: #a53a3a;
}

.exam-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 16px;
    padding: 14px;
    align-items: start;
}

.exam-left {
    min-width: 0;
}

.exam-right {
    position: sticky;
    top: 18px;
}

.summary-card {
    background: linear-gradient(180deg, #e8efff 0%, #edf3ff 100%);
    border: 1px solid #c9d7f1;
    border-radius: 18px;
    overflow: hidden;
    margin-bottom: 16px;
}

.summary-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px 10px;
}

.summary-heading {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: var(--heading);
}

.summary-subheading {
    margin: 6px 0 0;
    font-size: 13px;
    color: #43526d;
}

.summary-icons {
    display: flex;
    gap: 8px;
    color: #88a0d2;
    font-size: 12px;
    padding-top: 2px;
}

.summary-body {
    padding: 0 18px 10px;
}

.summary-list {
    margin: 0;
    padding-left: 18px;
    color: #32415d;
    line-height: 1.5;
    font-size: 14px;
}

.summary-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.38);
    border-top: 1px solid #d6e0f4;
}

.support-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--blue-soft);
    color: var(--blue-dark);
    font-weight: 700;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 13px;
}

.progress-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--heading);
    font-weight: 700;
    font-size: 14px;
}

.progress-dots {
    display: flex;
    align-items: center;
    gap: 7px;
}

.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    border: 2px solid #a3b6db;
    background: #fff;
}

    .progress-dot.complete {
        background: var(--blue);
        border-color: var(--blue);
    }

    .progress-dot.active {
        border-color: var(--blue);
    }

.section-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--heading);
    margin: 0 0 10px;
}

#questionViewport {
    min-height: 720px;
    overflow: visible;
}

#currentSectionTitle {
    margin-bottom: 12px;
}

.question-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    box-shadow: var(--shadow-soft);
    overflow: visible;
}

    .question-card.active-question {
        border-color: #a7bcf2;
        box-shadow: 0 0 0 3px rgba(44, 99, 234, 0.08), var(--shadow-soft);
    }

.question-card--short_response {
    overflow: visible;
}

.question-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 10px;
}

.badge,
.mark-badge,
.type-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 700;
}

.badge {
    background: #eef3fb;
    color: #556883;
}

.mark-badge {
    background: #ecf3ff;
    color: var(--blue-dark);
}

.type-badge {
    background: #f3f6fb;
    color: var(--heading);
}

.question-text {
    font-size: 16px;
    font-weight: 800;
    line-height: 1.52;
    color: var(--heading);
    margin-bottom: 12px;
    max-width: 95ch;
}

.question-support-pill-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.question-support-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    background: #f3f7ff;
    color: #34528e;
    border: 1px solid #d9e5ff;
    font-size: 11px;
    font-weight: 700;
}

.question-body-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}

.question-body-grid--mcq,
.question-body-grid--short_response,
.question-body-grid--extended_response {
    gap: 12px;
}

.question-workspace {
    display: grid;
    gap: 14px;
}

.question-workspace--mcq {
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    align-items: start;
}

.question-workspace--short {
    grid-template-columns: minmax(560px, 1fr) minmax(360px, 440px);
    align-items: start;
}

.question-workspace--extended {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
}

.workspace-main,
.workspace-support,
.stimulus-panel,
.workspace-side-card,
.options,
.option {
    min-width: 0;
}

.workspace-main {
    min-width: 0;
    overflow: visible;
}

.workspace-main--sticky-stimulus {
    position: sticky;
    top: 18px;
    align-self: start;
}

.workspace-main--extended {
    min-width: 0;
}

.workspace-support {
    min-width: 0;
}

.workspace-support--mcq,
.workspace-support--short {
    display: grid;
    gap: 12px;
}

.workspace-side-card {
    background: #fbfcfe;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 1px 0 rgba(33, 47, 79, 0.02);
}

.workspace-side-card--groups,
.workspace-side-card--mcq-answer {
    padding: 14px;
}

.workspace-side-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 800;
    color: var(--heading);
}

.workspace-side-subtitle {
    margin-bottom: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
}

.stimulus-panel {
    border: 1px dashed var(--border-strong);
    border-radius: 16px;
    background: #fbfcfe;
    padding: 12px;
    min-width: 0;
    overflow: visible;
    max-width: 100%;
}

.stimulus-title {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 700;
}

.stimulus-render-wrap,
.ui-renderer-stage,
.ui-renderer-fitbox {
    overflow: visible !important;
}

.stimulus-panel .ui-renderer-stage,
.stimulus-panel .ui-renderer-fitbox,
.stimulus-panel .ui-renderer-scale-wrap,
.stimulus-panel .ui-renderer-root {
    max-width: 100%;
}

.ui-renderer-stage {
    width: 100%;
    display: block;
    padding: 6px 0;
    min-width: 0;
}

.ui-renderer-fitbox {
    width: 100%;
    display: block;
    min-width: 0;
}

.ui-renderer-scale-wrap {
    transform-origin: top left;
    will-change: transform;
}

.stimulus-panel .ui-renderer-root.desktop,
.stimulus-panel .ui-renderer-root.mobile {
    margin: 0;
}

/* MCQ */

.options {
    display: grid;
    gap: 10px;
}

.option {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    overflow: visible;
}

    .option label {
        display: grid;
        grid-template-columns: 18px 18px minmax(0, 1fr);
        align-items: start;
        gap: 10px;
        width: 100%;
        cursor: pointer;
        color: var(--text);
        line-height: 1.5;
        font-size: 14px;
    }

        .option label input[type="radio"] {
            margin: 2px 0 0;
            width: 14px;
            height: 14px;
            flex-shrink: 0;
        }

    .option strong,
    .option .mcq-option-key {
        min-width: 18px;
        font-weight: 700;
        line-height: 1.45;
    }

    .option label span,
    .option label div,
    .option label p,
    .option-text,
    .mcq-option-text {
        min-width: 0;
        display: block;
        white-space: normal;
        overflow-wrap: break-word;
        word-break: normal;
        line-height: 1.5;
    }

/* Generic response boxes */

.sentence-starters {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 11px 12px;
}

    .sentence-starters h4 {
        margin: 0 0 7px;
        font-size: 13px;
        color: var(--heading);
    }

    .sentence-starters ul {
        margin: 0;
        padding-left: 18px;
        color: var(--muted);
        line-height: 1.5;
        font-size: 13px;
    }

.question-answer-box textarea {
    width: 100%;
    min-height: 150px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 13px 14px;
    font-size: 15px;
    font-family: Arial, sans-serif;
    color: var(--text);
    background: #fff;
    outline: none;
}

    .question-answer-box textarea:focus {
        border-color: #9cb6f1;
        box-shadow: 0 0 0 3px rgba(44, 99, 234, 0.08);
    }

.question-answer-box--compact textarea {
    min-height: 116px;
    font-size: 14px;
    line-height: 1.5;
}

.question-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.question-status {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

    .question-status.met {
        color: #15803d;
    }

    .question-status.partial {
        color: #b45309;
    }

    .question-status.missing {
        color: #b91c1c;
    }

.question-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    border: none;
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

    button:hover {
        opacity: 0.97;
    }

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

.primary-btn {
    background: var(--blue);
    color: #fff;
}

    .primary-btn:hover {
        background: var(--blue-dark);
    }

.secondary-btn {
    background: #53627c;
    color: #fff;
}

    .secondary-btn:hover {
        background: #43516a;
    }

.ghost-btn {
    background: #eef3fb;
    color: var(--heading);
}

    .ghost-btn:hover {
        background: #e4ebf8;
    }

.danger-btn {
    background: #fdeaea;
    color: #b25252;
    border: 1px solid #efcaca;
}

.exam-nav-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.exam-nav-right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.side-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
    padding: 16px;
}

    .side-panel h3 {
        margin: 0 0 10px;
        font-size: 16px;
        color: var(--heading);
    }

.side-progress-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0 12px;
    border-bottom: 1px solid #edf1f7;
    margin-bottom: 10px;
}

.side-small,
.small-muted {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.45;
}

.criteria-list {
    display: grid;
    gap: 0;
}

.criteria-item {
    display: grid;
    grid-template-columns: 12px 1fr auto;
    gap: 10px;
    align-items: start;
    padding: 10px 0;
    border-bottom: 1px solid #edf1f7;
}

    .criteria-item:last-child {
        border-bottom: none;
    }

.criteria-dot {
    width: 11px;
    height: 11px;
    border-radius: 999px;
    margin-top: 4px;
    background: #c4ccd8;
}

    .criteria-dot.met {
        background: var(--green);
    }

    .criteria-dot.partial {
        background: var(--amber);
    }

    .criteria-dot.missing {
        background: #afb7c3;
    }

.criteria-status {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-align: right;
    white-space: nowrap;
}

    .criteria-status.met {
        color: var(--green);
    }

    .criteria-status.partial {
        color: var(--amber);
    }

    .criteria-status.missing {
        color: #959eac;
    }

.side-feedback-box {
    margin-top: 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 13px;
    line-height: 1.5;
    color: var(--heading);
    font-size: 14px;
}

    .side-feedback-box h4 {
        margin: 0 0 7px;
        font-size: 13px;
        color: var(--heading);
    }

.builder-reminders,
.concept-reminders {
    margin-top: 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
}

    .builder-reminders h4,
    .concept-reminders h4 {
        margin: 0 0 7px;
        font-size: 13px;
        color: var(--heading);
    }

    .builder-reminders ul,
    .concept-reminders ul {
        margin: 0;
        padding-left: 18px;
        color: var(--muted);
        line-height: 1.5;
        font-size: 13px;
    }

/* Floating chat */

.floating-chat {
    position: fixed;
    right: 22px;
    bottom: 18px;
    width: 345px;
    max-width: calc(100vw - 24px);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 18px 48px rgba(39, 72, 146, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.28);
    z-index: 999;
    background: #fff;
}

    .floating-chat.minimised .chat-body,
    .floating-chat.minimised .chat-footer,
    .floating-chat.minimised .chat-context {
        display: none;
    }

.chat-header {
    background: linear-gradient(135deg, #2a61ea 0%, #1f50d0 100%);
    color: #fff;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.chat-title {
    font-weight: 800;
    font-size: 16px;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-btn {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    padding: 0;
    font-size: 14px;
}

.chat-context {
    background: #edf3ff;
    border-bottom: 1px solid #dbe5ff;
    padding: 8px 12px;
    font-size: 12px;
    color: #35508d;
    line-height: 1.4;
}

.chat-body {
    height: 248px;
    overflow-y: auto;
    background: #fff;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-bubble {
    max-width: 88%;
    padding: 11px 13px;
    border-radius: 18px;
    line-height: 1.46;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
}

    .chat-bubble.assistant {
        align-self: flex-start;
        background: #eef3fb;
        color: var(--heading);
        border-bottom-left-radius: 6px;
    }

    .chat-bubble.user {
        align-self: flex-end;
        background: #dfe9ff;
        color: #123980;
        border-bottom-right-radius: 6px;
    }

    .chat-bubble.system {
        align-self: flex-start;
        background: #f8fafc;
        color: var(--muted);
        border: 1px solid var(--border);
        font-style: italic;
    }

    .chat-bubble.thinking {
        opacity: 0.6;
        font-style: italic;
    }

.chat-footer {
    background: #fff;
    padding: 10px;
    border-top: 1px solid #edf1f7;
}

.chat-input-row {
    display: grid;
    grid-template-columns: 1fr 40px;
    gap: 8px;
    align-items: center;
}

.chat-input {
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 10px 12px;
    font-size: 13px;
    outline: none;
}

    .chat-input:focus {
        border-color: #9cb6f1;
        box-shadow: 0 0 0 3px rgba(44, 99, 234, 0.08);
    }

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    padding: 0;
    background: var(--blue);
    color: #fff;
    font-size: 15px;
}

.chat-quick-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.chat-chip {
    border: none;
    border-radius: 999px;
    padding: 7px 9px;
    background: #eef3fb;
    color: var(--heading);
    font-size: 11px;
    font-weight: 700;
}

.result-card {
    margin: 16px 14px 14px;
    padding: 16px;
    border-radius: 18px;
    background: #f8fbff;
    border: 1px solid #dbe7ff;
}

.result-subcard {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid #dbe7fb;
    background: #fff;
    border-radius: 14px;
}

.result-good {
    color: var(--green);
    font-weight: 700;
}

.result-bad {
    color: #b64f4f;
    font-weight: 700;
}

/* DFD visuals */

.dfd-node {
    position: absolute;
    user-select: none;
    box-sizing: border-box;
    color: #111827;
    z-index: 10;
}

.node-process {
    border: 1.8px solid #4b5563;
    border-radius: 12px;
    background: #f8fafc;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.process-number {
    border-bottom: 1.6px solid #4b5563;
    background: #e5e7eb;
    text-align: center;
    padding: 8px 6px 6px;
    font-weight: 600;
    line-height: 1.1;
}

.process-label {
    height: calc(100% - 38px);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px 10px;
    line-height: 1.2;
}

.node-data_store {
    border: 1.8px solid #4b5563;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    position: absolute;
}

    .node-data_store::before {
        content: "";
        position: absolute;
        top: 0;
        left: 22px;
        width: 1.8px;
        height: 100%;
        background: #4b5563;
    }

.data-store-code {
    position: absolute;
    top: 50%;
    left: 7px;
    transform: translateY(-50%);
    font-weight: 600;
    line-height: 1;
}

.data-store-label {
    position: absolute;
    top: 50%;
    left: 38px;
    right: 8px;
    transform: translateY(-50%);
    text-align: left;
    font-weight: 500;
    line-height: 1.15;
}

.node-external_entity {
    background: transparent;
    position: absolute;
}

.external-shadow,
.external-face {
    position: absolute;
    inset: 0;
    border: 1.8px solid #4b5563;
    border-radius: 6px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    box-sizing: border-box;
    line-height: 1.2;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.external-shadow {
    transform: translate(-8px, -8px);
    z-index: 0;
}

.external-face {
    z-index: 1;
}

.dfd-node.static {
    cursor: default;
}

.dfd-title {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--heading);
    font-weight: 700;
}

.stimulus-render-mount .dfd-viewport,
.stimulus-panel .dfd-viewport {
    height: 400px;
    overflow: auto;
    border: 2px dashed var(--border);
    border-radius: 16px;
    background: linear-gradient(to right, rgba(148, 163, 184, 0.08) 1px, transparent 1px), linear-gradient(to bottom, rgba(148, 163, 184, 0.08) 1px, transparent 1px), #f8fafc;
    background-size: 24px 24px;
}

#extendedBuilderMount .dfd-viewport {
    height: 690px;
    overflow: auto;
    border: 2px dashed var(--border);
    border-radius: 16px;
    background: linear-gradient(to right, rgba(148, 163, 184, 0.08) 1px, transparent 1px), linear-gradient(to bottom, rgba(148, 163, 184, 0.08) 1px, transparent 1px), #f8fafc;
    background-size: 24px 24px;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 12px;
    color: var(--text);
}

    .preview-table th,
    .preview-table td {
        border: 1px solid var(--border);
        padding: 8px 9px;
        text-align: left;
        vertical-align: top;
    }

    .preview-table th {
        background: #eef3fb;
        color: var(--heading);
    }

/* Pseudocode */

.pseudocode-stimulus-panel,
.pseudocode-extended-panel {
    background: #fbfcfe;
}

.pseudocode-stimulus-panel--short {
    padding: 12px;
}

.pseudocode-stimulus-card {
    display: grid;
    gap: 10px;
}

.pseudocode-stimulus-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--heading);
}

.pseudocode-stimulus-context {
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
}

.pseudocode-code-block {
    border: 1px solid #1a2742;
    border-radius: 16px;
    background: linear-gradient(180deg, #0e1730 0%, #091126 100%);
    color: #e5edf9;
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.pseudocode-line {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    align-items: stretch;
    min-height: 38px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

    .pseudocode-line:last-child {
        border-bottom: none;
    }

.pseudocode-line-number {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    color: #94a3b8;
    font-size: 12px;
    font-weight: 700;
    border-right: 1px solid rgba(148, 163, 184, 0.12);
}

.pseudocode-line-code {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 8px 12px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 14px;
    line-height: 1.5;
}

.pseudocode-line-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.pseudocode-line.token-keyword .pseudocode-line-text {
    color: #93c5fd;
    font-weight: 700;
}

.pseudocode-line.token-condition .pseudocode-line-text,
.pseudocode-line.token-loop .pseudocode-line-text {
    color: #fcd34d;
    font-weight: 700;
}

.pseudocode-line.token-assignment .pseudocode-line-text {
    color: #e5edf9;
}

.pseudocode-line.token-input .pseudocode-line-text,
.pseudocode-line.token-output .pseudocode-line-text {
    color: #86efac;
    font-weight: 700;
}

.pseudocode-line.token-function_call .pseudocode-line-text {
    color: #c4b5fd;
    font-weight: 700;
}

.pseudocode-line.token-comment .pseudocode-line-text {
    color: #94a3b8;
    font-style: italic;
}

.pseudocode-line.is-locked .pseudocode-line-code {
    background: rgba(255, 255, 255, 0.02);
}

.pseudocode-hover-help {
    position: absolute;
    left: 14px;
    bottom: calc(100% + 8px);
    min-width: 220px;
    max-width: 320px;
    padding: 10px 11px;
    border-radius: 12px;
    background: #ffffff;
    color: var(--heading);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.14s ease, transform 0.14s ease;
    z-index: 20;
    font-family: Arial, sans-serif;
    font-size: 12px;
    line-height: 1.45;
}

.pseudocode-line:hover .pseudocode-hover-help {
    opacity: 1;
    transform: translateY(0);
}

.pseudocode-library-box {
    margin-top: 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 11px 12px;
}

.pseudocode-library-title {
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 800;
    color: var(--heading);
}

.pseudocode-library-list {
    display: grid;
    gap: 8px;
}

.pseudocode-library-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 9px 10px;
}

.pseudocode-library-name {
    font-size: 13px;
    font-weight: 800;
    color: var(--heading);
}

.pseudocode-library-purpose {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--muted);
}

.pseudocode-grouped-response-grid {
    display: grid;
    gap: 12px;
}

.pseudocode-grouped-response-grid--compact {
    gap: 10px;
}

.pseudocode-group-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    padding: 12px;
}

.pseudocode-group-card--compact {
    padding: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}

.pseudocode-group-card-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.pseudocode-group-index {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #eaf1ff;
    color: var(--blue-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    flex-shrink: 0;
}

.pseudocode-group-label {
    font-size: 13px;
    font-weight: 800;
    color: var(--heading);
}

.pseudocode-group-ref {
    margin-top: 2px;
    font-size: 11px;
    color: #5c6f8f;
    line-height: 1.35;
}

.pseudocode-group-prompt {
    margin-top: 6px;
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--muted);
}

.pseudo-builder-mount {
    margin-top: 12px;
}

.pseudo-builder-mount--wide {
    margin-top: 14px;
}

.pseudo-builder-shell {
    display: block;
}

.extended-hero {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.extended-hero-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.extended-context {
    max-width: 880px;
}

.extended-criteria-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.extended-criteria-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 11px;
    background: #eef4ff;
    color: #244c97;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid #d8e4ff;
}

.extended-top-support {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.extended-inline-box {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 11px;
}

.extended-inline-title {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 800;
    color: var(--heading);
}

.extended-inline-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.extended-inline-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    background: #f4f7fd;
    color: #38506d;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #e0e8f6;
}

/* Desk check polish */

.deskcheck-shell {
    display: grid;
    gap: 14px;
}

.deskcheck-table-card,
.deskcheck-final-card {
    border: 1px solid #dbe4f0;
    background: #f8fafc;
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 1px 0 rgba(33, 47, 79, 0.02);
}

.deskcheck-card-title {
    font-size: 14px;
    font-weight: 800;
    color: #25314d;
    margin-bottom: 6px;
}

.deskcheck-card-prompt {
    font-size: 12px;
    line-height: 1.45;
    color: #6d7a91;
    margin-bottom: 10px;
}

.deskcheck-table-wrap {
    overflow: auto;
    border: 1px solid #dbe4f0;
    border-radius: 12px;
    background: #ffffff;
}

.deskcheck-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 720px;
    background: #fff;
}

    .deskcheck-table th,
    .deskcheck-table td {
        border-bottom: 1px solid #e7edf6;
        border-right: 1px solid #eef2f7;
        padding: 0;
        vertical-align: middle;
    }

        .deskcheck-table th:last-child,
        .deskcheck-table td:last-child {
            border-right: none;
        }

    .deskcheck-table tr:last-child td {
        border-bottom: none;
    }

    .deskcheck-table thead th {
        background: #eef4ff;
        color: #25314d;
        font-size: 12px;
        font-weight: 800;
        text-align: left;
        padding: 10px 12px;
        white-space: nowrap;
        position: sticky;
        top: 0;
        z-index: 3;
    }

    .deskcheck-table th:first-child,
    .deskcheck-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
    }

    .deskcheck-table thead th:first-child {
        z-index: 4;
    }

.deskcheck-step-cell {
    width: 72px;
    background: #f4f7fd;
    font-size: 12px;
    font-weight: 800;
    color: #475569;
    text-align: center;
    padding: 10px 8px !important;
}

.deskcheck-table tbody tr {
    transition: background 0.14s ease;
}

    .deskcheck-table tbody tr:hover {
        background: #f8fbff;
    }

    .deskcheck-row.active,
    .deskcheck-table tbody tr.active {
        background: #eef4ff;
        box-shadow: inset 4px 0 0 var(--blue);
    }

    .deskcheck-row.correct,
    .deskcheck-table tbody tr.correct {
        background: var(--green-soft);
    }

    .deskcheck-row.partial,
    .deskcheck-table tbody tr.partial {
        background: var(--amber-soft);
    }

    .deskcheck-row.incorrect,
    .deskcheck-table tbody tr.incorrect {
        background: var(--red-soft);
    }

.deskcheck-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.4;
    color: #0f172a;
    font-family: Arial, sans-serif;
}

    .deskcheck-input.is-line {
        font-family: Consolas, "Courier New", monospace;
    }

    .deskcheck-input:focus {
        background: #f8fbff;
        box-shadow: inset 0 0 0 2px #93c5fd;
    }

.deskcheck-table input:focus,
.deskcheck-final-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(44, 99, 234, 0.15), inset 0 0 0 1px rgba(44, 99, 234, 0.05);
}

.deskcheck-final-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.deskcheck-final-field,
.final-answer-box {
    display: grid;
    gap: 6px;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 8px;
    background: #fff;
}

    .final-answer-box.correct,
    .deskcheck-final-field.correct {
        border-color: var(--green);
        background: var(--green-soft);
    }

    .final-answer-box.incorrect,
    .deskcheck-final-field.incorrect {
        border-color: var(--red);
        background: var(--red-soft);
    }

.deskcheck-final-label {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
}

.deskcheck-final-input {
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    padding: 10px 12px;
    font-size: 13px;
    color: #0f172a;
}

.deskcheck-empty {
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: #64748b;
    background: #ffffff;
}

.deskcheck-cell-correct {
    background: rgba(23, 131, 77, 0.08);
}

.deskcheck-cell-partial {
    background: rgba(201, 138, 23, 0.10);
}

.deskcheck-cell-incorrect {
    background: rgba(196, 88, 88, 0.10);
}

.deskcheck-focus-ring {
    box-shadow: 0 0 0 2px rgba(44, 99, 234, 0.16);
}

/* UI mockup stability helpers kept in */

.question-workspace--extended-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 14px;
    align-items: start;
}

.workspace-support--extended-side {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.extended-annotation-sidecard {
    position: sticky;
    top: 18px;
    max-height: calc(100vh - 120px);
    overflow: auto;
}

.extended-annotation-board {
    display: grid;
    gap: 12px;
}

.builder-toolbar-bottom {
    border-style: solid;
}

.annotation-card {
    will-change: transform;
    transition: box-shadow 0.15s ease, border 0.15s ease;
}

    .annotation-card.active {
        border-color: #2c63ea;
        box-shadow: 0 0 0 3px rgba(44, 99, 234, 0.12);
    }

.ui-builder-stage {
    overflow: auto !important;
    width: 100%;
}

.ui-builder-canvas--desktop {
    margin: 20px auto;
}

/* =========================
   DESK CHECK STEPPING FIX
========================= */


    .pseudocode-line.is-clickable-trace-line:hover {
        background: rgba(44, 99, 234, 0.08);
    }


    .pseudocode-line.is-completed-trace-line .pseudocode-line-number {
        color: #86efac;
    }

.pseudocode-line[style*="not-allowed"] .pseudocode-line-code {
    opacity: 0.78;
}

.deskcheck-table tbody tr.active {
    background: #eef4ff;
    box-shadow: inset 4px 0 0 var(--blue);
}

.deskcheck-table tbody tr.correct {
    background: var(--green-soft);
}

.deskcheck-table tbody tr.incorrect {
    background: var(--red-soft);
}

.deskcheck-table tbody tr.partial {
    background: var(--amber-soft);
}

.deskcheck-input--readonly,
.deskcheck-input[readonly] {
    background: #f8fafc !important;
    color: #64748b !important;
    cursor: default;
}

.deskcheck-table tbody tr.active .deskcheck-input:not([readonly]) {
    background: #ffffff;
    box-shadow: inset 0 0 0 2px rgba(44, 99, 234, 0.12);
}

.deskcheck-final-field.correct,
.final-answer-box.correct {
    border-color: var(--green);
    background: var(--green-soft);
}

.deskcheck-final-field.incorrect,
.final-answer-box.incorrect {
    border-color: var(--red);
    background: var(--red-soft);
}

.deskcheck-state-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.deskcheck-state-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    background: #eef4ff;
    color: #244c97;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #d8e4ff;
}

.workspace-side-card .deskcheck-shell {
    margin-top: 0;
}

.workspace-side-card .deskcheck-table-card,
.workspace-side-card .deskcheck-final-card {
    background: #ffffff;
}

/* Responsive */

@media (max-width: 1320px) {
    .question-workspace--short {
        grid-template-columns: minmax(0, 1fr);
    }

    .workspace-main--sticky-stimulus {
        position: static;
    }
}

@media (max-width: 1280px) {
    .question-workspace--mcq,
    .question-workspace--short,
    .question-workspace--extended-split,
    .question-workspace--deskcheck-split {
        grid-template-columns: minmax(0, 1fr);
    }

    .workspace-main--sticky-stimulus {
        position: static;
    }

    .extended-annotation-sidecard {
        position: static;
        top: auto;
        max-height: none;
        overflow: visible;
    }

    .pseudocode-extended-panel {
        padding: 12px;
    }
}

@media (max-width: 1200px) {
    .exam-layout {
        grid-template-columns: 1fr;
    }

    .exam-right {
        position: static;
        top: auto;
    }
}

@media (max-width: 1100px) {
    .pseudo-builder-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .exam-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .exam-right {
        position: static;
        top: auto;
    }

    .exam-page-shell {
        padding: 14px 14px 120px;
    }

    .summary-card-top,
    .summary-footer,
    .question-footer,
    .exam-nav-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .floating-chat {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        bottom: 12px;
    }

    .chat-body {
        height: 230px;
    }

    .stimulus-render-mount .dfd-viewport,
    .stimulus-panel .dfd-viewport {
        height: 280px;
    }

    #extendedBuilderMount .dfd-viewport {
        height: 500px;
    }

    .pseudocode-line {
        grid-template-columns: 42px minmax(0, 1fr);
    }

    .pseudocode-line-code {
        font-size: 13px;
        padding: 8px 10px;
    }

    .pseudo-builder-line {
        grid-template-columns: 28px minmax(0, 1fr);
    }

    .pseudo-builder-line-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }

    .extended-top-support {
        grid-template-columns: 1fr;
    }

    .deskcheck-table {
        min-width: 640px;
    }
}

@media (max-width: 700px) {
    .question-card {
        padding: 12px;
    }

    .question-text {
        font-size: 15px;
    }

    .workspace-side-card,
    .stimulus-panel {
        padding: 10px;
    }

    .pseudocode-group-card--compact {
        padding: 10px;
    }

    .question-answer-box--compact textarea {
        min-height: 100px;
    }

    .question-workspace--extended {
        grid-template-columns: minmax(0, 1fr);
    }

    .workspace-main--extended {
        min-width: 0;
    }

    .pseudocode-extended-panel {
        padding: 14px;
    }

    .pseudo-builder-mount--wide {
        margin-top: 14px;
    }

    .extended-top-support {
        grid-template-columns: 1fr;
        margin-bottom: 14px;
    }

    .workspace-support--mcq,
    .workspace-side-card--mcq-answer {
        min-width: 0;
    }

    /* =========================================================
   UI_MOCKUP FINAL POLISH PATCH
   Add this at the END of styles.css
========================================================= */

    /* Overall shell */
    .exam-page-shell {
        max-width: 1560px;
        padding: 18px 20px 132px;
    }

    .exam-main-card {
        min-height: 82vh;
        border-radius: 30px;
    }

    .exam-layout {
        grid-template-columns: minmax(0, 1fr) 330px;
        gap: 18px;
        padding: 16px;
    }

    .exam-left,
    .exam-right,
    #questionViewport,
    .question-card,
    .question-body-grid,
    .question-workspace,
    .workspace-main,
    .workspace-support {
        min-width: 0;
    }

    /* Summary / header */
    .summary-card {
        border-radius: 20px;
        margin-bottom: 18px;
    }

    .summary-heading {
        font-size: 18px;
    }

    .section-title {
        margin: 0 0 12px;
        font-size: 18px;
    }

    #questionViewport {
        min-height: 760px;
        overflow: visible;
    }

    /* Question card polish */
    .question-card {
        border-radius: 20px;
        padding: 18px;
        overflow: visible;
    }

        .question-card.active-question {
            box-shadow: 0 0 0 3px rgba(44, 99, 234, 0.08), 0 16px 34px rgba(33, 47, 79, 0.08);
        }

    .question-text {
        font-size: 16px;
        line-height: 1.55;
        max-width: 100ch;
        margin-bottom: 14px;
    }

    .question-body-grid {
        gap: 14px;
    }

    .question-footer {
        margin-top: 16px;
        padding-top: 2px;
    }

    /* MCQ balance */
    .question-workspace--mcq,
    .question-workspace--mcq-desktop {
        display: grid;
        grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.92fr);
        gap: 16px;
        align-items: start;
    }

    .workspace-support--mcq {
        gap: 14px;
    }

    .workspace-side-card--mcq-answer {
        padding: 16px;
    }

    .workspace-side-card,
    .stimulus-panel {
        border-radius: 18px;
    }

    .option {
        border-radius: 16px;
        padding: 13px 14px;
        transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    }

        .option:hover {
            border-color: #b8c9e6;
            background: #fbfdff;
        }

        .option label {
            grid-template-columns: 18px 20px minmax(0, 1fr);
            gap: 11px;
        }

        .mcq-option-key,
        .option strong {
            color: var(--heading);
        }

    /* Stimulus polish */
    .stimulus-panel {
        padding: 14px;
        background: linear-gradient(180deg, #fbfcfe 0%, #f8fbff 100%);
    }

    .stimulus-title {
        margin-bottom: 9px;
        font-size: 13px;
        color: #5f6f87;
        font-weight: 800;
    }

    .stimulus-render-wrap {
        width: 100%;
        min-width: 0;
    }

    .stimulus-panel--desktop .ui-renderer-root.desktop {
        margin: 0;
    }

    .stimulus-panel--mobile .ui-renderer-root.mobile {
        margin: 0 auto;
    }

    /* Short response stage */
    .question-workspace--annotation-stage {
        display: block;
    }

    .annotation-stage-shell {
        gap: 16px;
    }

    .annotation-stage-topbar {
        align-items: flex-start;
    }

    .annotation-stage-board {
        min-height: 820px;
        padding: 20px;
        border-radius: 22px;
    }

    .annotation-stage-center {
        z-index: 1;
    }

    .annotation-stage-center--short {
        width: min(100%, 1020px);
        max-width: 1020px;
    }

    .annotation-help-strip {
        margin-bottom: 12px;
    }

    .annotation-help-pill {
        font-size: 11px;
        padding: 7px 11px;
    }

    .annotation-board-note {
        margin-top: 14px !important;
        border-radius: 16px;
        padding: 13px 15px;
    }

    .annotation-card-layer {
        z-index: 4;
    }

    .annotation-card {
        width: 272px;
        border-radius: 18px;
        box-shadow: 0 16px 32px rgba(33, 47, 79, 0.12);
    }

    .annotation-card-header {
        padding: 10px 12px;
    }

    .annotation-card-body {
        padding: 12px;
        gap: 11px;
    }

    .annotation-card-preview {
        min-height: 62px;
        border-radius: 13px;
    }

    .annotation-card textarea {
        min-height: 62px;
    }

    .annotation-card.active {
        border-color: #2c63ea;
        box-shadow: 0 0 0 3px rgba(44, 99, 234, 0.12), 0 16px 32px rgba(33, 47, 79, 0.14);
    }

    /* Extended response stage */
    .question-workspace--extended-stage {
        display: block;
    }

    .annotation-stage-board--extended {
        min-height: 980px;
        padding: 22px 20px 26px;
    }

    .annotation-stage-center--extended {
        width: min(100%, 1240px);
        max-width: 1240px;
    }

    .builder-floating-tip {
        margin-bottom: 12px;
        border-radius: 14px;
        padding: 11px 13px;
        font-size: 12px;
    }

    .builder-toolbar-bottom {
        margin-top: 14px;
        border-radius: 16px;
    }

        .builder-toolbar-bottom .question-actions {
            gap: 8px;
        }

    /* Builder mount cleanup */
    #extendedBuilderMount {
        width: 100%;
        min-width: 0;
    }

    .ui-builder-shell {
        align-items: start;
    }

    .ui-builder-stage {
        border-radius: 20px;
        padding: 12px;
    }

    .ui-builder-canvas {
        margin: 18px auto !important;
    }

    .ui-builder-canvas--desktop {
        margin: 20px auto !important;
    }

    /* Side panel */
    .exam-right {
        top: 16px;
    }

    .side-panel {
        border-radius: 20px;
        padding: 17px;
    }

    .criteria-item {
        gap: 11px;
    }

    /* Navigation footer */
    .exam-nav-footer {
        margin-top: 18px;
    }

    /* Floating chat */
    .floating-chat {
        right: 18px;
        bottom: 16px;
        width: 360px;
        border-radius: 20px;
    }

    .chat-body {
        height: 260px;
    }

    .chat-footer {
        padding: 10px;
    }

    /* Stronger responsive behaviour */
    @media (max-width: 1400px) {
        .question-workspace--mcq,
        .question-workspace--mcq-desktop {
            grid-template-columns: minmax(0, 1.18fr) minmax(340px, 0.9fr);
        }

        .annotation-stage-center--extended {
            max-width: 1160px;
        }
    }

    @media (max-width: 1280px) {
        .exam-layout {
            grid-template-columns: 1fr;
        }

        .exam-right {
            position: static;
            top: auto;
        }

        .question-workspace--mcq,
        .question-workspace--mcq-desktop {
            grid-template-columns: 1fr;
        }

        .annotation-stage-board {
            min-height: auto;
            padding-bottom: 340px;
        }

        .annotation-stage-board--extended {
            min-height: auto;
            padding-bottom: 360px;
        }

        .annotation-card {
            width: min(92vw, 300px);
        }
    }

    @media (max-width: 900px) {
        .exam-page-shell {
            padding: 14px 14px 126px;
        }

        .exam-layout {
            padding: 12px;
            gap: 14px;
        }

        .question-card {
            padding: 14px;
        }

        .annotation-stage-board,
        .annotation-stage-board--extended {
            padding: 14px 12px 320px;
            border-radius: 18px;
        }

        .annotation-stage-center--short,
        .annotation-stage-center--extended {
            width: 100%;
            max-width: 100%;
        }

        .floating-chat {
            left: 12px;
            right: 12px;
            width: auto;
            max-width: none;
        }
    }

    @media (max-width: 700px) {
        .summary-heading {
            font-size: 16px;
        }

        .section-title {
            font-size: 16px;
        }

        .question-text {
            font-size: 15px;
        }

        .workspace-side-card,
        .stimulus-panel {
            padding: 11px;
        }

        .option {
            padding: 12px;
        }

        .chat-body {
            height: 220px;
        }
    }

    /* =========================
   DESK CHECK GUIDED PANEL
========================= */

        .deskcheck-guide-dot.active {
            background: var(--blue);
        }

        .deskcheck-guide-dot.complete {
            background: var(--green);
        }
    /* =========================
   DESK CHECK STEP CONTROL
========================= */

    .deskcheck-table tbody tr.locked-row {
        opacity: 0.45;
    }

    .deskcheck-table tbody tr.current-row {
        background: #eef4ff;
        box-shadow: inset 4px 0 0 var(--blue);
    }

    .deskcheck-table tbody tr.completed-row {
        background: var(--green-soft);
    }

    .deskcheck-table tbody tr.error-row {
        background: var(--red-soft);
    }
    /* =========================
   INLINE FEEDBACK TAGS
========================= */

    .deskcheck-feedback-tag {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 11px;
        padding: 4px 8px;
        border-radius: 999px;
        font-weight: 700;
    }

        .deskcheck-feedback-tag.correct {
            background: var(--green-soft);
            color: var(--green);
        }

        .deskcheck-feedback-tag.incorrect {
            background: var(--red-soft);
            color: var(--red);
        }

        .deskcheck-feedback-tag.hint {
            background: var(--blue-soft);
            color: var(--blue-dark);
        }
    /* =========================================================
   UI_MOCKUP PAGE POLISH PATCH
   Add at the END of styles.css
========================================================= */

    /* Builder panel fit */
    #uiBuilderMount,
    .ui-builder-mount-fit {
        width: 100%;
        min-width: 0;
    }

        #uiBuilderMount .ui-builder-shell,
        .ui-builder-mount-fit .ui-builder-shell {
            min-height: 0;
            width: 100%;
        }

        #uiBuilderMount .ui-builder-stage,
        .ui-builder-mount-fit .ui-builder-stage {
            min-height: 0;
            max-height: none;
            padding: 12px;
            overflow: auto;
        }

        #uiBuilderMount .ui-builder-canvas-wrap,
        .ui-builder-mount-fit .ui-builder-canvas-wrap {
            width: 100%;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            margin: 0 auto;
        }

        #uiBuilderMount .ui-builder-canvas,
        .ui-builder-mount-fit .ui-builder-canvas {
            margin: 0 auto;
            max-width: 100%;
        }

        #uiBuilderMount .ui-builder-canvas--desktop,
        .ui-builder-mount-fit .ui-builder-canvas--desktop {
            margin: 0 auto;
        }

    /* Extended response panel breathing room */
    #extendedResponseCard .ui-panel-body {
        padding-top: 16px;
    }

    #extendedHintMount {
        margin-top: 12px;
    }

    #extendedAnnotationEditorMount {
        margin-top: 12px;
    }

    /* Floating builder annotation cards */
    .ui-floating-card {
        backdrop-filter: blur(4px);
    }

        .ui-floating-card.expanded {
            max-height: min(76vh, 720px);
            overflow: auto;
        }

            .ui-floating-card.expanded .ui-floating-card-body {
                gap: 12px;
            }

            .ui-floating-card.expanded .ui-floating-card-preview {
                padding-bottom: 2px;
            }

    .ui-floating-editor {
        margin-top: 2px;
    }

        .ui-floating-editor .ui-select,
        .ui-floating-editor .ui-textarea {
            font-size: 13px;
        }

        .ui-floating-editor .ui-textarea {
            min-height: 110px;
        }

    .ui-floating-editor-actions {
        padding-top: 2px;
        border-top: 1px solid #eef2f7;
    }

    /* Cleaner collapsed state */
    .ui-floating-card:not(.expanded) .ui-floating-card-body {
        padding-bottom: 14px;
    }

    /* Success criteria polish */
    #successCriteriaList {
        display: block;
    }

    .ui-success-guide-shell {
        display: grid;
        gap: 10px;
    }

    .ui-success-guide-card {
        transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
    }

        .ui-success-guide-card.strong {
            box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.05);
        }

        .ui-success-guide-card.partial {
            box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.05);
        }

        .ui-success-guide-card.missing,
        .ui-success-guide-card.needs-work {
            box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.05);
        }

    .ui-success-guide-text {
        font-weight: 700;
    }

    .ui-success-guide-meta {
        border-top: 1px solid rgba(215, 221, 232, 0.7);
        margin-top: -2px;
        padding-top: 10px;
    }

    /* Live feedback card spacing */
    .ui-marking-guide-shell {
        gap: 12px;
    }

    .ui-marking-guide-summary {
        margin-bottom: 2px;
    }

    /* Better page fit on medium screens */
    @media (max-width: 1280px) {
        .ui-main-grid {
            grid-template-columns: 1fr;
        }

        .ui-right-column {
            order: 2;
        }

        .ui-left-column {
            order: 1;
        }
    }

    /* Floating cards behave better on smaller screens */
    @media (max-width: 900px) {
        .ui-floating-card {
            width: min(88vw, 300px);
        }

            .ui-floating-card.expanded {
                width: min(92vw, 380px);
                max-height: min(70vh, 680px);
            }

        #uiBuilderMount .ui-builder-stage,
        .ui-builder-mount-fit .ui-builder-stage {
            padding: 10px;
        }
    }

    /* Tight mobile cleanup */
    @media (max-width: 640px) {
        #extendedResponseCard .ui-panel-body {
            padding-left: 12px;
            padding-right: 12px;
        }

        .ui-floating-card {
            border-radius: 14px;
        }

        .ui-floating-card-header {
            padding: 9px 10px;
        }

        .ui-floating-card-body {
            padding: 10px;
        }

        .ui-success-guide-row,
        .ui-marking-guide-row {
            grid-template-columns: 10px 1fr;
        }
        .ui-floating-card-body {
            pointer-events: auto;
        }

        .ui-success-guide-status,
        .ui-marking-guide-status {
            grid-column: 2;
            margin-top: 0;
        }
    }
    /* =========================
   DESK CHECK CLICK-TO-EXECUTE FINAL
   Add at END of styles.css
========================= */

    .question-workspace--deskcheck {
        display: grid;
        gap: 14px;
    }

    .question-workspace--deskcheck-split {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(420px, 0.92fr);
        gap: 14px;
        align-items: start;
    }

    .deskcheck-guide-panel {
        background: linear-gradient(180deg, #eef4ff 0%, #f5f9ff 100%);
        border: 1px solid #d8e4ff;
        border-radius: 18px;
        padding: 14px;
        display: grid;
        gap: 10px;
        box-shadow: var(--shadow-soft);
    }

    .deskcheck-guide-title {
        font-size: 13px;
        font-weight: 800;
        color: var(--heading);
    }

    .deskcheck-guide-step {
        font-size: 13px;
        line-height: 1.45;
        color: var(--text);
    }

    .deskcheck-guide-progress {
        display: flex;
        gap: 6px;
        margin-top: 6px;
    }

    .deskcheck-guide-dot {
        width: 8px;
        height: 8px;
        border-radius: 999px;
        background: #c7d4e8;
    }

        .deskcheck-guide-dot.active {
            background: var(--blue);
        }

        .deskcheck-guide-dot.complete {
            background: var(--green);
        }

    /* -------------------------
   PSEUDOCODE STEP STATES
------------------------- */

    .pseudocode-line {
        transition: background 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease, transform 0.14s ease;
    }



    /* -------------------------
   TRACE TABLE STATES
------------------------- */



    .deskcheck-input:focus,
    .deskcheck-final-input:focus {
        border-color: var(--blue);
        box-shadow: 0 0 0 2px rgba(44, 99, 234, 0.15), inset 0 0 0 1px rgba(44, 99, 234, 0.05);
    }

    /* -------------------------
   STATE CHIPS
------------------------- */

    .deskcheck-state-strip {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .deskcheck-state-chip {
        display: inline-flex;
        align-items: center;
        border-radius: 999px;
        padding: 6px 10px;
        background: #eef4ff;
        color: #244c97;
        font-size: 11px;
        font-weight: 700;
        border: 1px solid #d8e4ff;
    }

    /* -------------------------
   FINAL ANSWER STATES
------------------------- */

    .deskcheck-final-field.correct,
    .final-answer-box.correct {
        border-color: var(--green);
        background: var(--green-soft);
    }

    .deskcheck-final-field.incorrect,
    .final-answer-box.incorrect {
        border-color: var(--red);
        background: var(--red-soft);
    }

    /* -------------------------
   INLINE FEEDBACK TAGS
------------------------- */

    .deskcheck-feedback-tag {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 11px;
        padding: 4px 8px;
        border-radius: 999px;
        font-weight: 700;
    }

        .deskcheck-feedback-tag.correct {
            background: var(--green-soft);
            color: var(--green);
        }

        .deskcheck-feedback-tag.incorrect {
            background: var(--red-soft);
            color: var(--red);
        }

        .deskcheck-feedback-tag.hint {
            background: var(--blue-soft);
            color: var(--blue-dark);
        }

    /* -------------------------
   CARD CONSISTENCY
------------------------- */

    .workspace-side-card .deskcheck-shell {
        margin-top: 0;
    }

    .workspace-side-card .deskcheck-table-card,
    .workspace-side-card .deskcheck-final-card {
        background: #ffffff;
    }

    /* -------------------------
   RESPONSIVE
------------------------- */

    @media (max-width: 1280px) {
        .question-workspace--deskcheck-split {
            grid-template-columns: minmax(0, 1fr);
        }
    }

    @media (max-width: 900px) {
        .deskcheck-table {
            min-width: 640px;
        }
    }
    /* =========================
   DESK CHECK LOCKED FINAL
   Paste near end of styles.css
   BEFORE responsive media queries
========================= */

    .question-workspace--deskcheck {
        display: grid;
        gap: 14px;
    }

        .question-workspace--deskcheck .workspace-main,
        .question-workspace--deskcheck .workspace-support,
        .question-workspace--deskcheck .workspace-side-card,
        .question-workspace--deskcheck .stimulus-panel {
            min-width: 0;
        }

    .deskcheck-guide-panel {
        background: linear-gradient(180deg, #eef4ff 0%, #f5f9ff 100%);
        border: 1px solid #d8e4ff;
        border-radius: 18px;
        padding: 14px;
        display: grid;
        gap: 10px;
        box-shadow: var(--shadow-soft);
    }

    .deskcheck-guide-title {
        font-size: 13px;
        font-weight: 800;
        color: var(--heading);
    }

    .deskcheck-guide-step {
        font-size: 13px;
        line-height: 1.45;
        color: var(--text);
    }

    .deskcheck-guide-progress {
        display: flex;
        gap: 6px;
        margin-top: 6px;
    }

    .deskcheck-guide-dot {
        width: 8px;
        height: 8px;
        border-radius: 999px;
        background: #c7d4e8;
    }

        .deskcheck-guide-dot.active {
            background: var(--blue);
        }

        .deskcheck-guide-dot.complete {
            background: var(--green);
        }

    /* -------------------------
   PSEUDOCODE STEP STATES
------------------------- */

    .pseudocode-line {
        transition: background 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
    }

        .pseudocode-line.is-clickable-trace-line,
        .pseudocode-line.is-available-step {
            cursor: pointer;
        }

            .pseudocode-line.is-clickable-trace-line:hover,
            .pseudocode-line.is-available-step:hover {
                background: rgba(44, 99, 234, 0.08);
            }

        .pseudocode-line.is-active-step,
        .pseudocode-line.is-current-trace-line {
            background: rgba(44, 99, 234, 0.12);
            box-shadow: inset 4px 0 0 var(--blue);
        }

        .pseudocode-line.is-complete-step,
        .pseudocode-line.is-completed-trace-line {
            background: rgba(23, 131, 77, 0.08);
        }

            .pseudocode-line.is-complete-step .pseudocode-line-number,
            .pseudocode-line.is-completed-trace-line .pseudocode-line-number {
                color: #86efac;
            }

        .pseudocode-line.is-locked-step {
            opacity: 0.42;
            cursor: not-allowed;
        }

            .pseudocode-line.is-locked-step .pseudocode-line-code {
                background: rgba(255, 255, 255, 0.02);
            }

    /* -------------------------
   LIVE EXECUTION STRIP
------------------------- */

    .deskcheck-state-strip {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .deskcheck-state-chip {
        display: inline-flex;
        align-items: center;
        border-radius: 999px;
        padding: 6px 10px;
        background: #eef4ff;
        color: #244c97;
        font-size: 11px;
        font-weight: 700;
        border: 1px solid #d8e4ff;
    }

    /* -------------------------
   TRACE TABLE STATES
------------------------- */

    .deskcheck-table tbody tr.current-row,
    .deskcheck-table tbody tr.active {
        background: #eef4ff;
        box-shadow: inset 4px 0 0 var(--blue);
    }

    .deskcheck-table tbody tr.completed-row,
    .deskcheck-table tbody tr.correct {
        background: var(--green-soft);
    }

    .deskcheck-table tbody tr.locked-row {
        background: var(--green-soft);
        opacity: 0.72;
    }

    .deskcheck-table tbody tr.error-row,
    .deskcheck-table tbody tr.incorrect {
        background: var(--red-soft);
    }

    .deskcheck-table tbody tr.partial {
        background: var(--amber-soft);
    }

    .deskcheck-input--readonly,
    .deskcheck-input[readonly] {
        background: #f8fafc !important;
        color: #64748b !important;
        cursor: default;
    }

    .deskcheck-table tbody tr.current-row .deskcheck-input:not([readonly]),
    .deskcheck-table tbody tr.active .deskcheck-input:not([readonly]) {
        background: #ffffff;
        box-shadow: inset 0 0 0 2px rgba(44, 99, 234, 0.12);
    }

    .deskcheck-input:focus,
    .deskcheck-final-input:focus {
        border-color: var(--blue);
        box-shadow: 0 0 0 2px rgba(44, 99, 234, 0.15), inset 0 0 0 1px rgba(44, 99, 234, 0.05);
    }

    /* -------------------------
   FINAL ANSWER STATES
------------------------- */

    .deskcheck-final-field.correct,
    .final-answer-box.correct {
        border-color: var(--green);
        background: var(--green-soft);
    }

    .deskcheck-final-field.incorrect,
    .final-answer-box.incorrect {
        border-color: var(--red);
        background: var(--red-soft);
    }

    /* -------------------------
   INLINE TAGS
------------------------- */

    .deskcheck-feedback-tag {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 11px;
        padding: 4px 8px;
        border-radius: 999px;
        font-weight: 700;
    }

        .deskcheck-feedback-tag.correct {
            background: var(--green-soft);
            color: var(--green);
        }

        .deskcheck-feedback-tag.incorrect {
            background: var(--red-soft);
            color: var(--red);
        }

        .deskcheck-feedback-tag.hint {
            background: var(--blue-soft);
            color: var(--blue-dark);
        }
    .mcq-option-card.is-selected {
        border-color: #2563eb;
        background: #eff6ff;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
    }
    .mcq-option-card.is-selected {
        border-color: #2563eb;
        background: #eff6ff;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
    }

    /* -------------------------
   CARD CONSISTENCY
------------------------- */

    .workspace-side-card .deskcheck-shell {
        margin-top: 0;
    }

    .workspace-side-card .deskcheck-table-card,
    .workspace-side-card .deskcheck-final-card {
        background: #ffffff;
    }
    /* =========================
   GUIDED PLAYBACK VISUALS
========================= */

    .deskcheck-playback-popup {
        border-radius: 14px;
        padding: 12px 13px;
        font-size: 12px;
        line-height: 1.5;
        font-weight: 700;
        border: 1px solid transparent;
        background: #f8fbff;
        color: var(--heading);
    }

    .deskcheck-playback-popup--info {
        background: #eef4ff;
        border-color: #d8e4ff;
        color: #244c97;
    }

    .deskcheck-playback-popup--correct {
        background: var(--blue-soft);
        border-color: #cfe0ff;
        color: var(--blue-dark);
    }

    .deskcheck-playback-popup--hint {
        background: #fff8e8;
        border-color: #f5df9b;
        color: #8a6112;
    }

    .deskcheck-cell-playback {
        background: rgba(44, 99, 234, 0.10);
        transition: background 0.25s ease;
    }

    .deskcheck-cell-playback-input {
        background: #ffffff !important;
        box-shadow: inset 0 0 0 2px rgba(44, 99, 234, 0.18);
    }
}
