.ap-lesson-shell,
.ap-lesson-shell * {
    box-sizing: border-box;
}

.ap-lesson-shell {
    --ap-viewport-offset: 120px;
    --ap-bg: #0d1117;
    --ap-panel: #111827;
    --ap-panel-soft: #151b26;
    --ap-border: #2c3444;
    --ap-text: #e6edf3;
    --ap-muted: #9aa7b5;
    --ap-accent: #20c7b7;
    --ap-accent-2: #ec2870;
    --ap-code: #080b10;
    --ap-success: #49d17d;
    --ap-warning: #f7c76c;
    width: 100%;
    color: var(--ap-text);
    font-family: Arial, sans-serif;
}

.ap-lesson-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(500px, 1.06fr);
    width: 100%;
    height: calc(100dvh - var(--ap-viewport-offset));
    min-height: 650px;
    max-height: calc(100dvh - var(--ap-viewport-offset));
    overflow: hidden;
    border: 1px solid var(--ap-border);
    border-radius: 18px;
    background: var(--ap-bg);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.ap-lesson-content {
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 34px 34px 40px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    background:
        radial-gradient(circle at top left, rgba(32, 199, 183, 0.09), transparent 34%),
        linear-gradient(180deg, #141c2b 0%, #0f1623 100%);
    border-right: 1px solid var(--ap-border);
}

.ap-lesson-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding: 7px 11px;
    border: 1px solid rgba(32, 199, 183, 0.28);
    border-radius: 999px;
    background: rgba(32, 199, 183, 0.09);
    color: #61e4d6;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ap-lesson-title {
    margin: 0;
    color: #fff;
    font-size: clamp(30px, 3vw, 48px);
    line-height: 1.08;
    letter-spacing: -0.035em;
}

.ap-lesson-lead {
    margin: 17px 0 0;
    max-width: 720px;
    color: #bdc8d4;
    font-size: 17px;
    line-height: 1.75;
}

.ap-lesson-divider {
    height: 1px;
    margin: 28px 0;
    background: linear-gradient(90deg, rgba(32,199,183,.35), rgba(255,255,255,.06), transparent);
}

.ap-lesson-section {
    margin-top: 28px;
}

.ap-lesson-section:first-of-type {
    margin-top: 0;
}

.ap-lesson-section h2 {
    margin: 0 0 12px;
    color: #fff;
    font-size: 23px;
    line-height: 1.25;
}

.ap-lesson-section h3 {
    margin: 21px 0 10px;
    color: #fff;
    font-size: 17px;
}

.ap-lesson-section p {
    margin: 0 0 14px;
    color: #c4ced8;
    font-size: 15px;
    line-height: 1.78;
}

.ap-highlight {
    color: #72eadf;
    font-weight: 700;
}

.ap-inline-code {
    padding: 2px 7px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 6px;
    background: rgba(0,0,0,.28);
    color: #f4d680;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: .92em;
}

/* Plain <code> in a lesson (no class) would get the theme's light background under light text: give it the same dark chip. */
.ap-lesson-content code:not([class]) {
    padding: 2px 7px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 6px;
    background: #1b2230;
    color: #f4d680;
    font-size: .92em;
}

.ap-lesson-content pre code:not([class]) {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font-size: inherit;
}

.ap-info-card,
.ap-case-card,
.ap-exercise-card {
    margin-top: 16px;
    padding: 19px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    background: rgba(7,12,20,.45);
}

.ap-info-card {
    border-left: 4px solid var(--ap-accent);
}

.ap-info-card strong,
.ap-case-card strong,
.ap-exercise-card strong {
    display: block;
    margin-bottom: 7px;
    color: #fff;
    font-size: 14px;
}

.ap-info-card p,
.ap-case-card p,
.ap-exercise-card p {
    margin-bottom: 0;
}

.ap-code-example {
    margin: 15px 0 0;
    padding: 16px 17px;
    overflow-x: auto;
    border: 1px solid #293141;
    border-radius: 12px;
    background: #080b10;
    color: #e6edf3;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 14px;
    line-height: 1.65;
    white-space: pre;
}

.ap-steps {
    display: grid;
    gap: 10px;
    margin-top: 15px;
}

.ap-step {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 11px;
    align-items: start;
    padding: 12px 13px;
    border: 1px solid rgba(255,255,255,.065);
    border-radius: 11px;
    background: rgba(255,255,255,.025);
}

.ap-step-number {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: rgba(32,199,183,.12);
    color: #72eadf;
    font-size: 13px;
    font-weight: 800;
}

.ap-step-text {
    color: #c6d0db;
    font-size: 14px;
    line-height: 1.6;
}

