/* Markdown69 — cheat sheet stylesheet */

:root {
  --accent: #1eaedb;
  --accent-dark: #178db1;
  --bg: #ffffff;
  --bg-soft: #f7f9fa;
  --bg-code: #f1f3f4;
  --text: #24292f;
  --text-soft: #57606a;
  --border: #e1e4e8;
  --border-strong: #d0d7de;
  --shadow: 0 1px 3px rgba(27, 31, 36, .08), 0 8px 24px rgba(27, 31, 36, .06);
  --radius: 10px;
  --mono: 'Roboto Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --sans: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #4fc3e8;
    --accent-dark: #7bd3ef;
    --bg: #0d1117;
    --bg-soft: #161b22;
    --bg-code: #1b222c;
    --text: #e6edf3;
    --text-soft: #9198a1;
    --border: #21262d;
    --border-strong: #30363d;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrapper { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 18px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  background: var(--accent); color: #fff;
  border-radius: 9px; font-weight: 700; font-size: 18px; line-height: 1;
}
.brand-accent { color: var(--accent); }
.brand-mark .brand-accent { color: #fff; }

/* Language switcher */
.lang-switcher { position: relative; }
.lang-switcher summary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; cursor: pointer; list-style: none;
  border: 1px solid var(--border-strong); border-radius: 8px;
  color: var(--text); font-size: 14px; font-weight: 500; user-select: none;
}
.lang-switcher summary::-webkit-details-marker { display: none; }
.lang-switcher summary:hover { border-color: var(--accent); color: var(--accent); }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  margin: 0; padding: 6px; list-style: none;
  min-width: 190px; max-height: 70vh; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow);
}
.lang-menu li { margin: 0; }
.lang-menu a {
  display: block; padding: 8px 12px; border-radius: 7px;
  color: var(--text); font-size: 14px;
}
.lang-menu a:hover { background: var(--bg-soft); text-decoration: none; }
.lang-menu a.current { color: var(--accent); font-weight: 700; }
.lang-menu a.current::after { content: " ✓"; }

/* ---------- Layout ---------- */
.doc-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 48px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}
@media (max-width: 900px) {
  .doc-layout { grid-template-columns: 1fr; gap: 0; padding-top: 24px; }
  .toc { display: none; }
}

/* ---------- TOC ---------- */
.toc { position: relative; }
.toc-inner { position: sticky; top: calc(var(--header-h) + 24px); }
.toc-title {
  margin: 0 0 10px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft);
}
.toc nav ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.toc nav ul ul { border: 0; padding-left: 14px; }
.toc nav li { margin: 0; }
.toc nav a {
  display: block; padding: 4px 0 4px 14px; margin-left: -2px;
  border-left: 2px solid transparent;
  color: var(--text-soft); font-size: 13.5px; line-height: 1.4;
}
.toc nav a:hover { color: var(--accent); text-decoration: none; }
.toc nav a.toc-active { color: var(--accent); border-left-color: var(--accent); font-weight: 500; }

/* ---------- Editor hero ---------- */
.editor-section {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: 40px 0 48px;
}
#editor-title { font-size: 2rem; line-height: 1.2; margin: 0 0 .35em; font-weight: 700; letter-spacing: -.02em; }
.editor-intro { color: var(--text-soft); max-width: 74ch; margin: 0 0 1.6em; font-size: 1.05rem; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .editor-grid { grid-template-columns: 1fr; } }
.editor-pane {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg); box-shadow: var(--shadow);
}
.pane-head {
  padding: 8px 14px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft);
  background: var(--bg-soft); border-bottom: 1px solid var(--border);
}
#md-input, .preview { height: 440px; overflow: auto; }
@media (max-width: 760px) { #md-input, .preview { height: 320px; } }
#md-input {
  width: 100%; padding: 16px; border: 0; outline: none; resize: vertical;
  font-family: var(--mono); font-size: 14px; line-height: 1.6;
  color: var(--text); background: var(--bg); tab-size: 2;
}
.preview { padding: 18px 20px; font-size: 15px; line-height: 1.65; }

/* Rendered preview (markdown-body) */
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 { margin: 1em 0 .4em; font-weight: 700; line-height: 1.25; }
.markdown-body h1 { font-size: 1.7em; border-bottom: 1px solid var(--border); padding-bottom: .2em; }
.markdown-body h2 { font-size: 1.4em; border-bottom: 1px solid var(--border); padding-bottom: .2em; }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body h4 { font-size: 1em; }
.markdown-body h5 { font-size: .9em; }
.markdown-body h6 { font-size: .85em; color: var(--text-soft); }
.markdown-body p { margin: 0 0 .9em; }
.markdown-body ul, .markdown-body ol { margin: 0 0 .9em; padding-left: 1.6em; }
.markdown-body li { margin: .2em 0; }
.markdown-body li input[type=checkbox] { margin-right: .4em; accent-color: var(--accent); }
.markdown-body a { color: var(--accent); }
.markdown-body code {
  font-family: var(--mono); font-size: 85%;
  padding: .18em .4em; background: var(--bg-code);
  border: 1px solid var(--border); border-radius: 5px;
}
.markdown-body pre {
  margin: 0 0 .9em; padding: 12px 14px; overflow-x: auto;
  background: var(--bg-code); border: 1px solid var(--border); border-radius: 8px;
}
.markdown-body pre code { padding: 0; border: 0; background: none; font-size: 13px; }
.markdown-body blockquote {
  margin: 0 0 .9em; padding: .2em 1em; color: var(--text-soft);
  border-left: 4px solid var(--border-strong);
}
.markdown-body table { border-collapse: collapse; margin: 0 0 .9em; font-size: 14px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border-strong); padding: 5px 11px; }
.markdown-body th { background: var(--bg-soft); }
.markdown-body hr { border: 0; border-top: 2px solid var(--border); margin: 1em 0; }
.markdown-body img { max-width: 100%; border-radius: 4px; }
.markdown-body del { color: var(--text-soft); }

