/* ============================================================
   SQL SANDBOX
   Dark theme — SQL Learning Platform
   ============================================================ */


/* ============================================================
   GLOBAL
   ============================================================ */

* {
    box-sizing: border-box;
}


html,
body {

    margin: 0;
    padding: 0;

    width: 100%;
    height: 100%;
}


body {

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    background: #0b1120;

    color: #e5e7eb;

    overflow: hidden;
}


/* ============================================================
   PLATFORM NAVIGATION
   ============================================================ */

.platform-header {

    height: 58px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 22px;

    background: #0f172a;

    border-bottom: 1px solid #263247;

    flex-shrink: 0;
}


.platform-header h1 {

    margin: 0;

    font-size: 18px;

    font-weight: 700;

    color: #f8fafc;

    white-space: nowrap;
}


.platform-nav {

    display: flex;
    align-items: center;

    gap: 22px;

    min-width: 0;
}


.platform-nav a {

    color: #cbd5e1;

    text-decoration: none;

    font-size: 13px;

    font-weight: 600;

    white-space: nowrap;

    transition: color .15s ease;
}


.platform-nav a:hover {

    color: #60a5fa;
}


.platform-nav a[href="sandbox.html"] {

    color: #60a5fa;
}


/* ============================================================
   MAIN LAYOUT
   ============================================================ */

.sandbox-layout {

    display: flex;

    width: 100%;

    height: calc(100vh - 58px);

    min-height: 0;
}


/* ============================================================
   DATABASE SIDEBAR
   ============================================================ */

.database-sidebar {

    width: 260px;

    min-width: 260px;

    display: flex;
    flex-direction: column;

    background: #0f172a;

    border-right: 1px solid #263247;
}


.sidebar-header {

    height: 46px;

    padding: 0 14px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid #263247;

    color: #94a3b8;

    font-size: 11px;

    font-weight: 700;

    letter-spacing: .06em;

    flex-shrink: 0;
}


.database-search {

    padding: 10px;

    flex-shrink: 0;
}


.database-search input {

    width: 100%;

    height: 34px;

    padding: 0 10px;

    border: 1px solid #334155;

    border-radius: 6px;

    outline: none;

    background: #111c31;

    color: #e5e7eb;

    font-size: 13px;
}


.database-search input::placeholder {

    color: #64748b;
}


.database-search input:focus {

    border-color: #3b82f6;

    box-shadow:
        0 0 0 2px rgba(59, 130, 246, .12);
}


.database-tree {

    flex: 1;

    min-height: 0;

    overflow-y: auto;

    padding: 5px 8px;
}


.empty-database-message {

    padding: 35px 15px;

    text-align: center;

    color: #64748b;
}


.empty-database-icon {

    font-size: 30px;

    margin-bottom: 9px;
}


.empty-database-message p {

    margin: 0 0 4px;

    color: #94a3b8;

    font-size: 13px;

    font-weight: 600;
}


.empty-database-message span {

    display: block;

    color: #64748b;

    font-size: 11px;

    line-height: 1.5;
}


/* ============================================================
   DATABASE TREE
   ============================================================ */

.database-item {

    margin-bottom: 5px;
}


.database-header {

    height: 34px;

    display: flex;
    align-items: center;

    gap: 7px;

    padding: 0 7px;

    border-radius: 5px;

    cursor: pointer;

    color: #e2e8f0;

    font-size: 13px;

    font-weight: 600;
}


.database-header:hover {

    background: #172338;
}


.database-arrow {

    width: 12px;

    color: #94a3b8;

    font-size: 10px;
}


.database-icon {

    font-size: 14px;
}


.database-name {

    color: #e2e8f0;
}


.table-list {

    padding-left: 26px;
}


.table-item {

    height: 32px;

    display: flex;
    align-items: center;

    gap: 7px;

    padding: 0 8px;

    border-radius: 5px;

    color: #94a3b8;

    font-size: 13px;

    cursor: pointer;
}


.table-item:hover {

    background: #172338;

    color: #60a5fa;
}


/* ============================================================
   SIDEBAR ACTIONS
   ============================================================ */

.sidebar-actions {

    padding: 11px;

    border-top: 1px solid #263247;

    flex-shrink: 0;
}


.create-database-button {

    width: 100%;

    height: 36px;

    border: 1px solid #334155;

    border-radius: 6px;

    background: #111c31;

    color: #cbd5e1;

    cursor: pointer;

    font-size: 13px;

    font-weight: 600;
}


.create-database-button:hover {

    background: #172338;

    border-color: #475569;

    color: #ffffff;
}


/* ============================================================
   WORKSPACE
   ============================================================ */

.sandbox-workspace {

    flex: 1;

    min-width: 0;

    min-height: 0;

    display: flex;

    flex-direction: column;

    background: #0b1120;

    overflow: hidden;
}


/* ============================================================
   INFORMATION BANNER
   ============================================================ */

.sandbox-info-banner {

    min-height: 54px;

    display: flex;
    align-items: center;

    gap: 11px;

    padding: 8px 15px;

    background: #111c31;

    border-bottom: 1px solid #263247;

    flex-shrink: 0;
}


.sandbox-info-icon {

    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 7px;

    background: #2563eb;

    color: #ffffff;

    font-size: 16px;

    flex-shrink: 0;
}


.sandbox-info-content {

    display: flex;

    flex-direction: column;

    gap: 2px;

    min-width: 0;
}


.sandbox-info-content strong {

    color: #f1f5f9;

    font-size: 13px;
}


.sandbox-info-content span {

    color: #aebbd0;

    font-size: 11px;

    line-height: 1.4;
}


/* ============================================================
   QUERY TABS
   ============================================================ */

.query-tabs-container {

    height: 40px;

    position: relative;

    min-height: 40px;

    display: flex;

    background: #0f172a;

    border-bottom: 1px solid #263247;

    flex-shrink: 0;
}


.query-tabs {

    display: flex;

    align-items: stretch;

    min-width: 0;

    overflow-x: auto;

    overflow-y: hidden;
}


.query-tab {

    min-width: 90px;

    height: 40px;

    padding: 0 15px;

    border: 0;

    border-right: 1px solid #263247;

    background: #111c31;

    color: #94a3b8;

    cursor: pointer;

    font-size: 12px;

    font-weight: 600;

    white-space: nowrap;
}


