:root {
  --bg: #f4f1eb;
  --panel: #fffdf9;
  --text: #1f1f1d;
  --muted: #6d6a64;
  --line: #ded7ca;
  --accent: #8b352b;
  --accent-soft: #f3e4dd;
  --sidebar: #ece5d8;
  --code: #282520;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  width: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  line-height: 1.65;
  overflow-x: hidden;
}

img,
svg {
  max-width: 100%;
}

a {
  color: inherit;
}

code {
  padding: 0.08rem 0.28rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.92em;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  padding: 1.15rem;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  width: 2.6rem;
  height: 2.6rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: var(--text);
  color: white;
  font-family: Georgia, serif;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.4rem;
  line-height: 1.1;
}

.brand p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.nav {
  display: grid;
  gap: 0.25rem;
  overflow: auto;
  padding: 0.85rem;
  -webkit-overflow-scrolling: touch;
}

.doc-select-wrap {
  display: none;
}

.nav button {
  width: 100%;
  padding: 0.78rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.nav button:hover,
.nav button.active {
  border-color: var(--line);
  background: var(--panel);
}

.nav strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.25;
}

.nav span {
  display: block;
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.sidebar-footer {
  display: grid;
  gap: 0.25rem;
  margin-top: auto;
  padding: 1rem 1.15rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.sidebar-footer a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.usage-note {
  color: var(--text);
  font-weight: 700;
}

.reader {
  min-width: 0;
  background: var(--panel);
}

.reader-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 1.35rem clamp(1.2rem, 4vw, 4rem);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.94);
  backdrop-filter: blur(12px);
}

.kicker {
  margin: 0 0 0.3rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.reader-header h2 {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.reader-header p:not(.kicker) {
  max-width: 760px;
  margin: 0.55rem 0 0;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
  min-width: 170px;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 2.35rem;
  padding: 0.5rem 0.82rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.reader-body {
  width: min(100%, 1100px);
  min-width: 0;
  padding: clamp(1.2rem, 4vw, 4rem);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1.1rem;
  width: min(100%, 1100px);
  padding: 0 clamp(1.2rem, 4vw, 4rem) 2rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.site-footer span:first-child {
  color: var(--accent);
}

.section {
  min-height: 100vh;
  padding: clamp(1.4rem, 5vw, 4rem);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lead {
  max-width: 620px;
  color: var(--muted);
}

.section .site-footer {
  padding: 2rem 0 0;
}

.markdown-body {
  max-width: 900px;
  font-size: 1.06rem;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.8rem 0 0.75rem;
  font-family: Georgia, "Iowan Old Style", serif;
  letter-spacing: -0.025em;
  line-height: 1.14;
}

.markdown-body h1 {
  margin-top: 0;
  font-size: 2.6rem;
}

.markdown-body h2 {
  font-size: 2rem;
}

.markdown-body h3 {
  font-size: 1.42rem;
}

.markdown-body h4 {
  font-size: 1.15rem;
}

.markdown-body p,
.markdown-body li {
  color: #34322e;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.35rem;
}

.markdown-body li {
  margin: 0.32rem 0;
}

.markdown-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  margin: 1rem 0 1.2rem;
  border-collapse: collapse;
  font-size: 0.96rem;
  -webkit-overflow-scrolling: touch;
}

.markdown-body th,
.markdown-body td {
  padding: 0.68rem 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  background: #f8f3eb;
}

.markdown-body pre,
.support-view {
  overflow: auto;
  border-radius: 12px;
  background: var(--code);
  color: #f8efe2;
  font-family: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
}

.markdown-body pre {
  padding: 1rem;
}

.mermaid-note {
  margin-top: 1rem;
  color: var(--muted);
  font-weight: 700;
}

.map-view {
  width: 100%;
}

.map-frame {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  -webkit-overflow-scrolling: touch;
}

.map-frame img {
  display: block;
  width: max(100%, 1180px);
  height: auto;
}

.support-tools {
  display: flex;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.support-tools input {
  flex: 1 1 auto;
  min-height: 2.45rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #faf7f1;
  color: var(--text);
  font: inherit;
}

.support-view {
  max-height: calc(100vh - 260px);
  margin: 0;
  padding: 1rem;
  white-space: pre-wrap;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    height: auto;
    top: 0;
    z-index: 5;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding: 0.72rem 0.85rem 0.58rem;
  }

  .brand-mark {
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 8px;
    font-size: 0.9rem;
  }

  .brand h1 {
    font-size: 1.1rem;
  }

  .brand p {
    font-size: 0.78rem;
  }

  .doc-select-wrap {
    display: grid;
    gap: 0.3rem;
    padding: 0 0.85rem 0.75rem;
  }

  .doc-select-wrap span {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .doc-select-wrap select {
    width: 100%;
    min-height: 2.55rem;
    padding: 0.55rem 2.2rem 0.55rem 0.72rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-size: 16px;
  }

  .nav {
    display: none;
  }

  .sidebar-footer {
    display: none;
  }

  .reader-header {
    position: static;
    display: block;
    padding: 0.95rem 0.95rem 0.85rem;
  }

  .reader-header h2 {
    font-size: clamp(1.55rem, 8vw, 2.3rem);
  }

  .reader-header p:not(.kicker) {
    display: none;
  }

  .actions {
    justify-content: flex-start;
    margin-top: 1rem;
    min-width: 0;
  }

  .reader-body {
    width: 100%;
    max-width: 100vw;
    padding: 0.9rem 0.95rem 2.5rem;
  }

  .site-footer {
    width: 100%;
    padding: 0 0.95rem 1.6rem;
  }

  .markdown-body {
    max-width: none;
    font-size: 1rem;
  }

  .markdown-body h1 {
    font-size: 2rem;
  }

  .markdown-body h2 {
    font-size: 1.55rem;
  }

  .markdown-body h3 {
    font-size: 1.22rem;
  }

  .support-view {
    max-height: none;
  }

  .map-frame {
    overflow: hidden;
  }

  .map-frame img {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 560px) {
  .brand {
    padding-inline: 0.75rem;
  }

  .doc-select-wrap {
    padding-inline: 0.75rem;
  }

  .actions {
    gap: 0.45rem;
  }

  .actions .button {
    flex: 1 1 calc(50% - 0.45rem);
    justify-content: center;
    padding-inline: 0.55rem;
  }

  .support-tools {
    flex-direction: column;
  }

  .support-tools input,
  .support-tools .button {
    width: 100%;
    font-size: 16px;
  }

  .markdown-body {
    font-size: 0.98rem;
  }

  .markdown-body ul,
  .markdown-body ol {
    padding-left: 1.1rem;
  }

  .markdown-body th,
  .markdown-body td {
    padding: 0.58rem 0.62rem;
  }
}
