:root {
    --bg: #0b1020;
    --bg-soft: #111833;
    --panel: #121a35cc;
    --panel-solid: #ffffff;
    --text: #e9ecff;
    --text-muted: #a5afcc;
    --border: #273258;
    --accent: #6f8cff;
    --accent-strong: #4f73ff;
    --editor-bg: #0f1733;
    --editor-text: #eef2ff;
    --preview-text: #1f2740;
    --shadow-lg: 0 20px 40px rgba(2, 9, 29, 0.45);
    --shadow-sm: 0 4px 12px rgba(2, 9, 29, 0.2);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: Inter, "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 10%, #1e2750 0%, transparent 35%),
        radial-gradient(circle at 90% 90%, #232f67 0%, transparent 30%),
        linear-gradient(135deg, #070b17 0%, #0b1020 100%);
}

.app-shell {
    max-width: 1400px;
    margin: 1.5rem auto;
    min-height: calc(100vh - 3rem);
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 1rem;
    padding: 0 1rem;
}

.site-header,
.site-main,
.site-footer {
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
}

.site-header,
.site-footer {
    background: var(--panel);
}

.site-header {
    padding: 1rem 1.25rem;
}

.brand-wrap .eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: 700;
}

.brand-wrap h1 {
    margin: 0;
    font-size: clamp(1.2rem, 1rem + 1vw, 1.9rem);
    line-height: 1.2;
    color: #f5f7ff;
}

.site-main {
    background: var(--panel);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.7rem;
    padding: 0.85rem;
    border-bottom: 1px solid var(--border);
    background: rgba(12, 19, 41, 0.8);
}

.toolbar-control {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding-right: 0.75rem;
    margin-right: 0.2rem;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.toolbar-select {
    border: 1px solid #34406a;
    background: #121a34;
    color: var(--text);
    border-radius: 8px;
    padding: 0.35rem 0.55rem;
    font-size: 0.84rem;
}

.toolbar-select:focus-visible,
.toolbar-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.toolbar-group {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-right: 0.75rem;
    margin-right: 0.2rem;
    border-right: 1px solid var(--border);
}

.toolbar-group:last-child {
    border-right: none;
    margin-right: 0;
    padding-right: 0;
}

.toolbar-button {
    border: 1px solid #33406e;
    background: linear-gradient(180deg, #182346, #131d3c);
    color: var(--text);
    border-radius: 9px;
    min-width: 2rem;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
    box-shadow: var(--shadow-sm);
}

.toolbar-button:hover {
    border-color: #5064a8;
    transform: translateY(-1px);
}

.toolbar-button:active {
    transform: translateY(0);
    background: #111937;
}

.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 0;
    flex: 1;
}

#editor,
#preview {
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem;
}

#editor {
    border: none;
    resize: none;
    outline: none;
    background: var(--editor-bg);
    color: var(--editor-text);
    font-size: 0.98rem;
    line-height: 1.6;
    font-family: "Fira Code", "Cascadia Code", Consolas, "Courier New", monospace;
}

#preview {
    background: var(--panel-solid);
    color: var(--preview-text);
    border-left: 1px solid #d8dff5;
}

#preview h1,
#preview h2,
#preview h3 {
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    padding-bottom: 0.2em;
    border-bottom: 1px solid #dce3f8;
}

#preview code {
    background: #f0f3ff;
    color: #1f2d62;
    border-radius: 4px;
    padding: 0.15em 0.4em;
    font-family: "Fira Code", "Cascadia Code", Consolas, "Courier New", monospace;
}

#preview pre {
    background: #eef2ff;
    border: 1px solid #d8dff5;
    border-radius: 10px;
    padding: 0.9em;
    overflow-x: auto;
}

#preview pre code {
    background: transparent;
    padding: 0;
}

#preview blockquote {
    border-left: 4px solid #9fb3ff;
    margin-left: 0;
    padding-left: 1em;
    color: #405081;
}

#preview table {
    width: 100%;
    border-collapse: collapse;
}

#preview th,
#preview td {
    border: 1px solid #d8dff5;
    padding: 0.45rem 0.6rem;
}

#preview th {
    background: #eef2ff;
}

.site-footer {
    padding: 0.75rem 1rem;
    text-align: center;
}

.site-footer p {
    margin: 0.15rem 0;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.site-footer a {
    color: #b9c7ff;
    font-weight: 600;
    text-decoration: none;
}

.site-footer a:hover {
    color: #d6deff;
    text-decoration: underline;
}

@media (max-width: 980px) {
    .app-shell {
        margin: 0.75rem auto;
        min-height: calc(100vh - 1.5rem);
    }

    .editor-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    #preview {
        border-left: none;
        border-top: 1px solid #d8dff5;
    }
}
