:root {
    --primary-color: #4f46e5;
    --dark-bg: #1e293b;
    --darker-bg: #0f172a;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f8fafc;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 200px);
}

.playground-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-bottom: 2rem;
}

.playground-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 80vh;
    min-height: 600px;
    max-height: 80vh;
}

.resizable-container {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 500px;
    gap: 0;
    height: 100%;
    overflow: hidden;
}

.resizable-container.vertical {
    flex-direction: column;
}

.resizable-panel {
    position: relative;
    overflow: hidden;
}

.editor-panel {
    width: 50%;
    min-width: 300px;
    height: 100%;
}

.preview-panel {
    width: 50%;
    min-width: 300px;
    height: 100%;
    flex: 1;
}

.resizer {
    width: 12px;
    height: 100%;
    background: #e2e8f0;
    cursor: col-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.vertical .resizer {
    width: 100%;
    height: 12px;
    cursor: row-resize;
}

.resizer:hover {
    background: #cbd5e1;
}

.resizer-handle {
    width: 4px;
    height: 60px;
    background: #94a3b8;
    border-radius: 2px;
    transition: all 0.2s;
}

.vertical .resizer-handle {
    width: 60px;
    height: 4px;
}

.resizer:hover .resizer-handle {
    background: var(--primary-color);
    height: 80px;
}

.vertical .resizer:hover .resizer-handle {
    width: 80px;
    height: 4px;
}

.editor-container {
    background: var(--darker-bg);
    border-radius: 10px;
    height: 100%;
    display: flex;
    flex-direction: column;
    margin-right: 8px;
}

.vertical .editor-container {
    margin-right: 0;
    margin-bottom: 8px;
}

.editor-header {
    background: var(--dark-bg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #334155;
}

.editor-tab {
    padding: 6px 16px;
    border-radius: 6px 6px 0 0;
    font-size: 14px;
    cursor: pointer;
    background: #374151;
    color: #d1d5db;   /* 7.2:1 on #374151 (WCAG 2.2 AA needs 4.5) */
    transition: all 0.3s ease;
    border: none;
    font-weight: 500;
}

.editor-tab.active {
    background: var(--primary-color);
    color: white;
}

.CodeMirror {
    height: 100% !important;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.5;
}

.preview-container {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-left: 8px;
}

.vertical .preview-container {
    margin-left: 0;
}

.preview-header {
    background: #f1f5f9;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
}

.preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

.console {
    background: var(--darker-bg);
    color: #e2e8f0;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    padding: 12px 16px;
    border-top: 1px solid #334155;
    max-height: 150px;
    overflow-y: auto;
    margin-top: 8px;
    border-radius: 6px;
}

/* Settings Panel */
.settings-panel {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-panel.show {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -48%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.settings-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-content {
    padding: 20px;
}

.settings-section {
    margin-bottom: 25px;
}

.settings-section h3 {
    margin-bottom: 15px;
    color: #374151;
    font-weight: 600;
}

.settings-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
}

.settings-option:last-child {
    border-bottom: none;
}

.refresh-delay-option {
    display: none;
}

.refresh-delay-option.show {
    display: flex;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
}

.overlay.show {
    display: block;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
}

.dropdown-content {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    background-color: #1e293b;
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 5px;
}

.dropdown-content.show {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    color: #e2e8f0;
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #334155;
}

.dropdown-item:hover {
    background-color: #334155;
}

.toast {
    position: fixed;
    bottom: 100px;
    right: 30px;
    padding: 12px 20px;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.tab-content {
    display: none;
    height: 100%;
}

.tab-content.active {
    display: block;
}

.cdn-resources {
    margin-top: 15px;
}

.cdn-resource-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 6px;
}

.cdn-resource-item input {
    flex: 1;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
}

.cdn-resource-item button {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
}

.add-cdn-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 10px;
}

/* Window Control Styles */
.window-control {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.window-control:hover {
    transform: scale(1.2);
}

.window-control.red {
    background-color: #ef4444;
}

.window-control.yellow {
    background-color: #f59e0b;
}

.window-control.green {
    background-color: #10b981;
}

.window-control.red:hover {
    background-color: #dc2626;
}

.window-control.yellow:hover {
    background-color: #d97706;
}

.window-control.green:hover {
    background-color: #059669;
}

/* Fullscreen styles */
.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.fullscreen .editor-header,
.fullscreen .preview-header {
    border-radius: 0 !important;
}

/* Preview fullscreen styles */
.preview-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.preview-fullscreen .preview-header {
    border-radius: 0 !important;
}

/* Refresh animation */
.refresh-animation {
    animation: spin 0.5s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Mobile styles - Small devices (phones) */
@media (max-width: 640px) {
    .playground-container {
        height: 160vh;
        min-height: 160vh;
        max-height: 160vh;
    }

    .resizable-container {
        flex-direction: column;
        height: 100%;
    }

    .editor-panel,
    .preview-panel {
        width: 100% !important;
        min-width: 100%;
    }

    .editor-container {
        margin-right: 0;
        margin-bottom: 8px;
    }

    .preview-container {
        margin-left: 0;
    }

    .resizer {
        display: flex !important;
        width: 100%;
        height: 12px;
        cursor: row-resize;
    }

    .resizer-handle {
        width: 60px;
        height: 4px;
    }

    .resizer:hover .resizer-handle {
        width: 80px;
        height: 4px;
    }

    /* Mobile layout overrides */
    .mobile-vertical .editor-panel {
        height: 50% !important;
        min-height: 80vh !important;
    }

    .mobile-vertical .preview-panel {
        height: 50% !important;
        min-height: 80vh !important;
    }

    .mobile-preview-only .editor-panel {
        display: none !important;
    }

    .mobile-preview-only .preview-panel {
        height: 100% !important;
        min-height: 160vh !important;
    }

    .mobile-code-only .preview-panel {
        display: none !important;
    }

    .mobile-code-only .editor-panel {
        height: 100% !important;
        min-height: 160vh !important;
    }
}

/* Medium devices (tablets) */
@media (min-width: 641px) and (max-width: 768px) {
    .playground-container {
        height: 80vh;
        min-height: 80vh;
        max-height: 80vh;
    }

    .resizable-container {
        flex-direction: column;
        height: 100%;
    }

    .editor-panel,
    .preview-panel {
        width: 100% !important;
        min-width: 100%;
    }

    .editor-container {
        margin-right: 0;
        margin-bottom: 8px;
    }

    .preview-container {
        margin-left: 0;
    }

    .resizer {
        display: flex !important;
        width: 100%;
        height: 12px;
        cursor: row-resize;
    }

    .resizer-handle {
        width: 60px;
        height: 4px;
    }

    .resizer:hover .resizer-handle {
        width: 80px;
        height: 4px;
    }

    /* Tablet layout overrides */
    .mobile-vertical .editor-panel {
        height: 50% !important;
        min-height: 40vh !important;
    }

    .mobile-vertical .preview-panel {
        height: 50% !important;
        min-height: 40vh !important;
    }

    .mobile-preview-only .editor-panel {
        display: none !important;
    }

    .mobile-preview-only .preview-panel {
        height: 100% !important;
        min-height: 80vh !important;
    }

    .mobile-code-only .preview-panel {
        display: none !important;
    }

    .mobile-code-only .editor-panel {
        height: 100% !important;
        min-height: 80vh !important;
    }
}

/* Desktop styles */
@media (min-width: 769px) {
    .playground-container {
        height: 80vh;
        min-height: 600px;
        max-height: 80vh;
    }
}

footer {
    margin-top: auto;
    background: #1f2937;
    position: relative;
    z-index: 10;
}

.dots-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s;
}

.dots-btn:hover {
    color: white;
    background-color: #374151;
}

.layout-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}

.layout-btn {
    padding: 8px 12px;
    background: #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.layout-btn.active {
    background: var(--primary-color);
    color: white;
}

.theme-preview {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
    margin-right: 8px;
    border: 1px solid #ccc;
}

.theme-material-darker {
    background: #212121;
}

.theme-dracula {
    background: #282a36;
}

.theme-monokai {
    background: #272822;
}

.theme-solarized {
    background: #002b36;
}

.theme-nord {
    background: #2e3440;
}

/* Mobile layout indicator */
.mobile-layout-indicator {
    display: none;
    /* Visually hidden, still announced: as a badge it covered the site header's menu button (top right) or the preview
       header (bottom) on a phone, and it only repeats what the layout already shows. */
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 768px) {
    .mobile-layout-indicator {
        display: block;
    }
}

/* Back to Code Editor Button */
.back-to-code-btn {
    position: fixed;
    bottom: 120px;
    right: 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
}

.back-to-code-btn.show {
    opacity: 1;
    transform: translateY(0);
}

.back-to-code-btn:hover {
    background: #4338ca;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

@media (max-width: 768px) {
    .back-to-code-btn {
        bottom: 100px;
        right: 20px;
        padding: 10px 16px;
        font-size: 13px;
    }

    .toast {
        bottom: 80px;
        right: 20px;
    }
}
/* WCAG 2.2 AA: CodeMirror line numbers (the theme defaults are 2 to 3:1; .CodeMirror.cm-s-* outranks the theme sheets) */
.CodeMirror .CodeMirror-linenumber { color: #a3a3a3; }
.CodeMirror.cm-s-material-darker .CodeMirror-linenumber { color: #a3a3a3; }
.CodeMirror.cm-s-dracula .CodeMirror-linenumber { color: #b4b8c8; }

/* The console sat below the editor panel's bottom edge and was clipped away (overflow hidden), so it could not be seen
   even when "Show Console" was on. It now sits on the bottom edge of the editor panel (the panel is position: relative). */
.editor-panel > .console { position: absolute; left: 0; right: 8px; bottom: 0; margin: 0; z-index: 5; box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.35); }