.ap-case-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 12px;
    margin-top: 15px;
}

.ap-case-card {
    margin-top: 0;
}

.ap-case-card span {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 21px;
}

.ap-exercise-card {
    border-color: rgba(236,40,112,.28);
    background:
        linear-gradient(135deg, rgba(236,40,112,.11), rgba(32,199,183,.06)),
        rgba(7,12,20,.58);
}

.ap-exercise-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 10px;
    color: #fff;
    font-size: 20px;
    font-weight: 800;
}

.ap-exercise-list {
    margin: 12px 0 0;
    padding-left: 20px;
    color: #cbd5df;
}

.ap-exercise-list li {
    margin: 7px 0;
    line-height: 1.55;
}

.ap-hint {
    margin-top: 14px;
    padding: 12px 13px;
    border-radius: 10px;
    background: rgba(247,199,108,.08);
    color: #eedca9;
    font-size: 13px;
    line-height: 1.55;
}

.ap-solution-toggle {
    margin-top: 18px;
    padding: 12px 18px;
    border: 1px solid rgba(236,40,112,.35);
    border-radius: 10px;
    background: #ec2870;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.ap-solution {
    display: none;
    margin-top: 18px;
    padding: 18px;
    border: 1px solid #2c3444;
    border-radius: 12px;
    background: #080b10;
}

.ap-solution.show {
    display: block;
}

.ap-solution h3 {
    margin: 0 0 10px;
    color: #20c7b7;
}

.ap-solution pre {
    margin: 12px 0 0;
    padding: 14px;
    overflow: auto;
    border-radius: 10px;
    background: #05070b;
    color: #e6edf3;
    font-family: Consolas, monospace;
    line-height: 1.6;
}

.ap-validation-message {
    display: none;
    margin-top: 16px;
    padding: 13px 14px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.55;
}

.ap-validation-message.show {
    display: block;
}

.ap-validation-message.error {
    border: 1px solid rgba(255,123,114,.35);
    background: rgba(255,123,114,.08);
    color: #ffb4ae;
}

.ap-validation-message.success {
    border: 1px solid rgba(73,209,125,.35);
    background: rgba(73,209,125,.08);
    color: #8be5aa;
}

.ap-next-lesson {
    display: none;
    margin-top: 16px;
    padding: 13px 16px;
    border-radius: 10px;
    background: #20c7b7;
    color: #061412;
    font-weight: 800;
    text-decoration: none;
}

.ap-next-lesson.show {
    display: inline-block;
}

.ap-editor-panel {
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0d1117;
}

.ap-editor-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 58px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--ap-border);
    background: #151b26;
}

.ap-lab-file {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.ap-lab-language {
    color: var(--ap-accent);
    font-size: 12px;
}

.ap-lab-run {
    min-height: 40px;
    padding: 9px 18px;
    border: 0;
    border-radius: 9px;
    background: var(--ap-accent-2);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.ap-lab-run:disabled {
    cursor: wait;
    opacity: .65;
}

.ap-lab-editor-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.ap-lab-code {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 20px;
    border: 0;
    outline: 0;
    resize: none;
    overflow: auto;
    background: #0d1117 !important;
    color: #e6edf3 !important;
    caret-color: #fff;
    tab-size: 4;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 15px;
    line-height: 1.7;
    white-space: pre;
}

.ap-lab-console {
    flex: 0 0 235px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top: 1px solid var(--ap-border);
    background: #080b10;
}

.ap-lab-console-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #202733;
    color: #c9d1d9;
    font-size: 13px;
    font-weight: 700;
}

.ap-lab-status {
    color: #8b949e;
    font-size: 12px;
    font-weight: 400;
}

.ap-lab-output {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0 !important;
    padding: 16px !important;
    overflow: auto;
    border: 0 !important;
    background: #080b10 !important;
    color: #e6edf3 !important;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ap-lab-output.is-error {
    color: #ff7b72 !important;
}

.ap-lab-help {
    padding: 10px 14px;
    border-top: 1px solid #202733;
    color: #8b949e;
    font-size: 12px;
}

@media (max-width: 1024px) {
    .ap-lesson-shell {
        --ap-viewport-offset: 100px;
    }

    .ap-lesson-layout {
        grid-template-columns: minmax(0,.95fr) minmax(430px,1.05fr);
    }

    .ap-lesson-content {
        padding: 28px 24px 34px;
    }
}

@media (max-width: 767px) {
    .ap-lesson-layout {
        display: block;
        height: auto;
        min-height: 0;
        max-height: none;
        overflow: visible;
        border-radius: 12px;
    }

    .ap-lesson-content {
        height: auto;
        max-height: none;
        overflow: visible;
        padding: 24px 18px 28px;
        border-right: 0;
        border-bottom: 1px solid var(--ap-border);
    }

    .ap-case-grid {
        grid-template-columns: 1fr;
    }

    .ap-editor-panel {
        height: auto;
        min-height: 620px;
    }

    .ap-lab-editor-wrap {
        flex: none;
        height: 370px;
    }

    .ap-lab-console {
        flex: none;
        height: 220px;
    }
}

/* Lab additions */
.ap-lab-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ap-lab-reset {
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid var(--ap-border);
    border-radius: 9px;
    background: transparent;
    color: #c9d1d9;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.ap-lab-reset:hover {
    border-color: rgba(32,199,183,.45);
    color: #fff;
}

.ap-lab-output.is-success {
    color: #e6edf3 !important;
}

.ap-lab-output .ap-lab-err {
    color: #ff7b72;
}

.ap-lab-output .ap-lab-note {
    color: #8b949e;
}

.ap-lab-progress {
    height: 3px;
    background: transparent;
    overflow: hidden;
}

.ap-lab-progress span {
    display: block;
    width: 35%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--ap-accent), transparent);
    animation: ap-lab-load 1.1s ease-in-out infinite;
}

