/*
 * Wiki 阅读壳：顶栏、三栏骨架、文件树、本页导航。
 * 只消费 main.css 的 token；Landing 复用本文件的顶栏。
 */

/* 账号组件与服务端登录占位共用；不依赖三栏阅读壳。 */
.wiki-account {
  position: relative;
  display: flex;
  align-items: center;
  flex: none;
}

.wiki-avatar-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  overflow: hidden;
  background: var(--paper-2);
  color: var(--ink-2);
  transition: 0.2s;
  padding: 0;
}

.wiki-avatar-btn svg {
  width: 18px;
  height: 18px;
}

.wiki-avatar-btn:hover {
  border-color: var(--watcha);
  color: var(--ink);
}

.wiki-avatar-btn.wiki-account-login-cta {
  display: flex;
  width: auto;
  min-width: 0;
  height: 38px;
  gap: 7px;
  padding: 0 15px;
  overflow: visible;
  border-color: var(--ink);
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper-2);
  font-size: var(--t-ui);
  font-weight: 500;
  white-space: nowrap;
}

.wiki-avatar-btn.wiki-account-login-cta:hover {
  border-color: var(--watcha-deep);
  background: var(--watcha-deep);
  color: var(--paper-2);
  transform: translateY(-1px);
}

.wiki-account-login-cta__mark {
  color: #8ddb6b;
  font-size: var(--t-mono);
}

.wiki-avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wiki-account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 168px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 18px 44px -18px rgba(26, 22, 17, 0.35);
  z-index: 75;
}

