/* ============================================================
   assiw 文档中心 — 复刻 Xiaomi MIMO 文档站（暖白极简 · 黑白灰）
   ============================================================ */

:root {
  /* 色彩令牌（取自 MIMO docs-styles） */
  --bg-page: #fcfaf8;
  --bg-card: #faf7f3;
  --bg-section: #f0ebe5;
  --border-warm: #f0ebe5;
  --surface-hover: #f7f3ef;

  --text-primary: #1f2329;
  --text-secondary: #646a73;
  --text-tertiary: rgba(0, 0, 0, 0.55);
  --nav-item: #282828;
  --black: #000;
  --black-soft: #171717;

  --accent: #262626;
  --line: rgba(0, 0, 0, 0.08);

  /* 字体 */
  --font-main: "PingFang SC", -apple-system, "MiSans", "Helvetica Neue", sans-serif;
  --font-code: ui-monospace, "SFMono-Regular", "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* 尺寸 */
  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 60px;
  --sidebar-w: 268px;
  --toc-w: 208px;
  --content-max: 760px;

  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 0 1.5px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

::selection { background: #e8e3dc; }

/* ---------- 公告条 ---------- */
.announce {
  position: sticky;
  top: 0;
  z-index: 60;
  background: #000;
  color: #fff;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.announce-inner { display: flex; align-items: center; gap: 14px; }
.announce-text { letter-spacing: 0.2px; }
.announce-close {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}
.announce-close:hover { color: #fff; }

/* ---------- 顶部导航 ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--bg-page);
  border-bottom: 1px solid var(--border-warm);
}
body[data-announce="1"] .header { top: 38px; }

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--black-soft);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--black);
  letter-spacing: -0.2px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  margin-right: auto;
}
.header-nav a {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 14px;
  font-size: 14px;
  color: var(--text-tertiary);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
}
.header-nav a:hover { color: var(--text-primary); }
.header-nav a.is-active {
  color: rgba(0, 0, 0, 0.85);
  border-bottom-color: var(--black);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* 搜索 */
.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 11px;
  color: var(--text-secondary);
  pointer-events: none;
}
.search-input {
  width: 180px;
  height: 36px;
  padding: 0 30px 0 34px;
  border: 1px solid var(--border-warm);
  border-radius: 8px;
  background: #fff;
  font-size: 13.5px;
  color: var(--text-primary);
  transition: width 0.2s ease, border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
  width: 240px;
  outline: none;
  border-color: #d8d0c6;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}
.search-input::placeholder { color: var(--text-tertiary); }
.search-kbd {
  position: absolute;
  right: 9px;
  font-family: var(--font-code);
  font-size: 11px;
  color: var(--text-tertiary);
  border: 1px solid var(--border-warm);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 18px;
  background: var(--bg-page);
}
.search-results {
  position: absolute;
  top: 44px;
  left: 0;
  width: 320px;
  max-height: 420px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border-warm);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 55;
}
.search-results:empty::after {
  content: "无匹配结果";
  display: block;
  padding: 20px 14px;
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
}
.search-result {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.search-result:hover, .search-result.is-sel { background: var(--surface-hover); }
.search-result-title { font-size: 13.5px; color: var(--text-primary); }
.search-result-path { font-size: 12px; color: var(--text-tertiary); }

/* 语言切换 */
.lang { position: relative; }
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-warm);
  border-radius: 8px;
  background: #fff;
  color: var(--text-primary);
  font-size: 13.5px;
}
.lang-toggle .chev { color: var(--text-tertiary); }
.lang-menu {
  position: absolute;
  top: 44px;
  right: 0;
  min-width: 120px;
  background: #fff;
  border: 1px solid var(--border-warm);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  padding: 5px;
  z-index: 55;
}
.lang-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text-primary);
}
.lang-option:hover { background: var(--surface-hover); }
.lang-option.is-active { font-weight: 600; }

/* 控制台按钮 */
.console-btn {
  height: 36px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  background: var(--black);
  color: #fff;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  transition: opacity 0.15s;
}
.console-btn:hover { opacity: 0.85; }

/* 移动端菜单按钮 */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-warm);
  border-radius: 8px;
  background: #fff;
  color: var(--text-primary);
  flex-shrink: 0;
}

