/* ==========================================================================
 * 墨匣 XNote — 应用壳样式
 *
 * 纪律：
 *   1. 只消费 XUI 令牌（var(--bg-elev-1)…），不写死任何颜色/间距；
 *   2. 布局差异全部收敛在 .app-* 命名空间，vendor/ 里的 XUI 与 Vditor 不做手改；
 *   3. 编辑区内部的样式在 css/editor.css（Vditor 覆盖层），打印在 css/print.css。
 * ========================================================================== */

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--t-body-size);
  line-height: var(--t-body-lh);
  color: var(--text-1);
  background: var(--bg-base);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app-skip {
  position: fixed;
  left: var(--s-3);
  top: var(--s-3);
  z-index: var(--z-tooltip);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  background: var(--bg-elev-3);
  color: var(--text-1);
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform var(--d-fast) var(--ease);
}

.app-skip:focus-visible {
  transform: translateY(0);
}

/* Vditor 的图标是内联 SVG，XUI 的图标是 background-image？—— 统一由 app.js 注入 SVG */
.app-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: currentColor;
  flex: none;
}

.app-icon svg {
  display: block;
}

/* ==========================================================================
 * 1. 标题栏 / 顶栏
 * ========================================================================== */

.app-shell {
  height: 100vh;
  height: 100dvh;
}

.app-titlebar {
  gap: var(--s-2);
  min-height: 32px;
}

.app-brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  flex: none;
}

.app-brand-name {
  letter-spacing: 0.01em;
  color: var(--text-1);
}

.app-brand-name b {
  font-weight: var(--t-weight-semibold);
  color: var(--accent);
}

.app-titlebar-sep {
  width: 1px;
  height: 12px;
  background: var(--line);
}

.app-titlebar-context {
  font-size: var(--t-micro-size);
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-titlebar-badge {
  font-size: var(--t-micro-size);
  color: var(--text-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 1px var(--s-2);
  background: var(--bg-elev-1);
}

/* 无边框（XShell 批准 window.frameless）时，标题栏变成可拖拽窗口边框 */
:root[data-frameless="1"] .app-titlebar {
  -webkit-app-region: drag;
}

:root[data-frameless="1"] .app-titlebar button,
:root[data-frameless="1"] .app-titlebar input {
  -webkit-app-region: no-drag;
}

.app-window-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: var(--s-2);
}

.app-win-btn {
  width: 34px;
  height: 24px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}

.app-win-btn:hover {
  background: var(--bg-elev-3);
  color: var(--text-1);
}

.app-win-btn.is-close:hover {
  background: var(--danger);
  color: #fff;
}

/* 顶栏 ------------------------------------------------------------------ */

.app-topbar {
  gap: var(--s-2);
  padding: 0 var(--s-3);
}

.app-topbar-main {
  flex: 1;
  min-width: 0;
  gap: var(--s-2-5);
}

.app-icon-btn {
  flex: none;
}

.app-title-box {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 0 var(--s-1);
}

.app-doc-title {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--r-xs);
  padding: 2px var(--s-1-5);
  margin-left: calc(var(--s-1-5) * -1);
  color: var(--text-1);
  font-family: inherit;
  font-size: var(--t-h2-size);
  font-weight: var(--t-weight-semibold);
  line-height: 1.25;
  text-overflow: ellipsis;
  transition: background var(--d-fast) var(--ease), border-color var(--d-fast) var(--ease);
}

.app-doc-title:hover {
  background: var(--bg-elev-2);
}

.app-doc-title:focus {
  outline: none;
  background: var(--bg-elev-2);
  border-color: var(--accent-ring);
}

.app-doc-sub {
  display: flex;
  align-items: center;
  gap: var(--s-1-5);
  min-width: 0;
  font-size: var(--t-micro-size);
  color: var(--text-3);
}

.app-doc-sub-sep {
  color: var(--line-strong);
}

.app-doc-path {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-save-state {
  white-space: nowrap;
}

.app-save-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--text-3);
  flex: none;
  transition: background var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease);
}

.app-save-dot.is-dirty {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
}

.app-save-dot.is-saving {
  background: var(--info);
  box-shadow: 0 0 0 3px var(--info-soft);
}