.wiki-account-menu__name {
  font-size: var(--t-ui);
  font-weight: 700;
  color: var(--ink);
  padding: 8px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wiki-account-menu__logout {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: var(--t-ui);
  color: var(--red-deep);
  text-align: left;
  transition: 0.2s;
}

.wiki-account-menu__logout:hover {
  background: rgba(191, 58, 38, 0.07);
}

.wiki-account-login-cta,
.wiki-account-menu__name,
.wiki-account-menu__logout {
  line-height: var(--lh-ui);
}

/* ============ 顶栏 ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 70;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.top-inner {
  width: min(var(--shell-max), 94%);
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.brandmark {
  width: 30px;
  height: 30px;
  display: block;
  flex: none;
}

.brandmark img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 8px;
}

.brand-t {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: var(--t-h3);
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: var(--ink);
}

.top-search {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 1 300px;
  margin-left: auto;
  border: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--paper-2) 66%, transparent);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--mut);
  font-size: var(--t-ui);
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.top-search:hover,
.top-search:focus-visible {
  border-color: var(--mut);
  background: var(--paper-2);
  color: var(--ink-2);
}

.top-search:focus-visible {
  outline: none;
}

.top-search svg {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.top-search__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-search kbd {
  font-family: var(--font-mono);
  font-size: var(--t-mono);
  border: 1px solid var(--line-2);
  border-radius: 5px;
  padding: 2px 6px;
  color: var(--mut);
  background: var(--card);
  white-space: nowrap;
}

/* ============ Ctrl K 课程搜索 ============ */
.space-search[hidden] {
  display: none;
}

.space-search {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: grid;
  place-items: start center;
  padding: min(13vh, 112px) 20px 28px;
}

.space-search__mask {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(26, 22, 17, 0.42);
  cursor: default;
}

.space-search__dialog {
  position: relative;
  width: min(680px, 100%);
  max-height: min(72vh, 680px);
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 13px;
  background: var(--paper-2);
  box-shadow: 0 24px 80px rgba(38, 30, 19, 0.18);
  color: var(--ink);
}

.space-search__field {
  display: grid;
  grid-template-columns: 19px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.space-search__field > svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--mut);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.space-search__input {
  width: 100%;
  color: var(--ink);
  font-size: var(--t-cardtitle);
  line-height: var(--lh-ui);
}

.space-search__input::placeholder {
  color: var(--mut);
}

.space-search__input:focus-visible {
  outline: none;
}

.space-search__field > button {
  border: 1px solid var(--line-2);
  border-radius: 5px;
  padding: 3px 6px;
  color: var(--mut);
  font-family: var(--font-mono);
  font-size: var(--t-mono);
  line-height: var(--lh-ui);
}

.space-search__field > button:hover,
.space-search__field > button:focus-visible {
  border-color: var(--mut);
  color: var(--ink-2);
}

.space-search__body {
  max-height: calc(min(72vh, 680px) - 62px);
  overflow-y: auto;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.space-search__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 7px 8px;
  color: var(--mut);
}

.space-search__meta p,
.space-search__meta small {
  margin: 0;
  font-size: var(--t-mono);
  line-height: var(--lh-ui);
}

.space-search__meta p {
  color: var(--ink-2);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.space-search__results {
  display: grid;
  gap: 3px;
}

.space-search__results a {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  min-height: 66px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.space-search__results a:hover,
.space-search__results a:focus-visible,
.space-search__results a[data-search-active="true"] {
  outline: none;
  border-color: var(--watcha-line);
  background: var(--watcha-soft);
}

.space-search__result-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--mut);
  background: var(--card);
}

.space-search__result-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.space-search__result-copy {
  display: grid;
  min-width: 0;
}

.space-search__result-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: var(--t-comp);
  line-height: var(--lh-ui);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.space-search__result-copy small {
  margin-top: 2px;
  overflow: hidden;
  color: var(--mut);
  font-size: var(--t-mono);
  line-height: var(--lh-ui);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.space-search__result-copy > span {
  margin-top: 2px;
  overflow: hidden;
  color: var(--ink-2);
  font-size: var(--t-ui);
  line-height: var(--lh-ui);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.space-search__results a > i {
  color: var(--watcha-deep);
  font-size: var(--t-mono);
  font-style: normal;
  white-space: nowrap;
}

.space-search__empty {
  margin: 4px 7px 8px;
  color: var(--mut);
  font-size: var(--t-ui);
  line-height: var(--lh-comp);
}

html.wiki-search-open,
html.wiki-search-open body {
  overflow: hidden;
}

.top-links {
  margin-left: auto;
  display: flex;
  gap: 22px;
}

.top-links a {
  font-size: var(--t-ui);
  font-weight: 500;
  color: var(--ink-2);
  transition: 0.2s;
  white-space: nowrap;
}

.top-links a:hover {
  color: var(--watcha-deep);
}

.ask-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--ink);
  color: var(--paper-2);
  font-size: var(--t-ui);
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 9px;
  transition: 0.25s;
  white-space: nowrap;
  flex: none;
}

.ask-btn i {
  font-style: normal;
  color: #8ddb6b;
  font-size: var(--t-mono);
}

.ask-btn:hover {
  background: var(--watcha-deep);
  transform: translateY(-1px);
}

/* 顶栏账号区 */
.top-account-slot {
  display: flex;
  align-items: center;
  flex: none;
  margin-left: auto;
}

/* 搜索存在时由搜索占据中间弹性空间；账号仍固定在最右。 */
.top-search + .top-account-slot {
  margin-left: 0;
}

/* 阅读进度 */
.progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 2px;
  background: transparent;
}

.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--watcha-deep);
}

/* ============ 窄屏侧栏入口 ============ */
.mobile-panel-switcher {
  display: none;
}

.mobile-panel-switcher__button {
  display: none;
  align-items: center;
  gap: 7px;
  padding: 5px 0;
  border: 0;
  color: var(--ink-2);
  background: transparent;
  font: inherit;
  font-size: var(--t-ui);
  cursor: pointer;
}

.mobile-panel-switcher__button:hover {
  color: var(--watcha-deep);
}

.mobile-panel-switcher__line {
  display: block;
  flex: 1;
  height: 1px;
  background: var(--line);
}

.mobile-panel-switcher__button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* ============ 三栏骨架 ============ */
.layout {
  width: min(var(--shell-max), 94%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--rail-w);
  gap: 42px;
}

.side,
.rail {
  position: sticky;
  top: calc(var(--head-h) + 18px);
  max-height: calc(100vh - var(--head-h) - 36px);
  overflow-y: auto;
  padding: 30px 0 70px;
  scrollbar-color: var(--line-2) transparent;
  scrollbar-width: thin;
}

.rail {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 30px;
}

.side::-webkit-scrollbar,
.rail::-webkit-scrollbar {
  display: block;
  width: 4px;
}

.side::-webkit-scrollbar-track,
.rail::-webkit-scrollbar-track {
  background: transparent;
}

