/* ============ 供配电与照明 复习网站样式 ============ */

:root {
  --c-bg: #f6f7f9;
  --c-surface: #ffffff;
  --c-surface-2: #f0f2f5;
  --c-border: #e2e6ec;
  --c-text: #1f2329;
  --c-text-soft: #5b6470;
  --c-text-mute: #8b94a3;
  --c-primary: #2b6cb0;
  --c-primary-soft: #eaf2fb;
  --c-primary-dark: #1d4e84;
  --c-accent: #c2410c;
  --c-accent-soft: #fdf0e8;
  --c-green: #15803d;
  --c-green-soft: #e7f5ec;
  --c-purple: #6d28d9;
  --c-purple-soft: #f1ecfb;
  --c-warn: #b45309;
  --c-warn-soft: #fdf4e3;
  --c-danger: #b91c1c;
  --c-danger-soft: #fdeaea;
  --c-code-bg: #f4f5f7;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08);
  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 1180px;
  --sidebar-w: 290px;
}

html.dark {
  --c-bg: #15171c;
  --c-surface: #1d2027;
  --c-surface-2: #262a33;
  --c-border: #343a46;
  --c-text: #e6e9ef;
  --c-text-soft: #aab2c0;
  --c-text-mute: #77808f;
  --c-primary: #5b9bd5;
  --c-primary-soft: #1f3349;
  --c-primary-dark: #7fb6e0;
  --c-accent: #e88a5a;
  --c-accent-soft: #3a261a;
  --c-green: #5fb878;
  --c-green-soft: #1c3324;
  --c-purple: #a98ae0;
  --c-purple-soft: #2a2238;
  --c-warn: #d9a14a;
  --c-warn-soft: #382d18;
  --c-danger: #e87878;
  --c-danger-soft: #3a1f1f;
  --c-code-bg: #262a33;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ 顶部栏 ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--c-text);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .logo {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-dark));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 800;
}
.brand .sub { font-size: 12px; color: var(--c-text-mute); font-weight: 400; }

.search-wrap {
  flex: 1;
  max-width: 460px;
  position: relative;
}
.search-wrap input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--c-border);
  border-radius: 18px;
  padding: 0 16px 0 36px;
  background: var(--c-surface-2);
  color: var(--c-text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-wrap input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-soft);
}
.search-wrap .ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--c-text-mute); font-size: 15px; pointer-events: none;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.icon-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  border-radius: 8px;
  color: var(--c-text-soft);
  cursor: pointer;
  font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--c-primary-soft); color: var(--c-primary); }

/* ============ 布局 ============ */
.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 28px;
  align-items: start;
}

/* ============ 侧边栏 ============ */
.sidebar {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 6px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 3px; }

.nav-section { margin-bottom: 18px; }
.nav-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-mute);
  margin: 0 0 8px;
  padding: 0 10px;
  font-weight: 700;
}
.nav-link {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--c-text-soft);
  font-size: 14px;
  cursor: pointer;
  transition: background .12s, color .12s;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--c-surface-2); color: var(--c-text); text-decoration: none; }
.nav-link.active {
  background: var(--c-primary-soft);
  color: var(--c-primary-dark);
  font-weight: 600;
  border-left-color: var(--c-primary);
}
.nav-link .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-border); margin-top: 8px; flex: none;
  transition: background .12s;
}
.nav-link.active .dot { background: var(--c-primary); }
.nav-link.done .dot { background: var(--c-green); }

/* ============ 主内容 ============ */
.content { min-width: 0; }
.page { display: none; }
.page.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-header {
  background: linear-gradient(135deg, var(--c-primary-soft), var(--c-surface));
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 22px;
}
.page-header .eyebrow {
  font-size: 12px; color: var(--c-primary); font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; margin-bottom: 4px;
}
.page-header h1 {
  margin: 0 0 6px; font-size: 26px; color: var(--c-text); font-weight: 800;
}
.page-header .desc { margin: 0; color: var(--c-text-soft); font-size: 14px; }
.page-header .meta {
  margin-top: 12px; display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px;
  color: var(--c-text-mute);
}
.page-header .meta span { display: inline-flex; align-items: center; gap: 5px; }

