/* Phase 3: rendered markdown (GitHub-dark inspired), loading skeletons, error states */

/* ---------- Rendered markdown ---------- */
.md { font-size: 16px; line-height: 1.75; color: var(--text); word-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }

.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 1.8em 0 0.7em; font-weight: 650; line-height: 1.3; letter-spacing: -0.01em; }
.md h1 { font-size: 1.9em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.md h2 { font-size: 1.5em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.md h3 { font-size: 1.25em; }
.md h4 { font-size: 1.05em; }
.md h5, .md h6 { font-size: 0.95em; color: var(--text-muted); }

.md p, .md ul, .md ol, .md table, .md pre, .md blockquote, .md details { margin: 0 0 1em; }
.md ul, .md ol { padding-left: 1.6em; }
.md li + li { margin-top: 0.25em; }
.md li > p { margin: 0.4em 0; }

.md a { color: var(--accent); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md strong { font-weight: 650; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.md img { max-width: 100%; height: auto; border-radius: 8px; }
.md mark { background: rgba(255, 214, 102, 0.28); color: inherit; padding: 0.05em 0.25em; border-radius: 4px; }
.md kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.1em 0.45em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
}

/* inline code */
.md code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.18em 0.4em;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

/* code blocks */
.md pre {
  position: relative;
  padding: 16px 18px;
  background: #0a0a0d;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.55;
  scrollbar-width: thin;
}
.md pre code, .md pre code.hljs { padding: 0; background: transparent; font-size: 13.5px; border-radius: 0; }
.md pre[data-lang] { padding-top: 30px; }
.md pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 8px;
  left: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.copy-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s var(--ease), color 0.15s var(--ease);
}
.md pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--text); }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* tables */
.md table { display: block; width: max-content; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.md th, .md td { padding: 8px 14px; border: 1px solid var(--border); text-align: left; }
.md th { background: var(--surface); font-weight: 600; }
.md tr:nth-child(even) td { background: rgba(255, 255, 255, 0.025); }

/* blockquotes */
.md blockquote {
  padding: 4px 18px;
  color: #cfcfd8;
  border-left: 3px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 0 8px 8px 0;
}
.md blockquote > :first-child { margin-top: 0.6em; }
.md blockquote > :last-child { margin-bottom: 0.6em; }

/* click-to-reveal blocks (used by Q&A) */
.md details { }
.md details > summary {
  cursor: pointer;
  display: inline-block;
  padding: 4px 12px;
  color: var(--accent);
  border: 1px solid rgba(138, 180, 255, 0.35);
  border-radius: 8px;
  user-select: none;
  list-style: none;
  transition: background 0.15s var(--ease);
}
.md details > summary::-webkit-details-marker { display: none; }
.md details > summary:hover { background: rgba(138, 180, 255, 0.1); }
.md details[open] > summary { margin-bottom: 0.8em; }

/* task lists */
.md input[type="checkbox"] { margin: 0 0.5em 0.15em -1.1em; accent-color: var(--accent); vertical-align: middle; }
.md li:has(> input[type="checkbox"]) { list-style: none; }

/* footnotes */
.md .footnotes, .md section[data-footnotes] { margin-top: 2.5em; padding-top: 1em; border-top: 1px solid var(--border); font-size: 0.9em; color: var(--text-muted); }
.md section[data-footnotes] > h2 { display: none; }
.md sup { line-height: 0; }

/* table of contents */
.md .toc {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.md .toc > summary { display: block; padding: 0; border: 0; color: var(--text); font-weight: 600; }
.md .toc > summary:hover { background: transparent; }
.md .toc[open] > summary { margin-bottom: 0.5em; }
.md .toc ul { list-style: none; margin: 0; padding: 0; }
.md .toc li { margin: 0; }
.md .toc li.sub { padding-left: 1.2em; }
.md .toc a { color: var(--text-muted); font-size: 14px; }
.md .toc a:hover { color: var(--text); text-decoration: none; }

/* Mermaid */
.mermaid-box {
  margin: 0 0 1em;
  padding: 16px;
  background: #0a0a0d;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.mermaid-box svg { max-width: 100%; height: auto; }
.mermaid-box .mermaid-error { color: #ff8a8a; margin-bottom: 8px; text-align: left; }
.mermaid-box pre { text-align: left; margin: 0; }

/* ---------- Loading skeletons ---------- */
.sk {
  display: block;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.sk-tiles { display: flex; flex-wrap: wrap; gap: 12px; }
.sk-tiles .sk { height: 42px; }
.sk-line { height: 14px; margin-bottom: 12px; }
.sk-title { height: 32px; width: 55%; margin-bottom: 24px; }
.sk-head { height: 22px; width: 70%; margin: 6px 4px 14px; }
.sk-ch { height: 30px; margin: 0 4px 8px; }

/* ---------- Error / notice boxes ---------- */
.notice {
  max-width: 520px;
  margin: 12vh auto 0;
  padding: 28px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.notice h2 { margin: 0 0 8px; font-size: 20px; }
.notice p { margin: 0 0 16px; color: var(--text-muted); }
.notice code, .notice-inline code { font-family: var(--font-mono); font-size: 0.9em; background: rgba(255,255,255,0.08); padding: 0.1em 0.4em; border-radius: 5px; }
.notice .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.notice-inline { margin: 0 0 1em; padding: 18px 20px; border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--text-muted); }
.notice-inline p { margin: 0 0 12px; }
.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  transition: background 0.18s var(--ease);
}
.btn:hover { background: var(--surface-hover); }

.empty-note { color: var(--text-muted); font-style: italic; }