.query-tab:hover {

    background: #172338;

    color: #dbeafe;
}


.query-tab.active {

    background: #0b1120;

    color: #60a5fa;

    border-top: 2px solid #3b82f6;
}


.query-tab-name {

    display: block;

    overflow: hidden;

    text-overflow: ellipsis;
}


/* ============================================================
   NEW QUERY BUTTON
   ============================================================ */

.new-query-button {

    width: 40px;

    min-width: 40px;

    height: 40px;

    border: 0;

    border-right: 1px solid #263247;

    background: #111c31;

    color: #cbd5e1;

    font-size: 18px;

    cursor: pointer;

    flex-shrink: 0;
}


.new-query-button:hover {

    background: #172338;

    color: #60a5fa;
}


/* ============================================================
   SQL EDITOR
   ============================================================

   IMPORTANT:

   The editor receives ALL available workspace height
   whenever the results panel is hidden.

   When results open, this section automatically shrinks
   because the results panel takes a portion of the workspace.
   ============================================================ */

.sql-editor-section {

    flex: 1 1 auto;

    min-height: 0;

    display: flex;

    flex-direction: column;

    background: #0b1120;

    border-bottom: 1px solid #263247;

    overflow: hidden;
}


/* ============================================================
   WORKSPACE TOOLBAR
   ============================================================ */

.workspace-toolbar {

    height: 46px;

    min-height: 46px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    padding: 0 13px;

    background: #0f172a;

    border-bottom: 1px solid #263247;

    flex-shrink: 0;
}


.workspace-title {

    color: #cbd5e1;

    font-size: 11px;

    font-weight: 700;

    letter-spacing: .05em;
}


.workspace-actions {

    display: flex;

    align-items: center;

    gap: 7px;
}


.toolbar-button,
.run-query-button {

    height: 34px;

    padding: 0 13px;

    border-radius: 7px;

    cursor: pointer;

    font-size: 12px;

    font-weight: 600;

    white-space: nowrap;
}


.toolbar-button {

    border: 1px solid #3b4a63;

    background: #111c31;

    color: #d1d9e6;
}


.toolbar-button:hover {

    background: #172338;

    border-color: #4b6b9b;

    color: #ffffff;
}


#describe-table-button,
#view-schema-button,
#view-relationships-button {

    border: 1px solid #3b4a63;

    background: #111c31;

    color: #dbeafe;
}


#describe-table-button:hover,
#view-schema-button:hover,
#view-relationships-button:hover {

    background: #172338;

    border-color: #60a5fa;

    color: #ffffff;
}


.run-query-button {

    border: 0;

    background: #2563eb;

    color: #ffffff;

    padding-left: 15px;

    padding-right: 15px;
}


.run-query-button:hover {

    background: #3b82f6;
}


.run-query-button:disabled {

    opacity: .6;

    cursor: not-allowed;
}


/* ============================================================
   SQL EDITOR WRAPPER
   ============================================================ */

.editor-wrapper {

    flex: 1;

    min-height: 0;

    padding: 10px;

    background: #0b1120;

    overflow: hidden;
}


/* ============================================================
   SQL TEXTAREA
   ============================================================

   The scrollbar belongs ONLY to this textarea.

   It is deliberately not placed on the query tabs or
   editor wrapper.
   ============================================================ */

.sql-editor {

    display: block;

    width: 100%;

    height: 100%;

    resize: none;

    padding: 16px;

    border: 1px solid #334155;

    border-radius: 8px;

    outline: none;

    background: #111c31;

    color: #f1f5f9;

    caret-color: #60a5fa;

    font-family:
        Consolas,
        Monaco,
        "Courier New",
        monospace;

    font-size: 14px;

    line-height: 1.65;

    overflow: auto;

    white-space: pre;

    tab-size: 4;

    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, .25);
}


.sql-editor::placeholder {

    color: #64748b;

    opacity: 1;
}


.sql-editor:focus {

    border-color: #3b82f6;

    box-shadow:
        0 0 0 2px rgba(59, 130, 246, .12),
        inset 0 1px 2px rgba(0, 0, 0, .25);
}


/* ============================================================
   SQL EDITOR SCROLLBAR
   ============================================================ */

.sql-editor::-webkit-scrollbar {

    width: 9px;

    height: 9px;
}


.sql-editor::-webkit-scrollbar-track {

    background: #0f172a;
}


.sql-editor::-webkit-scrollbar-thumb {

    background: #334155;

    border-radius: 8px;
}


.sql-editor::-webkit-scrollbar-thumb:hover {

    background: #475569;
}


/* ============================================================
   SANDBOX STATUS
   ============================================================ */

.sandbox-status {

    min-height: 28px;

    height: 28px;

    padding: 5px 13px;

    background: #0b1120;

    color: #94a3b8;

    font-size: 12px;

    flex-shrink: 0;

    overflow: hidden;
}


/* ============================================================
   QUERY RESULTS
   ============================================================

   DEFAULT:

   Hidden.

   The editor therefore occupies almost the entire
   workspace.

   When JavaScript removes .results-hidden:

   Results receive the compact default height.
   ============================================================ */

.results-section {

    position: relative;

    height: 180px;

    min-height: 80px;

    flex: 0 0 180px;

    display: flex;

    flex-direction: column;

    background: #0f172a;

    border-top: 1px solid #263247;

    overflow: hidden;

    transition:
        height .15s ease,
        flex-basis .15s ease;
}


.results-section.results-hidden {

    display: none;
}


/* ============================================================
   RESULTS RESIZE HANDLE
   ============================================================

   The user can drag this small area upward/downward to
   resize the results panel.
   ============================================================ */

.results-resize-handle {

    position: absolute;

    top: 0;

    left: 0;

    right: 0;

    height: 8px;

    z-index: 5;

    cursor: ns-resize;

    background: transparent;
}


.results-resize-handle::after {

    content: "";

    position: absolute;

    top: 3px;

    left: 50%;

    transform: translateX(-50%);

    width: 42px;

    height: 3px;

    border-radius: 4px;

    background: #475569;

    opacity: .75;
}


