.microlecture-section {
    --microlecture-sidebar-bg: transparent;
    --microlecture-sidebar-fg: var(--theme-text);
    --microlecture-sidebar-width: 280px;
    --microlecture-sidebar-toggle-width: 19px;
    --microlecture-secondary-index-font-size: calc(var(--nav-font-size) * 0.864);
    --board-font-size: var(--main-font-size);
    --board-small-font-size: var(--type-size-small);
    --board-line-height: var(--main-font-spacing);
    --board-content-line-height: var(--main-font-spacing);
    --board-space-1: 4px;
    --board-space-2: 8px;
    --board-space-3: 12px;
    --board-space-4: 16px;
    margin-top: 0;
    margin-bottom: calc(-1 * var(--main-padding-bottom));
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
}

/* Reply bodies follow Gallery's divider-free discussion flow. */
.microlecture-replies .board-reply-content {
    padding-block-end: 0;
    border-block-end: 0;
}

.microlecture-section *,
.microlecture-section *::before,
.microlecture-section *::after {
    box-sizing: border-box;
}

.microlecture-layout {
    display: grid;
    grid-template-columns: var(--microlecture-sidebar-width) minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
    position: relative;
    transition: grid-template-columns 180ms ease;
    flex: 1 0 auto;
}

.microlecture-layout.is-sidebar-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
}

.microlecture-layout.is-sidebar-collapsed .microlecture-sidebar {
    display: none;
}

@media (min-width: 901px) {
    .microlecture-layout::before {
        content: "";
        position: absolute;
        top: calc(var(--nav-box-height) + var(--nav-border-bottom-thk) - var(--main-padding-top));
        bottom: 0;
        left: calc(var(--microlecture-sidebar-width) + 5px);
        width: 1px;
        background: var(--theme-divider-strong);
        pointer-events: none;
        transition: left 180ms ease;
    }

    .microlecture-layout.is-sidebar-collapsed::before {
        left: 5px;
    }
}

.microlecture-sidebar-toggle {
    box-sizing: border-box;
    position: absolute;
    z-index: 2;
    top: calc(var(--nav-box-height) + var(--nav-border-bottom-thk) - var(--main-padding-top));
    left: calc(var(--microlecture-sidebar-width) + 5px - var(--microlecture-sidebar-toggle-width));
    width: var(--microlecture-sidebar-toggle-width);
    height: 66px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--type-control-padding-tight);
    border: 0;
    border-radius: 0 0 4px 4px;
    background: var(--theme-sidebar-toggle-bg);
    color: var(--theme-text);
    cursor: pointer;
    font-family: var(--body-font);
    line-height: 1;
    transition: left 180ms ease, background-color 120ms ease;
}

.microlecture-layout.is-sidebar-collapsed .microlecture-sidebar-toggle {
    left: calc(5px - var(--microlecture-sidebar-toggle-width));
    height: 76px;
}

.microlecture-sidebar-toggle:hover,
.microlecture-sidebar-toggle:focus-visible {
    background: var(--theme-sidebar-toggle-hover);
}

.microlecture-sidebar-toggle-label {
    display: block;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: nowrap;
    font-size: 10.8px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.02em;
}

.microlecture-sidebar {
    grid-column: 1;
    box-sizing: border-box;
    align-self: stretch;
    margin-top: calc(var(--nav-box-height) + var(--nav-border-bottom-thk) - var(--main-padding-top));
    margin-left: calc(-1 * var(--main-padding-left));
    min-height: 100%;
    padding-block: var(--type-sidebar-shell-padding-block);
    padding-inline: var(--type-sidebar-shell-padding-inline);
    background: var(--microlecture-sidebar-bg);
    color: var(--microlecture-sidebar-fg);
}

.microlecture-category-block + .microlecture-category-block {
    margin-top: 0;
}

.microlecture-category-btn {
    width: 100%;
    display: block;
    text-align: left;
    border: 0;
    padding-block: var(--type-control-padding-block);
    padding-inline: var(--type-control-padding-inline);
    background: transparent;
    color: var(--microlecture-sidebar-fg);
    cursor: pointer;
    font-size: var(--nav-font-size);
    font-weight: 400;
    line-height: 1.4;
}

.microlecture-category-btn:hover {
    color: var(--microlecture-sidebar-fg);
}

.microlecture-category-btn.is-open {
    text-decoration: none;
    font-weight: 700;
}