.side::-webkit-scrollbar-thumb,
.rail::-webkit-scrollbar-thumb {
  border: 0;
  border-radius: 999px;
  background: var(--line-2);
}

.sheet {
  background: var(--paper-2);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 52px 56px 100px;
  min-height: 100vh;
  animation: sheetIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes sheetIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.wiki-article {
  max-width: var(--article-measure);
  margin: 0 auto;
}

.wiki-skip-link {
  position: absolute;
  top: -48px;
  left: 16px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper-2);
  font-size: var(--t-ui);
  transition: top 0.2s;
}

.wiki-skip-link:focus-visible {
  top: 8px;
}

/* ============ 左侧目录树 ============ */
.col-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: var(--t-mono);
  letter-spacing: 0.14em;
  color: var(--mut);
  margin-bottom: 16px;
}

.col-label::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--watcha);
  border-radius: 2px;
  flex: none;
}

.g {
  margin-bottom: 4px;
}

.g[hidden],
.g-list a[hidden] {
  display: none;
}

.g-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: var(--t-ui);
  font-weight: 700;
  color: var(--ink);
  transition: 0.2s;
  text-align: left;
}

.g-head:hover {
  background: var(--card);
}

.g-kanji {
  width: 23px;
  height: 23px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: var(--t-ui);
  font-weight: 900;
  background: var(--paper-2);
  color: var(--ink-2);
  flex: none;
  transition: 0.2s;
}

.g.open > .g-head .g-kanji {
  border-color: var(--watcha-line);
  background: var(--watcha-soft);
  color: var(--watcha-deep);
}

.g-head .cnt {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--t-mono);
  color: var(--mut);
  font-weight: 400;
}

.g-head .chev {
  width: 13px;
  height: 13px;
  color: var(--mut);
  transition: transform 0.25s;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.g-head .chev.only {
  margin-left: auto;
}

.g.open > .g-head .chev {
  transform: rotate(90deg);
}

.g-list {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.g.open > .g-list {
  grid-template-rows: 1fr;
}

.g-list > div {
  overflow: hidden;
}

.g-list a {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: var(--t-ui);
  font-weight: 400;
  color: var(--ink-2);
  /* 右侧缓冲默认保留；选中加粗时再释放给标题使用。 */
  padding: 8px 24px 8px 43px;
  border-radius: 9px;
  transition: background-color 0.15s, color 0.15s;
  position: relative;
}

.g-list a:hover {
  background: var(--card);
  color: var(--ink);
}

.g-list a.is-navigation-locked {
  cursor: not-allowed;
  color: var(--ink-3);
}

.g-list a.is-navigation-locked .course-lock-icon {
  margin-left: auto;
}

.g-list a.is-navigation-locked:hover {
  background: transparent;
  color: var(--ink-3);
}

.g-list a.on {
  background: var(--watcha-soft);
  color: var(--watcha-deep);
}

.g-list a.on::before {
  content: "";
  position: absolute;
  left: 26px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--watcha);
}

/* 嵌套子分组：比顶级分组低一层，不带单字徽标 */
.g--sub {
  margin: 2px 0 2px 16px;
}

.g--sub > .g-head {
  font-size: var(--t-ui);
  font-weight: 700;
  color: var(--ink-2);
  padding: 7px 10px;
}

.g--sub > .g-list a {
  padding-left: 24px;
}

.g--sub > .g-list a.on::before {
  left: 8px;
}

.side-foot {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-foot a,
.side-foot button,
.rail-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-ui);
  color: var(--mut);
  padding: 7px 10px;
  border-radius: 8px;
  transition: 0.2s;
  text-align: left;
  width: 100%;
}

.side-foot a i,
.side-foot button i,
.rail-cta i {
  font-style: normal;
  color: var(--watcha);
  font-size: var(--t-mono);
}

.side-foot a:hover,
.side-foot button:hover,
.rail-cta:hover {
  color: var(--ink);
  background: var(--card);
}

.side-foot .side-foot__cta,
.rail-cta {
  margin-bottom: 6px;
  padding: 10px 12px;
  border-radius: 9px;
  font-weight: 700;
}

.side-foot .side-foot__cta--soft {
  border: 1px solid var(--watcha-line);
  background: var(--watcha-soft);
  color: var(--watcha-deep);
}

.rail-cta--soft {
  border: 1px solid var(--watcha-line);
  background: var(--watcha-soft);
  color: var(--watcha-deep);
}