/* ============ 通用排版 ============ */
.sec {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.sec > h2 {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
  color: var(--c-text);
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--c-border);
}
.sec > h2 .num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 8px;
  background: var(--c-primary); color: #fff;
  border-radius: 7px; font-size: 14px; font-weight: 700;
}
.sec > h3 {
  margin: 22px 0 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--c-primary-dark);
}
.sec > h4 {
  margin: 16px 0 8px; font-size: 15px; font-weight: 700; color: var(--c-text);
}
.sec p { margin: 10px 0; }
.sec ul, .sec ol { margin: 10px 0; padding-left: 24px; }
.sec li { margin: 5px 0; }
.sec strong { color: var(--c-text); font-weight: 700; }
.sec code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  background: var(--c-code-bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .9em;
  color: var(--c-accent);
}
.sec table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  display: block;
  overflow-x: auto;
}
.sec table th, .sec table td {
  border: 1px solid var(--c-border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.sec table th {
  background: var(--c-surface-2);
  font-weight: 700;
  color: var(--c-text);
  white-space: nowrap;
}
.sec table tr:nth-child(even) td { background: var(--c-surface-2); }
html.dark .sec table tr:nth-child(even) td { background: rgba(255,255,255,.02); }

/* ============ 图片 ============ */
figure {
  margin: 16px 0;
  text-align: center;
}
figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  background: #fff;
}
html.dark figure img { background: #2a2e36; }
figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--c-text-mute);
}
.img-half { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.img-half figure { margin: 0; }
@media (max-width: 640px) { .img-half { grid-template-columns: 1fr; } }

/* ============ 组件块 ============ */
.callout {
  border-radius: var(--radius-sm);
  padding: 14px 16px 14px 18px;
  margin: 14px 0;
  border-left: 4px solid;
  font-size: 14.5px;
}
.callout .ct-title {
  font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 6px;
}
.callout p:first-of-type { margin-top: 4px; }
.callout p:last-child { margin-bottom: 0; }
.callout.info { background: var(--c-primary-soft); border-color: var(--c-primary); color: var(--c-text); }
.callout.info .ct-title { color: var(--c-primary-dark); }
.callout.tip { background: var(--c-green-soft); border-color: var(--c-green); }
.callout.tip .ct-title { color: var(--c-green); }
.callout.warn { background: var(--c-warn-soft); border-color: var(--c-warn); }
.callout.warn .ct-title { color: var(--c-warn); }
.callout.danger { background: var(--c-danger-soft); border-color: var(--c-danger); }
.callout.danger .ct-title { color: var(--c-danger); }
.callout.note { background: var(--c-purple-soft); border-color: var(--c-purple); }
.callout.note .ct-title { color: var(--c-purple); }
.callout.understand { background: var(--c-accent-soft); border-color: var(--c-accent); }
.callout.understand .ct-title { color: var(--c-accent); }

.example {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-accent);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin: 16px 0;
}
.example .ex-title {
  font-weight: 700;
  color: var(--c-accent);
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
  font-size: 15px;
}
.example .ex-q { font-weight: 600; margin: 8px 0 6px; }
.example .ex-solve {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 10px 0;
  font-size: 14.5px;
}
.example .ex-answer {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--c-green-soft);
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--c-green);
  font-size: 14.5px;
}
.example .ex-answer .lab { font-weight: 400; color: var(--c-text-soft); margin-right: 6px; }

.formula {
  background: var(--c-surface-2);
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  margin: 12px 0;
  font-family: "SFMono-Regular", Consolas, monospace;
  text-align: center;
  font-size: 15px;
  overflow-x: auto;
}
.formula b { color: var(--c-primary-dark); }

.kp-card {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 10px 0;
  font-size: 14.5px;
}
.kp-card .kp-h { font-weight: 700; color: var(--c-text); margin-bottom: 4px; }

/* 规范引用 */
.std { color: var(--c-primary-dark); font-weight: 600; }
.std::before { content: "📕 "; }

/* 关键数值高亮 */
.hl { background: var(--c-warn-soft); padding: 1px 5px; border-radius: 3px; font-weight: 600; color: var(--c-warn); }

/* 思考题 */
.think {
  background: var(--c-purple-soft);
  border-left: 4px solid var(--c-purple);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 14px 0;
}
.think .tk-title { font-weight: 700; color: var(--c-purple); margin-bottom: 6px; }
.think details summary { cursor: pointer; color: var(--c-text-soft); font-size: 14px; margin-top: 6px; }
.think details summary:hover { color: var(--c-primary); }
.think .ans { margin-top: 8px; padding: 8px 12px; background: var(--c-surface); border-radius: var(--radius-sm); font-size: 14.5px; }

/* 章节锚点偏移 */
.anchor { scroll-margin-top: 80px; }

/* 页脚导航 */
.pagenav {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 28px;
}
.pagenav a {
  flex: 1; max-width: 48%;
  padding: 12px 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  transition: border-color .15s, box-shadow .15s;
}
.pagenav a:hover { border-color: var(--c-primary); box-shadow: var(--shadow-md); text-decoration: none; }
.pagenav .lab { font-size: 12px; color: var(--c-text-mute); }
.pagenav .ttl { font-size: 15px; font-weight: 600; color: var(--c-text); margin-top: 2px; }
.pagenav .next { text-align: right; }

/* 搜索结果 */
.search-results {
  position: fixed; top: 56px; left: 0; right: 0;
  max-height: 70vh; overflow-y: auto;
  background: var(--c-surface); border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-md);
  display: none; z-index: 99;
}
.search-results.show { display: block; }
.sr-inner { max-width: var(--maxw); margin: 0 auto; padding: 10px 20px 18px; }
.sr-item {
  display: block; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--c-text-soft); border: 1px solid transparent;
}
.sr-item:hover { background: var(--c-primary-soft); color: var(--c-text); text-decoration: none; border-color: var(--c-border); }
.sr-item .sr-t { font-weight: 600; color: var(--c-text); }
.sr-item .sr-s { font-size: 13px; color: var(--c-text-mute); margin-top: 2px; }
.sr-item mark { background: var(--c-warn-soft); color: var(--c-warn); padding: 0 2px; border-radius: 2px; }

/* 无障碍隐藏 */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* 移动端 */
.menu-toggle { display: none; }
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0; width: 280px;
    background: var(--c-surface); border-right: 1px solid var(--c-border);
    z-index: 90; transform: translateX(-100%); transition: transform .25s;
    max-height: none; padding: 16px;
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .brand .sub { display: none; }
  .overlay { display: none; position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,.4); z-index: 80; }
  .overlay.show { display: block; }
}
@media (max-width: 560px) {
  .search-wrap { display: none; }
  .sec { padding: 16px; }
  .page-header { padding: 16px; }
}