/* ---------- 三栏布局 ---------- */
.layout {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 48px;
  padding: 0 24px;
  align-items: start;
}

/* ---------- 左侧导航 ---------- */
.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  padding: 20px 0 24px;
  border-right: 1px solid var(--border-warm);
}
body[data-announce="1"] .sidebar { top: calc(var(--header-h) + 38px); height: calc(100vh - var(--header-h) - 38px); }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: #e0d9d0 transparent;
}

.nav-tree { display: flex; flex-direction: column; }

.nav-group { margin-bottom: 22px; }
.nav-group-head {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 6px;
  color: var(--black);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.16px;
  white-space: nowrap;
}
.nav-group-head.is-link:hover { background: var(--surface-hover); }
.nav-group-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-group-chev {
  color: var(--text-secondary);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.nav-group.is-collapsed .nav-group-chev { transform: rotate(-90deg); }

.nav-children { display: flex; flex-direction: column; gap: 1px; }
.nav-group.is-collapsed .nav-children { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 20px;
  color: var(--nav-item);
  letter-spacing: -0.16px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--surface-hover); }
.nav-item[data-depth="1"] { padding-left: 24px; }
.nav-item[data-depth="2"] { padding-left: 40px; }
.nav-item[data-depth="3"] { padding-left: 56px; }
.nav-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item.is-active {
  background: var(--black);
  color: #fff;
  font-weight: 500;
}
.nav-item.is-active:hover { background: var(--black); }

/* 分组标题（带副标题的顶级卡片样式，保留用于扩展） */
.nav-group-sub { font-size: 12px; color: var(--text-tertiary); }

.sidebar-card {
  margin-top: 16px;
  background: #fff;
  border: 1px solid var(--border-warm);
  border-radius: 6px;
  padding: 12px;
  box-shadow: var(--shadow-card);
}
.sidebar-card-body { display: flex; flex-direction: column; gap: 6px; }
.sidebar-card-title { font-size: 13px; font-weight: 600; color: var(--black); }
.sidebar-card-desc { font-size: 12px; line-height: 1.6; color: var(--text-tertiary); }
.sidebar-card-btn {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--black);
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
}

/* ---------- 主内容 ---------- */
.main-col { min-width: 0; padding-top: 36px; }

.content { min-height: 70vh; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-tertiary);
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb-sep { color: #c6beb4; font-size: 11px; }
.breadcrumb-current { color: var(--text-secondary); }

.page-head { margin: 18px 0 8px; }
.page-title {
  margin: 0;
  font-size: 32px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--black);
}
.page-sub {
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--text-secondary);
}

/* ---------- Markdown 正文 ---------- */
.markdown-body {
  max-width: var(--content-max);
  font-size: 15px;
  color: var(--text-primary);
  padding-top: 8px;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  color: var(--black);
  font-weight: 600;
  letter-spacing: -0.2px;
  line-height: 1.35;
  scroll-margin-top: calc(var(--header-h) + 24px);
}
.markdown-body h1 { font-size: 26px; margin: 36px 0 14px; }
.markdown-body h2 {
  font-size: 21px;
  margin: 40px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-warm);
}
.markdown-body h3 { font-size: 17px; margin: 28px 0 10px; }
.markdown-body h4 { font-size: 15px; margin: 24px 0 8px; }
.markdown-body h5, .markdown-body h6 { font-size: 14px; margin: 20px 0 8px; }

.markdown-body p { margin: 12px 0; }
.markdown-body a {
  color: var(--black);
  text-decoration: underline;
  text-decoration-color: #c9c1b6;
  text-underline-offset: 3px;
}
.markdown-body a:hover { text-decoration-color: var(--black); }

.markdown-body ul, .markdown-body ol { margin: 12px 0; padding-left: 26px; }
.markdown-body li { margin: 5px 0; }
.markdown-body li > ul, .markdown-body li > ol { margin: 4px 0; }

.markdown-body strong { font-weight: 600; color: var(--black); }

