/* Main docs layout: header + Split.js (see assets/sandbox_split.js initSqlShorts) */
#sqls-page-wrapper.sqls-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--app-header-height, 56px));
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
    padding: 4px 12px 2px;
}

/* Denied/degraded placeholders: simple scrollable block (no split) */
.sqls-page:not(#sqls-page-wrapper) {
    padding: 1rem;
}

#sqls-page-wrapper .sqls-split-header {
    flex-shrink: 0;
    margin-bottom: 4px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem 1rem;
    flex-wrap: wrap;
}

#sqls-page-wrapper .sqls-split-header .sqls-title {
    margin-bottom: 0;
    flex-shrink: 0;
}

#sqls-page-wrapper .sqls-split-header .sqls-subtitle {
    flex: 1 1 12rem;
    min-width: 0;
    max-width: 100%;
    text-align: left;
    margin-bottom: 0;
}

@media (max-width: 576px) {
    #sqls-page-wrapper .sqls-split-header {
        flex-direction: column;
        align-items: flex-start;
    }

    #sqls-page-wrapper .sqls-split-header .sqls-subtitle {
        flex: none;
        text-align: left;
        width: 100%;
    }
}

#sqls-page-wrapper .sandbox-split-outer {
    flex: 1 1 0;
    min-height: 0;
    height: auto !important;
}

#sqls-page-wrapper .sqls-page-footer-wrap {
    flex-shrink: 0;
}

/* SQL Shorts copyright: compact strip */
.sqls-page-footer-wrap {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding: 0.15rem 0 0;
    margin: 0.15rem 0 0;
}

.sqls-page-footer {
    font-size: 0.65rem;
    line-height: 1.25;
    margin: 0;
}

#sqls-page-wrapper #sqls-split-outer:not(.sandbox-left-collapsed) #sqls-panel-left {
    min-width: 220px;
}

#sqls-page-wrapper .sandbox-split-panel.sqls-panel-left {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
}

#sqls-page-wrapper .sqls-right-toolbar {
    flex-shrink: 0;
    min-width: 0;
}

.sqls-toggle-left-panel-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.sqls-toggle-left-panel-btn .sqls-toggle-label {
    display: none;
}

#sqls-page-wrapper .sqls-content-pane--main {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
}

/* Narrow viewports: switch from split workspace to reader-first stacked layout */
@media (max-width: 992px) {
    #sqls-page-wrapper.sqls-page {
        height: auto;
        min-height: calc(100vh - var(--app-header-height, 56px));
        padding: 4px 8px 2px;
    }

    #sqls-page-wrapper .sandbox-split-outer {
        flex-direction: column !important;
        flex-wrap: nowrap;
        overflow: hidden;
        min-height: 0;
        height: auto !important;
    }

    #sqls-page-wrapper .sandbox-split-outer > .gutter {
        display: none !important;
    }

    #sqls-page-wrapper .sqls-toggle-left-panel-btn .sqls-toggle-label {
        display: inline;
    }

    #sqls-page-wrapper .sandbox-split-panel.sqls-panel-left,
    #sqls-page-wrapper #sqls-panel-right {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        flex-basis: auto !important;
    }

    #sqls-page-wrapper #sqls-panel-left {
        flex: 0 0 auto !important;
        max-height: min(40vh, 20rem);
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        background: #fff;
        margin-bottom: 0.5rem;
        padding: 0.5rem;
    }

    #sqls-page-wrapper .sandbox-split-outer.sandbox-left-collapsed #sqls-panel-left {
        flex: 0 0 0 !important;
        height: 0 !important;
        min-height: 0 !important;
        max-height: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    #sqls-page-wrapper #sqls-panel-right {
        flex: 1 1 auto !important;
        min-height: 0;
    }

    #sqls-page-wrapper .sqls-content-pane {
        padding: 0.8rem 0.9rem;
        border-radius: 0.375rem;
    }

    #sqls-page-wrapper .sqls-chapter-list {
        padding-right: 0;
    }

    #sqls-page-wrapper .sqls-chapter-prose {
        font-size: 0.95rem;
        line-height: 1.68;
    }

    #sqls-page-wrapper .sqls-chapter-prose h1 {
        font-size: 1.3rem;
    }

    #sqls-page-wrapper .sqls-chapter-prose h2 {
        font-size: 1.05rem;
    }

    #sqls-page-wrapper .sqls-chapter-prose th,
    #sqls-page-wrapper .sqls-chapter-prose td {
        padding: 0.4rem 0.5rem;
    }

    #sqls-page-wrapper .sqls-page-footer {
        font-size: 0.6rem;
    }

    #sqls-page-wrapper .sqls-chapter-nav {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding-top: 0.75rem;
    }
}

