:root {
    --bg-primary: #1e1f1f;
    --bg-secondary: #252626;
    --bg-tertiary: #2a2b2b;
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #ededed;
    --text-secondary: #a0a0a0;
    --accent: #88b8ff;
    --accent-hover: #6ba3ff;
}

* {
    box-sizing: border-box;
}

#code-editor {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px); /* 40px is the height of the header */
    min-height: 600px;
    background: var(--bg-primary);
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.667em;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 1em;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.btn-primary,
.btn-secondary {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary i,
.btn-secondary i {
    font-size: 14px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--accent);
}

.demo-title-input {
    font-size: 13px;
    min-width: 200px;
}

.demo-title-input:focus {
    outline: none;
    border-color: var(--accent);
}

.layout-select {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
}

/* Editor Container */
.editor-container {
    display: flex;
    flex: 1;
    gap: 1px;
    background: var(--border-color);
    overflow: hidden;
}

/* Code Panels Container (Resizable) */
.code-panels-container {
    display: flex;
    flex-direction: column;
    width: 50%;
    min-width: 300px;
    max-width: 80%;
    resize: horizontal;
    overflow: hidden;
    background: var(--bg-secondary);
    position: relative;
    height: 100%;
}

.code-panels-container::-webkit-resizer {
    background: var(--accent);
    border: 2px solid var(--accent);
    border-radius: 4px 0 0 0;
    width: 20px;
    height: 20px;
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.3);
}

.code-panels-container::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to right, transparent, var(--accent));
    opacity: 0.3;
    pointer-events: none;
    z-index: 1;
}

.code-panels-container:hover::after {
    opacity: 0.6;
}

/* Stacked Layout - Code panels stacked vertically on left */
.editor-container.layout-stacked .code-panels-container {
    flex-direction: column;
    height: 100%;
}

.editor-container.layout-stacked .code-panels-container .editor-panel {
    flex: 1 1 0;
    min-height: 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.editor-container.layout-stacked .code-panels-container .editor-panel:last-child {
    border-bottom: none;
}

.editor-container.layout-stacked .code-panels-container .editor-panel[open] {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.editor-container.layout-stacked .code-panels-container .editor-panel:not([open]) {
    flex: 0 0 auto;
    min-height: auto;
}

/* Vertical Layout - Code panels in a row at top */
.editor-container.layout-vertical {
    flex-direction: column;
}

.editor-container.layout-vertical .code-panels-container {
    width: 100%;
    max-width: 100%;
    flex-direction: row;
    resize: vertical;
    min-height: 200px;
    max-height: 70%;
}

.editor-container.layout-vertical .code-panels-container .editor-panel {
    flex: 1;
    min-width: 0;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-container.layout-vertical .code-panels-container .editor-panel:last-child {
    border-right: none;
}

.editor-container.layout-vertical .code-panels-container .editor-panel[open] {
    flex: 1;
}

.editor-container.layout-vertical .code-panels-container .editor-panel:not([open]) {
    flex: 0 0 auto;
}

.editor-container.layout-vertical .code-panels-container .editor-panel:not([open]) .code-editor {
    display: none;
}

/* Preview Panel */
.editor-container.layout-stacked .preview-panel {
    flex: 1;
    min-width: 0;
}

.editor-container.layout-vertical .preview-panel {
    flex: 1;
    min-height: 0;
}

/* Editor Panel */
.editor-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.editor-panel[open] {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.editor-panel summary {
    list-style: none;
    cursor: pointer;
    flex-shrink: 0;
}

.editor-panel summary::-webkit-details-marker {
    display: none;
}

.editor-panel summary::marker {
    display: none;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-primary);
    user-select: none;
    position: relative;
}

.panel-header::before {
    content: '▼';
    font-size: 10px;
    opacity: 0.6;
    transition: transform 0.2s;
    margin-right: 4px;
}

.editor-panel:not([open]) .panel-header::before {
    transform: rotate(-90deg);
}

.panel-header:hover {
    background: var(--bg-primary);
}

.panel-icon {
    font-size: 14px;
}

.panel-title {
    font-weight: 600;
    flex: 1;
}

.preview-controls {
    display: flex;
    gap: 5px;
    margin-left: auto;
}

.btn-small {
    padding: 4px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.btn-small:hover {
    background: var(--bg-primary);
    border-color: var(--accent);
}

.code-editor {
    flex: 1;
    width: 100%;
    padding: 15px;
    background: var(--bg-primary);
    border: none;
    color: var(--text-primary);
    font-family: 'Reddit Mono', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 2;
    overflow: auto;
    min-height: 0;
    box-sizing: border-box;
}

.code-editor:focus {
    background: var(--bg-secondary);
}

/* Preview Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    background: #fff;
    min-height: 0;
}

.preview-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: #fff;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Demos List */
.demos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.demo-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.demo-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.demo-card-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 14px;
}

.demo-card-meta {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
}

.demo-card-actions {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.btn-delete {
    padding: 4px 8px;
    background: rgba(200, 0, 0, 0.2);
    border: 1px solid rgba(200, 0, 0, 0.4);
    border-radius: 3px;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 11px;
}

.btn-delete:hover {
    background: rgba(200, 0, 0, 0.3);
}

/* Share Modal */
.share-section {
    margin-bottom: 20px;
}

.share-section label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
}

.share-input-group {
    display: flex;
    gap: 8px;
}

.share-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: monospace;
}

.btn-copy {
    padding: 8px 16px;
    background: var(--accent);
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

.btn-copy:hover {
    background: var(--accent-hover);
}

.embed-textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: monospace;
    resize: vertical;
    margin-bottom: 8px;
}

/* Result Only View */
#code-editor.result-only .code-panels-container {
    display: none;
}

#code-editor.result-only .preview-panel {
    width: 100%;
    height: 100%;
}

#code-editor.result-only .preview-frame {
    height: 100vh;
}

#code-editor.result-only .toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

#code-editor.result-only .editor-container {
    margin-top: 60px;
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-menu #user-name {
    color: var(--text-primary);
    font-size: 13px;
}

/* Auth Forms */
.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.auth-tab:hover {
    color: var(--text-primary);
    background: var(--category-active);
}

.auth-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

.form-group input {
    padding: 10px 12px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 13px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--input-focus);
}

.auth-divider {
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    margin: 10px 0;
    position: relative;
}

.auth-divider:before,
.auth-divider:after {
    content: '';
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background: var(--border-color);
}

.auth-divider:before {
    left: 0;
}

.auth-divider:after {
    right: 0;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fff;
    color: #444;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-google:hover {
    background: #f5f5f5;
    border-color: #999;
}

.btn-google img {
    width: 18px;
    height: 18px;
}

/* Responsive */
@media (max-width: 1200px) {
    .editor-container {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
    }
}

