:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --line: #deded8;
  --muted: #7a7d76;
  --text: #2d2f2c;
  --accent: #236b5d;
  --accent-soft: #e3f0ed;
  --code-bg: #f3f1eb;
  --shadow: 0 18px 45px rgba(37, 42, 38, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 86px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 66px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 251, 248, 0.96);
  padding: 0 26px;
  backdrop-filter: blur(12px);
}

.drawer-toggle,
.drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.drawer-toggle {
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  font-weight: 650;
}

.drawer-toggle:hover,
.drawer-close:hover {
  border-color: #c6c8c1;
  background: #f1f3ef;
}

.toggle-icon {
  color: var(--accent);
  font-size: 17px;
}

.current-doc {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.current-label {
  color: var(--muted);
  font-size: 12px;
}

.current-doc strong {
  overflow: hidden;
  color: #22241f;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-backdrop {
  position: fixed;
  inset: 66px 0 0;
  z-index: 18;
  background: rgba(42, 45, 40, 0.14);
}

.doc-drawer {
  position: fixed;
  top: 66px;
  left: 0;
  right: 0;
  z-index: 20;
  max-height: min(58vh, 560px);
  overflow: auto;
  border-bottom: 1px solid var(--line);
  background: #fbfbf8;
  box-shadow: 0 20px 44px rgba(37, 42, 38, 0.15);
}

.drawer-inner {
  width: min(1060px, calc(100% - 44px));
  margin: 0 auto;
  padding: 22px 0 26px;
}

.drawer-close {
  width: 34px;
  height: 34px;
  font-size: 22px;
  line-height: 1;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: calc(100vh - 66px);
}

.outline {
  position: sticky;
  top: 66px;
  height: calc(100vh - 66px);
  overflow: auto;
  background: #fbfbf8;
  border-color: var(--line);
}

.outline {
  border-right: 1px solid var(--line);
  padding: 28px 18px;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.library h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.doc-drawer .file-tree {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  align-items: start;
  gap: 8px 14px;
}

.file-tree,
.tree-children {
  display: grid;
  gap: 4px;
}

.tree-children {
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid #e4e3de;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #3f423d;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 7px 9px;
}

.tree-row:hover {
  background: #eeeeea;
}

.tree-row.active {
  background: var(--accent-soft);
  color: #174c42;
  font-weight: 600;
}

.tree-item.collapsed > .tree-children {
  display: none;
}

.tree-item.collapsed > .tree-row .tree-icon {
  transform: rotate(-90deg);
}

.tree-icon {
  width: 18px;
  flex: 0 0 auto;
  color: var(--muted);
  text-align: center;
  transition: transform 0.16s ease;
}

.tree-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader {
  min-width: 0;
  padding: 38px clamp(26px, 7vw, 96px) 48px;
}

.empty-state {
  display: grid;
  min-height: calc(100vh - 92px);
  place-items: center;
  color: var(--muted);
  font-size: 17px;
}

.markdown-body {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 58px 64px;
  background: var(--panel);
  border: 1px solid rgba(222, 222, 216, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 16px;
  line-height: 1.78;
  overflow-wrap: anywhere;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  color: #20221f;
  line-height: 1.35;
  font-weight: 650;
  scroll-margin-top: 86px;
}

.markdown-body h1 {
  margin: 0 0 28px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
  font-size: 31px;
}

.markdown-body h2 {
  margin: 36px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e7e6e1;
  font-size: 24px;
}

.markdown-body h3 {
  margin: 30px 0 10px;
  font-size: 20px;
}

.markdown-body h4 {
  margin: 26px 0 8px;
  font-size: 17px;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table {
  margin: 0 0 16px;
}

.markdown-body a {
  color: #1b6f8f;
  text-decoration: none;
  border-bottom: 1px solid rgba(27, 111, 143, 0.3);
}

.markdown-body a:hover {
  border-bottom-color: currentColor;
}

.model-link {
  display: inline;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.model-link code {
  color: #1b6f8f;
}

.model-link:hover code {
  text-decoration: underline;
}

.markdown-body code {
  border-radius: 4px;
  background: var(--code-bg);
  color: #8b3f20;
  font-family: Consolas, "Cascadia Code", "Courier New", monospace;
  font-size: 0.9em;
  padding: 0.14em 0.36em;
}

.markdown-body pre {
  overflow: auto;
  border-radius: 6px;
  background: #292d2f;
  color: #f2f2ec;
  padding: 17px 19px;
  line-height: 1.62;
}

.markdown-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.markdown-body .mermaid {
  overflow: auto;
  border: 1px solid #d7d8d2;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  text-align: center;
  padding: 18px;
}

.markdown-body .mermaid svg {
  max-width: 100%;
  height: auto;
}

.markdown-body .mermaid-fallback {
  text-align: left;
  white-space: pre;
}

.markdown-body blockquote {
  border-left: 4px solid #b8c9c4;
  background: #f7faf8;
  color: #59605b;
  padding: 11px 16px;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid #d7d8d2;
  padding: 8px 11px;
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  background: #f1f3ef;
  font-weight: 650;
}

.markdown-body tr:nth-child(even) td {
  background: #fbfbf8;
}

.markdown-body hr {
  height: 1px;
  border: 0;
  background: var(--line);
  margin: 30px 0;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 6px;
}

.update-notice {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: min(460px, calc(100vw - 32px));
  border: 1px solid #c8d8d4;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgba(37, 42, 38, 0.16);
  padding: 14px 14px 14px 16px;
}

.update-notice strong {
  display: block;
  margin-bottom: 3px;
  color: #174c42;
  font-size: 14px;
}

.update-notice span {
  color: var(--muted);
  font-size: 13px;
}

.notice-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.notice-actions button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 0 12px;
}

.notice-actions button:first-child {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.notice-actions button:hover {
  filter: brightness(0.97);
}

.outline-title {
  margin-bottom: 14px;
  color: #494c47;
  font-size: 14px;
  font-weight: 700;
}

#outlineNav {
  display: grid;
  gap: 3px;
}

.outline-link {
  display: block;
  width: 100%;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
  text-align: left;
  padding: 5px 0 5px 10px;
}

.outline-link:hover {
  border-left-color: var(--accent);
  color: var(--accent);
}

.outline-level-2 {
  padding-left: 20px;
}

.outline-level-3,
.outline-level-4,
.outline-level-5,
.outline-level-6 {
  padding-left: 30px;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 14px;
  }

  .drawer-inner {
    width: calc(100% - 28px);
  }

  .doc-drawer .file-tree {
    grid-template-columns: 1fr;
  }

  .app-shell {
    display: block;
  }

  .outline {
    position: static;
    height: auto;
    max-height: 34vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px 14px;
  }

  .reader {
    padding: 18px 12px 28px;
  }

  .markdown-body {
    padding: 28px 20px 36px;
    border-radius: 6px;
    font-size: 15px;
  }

  .update-notice {
    right: 12px;
    bottom: 12px;
    left: 12px;
    align-items: stretch;
    flex-direction: column;
  }

  .notice-actions {
    justify-content: flex-end;
  }
}