.app-save-dot.is-saved {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.app-save-dot.is-error {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  flex: none;
}

.app-action {
  gap: var(--s-1-5);
  color: var(--text-2);
}

.app-action:hover {
  color: var(--text-1);
}

.app-action[aria-pressed="true"] {
  color: var(--accent-on-soft);
  background: var(--accent-soft);
}

.app-action-sep {
  width: 1px;
  height: 16px;
  background: var(--line);
  margin: 0 var(--s-1);
}

/* ==========================================================================
 * 2. 活动栏 / 侧栏 / 文档列表
 * ========================================================================== */

.app-activity {
  gap: var(--s-1);
}

.app-activity .xui-activity-btn svg {
  width: 18px;
  height: 18px;
}

.app-sidebar {
  min-width: 0;
}

.app-sidebar-head {
  gap: var(--s-2);
}

.app-sidebar-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}

.app-sidebar-title strong {
  font-size: var(--t-small-size);
  font-weight: var(--t-weight-semibold);
  color: var(--text-1);
}

.app-count {
  font-size: var(--t-micro-size);
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  background: var(--bg-elev-3);
  border-radius: var(--r-pill);
  padding: 0 var(--s-1-5);
  min-width: 18px;
  text-align: center;
}

.app-sidebar-tools {
  display: flex;
  align-items: center;
  gap: var(--s-0-5);
}

.app-search-wrap {
  position: relative;
  margin: var(--s-2) var(--s-2) var(--s-1);
  flex: none;
}

.app-search-icon {
  position: absolute;
  left: var(--s-2);
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-3);
  pointer-events: none;
}

.app-search {
  width: 100%;
  padding-left: 28px !important;
  padding-right: 26px !important;
  height: var(--btn-h-sm);
  font-size: var(--t-small-size);
}

.app-search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-search-clear:hover {
  background: var(--bg-elev-3);
  color: var(--text-1);
}

.app-doc-scroll {
  padding-top: var(--s-1);
  padding-bottom: var(--s-2);
}

.app-doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.app-doc-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  padding: var(--s-1-5) var(--s-2);
  text-align: left;
  cursor: pointer;
  color: var(--text-2);
  transition: background var(--d-fast) var(--ease), border-color var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}

.app-doc-item:hover {
  background: var(--bg-elev-3);
  color: var(--text-1);
}

.app-doc-item.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-ring);
  color: var(--text-1);
}

.app-doc-item.is-active .app-doc-item-title {
  color: var(--accent-on-soft);
}

.app-doc-item-row {
  display: flex;
  align-items: center;
  gap: var(--s-1-5);
  min-width: 0;
}

.app-doc-item-title {
  flex: 1;
  min-width: 0;
  font-size: var(--t-small-size);
  font-weight: var(--t-weight-medium);
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-doc-item-pin {
  width: 12px;
  height: 12px;
  color: var(--accent);
  flex: none;
}

.app-doc-item-meta {
  display: flex;
  align-items: center;
  gap: var(--s-1-5);
  min-width: 0;
  font-size: var(--t-micro-size);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.app-doc-item-excerpt {
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-3);
}

.app-doc-item-more {
  position: absolute;
  right: var(--s-1);
  top: var(--s-1);
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: var(--r-xs);
  background: var(--bg-elev-3);
  color: var(--text-2);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.app-doc-item:hover .app-doc-item-more,
.app-doc-item.is-active .app-doc-item-more,
.app-doc-item-more:focus-visible {
  display: inline-flex;
}

.app-doc-item-more:hover {
  background: var(--bg-elev-4);
  color: var(--text-1);
}

.app-doc-group-label {
  padding: var(--s-2) var(--s-2) var(--s-1);
  font-size: var(--t-micro-size);
  font-weight: var(--t-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.app-doc-empty {
  margin: var(--s-6) var(--s-3);
  text-align: center;
  font-size: var(--t-small-size);
  color: var(--text-2);
  line-height: 1.6;
}

.app-doc-empty span {
  font-size: var(--t-micro-size);
  color: var(--text-3);
}

.app-sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: var(--s-1-5);
}

.app-storage-row {
  display: flex;
  align-items: center;
  gap: var(--s-1-5);
  min-width: 0;
  font-size: var(--t-micro-size);
  color: var(--text-3);
}

.app-storage-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--text-3);
  flex: none;
}

.app-storage-dot.is-xshell {
  background: var(--accent);
}

.app-storage-dot.is-browser {
  background: var(--info);
}

.app-storage-dot.is-file {
  background: var(--warn);
}

.app-storage-dot.is-fallback {
  background: var(--danger);
}

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

/* ==========================================================================
 * 3. 主区 / 编辑器
 * ========================================================================== */

.app-main {
  flex-direction: row;
  position: relative;
}

.app-editor-stack {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}

.app-editor-host {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.app-vditor {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.app-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-6);
  background: var(--bg-base);
  z-index: 3;
}

.app-empty-inner {
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
}

.app-empty-mark {
  width: 56px;
  height: 56px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--s-1);
}