.markdown-body code {
  font-family: var(--font-code);
  font-size: 0.86em;
  background: var(--bg-section);
  border-radius: 5px;
  padding: 2px 6px;
  color: #3c3c3c;
}
.markdown-body pre {
  margin: 16px 0;
  padding: 16px 18px;
  background: #1c1b1a;
  border-radius: 10px;
  overflow-x: auto;
  line-height: 1.6;
}
.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: #e8e4dd;
  font-size: 13px;
}
.code-block { position: relative; }
.code-lang {
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--font-code);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.code-copy {
  position: absolute;
  top: 6px;
  right: 40px;
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 5px;
}
.code-copy:hover { color: #fff; }

.markdown-body blockquote {
  margin: 16px 0;
  padding: 2px 18px;
  border-left: 3px solid #d8d0c6;
  color: var(--text-secondary);
  background: var(--bg-card);
  border-radius: 0 8px 8px 0;
}
.markdown-body blockquote p { margin: 10px 0; }

.markdown-body hr {
  border: 0;
  height: 1px;
  background: var(--border-warm);
  margin: 32px 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-warm);
  padding: 9px 13px;
  text-align: left;
}
.markdown-body th {
  background: var(--bg-card);
  font-weight: 600;
  color: var(--black);
  white-space: nowrap;
}
.markdown-body tr:nth-child(even) td { background: #fcfaf8; }

.markdown-body img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border-warm);
}

/* 提示块 :::note / :::tip / :::warning / :::danger */
.admonition {
  margin: 16px 0;
  padding: 13px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-warm);
  background: var(--bg-card);
  font-size: 14px;
}
.admonition-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.admonition p:last-child { margin-bottom: 0; }
.admonition-tip { background: #f6f8f6; border-color: #e4e9e4; }
.admonition-tip .admonition-title { color: #2f6b3f; }
.admonition-warning { background: #fbf7ef; border-color: #f0e5d0; }
.admonition-warning .admonition-title { color: #9a6b1f; }
.admonition-danger { background: #fbf5f5; border-color: #f0dddd; }
.admonition-danger .admonition-title { color: #b33a3a; }

/* ---------- 上下页导航 ---------- */
.prev-next {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 48px 0 8px;
  padding-top: 24px;
  border-top: 1px solid var(--border-warm);
  max-width: var(--content-max);
}
.pn-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 16px;
  border: 1px solid var(--border-warm);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pn-card:hover { border-color: #d8d0c6; box-shadow: var(--shadow-card); }
.pn-card.is-next { text-align: right; align-items: flex-end; }
.pn-label { font-size: 12px; color: var(--text-tertiary); }
.pn-title { font-size: 14px; font-weight: 500; color: var(--black); }
.pn-empty { flex: 1; }

/* ---------- 右侧目录 ---------- */
.toc-col {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  padding: 4px 0 0;
  scrollbar-width: none;
}
body[data-announce="1"] .toc-col {
  top: calc(var(--header-h) + 38px + 24px);
  max-height: calc(100vh - var(--header-h) - 38px - 48px);
}
.toc-col::-webkit-scrollbar { display: none; }
.toc-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 10px;
  padding-left: 12px;
}
.toc-nav { display: flex; flex-direction: column; border-left: 1px solid var(--border-warm); }
.toc-nav a {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-tertiary);
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.toc-nav a:hover { color: var(--text-primary); }
.toc-nav a.is-active {
  color: var(--black);
  border-left-color: var(--black);
  font-weight: 500;
}
.toc-nav a[data-level="3"] { padding-left: 24px; font-size: 12.5px; }

/* ---------- 页脚 ---------- */
.footer {
  max-width: var(--content-max);
  padding: 32px 0 40px;
  margin-top: 32px;
  border-top: 1px solid var(--border-warm);
  font-size: 13px;
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.footer a { color: var(--text-secondary); }
.footer a:hover { color: var(--black); }

/* ---------- 遮罩（移动端） ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 45;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1280px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc-col { display: none; }
}

@media (max-width: 900px) {
  .header-nav, .search { display: none; }
  .menu-toggle { display: inline-flex; }
  .header-inner { gap: 14px; padding: 0 16px; }

  .layout {
    display: block;
    padding: 0 16px;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    height: 100vh;
    z-index: 50;
    background: var(--bg-page);
    border-right: 1px solid var(--border-warm);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding: 16px 16px 24px;
  }
  .sidebar.is-open { transform: translateX(0); }
  .main-col { padding-top: 24px; }
  .page-title { font-size: 26px; }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
