@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/dm-sans-regular.ttf") format("truetype");
}

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/dm-sans-medium.ttf") format("truetype");
}

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/dm-sans-semibold.ttf") format("truetype");
}

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/dm-sans-bold.ttf") format("truetype");
}

@font-face {
  font-family: "DM Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/dm-mono-regular.ttf") format("truetype");
}

@font-face {
  font-family: "DM Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/dm-mono-medium.ttf") format("truetype");
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/playfair-display-semibold.ttf") format("truetype");
}

@font-face {
  font-family: "Playfair Display";
  font-style: italic;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/playfair-display-semibold-italic.ttf") format("truetype");
}

@font-face {
  font-family: "Playfair Display";
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/playfair-display-bold-italic.ttf") format("truetype");
}

:root {
  --paper: #f4efe7;
  --paper-deep: #e9e0d4;
  --ink: #272421;
  --muted: #8b8176;
  --line: rgba(65, 55, 46, .12);
  --accent: #ef745e;
  --accent-deep: #cf5648;
  --sidebar: #2f302c;
  --sidebar-ink: #f3eee6;
  --sidebar-muted: #999b91;
  --code: #292a27;
  --shadow: 0 25px 60px rgba(76, 57, 41, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "DM Sans", sans-serif;
  transition: background .25s ease, color .25s ease;
}

body.dark {
  --paper: #242522;
  --paper-deep: #30312d;
  --ink: #eee8df;
  --muted: #aaa49a;
  --line: rgba(244, 239, 231, .13);
  --sidebar: #191a18;
  --sidebar-ink: #f3eee6;
  --sidebar-muted: #898d84;
  --code: #171815;
  --shadow: 0 25px 60px rgba(0, 0, 0, .2);
}

.login-screen {
  position: relative;
  display: grid;
  min-height: 100vh;
  padding: 48px 24px;
  overflow: hidden;
  place-items: center;
  background:
    radial-gradient(circle at 16% 16%, rgba(239,116,94,.21), transparent 28%),
    radial-gradient(circle at 82% 78%, rgba(109,140,155,.20), transparent 32%),
    var(--paper);
}
.login-screen::before {
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(65,55,46,.10);
  border-radius: 24px;
  content: "";
  pointer-events: none;
}
.login-backdrop {
  position: absolute;
  width: min(56vw, 760px);
  aspect-ratio: 1;
  border: 1px solid rgba(65,55,46,.12);
  border-radius: 50%;
  pointer-events: none;
}
.login-backdrop-one { top: -36%; right: -13%; }
.login-backdrop-two { bottom: -42%; left: -15%; border-color: rgba(239,116,94,.26); }
.login-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 480px);
  max-height: calc(100vh - 36px);
  padding: clamp(28px, 4vw, 42px);
  overflow-y: auto;
  background: rgba(250,247,241,.78);
  border: 1px solid rgba(65,55,46,.13);
  border-radius: 20px;
  box-shadow: 0 36px 90px rgba(76,57,41,.16), inset 0 1px rgba(255,255,255,.8);
  backdrop-filter: blur(18px);
}
.login-brand { display: flex; align-items: center; gap: 13px; }
.login-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #302f2b;
  background: var(--accent);
  border-radius: 13px 13px 13px 3px;
  font-family: "Playfair Display", serif;
  font-size: 27px;
  font-weight: 700;
}
.login-brand h1 { margin: 0; font-family: "Playfair Display", serif; font-size: 25px; letter-spacing: -.04em; }
.login-eyebrow { margin: 0 0 3px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 9px; letter-spacing: .13em; }
.login-intro { margin: clamp(32px, 5vw, 46px) 0 25px; }
.login-intro h2 {
  margin: 14px 0 16px;
  font-family: "Playfair Display", serif;
  font-size: clamp(35px, 4.3vw, 46px);
  font-weight: 600;
  letter-spacing: -.06em;
  line-height: 1.04;
}
.login-intro h2 em { color: var(--accent-deep); font-style: italic; }
.login-intro > p:last-child { max-width: 330px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.login-form { display: grid; gap: 6px; }
.login-form label { margin-top: 6px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: .05em; }
.login-form input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255,255,255,.54);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  font-size: 14px;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.login-form input::placeholder { color: #aca297; }
.login-form input:hover { border-color: rgba(207,86,72,.38); }
.login-form input:focus { background: #fffdf9; border-color: var(--accent-deep); box-shadow: 0 0 0 4px rgba(239,116,94,.13); }
.login-error { min-height: 18px; margin: 5px 0 -2px; color: #b44337; font-size: 12px; line-height: 1.5; }
.login-submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 46px;
  margin-top: 12px;
  padding: 0 17px 0 19px;
  color: #fffaf4;
  background: var(--accent-deep);
  border: 1px solid var(--accent-deep);
  border-radius: 10px;
  box-shadow: 0 13px 26px rgba(207,86,72,.24);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
.login-submit:hover:not(:disabled) { background: #b8483c; box-shadow: 0 16px 32px rgba(207,86,72,.3); transform: translateY(-2px); }
.login-submit:disabled { cursor: wait; opacity: .72; }
.login-submit span:last-child { font-size: 22px; font-weight: 400; line-height: 1; }
.login-footnote { margin: 20px 0 0; color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; text-align: center; }
body.reader-authenticated .login-screen { display: none; }
body:not(.reader-authenticated) .app-shell { display: none; }
body.dark .login-panel { background: rgba(43,44,40,.78); border-color: rgba(244,239,231,.13); box-shadow: 0 36px 90px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.06); }
body.dark .login-form input { background: rgba(0,0,0,.14); }
body.dark .login-form input:focus { background: rgba(0,0,0,.26); }

button, input { font: inherit; }
button { cursor: pointer; }
button, a, select { -webkit-tap-highlight-color: transparent; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 290px) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns .28s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 44px minmax(0, 1fr);
}

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 34px 22px 24px;
  color: var(--sidebar-ink);
  background: var(--sidebar);
  overflow: hidden;
  transition: width .28s ease, padding .28s ease, opacity .2s ease;
}

.sidebar-collapsed .sidebar {
  width: 44px;
  min-width: 44px;
  padding: 18px 6px 18px;
  opacity: 1;
  pointer-events: auto;
}

.sidebar::before {
  position: absolute;
  right: -100px;
  bottom: 70px;
  width: 220px;
  height: 220px;
  border: 1px solid rgba(239, 116, 94, .19);
  border-radius: 50%;
  content: "";
}

.sidebar::after {
  position: absolute;
  right: -70px;
  bottom: 100px;
  width: 160px;
  height: 160px;
  border: 1px solid rgba(239, 116, 94, .11);
  border-radius: 50%;
  content: "";
}

.brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  margin: -6px -8px 60px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s ease, box-shadow .2s ease;
}
.brand:hover {
  background: rgba(255,255,255,.05);
}
.brand:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(239,116,94,.45);
}
.brand-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-copy {
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  color: #302f2b;
  background: var(--accent);
  border-radius: 12px 12px 12px 3px;
  font-family: "Playfair Display", serif;
  font-size: 25px;
  font-weight: 700;
}