.app-empty h2 {
  margin: 0;
  font-size: var(--t-h1-size);
  font-weight: var(--t-weight-semibold);
  color: var(--text-1);
}

.app-empty p {
  margin: 0;
  color: var(--text-2);
  font-size: var(--t-small-size);
  line-height: 1.7;
}

.app-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-2);
  margin: var(--s-2) 0;
}

.app-empty-hint {
  margin-top: var(--s-2) !important;
  font-size: var(--t-micro-size) !important;
  color: var(--text-3) !important;
}

.app-empty-hint kbd {
  margin: 0 2px;
}

.app-boot {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  background: var(--bg-base);
  color: var(--text-2);
  font-size: var(--t-small-size);
  transition: opacity var(--d-base) var(--ease), visibility var(--d-base) var(--ease);
}

.app-boot[hidden] {
  display: none;
}

.app-boot img {
  animation: app-boot-pulse 1.6s var(--ease) infinite;
}

@keyframes app-boot-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.98); }
  50% { opacity: 1; transform: scale(1); }
}

.app-boot p {
  margin: 0;
}

/* 编辑器内核占位（js/app.js 的 showEditorSkeleton）：
 * 文档已经打开、外壳已经可交互，只是 Vditor 的 lute（3.5MB → gzip ≈592KB）还在路上。
 * 和 .app-boot 的区别：层级更低（不吃掉顶栏按钮），文案区分「外壳就绪 / 内核未就绪」。 */
.app-editor-skeleton {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-6);
  text-align: center;
  background: var(--bg-base);
  color: var(--text-2);
  font-size: var(--t-small-size);
}

.app-editor-skeleton[hidden] {
  display: none;
}

.app-editor-skeleton::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: app-boot-pulse 1.4s var(--ease) infinite;
}

.app-editor-skeleton p {
  margin: 0;
}

.app-editor-skeleton-msg {
  max-width: 46ch;
  line-height: 1.7;
}

.app-editor-skeleton-hint {
  max-width: 46ch;
  font-size: var(--t-micro-size);
  color: var(--text-3);
  line-height: 1.7;
}

.app-editor-skeleton .xui-btn {
  margin-top: var(--s-2);
}

/* 大纲 ------------------------------------------------------------------ */

.app-outline {
  position: relative;
  width: var(--inspector-w);
  flex: none;
  border-left: 1px solid var(--line);
  background: var(--bg-elev-1);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

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

.app-outline-head {
  font-size: var(--t-caption-size);
  font-weight: var(--t-weight-semibold);
  color: var(--text-2);
}

.app-outline-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--s-2) var(--s-2) var(--s-4);
}

.app-outline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.app-outline-item {
  display: flex;
  align-items: flex-start;
  gap: var(--s-1-5);
  width: 100%;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-2);
  text-align: left;
  padding: var(--s-1) var(--s-1-5);
  font-size: var(--t-small-size);
  line-height: 1.45;
  cursor: pointer;
  transition: background var(--d-fast) var(--ease), color var(--d-fast) var(--ease);
}

.app-outline-item:hover {
  background: var(--bg-elev-3);
  color: var(--text-1);
}

.app-outline-item.is-active {
  color: var(--accent-on-soft);
  background: var(--accent-soft);
}

.app-outline-item .app-outline-marker {
  flex: none;
  width: 14px;
  text-align: right;
  font-size: var(--t-micro-size);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

.app-outline-item span.app-outline-text {
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.app-outline-empty {
  margin: var(--s-5) var(--s-2);
  color: var(--text-3);
  font-size: var(--t-small-size);
  text-align: center;
  line-height: 1.7;
}

.app-outline-empty code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-elev-3);
  padding: 1px 5px;
  border-radius: var(--r-xs);
  color: var(--text-2);
}

/* ==========================================================================
 * 4. 状态栏
 * ========================================================================== */

.app-statusbar {
  gap: var(--s-2);
}

.app-statusbar .xui-status-item {
  color: var(--text-2);
}

.app-status-sep {
  width: 1px;
  height: 12px;
  background: var(--line);
}

.app-status-save {
  min-width: 96px;
}

.app-status-btn {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  cursor: pointer;
  padding: 0 var(--s-1);
  border-radius: var(--r-xs);
  height: calc(var(--statusbar-h) - 6px);
}

.app-status-btn:hover {
  background: var(--bg-elev-3);
  color: var(--text-1);
}

.app-status-reading {
  color: var(--text-3);
}

/* ==========================================================================
 * 5. 查找 / 替换浮层
 * ========================================================================== */