.ap-lab-progress.is-idle span {
    display: none;
}

@keyframes ap-lab-load {
    from { transform: translateX(-100%); }
    to { transform: translateX(300%); }
}

@media (max-width: 767px) {
    .ap-editor-panel-header {
        flex-wrap: wrap;
    }

    .ap-lab-run {
        flex: 1 1 auto;
    }
}

.ap-lesson-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 6px 10px 0;
    padding: 7px 11px;
    border: 1px solid rgba(32,199,183,.28);
    border-radius: 999px;
    background: rgba(32,199,183,.08);
    color: #72eadf;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: .02em;
    text-decoration: none;
    white-space: nowrap;
}

.ap-lesson-back + .ap-lesson-eyebrow {
    display: flex;
    width: fit-content;
}

.ap-table-wrap {
    margin-top: 15px;
    overflow-x: auto;
    border: 1px solid #293141;
    border-radius: 12px;
}

.ap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.ap-table th,
.ap-table td {
    padding: 10px 13px;
    border-bottom: 1px solid #222a38;
    color: #c6d0db;
    text-align: left;
    vertical-align: top;
    line-height: 1.5;
}

.ap-table th {
    background: rgba(32,199,183,.08);
    color: #fff;
    font-weight: 800;
}

.ap-table tr:last-child td {
    border-bottom: 0;
}

.ap-code-output {
    color: #a5e8c0;
    background: #06090d;
}

/* Web lessons: live preview above the console */
.ap-lab-preview {
    flex: 0 0 42%;
    min-height: 180px;
    border-top: 1px solid var(--ap-border);
    background: #ffffff;
    overflow: hidden;
}

.ap-lab-preview .ap-preview-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #ffffff;
}

.ap-lesson-shell[data-lab="web"] .ap-lab-console {
    flex-basis: 150px;
}

.ap-lab-preview-label {
    padding: 6px 14px;
    border-top: 1px solid var(--ap-border);
    background: #151b26;
    color: #9aa7b5;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

@media (max-width: 767px) {
    .ap-lab-preview {
        flex: none;
        height: 300px;
    }
}

/* Workspace runners (Git terminal, Excel workbook): the runner fills #ap-workspace. */
.ap-workspace-panel .ap-lab-workspace { flex: 1 1 auto; min-height: 520px; display: flex; flex-direction: column; overflow: hidden; }
/* The verification box stays compact so the workspace (terminal / workbook) gets the height. */
.ap-workspace-panel .ap-workspace-status { flex: 0 0 auto !important; min-height: 0 !important; height: auto !important; }
.ap-workspace-panel .ap-workspace-status .ap-lab-output { flex: 0 0 auto !important; min-height: 40px !important; max-height: 96px !important; overflow: auto; padding-top: 10px; padding-bottom: 10px; font-size: 13px; }
.ap-workspace-panel .ap-workspace-status .ap-lab-console-header { padding-top: 8px; padding-bottom: 8px; }

.ap-lab-output img.ap-lab-image {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 8px 0;
    border-radius: 6px;
    background: #fff;
}

/* Bold words inside the text of a card stay inline; only the card title is a block. */
.ap-info-card p strong, .ap-case-card p strong, .ap-exercise-card p strong,
.ap-info-card li strong, .ap-case-card li strong, .ap-exercise-card li strong { display: inline; }