.brand h1, .sidebar h2 { margin: 0; }
.brand h1 { font-size: 20px; letter-spacing: -.04em; }
.eyebrow {
  margin: 0 0 5px;
  color: var(--sidebar-muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: .16em;
}
.brand .eyebrow { margin-bottom: 2px; }
.inline-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--sidebar-muted);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 9px;
  font-family: "DM Mono", monospace;
  font-size: 12px;
  line-height: 1;
  letter-spacing: .02em;
}
.inline-toggle:hover {
  color: #fff;
  border-color: rgba(239,116,94,.55);
  background: rgba(239,116,94,.12);
}

.sidebar-collapsed .brand {
  justify-content: center;
  margin: -6px -2px 22px;
}
.sidebar-collapsed .brand-main,
.sidebar-collapsed .project-picker,
.sidebar-collapsed .sidebar-heading,
.sidebar-collapsed .search-box,
.sidebar-collapsed .tree-toolbar,
.sidebar-collapsed .tree,
.sidebar-collapsed .sidebar-footer {
  display: none;
}
.sidebar-collapsed .inline-toggle {
  width: 30px;
  height: 30px;
  font-size: 10px;
}

.project-picker {
  position: relative;
  z-index: 1;
  margin: 0 0 30px;
  padding: 13px 12px;
  background: linear-gradient(145deg, rgba(255,255,255,.09), rgba(255,255,255,.045));
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.project-select-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 7px;
  color: #c2c3ba;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: .04em;
}
.project-select-action {
  color: var(--accent);
  letter-spacing: 0;
}
.project-select-wrap {
  position: relative;
}
.project-select-icon {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 1;
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
  transform: translateY(-50%);
}
.project-picker select {
  width: 100%;
  height: 46px;
  padding: 0 38px 0 37px;
  color: var(--sidebar-ink);
  background: rgba(18,19,17,.38);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 11px;
  outline: none;
  font-size: 13px;
  font-weight: 600;
  appearance: none;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.project-select-wrap::after {
  position: absolute;
  top: 50%;
  right: 14px;
  color: var(--accent);
  content: "⌄";
  pointer-events: none;
  transform: translateY(-55%);
}
.project-picker select:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(239,116,94,.58);
}
.project-picker select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239,116,94,.14);
}
.project-picker option { color: var(--ink); background: var(--paper); }

