:root {
    --dark-bg: #1e1e1e;
    --med-bg: #252526;
    --light-bg: #333333;
    --text: #cccccc;
    --text-dark: #888888;
    --primary: #0e639c;
    --primary-hover: #157bbf;
    --border: #3a3a3a;
    --footer-height: 56px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--dark-bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.admin-dashboard {
    background: radial-gradient(circle at 10% 20%, rgba(14, 99, 156, 0.12), transparent 30%),
        radial-gradient(circle at 80% 10%, rgba(21, 123, 191, 0.12), transparent 30%),
        var(--dark-bg);
    color: var(--text);
    min-height: 100vh;
}

.admin-shell {
    max-width: 1200px;
    margin: 32px auto 48px auto;
    padding: 0 24px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    height: 44px;
    width: auto;
}

.admin-header h1 {
    margin: 0;
    font-size: 1.6rem;
    color: #fff;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 30px;
}

.muted {
    color: var(--text-dark);
    font-size: 0.95rem;
}

.top-actions {
    display: flex;
    gap: 14px;
    align-items: center;
}

.primary-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: rgba(14, 99, 156, 0.1);
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.primary-link:hover {
    background: var(--primary);
    color: #fff;
}

.admin-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.admin-panel {
    background: linear-gradient(145deg, #1f1f1f, #1a1a1a);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
}

.admin-card {
    background: linear-gradient(145deg, #1f1f1f, #1a1a1a);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.admin-card h3 {
    margin: 0;
    font-size: 1rem;
    color: #f5f5f5;
    letter-spacing: 0.2px;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.metric {
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    margin: 4px 0;
}

.pill {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.pill.ok {
    background: rgba(14, 99, 156, 0.15);
    color: var(--primary);
    border-color: rgba(14, 99, 156, 0.7);
}

.pill.warn {
    background: rgba(255, 107, 107, 0.12);
    color: #ff6b6b;
    border-color: rgba(255, 107, 107, 0.6);
}

.panel-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 4px;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--border);
    padding: 10px 8px;
    text-align: left;
    font-size: 0.95rem;
}

.admin-table th {
    color: #f5f5f5;
    font-weight: 700;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.alert-banner {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid rgba(255, 107, 107, 0.4);
    background: rgba(255, 107, 107, 0.12);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.alert-banner.warn strong {
    color: #ff8f8f;
}

.ban-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    margin-bottom: 12px;
}

.ban-form input {
    background: #131313;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    color: #f5f5f5;
    min-width: 0;
}

.ban-form button {
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    padding: 10px 14px;
    border: 1px solid var(--primary);
    cursor: pointer;
}

.ban-form button:hover {
    background: var(--primary-hover);
}

.inline-form {
    display: inline;
}

.ghost-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: #f5f5f5;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}

.ghost-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.list-header h4 {
    margin: 0;
    color: #f5f5f5;
}

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

    .ban-form {
        grid-template-columns: 1fr;
    }

    .ban-form button {
        width: 100%;
    }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background-color: var(--med-bg);
    border-bottom: 1px solid var(--border);
    height: 65px;
}

.brand-cluster {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-shrink: 0;
}

.logo {
    height: 50px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

.tier-hover-card {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 28px;
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: default;
    outline: none;
    white-space: nowrap;
}

.tier-hover-card:hover,
.tier-hover-card:focus-visible {
    border-color: rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.07);
}

.tier-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #9aa0a6;
    box-shadow: 0 0 10px rgba(154, 160, 166, 0.45);
}

.tier-free .tier-dot {
    background: #7aa7ff;
    box-shadow: 0 0 10px rgba(122, 167, 255, 0.45);
}

.tier-plus .tier-dot {
    background: #18c88a;
    box-shadow: 0 0 12px rgba(24, 200, 138, 0.5);
}

.tier-pro .tier-dot {
    background: #f5c542;
    box-shadow: 0 0 12px rgba(245, 197, 66, 0.55);
}

.tier-limit-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 320px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: #242424;
    color: var(--text);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 1100;
}

.tier-hover-card:hover .tier-limit-tooltip,
.tier-hover-card:focus-within .tier-limit-tooltip,
.tier-hover-card:focus-visible .tier-limit-tooltip {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.tier-tooltip-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tier-tooltip-head strong {
    color: #fff;
    font-size: 0.98rem;
}

.tier-tooltip-head span {
    color: var(--text-dark);
    font-size: 0.78rem;
    font-weight: 700;
}

.tier-tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 5px 0;
    color: var(--text-dark);
    font-weight: 600;
}

.tier-tooltip-row strong {
    color: var(--text);
    text-align: right;
    font-weight: 800;
}

.controls {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.queue-badge {
    margin-left: 10px;
    padding: 4px 10px;
    border-radius: 12px;
    background: #2d2d2d;
    color: var(--text);
    font-size: 0.8rem;
    border: 1px solid var(--border);
    min-width: 80px;
    text-align: center;
}

.queue-badge.hidden {
    display: none;
}

/* This adds consistent 8px space to all DIRECT children buttons */
.controls>button,
.controls>.user-menu-container {
    margin-left: 8px;
}

.header-credit {
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    /* 12px */
    color: var(--text-dark);
    white-space: nowrap;
    text-align: center;
    margin: 0 10px;
}

/* --- BUTTON STYLES --- */
button {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    border: none;
    border-radius: 5px;
    padding: 8px 14px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#run-btn {
    background-color: var(--primary);
    color: white;
}

#run-btn:hover {
    background-color: var(--primary-hover);
}

#run-btn:disabled {
    background-color: var(--light-bg);
    cursor: not-allowed;
}

