/* DBLab SQLite WASM workspace styles. */
.dblab-workspace .dblab-select {
    width: auto;
    max-width: 14rem;
}

.dblab-workspace .dblab-split {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
}

@media (max-width: 768px) {
    .dblab-workspace .dblab-split {
        grid-template-columns: 1fr;
    }

    .dblab-workspace .dblab-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    }
}

.dblab-workspace .dblab-sidebar {
    max-height: 460px;
    overflow-y: auto;
    background-color: var(--bs-tertiary-bg, #f8f9fa);
}

.dblab-workspace .dblab-schema-meta {
    font-size: 0.72rem;
    white-space: nowrap;
}

.dblab-workspace .dblab-sql-input {
    font-size: 0.9rem;
    resize: vertical;
}

.dblab-workspace .dblab-ac-list {
    position: absolute;
    z-index: 20;
    left: 0;
    top: 100%;
    min-width: 220px;
    max-height: 220px;
    overflow-y: auto;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.dblab-workspace .dblab-ac-item {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.25rem 0.5rem;
    border: 0;
    background: transparent;
    color: var(--bs-body-color, #212529);
    font-family: var(--bs-font-monospace, monospace);
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
}

.dblab-workspace .dblab-ac-item.active,
.dblab-workspace .dblab-ac-item:hover {
    background: var(--bs-primary-bg-subtle, #cfe2ff);
}

.dblab-workspace .dblab-ac-kind {
    font-size: 0.7rem;
    text-transform: uppercase;
    opacity: 0.65;
}

.dblab-workspace .dblab-result-table {
    font-size: 0.84rem;
}

.dblab-workspace .dblab-result-table th {
    background-color: var(--bs-tertiary-bg, #f8f9fa);
}

.dblab-workspace .dblab-null-val {
    font-style: italic;
    opacity: 0.6;
}

/* ER diagram styles (synced classes from tiny_codelab). */
.tiny_codelab-er {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.tiny_codelab-er-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
}

.tiny_codelab-er-lint {
    padding: .45rem .65rem;
    border: 1px solid #f59e0b;
    border-radius: .375rem;
    background: #fffbeb;
    color: #92400e;
}

.tiny_codelab-er-canvas {
    position: relative;
    width: 100%;
    height: 360px;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: .375rem;
    background: #f8fafc;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
}

.tiny_codelab-er-canvas:active {
    cursor: grabbing;
}

.tiny_codelab-er-table {
    cursor: move;
}

.tiny_codelab-er-warn-badge {
    cursor: pointer;
}

.tiny_codelab-er-svg {
    display: block;
    user-select: none;
}

.tiny_codelab-er-box {
    fill: #fff;
    stroke: #94a3b8;
    stroke-width: 1.5;
}

.tiny_codelab-er-head {
    fill: #1e293b;
}

.tiny_codelab-er-table.is-locked .tiny_codelab-er-head {
    fill: #475569;
}

.tiny_codelab-er-table.is-highlighted .tiny_codelab-er-box {
    stroke: #0f6cbf;
    stroke-width: 2.5;
}

.tiny_codelab-er-table:focus-visible .tiny_codelab-er-box {
    stroke: #0f6cbf;
    stroke-width: 2.5;
}

.tiny_codelab-er-title {
    fill: #fff;
    font-size: 13px;
    font-weight: 700;
}

.tiny_codelab-er-action {
    fill: #bfdbfe;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.tiny_codelab-er-action:hover {
    fill: #fff;
    text-decoration: underline;
}

.tiny_codelab-er-colname {
    fill: #0f172a;
    font-family: var(--bs-font-monospace, monospace);
    font-size: 12px;
    font-weight: 500;
}

.tiny_codelab-er-coltype {
    fill: #64748b;
    font-family: var(--bs-font-monospace, monospace);
    font-size: 11px;
}

.tiny_codelab-er-col-hl {
    fill: #dbeafe;
}

.tiny_codelab-er-badge {
    font-family: var(--bs-font-monospace, monospace);
    font-size: 10px;
    font-weight: 700;
}

.tiny_codelab-er-badge.is-pk {
    fill: #b45309;
}

.tiny_codelab-er-badge.is-fk {
    fill: #1d4ed8;
}

.tiny_codelab-er-edge-path,
.tiny_codelab-er-marker {
    stroke: #475569;
    stroke-width: 1.6;
}

.tiny_codelab-er-marker-hollow {
    stroke: #475569;
    stroke-width: 1.6;
    fill: #fff;
}

.tiny_codelab-er-edge.is-highlighted .tiny_codelab-er-edge-path,
.tiny_codelab-er-edge.is-highlighted .tiny_codelab-er-marker {
    stroke: #0f6cbf;
    stroke-width: 2.6;
}

.tiny_codelab-er-warn-circle {
    fill: #f59e0b;
}

.tiny_codelab-er-warn-text {
    fill: #1e293b;
    font-size: 11px;
    font-weight: 700;
}

.tiny_codelab-er-chen-entity {
    fill: #1e293b;
    stroke: #0f172a;
    stroke-width: 1.5;
}

.tiny_codelab-er-chen-attr {
    fill: #fff;
    stroke: #64748b;
    stroke-width: 1.2;
}

.tiny_codelab-er-chen-rel {
    fill: #fef3c7;
    stroke: #b45309;
    stroke-width: 1.4;
}

.tiny_codelab-er-chen-text {
    fill: #0f172a;
    font-size: 11px;
}

.tiny_codelab-er-chen-text.is-pk {
    font-weight: 700;
    text-decoration: underline;
}

.filter_codelab-dark .tiny_codelab-er-canvas {
    border-color: #3c3c3c;
    background: #1a1d21;
}

.filter_codelab-dark .tiny_codelab-er-box {
    fill: #252526;
    stroke: #52525b;
}

.filter_codelab-dark .tiny_codelab-er-head {
    fill: #334155;
}

.filter_codelab-dark .tiny_codelab-er-colname {
    fill: #e2e8f0;
}

.filter_codelab-dark .tiny_codelab-er-coltype {
    fill: #94a3b8;
}

.filter_codelab-dark .tiny_codelab-er-col-hl {
    fill: #1e3a5f;
}

.filter_codelab-dark .tiny_codelab-er-badge.is-pk {
    fill: #fbbf24;
}

.filter_codelab-dark .tiny_codelab-er-badge.is-fk {
    fill: #60a5fa;
}

.filter_codelab-dark .tiny_codelab-er-edge-path,
.filter_codelab-dark .tiny_codelab-er-marker {
    stroke: #94a3b8;
}

.filter_codelab-dark .tiny_codelab-er-marker-hollow {
    stroke: #94a3b8;
    fill: #1a1d21;
}

.filter_codelab-dark .tiny_codelab-er-lint {
    border-color: #b45309;
    background: #3b2a10;
    color: #fde68a;
}

.filter_codelab-dark .tiny_codelab-er-chen-attr {
    fill: #252526;
    stroke: #94a3b8;
}

.filter_codelab-dark .tiny_codelab-er-chen-text {
    fill: #e2e8f0;
}

.filter_codelab-dark .tiny_codelab-er-chen-rel {
    fill: #4b3d12;
    stroke: #fbbf24;
}

/* Scrolling regions take the keyboard focus (the console, the trace table, the call tree, the memory view). */
.tiny_codelab-console:focus-visible,
.tiny_codelab-trace-scroll:focus-visible,
.tiny_codelab-calltree-scroll:focus-visible,
.tiny_codelab-mem:focus-visible {
    outline: 2px solid #0f6cbf;
    outline-offset: 2px;
}

/* Less motion when the reader asks for it: no animated memory bars and no smooth scrolling (the turtle draws at once,
   tiny_codelab/turtle). */
@media (prefers-reduced-motion: reduce) {
    [class*="tiny_codelab-"] {
        transition: none;
        animation: none;
        scroll-behavior: auto;
    }
}

/* Forced colours (Windows high contrast): the browser sets the text and border colours to the system ones. Shapes are
   drawn in the text colour (currentcolor) on the page background; what colour alone marked gets a border, an outline
   or a dash: the changed variables, the current step, the repeated and waiting calls, the bars of an array. The
   turtle drawing and the complexity chart keep their own colours, as pictures. */
@media (forced-colors: active) {
    .tiny_codelab-console,
    .tiny_codelab-aihint-box,
    .tiny_codelab-cx,
    .tiny_codelab-mem-frame,
    .tiny_codelab-mem-object,
    .tiny_codelab-mem-content {
        border: 1px solid currentcolor;
    }

    .tiny_codelab-console-error,
    .tiny_codelab-console-compile,
    .tiny_codelab-console-status {
        font-weight: bold;
    }

    .tiny_codelab-vars-table tr.tiny_codelab-vars-changed td,
    .tiny_codelab-trace-table td.tiny_codelab-vars-changed,
    tr.tiny_codelab-mem-changed td,
    .tiny_codelab-mem-changed .tiny_codelab-mem-content {
        outline: 2px dashed currentcolor;
        outline-offset: -2px;
    }

    .tiny_codelab-trace-table tr.tiny_codelab-trace-current td {
        outline: 3px solid currentcolor;
    }

    .tiny_codelab-calltree-edge {
        stroke: currentcolor;
    }

    .tiny_codelab-calltree-node rect {
        fill: transparent;
        stroke: currentcolor;
    }

    .tiny_codelab-calltree-node text,
    .tiny_codelab-calltree-svg .tiny_codelab-calltree-value {
        fill: currentcolor;
        stroke: none;
    }

    .tiny_codelab-calltree-current rect {
        stroke-width: 4;
    }

    .tiny_codelab-calltree-repeated rect {
        stroke-dasharray: 6 3;
    }

    .tiny_codelab-calltree-waiting rect {
        stroke-dasharray: 2 2;
    }

    .tiny_codelab-mem-arrows {
        color: inherit;
    }

    .tiny_codelab-mem-arrows path {
        stroke: currentcolor;
    }

    .tiny_codelab-mem-arrows marker path {
        fill: currentcolor;
    }

    .tiny_codelab-mem-bar {
        outline: 2px solid currentcolor;
        outline-offset: -2px;
    }

    .tiny_codelab-mem-matrix td.tiny_codelab-mem-changed {
        outline: 2px dashed currentcolor;
    }

    .tiny_codelab-mem-matrix td.tiny_codelab-mem-current {
        border: 3px double currentcolor;
    }

    .tiny_codelab-console-past {
        border-left-style: double;
    }

    .tiny_codelab-turtle-svg,
    .tiny_codelab-cx-chart {
        forced-color-adjust: none;
    }
}

/* More contrast when the reader asks for it: darker borders, lines and secondary texts. */
@media (prefers-contrast: more) {
    .tiny_codelab-console-empty,
    .tiny_codelab-vars-empty,
    .tiny_codelab-calltree-summary,
    .tiny_codelab-aihint-note,
    .tiny_codelab-aihint-wait,
    .tiny_codelab-turtle-note,
    .tiny_codelab-mem-title,
    .tiny_codelab-mem-type,
    .tiny_codelab-mem-index,
    .tiny_codelab-mem-more {
        color: #111827;
    }

    .tiny_codelab-console,
    .tiny_codelab-cx,
    .tiny_codelab-turtle-svg,
    .tiny_codelab-mem-frame,
    .tiny_codelab-mem-object,
    .tiny_codelab-mem-content {
        border-color: #343a40;
    }

    .tiny_codelab-calltree-edge {
        stroke: #334155;
        stroke-width: 1.5;
    }

    .tiny_codelab-calltree-node:not(.tiny_codelab-calltree-repeated):not(.tiny_codelab-calltree-waiting) rect {
        stroke: #1f2937;
    }

    .tiny_codelab-mem-arrows path {
        stroke-width: 2;
    }

    .tiny_codelab-cx-tick,
    .tiny_codelab-cx-reflabel {
        fill: #2f2e2b;
    }

    .tiny_codelab-cx-grid {
        stroke: #9b9a93;
    }
}

/* SQL step by step (tiny_codelab/sqlstep). */
.tiny_codelab-sqlstep-panel {
    margin-top: .5rem;
    padding: .75rem;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: .375rem;
    background: #f8fafc;
}

.tiny_codelab-sqlstep-query,
.tiny_codelab-sqlstep-output {
    padding: .4rem .6rem;
    border-radius: .25rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    white-space: pre;
    overflow-x: auto;
}

.tiny_codelab-sqlstep-query {
    color: #1e3a8a;
}

.filter_codelab-dark .tiny_codelab-sqlstep-panel {
    background: #1e1e1e;
    border-color: #3c3c3c;
    color: #d4d4d4;
}

.filter_codelab-dark .tiny_codelab-sqlstep-query,
.filter_codelab-dark .tiny_codelab-sqlstep-output {
    background: #252526;
    border-color: #3c3c3c;
    color: #d4d4d4;
}

.filter_codelab-dark .tiny_codelab-sqlstep-query {
    color: #9cdcfe;
}

/* SQL transactions (tiny_codelab/sqltxn): two panes side by side, one under the other on a phone. */
.tiny_codelab-sqltxn-panes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: .75rem;
}

.tiny_codelab-sqltxn-out {
    min-height: 4rem;
    max-height: 18rem;
    overflow: auto;
    padding: .4rem .6rem;
    border-radius: .25rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    white-space: pre;
}

.filter_codelab-dark .tiny_codelab-sqltxn-out {
    background: #252526;
    border-color: #3c3c3c;
    color: #d4d4d4;
}

/* Printed copy of the code of an example (tiny_codelab/print): only for print. */
.tiny_codelab-printcode {
    display: none;
}

/* Print: pages with examples as worksheets. The code without the editor, the tools and the results of runs. */
@media print {
    .tiny_codelab-printable {
        border: 0;
        box-shadow: none;
    }

    .tiny_codelab-printable > :not(.tiny_codelab-printcode),
    .tiny_codelab-console,
    .tiny_codelab-cmphints,
    .tiny_codelab-aihint-box,
    .tiny_codelab-vars,
    .tiny_codelab-layout-side,
    .tiny_codelab-side .tiny_codelab-splitter,
    .tiny_codelab-terminal-form,
    .tiny_codelab-icon-button.btn,
    .tiny_codelab-sqlstep-panel,
    .tiny_codelab-sqlsteps-panel,
    .tiny_codelab-sqlplan-panel,
    .tiny_codelab-sqltxn-panel,
    .tiny_codelab-relalg-panel,
    .tiny_codelab-er-toolbar,
    .tiny_codelab-timeline-range {
        display: none;
    }

    .tiny_codelab-printcode {
        display: block;
    }

    .tiny_codelab-printcode pre {
        margin: 0 0 .75rem;
        padding: .5rem .75rem;
        border: 1px solid #6a737b;
        border-radius: 0;
        background: #fff;
        color: #000;
        font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
        font-size: .875rem;
        line-height: 1.35;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        break-inside: avoid;
        orphans: 3;
        widows: 3;
    }

    .tiny_codelab-printcode-name {
        margin-bottom: .15rem;
        font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
        font-size: .8125rem;
        font-weight: bold;
        break-after: avoid;
    }
}

/* ER diagram: views (dashed) and triggers. */
.tiny_codelab-er-table.is-view .tiny_codelab-er-box {
    stroke-dasharray: 6 4;
}

.tiny_codelab-er-table.is-view .tiny_codelab-er-head {
    fill: #6d28d9;
}

.tiny_codelab-er-viewedge {
    stroke: #7c3aed;
    stroke-width: 1.5;
    stroke-dasharray: 5 4;
}

.tiny_codelab-er-trigger {
    fill: #fbbf24;
    font-size: 10px;
    font-weight: 700;
    cursor: help;
}