.results-resize-handle:hover::after {

    background: #60a5fa;

    opacity: 1;
}


/* ============================================================
   RESULTS HEADER
   ============================================================ */

.results-header {

    min-height: 46px;

    height: 46px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 10px;

    padding: 6px 13px 6px 13px;

    background: #0f172a;

    border-bottom: 1px solid #263247;

    flex-shrink: 0;

    padding-top: 10px;
}


.results-title-container {

    min-width: 0;

    display: flex;

    flex-direction: column;

    gap: 1px;
}


.results-header h2 {

    margin: 0;

    color: #f1f5f9;

    font-size: 13px;

    line-height: 1.2;
}


.results-summary {

    color: #94a3b8;

    font-size: 10px;

    white-space: nowrap;
}


/* ============================================================
   RESULTS ACTIONS
   ============================================================ */

.results-actions {

    display: flex;

    align-items: center;

    gap: 4px;

    flex-shrink: 0;
}


.download-button {

    height: 28px;

    padding: 0 9px;

    border: 1px solid #334155;

    border-radius: 6px;

    background: #111c31;

    color: #cbd5e1;

    cursor: pointer;

    font-size: 11px;

    font-weight: 600;
}


.download-button:hover:not(:disabled) {

    background: #172338;

    border-color: #475569;

    color: #ffffff;
}


.download-button:disabled {

    opacity: .45;

    cursor: not-allowed;
}


/* ============================================================
   RESULTS MINIMIZE / MAXIMIZE / CLOSE BUTTONS
   ============================================================ */

.results-control-button {

    width: 28px;

    height: 28px;

    display: flex;

    align-items: center;

    justify-content: center;

    border: 1px solid #334155;

    border-radius: 6px;

    background: #111c31;

    color: #cbd5e1;

    cursor: pointer;

    font-size: 15px;

    line-height: 1;
}


.results-control-button:hover {

    background: #172338;

    border-color: #60a5fa;

    color: #ffffff;
}


/* ============================================================
   RESULTS CONTAINER
   ============================================================ */

.results-container {

    flex: 1;

    min-height: 0;

    overflow: auto;

    background: #0f172a;
}


/* ============================================================
   EMPTY RESULTS
   ============================================================ */

.empty-results {

    height: 100%;

    min-height: 70px;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: center;

    color: #64748b;
}


.empty-results-icon {

    font-size: 25px;

    margin-bottom: 5px;

    color: #475569;
}


.empty-results p {

    margin: 0;

    color: #94a3b8;

    font-size: 11px;
}


/* ============================================================
   RESULTS TABLE
   ============================================================ */

.results-table {

    width: 100%;

    border-collapse: collapse;

    font-size: 11px;
}


.results-table th {

    position: sticky;

    top: 0;

    z-index: 1;

    padding: 6px 9px;

    background: #172338;

    color: #dbeafe;

    text-align: left;

    font-size: 11px;

    font-weight: 700;

    border-bottom: 1px solid #334155;

    white-space: nowrap;
}


.results-table td {

    padding: 5px 9px;

    color: #cbd5e1;

    font-size: 11px;

    border-bottom: 1px solid #263247;

    white-space: nowrap;
}


.results-table tr:hover td {

    background: #172338;
}


/* ============================================================
   RESULTS SCROLLBAR
   ============================================================ */

.results-container::-webkit-scrollbar,
.database-tree::-webkit-scrollbar {

    width: 8px;

    height: 8px;
}


.results-container::-webkit-scrollbar-track,
.database-tree::-webkit-scrollbar-track {

    background: #0b1120;
}


.results-container::-webkit-scrollbar-thumb,
.database-tree::-webkit-scrollbar-thumb {

    background: #334155;

    border-radius: 8px;
}


.results-container::-webkit-scrollbar-thumb:hover,
.database-tree::-webkit-scrollbar-thumb:hover {

    background: #475569;
}


/* ============================================================
   MAXIMIZED RESULTS
   ============================================================

   When JavaScript adds .results-maximized, the results
   panel takes almost the entire workspace.
   ============================================================ */

.results-section.results-maximized {

    position: absolute;

    left: 260px;

    right: 0;

    top: 98px;

    bottom: 0;

    width: auto;

    height: auto !important;

    min-height: 0;

    flex: none;

    z-index: 100;
}


.results-section.results-maximized
.results-resize-handle {

    display: none;
}


/* ============================================================
   MINIMIZED RESULTS
   ============================================================ */

.results-section.results-minimized {

    height: 48px !important;

    min-height: 48px;

    flex-basis: 48px !important;
}


.results-section.results-minimized
.results-container {

    display: none;
}


.results-section.results-minimized
.results-resize-handle {

    display: none;
}


/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {

    position: fixed;

    inset: 0;

    display: flex;

    align-items: center;

    justify-content: center;

    background: rgba(2, 6, 23, .72);

    z-index: 1000;
}


.modal-overlay.hidden {

    display: none;
}


.modal {

    width: 420px;

    max-width: calc(100vw - 30px);

    background: #111c31;

    border: 1px solid #334155;

    border-radius: 10px;

    box-shadow:
        0 20px 50px rgba(0, 0, 0, .5);
}


.modal-header {

    display: flex;

    align-items: center;

    justify-content: space-between;

    padding: 16px 18px;

    border-bottom: 1px solid #263247;
}


.modal-header h2 {

    margin: 0;

    color: #f1f5f9;

    font-size: 16px;
}


.modal-close {

    border: 0;

    background: transparent;

    color: #94a3b8;

    font-size: 22px;

    cursor: pointer;
}


.modal-close:hover {

    color: #ffffff;
}


.modal-body {

    padding: 18px;
}


.modal-body label {

    display: block;

    margin-bottom: 7px;

    color: #cbd5e1;

    font-size: 13px;

    font-weight: 600;
}


.modal-body input {

    width: 100%;

    height: 38px;

    padding: 0 10px;

    border: 1px solid #334155;

    border-radius: 6px;

    outline: none;

    background: #0f172a;

    color: #f1f5f9;
}


.modal-body input:focus {

    border-color: #3b82f6;
}


.modal-help {

    margin: 9px 0 0;

    color: #94a3b8;

    font-size: 12px;

    line-height: 1.5;
}


