:root {
  color-scheme: light;
  --accent: #dc6507;
  --accent-strong: #9f3e08;
  --teal: #007f86;
  --ink: #1c252b;
  --muted: #62727d;
  --paper: #fffdf8;
  --shell: #e8ece9;
  --panel: #f7f8f5;
  --line: #d7ddd7;
  --code: #f4efe6;
  --code-line: #eadfce;
  --shadow: 0 18px 46px rgba(30, 39, 42, 0.12);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Aptos, Calibri, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(0, 127, 134, 0.07), transparent 24rem),
    var(--shell);
}

body.nav-shell {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  gap: clamp(12px, 1.2vw, 18px);
  width: min(1480px, calc(100vw - 52px));
  height: 100vh;
  margin: 0 auto;
  padding: clamp(14px, 2vw, 26px) 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.nav-title {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.nav-title h1 {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 23px;
  line-height: 1.05;
  font-weight: 750;
  letter-spacing: 0;
}

.nav-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.search {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfbf8;
}

.search input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #bac6c0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.search input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 127, 134, 0.16);
}

.entry-list {
  overflow: auto;
  padding: 10px 8px 18px;
  scrollbar-width: thin;
}

.entry-list a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid transparent;
  color: #17343c;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.22;
}

.entry-list a + a { margin-top: 2px; }

.entry-list span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-list a:hover,
.entry-list a.active {
  background: #fff;
  border-left-color: var(--accent);
  color: #071215;
  box-shadow: 0 4px 14px rgba(30, 39, 42, 0.08);
}

.viewer {
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.page {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(40px, 5vw, 72px) clamp(36px, 6vw, 96px) 44px;
  background: var(--paper);
  font-size: 15px;
  line-height: 1.55;
}

.page h1 {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.02;
  font-weight: 760;
  letter-spacing: 0;
}

.category {
  display: inline-block;
  margin: 0 0 28px;
  padding: 4px 10px;
  border-left: 4px solid var(--teal);
  background: #eef6f4;
  color: #155b63;
  font-size: 13px;
  font-weight: 700;
}

h2 {
  margin: 28px 0 10px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
  color: #0f1b20;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 760;
}

h2:first-of-type {
  border-top: 0;
  padding-top: 0;
}

h2 span {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

h3 {
  margin: 18px 0 8px;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.2;
  font-weight: 800;
  text-transform: uppercase;
}

p {
  max-width: 94ch;
  margin: 0 0 10px;
  color: #172127;
}

.code {
  max-width: 100%;
  margin: 8px 0 16px;
  padding: 14px 16px;
  overflow-x: auto;
  border: 1px solid var(--code-line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--code);
  white-space: pre-wrap;
  color: #101820;
  font: 13px/1.45 Consolas, "Cascadia Mono", "Courier New", monospace;
}

table {
  width: 100%;
  max-width: 1060px;
  margin: 10px 0 18px;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  font-size: 14px;
}

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

tr:first-child th,
tr:first-child td { border-top: 0; }

th {
  width: 24%;
  min-width: 150px;
  background: #f2f6f3;
  color: #102026;
  font-weight: 760;
}

.entry-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 40px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.entry-nav a {
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #0f6974;
  text-decoration: none;
}

.entry-nav a:hover {
  border-color: var(--teal);
  background: #eef6f4;
}

.function-groups {
  display: grid;
  gap: 22px;
  margin-top: 24px;
}

.function-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf5;
}

.function-section h2 {
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.function-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.function-chip {
  display: block;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #dfe5df;
  border-radius: 6px;
  background: #fff;
  color: #153841;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.function-chip:hover {
  border-color: var(--teal);
  background: #eef6f4;
  color: #06262d;
}

.function-chip.missing {
  color: var(--muted);
  background: #f3f4f1;
}

footer {
  margin: 44px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: left;
  font-size: 13px;
}

.corner { display: none; }

@media (max-width: 980px) {
  body.nav-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 38vh) minmax(0, 1fr);
    width: min(100%, calc(100vw - 30px));
    gap: 14px;
    padding: 15px 0;
  }

  .viewer { min-height: 0; }
  .page { padding: 32px 22px 36px; }
  .entry-nav { grid-template-columns: 1fr; }
  th { min-width: 120px; }
}