/* --- ICON BUTTONS --- */
.icon-btn {
    padding: 6px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lottie-icon {
    width: 28px;
    height: 28px;
    pointer-events: none;
    /* Invert colors for Lottie if needed, but usually better to edit JSON or use filter on container */
    filter: invert(1) brightness(2);
}

.svg-icon {
    width: 24px;
    height: 24px;
    filter: invert(1) brightness(2);
    /* Make black SVG white */
}

.svg-icon-small {
    width: 18px;
    height: 18px;
    filter: invert(1) brightness(2);
    /* Make black SVG white */
}

.icon-btn-small {
    padding: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dark);
    border-radius: 4px;
    margin-left: 8px;
    align-self: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn-small:hover {
    background-color: #444;
    color: white;
    border-color: #666;
}

#storage-btn {
    background-color: var(--light-bg);
    color: var(--text);
}

#storage-btn:hover {
    background-color: #444;
}

#user-menu-btn,
#guest-menu-btn {
    background-color: var(--light-bg);
    color: var(--text);
}

#user-menu-btn:hover,
#guest-menu-btn:hover {
    background-color: #444;
}


/* === AI BUTTON STYLE === */
#ai-btn {
    background: linear-gradient(135deg, #6200ea, #8a2be2);
    color: white;
    border: 1px solid #8a2be2;
    box-shadow: 0 0 10px rgba(138, 43, 226, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: auto;
    padding-right: 12px;
}

.ai-text {
    font-weight: 600;
    margin-left: 4px;
    font-size: 0.9rem;
}

#ai-btn:hover {
    background: linear-gradient(135deg, #7c4dff, #a157ff);
    box-shadow: 0 0 15px rgba(138, 43, 226, 0.6);
    transform: translateY(-1px);
}

#ai-btn:disabled {
    background: var(--light-bg);
    border-color: transparent;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}


/* --- AUTH BUTTON STYLES --- */
.auth-btn {
    text-decoration: none;
    background-color: var(--light-bg);
    /* Match other buttons */
    border-radius: 5px;
    transition: background-color 0.2s;
}

.auth-btn:hover {
    background-color: #444;
}

.container {
    display: flex;
    flex-grow: 1;
    height: 100%;
    /* Fix for mobile where body padding was removed */
    height: calc(100vh - 65px);
}

.editor-pane,
.output-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 50%;
}

.editor-pane {
    border-right: 1px solid var(--border);
}

.tab-header {
    display: flex;
    background-color: var(--med-bg);
    border-bottom: 1px solid var(--border);
    height: 40px;
}

.tab {
    padding: 10px 16px;
    font-size: 0.9rem;
    color: var(--text-dark);
    cursor: pointer;
    border-right: 1px solid var(--border);
}

/* Locked language tab (e.g., premium R for guests) */
.lang-tab.locked {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

.lang-tab.locked:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.lang-tab.locked .lock-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.22);
    color: var(--text-dark);
}

.lang-tab.locked .lock-icon {
    width: 12px;
    height: 12px;
}

/* Style for active language tab (C/Python) */
.lang-tab.active {
    background-color: var(--dark-bg);
    color: var(--text);
    border-top: 2px solid var(--primary);
}

/* Style for active panel tab (Output/Input) */
#output-tab.active,
#input-tab.active {
    background-color: var(--dark-bg);
    color: var(--text);
    border-top: 2px solid var(--primary);
}


#editor {
    flex-grow: 1;
    height: 100%;
}

.panel {
    display: none;
    flex-grow: 1;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    background-color: var(--dark-bg);
    color: var(--text);
}

.panel.active {
    display: block;
}

#output-pre {
    padding: 12px;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-y: auto;
}

#input-area {
    padding: 12px;
    border: none;
    outline: none;
    resize: none;
    width: 100%;
}

#terminal {
    background-color: var(--dark-bg);
    color: var(--text);
    height: 100%;
    width: 100%;
    padding: 0;
    flex: 1;
    display: flex;
}

.terminal-shell {
    flex: 1;
    height: 100%;
    display: flex;
}

.xterm {
    font-family: 'Fira Code', monospace;
    font-size: 14px;
}

/* --- POPUP STYLES --- */

#popup-modal {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--med-bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: opacity 0.3s ease, bottom 0.3s ease, background-color 0.2s, border-color 0.2s;
}

.popup-content {
    padding: 12px 20px 12px 30px;
    /* Padding for close button */
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.popup-hidden {
    opacity: 0;
    bottom: 0px;
    pointer-events: none;
}

.popup-visible {
    opacity: 1;
    bottom: 20px;
    pointer-events: auto;
}

#popup-close-btn {
    position: absolute;
    top: 2px;
    left: 8px;
    font-size: 1.5rem;
    color: var(--text-dark);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

#popup-close-btn:hover {
    color: var(--text);
}

#popup-modal.popup-error {
    background-color: #5a1d1d;
    border-color: #a02020;
}

/* --- Mobile Responsive Design --- */