.modal-footer {

    display: flex;

    justify-content: flex-end;

    gap: 8px;

    padding: 14px 18px;

    border-top: 1px solid #263247;
}


.secondary-button,
.primary-button {

    height: 36px;

    padding: 0 14px;

    border-radius: 6px;

    cursor: pointer;

    font-size: 13px;

    font-weight: 600;
}


.secondary-button {

    border: 1px solid #334155;

    background: #111c31;

    color: #cbd5e1;
}


.secondary-button:hover {

    background: #172338;
}


.primary-button {

    border: 0;

    background: #2563eb;

    color: #ffffff;
}


.primary-button:hover {

    background: #3b82f6;
}


/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 800px) {


    .platform-header {

        height: 54px;

        padding: 0 12px;
    }


    .platform-header h1 {

        font-size: 15px;
    }


    .platform-nav {

        gap: 10px;

        overflow-x: auto;
    }


    .platform-nav a {

        font-size: 11px;
    }


    .sandbox-layout {

        height: calc(100vh - 54px);
    }


    .mobile-sidebar-button {

        display: block;

        margin-right: 8px;
    }


    .database-sidebar {

        position: fixed;

        left: 0;

        top: 54px;

        bottom: 0;

        z-index: 500;

        transform: translateX(-100%);

        transition: transform .2s ease;

        box-shadow:
            5px 0 20px rgba(0, 0, 0, .5);
    }


    .database-sidebar.mobile-open {

        transform: translateX(0);
    }


    .close-sidebar-button {

        display: block;

        border: 0;

        background: transparent;

        color: #94a3b8;

        font-size: 22px;

        cursor: pointer;
    }


    .sandbox-info-banner {

        padding: 7px 10px;
    }


    .sandbox-info-content span {

        font-size: 10px;
    }


    .query-tab {

        min-width: 85px;

        padding: 0 12px;
    }


    .workspace-toolbar {

        padding: 0 9px;
    }


    .workspace-actions {

        gap: 4px;

        overflow-x: auto;
    }


    .toolbar-button {

        display: block;

        padding: 0 8px;
    }


    .run-query-button {

        padding: 0 9px;
    }


    .results-section.results-maximized {

        left: 0;

        top: 94px;
    }


    .results-header {

        padding-left: 9px;

        padding-right: 9px;
    }


    .download-button {

        padding: 0 8px;
    }


    .results-control-button {

        width: 27px;

        height: 27px;
    }

}


/* ============================================================
   SANDBOX OBJECT MANAGEMENT CONTROLS
   ============================================================ */

.database-header {
    position: relative;
}

.database-actions,
.table-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.database-action-button,
.table-action-button {
    border: 1px solid #334155;
    background: #111c31;
    color: #94a3b8;
    border-radius: 5px;
    cursor: pointer;
    line-height: 1;
    font-size: 11px;
    min-width: 22px;
    height: 22px;
}

.database-action-button:hover,
.table-action-button:hover {
    border-color: #60a5fa;
    color: #ffffff;
    background: #172338;
}

.table-action-button {
    min-width: 24px;
    padding: 0 5px;
}

.table-item-main {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.table-item-main > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   RESULTS DRAGGING
   ============================================================ */

.results-resize-handle {
    touch-action: none;
}

body.sandbox-resizing-results,
body.sandbox-resizing-results * {
    cursor: ns-resize !important;
    user-select: none !important;
}

/* ============================================================
   DYNAMIC TABLE / DATA MODALS
   ============================================================ */

.sandbox-ui-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(2, 6, 23, .74);
}

.sandbox-ui-modal {
    width: min(760px, 96vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #111c31;
    border: 1px solid #334155;
    border-radius: 10px;
    box-shadow: 0 22px 60px rgba(0,0,0,.55);
}

.sandbox-ui-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 13px 16px;
    border-bottom: 1px solid #263247;
}

.sandbox-ui-modal-header h2 {
    margin: 0;
    color: #f1f5f9;
    font-size: 15px;
}

.sandbox-ui-modal-header span {
    display: block;
    margin-top: 3px;
    color: #94a3b8;
    font-size: 11px;
}

.sandbox-ui-modal-close {
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 22px;
    cursor: pointer;
}

.sandbox-ui-modal-close:hover {
    color: #ffffff;
}

.sandbox-ui-modal-body {
    padding: 16px;
    overflow: auto;
}

.sandbox-ui-modal-body label {
    display: block;
    margin: 0 0 6px;
    color: #cbd5e1;
    font-size: 12px;
    font-weight: 600;
}

.sandbox-ui-modal-body label span {
    color: #64748b;
    font-weight: 400;
}

.sandbox-ui-input,
.sandbox-ui-textarea {
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #0b1120;
    color: #e2e8f0;
    padding: 9px 10px;
    font: 12px/1.45 monospace;
    outline: none;
}

.sandbox-ui-input:focus,
.sandbox-ui-textarea:focus {
    border-color: #3b82f6;
}

.sandbox-ui-help {
    margin: 4px 0 14px;
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.45;
}

.sandbox-ui-footer,
.sandbox-data-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.sandbox-data-toolbar {
    justify-content: flex-start;
    margin-top: 0;
    margin-bottom: 10px;
}

.sandbox-ui-primary,
.sandbox-ui-secondary {
    height: 32px;
    padding: 0 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.sandbox-ui-primary {
    border: 1px solid #3b82f6;
    background: #2563eb;
    color: #ffffff;
}

.sandbox-ui-primary:hover {
    background: #1d4ed8;
}

.sandbox-ui-secondary {
    border: 1px solid #475569;
    background: #111c31;
    color: #cbd5e1;
}

.sandbox-ui-secondary:hover {
    background: #172338;
}

.sandbox-data-grid-wrap {
    max-height: 55vh;
    overflow: auto;
    border: 1px solid #263247;
    border-radius: 7px;
}

.sandbox-data-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.sandbox-data-grid th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 7px 8px;
    background: #172338;
    color: #cbd5e1;
    border-bottom: 1px solid #334155;
    text-align: left;
    white-space: nowrap;
}

.sandbox-data-grid td {
    padding: 5px 7px;
    border-bottom: 1px solid #1e293b;
    color: #cbd5e1;
    vertical-align: middle;
}

