/* Tech Manual Template v3 - Markdown Style */
:root {
  --tm-primary: #1a73e8;
  --tm-primary-dark: #1557b0;
  --tm-primary-light: #e8f0fe;
  --tm-bg: #ffffff;
  --tm-bg-secondary: #f6f8fa;
  --tm-bg-code: #1e1e1e;
  --tm-text: #1f2328;
  --tm-text-secondary: #656d76;
  --tm-border: #d1d9e0;
  --tm-success: #1a7f37;
  --tm-warning: #bf8700;
  --tm-error: #cf222e;
  --tm-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', 'Microsoft YaHei', Helvetica, Arial, sans-serif;
  --tm-font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, 'Courier New', monospace;
  --tm-toc-width: 260px;
  --tm-content-max: 860px;
  --tm-radius: 6px;
  --tm-shadow: 0 1px 3px rgba(31, 35, 40, 0.04), 0 1px 2px rgba(31, 35, 40, 0.06);
  --tm-shadow-lg: 0 8px 24px rgba(31, 35, 40, 0.12);
}

/* Dark theme */
[data-theme="dark"] {
  --tm-bg: #0d1117;
  --tm-bg-secondary: #161b22;
  --tm-bg-code: #161b22;
  --tm-text: #e6edf3;
  --tm-text-secondary: #8b949e;
  --tm-border: #30363d;
  --tm-primary-light: #1a2744;
}

[data-theme="dark"] blockquote.info {
  background: #0d1d30;
  border-left-color: #1f6feb;
}

[data-theme="dark"] blockquote.warning {
  background: #2a2100;
  border-left-color: #d29922;
}

[data-theme="dark"] blockquote.danger {
  background: #2d0000;
  border-left-color: #f85149;
}

[data-theme="dark"] .image-container {
  background: #161b22;
}

[data-theme="dark"] .faq-item {
  background: #161b22;
  border-color: #30363d;
}

[data-theme="dark"] .search-highlight,
[data-theme="dark"] mark {
  background: #4a4a2a;
  color: #fff;
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--tm-font);
  color: var(--tm-text);
  background: var(--tm-bg);
  line-height: 1.8;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.tech-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 54px;
  background: var(--tm-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 200;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.tech-header .header-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.tech-header .header-title .version {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.tech-header .search-box {
  position: relative;
  width: 300px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tech-header .search-box input {
  width: 100%;
  padding: 7px 14px 7px 34px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 13px;
  outline: none;
  transition: all 0.2s;
  min-width: 0;
}

.tech-header .search-box input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.tech-header .search-box input:focus {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: none;
}

.tech-header .search-box::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  z-index: 1;
}

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

.toc-toggle,
.theme-toggle {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.2s;
  line-height: 1;
}

.toc-toggle:hover,
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Desktop: hide toc toggle */
.toc-toggle {
  display: none;
}

/* Container */
.md-cover-container {
  display: flex;
  margin-top: 54px;
  min-height: calc(100vh - 54px);
}

/* TOC Sidebar */
.md-cover-toc {
  position: fixed;
  left: 0;
  top: 54px;
  width: var(--tm-toc-width);
  height: calc(100vh - 54px);
  overflow-y: auto;
  padding: 16px 0;
  border-right: 1px solid var(--tm-border);
  background: var(--tm-bg);
  z-index: 100;
}

.md-cover-toc .toc-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tm-text-secondary);
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--tm-border);
  margin-bottom: 8px;
}

.toc-item {
  padding: 0;
}

.toc-item a {
  display: block;
  padding: 5px 16px;
  color: var(--tm-text-secondary);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.5;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}

.toc-item a:hover {
  color: var(--tm-primary);
  background: var(--tm-primary-light);
  border-left-color: var(--tm-primary);
}

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

/* TOC Levels */
.toc-level-1 a {
  padding-left: 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--tm-text);
}

.toc-level-2 a {
  padding-left: 28px;
  font-size: 13px;
}

