/* Palette: light by default, dark behind [data-theme="dark"]. */
:root {
    color-scheme: light;
    --bg: #f6f7fb;
    --bg-card: #ffffff;
    --bg-soft: #eef1f7;
    --text: #1e2430;
    --text-muted: #5b6472;
    --border: #dfe3ec;
    --accent: #4f46e5;
    --accent-soft: #eef2ff;
    --code-bg: #f3f4f9;
    --header-bg: #ffffff;
    --shadow: 0 1px 2px rgba(20, 26, 40, 0.06), 0 8px 24px rgba(20, 26, 40, 0.06);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1218;
    --bg-card: #161b24;
    --bg-soft: #1d2430;
    --text: #e6e9ef;
    --text-muted: #9aa4b5;
    --border: #2a3240;
    --accent: #8b86f7;
    --accent-soft: #1e2340;
    --code-bg: #11161e;
    --header-bg: #12171f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--accent); }

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.app-titles h1 {
    margin: 0;
    font-size: 19px;
    letter-spacing: -0.01em;
}

.app-titles p {
    margin: 2px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.app-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-source {
    font-size: 13px;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
}

.app-source:hover { background: var(--bg-soft); }

.btn {
    font: inherit;
    font-size: 13px;
    color: var(--text);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 11px;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}

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

.page {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
    gap: 18px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 24px 32px;
}

@media (max-width: 980px) {
    .page { grid-template-columns: 1fr; }
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 16px 18px 18px;
}

.card-header h2 {
    margin: 0;
    font-size: 16px;
}

.card-header p {
    margin: 4px 0 12px;
    color: var(--text-muted);
    font-size: 13px;
    max-width: 70ch;
}

.editor-target { width: 100%; min-height: 320px; }

.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 14px;
    margin: 0 0 14px;
    font-size: 13px;
}

.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }

.inspector h3 {
    margin: 16px 0 6px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.preview,
.log {
    margin: 0;
    padding: 10px 12px;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview { max-height: 190px; overflow: auto; }
.log { max-height: 210px; overflow: auto; }

.app-footer {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px 28px;
    color: var(--text-muted);
    font-size: 12.5px;
}

.app-footer p { margin: 0; }

/* TinyMCE tweaks: match the page palette in both themes. */
.tox-tinymce { border-radius: 8px !important; border-color: var(--border) !important; }