:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #d9e2ec;
  --accent: #c84f00;
  --accent-dark: #9a3b00;
  --link: #0b63ce;
  --code-bg: #f3f6fa;
  --code-border: #d7dee8;
  --output-bg: #fbfbfc;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(circle at top left, #fff7ed 0, transparent 32rem),
    var(--bg);
}

/* Main document card */
.content {
  max-width: 980px;
  margin: 48px auto;
  padding: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

/* Typography */
h1 {
  margin: 0 0 32px;
  padding-bottom: 20px;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.1;
  font-weight: 750;
  letter-spacing: -0.035em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

h2 {
  margin: 44px 0 16px;
  padding-bottom: 8px;
  font-size: 1.55rem;
  line-height: 1.25;
  font-weight: 700;
  color: #111827;
  border-bottom: 2px solid var(--border);
}

h3 {
  margin: 28px 0 12px;
  font-size: 1.2rem;
  line-height: 1.35;
  font-weight: 700;
}

p {
  margin: 0 0 1.15rem;
}

a {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
}

/* Inline code generated as <tt> */
tt,
code {
  padding: 0.12em 0.35em;
  border-radius: 5px;
  background: var(--code-bg);
  color: #9a3412;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.92em;
}

/* Code blocks */
pre {
  margin: 1rem 0 1.5rem;
  padding: 18px 20px;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--code-border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre;
}

pre.codeinput {
  background: var(--code-bg);
}

pre.codeoutput {
  background: var(--output-bg);
  color: #374151;
  border-left: 4px solid #94a3b8;
}

pre.error {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

/* MATLAB syntax highlighting */
span.keyword {
  color: #1d4ed8;
  font-weight: 600;
}

span.comment {
  color: #15803d;
}

span.string {
  color: #9333ea;
}

span.untermstring {
  color: #b91c1c;
}

span.syscmd {
  color: #a16207;
}

/* Lists */
ul,
ol {
  margin: 0 0 1.35rem 1.5rem;
  padding: 0;
}

ul {
  list-style: disc;
}

li {
  margin: 0.35rem 0;
}

/* Contents list */
h2 + div > ul {
  display: grid;
  gap: 0.45rem;
  margin-left: 0;
  padding: 18px 22px;
  list-style: none;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
}

h2 + div > ul li {
  margin: 0;
}

h2 + div > ul a {
  display: block;
  padding: 6px 0;
}

/* Tables */
table {
  width: 100%;
  margin: 1rem 0 1.5rem;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--border);
}

th {
  background: #f1f5f9;
  font-weight: 700;
}

tr:nth-child(even) td {
  background: #fafafa;
}

/* Top navigation */
table.navigation {
  width: 100%;
  margin: 0 0 36px;
  border: 0;
}

table.navigation td {
  border: 0;
  padding: 0;
  background: transparent !important;
}

table.navigation td:first-child {
  text-align: left;
}

table.navigation td:last-child {
  text-align: right;
}

.navigation .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  color: #1f2937;
  font-size: 0.95rem;
  font-weight: 650;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.navigation .nav-link:hover {
  text-decoration: none;
  border-color: #f4a261;
  color: var(--accent-dark);
}

.navigation .nav-link img {
  display: block;
  margin: 0;
  width: 22px;
  height: 22px;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
}

/* Footer */
.footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.footer p {
  margin: 0;
}

.footer a {
  color: var(--muted);
}

/* Mobile */
@media (max-width: 760px) {
  body {
    font-size: 15px;
  }

  .content {
    margin: 0;
    padding: 24px 18px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  table.navigation,
  table.navigation tbody,
  table.navigation tr,
  table.navigation td {
    display: block;
    width: 100%;
  }

  table.navigation td {
    text-align: left !important;
    margin-bottom: 10px;
  }

  .navigation .nav-link {
    width: 100%;
    justify-content: center;
  }

  pre {
    font-size: 0.82rem;
    padding: 14px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .content {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  pre.codeinput,
  pre.codeoutput {
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  .navigation {
    display: none;
  }
}