@media (max-width: 560px) {
    #sqls-page-wrapper .sqls-split-header {
        display: none;
    }

    #sqls-page-wrapper.sqls-page {
        padding-left: 6px;
        padding-right: 6px;
    }

    #sqls-page-wrapper .sqls-content-pane {
        padding: 0.7rem 0.75rem;
    }

    #sqls-page-wrapper .sqls-chapter-link {
        padding: 0.5rem 0.55rem;
    }

    #sqls-page-wrapper .sqls-chapter-prose {
        font-size: 1rem;
        line-height: 1.72;
    }
}

.sqls-title {
    margin-bottom: 0.25rem;
}

.sqls-subtitle {
    color: #6c757d;
    margin-bottom: 0;
}

.sqls-chapter-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
    padding-right: 0.25rem;
}

#sqls-page-wrapper .sqls-chapter-list {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
}

.sqls-chapter-link {
    display: block;
    padding: 0.4rem 0.55rem;
    border-radius: 0.375rem;
    text-decoration: none;
    color: #212529;
}

.sqls-chapter-link:hover {
    background: #f3f4f6;
}

.sqls-chapter-link.active {
    background: #e9f3ff;
    color: #0d6efd;
    font-weight: 600;
}

.sqls-content-pane {
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    min-height: 70vh;
    background: #fff;
    padding: 1rem 1.25rem;
    overflow-x: auto;
}

#sqls-page-wrapper .sqls-content-pane {
    min-height: 0;
}

