:root {
    --bg-page: #f4f4f5;
    --bg-panel: #ffffff;
    --bg-editor: #fafafa;
    --border: #e4e4e7;
    --text: #18181b;
    --text-muted: #71717a;
    --accent: #1c136e;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.2);
    --success: #ffb606;
    --success-hover: #ffb608;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-page);
    color: var(--text);
    min-height: 100vh;
    height: 100%;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

.top-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

.top-bar a {
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    font-weight: 500;
    transition: color 0.2s;
}

.top-bar a:hover {
    color: var(--accent);
}

.top-bar .logo-img {
    height: 32px;
    width: auto;
    display: block;
}

.playground-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.container {
    flex: 1;
    min-height: 0;
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
    width: 100%;
}

.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    height: 100%;
    min-height: 0;
}

@media (max-width: 900px) {
    .editor-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

/* Tablet: reduce header and container spacing */
@media (max-width: 1024px) {
    .top-bar {
        padding: 10px 16px;
    }
    .top-bar .logo-img {
        height: 28px;
    }
    .playground-title {
        font-size: 13px;
    }
    .container {
        padding: 16px;
    }
    .editor-container {
        gap: 16px;
    }
    .editor-header,
    .output-header {
        padding: 6px 10px;
        font-size: 10px;
    }
    .editor-header .badge,
    .output-header .badge {
        font-size: 14px;
    }
}

/* Mobile: compact header and editors, minimal spacing */
@media (max-width: 768px) {
    .top-bar {
        padding: 8px 12px;
    }
    .top-bar .logo-img {
        height: 26px;
    }
    .playground-title {
        font-size: 12px;
    }
    .container {
        padding: 10px 12px;
    }
    .editor-container {
        gap: 10px;
        grid-template-rows: minmax(180px, 1fr) minmax(180px, 1fr);
    }
    .editor-box,
    .output-container {
        border-radius: 8px;
    }
    .editor-header,
    .output-header {
        padding: 6px 8px;
        font-size: 9px;
    }
    .editor-header .badge,
    .output-header .badge {
        font-size: 13px;
    }
    .editor-actions {
        gap: 4px;
        flex-wrap: wrap;
    }
    .btn-clear,
    .btn-reset,
    .btn-format {
        padding: 4px 8px;
        font-size: 11px;
    }
    .btn-run {
        padding: 4px 10px;
        font-size: 12px;
    }
    .btn-run svg {
        width: 14px;
        height: 14px;
    }
    .editor-body .CodeMirror {
        min-height: 140px;
        font-size: 13px;
    }
}

/* Small mobile: even tighter */
@media (max-width: 480px) {
    .top-bar {
        padding: 6px 10px;
    }
    .top-bar .logo-img {
        height: 24px;
    }
    .playground-title {
        font-size: 11px;
    }
    .container {
        padding: 8px 10px;
    }
    .editor-container {
        gap: 8px;
        grid-template-rows: minmax(160px, 1fr) minmax(160px, 1fr);
    }
    .editor-header,
    .output-header {
        padding: 4px 6px;
    }
    .editor-body .CodeMirror {
        min-height: 120px;
        font-size: 12px;
    }
}

.editor-box,
.output-container {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.editor-header,
.output-header {
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--bg-editor);
    letter-spacing: 0.03em;
}

.editor-header {
    color: var(--text-muted);
}

.editor-header .badge, .output-header .badge  {
    color: #2a2a2a;
    /* padding: 2px 10px; */
    border-radius: 6px;
    font-size: 14px;
    font-weight: 800;
}

.output-header {
    color: var(--text-muted);
}

.editor-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.editor-body .CodeMirror {
    height: 100%;
    min-height: 200px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.editor-body .CodeMirror-gutters {
    border-right: 1px solid var(--border);
    background: var(--bg-editor);
}

.editor-body .CodeMirror-cursor {
    border-left-color: var(--text);
}

/* W3Schools-style HTML syntax colors */
.editor-body .cm-tag { color: #800080; }           /* purple - tag names like <div> */
.editor-body .cm-attribute { color: #ff0000; }     /* red - attribute names */
.editor-body .cm-string { color: #a31515; }        /* dark red - attribute values */
.editor-body .cm-meta { color: #008000; }          /* green - DOCTYPE, etc. */
.editor-body .cm-comment { color: #008000; font-style: italic; }  /* green - comments */
.editor-body .cm-bracket { color: #0000ff; }      /* blue - < and > */
.editor-body .cm-qualifier { color: #800080; }    /* purple - closing tag names */

.btn-run {
    text-align: center;
    padding: 5px 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn-run:hover {
    background: var(--success-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-run:active {
    transform: scale(0.98);
}

.btn-run svg {
    width: 16px;
    height: 16px;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-clear,
.btn-reset,
.btn-format {
    padding: 3px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
}

.btn-clear {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-clear:hover {
    background: var(--bg-editor);
    color: var(--text);
    border-color: var(--text-muted);
}

.btn-reset {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-reset:hover {
    background: var(--accent);
    color: white;
}

.btn-format {
    background: var(--accent);
    color: white;
    border: 1px solid var(--border);
}

.btn-format:hover {
    background: var(--bg-editor);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-clear:active,
.btn-reset:active,
.btn-format:active {
    transform: scale(0.98);
}

.output-container iframe {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

.output-body {
    flex: 1;
    min-height: 0;
    background: #fff;
}