:root {
  --bg: #0f1115; --panel: #171a21; --line: #262a33; --text: #e6e8ee; --muted: #9aa1ad;
  --accent: #f2a93b; --accent-ink: #1a1200;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); }
.top { padding: 1.25rem 1.25rem .5rem; max-width: 1200px; margin: 0 auto; }
.top h1 { font-size: 1.35rem; margin: 0 0 .25rem; font-weight: 600; }
.lead { margin: 0; color: var(--muted); font-size: .95rem; }

.toolbar { max-width: 1200px; margin: 1rem auto 0; padding: 0 0 .5rem; display: flex; justify-content: flex-end; min-height: 2.4rem; }
.tool { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: 0 auto 1rem; max-width: 1200px; height: 70vh; min-height: 420px; }
.tool { --split: 50%; }
.tool.layout-lado { grid-template-columns: minmax(0, var(--split)) 6px minmax(0, 1fr); }
.tool.layout-cima { grid-template-columns: 1fr; grid-template-rows: minmax(0, var(--split)) 6px minmax(0, 1fr); }
.tool.layout-codigo, .tool.layout-resultado { grid-template-columns: 1fr; }
.tool.layout-codigo .pane-preview, .tool.layout-resultado .pane-editor,
.tool.layout-codigo .divider, .tool.layout-resultado .divider { display: none; }
.divider { background: var(--line); cursor: col-resize; touch-action: none; }
.divider:hover, .divider:focus-visible { background: var(--accent); outline: 0; }
.tool.layout-cima .divider { cursor: row-resize; }
.pane { display: flex; flex-direction: column; background: var(--panel); min-width: 0; }
.pane-bar { display: flex; align-items: center; justify-content: space-between; padding: .4rem .75rem; border-bottom: 1px solid var(--line); font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; min-height: 2.2rem; }
.draft-warning { color: var(--accent); font-size: .75rem; text-transform: none; letter-spacing: 0; margin-left: .5rem; }
.actions { display: flex; gap: .4rem; }
.tabs { display: flex; gap: .15rem; }
.tab { font: inherit; font-size: .8rem; padding: .3rem .6rem; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; text-transform: uppercase; letter-spacing: .04em; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab.has-content::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: .35rem; vertical-align: middle; }
.btn { font: inherit; font-size: .8rem; padding: .35rem .7rem; border-radius: 6px; border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-accent:hover { filter: brightness(1.08); }
.code-wrap { position: relative; flex: 1; min-height: 0; }
.code-wrap .highlight, #editor { position: absolute; inset: 0; margin: 0; padding: .9rem; font-family: var(--mono); font-size: .9rem; line-height: 1.5; tab-size: 2;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; }
.code-wrap .highlight { overflow: hidden; color: var(--text); background: var(--panel); pointer-events: none; }
.code-wrap .highlight code { font: inherit; }
#editor { width: 100%; height: 100%; resize: none; border: 0; outline: 0; overflow: auto; scrollbar-gutter: stable; background: transparent; color: transparent; caret-color: var(--text); }
#editor::placeholder { color: var(--muted); }
#editor::selection { background: rgba(242, 169, 59, .3); color: transparent; }

.tok-tag { color: #7dd3fc; }
.tok-attr, .tok-prop { color: #c4b5fd; }
.tok-str, .tok-val { color: #86efac; }
.tok-cm, .tok-doc { color: #6b7280; font-style: italic; }
.tok-kw { color: #f472b6; }
.tok-num { color: #fbbf24; }
.tok-punct { color: var(--muted); }
.tok-sel { color: #7dd3fc; }
.frame-wrap { flex: 1; min-height: 0; display: flex; justify-content: center; background: #20232b; }
#preview { width: 100%; height: 100%; border: 0; background: #fff; flex: 0 0 auto; }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: rgba(242, 169, 59, .15); font-weight: 600; }

.console { border-top: 1px solid var(--line); background: #2a1416; color: #ffb4b4; font-family: var(--mono); font-size: .8rem; max-height: 35%; overflow: auto; padding: .4rem .75rem; }
.console-title { display: block; text-transform: uppercase; letter-spacing: .04em; font-size: .7rem; color: var(--muted); font-family: var(--sans); }
.console ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.console li { margin: .15rem 0; white-space: pre-wrap; word-break: break-word; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; max-width: 32rem; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 .5rem; font-size: 1.1rem; }
dialog p { margin: .4rem 0; line-height: 1.5; }
.modal-actions { display: flex; gap: .5rem; margin-top: .9rem; flex-wrap: wrap; }
.status { color: var(--accent); min-height: 1.2em; font-size: .9rem; }

.content { max-width: 760px; margin: 2rem auto; padding: 0 1.25rem; line-height: 1.65; }
.content h2 { font-size: 1.15rem; margin: 1.75rem 0 .5rem; }
.content ul, .content ol { padding-left: 1.25rem; }
.content li { margin: .35rem 0; }
.content code { font-family: var(--mono); background: var(--panel); padding: .1em .35em; border-radius: 4px; }
.content a { color: var(--accent); }
details { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .85rem; margin: .5rem 0; background: var(--panel); }
summary { cursor: pointer; font-weight: 600; }
details p { margin: .5rem 0 .25rem; }
.foot { max-width: 760px; margin: 2.5rem auto 2rem; padding: 0 1.25rem; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.author { color: var(--text); }

@media (max-width: 800px) {
  .tool, .tool.layout-lado, .tool.layout-cima { grid-template-columns: 1fr; grid-template-rows: none; height: auto; }
  .divider { display: none; }
  .pane-editor { height: 45vh; }
  .pane-preview { height: 45vh; }
  .top h1 { font-size: 1.15rem; }
}