.sidebar-heading {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 21px;
}

.sidebar-heading h2 { font-size: 17px; font-weight: 500; }
.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 17px;
}
.sidebar .icon-button { color: var(--sidebar-muted); border-color: rgba(255,255,255,.12); }
.icon-button:hover { color: var(--accent); border-color: var(--accent); }

.search-box {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 41px;
  padding: 0 11px;
  color: var(--sidebar-muted);
  background: rgba(255, 255, 255, .055);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 9px;
}
.search-box span { font-size: 22px; line-height: 1; transform: translateY(-2px); }
.search-box input {
  min-width: 0;
  flex: 1;
  color: var(--sidebar-ink);
  background: transparent;
  border: 0;
  outline: none;
  font-size: 12px;
}
.search-box input::placeholder { color: #7d8078; }
kbd {
  padding: 3px 5px;
  color: #83867e;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 4px;
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.tree-toolbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  margin: 12px 2px 10px;
}
.tree-toggle-all {
  padding: 6px 10px;
  color: #cdc9c0;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 8px;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: .02em;
}
.tree-toggle-all:hover:not(:disabled) {
  color: #fff;
  border-color: rgba(239,116,94,.55);
  background: rgba(239,116,94,.12);
}
.tree-toggle-all:disabled {
  opacity: .45;
  cursor: default;
}

.tree {
  position: relative;
  z-index: 1;
  flex: 1;
  margin: 20px -8px 20px;
  overflow-y: auto;
}
.tree::-webkit-scrollbar { width: 4px; }
.tree::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }
.tree-folder { margin: 0 0 10px; }
.tree-folder-title {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 10px;
  color: #bcc0b7;
  background: transparent;
  border: 0;
  font-family: "DM Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .01em;
  text-align: left;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}