.sandbox-cell-input {
    min-width: 100px;
    width: 100%;
    box-sizing: border-box;
    padding: 5px 6px;
    border: 1px solid #334155;
    border-radius: 4px;
    background: #0b1120;
    color: #e2e8f0;
    font: 11px monospace;
}

.sandbox-delete-row {
    width: 25px;
    height: 25px;
    border: 1px solid #7f1d1d;
    border-radius: 5px;
    background: #450a0a;
    color: #fecaca;
    cursor: pointer;
}

.sandbox-delete-row:hover {
    background: #7f1d1d;
}

@media (max-width: 700px) {
    .database-actions,
    .table-actions {
        gap: 2px;
    }

    .sandbox-ui-modal-overlay {
        padding: 8px;
    }

    .sandbox-ui-modal {
        width: 100%;
        max-height: 94vh;
    }
}

/* ============================================================
   PLATFORM HEADER — FINAL BRANDING
   ------------------------------------------------------------
   Matches the SQL Learning Platform identity used on Home,
   Tutorial and the corrected Playground header.

   Existing Sandbox editor, database explorer, SQL execution,
   results, modals and responsive behaviour are untouched.
   ============================================================ */

body > .platform-header {
    width: 100%;
    height: 72px;
    min-height: 72px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 24px;
    padding: 0 5vw;

    box-sizing: border-box;

    background: rgba(7, 17, 31, 0.96);
    border-bottom: 1px solid rgba(120, 170, 230, 0.18);

    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1000;

    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

/* Remove the old text-only header styling from affecting the brand. */
body > .platform-header > .platform-brand-link {
    display: inline-flex !important;
    align-items: center;
    gap: 10px;

    flex: 0 0 auto;

    color: #edf5ff !important;
    text-decoration: none !important;

    border-radius: 14px;
    line-height: 1;
    white-space: nowrap;

    transition:
        transform 0.2s ease,
        opacity 0.2s ease;
}

body > .platform-header > .platform-brand-link:hover {
    transform: translateY(-1px);
    opacity: 0.96;
}

body > .platform-header > .platform-brand-link:focus-visible {
    outline: 2px solid #55c2ff;
    outline-offset: 4px;
}

/* Same SQL square scale as the Tutorial/Playground branding. */
body > .platform-header .platform-brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;

    display: grid !important;
    place-items: center;

    margin: 0;
    padding: 0;

    border-radius: 12px;

    background: linear-gradient(
        135deg,
        #35a7ff,
        #7773ff
    ) !important;

    color: #04101e !important;

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    font-size: 13px !important;
    font-weight: 900 !important;
    line-height: 1 !important;

    box-shadow:
        0 8px 22px rgba(53, 167, 255, 0.18);
}

body > .platform-header .platform-brand-text {
    display: block;
    margin: 0;
    padding: 0;
    line-height: 1.1;
}

body > .platform-header .platform-brand-text strong {
    display: block;

    margin: 0;
    padding: 0;

    color: #edf5ff !important;

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    font-size: 16px !important;
    font-weight: 800 !important;
    letter-spacing: -0.01em;
    line-height: 1.1;

    text-decoration: none !important;
}

body > .platform-header .platform-brand-text small {
    display: block;

    margin: 4px 0 0;
    padding: 0;

    color: #9eb1c8 !important;

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.12em;
    line-height: 1;

    text-transform: uppercase;
}

/* Keep Sandbox navigation visually consistent. */
body > .platform-header > .platform-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    flex-wrap: wrap;
    gap: 20px;

    height: auto;
    min-width: 0;
}

body > .platform-header > .platform-nav > a {
    height: auto;

    display: inline-flex;
    align-items: center;

    margin: 0;
    padding: 0;

    background: transparent !important;
    border: 0;

    color: #9eb1c8 !important;

    font-size: 14px !important;
    font-weight: 500;
    line-height: 1.4;

    text-decoration: none !important;
    white-space: nowrap;

    transition:
        color 0.2s ease,
        transform 0.2s ease;
}

body > .platform-header > .platform-nav > a:hover {
    background: transparent !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}

body > .platform-header > .platform-nav > a[aria-current="page"] {
    background: transparent !important;
    color: #ffffff !important;
    font-weight: 700;
}

body > .platform-header > .platform-nav > a:focus-visible {
    outline: 2px solid #55c2ff;
    outline-offset: 4px;
    border-radius: 4px;
}

/* The main Sandbox height follows the new 72px header. */
body > .sandbox-layout {
    height: calc(100vh - 72px);
}

/* Mobile-only hamburger: hidden on desktop so the original desktop
   logo/navigation positioning remains unchanged. */
body > .platform-header > .mobile-nav-button {
    display: none !important;
}

