:root {
  --bg: #0f1020;
  --bg-accent: #12142a;
  --panel: #171a31;
  --panel-2: #1b1f3a;
  --text: #e7e9ee;
  --muted: #a7adc4;
  --brand: #6d8dff;
  --brand-2: #a06bff;
  --ring: #7aa2fa33;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(1200px 700px at 10% 0%, #141632 0%, var(--bg) 50%, #0b0c19 100%);
  font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.0));
  border-bottom: 1px solid #ffffff14;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 16px; margin: 0; font-weight: 600; letter-spacing: 0.3px; }
.logo {
  width: 32px; height: 32px; display: grid; place-items: center;
  background: conic-gradient(from 210deg, var(--brand), var(--brand-2));
  color: white; font-weight: 800; border-radius: 10px;
  box-shadow: 0 6px 18px rgba(109, 141, 255, 0.35);
}
.subtitle { margin: 0; color: var(--muted); font-size: 12px; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px;
  height: calc(100dvh - 96px);
}

.pane {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid #ffffff10;
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-height: 0;
}

.pane__title {
  padding: 12px 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--muted);
  border-bottom: 1px solid #ffffff12;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.0));
}

.pane__title--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar { display: flex; align-items: center; gap: 8px; }
.toolbar__field { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.input { appearance: none; background: #0b1024; color: var(--text); border: 1px solid #ffffff1a; border-radius: 6px; padding: 4px 6px; }

.btn {
  appearance: none;
  border: 1px solid #ffffff1a;
  background: linear-gradient(180deg, #2a2f5a, #22264a);
  color: #eef2ff;
  padding: 6px 10px;
  border-radius: 8px;
  font: 12px/1 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .15s ease, background .15s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
}
.btn:hover { background: linear-gradient(180deg, #34407a, #293160); }
.btn:active { transform: translateY(1px); }

.editor {
  flex: 1;
  resize: none;
  width: 100%;
  padding: 14px;
  background: transparent;
  color: var(--text);
  border: 0;
  outline: none;
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.editor:focus { box-shadow: inset 0 0 0 2px var(--ring); border-radius: 12px; }


.preview {
  flex: 1;
  padding: 18px 18px 24px;
  overflow: auto;
}
.preview:focus { box-shadow: inset 0 0 0 2px var(--ring); outline: none; border-radius: 12px; }

.preview h1, .preview h2, .preview h3, .preview h4, .preview h5, .preview h6 {
  margin: 0 0 10px;
  line-height: 1.25;
}
.preview h1 { font-size: 28px; color: #eaf0ff; }
.preview h2 { font-size: 22px; color: #e2e8ff; }
.preview h3 { font-size: 18px; color: #dbe2ff; }
.preview h4 { font-size: 16px; color: #d3dcff; }
.preview h5 { font-size: 14px; color: #ccd6ff; }
.preview h6 { font-size: 13px; color: #c4d0ff; text-transform: uppercase; letter-spacing: 0.8px; }

.preview p { margin: 0 0 10px; color: var(--muted); }

.preview ul, .preview ol {
  margin: 0 0 12px 18px;
  padding-left: 18px;
  color: var(--text);
}
.preview li { margin: 6px 0; color: var(--text); }
.preview li.task label { display: inline-flex; align-items: center; gap: 8px; }
.preview li.task input[type="checkbox"] { accent-color: var(--brand); cursor: default; }
.preview a { color: var(--brand); text-decoration: none; }
.preview a:hover { text-decoration: underline; }
.preview h1 .anchor, .preview h2 .anchor, .preview h3 .anchor, .preview h4 .anchor, .preview h5 .anchor, .preview h6 .anchor {
  visibility: hidden;
  margin-left: 8px;
  color: var(--muted);
  text-decoration: none;
}
.preview h1:hover .anchor, .preview h2:hover .anchor, .preview h3:hover .anchor, .preview h4:hover .anchor, .preview h5:hover .anchor, .preview h6:hover .anchor {
  visibility: visible;
}
.preview code {
  background: #0b0e23;
  border: 1px solid #ffffff12;
  padding: 0.1em 0.35em;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.preview img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 8px 0 12px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}

.preview blockquote {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-left: 3px solid #6d8dff88;
  background: rgba(109, 141, 255, 0.06);
  border-radius: 8px;
}
.preview nav.toc {
  border: 1px solid #ffffff1a;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
  background: rgba(255,255,255,0.03);
}
.preview nav.toc ul { margin: 6px 0; padding-left: 16px; }
.preview nav.toc a { text-decoration: none; }
.preview blockquote p { color: #e7ecff; }

.preview pre {
  margin: 0 0 14px;
  background: #0b0e23;
  border: 1px solid #ffffff12;
  border-radius: 10px;
  overflow: auto;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.preview pre code {
  display: block;
  padding: 12px 14px;
  border: 0;
  background: transparent;
}

.preview hr {
  border: 0;
  border-top: 1px solid #ffffff1a;
  margin: 16px 0;
}

.preview table.md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  color: var(--text);
}
.preview .md-table th,
.preview .md-table td {
  border: 1px solid #ffffff1a;
  padding: 8px 10px;
  vertical-align: top;
}
.preview .md-table thead th {
  background: rgba(109,141,255,0.10);
}
.preview .md-table tbody tr:nth-child(odd) td {
  background: rgba(255,255,255,0.02);
}

/* Footnotes */
.preview .footnotes {
  margin-top: 16px;
  padding-top: 8px;
  border-top: 1px dashed #ffffff1a;
  color: var(--muted);
}
.preview .footnotes ol {
  margin: 8px 0 0 18px;
}
.preview .footnotes a.footnote-backref { text-decoration: none; margin-left: 6px; }

.app-footer {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 12px; color: var(--muted); border-top: 1px solid #ffffff14;
  background: linear-gradient(0deg, rgba(255,255,255,0.05), rgba(255,255,255,0.0));
}

@media (max-width: 980px) {
  .split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr; /* dos filas del mismo tamaño */
    height: calc(100dvh - 96px); /* misma lógica que desktop para ocupar alto */
  }
  .pane { min-height: 0; }
  .editor, .preview { min-height: 0; }
}
