/* ==========================================================================
   阅读外壳样式（index.htm）
   设计要点：亮/暗双主题、侧栏可拖拽、移动端抽屉、纯 CSS 图标不用图片
   ========================================================================== */

:root {
  --shell-bg: #ffffff;
  --shell-side-bg: #f7f8fa;
  --shell-text: #1f2328;
  --shell-text-dim: #656d76;
  --shell-border: #e3e6ea;
  --shell-hover: rgba(0, 0, 0, .045);
  --shell-active: rgba(37, 99, 235, .10);
  --shell-accent: #2563eb;
  --shell-accent-soft: #dbe6fe;
  --shell-shadow: 0 8px 28px rgba(15, 23, 42, .14);
  --shell-header-h: 52px;
  --shell-radius: 8px;
  --shell-ui-font: 14px;
  --shell-content-font: 16px;
  color-scheme: light;
}

[data-theme="dark"] {
  --shell-bg: #16181d;
  --shell-side-bg: #1b1e24;
  --shell-text: #e6e8eb;
  --shell-text-dim: #9aa3ad;
  --shell-border: #2b2f37;
  --shell-hover: rgba(255, 255, 255, .06);
  --shell-active: rgba(110, 168, 254, .16);
  --shell-accent: #6ea8fe;
  --shell-accent-soft: #22304a;
  --shell-shadow: 0 8px 28px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  background: var(--shell-bg);
  color: var(--shell-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
               "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  font-size: var(--shell-ui-font);
  overflow: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------------- 顶栏 */

.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--shell-header-h);
  padding: 0 10px;
  border-bottom: 1px solid var(--shell-border);
  background: var(--shell-bg);
  position: relative;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  text-decoration: none;
  color: var(--shell-text);
  padding: 4px 8px 4px 2px;
  border-radius: var(--shell-radius);
  white-space: nowrap;
  flex: 0 0 auto;
}

.brand:hover { background: var(--shell-hover); }

.brand-title { font-size: 15px; font-weight: 700; letter-spacing: .2px; }

.brand-version {
  font-size: 11px;
  font-weight: 500;
  color: var(--shell-text-dim);
}

.icon-button,
.command-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--shell-radius);
  background: transparent;
  color: var(--shell-text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  flex: 0 0 auto;
}

.icon-button:hover, .command-button:hover { background: var(--shell-hover); }
.icon-button:active, .command-button:active { transform: translateY(1px); }

.icon {
  width: 17px; height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon-panel-close { display: none; }
body.sidebar-collapsed .icon-menu { display: none; }
body.sidebar-collapsed .icon-panel-close { display: block; }

/* 主题按钮：按当前主题显示对应图标 */
.theme-icon-light, .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: block; }
[data-theme="dark"] .theme-icon-dark { display: block; }
[data-theme-mode="system"] .theme-icon-system { display: block; }
[data-theme-mode="system"] .theme-icon-light,
[data-theme-mode="system"] .theme-icon-dark { display: none; }

/* ---------------------------------------------------------------- 搜索框 */

.global-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1 1 320px;
  max-width: 620px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--shell-border);
  border-radius: 17px;
  background: var(--shell-side-bg);
  color: var(--shell-text-dim);
}

.global-search:focus-within {
  border-color: var(--shell-accent);
  background: var(--shell-bg);
  box-shadow: 0 0 0 3px var(--shell-active);
}

.global-search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--shell-text);
  font: inherit;
  font-size: 13.5px;
}

.global-search kbd {
  font: 500 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--shell-text-dim);
  border: 1px solid var(--shell-border);
  border-radius: 5px;
  padding: 4px 5px;
  background: var(--shell-bg);
  white-space: nowrap;
}

.global-search-help {
  display: none;
  position: absolute;
  top: 42px;
  left: 0;
  right: 0;
  padding: 10px 12px;
  border: 1px solid var(--shell-border);
  border-radius: var(--shell-radius);
  background: var(--shell-bg);
  box-shadow: var(--shell-shadow);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--shell-text-dim);
  z-index: 40;
}

.global-search:focus-within .global-search-help { display: block; }
.global-search-help code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--shell-side-bg);
  color: var(--shell-text);
  font-size: 12px;
}

.header-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }

/* ---------------------------------------------------------------- 字体调整 */

.font-adjust-control { position: relative; }

.font-adjust-glyph {
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}

.font-adjust-menu,
.more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 268px;
  padding: 14px;
  border: 1px solid var(--shell-border);
  border-radius: 10px;
  background: var(--shell-bg);
  box-shadow: var(--shell-shadow);
  z-index: 50;
}

.font-adjust-menu[hidden], .more-menu[hidden] { display: none; }

.font-adjust-title,
.more-menu label {
  font-size: 12px;
  font-weight: 600;
  color: var(--shell-text-dim);
  margin-bottom: 10px;
  display: block;
}

.more-menu { width: 220px; padding: 12px; }
.more-menu label { margin-bottom: 6px; }

.more-menu select {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--shell-border);
  border-radius: 6px;
  background: var(--shell-bg);
  color: var(--shell-text);
  font: inherit;
  font-size: 13px;
  margin-bottom: 10px;
}

.menu-command {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--shell-text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.menu-command:hover { background: var(--shell-hover); }
.menu-command output { color: var(--shell-text-dim); font-size: 12px; }

.font-slider-group { margin-bottom: 14px; }
.font-slider-group:last-of-type { margin-bottom: 8px; }

.font-slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 6px;
}