.toc-level-3 a {
  padding-left: 40px;
  font-size: 12px;
  color: var(--tm-text-secondary);
}

/* Main content */
.md-cover-content {
  margin-left: var(--tm-toc-width);
  flex: 1;
  padding: 40px 48px;
  background: var(--tm-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

.md-cover-content>* {
  width: 100%;
  max-width: var(--tm-content-max);
  margin-left: auto;
  margin-right: auto;
}

/* Title section */
.title-section {
  text-align: center;
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--tm-border);
}

.title-section .main-title {
  font-size: 2.2em;
  font-weight: 700;
  line-height: 1.3;
  color: var(--tm-text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.title-section .subtitle {
  font-size: 1.3em;
  font-weight: 400;
  color: var(--tm-text-secondary);
  line-height: 1.3;
}

.title-section .meta-info {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: 13px;
  color: var(--tm-text-secondary);
}

/* Typography - Markdown Style */
h1 {
  font-size: 1.8em;
  font-weight: 700;
  margin-top: 48px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--tm-border);
  line-height: 1.3;
  color: var(--tm-text);
  scroll-margin-top: 70px;
  letter-spacing: -0.01em;
}

h1:first-of-type {
  margin-top: 0;
}

h2 {
  font-size: 1.4em;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--tm-border);
  line-height: 1.4;
  color: var(--tm-text);
  scroll-margin-top: 70px;
}

h3 {
  font-size: 1.15em;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 10px;
  line-height: 1.4;
  color: var(--tm-text);
  scroll-margin-top: 70px;
}

h4 {
  font-size: 1em;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 8px;
  line-height: 1.5;
  color: var(--tm-text);
  scroll-margin-top: 70px;
}

/* Chapter/Section numbers */
.chapter-num {
  display: inline-block;
  background: var(--tm-primary);
  color: white;
  width: 32px;
  height: 32px;
  line-height: 32px;
  text-align: center;
  border-radius: 6px;
  font-size: 0.7em;
  margin-right: 8px;
  vertical-align: middle;
}

.section-num {
  color: var(--tm-primary);
  margin-right: 6px;
  font-weight: 700;
}

.sub-num {
  color: var(--tm-text-secondary);
  margin-right: 6px;
  font-weight: 600;
}

p {
  margin-bottom: 16px;
  line-height: 1.8;
}

a {
  color: var(--tm-primary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

a:hover {
  border-bottom-color: var(--tm-primary);
}

strong {
  font-weight: 600;
}

code {
  font-family: var(--tm-font-mono);
  font-size: 0.88em;
  background: var(--tm-bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--tm-border);
}

/* Lists */
ul,
ol {
  margin: 8px 0 16px 24px;
}

li {
  margin-bottom: 6px;
  line-height: 1.7;
}

li>ul,
li>ol {
  margin-top: 6px;
  margin-bottom: 0;
}

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
  border-radius: var(--tm-radius);
  overflow: hidden;
  border: 1px solid var(--tm-border);
}

th,
td {
  border: 1px solid var(--tm-border);
  padding: 10px 14px;
  text-align: left;
}
td{
  min-width: 6em;
}


th {
  background: var(--tm-bg-secondary);
  color: var(--tm-text);
  font-weight: 600;
  font-size: 13px;
}

tr:hover {
  background: var(--tm-primary-light);
}

/* Blockquote */
blockquote {
  border-left: 4px solid var(--tm-primary);
  padding: 16px 20px;
  margin: 16px 0;
  background: var(--tm-primary-light);
  border-radius: 0 var(--tm-radius) var(--tm-radius) 0;
  font-size: 14px;
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote.info {
  border-left-color: var(--tm-primary);
  background: #e8f0fe;
}

blockquote.warning {
  border-left-color: var(--tm-warning);
  background: #fef7e0;
}

blockquote.danger {
  border-left-color: var(--tm-error);
  background: #fce8e6;
}

blockquote ul {
  margin: 8px 0 0 20px;
}

blockquote li {
  margin-bottom: 4px;
}

/* Images */
.image-container {
  text-align: center;
  margin: 16px 0 24px;
  padding: 12px;
  background: var(--tm-bg-secondary);
  border-radius: var(--tm-radius);
  border: 1px solid var(--tm-border);
}

.image-container img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}

.image-container img:hover {
  transform: scale(1.01);
}

.image-caption {
  margin-top: 8px;
  color: var(--tm-text-secondary);
  font-size: 13px;
}

/* Image grid */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 16px 0 24px;
  max-width: var(--tm-content-max);
}

.image-grid .image-container {
  margin: 0;
}

/* FAQ */
.faq-list {
  margin: 16px 0;
}

.faq-item {
  padding: 16px 20px;
  margin-bottom: 12px;
  background: var(--tm-bg-secondary);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
}

.faq-q {
  margin-bottom: 8px;
  color: var(--tm-text);
}

.faq-a {
  margin-bottom: 0;
  color: var(--tm-text-secondary);
  padding-left: 16px;
  border-left: 2px solid var(--tm-border);
}

/* Search highlight */
.search-highlight {
  background: #fff3cd;
  padding: 2px 0;
  border-radius: 2px;
  box-shadow: 0 0 0 2px #fff3cd;
  color: #333;
}

[data-theme="dark"] .search-highlight {
  background: #4a4a2a;
  box-shadow: 0 0 0 2px #4a4a2a;
  color: #fff;
}

.search-result-count {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Back to top */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  background: var(--tm-primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--tm-shadow-lg);
  z-index: 1000;
  transition: all 0.3s;
}

.back-to-top.visible {
  display: flex;
}

.back-to-top:hover {
  background: var(--tm-primary-dark);
  transform: translateY(-2px);
}

/* Image overlay */
#image-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9999;
  cursor: zoom-out;
  justify-content: center;
  align-items: center;
}