/* Chapter body: match portal typography (themes.css variables + Bootstrap-like rhythm) */
.sqls-chapter-prose {
    font-size: var(--font-size-body-lg, 0.875rem);
    line-height: 1.6;
    color: var(--bs-body-color, #212529);
    max-width: 100%;
}

.sqls-chapter-prose h1 {
    font-size: var(--font-size-display, 1.5rem);
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.sqls-chapter-prose h2 {
    font-size: var(--font-size-page-title, 1.125rem);
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 0.25rem;
}

.sqls-chapter-prose h3,
.sqls-chapter-prose h4 {
    font-size: var(--font-size-body-lg, 0.875rem);
    margin-top: 1rem;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.sqls-chapter-prose p {
    margin-bottom: 0.65rem;
}

.sqls-chapter-prose ul,
.sqls-chapter-prose ol {
    margin-bottom: 0.65rem;
    padding-left: 1.25rem;
}

.sqls-chapter-prose li {
    margin-bottom: 0.25rem;
}

.sqls-chapter-prose a {
    color: var(--bs-link-color, #0d6efd);
    text-decoration: none;
}

.sqls-chapter-prose a:hover {
    text-decoration: underline;
}

.sqls-chapter-prose blockquote {
    margin: 0 0 0.75rem;
    padding: 0.35rem 0.75rem;
    border-left: 4px solid #cfe2ff;
    background: #f8f9fa;
    color: #495057;
}

.sqls-chapter-prose hr {
    margin: 1rem 0;
    opacity: 0.35;
}

.sqls-chapter-prose table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
    font-size: var(--font-size-body, 0.8125rem);
}

.sqls-chapter-prose th,
.sqls-chapter-prose td {
    padding: 0.45rem 0.65rem;
    border: 1px solid #dee2e6;
    vertical-align: top;
}

.sqls-chapter-prose thead th {
    background: var(--bs-table-bg, #f8f9fa);
    font-weight: 600;
}

.sqls-chapter-prose tbody tr:nth-of-type(even) {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Inline SQL / identifiers */
.sqls-chapter-prose code:not(pre code) {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
        "Courier New", monospace;
    font-size: 0.95em;
    padding: 0.1em 0.35em;
    background: #f1f3f5;
    border-radius: 0.25rem;
    color: #c7254e;
}

/* Fenced blocks: room for Prism tokens */
.sqls-chapter-prose pre {
    margin: 0 0 1rem;
    padding: 0.85rem 1rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow-x: auto;
}

.sqls-chapter-prose pre code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
        "Courier New", monospace;
    font-size: var(--font-size-body-lg, 0.875rem);
    line-height: 1.55;
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0;
    color: inherit !important;
}

.sqls-chapter-prose details {
    margin-bottom: 0.75rem;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    padding: 0.5rem 0.65rem;
    background: #fff;
}

.sqls-chapter-prose summary {
    cursor: pointer;
    font-weight: 600;
}

/* Student practice blocks (<sql-shorts-practice> in chapter sources) */
.sqls-chapter-prose details.sql-shorts-practice {
    margin: 1.25rem 0 1.5rem;
    padding: 0;
    border: 1px solid var(--border-color, #dfdfdf);
    border-radius: 0.5rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    overflow: hidden;
}

.sqls-chapter-prose details.sql-shorts-practice:not([open]) {
    border: 2px solid rgba(20, 70, 160, 0.28);
    border-left: 5px solid var(--primary-color, #1446a0);
    box-shadow: 0 2px 10px rgba(20, 70, 160, 0.1);
}

.sqls-chapter-prose details.sql-shorts-practice > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    font-weight: 600;
    font-size: var(--font-size-body-lg, 0.875rem);
    color: var(--primary-color, #1446a0);
    background: rgba(20, 70, 160, 0.07);
    border-bottom: 1px solid var(--border-color, #dfdfdf);
    list-style: none;
}

.sqls-chapter-prose details.sql-shorts-practice > summary::-webkit-details-marker {
    display: none;
}

.sqls-chapter-prose details.sql-shorts-practice > summary::after {
    flex-shrink: 0;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1;
    color: var(--primary-color, #1446a0);
    content: "+";
}

.sqls-chapter-prose details.sql-shorts-practice[open] > summary::after {
    content: "\2212";
}

.sqls-chapter-prose details.sql-shorts-practice:not([open]) > summary {
    border-bottom-color: transparent;
    background: linear-gradient(
        90deg,
        rgba(20, 70, 160, 0.16) 0%,
        rgba(20, 70, 160, 0.07) 55%,
        rgba(20, 70, 160, 0.04) 100%
    );
    font-size: 0.9375rem;
}

.sqls-chapter-prose details.sql-shorts-practice[open] > summary {
    border-bottom-color: var(--border-color, #dfdfdf);
}

.sqls-chapter-prose details.sql-shorts-practice > .sql-shorts-practice__body {
    padding: 0.85rem 1rem 1rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
}

.sqls-chapter-prose details.sql-shorts-practice > .sql-shorts-practice__body > :last-child {
    margin-bottom: 0;
}

.sqls-chapter-nav-wrap {
    margin-top: 1rem;
}

.sqls-chapter-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    padding-top: 0.85rem;
    border-top: 1px solid #e9ecef;
}

.sqls-chapter-nav-link {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    padding: 0.8rem 0.9rem;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    background: #fff;
    color: #212529;
    text-decoration: none;
}

.sqls-chapter-nav-link:hover {
    border-color: #b8d4ff;
    background: #f8fbff;
    text-decoration: none;
}

.sqls-chapter-nav-kicker {
    font-size: 0.72rem;
    line-height: 1.25;
    color: #6c757d;
}

.sqls-chapter-nav-title {
    font-size: 0.95rem;
    line-height: 1.35;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.sqls-error-panel {
    padding: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    background: #fff;
}
