/* CTE Offline App Shell — docs-style layout (competitor-inspired) */

:root {
  --cte-sidebar-w: 270px;
  --cte-header-h: 60px;
  --cte-bg: #f6f7f9;
  --cte-panel: #ffffff;
  --cte-border: #e5e7eb;
  --cte-text: #111827;
  --cte-text-sec: #4b5563;
  --cte-text-muted: #9ca3af;
  --cte-accent: #ba2f2a;
  --cte-accent-soft: #fdf2f2;
  --cte-hover: #f3f4f6;
  --cte-radius: 12px;
  --cte-shadow: 0 1px 3px rgba(0,0,0,.06);
  --cte-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-theme="dark"] {
  --cte-bg: #0f0f10;
  --cte-panel: #1a1a1b;
  --cte-border: #2a2a2b;
  --cte-text: #e5e5e5;
  --cte-text-sec: #a1a1aa;
  --cte-text-muted: #71717a;
  --cte-accent: #d74a43;
  --cte-accent-soft: rgba(186,47,42,.12);
  --cte-hover: rgba(255,255,255,.06);
}

html { scroll-behavior: smooth; }

body.cte-offline-app {
  margin: 0;
  font-family: var(--cte-font);
  color: var(--cte-text);
  background: var(--cte-bg);
  line-height: 1.55;
}

/* Hide original product header inside app shell */
body.cte-offline-app .site-header { display: none !important; }
body.cte-offline-app .announcement { display: none !important; }

/* ===== App Header ===== */
.cte-app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--cte-header-h);
  background: var(--cte-panel);
  border-bottom: 1px solid var(--cte-border);
  box-shadow: var(--cte-shadow);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
}

.cte-header-left, .cte-header-right { display: flex; align-items: center; gap: 12px; }

.cte-menu-btn {
  display: none;
  width: 36px; height: 36px;
  border: 1px solid var(--cte-border);
  background: transparent;
  border-radius: 8px;
  color: var(--cte-text-sec);
  font-size: 18px;
  cursor: pointer;
}

.cte-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  color: var(--cte-text);
  font-weight: 700;
  font-size: 15px;
}
.cte-brand img { height: 30px; width: auto; display: block; }
.cte-brand span {
  color: var(--cte-text-sec);
  font-weight: 500;
  padding-left: 10px;
  border-left: 1px solid var(--cte-border);
}

.cte-search-trigger {
  display: flex; align-items: center; gap: 10px;
  background: var(--cte-bg);
  border: 1px solid var(--cte-border);
  border-radius: 999px;
  padding: 7px 14px;
  color: var(--cte-text-muted);
  font-size: 13px;
  cursor: pointer;
  min-width: 180px;
}
.cte-search-trigger svg { width: 16px; height: 16px; flex-shrink: 0; }
.cte-search-trigger kbd {
  margin-left: auto;
  font-family: inherit;
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--cte-border);
  border-radius: 5px;
  background: var(--cte-panel);
}

.cte-theme-btn, .cte-home-link {
  display: inline-flex; align-items: center; justify-content: center;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--cte-border);
  background: var(--cte-panel);
  color: var(--cte-text-sec);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.cte-theme-btn svg { width: 18px; height: 18px; }

/* Logo & Home link removed from shell — hide any residual */
.cte-brand, .cte-home-link { display: none !important; }

/* ===== Sidebar ===== */
.cte-app-sidebar {
  position: fixed;
  top: var(--cte-header-h); left: 0; bottom: 0;
  width: var(--cte-sidebar-w);
  background: var(--cte-panel);
  border-right: 1px solid var(--cte-border);
  overflow-y: auto;
  padding: 18px 0 40px;
  z-index: 150;
}

.cte-sidebar-nav { padding: 0 14px; }

.cte-nav-section { margin-bottom: 22px; }
.cte-nav-section:last-child { margin-bottom: 0; }

.cte-nav-chapter {
  display: flex; align-items: center; gap: 9px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--cte-text-muted);
  padding: 7px 10px;
  margin-bottom: 4px;
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
}
.cte-nav-chapter:hover { background: var(--cte-hover); }
.cte-nav-chapter:focus-visible { outline: 2px solid var(--cte-accent); outline-offset: 1px; }
.cte-nav-chapter .cte-ch-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: inline-flex; color: var(--cte-accent);
}
.cte-nav-chapter .cte-ch-icon svg { width: 18px; height: 18px; }
.cte-nav-chapter .cte-ch-title { flex: 1; min-width: 0; }
.cte-nav-chapter .cte-ch-toggle {
  width: 16px; height: 16px; flex-shrink: 0;
  display: inline-flex; color: var(--cte-text-muted);
  transition: transform .2s ease;
}
.cte-nav-chapter .cte-ch-toggle svg { width: 16px; height: 16px; }
.cte-nav-section.cte-collapsed .cte-nav-list { display: none; }
.cte-nav-section.cte-collapsed .cte-nav-chapter .cte-ch-toggle { transform: rotate(-90deg); }