.microlecture-category-code {
    display: inline-block;
    vertical-align: top;
    margin-right: 6px;
    white-space: nowrap;
    font-size: var(--nav-font-size);
}

.microlecture-lecture-list {
    display: none;
    margin-left: 2px;
    padding-top: 2px;
    padding-bottom: 0;
}

.microlecture-lecture-list.is-open {
    display: block;
}

.microlecture-lecture-tree {
    list-style: none;
    margin: 0;
    padding: 0 0 0 16px;
    border-left: 1px dotted var(--theme-divider-dotted);
}

.microlecture-lecture-item {
    margin: 0;
    padding: 0;
}

.microlecture-lecture-btn {
    width: 100%;
    display: grid;
    grid-template-columns: 25.92px minmax(0, 1fr);
    column-gap: 6px;
    align-items: start;
    text-align: left;
    border: 0;
    padding-block: var(--type-control-padding-block);
    padding-inline: var(--type-control-padding-inline);
    background: transparent;
    color: var(--microlecture-sidebar-fg);
    cursor: pointer;
    font-size: var(--nav-font-size);
    line-height: 1.4;
    font-weight: 400;
}

.microlecture-lecture-btn:hover {
    color: var(--microlecture-sidebar-fg);
}

.microlecture-lecture-btn.is-active {
    font-weight: 700;
}

.microlecture-lecture-code {
    display: block;
    align-self: start;
    font-size: var(--microlecture-secondary-index-font-size);
    white-space: nowrap;
}

.microlecture-lecture-title {
    min-width: 0;
    font-size: var(--nav-font-size);
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.microlecture-no-lecture {
    margin: 0;
    padding: 2px 0 2px 16px;
    font-size: var(--nav-font-size);
    line-height: 1.4;
    color: var(--microlecture-sidebar-fg);
}

.microlecture-detail-column {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    border-left: 0;
    margin-top: calc(var(--nav-box-height) + var(--nav-border-bottom-thk) - var(--main-padding-top));
    margin-left: -5px;
    padding: var(--type-space-content);
    box-sizing: border-box;
    min-height: 320px;
}

.microlecture-home-panel {
    display: none;
}

.microlecture-home-panel.is-active {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
}

.microlecture-home-panel.is-active::after {
    content: "";
    display: block;
    flex: 0 0 1px;
    width: 100%;
    margin-top: auto;
    background: var(--theme-divider-strong);
}

.microlecture-home-panel h5 {
    margin: 0 0 var(--type-space-content);
    font-size: var(--type-size-content-title);
    font-weight: 700;
    line-height: var(--type-leading-heading);
}

.microlecture-home-panel p {
    margin: 0;
    font-size: var(--type-size-content-description);
    line-height: var(--type-leading-reading);
}

.microlecture-home-table-wrap {
    margin-top: var(--type-space-content);
    margin-bottom: var(--type-space-content);
    width: 100%;
    margin-right: 0;
}

.microlecture-home-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--nav-font-size);
    line-height: 1.4;
}

.microlecture-home-table th,
.microlecture-home-table td {
    border-top: 1px solid var(--theme-divider-strong);
    padding: 4px 8px 4px 0;
    text-align: left;
    vertical-align: top;
    font-size: var(--nav-font-size);
}

/* Draw body-row separators independently from the table's collapsed borders. */
.microlecture-home-table > tbody > tr + tr > td {
    border-top: 1px dotted var(--theme-divider-dotted);
}

/* Keep the table edge distinct from the home panel's later solid closing line. */
.microlecture-home-table > tbody > tr:last-child > td {
    border-bottom: 1px dotted var(--theme-divider-dotted);
}

.microlecture-home-table th:first-child,
.microlecture-home-table td:first-child {
    width: 36%;
    padding-right: 12px;
}

.microlecture-home-table th {
    font-weight: 700;
}

.microlecture-home-category-line {
    width: 100%;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    column-gap: 6px;
    align-items: start;
    line-height: 1.4;
}

.microlecture-home-category-index {
    display: block;
    align-self: start;
    font-size: var(--nav-font-size);
    white-space: nowrap;
}