/* Mobile header. */
@media (max-width: 760px) {
    body > .platform-header {
        height: auto;
        min-height: auto;

        align-items: flex-start;
        flex-wrap: wrap;

        padding: 12px 4vw;
        gap: 10px 18px;
    }

    body > .platform-header .platform-brand-mark {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    body > .platform-header .platform-brand-text strong {
        font-size: 15px !important;
    }

    body > .platform-header > .platform-nav {
        width: 100%;
        justify-content: flex-start;
        gap: 8px 16px;

        overflow-x: auto;
        overflow-y: hidden;
    }

    body > .platform-header > .platform-nav > a {
        font-size: 13px !important;
    }

    body > .sandbox-layout {
        height: calc(100vh - 122px);
    }
}

@media (max-width: 480px) {
    body > .platform-header > .platform-nav {
        gap: 7px 13px;
    }

    body > .platform-header > .platform-nav > a {
        font-size: 12px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body > .platform-header > .platform-brand-link,
    body > .platform-header > .platform-nav > a {
        transition: none;
    }
}



/* ============================================================
   RESPONSIVE RUN QUERY BUTTON — MOBILE ONLY
   ------------------------------------------------------------
   Desktop keeps the existing worksheet-toolbar button exactly as-is.
   Mobile moves that same button below the SQL editor so it cannot
   collide with Describe / Schema / Relationships.
   ============================================================ */

.sandbox-editor-actions {
    display: none;
}

@media (max-width: 760px) {

    /* The button is physically moved here by sandbox.js. */
    .sandbox-editor-actions {
        display: flex;
        width: 100%;
        box-sizing: border-box;
        justify-content: flex-start;
        align-items: center;
        margin-top: 16px;
        padding: 0;
        flex: 0 0 auto;
    }

    .sandbox-editor-actions .run-query-button {
        width: 100%;
        min-width: 0;
        min-height: 48px;
        height: 48px;
        padding: 10px 18px;
        box-sizing: border-box;
        border-radius: 8px;
        font-size: 16px;
        font-weight: 700;

        /* Match Playground mobile Run Query button exactly:
           keep the button full-width and center its label. */
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    /* Prevent the desktop toolbar copy from occupying mobile space. */
    .workspace-actions > .run-query-button {
        display: none !important;
    }

    /* Let the document grow naturally so the new footer is reachable. */
    html,
    body {
        height: auto !important;
        min-height: 100% !important;
    }

    body {
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    body > .sandbox-layout {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .sandbox-workspace {
        min-height: 0 !important;
        overflow: visible !important;
    }

    .sql-editor-section {
        flex: 0 0 auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .editor-wrapper {
        height: 360px !important;
        min-height: 300px !important;
        flex: 0 0 360px !important;
    }
}

@media (max-width: 420px) {
    .editor-wrapper {
        height: 340px !important;
        min-height: 280px !important;
        flex-basis: 340px !important;
    }
}


/* ============================================================
   SANDBOX PAGE SCROLL — DESKTOP + MOBILE
   ------------------------------------------------------------
   Keep the existing workspace dimensions/logic, but allow the page
   itself to scroll so the footer remains reachable after the main
   workspace.
   ============================================================ */

html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    overflow-y: auto;
}


/* ============================================================
   SANDBOX FOOTER — SAME AS LOCKED PLAYGROUND FOOTER
   ============================================================ */

.challenge-site-footer {
    width: 100%;
    box-sizing: border-box;
    margin-top: 40px;
    padding: 32px 5vw 28px;

    background: #07111f;
    border-top: 1px solid rgba(120, 170, 230, 0.18);
    flex: 0 0 auto;
}

.challenge-footer-inner {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    align-items: start;
    gap: 36px;
}

.challenge-footer-brand a {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #edf5ff;
    text-decoration: none;
}

.challenge-footer-brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, #35a7ff, #7773ff);
    color: #04101e;
    font-size: 13px;
    font-weight: 900;
    box-shadow: 0 8px 22px rgba(53, 167, 255, 0.18);
}

.challenge-footer-brand strong {
    display: block;
    color: #ffffff;
    font-size: 16px;
    line-height: 1.2;
}

.challenge-footer-brand small {
    display: block;
    margin: 6px 0;
    color: #9eb1c8;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

.challenge-footer-links {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 10px 22px;
    text-align: center;
}

.challenge-footer-links a {
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    transition: color .2s ease, transform .2s ease;
}

.challenge-footer-links a:hover,
.challenge-footer-links a[aria-current="page"] {
    color: #ffffff;
    transform: translateX(2px);
}

.challenge-footer-copy {
    color: #9eb1c8;
    font-size: 13px;
    line-height: 1.6;
}

.challenge-footer-copy p {
    margin: 0 0 8px;
}

@media (max-width: 760px) {
    .challenge-site-footer {
        margin-top: 32px;
        padding: 28px 18px 24px;
    }

    .challenge-footer-inner {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .challenge-footer-links {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 10px 18px;
        text-align: center;
    }

    .challenge-footer-copy {
        padding-top: 4px;
    }
}

/* Keep the footer reachable when the page content is short. */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body > .sandbox-layout {
    flex: 0 0 auto;
}

body > .challenge-site-footer {
    margin-top: 40px;
}

@media (max-width: 760px) {
    body > .challenge-site-footer {
        margin-top: 32px;
    }
}


/* ============================================================
   PLAYGROUND-STYLE SQL EDITOR CARD — SANDBOX
   ------------------------------------------------------------
   Visual-only styling. The existing #sql-editor textarea and
   Run Query button are preserved, so Sandbox logic is unchanged.
   ============================================================ */

.sandbox-editor-panel {
    width: calc(100% - 36px);
    margin: 18px auto;
    padding: 18px;
    box-sizing: border-box;
    flex: 0 0 auto;
    background: #1e293b;
    border-radius: 12px;
}

.sandbox-editor-panel h3 {
    margin: 0 0 14px;
    color: #f8fafc;
    font-size: 1.15rem;
    line-height: 1.35;
}

.sandbox-editor-panel .editor-wrapper {
    width: 100%;
    height: 500px;
    min-height: 500px;
    flex: 0 0 500px;
    box-sizing: border-box;
    overflow: hidden;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 0;
}

.sandbox-editor-panel .sql-editor {
    width: 100%;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
    padding: 15px;
    border: 0;
    border-radius: 10px;
    background: #0f172a;
    color: #ffffff;
    font-size: 16px;
    line-height: 1.5;
    resize: none;
}

.sandbox-editor-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: 16px;
}

.sandbox-editor-actions .run-query-button {
    width: auto;
    min-width: 140px;
    min-height: 48px;
    height: 48px;
    padding: 10px 18px;
    box-sizing: border-box;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
}

@media (max-width: 760px) {
    .sandbox-editor-panel {
        width: calc(100% - 24px);
        margin: 18px 12px;
        padding: 18px;
        border-radius: 12px;
    }

    .sandbox-editor-panel h3 {
        font-size: 1.25rem;
        line-height: 1.35;
        margin-bottom: 14px;
    }

    .sandbox-editor-panel .editor-wrapper {
        height: 360px;
        min-height: 300px;
        flex: 0 0 360px;
        border-radius: 10px;
    }

    .sandbox-editor-panel .sql-editor {
        min-height: 0;
        padding: 14px;
        font-size: 16px;
        line-height: 1.5;
        border-radius: 10px;
    }

    .sandbox-editor-actions {
        margin-top: 16px;
    }

    .sandbox-editor-actions .run-query-button {
        width: 100%;
        min-width: 0;
        min-height: 48px;
        height: 48px;
        font-size: 16px;
    }
}

@media (max-width: 420px) {
    .sandbox-editor-panel {
        width: calc(100% - 20px);
        margin-left: 10px;
        margin-right: 10px;
        padding: 15px;
    }

    .sandbox-editor-panel .editor-wrapper {
        height: 340px;
        min-height: 280px;
        flex-basis: 340px;
    }
}

/* ============================================================
   MOBILE DATABASE EXPLORER BUTTON
   ------------------------------------------------------------
   sandbox.js already listens for #mobile-sidebar-button and
   opens the existing #database-sidebar. This is presentation
   only; database/table rendering remains untouched.
   ============================================================ */

.mobile-sidebar-button {
    display: none;
}

@media (max-width: 760px) {
    #query-tabs-container .mobile-sidebar-button {
        position: absolute;
        top: -44px;
        left: 12px;
        width: 44px;
        height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        border: 1px solid #334155;
        border-radius: 9px;
        background: #0f1b2e;
        color: #9eb1c8;
        font-size: 17px;
        line-height: 1;
        cursor: pointer;
        z-index: 1004;
    }

    #query-tabs-container .mobile-sidebar-button:hover {
        background: #172033;
        color: #ffffff;
        border-color: #475569;
    }

    .database-sidebar {
        z-index: 1005;
    }
}

/* ============================================================
   DESKTOP WORKSPACE SCROLL
   ------------------------------------------------------------
   The Sandbox workspace contains the large SQL editor card.
   Desktop gets its own vertical scrollbar so the full editor
   border can always be reached without changing the mobile UI.
   ============================================================ */
@media (min-width: 761px) {
    .sandbox-workspace {
        overflow-x: hidden;
        overflow-y: auto;
    }
}


/* ============================================================
   FINAL TARGETED FIXES
   1. Mobile Database Explorer button placement
   2. Desktop complete editor/workspace scrolling
   3. Mobile Playground-style hamburger
   ============================================================ */

@media (max-width: 760px) {

    /* Keep Database Explorer button inside the Query 1 bar,
       away from the blue Sandbox information icon/background. */
    #query-tabs-container {
        min-height: 40px;
        height: 40px;
        position: relative;
    }

    #query-tabs-container .mobile-sidebar-button {
        position: absolute;
        top: 2px;
        left: 12px;

        width: 44px;
        height: 36px;

        display: inline-flex;
        align-items: center;
        justify-content: center;

        margin: 0;
        padding: 0;

        border: 1px solid #334155;
        border-radius: 9px;

        background: #0f1b2e;
        color: #9eb1c8;

        font-size: 17px;
        line-height: 1;
        cursor: pointer;
        z-index: 1004;
    }

    #query-tabs-container .mobile-sidebar-button:hover {
        background: #172033;
        color: #ffffff;
        border-color: #475569;
    }

    /* Give Query 1 its own space beside the explorer button. */
    #query-tabs-container .query-tabs {
        padding-left: 68px;
        box-sizing: border-box;
    }

    /* Playground-style hamburger: left of the SQL logo. */
    body > .platform-header {
        position: sticky;
        top: 0;

        min-height: 112px;
        height: 112px;

        display: flex;
        align-items: flex-start;
        justify-content: flex-start;
        flex-wrap: nowrap;

        padding: 12px 12px 12px 66px;
        gap: 10px;

        z-index: 1000;
    }

    body > .platform-header > .mobile-nav-button {
        position: absolute;
        top: 12px;
        left: 12px;

        width: 44px;
        height: 44px;

        display: inline-flex;
        align-items: center;
        justify-content: center;

        padding: 0;

        border: 1px solid #334155;
        border-radius: 12px;

        background: #0f1b2e;
        color: #e2e8f0;

        font-size: 24px;
        line-height: 1;
        cursor: pointer;
        z-index: 1003;
    }

    body > .platform-header > .mobile-nav-button:hover {
        background: #172033;
        border-color: #475569;
    }

    body > .platform-header > .platform-brand-link {
        flex: 0 0 auto;
        margin: 0;
    }

    body > .platform-header .platform-brand-mark {
        width: 48px;
        height: 48px;
        flex-basis: 48px;
    }

    body > .platform-header .platform-brand-text strong {
        font-size: 16px !important;
    }

    /* Mobile navigation is hidden until hamburger is tapped. */
    body > .platform-header > .platform-nav {
        display: none;

        position: absolute;
        top: 100%;
        left: 0;
        right: 0;

        width: 100%;

        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;

        gap: 0;
        padding: 10px 14px 14px;
        box-sizing: border-box;

        background: rgba(7, 17, 31, 0.98);
        border-top: 1px solid rgba(120, 170, 230, 0.12);
        border-bottom: 1px solid rgba(120, 170, 230, 0.18);

        box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);

        overflow: visible;
        z-index: 1002;
    }

    body > .platform-header.mobile-nav-open > .platform-nav {
        display: flex;
    }

    body > .platform-header > .platform-nav > a {
        width: 100%;
        min-height: 40px;

        display: flex;
        align-items: center;

        padding: 8px 10px;

        font-size: 14px !important;
        white-space: nowrap;
    }
}

