:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #202124;
  --body: #3f444b;
  --muted: #6b7280;
  --subtle: #8a9099;
  --line: #e5e7eb;
  --line-soft: #eef0f2;
  --surface: #fafafa;
  --active: #f1f2f4;
  --ink: #111827;
  --sidebar-width: 288px;
  --topbar-height: 64px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  font-size: 15px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.icon-sprite {
  display: none;
}

svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.app-shell {
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: var(--sidebar-width);
  min-height: 100vh;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 0 16px 18px;
}

.brand {
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 750;
}

.brand strong,
.workspace-card strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.brand span,
.workspace-card span {
  display: block;
  margin-top: 2px;
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.2;
}

.search-wrapper {
  position: relative;
}

.search-box {
  display: flex;
  height: 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #9ca3af;
  padding: 0 10px;
  cursor: text;
}

.search-input {
  display: none;
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  padding: 0;
}

.search-input::placeholder {
  color: #9ca3af;
}

.search-box.is-active .search-input {
  display: block;
}

.search-box.is-active .search-placeholder,
.search-box.is-active #searchKbd {
  display: none;
}

.search-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.12);
  max-height: 320px;
  overflow-y: auto;
}

.search-dropdown.is-open {
  display: block;
}

.search-results {
  overflow-y: auto;
  padding: 6px;
}

.search-results:empty::after {
  content: "无匹配结果";
  display: block;
  padding: 16px 12px;
  color: var(--subtle);
  font-size: 13px;
  text-align: center;
}

.search-results .tree-node {
  gap: 0;
}

.search-results .tree-item {
  min-height: 32px;
  font-size: 13px;
}

.search-results .tree-item.search-match {
  background: #fffbe6;
}

.search-box svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.search-box span {
  min-width: 0;
  flex: 1;
  font-size: 13px;
}

kbd {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #7b818a;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  padding: 5px 7px;
}

.nav-group,
.catalog-tree {
  display: grid;
  gap: 2px;
}

.catalog {
  padding-top: 10px;
}

.catalog-header {
  display: grid;
  gap: 8px;
}

.catalog-actions,
.tree-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.catalog-actions {
  padding: 0 10px 4px;
}

.catalog-actions button,
.tree-actions button {
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #fff;
  color: #6b7280;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 6px 7px;
}

.catalog-actions button:hover,
.tree-actions button:hover {
  background: var(--surface);
  color: var(--ink);
}

.tree-actions .danger-action {
  color: #b42318;
}

.tree-actions .danger-action:hover {
  border-color: #f3b7b1;
  background: #fff5f4;
  color: #912018;
}

.nav-item,
.tree-item {
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 10px;
  border-radius: 7px;
  color: #4b5563;
  font-size: 13px;
  padding: 0 10px;
}

.tree-item {
  min-width: 0;
  width: 100%;
  min-height: 32px;
  border: 0;
  background: transparent;
  gap: 8px;
  color: #59616b;
  cursor: pointer;
  text-align: left;
}

.tree-node {
  display: grid;
  gap: 2px;
}

.tree-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-item:hover,
.tree-item:hover {
  background: var(--surface);
}

.nav-item.active,
.tree-item.active,
.tree-item.selected {
  background: var(--active);
  color: var(--ink);
}

.nav-item svg,
.tree-item svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: #8a9099;
}

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

.tree-item.folder {
  color: #4b5563;
  font-weight: 650;
}