.cte-nav-list { list-style: none; margin: 0; padding: 0; }
.cte-nav-list li { margin: 1px 0; }
.cte-nav-list a {
  display: flex; align-items: center;
  padding: 7px 10px 7px 14px;
  border-radius: 8px;
  color: var(--cte-text-sec);
  text-decoration: none;
  font-size: 13.5px;
  gap: 9px;
  transition: background .15s ease, color .15s ease;
}
.cte-nav-list a .cte-ico {
  width: 17px; height: 17px; flex-shrink: 0;
  display: inline-flex; color: var(--cte-text-muted);
}
.cte-nav-list a .cte-ico svg { width: 17px; height: 17px; }
.cte-nav-list a.cte-current .cte-ico { color: var(--cte-accent); }
.cte-nav-list a .cte-t-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cte-nav-list a:hover { background: var(--cte-hover); color: var(--cte-text); }
.cte-nav-list a.cte-current {
  background: var(--cte-accent-soft);
  color: var(--cte-accent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--cte-accent);
}

.cte-nav-list .cte-children { list-style: none; padding-left: 14px; margin: 2px 0 0; }
.cte-nav-list .cte-children a { padding-left: 14px; font-size: 13px; }

/* ===== Main Content ===== */
.cte-app-main {
  margin-left: var(--cte-sidebar-w);
  margin-top: var(--cte-header-h);
  min-height: calc(100dvh - var(--cte-header-h));
  padding: 28px 32px 64px;
}

.cte-breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--cte-text-muted);
  margin-bottom: 18px;
}
.cte-breadcrumb a { color: var(--cte-text-sec); text-decoration: none; }
.cte-breadcrumb a:hover { color: var(--cte-accent); text-decoration: underline; }
.cte-breadcrumb span:last-child { color: var(--cte-text); font-weight: 500; }

.cte-content-wrap {
  background: var(--cte-panel);
  border: 1px solid var(--cte-border);
  border-radius: var(--cte-radius);
  box-shadow: var(--cte-shadow);
  padding: 32px;
}

/* Ensure inner containers don't overflow and images scale */
.cte-content-wrap img { max-width: 100%; height: auto; }
.cte-content-wrap .container { max-width: none; margin: 0; padding: 0; }

/* ===== Home Dashboard ===== */
.cte-home-hero { margin-bottom: 28px; }
.cte-home-hero h1 {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 10px;
  letter-spacing: -.02em;
}
.cte-home-hero p {
  margin: 0;
  color: var(--cte-text-sec);
  font-size: 15px;
  max-width: 640px;
}

.cte-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.cte-home-card {
  background: var(--cte-panel);
  border: 1px solid var(--cte-border);
  border-radius: var(--cte-radius);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.cte-home-card[data-href] { cursor: pointer; }
.cte-home-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
  border-color: var(--cte-accent);
}
.cte-home-card .cte-card-chapter {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--cte-accent);
  margin-bottom: 8px;
}
.cte-home-card h3 { margin: 0 0 8px; font-size: 17px; }
.cte-home-card ul {
  list-style: none;
  margin: 0; padding: 0;
  font-size: 13px;
  color: var(--cte-text-sec);
}
.cte-home-card li { padding: 3px 0; }

/* ===== Search Modal ===== */
.cte-search-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  display: none; align-items: flex-start; justify-content: center;
  padding-top: 120px;
}
.cte-search-overlay.cte-open { display: flex; }

.cte-search-box {
  width: min(560px, 92vw);
  background: var(--cte-panel);
  border: 1px solid var(--cte-border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
  overflow: hidden;
}
.cte-search-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--cte-border);
}
.cte-search-input-wrap svg { width: 18px; height: 18px; color: var(--cte-text-muted); flex-shrink: 0; }
.cte-search-input-wrap input {
  flex: 1;
  border: 0; outline: 0;
  background: transparent;
  color: var(--cte-text);
  font-size: 15px;
}
.cte-search-input-wrap input::placeholder { color: var(--cte-text-muted); }
.cte-search-results { max-height: 360px; overflow-y: auto; }
.cte-search-results a {
  display: block;
  padding: 11px 16px;
  text-decoration: none;
  color: var(--cte-text);
  border-bottom: 1px solid var(--cte-border);
}
.cte-search-results a:hover, .cte-search-results a.cte-selected { background: var(--cte-hover); }
.cte-search-results .cte-r-title { font-size: 14px; font-weight: 600; }
.cte-search-results .cte-r-chapter { font-size: 12px; color: var(--cte-text-muted); margin-top: 2px; }
.cte-search-empty { padding: 20px; text-align: center; color: var(--cte-text-muted); font-size: 14px; }

/* ===== Mobile ===== */
.cte-sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 140;
}