.app-find {
  position: fixed;
  top: calc(32px + var(--topbar-h) + var(--s-2));
  right: 12px;
  z-index: var(--z-popover);
  width: min(420px, calc(100vw - 48px));
  background: var(--surface-overlay);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-menu);
  padding: var(--s-2);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.app-find[hidden] {
  display: none;
}

.app-find-row {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.app-find-icon {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  flex: none;
  margin-left: var(--s-1);
}

.app-find-input {
  flex: 1;
  min-width: 0;
  height: var(--btn-h-sm);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--bg-elev-1);
  color: var(--text-1);
  font-family: inherit;
  font-size: var(--t-small-size);
  padding: 0 var(--s-2);
}

.app-find-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

.app-find-count {
  min-width: 46px;
  text-align: center;
  font-size: var(--t-micro-size);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.app-find-btn {
  flex: none;
}

.app-find-replace {
  border-top: 1px solid var(--line);
  padding-top: var(--s-2);
}

.app-find[hidden],
#findPanel[hidden] {
  display: none;
}

/* 命中高亮（CSS Custom Highlight API，Chromium 105+ / WebView2 可用） */
::highlight(xnote-find) {
  background-color: var(--warn-soft);
  color: inherit;
}

::highlight(xnote-find-current) {
  background-color: var(--accent);
  color: var(--text-on-accent);
}

/* ==========================================================================
 * 6. 拖放导入 / 离线提示条
 * ========================================================================== */

.app-drop {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--scrim);
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.app-drop[hidden] {
  display: none;
}

.app-drop-inner {
  border: 2px dashed var(--accent);
  border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-7);
  background: var(--bg-elev-1);
  color: var(--text-1);
  font-size: var(--t-h2-size);
  font-weight: var(--t-weight-semibold);
  box-shadow: var(--shadow-dialog);
}

.pwa-banner {
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2);
  max-width: min(720px, calc(100vw - 32px));
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  background: var(--surface-overlay);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-toast);
  font-size: var(--t-small-size);
  color: var(--text-1);
}

.pwa-banner[hidden] {
  display: none;
}

.pwa-banner-msg {
  flex: 1;
  min-width: 200px;
}

/* ==========================================================================
 * 7. 响应式
 * ========================================================================== */

@media (max-width: 1180px) {
  .app-action-label {
    display: none;
  }

  .app-action {
    padding: 0 var(--s-1-5) !important;
  }
}

@media (max-width: 960px) {
  .app-sidebar {
    position: absolute;
    left: 48px;
    top: 0;
    bottom: 0;
    z-index: var(--z-dock);
    width: 260px;
    box-shadow: var(--shadow-md);
    /* 左边还留着 48px 活动栏，所以要多滑出 49px 才能完全藏住 */
    transform: translateX(calc(-100% - 49px));
    transition: transform var(--d-base) var(--ease);
  }

  .app-sidebar.is-open {
    transform: translateX(0);
  }

  .app-outline {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: var(--z-dock);
    width: 280px;
    box-shadow: var(--shadow-md);
  }

  .app-status-reading,
  .app-titlebar-context {
    display: none;
  }
}

@media (max-width: 640px) {
  .app-topbar {
    padding: 0 var(--s-2);
  }

  .app-doc-sub {
    display: none;
  }

  .app-topbar-actions {
    gap: 2px;
  }

  .app-statusbar .xui-statusbar-group {
    gap: var(--s-2);
  }

  .app-find {
    right: 6px;
    left: 6px;
    width: auto;
  }
}

/* 减少动效偏好：XUI 的 data-motion 已覆盖大部分，这里兜住动画本身 */
@media (prefers-reduced-motion: reduce) {
  .app-boot img {
    animation: none;
  }
}
20138


/* ==========================================================================
 * 8. 设置 / 关于 / 快捷键弹窗
 * ========================================================================== */

.app-settings {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.app-settings-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.app-settings-section + .app-settings-section {
  margin-top: var(--s-2);
}

.app-settings-title {
  margin: 0 0 var(--s-1);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--line-subtle);
  font-size: var(--t-small-size);
  font-weight: var(--t-weight-semibold);
  color: var(--text-1);
  letter-spacing: 0.02em;
}

.app-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3) var(--s-4);
}

.app-settings-kv {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--s-1-5) var(--s-3);
  font-size: var(--t-small-size);
}

.app-settings-kv > span {
  color: var(--text-3);
}

.app-settings-kv > b {
  color: var(--text-1);
  font-weight: var(--t-weight-medium);
  overflow-wrap: anywhere;
}

