/* 极简 · 高对比 · 充足留白 */
:root {
  --bg: #FAFAFA;
  --panel: #FFFFFF;
  --line: #E6E6EA;
  --line-soft: #F0F0F3;
  --fg: #16161A;
  --fg-2: #5A5A63;
  --fg-3: #9A9AA4;
  --accent: #0B5FFF;
  --accent-soft: #EAF1FF;
  --warn: #B4530A;
  --radius: 10px;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "SF Pro Display", -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; }

/* ---------------- topbar ---------------- */
.topbar {
  flex: 0 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: .2px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); align-self: center;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.badge {
  font-family: var(--mono); font-size: 11px; letter-spacing: .5px;
  color: var(--fg-2); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 20px;
}

.search-wrap { position: relative; flex: 1 1 auto; max-width: 520px; }
#search {
  width: 100%; height: 34px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #FCFCFD url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'><circle cx='6' cy='6' r='4.2' fill='none' stroke='%239A9AA4' stroke-width='1.4'/><path d='M9.2 9.2L12.5 12.5' stroke='%239A9AA4' stroke-width='1.4' stroke-linecap='round'/></svg>") no-repeat 10px center;
  color: var(--fg); font-family: inherit; font-size: 13px; outline: none;
}
#search:focus { border-color: var(--accent); background-color: #fff; }

.search-results {
  position: absolute; top: 40px; left: 0; right: 0;
  max-height: 380px; overflow: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 12px 28px rgba(16,16,26,.10);
  z-index: 40; padding: 6px;
}
.search-results .item { padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.search-results .item:hover { background: var(--accent-soft); }
.search-results .item .t { font-size: 13px; }
.search-results .item .p { font-family: var(--mono); font-size: 11px; color: var(--fg-3); margin-top: 2px; }
.search-results .empty { padding: 12px; color: var(--fg-3); font-size: 12px; }

.actions { margin-left: auto; display: flex; gap: 8px; }

.ghost {
  height: 30px; padding: 0 12px; line-height: 28px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--fg-2);
  font-size: 12px; font-family: inherit; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------- layout ---------------- */
.layout {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 260px;
}

.sidebar, .toc {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
  min-height: 0;
}
.toc { border-right: none; border-left: 1px solid var(--line); }

.sidebar-head {
  position: sticky; top: 0;
  padding: 14px 16px 10px;
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--fg-3); background: var(--panel);
  border-bottom: 1px solid var(--line-soft);
  display: flex; justify-content: space-between;
}
.count { font-family: var(--mono); text-transform: none; letter-spacing: 0; }

/* ---------------- tree ---------------- */
.tree { padding: 8px 8px 24px; }
.node { user-select: none; }
.row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: 7px; cursor: pointer;
  font-size: 13px; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row:hover { background: var(--line-soft); }
.row.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.row .caret {
  width: 12px; flex: 0 0 12px; color: var(--fg-3);
  font-family: var(--mono); font-size: 10px; text-align: center;
  transition: transform .15s ease;
}
.row.open .caret { transform: rotate(90deg); }
.row .ext {
  margin-left: auto; flex: 0 0 auto;
  font-family: var(--mono); font-size: 10px; color: var(--fg-3);
  text-transform: uppercase;
}
.row .pages { font-family: var(--mono); font-size: 10px; color: var(--fg-3); }
.children { margin-left: 12px; border-left: 1px solid var(--line-soft); padding-left: 4px; }

/* ---------------- viewer ---------------- */
.viewer { overflow: auto; min-height: 0; padding: 24px; background: var(--bg); }

.empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.empty-title { font-size: 15px; font-weight: 500; }
.empty-sub { font-size: 12px; color: var(--fg-3); }

.doc-head {
  display: flex; align-items: flex-end; gap: 16px;
  padding-bottom: 14px; margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.doc-name { font-size: 17px; font-weight: 600; letter-spacing: .2px; word-break: break-all; }
.doc-sub { font-family: var(--mono); font-size: 11px; color: var(--fg-3); margin-top: 4px; }
.doc-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.zoom { font-size: 11px; color: var(--fg-3); display: inline-flex; align-items: center; gap: 6px; }
.zoom select {
  height: 28px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--fg-2); font-family: var(--mono); font-size: 11px; padding: 0 6px;
}

.pages { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.page { position: relative; }
.page img {
  display: block; width: 600px; height: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 1px 2px rgba(16,16,26,.05);
}
.page .no {
  position: absolute; left: 8px; top: 8px;
  font-family: var(--mono); font-size: 10px; color: var(--fg-3);
  background: rgba(255,255,255,.86); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px;
}
.page.target img { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.placeholder { width: 600px; height: 780px; border: 1px dashed var(--line); border-radius: 6px; background: #fff; }

/* ---------------- toc list ---------------- */
.toc-list { padding: 8px 8px 24px; }
.toc-item {
  display: block; width: 100%; text-align: left;
  padding: 6px 10px; border: 0; background: none;
  font-family: inherit; font-size: 12.5px; color: var(--fg-2);
  border-radius: 7px; cursor: pointer; line-height: 1.45;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toc-item:hover { background: var(--line-soft); color: var(--fg); }
.toc-item.active { color: var(--accent); background: var(--accent-soft); }
.toc-item.l2 { padding-left: 22px; }
.toc-item.l3 { padding-left: 34px; }
.toc-item.l4, .toc-item.l5 { padding-left: 46px; }
.toc-item.disabled { opacity: .45; cursor: default; }
.toc-empty { padding: 12px 12px; font-size: 12px; color: var(--fg-3); }

/* ---------------- statusbar ---------------- */
.statusbar {
  flex: 0 0 auto; height: 30px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-top: 1px solid var(--line);
  background: var(--panel); color: var(--fg-3);
  font-family: var(--mono); font-size: 11px;
}
.spacer { flex: 1 1 auto; }

.doc-error {
  max-width: 600px; margin: 40px auto; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 24px;
}
.doc-error-title { font-size: 15px; font-weight: 600; color: var(--warn); }
.doc-error-reason { margin-top: 10px; font-size: 13px; color: var(--fg-2); line-height: 1.6; }
.doc-error-hint { margin-top: 16px; font-size: 12px; color: var(--fg-3); }
.doc-error-hint a { color: var(--accent); text-decoration: none; }

.hidden { display: none !important; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
}
