* { box-sizing: border-box; }
:root {
  --bg: #f7f9fc;
  --panel: #ffffff;
  --border: #d8e0ef;
  --text: #1b2430;
  --muted: #5f6f89;
  --hover: #eef3ff;
  --active: #dfe9ff;
  --code-bg: #f2f5fb;
  --pre-bg: #eef2f9;
}

body {
  margin: 0;
  display: grid;
  grid-template-columns: 340px 1fr;
  font-family: Inter, system-ui, Apple SD Gothic Neo, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#backdrop {
  display: none;
}

aside {
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--border);
  padding: 16px;
  background: var(--panel);
}

main {
  height: 100vh;
  overflow: auto;
  padding: 20px;
}

.mobile-topbar {
  display: none;
}

h1 { font-size: 18px; margin: 0 0 12px; }

#q {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

#tree { margin: 12px 0 0; }
.tree-group { margin: 6px 0; }
.tree-folder > summary { list-style: none; cursor: pointer; user-select: none; }
.tree-folder > summary::-webkit-details-marker { display: none; }
.tree-title {
  font-weight: 700;
  font-size: 14px;
  color: #324460;
  padding: 6px 8px 6px 22px;
  border-radius: 8px;
  position: relative;
}
.tree-title::before {
  content: '▸';
  position: absolute;
  left: 8px;
  top: 5px;
  color: #6f86ad;
  font-size: 12px;
  transition: transform .15s ease;
}
.tree-folder[open] > .tree-title::before { transform: rotate(90deg); }
.tree-title:hover { background: var(--hover); }
.tree-sub {
  margin-left: 10px;
  border-left: 1px dashed #c8d4ea;
  padding-left: 10px;
  margin-top: 4px;
}
.tree-item {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: #2d3f5f;
  text-decoration: none;
  font-size: 13px;
  word-break: break-all;
}
.tree-item:hover { background: var(--hover); }
.tree-item.active { background: var(--active); font-weight: 600; color: #18345f; }

article {
  max-width: 980px;
  line-height: 1.72;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
article h1, article h2, article h3 { line-height: 1.3; }
article code { background: var(--code-bg); padding: 2px 6px; border-radius: 6px; }
article pre { background: var(--pre-bg); padding: 14px; border-radius: 10px; overflow: auto; }
article table { border-collapse: collapse; width: 100%; }
article th, article td { border: 1px solid #ccd8ef; padding: 8px; }
#meta { color: var(--muted); font-size: 13px; margin: 0 0 10px; }

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  aside {
    position: fixed;
    left: 0;
    top: 0;
    width: 84vw;
    max-width: 340px;
    height: 100vh;
    transform: translateX(-102%);
    transition: transform .2s ease;
    z-index: 30;
    box-shadow: 0 10px 30px rgba(0,0,0,.15);
  }

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

  #backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 20;
  }

  body.sidebar-open #backdrop {
    display: block;
  }

  main {
    height: auto;
    padding: 12px;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    position: sticky;
    top: 0;
    background: var(--bg);
    padding: 6px 0;
    z-index: 10;
  }

  #menuBtn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 14px;
  }

  .mobile-title {
    font-size: 14px;
    color: var(--muted);
  }

  article {
    padding: 14px;
    border-radius: 10px;
  }
}