@media (max-width: 900px) {
  .cte-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .cte-app-sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .cte-app-sidebar.cte-open {
    transform: translateX(0);
  }
  .cte-sidebar-overlay.cte-open { display: block; }
  .cte-app-main {
    margin-left: 0;
    padding: 24px 22px 60px;
  }
  .cte-search-trigger kbd { display: none; }
  .cte-search-trigger { min-width: auto; flex: 1; max-width: 360px; }
  .cte-content-wrap { padding: 28px; }
  .cte-home-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .cte-brand span { display: none; }
  .cte-home-hero h1 { font-size: 24px; }
  .cte-app-main { padding: 20px 16px 48px; }
  .cte-content-wrap { padding: 22px; }
}

/* ---------- 离线态清理：屏蔽线上专属外壳 ---------- */
/* 老站营销页脚在离线包里全是死链 (#)，直接隐藏 */
.cte-offline-app .site-footer,
.cte-offline-app footer.site-footer,
.cte-offline-app .site-header,
.cte-offline-app .guide-rail,
.cte-offline-app .guide-rail-backdrop,
.cte-offline-app .rail-reopen,
.cte-offline-app #railReopen,
.cte-offline-app .article-sidebar,
.cte-offline-app .newsletter,
.cte-offline-app .buy-cta,
.cte-offline-app .upl-cta-band {
  display: none !important;
}

/* 阅读进度条挪到 header 之下，否则被 z-index:200 的 header 完全遮住 */
.cte-offline-app .upl-reading-progress {
  top: 60px !important;
  z-index: 201 !important;
}
@media (max-width: 900px) {
  .cte-offline-app .upl-reading-progress { top: 56px !important; }
}

/* ---------- 上/下页导航 ---------- */
.cte-pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--cte-line, #e4e2db);
}
.cte-pager-link {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--cte-line, #e4e2db);
  border-radius: 14px;
  text-decoration: none;
  color: var(--cte-ink, #1c1c1c);
  background: var(--cte-card, #fff);
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
  min-width: 0;
}
.cte-pager-next { text-align: right; align-items: flex-end; }
.cte-pager-link:hover {
  border-color: var(--cte-accent, #ba2f2a);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0,0,0,.08);
}
.cte-pager-dir {
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--cte-muted, #8a8780);
}
.cte-pager-label {
  font-family: var(--cte-serif, Georgia, serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--cte-accent, #ba2f2a);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.cte-pager-spacer { flex: 1 1 0; }

@media (max-width: 900px) {
  .cte-pager { flex-direction: column; }
  .cte-pager-next { text-align: left; align-items: flex-start; }
}

/* ---------- 导航折叠组（第二章 Connectivity / Essential Apps 等） ---------- */
.cte-nav-list .cte-group { margin-top: 4px; }
.cte-nav-list .cte-group-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  color: var(--cte-ink, #1c1c1c);
  text-decoration: none;
}
.cte-nav-list .cte-group-head:hover { background: var(--cte-hover, rgba(0,0,0,.04)); }
.cte-nav-list .cte-group-head.cte-current { background: var(--cte-current-bg, #fff0ef); color: var(--cte-accent, #ba2f2a); }
.cte-nav-list .cte-group-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--cte-accent, #ba2f2a);
}
.cte-nav-list .cte-group-icon svg { width: 16px; height: 16px; }
.cte-nav-list .cte-group-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 默认展开：可折叠父级像竞品一样常驻可见，子项缩进 */
.cte-nav-list .cte-children { list-style: none; padding-left: 16px; margin: 2px 0 6px; border-left: 2px solid var(--cte-line, #e4e2db); }
.cte-nav-list .cte-children a { padding-left: 4px; font-size: 13px; }
html[data-theme="dark"] .cte-nav-list .cte-children { border-left-color: var(--cte-line, #333338); }
html[data-theme="dark"] .cte-nav-list .cte-group-head { color: var(--cte-ink, #e5e5e5); }

/* ---------- 首页 dashboard 章节图标 ---------- */
.cte-home-card .cte-card-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 11px;
  background: var(--cte-accent-soft); color: var(--cte-accent);
  margin-bottom: 12px;
}
.cte-home-card .cte-card-ico svg { width: 22px; height: 22px; }
.cte-home-card .cte-card-chapter { display: flex; align-items: center; gap: 0; }

/* 补齐暗色变量（2026-08-29）：上下页导航等组件引用 --cte-card/--cte-ink/--cte-muted/--cte-line，
   原缺失导致暗色下回退成白底卡片 + 浅字 = 不可读。与 arrival-kit/assets/offline-shell.css 同步。 */
html[data-theme="dark"] {
  --cte-card: #1a1a1b;
  --cte-ink: #e5e5e5;
  --cte-muted: #a1a1aa;
  --cte-line: #2a2a2b;
}
