/* ============================================
   LB-QM Series Soft Starter Manual - Stylesheet
   Mobile-first design for elderly-friendly reading
   ============================================ */

:root {
  --primary-color: #1a5276;
  --primary-dark: #0e3a54;
  --accent-color: #2980b9;
  --bg-color: #f8f9fa;
  --card-bg: #ffffff;
  --text-color: #2c3e50;
  --text-secondary: #5a6c7d;
  --border-color: #dde2e8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --font-base: 14px;
  --font-line-height: 1.75;

  --safe-top: env(safe-area-inset-top, 20px);
  --safe-bottom: env(safe-area-inset-bottom, 20px);

  /* Font size levels */
  --size-s: 12px;
  --size-m: 14px;
  --size-l: 16px;
  --size-xl: 18px;
  --size-xxl: 20px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-base);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text-color);
  background: var(--bg-color);
  line-height: var(--font-line-height);
  padding-bottom: 0;
  overflow-x: hidden;
}

/* ============ Header ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: #fff;
  padding: 12px 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 800px;
  margin: 0 auto;
}

.header-title {
  font-size: var(--size-l);
  font-weight: 700;
  letter-spacing: 1px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-subtitle {
  font-size: 11px;
  opacity: 0.85;
  display: block;
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.header-btn {
  background: rgba(255,255,255,0.18);
  border: none;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: all 0.15s;
  flex-shrink: 0;
}

.header-btn svg {
  width: 20px;
  height: 20px;
}

.header-btn:active {
  background: rgba(255,255,255,0.35);
  transform: scale(0.92);
}

.header-btn #langToggle {
  font-size: 13px;
  font-weight: 700;
}

/* ============ Quick Nav Grid (Home) ============ */
.quick-nav {
  max-width: 800px;
  margin: 12px auto 0;
  padding: 0 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quick-nav-item {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 14px 12px;
  text-decoration: none;
  color: var(--text-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid transparent;
}

.quick-nav-item:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-md);
}

.quick-nav-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.quick-nav-text {
  font-size: var(--size-m);
  font-weight: 600;
  line-height: 1.3;
}

