:root {
  --ink: #123f50;
  --muted: #5c737b;
  --paper: #fffdfa;
  --surface: #f2f7f5;
  --line: #cfe0de;
  --accent: #007c76;
  --accent-soft: #dff3ef;
  --danger: #a84743;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #e7f4f1 0, transparent 26rem),
    linear-gradient(135deg, #f8fbfa, #edf3f5);
  font-family: "Aptos", "Segoe UI", sans-serif;
}

.app { max-width: 1540px; margin: 0 auto; padding: 42px 28px 54px; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 30px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 10px 26px rgba(20, 63, 80, .07);
}

.site-nav .brand {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  letter-spacing: -.02em;
  text-decoration: none;
}

.nav-links { display: flex; flex-wrap: wrap; gap: 8px; }

.nav-links a {
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.nav-links a:hover { border-color: #aac4c7; color: var(--ink); }
.nav-links a[aria-current="page"] { border-color: #acd5cc; background: var(--accent-soft); color: #00635e; }

header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 30px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}

h1 { margin: 0; padding-bottom: .08em; font-family: Georgia, "Times New Roman", serif; font-size: clamp(30px, 4vw, 48px); line-height: 1.18; letter-spacing: -.035em; }
.lead { max-width: 770px; margin: 14px 0 0; color: var(--muted); font-size: 17px; line-height: 1.55; }

.status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 16px;
  border: 1px solid #acd5cc;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #00635e;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, .86fr) minmax(0, 1.6fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 18px 50px rgba(20, 63, 80, .10);
}

.source { padding: 24px; background: #f0f6f4; border-right: 1px solid var(--line); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-tools { display: flex; align-items: center; gap: 12px; }
.panel-title { margin: 0; font-size: 15px; letter-spacing: .01em; }
.hint { color: var(--muted); font-size: 12px; }

textarea {
  display: block;
  width: 100%;
  min-height: 680px;
  resize: vertical;
  padding: 18px;
  border: 1px solid #b9d2ce;
  border-radius: 14px;
  outline: none;
  background: #173f4e;
  color: #e7f5f2;
  font: 13px/1.55 "SFMono-Regular", Consolas, monospace;
  tab-size: 2;
}

textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 124, 118, .14); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 15px; }
button {
  appearance: none;
  border: 1px solid var(--accent);
  border-radius: 9px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font: 700 13px "Aptos", "Segoe UI", sans-serif;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(0, 99, 94, .19); }
button.secondary { border-color: #aac4c7; background: transparent; color: var(--ink); }
button.secondary:hover { background: #e6f0ef; }
button.compact { padding: 7px 11px; font-size: 12px; }

.preview { min-width: 0; padding: 24px; }
.preview-stage {
  position: relative;
  min-height: 740px;
  overflow: auto;
  border: 1px solid #d9e7e4;
  border-radius: 14px;
  background-color: #fff;
  background-image: radial-gradient(#dbe8e5 1px, transparent 1px);
  background-size: 18px 18px;
}
#diagram { min-width: fit-content; padding: 28px; }
#diagram svg { display: block; max-width: none; height: auto; }

.preview-stage:fullscreen { min-height: 0; height: 100%; border: 0; border-radius: 0; background-color: #fff; }
.preview-stage:fullscreen #diagram { padding: 40px; }

.error { margin: 18px; padding: 15px; border-left: 4px solid var(--danger); background: #fff2f1; color: #7f302c; font: 14px/1.5 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; }

footer { margin-top: 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* Cheatsheet page */
.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 26px;
}

.toc a {
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.toc a:hover { border-color: var(--accent); color: var(--accent); }

.sheet { display: grid; gap: 22px; }

.card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 14px 38px rgba(20, 63, 80, .08);
  scroll-margin-top: 20px;
}

.card h2 { margin: 0 0 8px; font-family: Georgia, "Times New Roman", serif; font-size: 25px; letter-spacing: -.02em; }
.card h3 { margin: 26px 0 10px; font-size: 15px; }
.card h3:first-of-type { margin-top: 20px; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.card p:last-child { margin-bottom: 0; }
.card ul { margin: 0 0 12px; padding-left: 20px; color: var(--muted); font-size: 15px; line-height: 1.65; }
.card li + li { margin-top: 6px; }
.card code { padding: 2px 5px; border-radius: 5px; background: var(--accent-soft); color: #00534f; font: 13px "SFMono-Regular", Consolas, monospace; }
.card a { color: var(--accent); }

.example {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  margin: 0 0 8px;
  border: 1px solid #d9e7e4;
  border-radius: 16px;
}

.example-code { display: flex; flex-direction: column; min-width: 0; background: #173f4e; }
.example-code pre {
  flex: 1 1 auto;
  margin: 0;
  overflow-x: auto;
  padding: 18px;
  color: #e7f5f2;
  font: 13px/1.6 "SFMono-Regular", Consolas, monospace;
  tab-size: 2;
}

.example-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 16px; }
.example-actions button { border-color: #4c7c85; background: #21596a; color: #e7f5f2; }
.example-actions button:hover { background: #2a6b7d; }

.example-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  min-height: 200px;
  padding: 18px;
  border-left: 1px solid #d9e7e4;
  background-color: #fff;
  background-image: radial-gradient(#dbe8e5 1px, transparent 1px);
  background-size: 18px 18px;
}

.example-preview svg { max-width: 100%; height: auto; }
.example-preview .error { margin: 0; }

.ref-table { width: 100%; margin: 0 0 8px; border-collapse: collapse; font-size: 14px; }
.ref-table th, .ref-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ref-table th { color: var(--ink); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.ref-table td:first-child { white-space: nowrap; font: 13px "SFMono-Regular", Consolas, monospace; }
.ref-table td { color: var(--muted); }

.callout {
  margin: 0 0 8px;
  padding: 15px 17px;
  border-left: 4px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: var(--accent-soft);
  color: #00534f;
  font-size: 14px;
  line-height: 1.6;
}

@media (max-width: 980px) {
  .app { padding: 26px 16px 42px; }
  header { display: block; }
  .status { display: inline-flex; margin-top: 18px; }
  .workspace { grid-template-columns: 1fr; }
  .source { border-right: 0; border-bottom: 1px solid var(--line); }
  textarea { min-height: 360px; }
  .preview-stage { min-height: 520px; }
  .example { grid-template-columns: 1fr; }
  .example-preview { border-left: 0; border-top: 1px solid #d9e7e4; }
}
