:root {
  font-family: ui-monospace, 'SF Mono', Menlo, Monaco, monospace;
  color-scheme: dark;
  --bg: #050507;
  --fg: #e5e5e5;
  --muted: #888;
  --dim: #555;
  --border: #1f1f26;
  --border-hover: #2a2a33;
  --accent: #4ade80;
  --danger: #f87171;
  --input: #0d0d13;
  --code: #11111a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: radial-gradient(ellipse at top, #0a0a14 0%, var(--bg) 70%);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 1.25rem;
  gap: 1rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand h1 {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff, #888);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand h1::before {
  content: '> ';
  color: var(--accent);
  -webkit-text-fill-color: var(--accent);
}

.home-link {
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.15s;
}
.home-link:hover { opacity: 0.75; }

.tagline { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }

.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

button {
  font-family: inherit;
  font-size: 0.8rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
button:hover { background: rgba(74, 222, 128, 0.08); }

.split {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 0;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: #0a0a10;
}

.pane-header .meta {
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.72rem;
}

#input {
  flex: 1;
  font-family: inherit;
  font-size: 0.9rem;
  background: transparent;
  color: var(--fg);
  border: none;
  padding: 1rem 1.1rem;
  resize: none;
  outline: none;
  line-height: 1.6;
  min-height: 0;
}

.preview {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  font-family: -apple-system, system-ui, 'Segoe UI', sans-serif;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--fg);
  min-height: 0;
}

.preview h1, .preview h2, .preview h3, .preview h4 {
  margin: 1.4em 0 0.5em;
  line-height: 1.25;
  color: #fff;
}
.preview h1:first-child, .preview h2:first-child, .preview h3:first-child { margin-top: 0; }
.preview h1 { font-size: 1.8rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.preview h2 { font-size: 1.4rem; border-bottom: 1px solid var(--border); padding-bottom: 0.2em; }
.preview h3 { font-size: 1.15rem; }
.preview p { margin: 0.7em 0; }
.preview a { color: var(--accent); text-decoration: none; }
.preview a:hover { text-decoration: underline; }
.preview ul, .preview ol { margin: 0.7em 0 0.7em 1.5em; }
.preview li { margin: 0.25em 0; }
.preview blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.2em 0 0.2em 1em;
  margin: 0.8em 0;
  color: var(--muted);
}
.preview code {
  font-family: ui-monospace, Menlo, monospace;
  background: var(--code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-size: 0.85em;
}
.preview pre {
  background: var(--code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.9em 1em;
  overflow-x: auto;
  margin: 0.8em 0;
}
.preview pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}
.preview table {
  border-collapse: collapse;
  margin: 0.8em 0;
  width: 100%;
}
.preview th, .preview td {
  border: 1px solid var(--border);
  padding: 0.45em 0.75em;
  text-align: left;
}
.preview th { background: #0a0a10; }
.preview hr { border: none; border-top: 1px solid var(--border); margin: 1.4em 0; }
.preview img { max-width: 100%; border-radius: 6px; }

.mermaid-block {
  background: var(--code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1em;
  margin: 0.8em 0;
  text-align: center;
  overflow-x: auto;
}
.mermaid-block svg { max-width: 100%; height: auto; }
.mermaid-error {
  color: var(--danger);
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  text-align: left;
}

footer {
  text-align: center;
  padding-top: 0.25rem;
}
footer a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}
footer a:hover { color: var(--accent); }

@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .pane { min-height: 40vh; }
}