.quick-nav-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Icon colors */
.bg-blue { background: #eaf2fa; }
.bg-green { background: #eafaf1; }
.bg-orange { background: #fef5e7; }
.bg-red { background: #fdeaea; }
.bg-purple { background: #efecfb; }
.bg-cyan { background: #e8fafc; }
.bg-yellow { background: #fefce8; }
.bg-pink { background: #fdf2f8; }

/* ============ Sections ============ */
.section {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 12px;
}

.section-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: visible;
}

.section-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
  position: sticky;
  top: 60px;
  z-index: 50;
  background: var(--card-bg);
  /* 确保 sticky header 不遮挡下方内容 */
  margin-bottom: 0;
}

/* 为 sticky header 后面的第一个元素留出足够间距 */
.section-header + .section-body {
  padding-top: 16px;
}

.section-number {
  background: var(--primary-color);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.section-title {
  font-size: var(--size-l);
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.3;
}

.section-body {
  padding: 14px 14px 20px;
}

/* 移动端增加 section-body 内边距，防止 sticky header 遮挡 */
@media (max-width: 480px) {
  .section-body {
    padding: 12px 12px 18px;
  }
  .section-body p,
  .section-body li {
    padding-right: 2px;
  }
}

/* ============ Typography ============ */
h3 {
  font-size: var(--size-m);
  font-weight: 700;
  color: var(--primary-dark);
  margin: 16px 0 8px;
  padding-left: 10px;
  border-left: 3px solid var(--accent-color);
}

p {
  margin: 8px 0;
  text-align: justify;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
}

ul, ol {
  padding-left: 20px;
  margin: 8px 0;
}

li {
  margin: 5px 0;
}

strong {
  font-weight: 600;
  color: var(--primary-dark);
  word-break: break-word;
}

li {
  margin: 5px 0;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Feature list bullets */
.feature-list {
  list-style: none;
  padding-left: 0;
  margin: 12px 0;
}

.feature-list li {
  position: relative;
  padding-left: 20px;
  margin: 8px 0;
  font-size: var(--size-m);
  line-height: 1.8;
}

.feature-list li::before {
  content: "\25CF";
  color: var(--accent-color);
  position: absolute;
  left: 0;
  top: 0.45em;
  font-size: 8px;
  line-height: inherit;
}

/* ============ Tables ============ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 12px 0;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  scrollbar-width: thin;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
  font-size: var(--size-s);
  line-height: 1.55;
}

thead th {
  background: #edf2f7;
  color: var(--primary-dark);
  font-weight: 600;
  padding: 9px 8px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid #cbd5e1;
  position: sticky;
  top: 0;
}

td {
  padding: 7px 8px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  word-break: break-all;
}

tr:hover td {
  background: #f8fafc;
}

td code, td .code-inline {
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: inherit;
  font-family: "SF Mono", Consolas, monospace;
  color: #be123c;
}

/* Parameter table specific */
.param-table td:first-child {
  white-space: nowrap;
  font-weight: 600;
  color: var(--primary-color);
  width: 60px;
}

/* ============ Images ============ */
.img-container {
  margin: 14px 0;
  text-align: center;
}

.img-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.img-caption {
  font-size: var(--size-s);
  color: var(--text-secondary);
  margin-top: 6px;
  text-align: center;
}

/* Terminal diagram placeholder */
.wiring-diagram {
  background: #f8fafc;
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 24px 12px;
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--size-m);
  margin: 14px 0;
}

/* ============ Warning / Notice boxes ============ */
.warning-box {
  background: #fef3cd;
  border-left: 4px solid #d69e2e;
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  margin: 14px 0;
  font-size: var(--size-m);
}

.warning-box strong {
  color: #b7791f;
}

.notice-box {
  background: #dbeafe;
  border-left: 4px solid #2563eb;
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  margin: 14px 0;
  font-size: var(--size-m);
}

.danger-box {
  background: #fee2e2;
  border-left: 4px solid #dc2626;
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  margin: 14px 0;
  font-size: var(--size-m);
}

.danger-box strong {
  color: #b91c1c;
}

/* ============ Key Operation Steps ============ */
.step-list {
  counter-reset: step-counter;
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.step-list li {
  counter-increment: step-counter;
  position: relative;
  padding-left: 42px;
  margin: 14px 0;
  min-height: 32px;
}

.step-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  background: var(--primary-color);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.step-display {
  background: #1a3a5c;
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 13px;
  display: inline-block;
  margin: 3px 0;
  white-space: nowrap;
}

/* ============ LCD Screen Simulation ============ */
figure.lcd-figure {
  margin: 8px 0;
  width: 240px;
  min-width: 240px;
  overflow: hidden;
  contain: layout paint style;   /* 隔离渲染，防止外部布局干扰 */
  flex-shrink: 0;
}

figure.lcd-image {
  margin: 10px 0;
  max-width: 100%;
  overflow: hidden;
  contain: layout paint style;
}

figure.lcd-image img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}

.lcd-screen {
  background: #1a3a5c;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.85;
  margin: 0;
  width: 100%;
  min-width: 0;
  letter-spacing: 0.2px;
  border: 2px solid #0f2844;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.15);
  overflow: hidden;
  table-layout: fixed;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.lcd-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1.85em;
  color: #e2e8f0;
}

.lcd-line.lcd-empty {
  color: transparent;
}

.lcd-line.lcd-edit {
  color: #7dd3fc;
}

.lcd-line.lcd-cursor::before {
  content: ">> ";
  color: #fbbf24;
  font-weight: 700;
}

.lcd-line.lcd-highlight {
  color: #fbbf24;
}

.lcd-line.lcd-dim {
  color: #94a3b8;
}

.lcd-desc {
  font-size: var(--size-s);
  color: var(--text-secondary);
  margin: 4px 0 2px;
  line-height: 1.5;
}

figure.lcd-figure figcaption,
figure.lcd-image figcaption {
  font-size: var(--size-s);
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.5;
  text-align: left;
  padding: 0;
}

.screen-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 10px 0;
}

.screen-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.screen-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0;
}

.screen-group .screen-row {
  flex: 0 0 auto;
}

/* Step-list inside LCD screens: let figures not overflow */
ol.step-list > li > figure.lcd-figure {
  max-width: 100%;
}

/* First column wider */
table.col-wide-first td:first-child,
table.col-wide-first th:first-child {
  min-width: 90px;
  white-space: nowrap;
}

.key-badge {
  display: inline-block;
  background: #e2e8f0;
  color: var(--primary-dark);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: var(--size-s);
  font-weight: 600;
  font-family: "SF Mono", Consolas, monospace;
  border: 1px solid #cbd5e1;
  vertical-align: middle;
}

/* ============ Footer ============ */
.footer {
  max-width: 800px;
  margin: 20px auto 0;
  padding: 20px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
}

.footer-brand {
  font-weight: 700;
  color: var(--primary-color);
  font-size: 14px;
  margin-bottom: 4px;
}

/* ============ TOC Sidebar Overlay ============ */
.toc-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(26,82,118,0.18);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  pointer-events: none;
}

.toc-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.toc-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: #fff;
  z-index: 301;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
  box-shadow: 4px 0 30px rgba(0,0,0,0.08);
  padding: 16px 0;
  border-right: 1px solid #e8ecf0;
}

.toc-overlay.show .toc-panel {
  transform: translateX(0);
}

.toc-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.toc-panel-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-dark);
}

.toc-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.toc-list {
  list-style: none;
  padding: 8px 0;
}

.toc-item a {
  display: block;
  padding: 11px 20px;
  color: var(--text-color);
  text-decoration: none;
  font-size: var(--size-m);
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.toc-item a:active,
.toc-item a.active {
  background: #eff6ff;
  color: var(--primary-color);
  border-left-color: var(--primary-color);
  font-weight: 600;
}

/* ============ Search Panel ============ */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: rgba(26,82,118,0.18);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  pointer-events: none;
}

.search-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.search-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 351;
  background: #fff;
  transform: translateY(-100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  border-radius: 0 0 20px 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.06);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.search-overlay.show .search-panel {
  transform: translateY(0);
}

.search-input-wrap {
  padding: 16px 16px 12px;
  border-bottom: 1px solid #eef2f6;
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-input {
  flex: 1;
  border: 2px solid #e0e6ed;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: var(--size-m);
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
  background: #f8fafb;
  color: var(--text-color);
}

.search-input:focus {
  border-color: var(--accent-color);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(41,128,185,0.1);
}

.search-cancel {
  background: none;
  border: none;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  white-space: nowrap;
}

.search-results {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}

.search-result-item {
  padding: 12px 20px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}

.search-result-item:active {
  background: #f1f5f9;
}

.search-result-section {
  font-size: var(--size-s);
  color: var(--accent-color);
  font-weight: 600;
  margin-bottom: 3px;
}

.search-result-text {
  font-size: var(--size-m);
  color: var(--text-color);
  line-height: 1.5;
}

.search-result-text mark {
  background: #fef08a;
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}

.search-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ============ Font Size Control ============ */
.font-control-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 8px;
  border: 1px solid var(--border-color);
  z-index: 250;
  min-width: 180px;
}

.font-control-panel.show {
  display: block;
}

.font-option {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text-color);
  transition: background 0.15s;
}