#image-overlay img {
  max-width: 92%;
  max-height: 92%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Print */
@media print {

  .tech-header,
  .md-cover-toc,
  .back-to-top,
  .search-box,
  .toc-toggle {
    display: none !important;
  }

  .md-cover-container {
    margin-top: 0;
  }

  .md-cover-content {
    margin-left: 0;
    padding: 20px;
    max-width: 100%;
  }

  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
    page-break-after: avoid;
  }

  table {
    break-inside: avoid;
  }

  .image-container {
    break-inside: avoid;
  }

  a {
    color: var(--tm-text);
    border-bottom: none;
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .md-cover-toc {
    width: 220px;
  }

  .md-cover-content {
    padding: 30px 32px;
  }
}

@media (max-width: 768px) {

  /* Header: hide search, show toc toggle */
  .tech-header .search-box {
    display: none;
  }

  .toc-toggle {
    display: block;
  }

  /* TOC sidebar */
  .md-cover-toc {
    display: none;
  }

  .md-cover-toc.mobile-open {
    display: block;
    position: fixed;
    top: 54px;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(100vh - 54px);
    z-index: 150;
    background: var(--tm-bg);
    border-right: none;
    box-shadow: var(--tm-shadow-lg);
  }

  /* Content */
  .md-cover-content {
    margin-left: 0;
    padding: 20px 16px;
  }

  .image-grid {
    grid-template-columns: 1fr;
  }

  /* Title */
  .title-section .main-title {
    font-size: 1.6em;
  }

  .title-section .subtitle {
    font-size: 1.1em;
  }
}

/* Scrollbar */
.md-cover-toc::-webkit-scrollbar {
  width: 4px;
}

.md-cover-toc::-webkit-scrollbar-track {
  background: transparent;
}

.md-cover-toc::-webkit-scrollbar-thumb {
  background: var(--tm-border);
  border-radius: 2px;
}

.md-cover-toc::-webkit-scrollbar-thumb:hover {
  background: var(--tm-text-secondary);
}