.tree-actions {
  position: absolute;
  top: 50%;
  right: 4px;
  z-index: 2;
  flex: 0 0 auto;
  max-width: calc(100% - 18px);
  transform: translateY(-50%);
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.tree-row:hover .tree-actions,
.tree-row:focus-within .tree-actions {
  opacity: 1;
  pointer-events: auto;
}

.active svg,
.selected svg {
  color: var(--ink);
}

.section-label {
  margin: 12px 10px 4px;
  color: #9aa0a6;
  font-size: 11px;
  font-weight: 700;
}

.workspace-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.avatar {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #d7dee8;
}

.page {
  min-height: 100vh;
  padding-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 0 28px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumb svg {
  width: 16px;
  height: 16px;
  color: #b0b5bb;
}

.breadcrumb strong {
  color: var(--text);
  font-weight: 650;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #fff;
  color: #5f6670;
  cursor: pointer;
}

.icon-button.text-action {
  width: auto;
  padding: 0 12px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.icon-button:hover {
  background: var(--surface);
}

.autof-home-button {
  display: inline-grid;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 0 14px;
  letter-spacing: 0.5px;
}

.autof-home-button:hover {
  background: #2b3441;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.menu-button {
  display: none;
}

.editor-toolbar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 9;
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.94);
  padding: 0 28px;
}

.editor-toolbar button {
  min-height: 30px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #fff;
  color: #4b5563;
  cursor: pointer;
  font-size: 13px;
  padding: 0 10px;
}

.editor-toolbar button:hover {
  background: var(--surface);
  color: var(--ink);
}

.editor-toolbar .toolbar-spacer {
  flex: 1;
}

.editor-toolbar #saveState {
  color: var(--subtle);
  font-size: 12px;
}

.editor-toolbar #saveState.is-pending {
  color: #b45309;
}

.toolbar-save {
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  background: var(--line);
  color: var(--subtle);
  cursor: default;
  font-size: 13px;
  font-weight: 650;
  padding: 0 14px;
  transition: background 150ms ease, color 150ms ease;
}

.toolbar-save.is-active {
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}

.toolbar-save.is-active:hover {
  background: #2b3441;
}

.article {
  width: min(760px, calc(100vw - var(--sidebar-width) - 96px));
  margin: 0 auto;
  padding: 58px 0 80px;
}

.article-editor {
  outline: none;
}

.article-editor:focus {
  outline: none;
}

.article-editor:focus-visible {
  outline: none;
}

.article h1 {
  margin: 0;
  color: var(--ink);
  font-size: 38px;
  font-weight: 780;
  line-height: 1.18;
}

.lede {
  margin: 14px 0 0;
  color: var(--body);
  font-size: 16px;
  line-height: 1.78;
}

.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  padding: 9px 12px;
}

.notice svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--subtle);
}

section {
  margin-top: 32px;
}

.article h2 {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 730;
  line-height: 1.35;
}

.article p {
  margin: 0 0 18px;
  color: var(--body);
  line-height: 1.85;
}

.article ul {
  display: grid;
  gap: 10px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.article li {
  position: relative;
  color: var(--body);
  line-height: 1.7;
  padding-left: 16px;
}

.article li::before {
  position: absolute;
  top: 0.72em;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--ink);
  content: "";
}

blockquote {
  margin: 18px 0 0;
  border: 1px solid var(--line-soft);
  border-left: 3px solid #d1d5db;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
  padding: 16px 18px;
}

.article-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 34px;
  border-top: 1px solid var(--line-soft);
  padding-top: 18px;
  color: var(--subtle);
  font-size: 13px;
}

.meta-row,
.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

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

.footer-actions a:hover {
  color: var(--ink);
}

.edit-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 18px;
}

.edit-prompt h2 {
  margin: 0 0 5px;
  font-size: 15px;
}

.edit-prompt p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.edit-prompt button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  padding: 9px 16px;
}

.edit-prompt button:hover {
  background: #2b3441;
}

.nav-export-wrapper {
  display: grid;
}

.nav-export-wrapper > .nav-item.is-export-open {
  background: var(--active);
  color: var(--ink);
  border-radius: 7px 7px 0 0;
}

.nav-export-wrapper > .nav-item.is-export-open svg {
  color: var(--ink);
}

.export-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  max-height: 0;
  overflow: hidden;
  background: var(--active);
  border-radius: 0 0 7px 7px;
  padding: 0 10px;
  transition: max-height 200ms ease, padding 200ms ease;
}

.export-panel.is-open {
  max-height: 60px;
  padding: 8px 10px;
}

.export-panel span {
  flex: 1;
  color: var(--body);
  font-size: 12px;
  line-height: 1.4;
}