.side-foot .side-foot__cta--soft:hover,
.rail-cta--soft:hover {
  border-color: var(--watcha);
  background: var(--watcha-soft);
  color: var(--watcha-deep);
  transform: translateY(-1px);
}

/* 壳层交互统一使用 T8 UI 的紧凑行高，避免继承正文的 2 倍行高。 */
.top-search,
.top-links a,
.ask-btn,
.wiki-skip-link,
.g-head,
.g-list a,
.side-foot a,
.side-foot button,
.rail-cta,
.rail nav a,
.rail-empty,
.copy-btn {
  line-height: var(--lh-ui);
}

/* ============ 右侧本页导航 ============ */
.rail-outline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rail-outline-head .col-label {
  margin-bottom: 0;
}

.rail-outline-toggle {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--mut);
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease;
}

.rail-outline-toggle:hover {
  color: var(--watcha-deep);
  background: var(--watcha-soft);
}

.rail-outline-toggle:focus-visible {
  outline: 1px solid var(--watcha);
  outline-offset: 2px;
}

.rail-outline-toggle svg {
  grid-area: 1 / 1;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 120ms ease, transform 160ms ease;
}

.rail-outline-toggle .is-collapse,
.rail-outline-toggle[aria-expanded='true'] .is-expand {
  opacity: 0;
  transform: scale(0.72);
}

.rail-outline-toggle[aria-expanded='true'] .is-collapse {
  opacity: 1;
  transform: scale(1);
}

.rail-outline-scroll {
  flex: 0 1 auto;
  min-height: 0;
  max-height: min(240px, 36vh);
  margin-top: 12px;
  overflow-y: auto;
  padding-right: 2px;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.rail-outline-scroll[hidden] {
  display: none;
}

.rail-outline-scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.rail-outline-scroll:focus-visible {
  outline: 1px solid var(--watcha-line);
  outline-offset: 4px;
  border-radius: 4px;
}

.rail nav a {
  display: block;
  font-size: var(--t-ui);
  color: var(--mut);
  padding: 6.5px 0 6.5px 15px;
  border-left: 2px solid var(--line);
  transition: 0.2s;
  line-height: var(--lh-ui);
}

.rail nav a[data-level='3'] {
  padding-left: 27px;
  font-size: var(--t-ui);
}

.rail nav a[hidden] {
  display: none;
}

.rail nav a:hover {
  color: var(--ink);
}

.rail nav a.on {
  color: var(--watcha-deep);
  border-left-color: var(--watcha);
}

.rail-empty {
  font-size: var(--t-ui);
  color: var(--mut);
  line-height: var(--lh-ui);
}

.rail-actions {
  display: grid;
  gap: 7px;
  flex: none;
  margin-top: 14px;
}

.rail-actions .rail-cta {
  margin-bottom: 0;
}

body:not(:has([data-course-discussion-outlet] .course-discussion)) [data-course-discussion-action] {
  display: none;
}

body:not(:has([data-course-discussion-outlet] .course-discussion)) .rail-reader-actions:not(:has([data-reader-homework]:not([hidden]))) {
  display: none;
}

.rail-cta {
  appearance: none;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.rail-reader-actions .rail-cta {
  min-height: 40px;
  padding: 9px 12px;
  font-family: var(--font-sans);
  font-size: var(--t-ui);
  font-weight: 600;
  line-height: var(--lh-ui);
  border: 1px solid var(--line-2);
  background: var(--paper-2);
  color: var(--ink-2);
}

.rail-reader-actions .rail-cta--soft,
.rail-reader-actions .rail-cta:hover {
  border-color: var(--watcha-line);
  background: var(--watcha-soft);
  color: var(--watcha-deep);
  transform: none;
}

.rail-reader-actions [hidden] {
  display: none;
}

.rail-reader-actions svg,
.reader-back-top svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reader-back-top {
  position: fixed;
  right: max(24px, calc((100vw - min(var(--shell-max), 94vw)) / 2 + var(--rail-w) - 44px));
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 60;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--ink-2);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 0s linear 180ms;
}

.reader-back-top[data-visible='true'] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0s;
}

.reader-back-top:hover {
  color: var(--watcha-deep);
  border-color: var(--watcha-line);
  background: var(--watcha-soft);
}