/* ---------- Article ---------- */
.doc { min-width: 0; }
.doc > h2.doc-title {
  font-size: 2.1rem; line-height: 1.2; margin: 0 0 .4em; padding-top: 0;
  font-weight: 700; letter-spacing: -.02em;
}
.doc > h2.doc-title + p { font-size: 1.12rem; color: var(--text-soft); margin: 0 0 2.2em; }
.doc > h2 {
  font-size: 1.5rem; margin: 2.4em 0 .3em; padding-top: .3em; font-weight: 700; letter-spacing: -.01em;
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.doc > h2 + p { color: var(--text-soft); margin: .2em 0 1em; }
.doc > p { margin: 0 0 1em; }
.doc ul, .doc ol { padding-left: 1.4em; }

/* Heading anchors */
.doc .anchor, .doc .heading-anchor { display: none; }

/* ---------- Reference tables ---------- */
.doc table.ref {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0 0 1.2em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14.5px;
  table-layout: fixed;
}
.doc table.ref thead th {
  background: var(--bg-soft);
  text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-soft); font-weight: 700;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
}
.doc table.ref th, .doc table.ref td {
  padding: 12px 16px;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.doc table.ref tr:last-child td { border-bottom: 0; }
.doc table.ref td + td, .doc table.ref th + th { border-left: 1px solid var(--border); }
.doc table.ref td.src {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  background: var(--bg-code);
  white-space: pre-wrap;
  word-break: break-word;
  width: 44%;
}
.doc table.ref td.src code { background: none; border: 0; padding: 0; font-size: inherit; white-space: pre-wrap; }
.doc table.ref td.out { background: var(--bg); }

/* Horizontal scroll wrapper so wide reference tables never overflow the page */
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 1.2em; }
.table-scroll > table.ref { margin-bottom: 0; }

/* Live-rendered example cells: tame the scale of demo elements */
.doc .out > :first-child { margin-top: 0; }
.doc .out > :last-child { margin-bottom: 0; }
.doc .out h1, .doc .out h2, .doc .out h3,
.doc .out h4, .doc .out h5, .doc .out h6 { margin: .1em 0; line-height: 1.25; font-weight: 700; }
.doc .out h1 { font-size: 1.5rem; }
.doc .out h2 { font-size: 1.3rem; }
.doc .out h3 { font-size: 1.15rem; }
.doc .out h4 { font-size: 1rem; }
.doc .out h5 { font-size: .9rem; }
.doc .out h6 { font-size: .8rem; color: var(--text-soft); }
.doc .out ul, .doc .out ol { margin: .1em 0; padding-left: 1.3em; }
.doc .out p { margin: .1em 0; }
.doc .out img { vertical-align: middle; border-radius: 4px; }
.doc .out hr { margin: .6em 0; }
.doc .out del { color: var(--text-soft); }

/* Inline code */
.doc code {
  font-family: var(--mono);
  font-size: 85%;
  padding: .18em .4em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 5px;
  white-space: nowrap;
}

/* Fenced code blocks in result cells */
.doc pre {
  margin: .3em 0;
  padding: 12px 14px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
}
.doc pre code { background: none; border: 0; padding: 0; white-space: pre; font-size: inherit; }

/* Blockquote */
.doc blockquote {
  margin: .3em 0;
  padding: .2em 1em;
  color: var(--text-soft);
  border-left: 4px solid var(--border-strong);
}
.doc blockquote blockquote { margin-top: .4em; }

/* Task list */
.doc .out ul.tasklist { list-style: none; padding-left: .2em; }
.doc .out ul.tasklist li { display: flex; align-items: center; gap: .5em; }
.doc .out input[type=checkbox] { accent-color: var(--accent); }

/* Standalone rendered table example */
.doc .out table { border-collapse: collapse; font-size: 13px; }
.doc .out table th, .doc .out table td { border: 1px solid var(--border-strong); padding: 4px 10px; }
.doc .out table th { background: var(--bg-soft); }

/* Copy button on source cells */
.doc td.src { position: relative; }
.copy-btn {
  position: absolute; top: 6px; right: 6px;
  padding: 3px 8px; font-size: 11px; font-family: var(--sans);
  color: var(--text-soft); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: 6px;
  cursor: pointer; opacity: 0; transition: opacity .12s;
}
td.src:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { color: #fff; background: var(--accent); border-color: var(--accent); opacity: 1; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 48px;
  color: var(--text-soft);
  font-size: 13.5px;
}
.site-footer p { margin: 0; }

/* 404 */
.error404 { text-align: center; padding: 12vh 0; }
.error404 h1 { font-size: 5rem; margin: 0; color: var(--accent); }

@media (max-width: 700px) {
  /* keep readable column widths and let the wrapper scroll instead of squeezing */
  .doc table.ref { min-width: 520px; }
}
@media (max-width: 560px) {
  .brand-name { display: none; }
}