@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: calc(100vh - 65px);
        overflow: hidden;
    }

    .editor-pane,
    .output-pane {
        width: 100%;
    }

    .editor-pane {
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex: 0 0 auto;
        height: 55%;
        min-height: 150px;
    }

    .output-pane {
        flex: 1 1 auto;
        min-height: 100px;
        display: flex;
        flex-direction: column;
    }

    .output-pane .tab-header {
        flex-shrink: 0;
    }

    #terminal,
    .terminal-shell {
        flex: 1;
        height: auto !important;
        min-height: 0;
    }

    /* Ensure xterm fills the terminal container */
    .terminal-shell .xterm {
        height: 100% !important;
    }

    .terminal-shell .xterm-screen {
        height: 100% !important;
    }

    #editor {
        height: 100%;
    }

    header {
        flex-direction: row;
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        gap: 8px;
    }

    .brand-cluster {
        flex: 1 1 auto;
    }

    .tier-limit-tooltip {
        width: min(320px, calc(100vw - 24px));
    }

    .controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .header-credit {
        display: none;
    }

    /* Hide button text labels to favor icons on small screens */
    #ai-btn .ai-text {
        display: none;
    }

    /* Touch targets and compact buttons */
    button,
    .auth-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
        min-height: 44px;
    }

    .icon-btn,
    .icon-btn-small {
        min-height: 44px;
    }

    /* Slightly larger terminal text for readability */
    .xterm {
        font-size: 14px;
    }
}


/* --- PRELOADER STYLES --- */

/* By default, hide it (for mobile) */
#preloader {
    display: none;
}

/* Only show on screens 769px or wider (desktop) */
@media (min-width: 769px) {
    #preloader {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: rgba(30, 30, 30, 0.5);
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
        opacity: 1;
        visibility: visible;
        transition: opacity 0.5s ease, visibility 0.5s ease;
    }

    #preloader img {
        width: 250px;
        height: auto;
        animation: pulse 1.5s ease-in-out infinite;
    }

    #preloader.preloader-hidden {
        opacity: 0;
        visibility: hidden;
    }

    @keyframes pulse {
        0% {
            transform: scale(1);
        }

        50% {
            transform: scale(1.1);
        }

        100% {
            transform: scale(1);
        }
    }
}

/* AI Modal Styles */
#ai-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.ai-modal-hidden {
    display: none !important;
}

.ai-modal-content {
    background: var(--med-bg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: 8px;
    border: 1px solid #8a2be2;
    /* Purple border */
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(138, 43, 226, 0.2);
}

.ai-header {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2d2038;
    /* Dark purple bg */
    border-radius: 8px 8px 0 0;
}

.ai-header h3 {
    margin: 0;
    color: #d8b4fe;
    font-family: 'Inter', sans-serif;
}

#ai-close-btn {
    cursor: pointer;
    font-size: 1.5rem;
    color: #aaa;
}

#ai-response-body {
    padding: 20px;
    overflow-y: auto;
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    font-size: 0.95rem;
    color: #eee;
}

/* Style the code blocks returned by AI */
#ai-response-body pre {
    background: #111;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    border: 1px solid #444;
}

/* Style inline code (like `variable`) */
#ai-response-body code {
    font-family: 'Fira Code', monospace;
    background-color: #333;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

/* Reset paragraph text */
#ai-response-body p {
    margin-bottom: 10px;
    line-height: 1.5;
}

/* === LANGUAGE STYLES (FINAL FIX) === */

/* 1. The switcher buttons themselves */
.lang-switcher {
    display: flex;
    margin-right: 16px;
    margin-left: 8px;
    /* Fix spacing */
    background-color: var(--dark-bg);
    border-radius: 5px;
}

.lang-btn {
    padding: 6px 0;
    background-color: transparent;
    color: var(--text);
    opacity: 0.6;
    font-size: 0.8rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s, background-color 0.2s;
    width: 45px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.lang-btn.active {
    background-color: var(--light-bg);
    color: var(--text);
    opacity: 1.0;
    border-radius: 5px;
}

/* 2. General Language Display Rules */
[lang="fr"] {
    display: none;
}

[lang="en"] {
    display: inline;
}

body.lang-fr-active [lang="en"] {
    display: none;
}

body.lang-fr-active [lang="fr"] {
    display: inline;
}

/* 3. Guide-specific rules */
.guide-c,
.guide-python {
    display: none;
    white-space: pre-wrap;
}

body.prog-lang-c-active .guide-c {
    display: block;
}

body.prog-lang-c-active.lang-en-active .guide-c span[lang="en"],
body.prog-lang-c-active.lang-fr-active .guide-c span[lang="fr"] {
    display: block;
    white-space: pre-wrap;
}

body.prog-lang-python-active .guide-python {
    display: block;
}

body.prog-lang-python-active.lang-en-active .guide-python span[lang="en"],
body.prog-lang-python-active.lang-fr-active .guide-python span[lang="fr"] {
    display: block;
    white-space: pre-wrap;
}

/* === AUTH PAGES STYLES === */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100%;
    background-color: var(--dark-bg);
}

.auth-box {
    background: var(--med-bg);
    padding: 40px;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.auth-lang-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
}

.auth-lang-row .lang-switcher {
    margin: 0;
}

.auth-lang-row a {
    color: var(--text-dark);
    font-size: 0.85rem;
    text-decoration: none;
}

.auth-lang-row a:hover {
    color: var(--text);
}

.auth-box h2 {
    color: white;
    margin-bottom: 20px;
    font-family: 'Inter', sans-serif;
}

