:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: #f6f7f9;
  color: #1f2328;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
}

button {
  font: inherit;
}

.shell {
  --sidebar-width: 20vw;
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, var(--sidebar-width)) 6px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
}

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

.shell.is-sidebar-collapsed .sidebar,
.shell.is-sidebar-collapsed .resizer {
  border: 0;
  overflow: hidden;
  visibility: hidden;
}

.shell.is-sidebar-collapsed .sidebar {
  min-width: 0;
}

.sidebar {
  min-width: 0;
  border-right: 1px solid #d8dee4;
  background: #ffffff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 14px 14px 12px 16px;
  border-bottom: 1px solid #d8dee4;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 12px;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.header-actions form {
  margin: 0;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
}

.sidebar-header p {
  margin: 0;
  color: #656d76;
  font-size: 12px;
}

.sidebar-status:empty {
  display: none;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #f6f8fa;
  color: #24292f;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.icon-button:hover {
  background: #eef1f4;
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.refresh-action {
  width: 100%;
  min-height: 38px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #f6f8fa;
  color: #24292f;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
}

.refresh-action:hover {
  background: #eef1f4;
}

.refresh-action:disabled {
  cursor: wait;
  opacity: 0.72;
}

.tree {
  padding: 10px 8px 24px;
  overflow: auto;
  flex: 1;
}

.tree-node {
  min-width: 0;
}

.tree-summary {
  color: #24292f;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  line-height: 30px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  user-select: none;
}

.tree-summary:hover {
  background: #f0f3f6;
}

.tree-group {
  margin-left: 14px;
  padding-left: 8px;
  border-left: 1px solid #d8dee4;
}

.tree-item {
  width: 100%;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #57606a;
  cursor: pointer;
  display: block;
  padding: 0 8px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item:hover {
  background: #f0f3f6;
  color: #24292f;
}

.tree-item.is-active {
  background: #0969da;
  color: #ffffff;
}

.tree-empty {
  color: #8c959f;
  font-size: 13px;
  padding: 8px;
}

.resizer {
  background: #eaeef2;
  cursor: col-resize;
  position: relative;
}

.resizer::after {
  content: "";
  position: absolute;
  inset: 0 2px;
  background: transparent;
}

.resizer:hover,
.is-resizing .resizer {
  background: #0969da;
}

.sidebar-restore {
  position: absolute;
  z-index: 4;
  top: 14px;
  left: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #ffffff;
  color: #24292f;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(31, 35, 40, 0.1);
}

.sidebar-restore:hover {
  background: #f6f8fa;
}

.shell.is-sidebar-collapsed .sidebar-restore {
  display: inline-flex;
}

.preview {
  min-width: 0;
  height: 100vh;
  overflow: auto;
  background: #ffffff;
}

.empty-state {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  color: #57606a;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
  color: #24292f;
  font-size: 22px;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

.markdown-body {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 36px 42px 72px;
  line-height: 1.72;
  font-size: 15px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  line-height: 1.3;
  margin: 28px 0 14px;
}

.markdown-body h1 {
  padding-bottom: 12px;
  border-bottom: 1px solid #d8dee4;
  font-size: 30px;
}

.markdown-body h2 {
  padding-bottom: 8px;
  border-bottom: 1px solid #d8dee4;
  font-size: 23px;
}

.markdown-body h3 {
  font-size: 18px;
}

.markdown-body p {
  margin: 0 0 14px;
}

.markdown-body table {
  width: 100%;
  margin: 18px 0;
  border-collapse: collapse;
  font-size: 14px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid #d8dee4;
  padding: 8px 10px;
  text-align: left;
}

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

.markdown-body pre {
  overflow: auto;
  border-radius: 6px;
  background: #f6f8fa;
  padding: 14px 16px;
}

.markdown-body code {
  border-radius: 4px;
  background: #eff2f5;
  padding: 0.15em 0.35em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

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

.markdown-body blockquote {
  margin: 16px 0;
  padding-left: 14px;
  border-left: 4px solid #d0d7de;
  color: #57606a;
}

.markdown-body img {
  max-width: 100%;
}

.mermaid {
  margin: 24px 0;
  padding: 18px;
  border: 1px solid #d8dee4;
  border-radius: 6px;
  background: #ffffff;
  overflow: auto;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #f6f7f9;
  overflow: auto;
  padding: 24px;
}

.login-panel {
  width: min(100%, 360px);
  padding: 28px;
  border: 1px solid #d8dee4;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(31, 35, 40, 0.08);
}

.login-panel h1 {
  margin: 0;
  font-size: 24px;
}

.login-copy {
  margin: 8px 0 20px;
  color: #656d76;
  font-size: 14px;
}

.login-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #f0b8b8;
  border-radius: 6px;
  background: #fff5f5;
  color: #9a3412;
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: #24292f;
  font-size: 14px;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  height: 38px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 0 10px;
  font: inherit;
}

.login-form input:focus {
  border-color: #0969da;
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.16);
  outline: none;
}

.login-form button {
  height: 40px;
  border: 1px solid #0969da;
  border-radius: 6px;
  background: #0969da;
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
}

.login-form button:hover {
  background: #075ab7;
}

@media (max-width: 760px) {
  .shell {
    --sidebar-width: 42vw;
    grid-template-columns: minmax(180px, var(--sidebar-width)) 6px minmax(0, 1fr);
  }

  .markdown-body {
    padding: 24px 22px 56px;
  }
}
