/* UniDoc Vault: compact local-first Markdown workspace panel. */
.udoc-vault-panel {
  --uv-width: 360px;
  --uv-headings-height: clamp(88px, 17vh, 140px);
  --uv-headings-track: var(--uv-headings-height);
  position: fixed;
  z-index: 2600;
  left: 0;
  top: var(--uv-top, 142px);
  bottom: var(--uv-bottom, 34px);
  width: var(--uv-width);
  max-width: calc(100vw - 48px);
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* The tree and outline are independent scroll panes.  Keeping the outline
     as an explicit grid track prevents a note with a different heading count
     from re-running the panel's intrinsic sizing and visibly moving the tree. */
  grid-template-rows: auto auto auto auto minmax(min(120px, 20vh), 1fr) var(--uv-headings-track) auto;
  color: #242424;
  background: #fff;
  border-right: 1px solid #d8dce3;
  box-shadow: 8px 0 26px rgba(24, 38, 58, .14);
  font: 13px/1.35 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  transition: transform .16s ease, visibility .16s;
}

.udoc-vault-panel.headings-collapsed { --uv-headings-track: 31px; }
.udoc-vault-panel.is-compact-vertical { --uv-headings-height: clamp(72px, 13vh, 100px); }

.uv-resizer {
  position: absolute;
  z-index: 4;
  top: 0;
  right: -10px;
  bottom: 0;
  width: 20px;
  border: 0;
  outline: none;
  cursor: col-resize;
  touch-action: none;
}
.uv-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  right: 9px;
  bottom: 0;
  width: 2px;
  background: transparent;
  transition: width .12s ease, background-color .12s ease;
}
.uv-resizer:hover::before,
.uv-resizer:focus-visible::before,
.udoc-vault-panel.is-resizing .uv-resizer::before {
  width: 3px;
  background: #2b6cb0;
}
.uv-resizer:focus-visible { box-shadow: inset 0 0 0 2px rgba(43, 108, 176, .2); }
.uv-panel-resizing,
.uv-panel-resizing * { cursor: col-resize !important; user-select: none !important; }
.udoc-vault-panel.is-resizing { transition: none; }

.udoc-vault-panel.is-hidden {
  visibility: hidden;
  pointer-events: none;
  transform: translateX(calc(-1 * var(--uv-width) - 12px));
}

.uv-head {
  box-sizing: border-box;
  min-height: 54px;
  padding: 10px 10px 9px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e7e9ee;
}

