/* ========== Main Content Dimensions ========== */
main { max-width: 900px; padding: 40px 48px; }

/* ========== Breadcrumb ========== */
.breadcrumb { margin-bottom: 24px; font-size: 0.85rem; color: var(--text-muted); display: flex; align-items: center; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ========== Hero (Index Pages) ========== */
.hero { margin-bottom: 40px; padding: 32px; background: linear-gradient(135deg, #2a2a35 0%, #24242b 100%); border: 1px solid var(--border); border-radius: var(--radius); }
.hero h2 { font-size: 1.8rem; color: #fff; margin-bottom: 8px; }
.hero p { color: var(--text-muted); font-size: 0.95rem; max-width: 600px; }
@media (max-width: 768px) {
  .hero { padding: 20px; }
  .hero h2 { font-size: 1.4rem; }
}

/* ========== Sections & Cards ========== */
.section { margin-bottom: 48px; scroll-margin-top: 24px; }
.section-title { font-size: 1.3rem; color: #fff; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; }
.card h3 { font-size: 1.05rem; color: #fff; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.card h3 .emoji { font-size: 1.2rem; }
.card p, .card li { font-size: 0.92rem; color: var(--text); }
.card a { color: #c9a66b; text-decoration-color: rgba(201, 166, 107, 0.45); }
.card a:hover { color: var(--accent); text-decoration-color: currentColor; }
.card p { margin-bottom: 10px; }
.card ol { padding-left: 22px; margin: 10px 0; }
.card ul { padding-left: 20px; margin-bottom: 10px; }
.card li { margin-bottom: 6px; }

/* ========== Card Link Wrapper ========== */
.card-link { text-decoration: none; color: inherit; }

/* ========== Clickable Card Variants ========== */
.card-clickable { cursor: pointer; transition: var(--transition); }
.card-clickable:hover { transform: translateY(-2px); border-color: var(--accent); }
.card-p0 { border-left: 3px solid var(--red); }
.card-p1 { border-left: 3px solid var(--yellow); }
.card-p2 { border-left: 3px solid var(--blue); }
.card-dlc { border-left: 3px solid #c08040; }
.card-read-time { font-size: 0.8rem; color: var(--accent); margin-top: 8px; }
.tag-inline { margin-left: 8px; }

/* ========== Page TOC (Guide Pages) ========== */
.page-toc { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 24px; }
.page-toc h4 { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.page-toc ol { padding-left: 20px; font-size: 0.88rem; }
.page-toc li { margin-bottom: 4px; }
.page-toc a { color: var(--accent); text-decoration: none; }
.page-toc a:hover { text-decoration: underline; }

/* ========== Card + Diagram Grid ========== */
.card-with-diagram { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .card-with-diagram { grid-template-columns: 1fr; } }

/* ========== SVG Global ========== */
svg { max-width: 100%; height: auto; }

/* ========== SVG Diagram Labels ========== */
.guide-diagram .label-text { font-size: 11px; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; fill: var(--text); }

/* ========== SVG Timeline Labels ========== */
.tl-lbl { font: bold 10px -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; fill: var(--text-muted,#888); text-anchor:middle; }
.tl-txt { font: bold 12px -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; fill:#fff; text-anchor:middle; }
.tl-nt  { font: 10px -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; fill:rgba(255,255,255,0.75); text-anchor:middle; }

/* ========== Page Header (Standalone Pages) ========== */
.page-header { margin-bottom: 32px; padding-bottom: 16px; border-bottom: 2px solid var(--accent); }
.page-header h2 { font-size: 1.6rem; color: #fff; margin-bottom: 6px; }
.page-header p { color: var(--text-muted); font-size: 0.9rem; }

/* ========== Heading Sub Text ========== */
.heading-sub { font-size: 0.8rem; color: var(--text-muted); font-weight: 400; }

/* ========== Nav Current Page Highlight ========== */
.nav-current { font-weight: 600; }

/* ========== Highlighted Term ========== */
.term { color: var(--accent); font-weight: 600; }

/* ========== Tips ========== */
.tip { background: rgba(90,159,212,0.1); border-left: 3px solid var(--blue); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; margin: 12px 0; font-size: 0.88rem; }
.tip.warn { background: rgba(192,57,43,0.1); border-left-color: var(--red); }
.tip.good { background: rgba(68,170,153,0.1); border-left-color: var(--green); }
.key { background: #333; color: var(--accent); padding: 1px 6px; border-radius: 3px; font-size: 0.85rem; font-family: "Cascadia Code", "Fira Code", monospace; }

/* ========== Tags ========== */
.tag { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.tag-p0 { background: var(--red); color: #fff; }
.tag-p1 { background: var(--yellow); color: #1a1a1f; }
.tag-p2 { background: var(--text-muted); color: #fff; }

/* ========== Emergency Guide Hub ========== */
.emergency-hub { padding: 24px; background: linear-gradient(135deg, rgba(192,57,43,.1), rgba(212,149,107,.05)); border: 1px solid var(--border); border-radius: var(--radius); }
.emergency-hub .section-title { margin-bottom: 8px; }
.emergency-hub > p { color: var(--text-muted); font-size: .9rem; margin-bottom: 18px; }
.emergency-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.emergency-grid .card { margin: 0; padding: 18px; min-height: 132px; }
.emergency-grid .card h3 { font-size: .98rem; }
.emergency-grid .card p { font-size: .84rem; margin: 0; }
.emergency-links { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.emergency-links a { display: block; padding: 12px; color: var(--text); text-decoration: none; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; font-size: .84rem; line-height: 1.4; }
.emergency-links a:hover { color: var(--accent); border-color: var(--accent); }
@media (max-width: 860px) { .emergency-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .emergency-links { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .emergency-hub { padding: 18px; } .emergency-grid { grid-template-columns: 1fr; } .emergency-links { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ========== Table ========== */
table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.9rem; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--accent); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ========== Search ========== */
.search-wrap { position: relative; margin-bottom: 32px; }
.search-wrap input { width: 100%; padding: 12px 16px 12px 44px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 0.95rem; font-family: inherit; transition: var(--transition); }
.search-wrap input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212,149,107,0.15); }
.search-wrap input::placeholder { color: var(--text-muted); }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 1.1rem; color: var(--text-muted); pointer-events: none; }
.search-clear { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.2rem; padding: 4px 8px; border-radius: 3px; display: none; }
.search-clear:hover { color: var(--text); background: var(--border); }
.search-clear.visible { display: block; }
.no-results { display: none; text-align: center; padding: 48px 24px; color: var(--text-muted); font-size: 1rem; }
.no-results.visible { display: block; }
.no-results .icon { font-size: 3rem; display: block; margin-bottom: 12px; }
.card.hidden, .section-title.hidden { display: none; }
.search-highlight { background: var(--yellow); color: #1a1a1f; padding: 0 2px; border-radius: 2px; }

/* ========== Guide Diagrams ========== */
.guide-diagram { margin: 20px 0 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.guide-diagram svg { display: block; width: 100%; height: auto; }
.guide-diagram figcaption { padding: 10px 16px; font-size: 0.82rem; color: var(--text-muted); text-align: center; border-top: 1px solid var(--border); background: rgba(0,0,0,0.15); }
body.light .guide-diagram figcaption { background: rgba(0,0,0,0.03); }

/* ========== Theme Toggle ========== */
.theme-toggle { display: flex; align-items: center; gap: 8px; padding: 8px 16px; margin: 0 12px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 0.85rem; color: var(--text); font-family: inherit; transition: var(--transition); }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle .toggle-thumb { width: 36px; height: 20px; background: var(--border); border-radius: 10px; position: relative; transition: background var(--transition); }
.theme-toggle .toggle-thumb::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform var(--transition); }
body.light .toggle-thumb { background: var(--accent); }
body.light .toggle-thumb::after { transform: translateX(16px); }

/* ========== Light Theme ========== */
body.light { --bg: #f4f4f6; --bg-card: #ffffff; --bg-sidebar: #f0f0f3; --border: #d8d8de; --text: #3a3a44; --text-muted: #888896; --accent: #b87050; --accent-dim: #8a5040; }
body.light .tip { background: rgba(90,159,212,0.08); }
body.light .tip.warn { background: rgba(192,57,43,0.06); }
body.light .tip.good { background: rgba(68,170,153,0.06); }
body.light .tl-txt { fill: var(--text); }
body.light .tl-nt { fill: var(--text-muted); }
body.light .key { background: #e8e8ec; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  main { padding: 60px 16px 32px; }
  .card { padding: 16px; }
}

/* ========== Print ========== */
@media print { main { max-width: 100%; padding: 0; } body { background: #fff; color: #000; } }

/* ========== Page Navigation ========== */
.page-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); }
.page-nav a { display: flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; font-size: 0.88rem; transition: var(--transition); }
.page-nav a:hover { border-color: var(--accent); color: var(--accent); }
.page-nav .prev::before { content: '← '; }
.page-nav .next::after { content: ' →'; }
.page-nav .nav-label { font-size: 0.72rem; color: var(--text-muted); display: block; }

/* ========== Back to Top ========== */
.back-to-top { position: fixed; bottom: 24px; right: 24px; width: 40px; height: 40px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 50%; cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity var(--transition); z-index: 50; color: var(--text); }
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { border-color: var(--accent); color: var(--accent); }

/* ========== H3 Subtitle ========== */
.h3-sub { font-size: 0.85rem; color: var(--text-muted); font-weight: 400; }

/* ========== Lang Switch ========== */
.lang-switch { text-align: right; margin-bottom: 12px; }

/* ========== Evidence and source transparency ========== */
.evidence-panel { margin: 0 0 24px; padding: 16px 20px; border: 1px solid rgba(90,159,212,0.45); border-left: 3px solid var(--blue); border-radius: var(--radius); background: rgba(90,159,212,0.08); font-size: 0.88rem; }
.evidence-panel strong { color: var(--blue); }
.evidence-panel p { margin: 6px 0; color: var(--text); }
.evidence-panel ul { margin: 8px 0 0; padding-left: 20px; }
.evidence-panel a, .source-disclosure a { color: var(--blue); }
.source-disclosure { font-size: 0.8rem; }
.sources-page { max-width: 900px; margin: 0 auto; padding: 48px 32px; }
.sources-page h1, .sources-page h2 { color: #fff; }
.sources-page h2 { margin-top: 32px; font-size: 1.2rem; }
.sources-page p, .sources-page li { color: var(--text); }
.sources-page ul { padding-left: 20px; }
.sources-page a { color: var(--accent); }
body.sources-body { display: block; }
@media (max-width: 768px) { .sources-page { padding: 64px 16px 32px; } }