/* Desktop only: make the whole Sandbox workspace scrollable so
   the complete SQL editor card and results can be reached. */
@media (min-width: 761px) {

    .sandbox-workspace {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        min-height: 0;
    }

    .sql-editor-section {
        flex: 0 0 auto !important;
        min-height: max-content !important;
        overflow: visible !important;
    }

    .sandbox-editor-panel {
        flex: 0 0 auto;
    }

    .sandbox-editor-panel .editor-wrapper {
        flex: 0 0 500px;
    }
}


/* ============================================================
   MOBILE PLATFORM NAVIGATION — FINAL TOGGLE FIX
   ------------------------------------------------------------
   Desktop: hamburger stays hidden.
   Mobile: navigation remains hidden until the hamburger is tapped.
   This does not affect Sandbox/database/query/result logic.
   ============================================================ */
@media (max-width: 760px) {

    body > .platform-header > .mobile-nav-button {
        display: inline-flex !important;
    }

    body > .platform-header > .platform-nav {
        display: none !important;

        position: absolute;
        top: 100%;
        left: 0;
        right: 0;

        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;

        gap: 0;
        padding: 10px 14px 14px;
        box-sizing: border-box;

        background: rgba(7, 17, 31, 0.98);
        border-top: 1px solid rgba(120, 170, 230, 0.12);
        border-bottom: 1px solid rgba(120, 170, 230, 0.18);

        box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
        overflow: visible;
        z-index: 1002;
    }

    body > .platform-header.mobile-nav-open > .platform-nav {
        display: flex !important;
    }

    /* When the platform navbar is open, keep the separate
       Database Explorer button out of the navigation overlay.
       The button remains available when the navbar is closed. */
    body > .platform-header.mobile-nav-open
        + .sandbox-layout
        #mobile-sidebar-button {
        display: none !important;
        pointer-events: none !important;
    }

    body > .platform-header > .platform-nav > a {
        width: 100%;
        min-height: 40px;
        display: flex;
        align-items: center;
        padding: 8px 10px;
        font-size: 14px !important;
        white-space: nowrap;
    }
}