.auth-box input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    background: var(--dark-bg);
    border: 1px solid var(--border);
    color: white;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
}

.auth-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-submit-btn {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.auth-submit-btn:hover {
    background-color: var(--primary-hover);
}

.auth-link {
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.auth-link a {
    color: var(--primary);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

.auth-terms-note {
    font-size: 0.8rem;
    color: var(--text-dark);
    margin: 12px 0;
    line-height: 1.4;
}

.auth-terms-note a {
    color: var(--primary);
    text-decoration: none;
}

.auth-terms-note a:hover {
    text-decoration: underline;
}

.error-msg {
    background-color: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    border: 1px solid #ff6b6b;
    font-size: 0.9rem;
}

/* --- OAUTH (SOCIAL SIGN-IN) BUTTONS --- */
.oauth-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.oauth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 11px 12px;
    margin: 6px 0;
    background: #ffffff;
    color: #1f1f1f;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.oauth-btn:hover {
    background: #f1f1f1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.oauth-btn img {
    width: 20px;
    height: 20px;
    display: block;
    flex: 0 0 auto;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-dark);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 18px 0 4px;
    gap: 10px;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.verify-trust {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 12px 0 4px;
    font-size: 0.85rem;
    color: var(--text-dark);
    text-align: left;
    cursor: pointer;
    line-height: 1.35;
}

.verify-trust input[type="checkbox"] {
    width: auto;
    margin: 2px 0 0;
    flex: 0 0 auto;
    accent-color: var(--primary);
    cursor: pointer;
}

/* --- STORAGE MODAL STYLES --- */
.modal-hidden {
    display: none;
}

#storage-modal,
#rename-modal,
#confirm-modal,
#premium-modal,
#ai-confirm-modal,
#settings-confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
}

#storage-modal.modal-hidden,
#rename-modal.modal-hidden,
#confirm-modal.modal-hidden,
#premium-modal.modal-hidden,
#ai-confirm-modal.modal-hidden,
#settings-confirm-modal.modal-hidden {
    display: none;
}

.modal-content {
    background-color: var(--med-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.storage-modal-content {
    height: min(520px, 80vh);
}

.small-modal {
    max-width: 350px;
    padding: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    color: var(--text);
}

#storage-close-btn {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-dark);
}

#storage-close-btn:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    min-height: 350px;
    /* Ensure enough height for dropdowns */
}

#storage-modal .modal-body {
    min-height: 0;
    flex: 1 1 auto;
}

#file-list-container {
    max-height: 100%;
    overflow-y: auto;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    text-align: right;
}

.storage-action-bar {
    display: flex;
    justify-content: flex-start;
    flex: 0 0 auto;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    margin-top: 0;
}

.storage-action-bar .primary-btn {
    min-height: 40px;
    font-weight: 700;
}

.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
    padding-bottom: 16px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s;
}

.file-item:hover {
    background-color: var(--light-bg);
}

.file-info {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-grow: 1;
}

.lang-icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    vertical-align: middle;
}

.file-list-icon {
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

.file-name {
    color: var(--text);
    font-family: 'Fira Code', monospace;
}

.file-actions {
    position: relative;
}

.burger-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
}

.action-menu {
    position: fixed;
    background-color: var(--med-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 2005;
    display: flex;
    flex-direction: column;
    min-width: 120px;
    max-height: min(260px, calc(100vh - 16px));
    overflow-y: auto;
}

.action-menu.hidden {
    display: none;
}

/* --- DROPDOWN MENU STYLES --- */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--med-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 100;
    min-width: 150px;
    display: none;
    flex-direction: column;
    padding: 5px 0;
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-menu form,
.dropdown-form {
    display: contents;
}

.dropdown-item {
    padding: 8px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #444;
}

.dropdown-item .lottie-icon,
.dropdown-item img,
.dropdown-item svg,
.dropdown-icon-placeholder {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.dropdown-icon-placeholder {
    display: inline-block;
}

.upgrade-icon {
    filter: brightness(0) invert(1);
}

.dropdown-logout-btn {
    width: 100%;
    border: none;
    background: transparent;
    font: inherit;
    text-align: left;
    justify-content: flex-start;
}

.dropdown-item {
    padding: 8px 16px;
    font-size: 14px;
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border);
    margin: 4px 0;
}

.action-menu button {
    text-align: left;
    background: none;
    border: none;
    padding: 8px 12px;
    color: var(--text);
    width: 100%;
    border-radius: 0;
}

.action-menu button:hover {
    background-color: var(--primary);
    color: white;
}

.action-menu button.delete-action:hover {
    background-color: #a02020;
}

.primary-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
}

/* --- SETTINGS PAGE --- */
.settings-page {
    max-width: 900px;
    margin: 30px auto;
    padding: 0 16px 40px;
}

.settings-title {
    font-size: 1.8rem;
    margin-bottom: 16px;
    text-align: center;
}