.font-slider-label output { color: var(--shell-accent); font-weight: 600; }

.font-size-range {
  width: 100%;
  height: 4px;
  margin: 4px 0;
  border-radius: 2px;
  background: var(--shell-border);
  appearance: none;
  outline: none;
  cursor: pointer;
}

.font-size-range::-webkit-slider-thumb {
  appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--shell-accent);
  border: 2px solid var(--shell-bg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  cursor: pointer;
}

.font-size-range::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--shell-accent);
  border: 2px solid var(--shell-bg);
  cursor: pointer;
}

.font-range-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--shell-text-dim);
}

.font-adjust-help {
  font-size: 11.5px;
  color: var(--shell-text-dim);
  padding-top: 8px;
  border-top: 1px solid var(--shell-border);
}

/* ---------------------------------------------------------------- 布局 */

.app-layout {
  display: flex;
  height: calc(100% - var(--shell-header-h));
  position: relative;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width, 285px);
  flex: 0 0 auto;
  min-width: 0;
  border-right: 1px solid var(--shell-border);
  background: var(--shell-side-bg);
  transition: width .16s ease, margin .16s ease;
}

body.sidebar-collapsed .sidebar { width: 0; border-right: 0; overflow: hidden; }

.sidebar-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--shell-border);
  flex: 0 0 auto;
}

.sidebar-tabs [role="tab"] {
  flex: 1 1 0;
  padding: 7px 4px 9px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--shell-text-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
}

.sidebar-tabs [role="tab"]:hover { color: var(--shell-text); background: var(--shell-hover); }

.sidebar-tabs [role="tab"][aria-selected="true"] {
  color: var(--shell-accent);
  border-bottom-color: var(--shell-accent);
  font-weight: 600;
}

.sidebar-view-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--shell-text-dim);
  border-bottom: 1px solid var(--shell-border);
}

.sidebar-view-label[hidden] { display: none; }

.sidebar-view-label button {
  border: 1px solid var(--shell-border);
  border-radius: 5px;
  background: var(--shell-bg);
  color: var(--shell-text);
  font: inherit;
  font-size: 12px;
  padding: 3px 8px;
  cursor: pointer;
}

.sidebar-view-label button:hover { border-color: var(--shell-accent); color: var(--shell-accent); }

.nav-frame {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  background: var(--shell-side-bg);
}

.sidebar-collapse {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border: 0;
  border-top: 1px solid var(--shell-border);
  background: transparent;
  color: var(--shell-text-dim);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  flex: 0 0 auto;
}

.sidebar-collapse:hover { color: var(--shell-text); background: var(--shell-hover); }

.sidebar-resizer {
  flex: 0 0 5px;
  margin-left: -3px;
  cursor: col-resize;
  background: transparent;
  z-index: 20;
}

.sidebar-resizer:hover, .sidebar-resizer.dragging { background: var(--shell-active); }

body.sidebar-collapsed .sidebar-resizer { display: none; }

.sidebar-restore {
  display: none;
  position: absolute;
  top: 10px;
  left: 8px;
  z-index: 25;
  width: 30px; height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--shell-border);
  border-radius: 6px;
  background: var(--shell-bg);
  color: var(--shell-text-dim);
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .09);
}

body.sidebar-collapsed .sidebar-restore { display: inline-flex; }
.sidebar-restore:hover { color: var(--shell-accent); border-color: var(--shell-accent); }

.content-area {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  background: var(--shell-bg);
}

#content {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--shell-bg);
}

.noscript-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: var(--shell-text-dim);
  line-height: 1.8;
}

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: var(--shell-header-h) 0 0 0;
  border: 0;
  padding: 0;
  background: rgba(0, 0, 0, .38);
  z-index: 26;
  cursor: pointer;
}

.live-region {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* 搜索视图时侧栏加宽一点，结果更好读 */
body.search-view { --search-view: 1; }

/* ---------------------------------------------------------------- 移动端 */

.mobile-search-button { display: none; }
.mobile-action-label { display: none; }

@media (max-width: 860px) {
  :root { --shell-header-h: 50px; }

  .global-search { display: none; }
  .mobile-search-button { display: inline-flex; }
  .mobile-action-label { display: inline; font-size: 13px; }
  .sidebar-toggle { padding: 0 10px; }
  .brand-version { display: none; }
  .font-adjust-control, .print-button { display: none; }

  .sidebar {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    z-index: 28;
    width: min(86vw, 320px);
    box-shadow: var(--shell-shadow);
    transform: translateX(-102%);
    transition: transform .2s ease;
  }

  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .drawer-backdrop { display: block; }
  body.sidebar-collapsed .sidebar { width: min(86vw, 320px); }

  .sidebar-collapse { display: none; }
  .sidebar-resizer { display: none; }
  body.sidebar-collapsed .sidebar-restore { display: inline-flex; }
  .sidebar-restore { top: 8px; left: auto; right: 8px; }
}

/* ---------------------------------------------------------------- 打印 */

@media print {
  .app-header, .sidebar, .sidebar-resizer, .sidebar-restore, .drawer-backdrop { display: none !important; }
  .app-layout { height: auto; }
  .content-area { position: static; }
  body { overflow: visible; }
}