/* ============================================================
   FINAL MOBILE SANDBOX HEADER / FOOTER ALIGNMENT FIX
   ------------------------------------------------------------
   IMPORTANT:
   - Sandbox content, editor, database explorer, results and footer
     design are otherwise unchanged.
   - Mobile header follows the same dimensions/positioning as the
     working Tutorial mobile header.
   - Footer links stay on one horizontal row like Tutorial.
   - Navigation overlay remains full viewport width.
   ============================================================ */
@media (max-width: 760px) {

    /* Exact Tutorial-style mobile header geometry. */
    body > .platform-header {
        width: 100vw !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        min-height: 64px !important;
        height: 64px !important;

        display: grid !important;
        grid-template-columns: 44px minmax(0, max-content) 1fr !important;
        grid-template-rows: 44px !important;

        align-items: center !important;
        justify-content: start !important;
        flex-wrap: nowrap !important;

        gap: 10px !important;
        padding: 10px 12px !important;
        box-sizing: border-box !important;
    }

    /* Same left-of-logo hamburger size and position as Tutorial. */
    body > .platform-header > .mobile-nav-button {
        position: static !important;
        grid-column: 1 !important;
        grid-row: 1 !important;

        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;

        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;

        margin: 0 !important;
        padding: 0 !important;
        border: 1px solid #334155 !important;
        border-radius: 12px !important;
        background: #0f1b2e !important;
        color: #e2e8f0 !important;

        font-size: 24px !important;
        line-height: 1 !important;
        z-index: 2003 !important;
    }

    /* Keep the existing Sandbox logo/branding, but place it exactly
       beside the hamburger like the Tutorial page. */
    body > .platform-header > .platform-brand-link {
        grid-column: 2 / 4 !important;
        grid-row: 1 !important;

        width: max-content !important;
        max-width: calc(100vw - 70px) !important;
        margin: 0 !important;
        justify-self: start !important;
        align-self: center !important;
    }

    /* Tutorial uses the 48px mobile SQL mark. */
    body > .platform-header .platform-brand-mark {
        width: 48px !important;
        height: 48px !important;
        flex-basis: 48px !important;
    }

    body > .platform-header .platform-brand-text strong {
        font-size: 16px !important;
    }

    /* Full-width Tutorial-style mobile navigation overlay. */
    body > .platform-header > .platform-nav {
        display: none !important;

        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;

        width: 100vw !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;

        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 0 !important;

        padding: 10px 14px 14px !important;
        background: rgba(7, 17, 31, 0.98) !important;
        border-top: 1px solid rgba(120, 170, 230, 0.12) !important;
        border-bottom: 1px solid rgba(120, 170, 230, 0.18) !important;
        box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35) !important;
        overflow: visible !important;
        z-index: 2002 !important;
    }

    body > .platform-header.mobile-nav-open > .platform-nav {
        display: flex !important;
    }

    body > .platform-header > .platform-nav > a {
        width: 100% !important;
        min-height: 44px !important;
        box-sizing: border-box !important;

        display: flex !important;
        align-items: center !important;

        padding: 8px 10px !important;
        border-radius: 8px !important;
        font-size: 14px !important;
        white-space: nowrap !important;
    }

}

@media (max-width: 420px) {
    /* Same compact edge spacing used by the Tutorial mobile header. */
    body > .platform-header {
        grid-template-columns: 40px minmax(0, max-content) 1fr !important;
        gap: 10px !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    body > .platform-header > .mobile-nav-button {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
    }

    body > .platform-header .platform-brand-mark {
        width: 40px !important;
        height: 40px !important;
        flex-basis: 40px !important;
    }
}


/* ============================================================
   FINAL SANDBOX FOOTER FIX — FOOTER ONLY
   ------------------------------------------------------------
   The Sandbox workspace, SQL editor, query controls and all
   existing functionality remain unchanged.

   Desktop:
   - balanced brand / navigation / copyright columns
   - navigation wraps instead of overflowing
   - copyright remains readable and aligned

   Mobile:
   - footer links wrap into clean multiple rows
   - no horizontal footer scrolling
   ============================================================ */

@media (min-width: 761px) {

    .challenge-site-footer .challenge-footer-inner {
        grid-template-columns:
            minmax(220px, 1.15fr)
            minmax(320px, 1.7fr)
            minmax(220px, 0.95fr);
        align-items: start;
        gap: 28px;
    }

    .challenge-site-footer .challenge-footer-links {
        flex-wrap: wrap;
        justify-content: center;
        align-content: flex-start;
        row-gap: 10px;
        column-gap: 20px;
        min-width: 0;
        line-height: 1.4;
        white-space: normal;
    }

    .challenge-site-footer .challenge-footer-links a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .challenge-site-footer .challenge-footer-copy {
        min-width: 0;
        text-align: right;
    }
}

@media (max-width: 760px) {

    .challenge-site-footer .challenge-footer-links {
        width: 100%;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        align-content: center;
        gap: 10px 18px;
        overflow: visible;
        white-space: normal;
        text-align: center;
    }

    .challenge-site-footer .challenge-footer-links a {
        flex: 0 0 auto;
        white-space: normal;
    }

    .challenge-site-footer .challenge-footer-copy {
        text-align: center;
    }
}
