/* --- Layout and Theme --- */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: #181a1b;
    color: #f1f1f1;
    transition: background 0.2s, color 0.2s;
}
body.light-theme {
    background: #f5f5f5;
    color: #181a1b;
}

.header {
    background: #23272b;
    color: #f1f1f1;
    padding: 1em 2em;
    font-size: 1.5em;
    font-weight: bold;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #1a73e8;
    position: relative;
    transition: background 0.2s, color 0.2s;
}
body.dark-theme .header {
    background: #181a1b;
    color: #f1f1f1;
    border-bottom: 2px solid #1976d2;
}
body.light-theme .header {
    background: #eaeaea;
    color: #181a1b;
    border-bottom: 2px solid #1565c0;
}

/* --- Enhanced Header --- */
.header-logo {
    width: 2.4em;
    height: 2.4em;
    margin-right: 0.5em;
    vertical-align: middle;
}
.header-title {
    font-size: 1.7em;
    font-weight: bold;
    letter-spacing: 0.04em;
    color: #8be9fd;
    text-shadow: 0 2px 8px #222a, 0 1px 0 #222a;
}
.header-subtitle {
    font-size: 1.1em;
    font-weight: 400;
    opacity: 0.7;
    margin-left: 0.5em;
    color: #90caf9;
}

/* --- Explorer Entry Flex Alignment --- */
.explorer-entry {
    display: flex;
    align-items: center;
    gap: 0.7em;
}
.explorer-icon {
    font-size: 1.2em;
    min-width: 1.6em;
    text-align: center;
    margin-right: 0.2em;
}
.explorer-name {
    font-size: 1em;
    word-break: break-all;
}

.main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: row;
    gap: 2em;
    padding: 2em;
    min-height: 60vh;
    background: transparent;
}
#explorer-main, #explorer-preview {
    background: #22262b;
    border-radius: 1.1em;
    box-shadow: 0 4px 24px #0004;
    border: 1px solid #1a73e8;
    padding: 1.5em 1.2em;
    min-height: 40vh;
    overflow: auto;
}
#explorer-main {
    margin-right: 0.5em;
}
#explorer-preview {
    margin-left: 0.5em;
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-width: 0;
}

/* --- CodeMirror Integration for Preview --- */
#explorer-codemirror-preview {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.CodeMirror {
    flex: 1 1 auto;
    height: 60vh !important;
    min-height: 0;
    font-size: 1.1em;
    background: #23272b;
    color: #f8f8f2;
    border-radius: 0.5em;
    border: none;
    transition: background 0.2s, color 0.2s;
}
body.light-theme .CodeMirror {
    background: #fff;
    color: #181a1b;
}

.footer {
    flex-shrink: 0;
    background: #23272b;
    color: #f1f1f1;
    padding: 1.2em 2em 1em 2em;
    font-size: 1em;
    border-top: 2px solid #1a73e8;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    z-index: 100;
    transition: background 0.2s, color 0.2s;
}
body.dark-theme .footer {
    background: #181a1b;
    color: #f1f1f1;
    border-top: 2px solid #1976d2;
}
body.light-theme .footer {
    background: #eaeaea;
    color: #181a1b;
    border-top: 2px solid #1565c0;
}
.footer a {
    color: #90caf9;
    text-decoration: underline;
}
body.light-theme .footer a {
    color: #1976d2;
}
.footer ul {
    list-style: none;
    padding: 0;
    margin: 0.5em 0 0 0;
    display: flex;
    gap: 1.5em;
    justify-content: center;
    align-items: center;
}
.footer li {
    display: inline;
}

.theme-switcher {
    position: absolute;
    right: 20px;
    top: 10px;
    background: #444;
    color: #f1f1f1;
    border: none;
    border-radius: 4px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.2s, color 0.2s;
}
body.light-theme .theme-switcher {
    background: #ddd;
    color: #181a1b;
}
body.dark-theme .theme-switcher {
    background: #23272b;
    color: #f1f1f1;
}

/* Explorer file/dir links */
.explorer-link, .explorer-link:visited {
    color: #90caf9;
    text-decoration: none;
    font-weight: 500;
}
body.light-theme .explorer-link, body.light-theme .explorer-link:visited {
    color: #1976d2;
}
.explorer-link:hover {
    text-decoration: underline;
    color: #42a5f5;
}
body.light-theme .explorer-link:hover {
    color: #1565c0;
}

@media (max-width: 900px) {
    .main {
        flex-direction: column;
        gap: 1em;
        padding: 1em;
    }
    #explorer-main, #explorer-preview {
        min-height: 20vh;
        padding: 1em 0.7em;
    }
    #explorer-preview {
        margin-left: 0;
    }
}