.settings-card {
    background: var(--med-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.settings-card h3 {
    margin-bottom: 8px;
}

.settings-page .primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 210px;
    max-width: 100%;
    min-height: 42px;
    padding: 0 16px;
    line-height: 1.15;
    text-align: center;
    text-decoration: none;
    font-weight: 700;
}

.settings-tier-card {
    border-color: rgba(14, 99, 156, 0.55);
    background: linear-gradient(145deg, rgba(14, 99, 156, 0.14), var(--med-bg) 44%);
}

.settings-tier-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.settings-tier-head > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.settings-tier-head .settings-meta {
    margin-bottom: 0;
}

.settings-tier-current {
    display: grid;
    gap: 2px;
    min-width: 132px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid rgba(60, 130, 246, 0.45);
    background: rgba(60, 130, 246, 0.16);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    text-align: right;
}

.settings-tier-current-label {
    color: var(--text-dark);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.settings-tier-current strong {
    color: #fff;
    font-size: clamp(1.55rem, 2vw, 2.1rem);
    line-height: 1;
}

.settings-tier-current-plus {
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.14);
}

.settings-tier-current-pro {
    border-color: rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.14);
}

.settings-tier-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.settings-upgrade-btn,
.settings-max-plan {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    text-decoration: none;
    font-weight: 700;
}

.settings-support-note {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    color: #a7f3c1;
    font-weight: 800;
}

.settings-max-plan {
    color: #a7f3c1;
    border: 1px solid rgba(34, 197, 94, 0.35);
    border-radius: 4px;
    padding: 8px 14px;
    background: rgba(34, 197, 94, 0.12);
}

.settings-tier-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.settings-tier-stat {
    display: grid;
    gap: 4px;
    background: rgba(0, 0, 0, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 12px;
    min-width: 0;
}

.settings-tier-stat-label,
.settings-tier-stat span:last-child {
    color: var(--text-dark);
    font-size: 0.82rem;
}

.settings-tier-stat strong {
    color: #fff;
    font-size: 1.05rem;
}

.settings-billing-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
}

.settings-inline-form {
    margin: 0;
}

.settings-paypal-manage {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.settings-cancel-plan {
    background-color: #8b2222;
    border-color: #8b2222;
}

.settings-billing-note {
    margin: 0;
}

.settings-meta {
    color: var(--text-dark);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.settings-actions--stack {
    flex-direction: column;
    align-items: flex-start;
}

.settings-actions--stack .settings-status,
.settings-actions--stack input[type="text"],
.settings-actions--stack input[type="email"],
.settings-actions--stack input[type="password"] {
    flex: 0 0 auto;
    width: 100%;
    max-height: none;
}

.settings-button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
}

.settings-actions input[type="text"],
.settings-actions input[type="email"],
.settings-actions input[type="password"] {
    background: var(--dark-bg);
    border: 1px solid var(--border);
    border-radius: 5px;
    max-height: 44px;
    padding: 10px;
    color: var(--text);
    min-width: 0;
    width: min(100%, 420px);
    flex: 1 1 260px;
}

.settings-actions button,
.settings-link-btn {
    min-width: 140px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.settings-link-btn {
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
}

.settings-link-btn:hover {
    background-color: #444;
    border-color: #666;
}

.settings-status {
    flex: 1 1 220px;
    min-width: 180px;
}

.api-key-row {
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 14px;
}

.api-key-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 280px;
    min-width: 0;
}

.api-key-preview {
    font-family: 'Fira Code', monospace;
    color: #9ed0ff;
}

.settings-textarea-code {
    width: 100%;
    background: #121212;
    color: #f5f5f5;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 12px;
    font-family: 'Fira Code', monospace;
}

.settings-card.danger {
    border: 1px solid #a02020;
}

.settings-danger-note {
    color: #ff8888;
    margin-bottom: 8px;
}

.settings-confirm-content {
    gap: 0;
    max-width: 540px;
}

.settings-confirm-content h4 {
    margin: 0;
    color: var(--text);
}

.settings-confirm-actions {
    justify-content: flex-end;
}

.settings-confirm-actions button {
    min-width: 170px;
    white-space: nowrap;
}

.settings-confirm-danger {
    background-color: #a02020;
    border-color: #a02020;
}

.settings-confirm-danger:hover {
    background-color: #b82a2a;
    border-color: #b82a2a;
}

@media (max-width: 720px) {
    .settings-tier-head {
        flex-direction: column;
    }

    .settings-page .primary-btn,
    .settings-inline-form {
        width: 100%;
    }

    .settings-tier-current {
        width: 100%;
        text-align: left;
    }

    .settings-tier-grid {
        grid-template-columns: 1fr;
    }

    .settings-confirm-content {
        max-width: calc(100vw - 32px);
    }

    .settings-confirm-actions {
        flex-wrap: wrap;
    }

    .settings-confirm-actions button {
        flex: 1 1 170px;
    }
}

/* --- CONNECTED ACCOUNTS (OAUTH) --- */
.connected-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.connected-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: var(--dark-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.connected-provider {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text);
}

.connected-logo {
    width: 26px;
    height: 26px;
    background: #fff;
    border-radius: 5px;
    padding: 3px;
    box-sizing: border-box;
    flex: 0 0 auto;
}

.connected-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.connected-badge {
    color: #2ecc71;
    font-size: 0.85rem;
    font-weight: 600;
}

.connected-disconnect-form {
    margin: 0;
    display: inline;
}

.connected-link-btn {
    width: auto;
    padding: 8px 18px;
    margin: 0;
}

.disconnect-btn {
    background: transparent;
    color: #ff6b6b;
    border: 1px solid #ff6b6b;
    border-radius: 4px;
    padding: 7px 14px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    transition: background-color 0.2s;
}

.disconnect-btn:hover {
    background: rgba(255, 107, 107, 0.12);
}

/* --- TRUSTED DEVICES --- */
.device-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.device-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: var(--dark-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.device-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.device-ua {
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.device-dates {
    font-size: 0.8rem;
    color: var(--text-dark);
}

.device-current-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: #2ecc71;
    border: 1px solid #2ecc71;
    border-radius: 10px;
    padding: 1px 8px;
}

.flash-messages {
    margin-bottom: 16px;
}

.flash {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.flash.success {
    background: #1f402e;
    border-color: #2f7a4c;
}

.flash.error {
    background: #402020;
    border-color: #a02020;
}

.settings-inline-note {
    font-size: 0.9rem;
    color: var(--text-dark);
}

@media (max-width: 768px) {
    .settings-actions,
    .settings-button-row,
    .api-key-row {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-actions button,
    .settings-link-btn {
        width: 100%;
        min-width: 0;
    }

    .settings-actions input[type="text"],
    .settings-actions input[type="email"],
    .settings-actions input[type="password"] {
        width: 100%;
    }

    .settings-status {
        min-width: 0;
    }
}

#new-filename-input,
#rename-input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    background-color: var(--dark-bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 4px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.loading-text,
.empty-text,
.error-text {
    text-align: center;
    color: var(--text-dark);
    margin-top: 20px;
}

.error-text {
    color: #ff6b6b;
}

/* === CONSOLE SIMULATION === */
.user-echo {
    display: inline !important;
    color: #4caf50;
    /* Terminal Green */
    font-weight: bold;
}

/* Icon Buttons for Output Pane */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dark);
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    width: 32px;
    height: 32px;
}

.icon-btn:hover {
    background-color: #444;
    color: white;
    border-color: #666;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

.output-pane .tab-header {
    justify-content: space-between;
    padding-right: 8px;
}

.output-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.controls button,
.auth-btn {
    padding: 8px 14px;
    /* Restore original padding */
    width: auto;
    /* Prevent collapsing into a square */
    min-width: 80px;
    /* Ensure text fits */
    display: inline-flex;
    /* Keep flex alignment */
    gap: 6px;
    /* Space between icon and text */
}

.lang-btn {
    width: 45px !important;
    /* Force small width */
    padding: 4px 0 !important;
    /* Reduce padding */
    font-size: 0.8rem;
    min-width: auto !important;
    /* Override the 80px min-width */
}

/* Ensure Icon Buttons (Run, Storage, User) stay square */
.controls .icon-btn {
    width: 40px !important;
    height: 40px !important;
    padding: 6px !important;
    min-width: 0 !important;
}

/* Force the AI button to be wide enough for its icon and text */
#ai-btn {
    width: auto !important;
    padding: 8px 16px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Ensure the span inside is actually visible on desktop */
#ai-btn span {
    display: inline-block;
    white-space: nowrap;
}

/* ============================================
   RESIZABLE PANELS
   ============================================ */
#resize-handle {
    width: 6px;
    background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background-color 0.2s;
    position: relative;
    z-index: 10;
}

#resize-handle:hover,
#resize-handle.dragging {
    background: var(--primary);
}

#resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 40px;
    background: var(--text-dark);
    border-radius: 1px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

#resize-handle:hover::after {
    opacity: 1;
    background: #fff;
}

/* Prevent text selection while dragging */
body.resizing {
    user-select: none;
    cursor: col-resize !important;
}

body.resizing * {
    cursor: col-resize !important;
}

/* ============================================
   FULLSCREEN MODE
   ============================================ */
body.fullscreen-mode header {
    display: none;
}

body.fullscreen-mode .container {
    height: 100vh;
}

.fullscreen-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dark);
    padding: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 8px;
    align-self: center;
}

.fullscreen-btn:hover {
    background-color: #444;
    color: white;
    border-color: #666;
}

.fullscreen-btn svg {
    width: 14px;
    height: 14px;
}

/* Exit fullscreen button (shown in fullscreen mode) */
.exit-fullscreen-btn {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 10000;
    background: var(--med-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

body.fullscreen-mode .exit-fullscreen-btn {
    display: flex;
}

.exit-fullscreen-btn:hover {
    background: var(--light-bg);
}

/* ============================================
   KEYBOARD SHORTCUTS HELP MODAL
   ============================================ */
#shortcuts-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10001;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

#shortcuts-modal.modal-hidden {
    display: none;
}

.shortcuts-content {
    background: var(--med-bg);
    width: 90%;
    max-width: 450px;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.shortcuts-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shortcuts-header h3 {
    margin: 0;
    color: var(--text);
    font-size: 1rem;
}

#shortcuts-close-btn {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-dark);
    line-height: 1;
}

#shortcuts-close-btn:hover {
    color: var(--text);
}

.shortcuts-body {
    padding: 20px;
}

.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.shortcut-row:last-child {
    border-bottom: none;
}

.shortcut-keys {
    display: flex;
    gap: 4px;
}

.shortcut-key {
    background: var(--dark-bg);
    border: 1px solid var(--border);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--text);
}

.shortcut-action {
    color: var(--text-dark);
    font-size: 0.9rem;
}

/* ============================================
   ENHANCED MOBILE RESPONSIVE
   ============================================ */
