:root {
    --bg-deep: #020617;
    --bg-panel: #0f172a;
    --bg-input: #1e293b;
    --bg-hover: #334155;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-2: #ec4899;
    --cyan: #06b6d4;
    --border: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.05);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --text-dimmer: #64748b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --header-h: 60px;
    --sidebar-w: 220px;
    --resizer-size: 5px;
    --dd-accent: #6366f1;
    --dd-accent-2: #ec4899;
    --dd-cyan: #06b6d4;
}

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

body,
html {
    height: 100%;
    width: 100%;
    background: var(--bg-deep);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
}

body {
    overflow-y: auto;
    overflow-x: hidden;
}
svg {
    height: 1em;
    width: auto;
    vertical-align: -0.125em;
    fill: currentcolor;
}
/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-input);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* ===============================================
   LOGO & BRANDING
   =============================================== */
.dd-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    user-select: none;
}

.dd-logo-link {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.dd-logo-icon {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.dd-icon-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1f35 0%, #0f1424 100%);
    border-radius: 12px;
    border: 2px solid rgba(99, 102, 241, 0.3);
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.terminal-header {
    position: absolute;
    top: 6px;
    left: 6px;
    display: flex;
    gap: 3px;
    z-index: 2;
}

.terminal-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

.terminal-dot:nth-child(1) {
    background: #ff5f56;
    animation-delay: 0s;
}

.terminal-dot:nth-child(2) {
    background: #ffbd2e;
    animation-delay: 0.3s;
}

.terminal-dot:nth-child(3) {
    background: #27c93f;
    animation-delay: 0.6s;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.dd-code-symbol {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 50%, var(--cyan) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 900;
    animation: glow-pulse 3s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

@keyframes glow-pulse {

    0%,
    100% {
        filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.4));
    }

    50% {
        filter: drop-shadow(0 0 16px rgba(99, 102, 241, 0.8));
    }
}

.dd-binary-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    opacity: 0.15;
}

.dd-binary-col {
    position: absolute;
    top: -100%;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 7px;
    color: var(--accent);
    white-space: nowrap;
    animation: fall linear infinite;
}

.dd-binary-col:nth-child(1) {
    left: 15%;
    animation-duration: 4s;
    animation-delay: 0s;
}

.dd-binary-col:nth-child(2) {
    left: 45%;
    animation-duration: 5s;
    animation-delay: 1s;
}

.dd-binary-col:nth-child(3) {
    left: 75%;
    animation-duration: 4.5s;
    animation-delay: 2s;
}

@keyframes fall {
    to {
        transform: translateY(200%);
    }
}

.dd-corner {
    position: absolute;
    width: 10px;
    height: 10px;
    border: 2px solid var(--accent-2);
    opacity: 0.6;
}

.dd-corner.tl {
    top: 3px;
    left: 3px;
    border-right: none;
    border-bottom: none;
}

.dd-corner.tr {
    top: 3px;
    right: 3px;
    border-left: none;
    border-bottom: none;
}

.dd-corner.bl {
    bottom: 3px;
    left: 3px;
    border-right: none;
    border-top: none;
}

.dd-corner.br {
    bottom: 3px;
    right: 3px;
    border-left: none;
    border-top: none;
}

/* ===============================================
   APP LAYOUT
   =============================================== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===============================================
   TOP BAR
   =============================================== */
.top-bar {
    height: var(--header-h);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    gap: 20px;
    flex-shrink: 0;
    z-index: 100;
}

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

.brand-text {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.5px;
}

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

.auto-run-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
}

.auto-run-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

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

.btn-primary.pending {
    animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(99, 102, 241, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0);
    }
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

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

.btn-icon {
    padding: 10px 12px;
}

.mobile-only-btn {
    display: none;
}

.btn-icon-small {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.btn-icon-small:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

/* ===============================================
   WORKSPACE
   =============================================== */
.workspace {
    display: flex;
    height: calc(100vh - var(--header-h));
    min-height: 500px;
    overflow: hidden;
    position: relative;
}

/* ===============================================
   EDITOR PANEL
   =============================================== */
.editor-panel {
    width: 45%;
    display: flex;
    background: var(--bg-panel);
    min-width: 300px;
}

/* File Sidebar */
.file-sidebar {
    width: var(--sidebar-w);
    background: var(--bg-deep);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.file-sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
    opacity: 0;
}

.sidebar-toggle-btn {
    transition: transform 0.3s ease;
}

.file-sidebar.collapsed .sidebar-toggle-btn svg {
    transform: rotate(180deg);
}

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

.sidebar-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sidebar-close-btn {
    display: none;
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dim);
}

.sidebar-title svg {
    color: var(--accent);
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 8px;
}

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

.file-item.active {
    background: var(--bg-input);
    border-color: var(--accent);
}

.file-item-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.file-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.file-icon.html {
    color: #e34c26;
}

.file-icon.css {
    color: #264de4;
}

.file-icon.js {
    color: #f0db4f;
}