.reader-back-top:focus-visible {
  outline: 2px solid var(--watcha);
  outline-offset: 3px;
}

@media (max-width: 1180px) {
  .reader-back-top {
    right: max(20px, env(safe-area-inset-right));
  }
}

@media (prefers-reduced-motion: reduce) {
  .reader-back-top {
    transition: none;
    transform: none;
  }
}

.rail-close {
  display: none;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--ink-2);
  background: var(--paper-2);
  margin-bottom: 14px;
}

.rail-close svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ============ 移动端抽屉 ============ */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 22, 17, 0.4);
  z-index: 84;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
}

.backdrop.show {
  opacity: 1;
  pointer-events: auto;
}



/* ============ 独立页（404 等） ============ */
.wiki-site-header {
  position: sticky;
  top: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 max(3%, 18px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(14px);
}

.wiki-site-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: var(--t-h3);
  color: var(--ink);
}

.wiki-site-header__brand img {
  border-radius: 8px;
}

.wiki-site-header__home {
  font-size: var(--t-ui);
  font-weight: 500;
  color: var(--ink-2);
}

.wiki-site-header__home:hover {
  color: var(--watcha-deep);
}

.wiki-not-found {
  width: min(560px, 90%);
  margin: 0 auto;
  padding: 96px 0 120px;
  text-align: center;
}

.wiki-not-found p {
  font-family: var(--font-gara);
  font-style: italic;
  font-size: 64px;
  color: var(--red);
  line-height: 1;
}

.wiki-not-found h1 {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: var(--t-h2);
  margin: 18px 0 10px;
}

.wiki-not-found span {
  display: block;
  color: var(--ink-2);
  font-size: var(--t-comp);
  line-height: var(--lh-comp);
}

.wiki-not-found a {
  display: inline-flex;
  margin-top: 26px;
  background: var(--ink);
  color: var(--paper-2);
  font-size: var(--t-ui);
  font-weight: 500;
  padding: 11px 20px;
  border-radius: 9px;
  transition: 0.2s;
}

.wiki-not-found a:hover {
  background: var(--watcha-deep);
}

/* ============ 响应式 ============ */
@media (max-width: 1180px) {
  .mobile-panel-switcher {
    position: sticky;
    top: 64px;
    z-index: 65;
    display: flex;
    width: min(var(--shell-max), 94%);
    margin: 0 auto;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .mobile-panel-switcher__outline {
    display: inline-flex;
  }

  .layout {
    grid-template-columns: 236px minmax(0, 1fr);
  }

  .rail {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 292px;
    max-height: none;
    background: var(--paper-2);
    border-left: 1px solid var(--line);
    z-index: 90;
    transform: translateX(105%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 26px 22px 60px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .rail.open {
    transform: none;
  }

  .rail.open .rail-close {
    display: inline-flex;
  }

}

@media (max-width: 1000px) {
  .top-links {
    display: none;
  }

  .ask-btn {
    margin-left: auto;
  }

  .top-search {
    margin-left: auto;
  }
}

@media (max-width: 960px) {
  .mobile-panel-switcher__tree {
    display: inline-flex;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 292px;
    max-height: none;
    background: var(--paper-2);
    border-right: 1px solid var(--line);
    z-index: 90;
    transform: translateX(-105%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 26px 22px 60px;
    overflow-y: auto;
  }

  .side.open {
    transform: none;
  }

  .side.open .side-close {
    display: inline-flex;
  }

  .side .col-label {
    margin-top: 4px;
  }

  .sheet {
    border-left: none;
    border-right: none;
    padding: 18px 0 90px;
    background: transparent;
  }
}

@media (max-width: 760px) {
  .top-search {
    display: flex;
    flex: none;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-left: auto;
    padding: 0;
    border-radius: 8px;
  }

  .top-search__label,
  .top-search kbd {
    display: none;
  }

  .space-search {
    align-items: start;
    padding: 72px 10px 10px;
  }

  .space-search__dialog {
    max-height: calc(100dvh - 84px);
    border-radius: 11px;
  }

  .space-search__body {
    max-height: calc(100dvh - 146px);
  }

  .space-search__field {
    padding: 13px 12px;
  }

  .space-search__meta small,
  .space-search__result-copy > span {
    display: none;
  }

  .space-search__results a {
    min-height: 58px;
    padding: 8px;
  }
}