.app-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.app-form p {
  margin: 0;
}

.app-about-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.app-about-head img {
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.app-about-head h3 {
  margin: 0 0 2px;
  font-size: var(--t-h2-size);
  font-weight: var(--t-weight-semibold);
  color: var(--text-1);
}

.app-about-head h3 b {
  color: var(--accent);
}

.app-about-head p {
  color: var(--text-3);
  font-size: var(--t-micro-size);
}

.app-about-links {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.app-about-links a.xui-btn {
  text-decoration: none;
}

.app-shortcuts {
  display: flex;
  flex-direction: column;
  gap: var(--s-1-5);
}

.app-shortcut-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--t-small-size);
  color: var(--text-2);
}

.app-shortcut-row kbd {
  min-width: 112px;
  justify-content: center;
  display: inline-flex;
}

.app-settings .xui-seg {
  align-self: flex-start;
}

@media (max-width: 560px) {
  .app-settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ==========================================================================
 * 9. 无边框窗口的 8 个缩放热区（只有壳里 frameless 时才由 JS 创建）
 * ========================================================================== */

.app-resize {
  position: fixed;
  z-index: var(--z-drag);
}

.app-resize--north,
.app-resize--south {
  left: 8px;
  right: 8px;
  height: 4px;
  cursor: ns-resize;
}

.app-resize--north { top: 0; }
.app-resize--south { bottom: 0; }

.app-resize--east,
.app-resize--west {
  top: 8px;
  bottom: 8px;
  width: 4px;
  cursor: ew-resize;
}

.app-resize--east { right: 0; }
.app-resize--west { left: 0; }

.app-resize--north-east,
.app-resize--north-west,
.app-resize--south-east,
.app-resize--south-west {
  width: 10px;
  height: 10px;
}

.app-resize--north-east { top: 0; right: 0; cursor: nesw-resize; }
.app-resize--north-west { top: 0; left: 0; cursor: nwse-resize; }
.app-resize--south-east { bottom: 0; right: 0; cursor: nwse-resize; }
.app-resize--south-west { bottom: 0; left: 0; cursor: nwse-resize; }

/* ==========================================================================
 * 10. 补丁：侧栏隐藏 / 查找计数为空 / 按钮组
 * ========================================================================== */

.app-sidebar.is-hidden {
  display: none;
}

.app-find-count.is-empty {
  color: var(--danger);
}

.app-empty .xui-btn {
  min-width: 96px;
}

.app-status-btn:focus-visible {
  outline: var(--focus-ring-w) solid var(--accent);
  outline-offset: -1px;
}

/* 同步状态：失败要看得出来，成功别抢眼 */
.app-status-sync.is-error {
  color: var(--danger);
}

.app-status-sync.is-ok {
  color: var(--text-2);
}

.app-status-sync:disabled {
  cursor: progress;
  opacity: 0.7;
}

/* 远端配置面板（设置对话框里按类型显隐） */
.app-remote-panel {
  margin-top: var(--s-3);
}

.app-remote-panel[hidden] {
  display: none;
}

.app-remote-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

/* 冲突副本列表：一行一个按钮，长标题截断但不丢信息（title 里保留全文） */
.app-conflict-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  align-items: center;
}

.app-conflict-item {
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  justify-content: flex-start;
}

.app-settings-kv b#syncStateText {
  font-weight: var(--t-weight-medium);
}

/* ==========================================================================
 * 11. 减弱动效 × Mermaid 的真实兼容补丁
 *
 * XUI 在「减弱动效」下给 * 设了 transition-duration: 0.01ms。实测（Chrome 158 / WebView2）
 * 只要行内/全局存在正的 transition-duration，mermaid 的标尺测量就会被放大：
 * 同一张 graph LR 的 viewBox 从 218×70 变成 2054×2043，图被压成一角。
 * 0s 的语义与 0.01ms 相同（没有过渡），但不会污染测量，所以这里把它压到 0s。
 * ========================================================================== */

:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  transition-duration: 0s !important;
}

@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) *,
  :root:not([data-motion="full"]) *::before,
  :root:not([data-motion="full"]) *::after {
    transition-duration: 0s !important;
  }
}

/* hidden 属性必须压过组件自己的 display（空状态 / 窗口按钮 / 面板都靠它切换） */
.app-window-controls[hidden],
.app-empty[hidden],
.app-outline[hidden],
.app-titlebar-badge[hidden],
.pwa-banner[hidden],
#findPanel[hidden] {
  display: none !important;
}

/* hidden 是语义不是建议：任何组件都不该用 display 把它盖掉 */
[hidden] {
  display: none !important;
}