/* Medium screens (tablets) */
@media (max-width: 768px) {

    /* Vertical resize handle for stacked layout */
    #resize-handle {
        width: 100%;
        height: 8px;
        cursor: row-resize;
    }

    #resize-handle::after {
        width: 40px;
        height: 2px;
    }

    body.resizing {
        cursor: row-resize !important;
    }

    body.resizing * {
        cursor: row-resize !important;
    }

    /* Hide fullscreen button on mobile */
    .fullscreen-btn {
        display: none;
    }

    /* Adjust exit button for mobile - keep on left */
    .exit-fullscreen-btn {
        top: 5px;
        left: 5px;
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Fix tab header layout on mobile */
    .tab-header {
        flex-wrap: nowrap;
        align-items: center;
    }

    .output-pane .tab-header {
        padding-right: 4px;
        gap: 4px;
    }

    .output-controls {
        flex-shrink: 0;
    }

    .output-controls .icon-btn {
        width: 28px;
        height: 28px;
        padding: 4px;
    }

    .output-controls .icon-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* Small screens (phones) */
@media (max-width: 480px) {
    header {
        padding: 6px 8px;
        gap: 6px;
    }

    .logo {
        height: 36px;
    }

    .tier-hover-card {
        padding: 4px 8px;
        font-size: 0.72rem;
    }

    .tier-limit-tooltip {
        left: -48px;
        width: calc(100vw - 24px);
    }

    .controls {
        gap: 4px;
    }

    .controls>button,
    .controls>.user-menu-container {
        margin-left: 4px;
    }

    /* Smaller buttons on very small screens */
    .controls .icon-btn {
        width: 36px !important;
        height: 36px !important;
    }

    .lang-btn {
        width: 36px !important;
        padding: 3px 0 !important;
        font-size: 0.7rem;
    }

    /* Stack panes with less height for editor */
    .editor-pane {
        flex: 0 0 55%;
        height: 55%;
    }

    .output-pane {
        flex: 0 0 45%;
        height: 45%;
    }

    /* Smaller terminal font */
    .xterm {
        font-size: 12px;
    }

    /* Smaller tabs */
    .tab {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    /* Adjust shortcuts modal */
    .shortcuts-content {
        width: 95%;
        max-width: none;
    }

    .shortcut-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .shortcut-action {
        font-size: 0.85rem;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .logo {
        height: 30px;
    }

    .tier-hover-card {
        font-size: 0.68rem;
    }

    .controls .icon-btn {
        width: 32px !important;
        height: 32px !important;
    }

    .lang-switcher {
        margin-right: 8px;
        margin-left: 4px;
    }

    .lang-btn {
        width: 30px !important;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {

    /* Larger touch targets */
    #resize-handle {
        width: 12px;
    }

    @media (max-width: 768px) {
        #resize-handle {
            height: 12px;
            width: 100%;
        }
    }

    /* Better button feedback */
    .icon-btn:active,
    .primary-btn:active {
        transform: scale(0.95);
    }
}

/* --- NIGHTLY PRICING PAGE --- */
.nightly-pricing-body {
    min-height: 100vh;
    height: auto;
}

.nightly-pricing-page {
    width: min(1180px, calc(100% - 32px));
    margin: 30px auto 96px;
}

.nightly-pricing-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.75fr);
    gap: 18px;
    align-items: stretch;
    margin-bottom: 20px;
}

.nightly-hero-copy,
.nightly-pricing-summary,
.nightly-plan-card,
.nightly-table-wrap,
.nightly-faq-item {
    background: linear-gradient(145deg, #252526, #1f1f1f);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
}

.nightly-hero-copy {
    padding: 34px;
}

.nightly-admin-note,
.nightly-plan-label {
    color: #9ed0ff;
    font-family: 'Fira Code', monospace;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
}

.nightly-pricing-summary {
    display: grid;
    gap: 10px;
    padding: 22px;
}

.nightly-summary-item {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.16);
}

.nightly-summary-item strong {
    color: #fff;
    font-size: 1rem;
}

.nightly-summary-item span {
    color: var(--text-dark);
    line-height: 1.45;
    font-size: 0.9rem;
}

.nightly-hero-copy h1 {
    color: #fff;
    font-size: clamp(2rem, 4vw, 4.1rem);
    line-height: 1.02;
    margin: 12px 0 16px;
    max-width: 820px;
}

.nightly-hero-lede {
    color: var(--text);
    font-size: 1.02rem;
    line-height: 1.65;
    max-width: 760px;
}

.nightly-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.nightly-primary {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    border: 1px solid var(--primary);
}

.nightly-secondary {
    display: inline-flex;
    align-items: center;
    color: #d7eaff;
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.03);
}

.nightly-secondary:hover {
    border-color: var(--primary);
    color: #fff;
}

.nightly-status-panel {
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.nightly-status-top,
.nightly-plan-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.nightly-plan-name {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.nightly-status-pill {
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 700;
}

.nightly-status-pill.ready {
    color: #a7f3c1;
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
}

.nightly-status-pill.missing {
    color: #ffc0c0;
    background: rgba(255, 107, 107, 0.12);
    border-color: rgba(255, 107, 107, 0.35);
}

.nightly-status-panel p,
.nightly-note-card p {
    color: var(--text);
    line-height: 1.55;
}

.nightly-mini-grid {
    display: grid;
    gap: 8px;
    margin-top: auto;
}

.nightly-mini-grid span {
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 10px;
    background: rgba(0, 0, 0, 0.14);
    font-size: 0.9rem;
}

.nightly-section {
    margin-top: 20px;
}

.nightly-section-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: end;
    margin-bottom: 14px;
}

.nightly-section-head.compact {
    align-items: center;
}

.nightly-section-head h2 {
    color: #fff;
    font-size: 1.55rem;
}

.nightly-section-head p {
    color: var(--text-dark);
    line-height: 1.5;
    max-width: 610px;
}

.nightly-billing-toggle {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
}

.nightly-billing-toggle button {
    min-width: 88px;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    color: var(--text);
    background: transparent;
    cursor: pointer;
    font-weight: 700;
}

.nightly-billing-toggle button.active {
    color: #fff;
    background: var(--primary);
}

.nightly-plan-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.nightly-plan-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    min-height: 420px;
}