.export-panel button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  padding: 6px 12px;
}

.export-panel button:hover {
  background: #2b3441;
}

.share-wrapper {
  position: relative;
}

.share-popup {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  width: 260px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.1);
  padding: 18px;
}

.share-popup.is-open {
  display: block;
}

.share-popup-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 10px;
}

.share-popup-text {
  color: var(--body);
  font-size: 13px;
  line-height: 1.7;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: var(--surface);
  user-select: all;
}

.share-popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.share-popup-copy {
  flex: 1;
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  padding: 8px 0;
}

.share-popup-copy:hover {
  background: #2b3441;
}

.share-popup-close {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  padding: 8px 0;
}

.share-popup-close:hover {
  background: var(--active);
  color: var(--ink);
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  :root {
    --topbar-height: 56px;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 160ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: block;
    pointer-events: none;
    background: rgba(17, 24, 39, 0);
    transition: background 160ms ease;
  }

  .sidebar-backdrop.is-open {
    pointer-events: auto;
    background: rgba(17, 24, 39, 0.18);
  }

  .page {
    padding-left: 0;
  }

  .topbar {
    padding: 0 16px;
  }

  .editor-toolbar {
    top: var(--topbar-height);
    overflow-x: auto;
    padding: 0 16px;
  }

  .editor-toolbar span {
    min-width: max-content;
  }


  .menu-button {
    display: inline-grid;
  }

  .breadcrumb {
    position: absolute;
    left: 50%;
    flex-direction: column;
    gap: 1px;
    transform: translateX(-50%);
    font-size: 11px;
    text-align: center;
  }

  .breadcrumb svg {
    display: none;
  }

  .breadcrumb span {
    color: var(--text);
    font-size: 14px;
    font-weight: 650;
  }

  .breadcrumb strong {
    color: var(--subtle);
    font-size: 11px;
    font-weight: 500;
  }

  .header-actions .icon-button:not(:last-child) {
    display: none;
  }

  .tree-actions {
    position: static;
    max-width: none;
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  .article {
    width: min(342px, calc(100vw - 48px));
    padding: 32px 0 56px;
  }

  .article h1 {
    font-size: 30px;
    line-height: 1.2;
  }

  .lede,
  .article p {
    font-size: 15px;
    line-height: 1.78;
  }

  .notice {
    margin-top: 20px;
  }

  section {
    margin-top: 28px;
  }

  .article h2 {
    font-size: 20px;
  }

  .article-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .edit-prompt {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 420px) {
  .sidebar {
    width: min(var(--sidebar-width), 86vw);
  }

  .article {
    width: calc(100vw - 48px);
  }
}
.workspace-card { width: 100%; border: 0; text-align: left; cursor: pointer; font: inherit; }
.notes-legal { padding: 20px 28px 28px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: #7a8178; }
.notes-legal a { color: inherit; text-decoration: none; }
.read-only .catalog-actions, .read-only .tree-actions, .read-only .editor-toolbar, .read-only #resetButton { display: none !important; }
.read-only .article-editor { cursor: default; }
.login-dialog { width: min(420px, calc(100vw - 32px)); border: 1px solid #d8ddd5; border-radius: 18px; padding: 0; box-shadow: 0 24px 80px #17201533; }
.login-dialog::backdrop { background: #17201566; backdrop-filter: blur(4px); }
.login-dialog form { position: relative; display: grid; gap: 16px; padding: 32px; }
.login-dialog h2, .login-dialog p { margin: 0; }
.login-dialog label { display: grid; gap: 8px; font-size: 13px; }
.login-dialog input { padding: 12px 14px; border: 1px solid #cdd5ca; border-radius: 8px; font: inherit; }
.dialog-close { position: absolute; right: 16px; top: 14px; border: 0; background: none; font-size: 24px; cursor: pointer; }
.login-submit { padding: 12px; border: 0; border-radius: 8px; background: #263c2c; color: #fff; cursor: pointer; }
.login-message { min-height: 18px; color: #a33; font-size: 12px; }