.file-name {
    font-size: 0.875rem;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.file-item:hover .file-actions {
    opacity: 1;
}

.file-action-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.file-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.file-action-btn.delete:hover {
    color: var(--danger);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.btn-sidebar {
    width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-sidebar:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

/* Floating Sidebar Toggle */
.floating-sidebar-toggle {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 50;
    background: var(--accent);
    border: 1px solid var(--border);
    color: white;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    animation: slideInLeft 0.3s ease;
}

.floating-sidebar-toggle:hover {
    background: var(--accent-hover);
    transform: translateX(3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.floating-sidebar-toggle:active {
    transform: translateX(3px) scale(0.98);
}

.file-sidebar.collapsed~.floating-sidebar-toggle {
    display: flex;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Editor Area */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.editor-header {
    display: flex;
    align-items: center;
    background: var(--bg-deep);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    min-height: 42px;
}

.current-file-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.editor-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.cm-wrapper {
    height: 100%;
    width: 100%;
    overflow: auto;
    background: var(--bg-input);
}

/* ===============================================
   RESIZERS
   =============================================== */
.resizer-main {
    width: var(--resizer-size);
    background: var(--bg-panel);
    cursor: col-resize;
    flex-shrink: 0;
    position: relative;
}

.resizer-main:hover {
    background: var(--accent);
}

.resizer-console {
    height: var(--resizer-size);
    background: var(--bg-panel);
    cursor: row-resize;
    flex-shrink: 0;
    position: relative;
}

.resizer-console:hover {
    background: var(--accent);
}

.shield {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: transparent;
}

body.is-resizing .shield {
    display: block;
}

body.is-resizing {
    user-select: none;
}

/* ===============================================
   PREVIEW PANEL
   =============================================== */
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    min-width: 300px;
}

.preview-header {
    background: var(--bg-panel);
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewport-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.viewport-info svg {
    color: var(--accent);
}

.preview-content {
    flex: 0 0 60%;
    position: relative;
    background: #ffffff;
}

#sandbox {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
}

/* Console Panel */
.console-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #000000;
    min-height: 100px;
}

.console-panel.hidden {
    display: none;
}

.console-header {
    padding: 10px 16px;
    background: #0a0a0a;
    border-top: 1px solid #1e293b;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.console-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

.console-actions {
    display: flex;
    gap: 8px;
}

.btn-console-clear {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-console-clear:hover {
    background: var(--bg-hover);
    color: var(--accent);
}

.console-logs {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
}

.console-log {
    padding: 4px 0;
    border-bottom: 1px solid #1e293b;
    color: var(--text-dim);
}

.console-log.error {
    color: #f87171;
}

/* ===============================================
   PAGE CONTENT AREA
   =============================================== */

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    width: 90%;
    max-width: 500px;
    background: var(--bg-panel);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.modal-card-sm {
    max-width: 400px;
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 6px;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-close:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

/* Form Elements */
.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder {
    color: var(--text-dimmer);
}

.form-textarea {
    width: 100%;
    min-height: 150px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    outline: none;
    resize: vertical;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-help {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-dimmer);
}

.delete-message {
    color: var(--text-dim);
    line-height: 1.6;
}

.delete-message strong {
    color: var(--text-main);
}

/* ===============================================
   RESPONSIVE DESIGN
   =============================================== */
@media (max-width: 1024px) {
    .sidebar-w {
        --sidebar-w: 180px;
    }

    .editor-panel {
        width: 50%;
    }
}

@media (max-width: 768px) {
    .top-bar {
        padding: 0 12px;
        height: 56px;
    }

    .brand-text {
        display: none;
    }

    .dd-logo-icon {
        width: 35px;
        height: 35px;
    }

    .auto-run-label span {
        display: none;
    }

    .btn span {
        display: none;
    }

    .btn {
        padding: 10px 12px;
    }

    .workspace {
        flex-direction: column;
        height: calc(100vh - 56px);
        position: relative;
    }

    .editor-panel {
        width: 100% !important;
        height: 50%;
        min-height: 200px;
        position: relative;
    }

    .preview-panel {
        width: 100% !important;
        height: 50%;
        min-height: 200px;
    }

    .resizer-main {
        width: 100% !important;
        height: 12px !important;
        cursor: row-resize !important;
        background: #000;
        border-top: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
    }

    .resizer-main::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 40px;
        height: 3px;
        background: var(--text-dim);
        border-radius: 2px;
    }

    .modal-card {
        width: 95%;
        margin: 16px;
    }

    /* Mobile sidebar adjustments */
    .file-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 100;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
    }

    .file-sidebar.collapsed {
        transform: translateX(-100%);
    }

    .floating-sidebar-toggle {
        top: 8px;
        left: 8px;
        padding: 8px 10px;
        font-size: 0.9rem;
    }

    .editor-area {
        transition: margin-left 0.3s ease;
    }

    /* Mobile editor toggle */
    .mobile-only-btn {
        display: flex;
    }

    .editor-panel.mobile-hidden {
        display: none;
    }

    .resizer-main.mobile-hidden {
        display: none;
    }

    .preview-panel.mobile-fullscreen {
        height: 100% !important;
    }
}

@media (max-width: 768px) {
    .file-actions {
        opacity: 1;
    }
    .dd-code-symbol {
        font-size: 12px;
    }
}