.nightly-plan-card.featured {
    border-color: rgba(60, 130, 246, 0.9);
    background: linear-gradient(145deg, rgba(14, 99, 156, 0.26), #202124 34%, #1d1d1d);
    box-shadow: 0 16px 42px rgba(14, 99, 156, 0.22), 0 12px 32px rgba(0, 0, 0, 0.32);
}

.nightly-popular-badge {
    color: #fff;
    background: var(--primary);
    border: 1px solid rgba(158, 208, 255, 0.38);
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
}

.nightly-plan-price {
    display: inline-flex;
    align-items: baseline;
    color: #fff;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.nightly-plan-price span {
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
}

.nightly-plan-copy {
    color: var(--text);
    line-height: 1.5;
    margin: 14px 0;
    min-height: 46px;
}

.nightly-feature-list {
    list-style: none;
    display: grid;
    gap: 10px;
    margin: 4px 0 20px;
}

.nightly-feature-list li {
    color: var(--text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 10px;
}

.nightly-feature-list li::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--primary-hover);
    margin-right: 10px;
    vertical-align: middle;
}

.nightly-card-action {
    margin-top: auto;
    display: grid;
    gap: 8px;
    min-height: 68px;
    align-content: start;
}

.nightly-disabled-btn,
.nightly-checkout-btn {
    width: 100%;
    min-height: 42px;
    font-weight: 700;
}

.nightly-disabled-btn {
    color: var(--text-dark);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}

.nightly-plan-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.nightly-checkout-btn:disabled {
    opacity: 0.72;
    cursor: not-allowed;
}

.nightly-paypal-wrap {
    margin-top: auto;
}

.nightly-paypal-status {
    color: var(--text-dark);
    font-size: 0.82rem;
    line-height: 1.35;
    margin: 0;
    min-height: 18px;
    text-align: center;
}

.nightly-plan-foot {
    color: var(--text-dark);
    font-size: 0.9rem;
    line-height: 18px;
    min-height: 18px;
    margin: 10px 0 0;
    text-align: center;
}

.nightly-table-wrap {
    overflow-x: auto;
}

.nightly-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

.nightly-table th,
.nightly-table td {
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
    text-align: left;
}

.nightly-table th {
    color: #9ed0ff;
    font-size: 0.9rem;
}

.nightly-table td {
    color: var(--text);
}

.nightly-table tbody tr:last-child td {
    border-bottom: none;
}

.nightly-faq {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.nightly-faq-item {
    padding: 18px;
}

.nightly-faq-item h3 {
    color: #fff;
    margin-bottom: 8px;
}

.nightly-faq-item p {
    color: var(--text);
    line-height: 1.55;
}

@media (max-width: 900px) {
    .nightly-pricing-hero,
    .nightly-plan-grid,
    .nightly-faq {
        grid-template-columns: 1fr;
    }

    .nightly-plan-card {
        min-height: 0;
    }

    .nightly-section-head {
        display: block;
    }

    .nightly-section-head p {
        margin-top: 8px;
    }
}

@media (max-width: 560px) {
    .nightly-pricing-page {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .nightly-hero-copy,
    .nightly-status-panel,
    .nightly-plan-card {
        padding: 16px;
    }

    .nightly-hero-copy h1 {
        font-size: 2rem;
    }

    .nightly-hero-actions {
        flex-direction: column;
    }

    .nightly-primary,
    .nightly-secondary {
        justify-content: center;
        width: 100%;
    }
}

/* --- LEGAL PAGES --- */
.legal-page {
    max-width: 800px;
    margin: 40px auto;
    padding: 0 20px 80px;
    line-height: 1.6;
}

.legal-header {
    margin-bottom: 32px;
    text-align: center;
}

.legal-title {
    font-size: 2.2rem;
    color: #fff;
    margin-bottom: 8px;
}

.legal-update {
    color: var(--text-dark);
    font-size: 0.9rem;
}

.legal-content {
    background: var(--med-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.legal-section {
    margin-bottom: 32px;
}

.legal-section h3 {
    color: #fff;
    margin-bottom: 12px;
    font-size: 1.4rem;
}

.legal-content p {
    margin-bottom: 16px;
    color: var(--text);
}

.legal-content ul, .legal-content ol {
    margin-bottom: 16px;
    margin-left: 24px;
}

.legal-content li {
    margin-bottom: 8px;
}

.footer-legal {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    margin-top: auto;
    background: var(--dark-bg);
    height: var(--footer-height);
    align-items: center;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
}

.legal-link {
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.1s;
}

.legal-link:hover {
    color: var(--primary);
}

@media (min-width: 769px) {
    .container {
        height: calc(100vh - 65px - var(--footer-height));
    }
}

@media (max-width: 768px) {
    .footer-legal {
        position: static;
        height: auto;
        padding: 20px;
    }
}