.font-option:hover,
.font-option.active {
  background: #eff6ff;
  color: var(--primary-color);
  font-weight: 600;
}

.font-btn-wrapper {
  position: relative;
}

/* Size labels in options */
[data-size="s"] { font-size: 14px !important; }
[data-size="m"] { font-size: 16px !important; }
[data-size="l"] { font-size: 18px !important; }
[data-size="xl"] { font-size: 20px !important; }
[data-size="xxl"] { font-size: 22px !important; }

/* ============ Header font panel (white theme) ============ */
#headerFontPanel {
  background: rgba(255,255,255,0.97);
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
#headerFontPanel .font-option {
  color: var(--text-color);
}
#headerFontPanel .font-option.active {
  background: #1a5276;
  color: #fff;
}

/* ============ Scroll-to-top button ============ */
.scroll-top {
  position: fixed;
  right: 16px;
  bottom: 80px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(26,82,118,0.35);
  transition: transform 0.2s, opacity 0.2s;
  opacity: 0;
}

.scroll-top.visible {
  display: flex;
  opacity: 1;
}

.scroll-top:active {
  transform: scale(0.92);
}

/* ============ Responsive tweaks ============ */
@media (max-width: 320px) {
  figure.lcd-figure {
    width: 100%;
    min-width: 0;
  }
}

@media (min-width: 480px) {
  .quick-nav {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
  .section { padding: 20px 16px; }
}

@media (min-width: 768px) {
  :root { --font-base: 15px; }
  .quick-nav { grid-template-columns: repeat(4, 1fr); }
  .section-body { padding: 18px 24px 24px; }
}

/* ============ [新增] tag style ============ */
.new-tag {
  font-size: 10px;
  color: #16a34a;
  margin-left: 4px;
  white-space: nowrap;
}
@media print {
  .header, .scroll-top, .toc-overlay, .search-overlay { display: none !important; }
  body { padding: 0; background: #fff; }
  .section { page-break-inside: avoid; }
}