.uv-head strong { display: block; font-size: 15px; font-weight: 650; }
.uv-head .uv-root {
  display: block;
  max-width: 270px;
  margin-top: 1px;
  color: #6b7280;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uv-icon {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  padding: 0 !important;
  display: inline-grid;
  place-items: center;
  border: 0 !important;
  border-radius: 5px;
  background: transparent !important;
  color: #59636e;
  font-size: 21px;
  cursor: pointer;
}
.uv-icon:hover { background: #edf2f8 !important; color: #1f5f9f; }
.uv-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.uv-actions {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  padding: 8px 10px 4px;
  display: flex;
  gap: 5px;
}
.uv-actions > button:not(.uv-icon) {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 10px;
  border: 1px solid #c9d2df;
  border-radius: 5px;
  color: #245b94;
  background: #f8fbff;
  font: inherit;
  cursor: pointer;
}
.uv-actions > button:hover { border-color: #83a8d0; background: #edf5ff; }

.uv-search {
  box-sizing: border-box;
  min-width: 0;
  margin: 4px 10px 7px;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid #cfd5de;
  border-radius: 6px;
  background: #fff;
}
.uv-search:focus-within { border-color: #2b6cb0; box-shadow: 0 0 0 1px #2b6cb0; }
.uv-search span { color: #687386; font-size: 18px; }
.uv-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: #222;
  background: transparent;
  font: inherit;
}

.uv-tabs {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0 10px 7px;
  padding: 2px;
  border-radius: 6px;
  background: #f0f2f5;
}
.uv-tabs button {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 6px;
  border: 0;
  border-radius: 4px;
  color: #576273;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
.uv-tabs button.active { color: #174f88; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.uv-viewport {
  position: relative;
  box-sizing: border-box;
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border-block: 1px solid #edf0f4;
  contain: strict;
  scrollbar-width: thin;
}
.uv-spacer { width: 1px; opacity: 0; pointer-events: none; }
.uv-rows {
  position: absolute;
  inset: 0 0 auto;
  will-change: transform;
}
.uv-row {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  height: 34px;
  min-width: 0;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  padding: 0 9px;
  border: 0;
  color: #303744;
  background: transparent;
  text-align: left;
  font: inherit;
  cursor: default;
}
.uv-row:hover { background: #f1f6fb; }
.uv-row.active { color: #174f88; background: #e6f0fb; }
.uv-row.is-keyboard { outline: 2px solid #76a7e3; outline-offset: -2px; background: #edf5ff; }
.uv-row > span { color: #667a92; text-align: center; }
.uv-row > b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.uv-row > small { max-width: 94px; overflow: hidden; color: #8a94a3; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.uv-folder > b { font-weight: 600; }
.uv-file > small { opacity: 0; }
.uv-file:hover > small, .uv-file.active > small { opacity: 1; }
.uv-tag > span { color: #2b6cb0; font-weight: 700; }
.uv-result-section {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  color: #707b89;
  background: #fafbfc;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .02em;
  cursor: default;
}
.uv-result-section:hover { background: #fafbfc; }

.uv-headings {
  min-width: 0;
  box-sizing: border-box;
  min-height: 0;
  height: 100%;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 5px 0 6px;
}
.uv-section-title {
  position: sticky;
  z-index: 1;
  top: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 12px;
  border: 0;
  color: #707b89;
  background: #fff;
  text-align: left;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.uv-section-title:hover { color: #174f88; background: #f4f7fb; }
.uv-section-chevron { transition: transform .16s ease; }
.uv-headings.is-collapsed { height: 100%; max-height: none; overflow: hidden; padding-bottom: 0; }
.uv-headings.is-collapsed .uv-heading-list { display: none; }
.uv-headings.is-collapsed .uv-section-chevron { transform: rotate(-90deg); }
.uv-heading-list { display: grid; }
.uv-heading-list button {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  padding: 4px 12px 4px calc(12px + var(--uv-level, 0) * 13px);
  overflow: hidden;
  border: 0;
  color: #384355;
  background: transparent;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  cursor: pointer;
}
.uv-heading-list button:hover { color: #174f88; background: #eef5fd; }
.uv-empty { padding: 3px 12px; color: #9aa2ad; font-size: 11px; }

.udoc-vault-panel > footer {
  min-width: 0;
  box-sizing: border-box;
  min-height: 31px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid #e6e9ee;
  color: #6d7785;
  background: #fafbfc;
  font-size: 10px;
}
.uv-active, .uv-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uv-active { flex: 1; }
.uv-active.is-dirty { color: #b24b18; font-weight: 600; }
.uv-status { max-width: 48%; text-align: right; }
.uv-status.is-busy::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border: 1.5px solid #8aa9c9; border-top-color: #1f5f9f; border-radius: 50%; animation: uv-spin .65s linear infinite; }
@keyframes uv-spin { to { transform: rotate(360deg); } }

.uv-import-state {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  color: #667085;
  background: #fff;
  text-align: center;
  font-size: 12px;
}
.udoc-vault-panel.is-importing .uv-viewport { overflow: hidden; }
.udoc-vault-panel.is-importing .uv-spacer,
.udoc-vault-panel.is-importing .uv-rows { visibility: hidden; }
.udoc-vault-panel.is-importing .uv-import-state { display: flex; }

/* The panel already spans the complete space between the ribbon and status
   bar.  On short/zoomed viewports reclaim height from chrome and the outline
   instead of allowing the file tree to collapse to a token strip. */
.udoc-vault-panel.is-compact-vertical .uv-head {
  min-height: 46px;
  padding-block: 6px;
}
.udoc-vault-panel.is-compact-vertical .uv-actions { padding-block: 5px 2px; }
.udoc-vault-panel.is-compact-vertical .uv-search {
  height: 30px;
  margin-block: 2px 5px;
}
.udoc-vault-panel.is-compact-vertical .uv-tabs { margin-bottom: 5px; }
.udoc-vault-panel.is-compact-vertical .uv-tabs button { padding-block: 4px; }
.udoc-vault-panel.is-compact-vertical > footer {
  min-height: 28px;
  padding-block: 3px;
}

.uv-heading-flash { animation: uv-heading-flash 1.1s ease; }
@keyframes uv-heading-flash { 0%, 55% { background: rgba(255, 223, 78, .58); } 100% { background: transparent; } }

.uv-conflict-overlay {
  position: fixed;
  z-index: 20000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 28, 39, .42);
}
.uv-conflict {
  width: min(520px, 94vw);
  padding: 20px;
  border-radius: 9px;
  color: #242424;
  background: #fff;
  box-shadow: 0 18px 55px rgba(0, 0, 0, .26);
}
.uv-conflict h2 { margin: 0 0 8px; font-size: 18px; }
.uv-conflict p { margin: 0 0 18px; color: #5f6875; line-height: 1.6; }
.uv-conflict > div { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.uv-conflict button { padding: 7px 12px; border: 1px solid #bdc7d4; border-radius: 5px; color: #25364b; background: #fff; cursor: pointer; }
.uv-conflict button:hover { background: #f3f6fa; }
.uv-conflict button.danger { border-color: #c94343; color: #fff; background: #c94343; }

.uv-context-menu {
  position: fixed;
  z-index: 23000;
  width: 190px;
  padding: 6px;
  display: grid;
  gap: 2px;
  border: 1px solid #d9dee7;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 40px rgba(31, 48, 76, .22);
  font: 13px/1.35 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}
.uv-context-menu button {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  color: #30343b;
  background: transparent;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.uv-context-menu button:hover,
.uv-context-menu button:focus-visible { outline: 0; background: #edf3fc; color: #174ea6; }
.uv-context-menu button.danger { color: #b3261e; }
.uv-context-menu button.danger:hover { color: #8c1d18; background: #fce8e6; }

/* Vault 路径选择由 UniDoc 本地服务完成：不用浏览器 File System Access
   权限 UI，视觉与现有弹窗保持同一套轻量 Google Docs 风格。 */
.uv-dialog-overlay {
  position: fixed;
  z-index: 22000;
  inset: 0;
  display: grid;
  place-items: start center;
  padding: min(14vh, 120px) 20px 20px;
  background: rgba(25, 34, 48, .34);
  backdrop-filter: blur(2px);
}
.uv-dialog {
  width: min(620px, 94vw);
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 16px;
  padding: 22px;
  border: 1px solid #d8e0eb;
  border-radius: 18px;
  color: #202124;
  background: #fff;
  box-shadow: 0 24px 70px rgba(23, 39, 65, .24);
}
.uv-dialog-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: #0b57d0;
  font-weight: 750;
  font-size: 17px;
}
.uv-dialog h2 { margin: 1px 0 7px; font-size: 19px; line-height: 1.35; }
.uv-dialog p { margin: 0 0 17px; color: #5f6368; line-height: 1.55; }
.uv-dialog label { display: grid; gap: 7px; color: #3c4043; font-size: 12px; font-weight: 650; }
.uv-dialog input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #c7d0dc;
  border-radius: 9px;
  outline: 0;
  color: #202124;
  background: #fff;
  font: 13px/1.4 Consolas, "SFMono-Regular", monospace;
}
.uv-dialog input:focus { border-color: #0b57d0; box-shadow: 0 0 0 3px rgba(11,87,208,.12); }
.uv-dialog-error { min-height: 18px; margin-top: 5px; color: #b3261e; font-size: 12px; }
.uv-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 7px; }
.uv-dialog-actions button {
  min-width: 78px;
  padding: 8px 14px;
  border: 1px solid #c7d0dc;
  border-radius: 9px;
  color: #174ea6;
  background: #fff;
  font: inherit;
  cursor: pointer;
}
.uv-dialog-actions button:hover { background: #f2f6fc; }
.uv-dialog-actions button.primary { border-color: #0b57d0; color: #fff; background: #0b57d0; }
.uv-dialog-actions button.primary:hover { background: #0847ad; }

@media (max-width: 620px) {
  .udoc-vault-panel {
    --uv-headings-height: clamp(72px, 14vh, 112px);
    width: 100vw;
    max-width: 100vw;
    box-shadow: none;
  }
  .uv-resizer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .udoc-vault-panel { transition: none; }
  .uv-status.is-busy::before { animation-duration: 1.4s; }
}