.microlecture-home-category-title {
    display: block;
    min-width: 0;
    font-size: var(--nav-font-size);
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.microlecture-home-lecture-btn {
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    text-align: left;
    cursor: pointer;
    width: 100%;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    column-gap: 6px;
    align-items: start;
    font-size: var(--nav-font-size);
    line-height: 1.4;
}

.microlecture-home-lecture-btn:hover {
    text-decoration: underline;
}

.microlecture-home-lecture-index {
    display: block;
    align-self: start;
    font-size: var(--microlecture-secondary-index-font-size);
    white-space: nowrap;
}

.microlecture-home-lecture-title {
    display: block;
    min-width: 0;
    font-size: var(--nav-font-size);
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.microlecture-panel {
    display: none;
}

.microlecture-panel.is-active {
    display: block;
}

.microlecture-panel h5 {
    margin: 0 0 var(--type-space-content);
    font-size: var(--type-size-content-title);
    font-weight: 700;
    line-height: var(--type-leading-heading);
}

.microlecture-description-toggle {
    margin: 0 0 var(--type-space-content);
}

.microlecture-description-toggle summary {
    display: inline;
    font-size: var(--nav-font-size);
    line-height: 1.4;
    color: var(--theme-text);
    cursor: pointer;
    user-select: none;
    list-style: none;
    font-weight: 400;
}

.microlecture-description-toggle summary::-webkit-details-marker {
    display: none;
}

.microlecture-description-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    object-fit: contain;
    vertical-align: -0.08em;
}

.microlecture-description-label-open {
    display: none;
}

.microlecture-description-label-closed {
    display: inline;
}

.microlecture-description-toggle[open] .microlecture-description-label-open {
    display: inline;
}

.microlecture-description-toggle[open] .microlecture-description-label-closed {
    display: none;
}

.microlecture-description-toggle summary strong {
    font-weight: 700;
}

.microlecture-description-body {
    display: none;
    margin: 8px 0 0 0;
    font-size: var(--type-size-content-description);
    line-height: var(--type-leading-reading);
    font-weight: 400;
}

.microlecture-description-toggle[open] .microlecture-description-body {
    display: block;
}

.microlecture-video-area {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 0;
    overflow: hidden;
}

.microlecture-video-loading {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 2;
    align-items: center;
    justify-content: center;
    background: var(--theme-surface);
    color: var(--theme-text);
    font-size: calc(var(--nav-font-size) * 1.6) !important;
    line-height: 1.3 !important;
    font-weight: 600;
    box-sizing: border-box;
    border: 1px dashed var(--theme-border-dotted);
}

.microlecture-video-area.is-loading .microlecture-video-loading {
    display: flex;
}

.microlecture-video-timeout {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 2;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    text-align: center;
    padding: var(--type-space-content);
    background: var(--theme-surface);
    color: var(--theme-text);
    font-size: var(--nav-font-size);
    line-height: 1.4;
    box-sizing: border-box;
    border: 1px dashed var(--theme-border-dotted);
}

.microlecture-video-timeout-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.microlecture-video-retry {
    border: 1px solid var(--theme-border);
    background: var(--theme-control-bg);
    color: var(--theme-text);
    font-size: var(--nav-font-size);
    line-height: 1.4;
    padding-block: var(--type-control-padding-block);
    padding-inline: var(--type-control-padding-inline);
    cursor: pointer;
    font-family: inherit;
}

.microlecture-video-retry:hover,
.microlecture-video-retry:focus-visible {
    text-decoration: underline;
}

.microlecture-video-timeout a {
    color: var(--theme-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.microlecture-video-area.is-timeout .microlecture-video-timeout {
    display: flex;
}

.microlecture-video-area.is-loading iframe {
    visibility: hidden;
}

.microlecture-video-area.is-timeout iframe {
    visibility: hidden;
}

.microlecture-video-area iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.microlecture-video-guide {
    margin: 8px 0 6px 0;
    font-size: calc(var(--nav-font-size) * 0.8);
    line-height: 1.4;
    font-style: italic;
}

.microlecture-video-guide a {
    color: var(--theme-text);
    text-decoration: none;
    font-size: inherit;
    line-height: inherit;
}

.microlecture-video-guide a:hover,
.microlecture-video-guide a:focus-visible {
    text-decoration: underline;
    font-size: inherit;
}

.microlecture-video-unavailable {
    margin: 8px 0 6px 0;
    font-size: var(--nav-font-size);
    line-height: 1.4;
}

.microlecture-video-unavailable a {
    color: var(--theme-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.microlecture-empty {
    margin: 0;
    padding: 8px 0;
    font-size: var(--nav-font-size);
}

.microlecture-attachments {
    margin-top: var(--type-space-content);
    padding-top: var(--type-space-content);
    border-top: 1px solid var(--theme-divider-standard);
}

.microlecture-attachments h6 {
    margin: 0 0 var(--type-space-tight);
    font-size: var(--type-size-section-title);
    line-height: var(--type-leading-heading);
}

.microlecture-attachment-list {
    margin: 0;
    padding-left: 20px;
}

.microlecture-attachment-list li + li {
    margin-top: var(--type-space-tight);
}

.microlecture-attachment-list span,
.microlecture-materials-empty,
.microlecture-download-links-help {
    color: var(--theme-text-muted);
    font-size: var(--type-size-small);
}

.microlecture-attachment-list span::before {
    content: " · ";
}

.microlecture-reply-entry-action {
    margin-top: var(--type-space-content);
}

@media (max-width: 900px) {
    .microlecture-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        gap: 14px;
    }

    .microlecture-layout.is-sidebar-collapsed {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        gap: 14px;
    }

    .microlecture-sidebar-toggle {
        position: relative;
        top: auto;
        left: auto;
        grid-column: 1;
        grid-row: 1;
        align-self: end;
        justify-self: end;
        width: 66px;
        height: 19px;
        margin-right: calc(-1 * var(--main-padding-right));
        margin-bottom: 1px;
        border-radius: 4px 4px 0 0;
    }

    .microlecture-layout.is-sidebar-collapsed .microlecture-sidebar-toggle {
        left: auto;
        width: 76px;
        height: 19px;
    }

    .microlecture-sidebar-toggle-label {
        display: inline;
        writing-mode: horizontal-tb;
        text-orientation: mixed;
        letter-spacing: normal;
    }

    .microlecture-sidebar {
        grid-column: 1;
        grid-row: 1;
        margin-right: calc(-1 * var(--main-padding-right));
        padding-block: var(--type-sidebar-shell-padding-block);
        padding-inline: var(--type-sidebar-shell-padding-inline);
        min-height: auto;
        align-self: auto;
        background: transparent;
        color: var(--theme-text);
        border-bottom: 0;
    }

    .microlecture-detail-column {
        grid-column: 1;
        grid-row: 2;
        border-left: 0;
        border-top: 0;
        margin-top: 0;
        margin-left: calc(-1 * var(--main-padding-left));
        margin-right: calc(-1 * var(--main-padding-right));
        padding: var(--type-space-content);
        min-height: 0;
    }

    .microlecture-lecture-btn {
        grid-template-columns: 24.48px minmax(0, 1fr);
    }

}

@media (max-width: 650px) {
    .microlecture-home-table th:first-child,
    .microlecture-home-table td:first-child {
        width: 36%;
        padding-right: 12px;
    }

    .microlecture-home-category-line {
        display: grid;
        grid-template-columns: 38px minmax(0, 1fr);
        column-gap: 6px;
        align-items: start;
        min-height: 0;
        text-align: left;
    }

    .microlecture-home-category-index {
        align-self: start;
        text-align: left;
        white-space: nowrap;
        line-height: 1.4;
    }

    .microlecture-home-category-title {
        writing-mode: horizontal-tb;
        text-orientation: mixed;
        transform: none;
        white-space: normal;
        word-break: normal;
        overflow-wrap: break-word;
        line-height: 1.4;
        text-align: left;
    }
}

/* Keep every Micro Lectures navigation level visually equal. */
.microlecture-category-btn,
.microlecture-category-code,
.microlecture-category-name,
.microlecture-lecture-btn,
.microlecture-lecture-code,
.microlecture-lecture-title,
.microlecture-home-category-line,
.microlecture-home-category-index,
.microlecture-home-category-title,
.microlecture-home-lecture-btn,
.microlecture-home-lecture-index,
.microlecture-home-lecture-title {
    color: var(--theme-text);
    font-size: var(--nav-font-size);
}

/* Scale the panel control from the same text system as the page. */
.microlecture-sidebar-toggle-label {
    font-size: calc(var(--nav-font-size) * 0.8);
}

@media (min-width: 901px) {
    .microlecture-sidebar-toggle {
        height: 72px;
    }

    .microlecture-layout.is-sidebar-collapsed .microlecture-sidebar-toggle {
        height: 82px;
    }
}

@media (max-width: 900px) {
    .microlecture-sidebar-toggle {
        width: 72px;
    }

    .microlecture-layout.is-sidebar-collapsed .microlecture-sidebar-toggle {
        width: 82px;
    }
}