.tree-folder-title:hover {
  color: var(--sidebar-ink);
  background: rgba(255,255,255,.055);
  border-radius: 7px;
}
.tree-folder-title[aria-expanded="true"] {
  color: #eff0e9;
}
.tree-folder-chevron {
  width: 12px;
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
  text-align: center;
}
.tree-folder-children {
  margin: 0 0 4px 14px;
  padding-left: 8px;
  border-left: 1px solid rgba(255,255,255,.09);
}
.tree-folder-children.hidden { display: none; }
.tree-file {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px 8px 30px;
  color: #d0d2c8;
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  transition: color .2s ease, background .2s ease;
}
.tree-file:hover { color: #fff; background: rgba(255,255,255,.06); }
.tree-file.active { color: #fff4ed; background: rgba(239,116,94,.17); }
.tree-file-icon { color: #858980; font-family: "DM Mono", monospace; font-size: 11px; }
.tree-file.active .tree-file-icon { color: var(--accent); }
.tree-empty, .loading-state { padding: 16px 9px; color: var(--sidebar-muted); font-size: 12px; line-height: 1.6; }
.sidebar-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 18px;
  color: #7f8279;
  border-top: 1px solid rgba(255,255,255,.09);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: .03em;
}
.status-dot { width: 6px; height: 6px; background: #88b57d; border-radius: 50%; box-shadow: 0 0 0 4px rgba(136,181,125,.12); }

.main-content { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  padding: 0 54px;
  border-bottom: 1px solid var(--line);
}
.topbar-leading {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.breadcrumbs { min-width: 0; overflow: hidden; color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs span:last-child { color: var(--ink); }
.breadcrumbs .separator { padding: 0 9px; color: #bbb0a4; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.text-button {
  padding: 5px 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-family: "DM Mono", monospace;
  font-size: 10px;
}
.text-button:hover, .text-button.active { color: var(--accent-deep); }
.topbar .icon-button { color: var(--muted); }
.mobile-menu { display: none; }
.sidebar-backdrop { display: none; }

.reader-canvas {
  position: relative;
  min-height: calc(100vh - 82px);
  padding: 56px clamp(26px, 7vw, 112px) 100px;
}
.reader-fullscreen-toggle {
  position: absolute;
  top: 18px;
  right: 26px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: rgba(244,239,231,.86);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 8px 24px rgba(76,57,41,.08);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease;
}
.reader-fullscreen-toggle:hover {
  color: var(--accent-deep);
  background: var(--paper);
  border-color: rgba(207,86,72,.4);
  transform: translateY(-1px);
}
body.dark .reader-fullscreen-toggle {
  background: rgba(36,37,34,.86);
}
.reader-canvas.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  min-height: 100vh;
  overflow: auto;
  background: var(--paper);
}
.reader-canvas:fullscreen {
  background: var(--paper);
}
.reader-canvas.is-fullscreen .reader-fullscreen-toggle {
  position: fixed;
  top: 22px;
  right: 26px;
}
.welcome-panel {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 600px;
  padding: 80px clamp(30px, 7vw, 110px);
  overflow: hidden;
  background: var(--paper-deep);
  border-radius: 3px;
}
.welcome-copy { position: relative; z-index: 1; max-width: 590px; }
.accent { color: var(--accent-deep); }
.welcome-copy h2 {
  margin: 19px 0 25px;
  font-family: "Playfair Display", serif;
  font-size: clamp(38px, 5.1vw, 66px);
  font-weight: 600;
  letter-spacing: -.055em;
  line-height: 1.06;
}
.welcome-copy h2 em { color: var(--accent-deep); font-style: italic; }
.welcome-description { max-width: 430px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.format-legend { display: flex; gap: 22px; margin-top: 35px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; }
.format-legend span { display: flex; align-items: center; gap: 8px; }
.format-dot { width: 8px; height: 8px; border-radius: 50%; }
.markdown-dot { background: #6d8c9b; }
.plantuml-dot { background: var(--accent); }
.mermaid-dot { background: #5b8def; }
.welcome-orbit { position: absolute; border: 1px solid rgba(68, 61, 53, .14); border-radius: 50%; }
.orbit-one { width: 620px; height: 620px; right: -170px; top: -45px; }
.orbit-two { width: 420px; height: 420px; right: -62px; top: 55px; border-color: rgba(239,116,94,.22); }
.welcome-note { position: absolute; right: 55px; bottom: 34px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 9px; letter-spacing: .08em; }
.note-line { width: 34px; height: 1px; background: var(--accent); }

.document-header { max-width: 1180px; margin: 0 auto 48px; }
.document-kind { display: flex; align-items: center; gap: 8px; color: var(--accent-deep); font-family: "DM Mono", monospace; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.kind-dot { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; }
.document-title { margin: 15px 0 12px; font-family: "Playfair Display", serif; font-size: clamp(35px, 5vw, 61px); font-weight: 600; letter-spacing: -.055em; line-height: 1.05; overflow-wrap: anywhere; }
.document-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; }
.document-meta span + span::before { margin-right: 18px; color: #c5b7a9; content: "·"; }
.document-body { max-width: 1180px; margin: 0 auto; }
.markdown-body { font-size: 16px; line-height: 1.85; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 1.7em 0 .55em; font-family: "Playfair Display", serif; line-height: 1.2; letter-spacing: -.035em; }
.markdown-body h1 { font-size: 38px; }
.markdown-body h2 { padding-bottom: 10px; font-size: 30px; border-bottom: 1px solid var(--line); }
.markdown-body h3 { font-size: 24px; }
.markdown-body p { margin: 0 0 1.25em; }
.markdown-body a { color: var(--accent-deep); text-underline-offset: 3px; }
.markdown-body strong { font-weight: 700; }
.markdown-body code { padding: 3px 6px; color: var(--accent-deep); background: rgba(239,116,94,.09); border-radius: 4px; font-family: "DM Mono", monospace; font-size: .85em; }
.markdown-body pre { margin: 1.5em 0; padding: 20px 22px; overflow-x: auto; color: #ece5dc; background: var(--code); border-radius: 6px; line-height: 1.65; }
.markdown-body pre code { padding: 0; color: inherit; background: transparent; font-size: 12px; }
.mermaid-diagram {
  position: relative;
  min-height: 120px;
  margin: 2.1em 0;
  padding: clamp(18px, 3vw, 32px);
  overflow: auto;
  background: rgba(255,255,255,.42);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
body.dark .mermaid-diagram { background: rgba(255,255,255,.04); }
.mermaid-diagram svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 680px;
  margin: 0 auto;
}
.mermaid-diagram svg text,
.mermaid-diagram svg foreignObject {
  font-family: "DM Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
}
.diagram-card,
.mermaid-diagram {
  position: relative;
}
.diagram-viewport {
  position: relative;
  width: 100%;
}
.diagram-surface {
  display: block;
  width: 100%;
  transform: translate3d(var(--diagram-pan-x, 0px), var(--diagram-pan-y, 0px), 0) scale(var(--diagram-scale, 1));
  transform-origin: 0 0;
  will-change: transform;
  cursor: grab;
}
.diagram-dragging .diagram-surface {
  cursor: grabbing;
}
.diagram-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
}
.diagram-zoom-control,
.diagram-reset-toggle,
.diagram-collapse-toggle,
.diagram-fullscreen-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(244,239,231,.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(76,57,41,.1);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: color .2s ease, background .2s ease, border-color .2s ease, transform .2s ease, opacity .2s ease;
}
.diagram-zoom-control:hover:not(:disabled),
.diagram-reset-toggle:hover,
.diagram-collapse-toggle:hover,
.diagram-fullscreen-toggle:hover {
  color: var(--accent-deep);
  background: var(--paper);
  border-color: rgba(207,86,72,.4);
  transform: translateY(-1px);
}
body.dark .diagram-zoom-control,
body.dark .diagram-reset-toggle,
body.dark .diagram-collapse-toggle,
body.dark .diagram-fullscreen-toggle {
  background: rgba(36,37,34,.88);
}
.diagram-zoom-control:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}
.diagram-zoom-value {
  min-width: 54px;
}
.diagram-reset-toggle,
.diagram-collapse-toggle {
  font-size: 11px;
}
.diagram-reset-toggle {
  display: none;
}
.diagram-card.diagram-fullscreen-active .diagram-reset-toggle,
.mermaid-diagram.diagram-fullscreen-active .diagram-reset-toggle,
.diagram-card.diagram-fullscreen-fallback .diagram-reset-toggle,
.mermaid-diagram.diagram-fullscreen-fallback .diagram-reset-toggle,
.diagram-card:fullscreen .diagram-reset-toggle,
.mermaid-diagram:fullscreen .diagram-reset-toggle {
  display: inline-flex;
}
.diagram-zoom-control[data-zoom="out"],
.diagram-zoom-control[data-zoom="reset"],
.diagram-zoom-control[data-zoom="in"] {
  display: none;
}
.diagram-card.diagram-fullscreen-active .diagram-zoom-control[data-zoom="out"],
.diagram-card.diagram-fullscreen-active .diagram-zoom-control[data-zoom="reset"],
.diagram-card.diagram-fullscreen-active .diagram-zoom-control[data-zoom="in"],
.mermaid-diagram.diagram-fullscreen-active .diagram-zoom-control[data-zoom="out"],
.mermaid-diagram.diagram-fullscreen-active .diagram-zoom-control[data-zoom="reset"],
.mermaid-diagram.diagram-fullscreen-active .diagram-zoom-control[data-zoom="in"],
.diagram-card.diagram-fullscreen-fallback .diagram-zoom-control[data-zoom="out"],
.diagram-card.diagram-fullscreen-fallback .diagram-zoom-control[data-zoom="reset"],
.diagram-card.diagram-fullscreen-fallback .diagram-zoom-control[data-zoom="in"],
.mermaid-diagram.diagram-fullscreen-fallback .diagram-zoom-control[data-zoom="out"],
.mermaid-diagram.diagram-fullscreen-fallback .diagram-zoom-control[data-zoom="reset"],
.mermaid-diagram.diagram-fullscreen-fallback .diagram-zoom-control[data-zoom="in"] {
  display: inline-flex;
}
.diagram-card.diagram-fullscreen-active .diagram-collapse-toggle,
.mermaid-diagram.diagram-fullscreen-active .diagram-collapse-toggle,
.diagram-card.diagram-fullscreen-fallback .diagram-collapse-toggle,
.mermaid-diagram.diagram-fullscreen-fallback .diagram-collapse-toggle,
.diagram-card:fullscreen .diagram-collapse-toggle,
.mermaid-diagram:fullscreen .diagram-collapse-toggle {
  display: none;
}
.diagram-card:fullscreen,
.mermaid-diagram:fullscreen,
.diagram-fullscreen-fallback {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  padding: 68px 24px 24px;
  overflow: hidden;
  background: var(--paper);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.diagram-fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 300;
}
.diagram-card:fullscreen svg,
.mermaid-diagram:fullscreen svg,
.diagram-fullscreen-fallback svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  max-height: none;
  min-width: 0;
  min-height: 0;
  margin: 0 auto;
}
.diagram-card:fullscreen .diagram-viewport,
.mermaid-diagram:fullscreen .diagram-viewport,
.diagram-fullscreen-fallback .diagram-viewport {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}
.diagram-card:fullscreen .diagram-surface,
.mermaid-diagram:fullscreen .diagram-surface,
.diagram-fullscreen-fallback .diagram-surface {
  height: 100%;
}
.diagram-card:fullscreen .diagram-toolbar,
.mermaid-diagram:fullscreen .diagram-toolbar,
.diagram-fullscreen-fallback .diagram-toolbar {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 310;
}
.diagram-card:fullscreen .diagram-zoom-value,
.mermaid-diagram:fullscreen .diagram-zoom-value,
.diagram-fullscreen-fallback .diagram-zoom-value {
  display: inline-flex;
}
.diagram-collapsed .diagram-viewport {
  display: none;
}
.diagram-collapsed-note {
  display: none;
  width: 100%;
  padding: 18px 16px;
  color: var(--muted);
  background: rgba(244,239,231,.55);
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  font-family: "DM Mono", monospace;
  font-size: 11px;
}
body.dark .diagram-collapsed-note {
  background: rgba(255,255,255,.03);
}
.diagram-collapsed .diagram-collapsed-note {
  display: block;
}
.diagram-collapsed.diagram-card,
.diagram-collapsed.mermaid-diagram {
  min-height: 0;
}
.mermaid-error {
  color: #9a4036;
  background: rgba(239,116,94,.08);
  border-color: rgba(239,116,94,.3);
}
.mermaid-error-title { margin-bottom: 8px; font-weight: 700; }
.mermaid-error-message { margin-bottom: 14px; font-size: 12px; line-height: 1.6; }
.mermaid-error pre {
  margin: 0;
  color: #e9e2da;
  background: var(--code);
}
.markdown-body ul, .markdown-body ol { margin: 0 0 1.3em; padding-left: 1.5em; }
.markdown-body li { margin: .35em 0; padding-left: .3em; }
.markdown-body blockquote { margin: 1.5em 0; padding: 3px 0 3px 20px; color: var(--muted); border-left: 2px solid var(--accent); font-family: "Playfair Display", serif; font-size: 20px; font-style: italic; }
.markdown-body hr { margin: 2.5em 0; border: 0; border-top: 1px solid var(--line); }
.image-placeholder { display: block; padding: 25px; color: var(--muted); border: 1px dashed var(--line); text-align: center; font-family: "DM Mono", monospace; font-size: 11px; }
.image-placeholder::before { content: "Image: "; color: var(--accent-deep); }
.plantuml-view { display: grid; gap: 25px; }
.diagram-card { padding: clamp(20px, 4vw, 44px); overflow: auto; background: rgba(255,255,255,.35); border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow); }
body.dark .diagram-card { background: rgba(255,255,255,.04); }
.diagram-card svg { display: block; width: 100%; height: auto; min-height: 420px; }
.diagram-card svg text { font-family: "DM Sans", "PingFang SC", "Microsoft YaHei", sans-serif; }
.diagram-card.diagram-fullscreen-fallback svg {
  min-height: 0;
}
.diagram-collapsed.diagram-card {
  overflow: hidden;
}
.source-card { overflow: hidden; border: 1px solid var(--line); border-radius: 4px; }
.source-card pre { margin: 0; padding: 22px; overflow: auto; color: #e9e2da; background: var(--code); font-family: "DM Mono", monospace; font-size: 12px; line-height: 1.7; }
.error-panel { max-width: 700px; margin: 60px auto; padding: 28px; color: #9a4036; background: rgba(239,116,94,.11); border: 1px solid rgba(239,116,94,.3); }

@media (max-width: 800px) {
  .login-screen { padding: 18px; }
  .login-screen::before { inset: 10px; border-radius: 16px; }
  .login-panel { padding: 30px 27px; border-radius: 16px; }
  .login-intro { margin: 34px 0 24px; }
  .login-intro h2 { font-size: 40px; }
  .app-shell { display: block; }
  .app-shell.sidebar-collapsed { display: block; }
  .sidebar-collapsed .sidebar {
    width: min(290px, calc(100vw - 28px));
    min-width: min(290px, calc(100vw - 28px));
    padding-top: max(34px, calc(34px + env(safe-area-inset-top)));
    padding-right: 22px;
    padding-bottom: max(24px, calc(24px + env(safe-area-inset-bottom)));
    padding-left: 22px;
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar-collapsed .brand { justify-content: space-between; margin-bottom: 66px; }
  .sidebar-collapsed .brand-main { display: flex; }
  .sidebar-collapsed .project-picker,
  .sidebar-collapsed .sidebar-heading,
  .sidebar-collapsed .search-box,
  .sidebar-collapsed .tree-toolbar { display: flex; }
  .sidebar-collapsed .project-picker { display: block; }
  .sidebar-collapsed .tree { display: block; }
  .sidebar-collapsed .sidebar-footer { display: flex; }
  .sidebar { position: fixed; z-index: 10; top: 0; bottom: 0; left: 0; width: min(290px, calc(100vw - 28px)); padding-top: max(34px, calc(34px + env(safe-area-inset-top))); padding-bottom: max(24px, calc(24px + env(safe-area-inset-bottom))); transform: translateX(-100%); transition: transform .25s ease; box-shadow: 15px 0 40px rgba(0,0,0,.18); overscroll-behavior: contain; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 9; display: block; width: 100%; height: 100%; padding: 0; background: rgba(28,29,26,.42); border: 0; opacity: 0; pointer-events: none; transition: opacity .25s ease; }
  .sidebar-backdrop.visible { opacity: 1; pointer-events: auto; }
  body.mobile-sidebar-open { overflow: hidden; }
  .brand { margin: -6px -8px 24px; }
  .sidebar-collapsed .brand { margin-bottom: 24px; }
  .project-picker { margin-bottom: 18px; padding: 10px; }
  .project-select-label { justify-content: flex-start; margin: 0 3px 7px; color: #e0ddd5; font-family: "DM Sans", sans-serif; font-size: 12px; letter-spacing: .02em; }
  .sidebar-heading { display: none; }
  .tree-toolbar { margin-top: 4px; margin-bottom: 4px; }
  .tree { margin-top: 8px; margin-bottom: 16px; }
  .tree-folder { margin-bottom: 4px; }
  .tree-folder-title { padding-top: 10px; padding-bottom: 10px; color: #e2e3dc; font-size: 13px; }
  .topbar { min-height: 64px; padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  .inline-toggle { display: none; }
  .mobile-menu { display: grid; flex: 0 0 42px; width: 42px; height: 42px; margin-right: 2px; border: 0; font-size: 19px; }
  .breadcrumbs { flex: 1; }
  .topbar-actions { flex: 0 0 auto; gap: 6px; }
  .topbar-actions .text-button { max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions .icon-button { width: 40px; height: 40px; }
  .logout-button { display: grid; width: 40px; height: 40px; padding: 0; place-items: center; overflow: hidden; font-size: 0 !important; }
  .logout-button::after { color: currentColor; content: "↪"; font-family: "DM Sans", sans-serif; font-size: 20px; line-height: 1; }
  .reader-canvas { min-height: calc(100vh - 64px); padding: 66px 14px 50px; }
  .reader-fullscreen-toggle { top: 12px; right: 14px; min-height: 40px; padding: 0 11px; }
  .reader-canvas.is-fullscreen { padding: 66px 14px 50px; }
  .diagram-card:fullscreen,
  .mermaid-diagram:fullscreen,
  .diagram-fullscreen-fallback {
    padding: 60px 10px 10px;
  }
  .diagram-toolbar { top: 10px; right: 10px; max-width: calc(100% - 20px); flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
  .diagram-zoom-control,
  .diagram-reset-toggle,
  .diagram-collapse-toggle,
  .diagram-fullscreen-toggle { min-height: 40px; padding: 0 10px; }
  .diagram-card { padding: 16px; }
  .diagram-card svg { min-height: 220px; }
  .mermaid-diagram { margin: 1.6em 0; padding: 14px; }
  .markdown-body { font-size: 15px; line-height: 1.8; }
  .markdown-body h1 { font-size: 31px; }
  .markdown-body h2 { font-size: 26px; }
  .markdown-body h3 { font-size: 22px; }
  .search-box kbd { display: none; }
  .search-box { min-height: 44px; }
  .tree-file, .tree-folder-title { min-height: 44px; }
  .welcome-panel { min-height: calc(100vh - 120px); padding: 50px 28px; }
  .welcome-note { right: 28px; bottom: 24px; }
  .orbit-one { right: -360px; }
  .orbit-two { right: -280px; }
  .document-header { margin-bottom: 32px; }
  .document-title { font-size: 35px; }
}

@media (max-width: 390px) {
  .topbar { padding-right: 8px; padding-left: 8px; }
  .topbar-actions { gap: 2px; }
  .topbar-actions #source-toggle { display: none; }
  .breadcrumbs { font-size: 9px; }
  .reader-canvas { padding-right: 10px; padding-left: 10px; }
  .reader-fullscreen-toggle { right: 10px; }
  .welcome-panel { padding: 42px 22px; }
  .welcome-copy h2 { font-size: 40px; }
  .login-panel { padding-right: 22px; padding-left: 22px; }
}
