/**
 * 创明笔记工作区 — 全屏白板 + 浮动工具岛 + 侧滑抽屉
 * 工作区采用固定浅色 UI（参考 Excalidraw），不随站点四套主题变化
 */

body.notes-workspace {
  color-scheme: light;
  background: #ffffff;
  /* 工作区内统一覆盖站点主题变量 */
  --ink-bg: #f8f9fa;
  --ink-bg-alt: #f1f3f5;
  --ink-surface: rgba(255, 255, 255, 0.98);
  --ink-surface-solid: #ffffff;
  --ink-surface-2: #f8f9fa;
  --ink-border: #dee2e6;
  --ink-text: #1e1e1e;
  --ink-muted: #868e96;
  --ink-accent: #495057;
  --ink-accent-secondary: #6965db;
  --ink-accent-soft: rgba(105, 101, 219, 0.1);
  --ink-accent-hover: #343a40;
  --ink-on-accent: #ffffff;
  --ink-danger: #e03131;
  --ink-success: #2f9e44;
  --ink-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --ink-canvas-bg: #ffffff;
  --ink-canvas-grid: rgba(0, 0, 0, 0.06);
  --ink-modal-backdrop: rgba(0, 0, 0, 0.35);
  --ink-toast-bg: #212529;
  --ink-toast-text: #ffffff;
  --ink-btn-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  --ink-btn-raised-bg: #ffffff;
  --ink-btn-raised-border: #dee2e6;
  --ink-btn-accent-bg: rgba(105, 101, 219, 0.1);
  --ink-btn-accent-border: #6965db;
  --ink-btn-accent-text: #5f5bd5;
  --ink-gradient-accent: linear-gradient(180deg, #7481ff 0%, #6965db 100%);
  --ink-btn-primary-shadow: 0 1px 3px rgba(105, 101, 219, 0.35);
}

body.notes-workspace .notes-bg-decoration {
  display: none;
}

body.notes-workspace .notes-theme-panel-wrap {
  display: none;
}

/* hidden 须压过 display:flex 等显式样式（浮动工具栏、模态按钮等） */
body.notes-workspace [hidden] {
  display: none !important;
}

#notes-app {
  --wb-inset: clamp(12px, 2vw, 28px);
  --wb-island-gap: 4px;
  --wb-island-radius: 8px;
  --wb-canvas-bg: #ffffff;
  --wb-chrome-bg: #ffffff;
  --wb-chrome-muted-bg: #f8f9fa;
  --wb-chrome-border: #e9ecef;
  --wb-chrome-text: #1e1e1e;
  --wb-chrome-muted: #868e96;
  --wb-chrome-accent: #6965db;
  --wb-chrome-accent-soft: rgba(105, 101, 219, 0.12);
  --wb-island-bg: #ffffff;
  --wb-island-border: #e9ecef;
  --wb-island-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 2px 12px rgba(0, 0, 0, 0.08);
  --wb-drawer-width: var(--ws-explorer-width, 280px);
  --wb-notes-width: min(440px, 92vw);
  /* Side panels sit between top/bottom chrome so toolbars never need to move. */
  --wb-panel-top: calc(var(--wb-inset) + 64px);
  --wb-panel-bottom: calc(var(--wb-inset) + 56px);
  --ws-explorer-width: 280px;
  --ws-explorer-projects-height: 220px;
}

/* ========== App shell ========== */
.ws-app {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--wb-canvas-bg);
}

/* ========== Full-bleed canvas stage ========== */
.wb-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.wb-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.wb-surface {
  position: relative;
  z-index: 2;
}

.wb-ui {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.wb-island {
  position: absolute;
  display: flex;
  align-items: center;
  gap: var(--wb-island-gap);
  padding: 6px 8px;
  border-radius: var(--wb-island-radius);
  background: var(--wb-island-bg);
  border: 1px solid var(--wb-island-border);
  box-shadow: var(--wb-island-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: auto;
  max-width: calc(100vw - var(--wb-inset) * 2);
  transition: left 0.28s ease, right 0.28s ease, top 0.28s ease;
}

.wb-island-tl {
  top: var(--wb-inset);
  left: var(--wb-inset);
  flex-wrap: nowrap;
  max-width: min(420px, calc(100vw - var(--wb-inset) * 2));
  min-height: calc(2rem + 12px);
  z-index: 13;
}

.wb-top-chrome {
  position: absolute;
  top: var(--wb-inset);
  right: var(--wb-inset);
  left: auto;
  z-index: 12;
  --wb-tl-reserve: min(420px, calc(100vw - var(--wb-inset) * 2));
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: none;
}

.wb-top-chrome .wb-island {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  transform: none;
  max-width: none;
  flex-shrink: 0;
}

.wb-top-chrome .wb-island-tc {
  flex: 0 0 auto;
  width: max-content;
  min-height: calc(2rem + 12px);
  max-width: calc(100vw - var(--wb-inset) * 2 - var(--wb-tl-reserve) - 12px);
  flex-wrap: nowrap;
  justify-content: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.wb-top-chrome .wb-tool-group {
  flex-wrap: nowrap;
  justify-content: flex-start;
  width: max-content;
  max-width: 100%;
}

.wb-export-wrap {
  position: relative;
  display: inline-flex;
}

.wb-export-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 10rem;
  padding: 0.35rem;
  border-radius: 8px;
  background: var(--wb-island-bg, rgba(255, 255, 255, 0.96));
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  border: 1px solid rgba(15, 23, 42, 0.08);
  z-index: 65;
}

.wb-export-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
}

.wb-export-dropdown button:hover {
  background: rgba(59, 130, 246, 0.08);
}

.wb-island-br .wb-export-dropdown {
  top: auto;
  bottom: calc(100% + 6px);
}

.ws-selection-toolbar {
  position: fixed;
  z-index: 40;
  transform: translate(-50%, -100%);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.ws-toolbar-colors {
  display: inline-flex;
  gap: 0.2rem;
  padding-right: 0.35rem;
  border-right: 1px solid rgba(15, 23, 42, 0.08);
}

.ws-toolbar-colors button[data-action="color"] {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  flex-shrink: 0;
}

.ws-toolbar-colors button[data-action="color"][data-color="__default__"] {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.ws-toolbar-colors button[data-action="color"][data-color="#fef08a"] { background: #fef08a; }
.ws-toolbar-colors button[data-action="color"][data-color="#bfdbfe"] { background: #bfdbfe; }
.ws-toolbar-colors button[data-action="color"][data-color="#bbf7d0"] { background: #bbf7d0; }
.ws-toolbar-colors button[data-action="color"][data-color="#fecaca"] { background: #fecaca; }

.ws-toolbar-colors button[data-action="color"]:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.ws-selection-toolbar button[data-action="delete"] {
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
}

.ws-selection-toolbar button[data-action="delete"]:hover {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
}

.ws-textarea {
  width: 100%;
  min-height: 10rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.ws-modal-hint {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: rgba(15, 23, 42, 0.65);
}

.ws-import-webpage-fields {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.ws-import-webpage-fields .ws-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.75);
}

.ws-import-legal-hint {
  margin-top: 0.25rem;
  margin-bottom: 0;
  font-size: 0.75rem;
}

.ws-link-popover-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.ws-conn-types-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 360px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}

.ws-conn-types-head,
.ws-conn-type-row {
  display: grid;
  grid-template-columns: 44px minmax(72px, 0.75fr) minmax(0, 2.4fr) 56px auto;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
}

.ws-conn-types-head {
  padding: 0 0.5rem 0.25rem;
  font-size: 0.72rem;
  color: var(--ink-muted, #64748b);
}

.ws-conn-type-row {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--ink-border, rgba(15, 23, 42, 0.1));
  border-radius: 8px;
}

.ws-conn-type-color {
  width: 40px;
  height: 36px;
  min-width: 40px;
  padding: 2px;
  border: 1px solid var(--ink-border, rgba(15, 23, 42, 0.18));
  border-radius: 6px;
  background: var(--ink-surface, #fff);
  cursor: pointer;
  box-sizing: border-box;
}

.ws-conn-type-color::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.ws-conn-type-color::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.ws-conn-type-row .ws-input {
  font-size: 0.82rem;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.ws-conn-type-desc {
  min-width: 0;
}

.ws-conn-type-badge {
  font-size: 0.68rem;
  color: var(--ink-muted, #64748b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.ws-template-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ws-template-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.5rem 0.65rem;
  cursor: pointer;
}

.ws-template-item:hover {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.05);
}

.ws-template-item strong {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 0.15rem;
}

.ws-template-item span {
  display: block;
  font-size: 0.75rem;
  color: rgba(15, 23, 42, 0.55);
}

.wb-bottom-chrome {
  position: absolute;
  bottom: var(--wb-inset);
  left: var(--wb-inset);
  right: var(--wb-inset);
  z-index: 12;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  box-sizing: border-box;
}

.wb-bottom-chrome .wb-island {
  position: relative;
  bottom: auto;
  left: auto;
  right: auto;
  pointer-events: auto;
}

.wb-island-bl {
  flex-wrap: wrap;
  max-width: min(520px, calc(100vw - var(--wb-inset) * 2));
}

.wb-island-br {
  flex-wrap: nowrap;
  justify-content: flex-end;
  max-width: calc(100vw - var(--wb-inset) * 2 - 24px);
  margin-left: auto;
  z-index: 14;
  /* 勿在此设 overflow-x：会把 overflow-y 算成 auto，裁掉向上弹出的导入/导出菜单 */
  overflow: visible;
}

.wb-island-br-scroll {
  display: flex;
  align-items: center;
  gap: var(--wb-island-gap);
  flex-wrap: nowrap;
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.wb-island-br-scroll::-webkit-scrollbar {
  display: none;
}

.wb-island-br > *,
.wb-island-br-scroll > * {
  flex-shrink: 0;
}

.wb-icon-btn {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--wb-chrome-text);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.wb-icon-btn:hover,
.wb-icon-btn.active {
  background: var(--wb-chrome-accent-soft);
  color: var(--wb-chrome-accent);
}

.wb-brand {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--wb-chrome-text);
  text-decoration: none;
  white-space: nowrap;
}

.wb-brand:hover {
  color: var(--wb-chrome-accent);
  text-decoration: none;
}

.wb-project {
  font-size: 0.82rem;
  color: var(--wb-chrome-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 0.5rem;
  border-left: 1px solid var(--wb-island-border);
}

.wb-user-strip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.25rem;
  min-width: 0;
  flex-shrink: 1;
}

.wb-user-strip .ws-user {
  padding: 0.2rem 0.35rem;
  font-size: 0.78rem;
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wb-divider {
  width: 1px;
  height: 1.4rem;
  background: var(--wb-island-border);
  flex-shrink: 0;
}

.wb-tool-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px;
  max-width: 100%;
}

.wb-tool-btn {
  min-width: 2rem;
  padding: 0.35rem 0.55rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--wb-chrome-text);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.wb-tool-btn:hover:not(:disabled) {
  background: var(--wb-chrome-muted-bg);
}

.wb-tool-btn.active {
  background: var(--wb-chrome-accent-soft);
  color: var(--wb-chrome-accent);
  font-weight: 600;
}

.wb-tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wb-eraser-strip {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.15rem 0 0.35rem;
  border-left: 1px solid var(--wb-island-border);
  margin-left: 0.15rem;
}

.wb-eraser-strip input[type="range"] {
  width: 72px;
  accent-color: var(--wb-chrome-accent);
}

.wb-eraser-val {
  font-size: 0.72rem;
  color: var(--wb-chrome-muted);
  min-width: 1.4rem;
}

.wb-zoom-strip {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.wb-zoom-strip input[type="range"] {
  width: 72px;
  accent-color: var(--wb-chrome-accent);
}

.wb-zoom-val {
  font-size: 0.75rem;
  color: var(--wb-chrome-muted);
  min-width: 2.5rem;
  text-align: center;
}

.wb-layout-status {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--wb-chrome-muted-bg);
  color: var(--wb-chrome-muted);
  border: 1px solid var(--wb-island-border);
}

.wb-layout-status[data-state="pending"] {
  color: var(--wb-chrome-accent);
  border-color: color-mix(in srgb, var(--wb-chrome-accent) 35%, var(--wb-island-border));
  background: var(--wb-chrome-accent-soft);
}

.wb-layout-status[data-state="error"] {
  color: #ef4444;
  border-color: #ef4444;
}

.wb-collab-status {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--wb-chrome-muted-bg);
  color: var(--wb-chrome-muted);
  border: 1px solid var(--wb-island-border);
  white-space: nowrap;
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.wb-collab-status[data-state="online"] {
  color: #22c55e;
  border-color: color-mix(in srgb, #22c55e 35%, var(--wb-island-border));
  background: color-mix(in srgb, #22c55e 12%, var(--wb-chrome-muted-bg));
}

.wb-collab-status[data-state="connecting"] {
  color: #60a5fa;
  border-color: color-mix(in srgb, #60a5fa 35%, var(--wb-island-border));
}

.wb-collab-status[data-state="failed"] {
  color: #ef4444;
  border-color: color-mix(in srgb, #ef4444 35%, var(--wb-island-border));
}

.wb-presence-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.wb-presence-cursor {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-4px, -4px);
  will-change: transform;
  pointer-events: none;
  transition: none;
}

.wb-presence-cursor.is-agent {
  z-index: 2;
}

.wb-presence-cursor.is-agent .wb-presence-label {
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.wb-presence-action {
  font-weight: 500;
  opacity: 0.9;
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wb-presence-action:not([hidden])::before {
  content: '·';
  margin-right: 0.15rem;
  opacity: 0.7;
}

.wb-presence-pointer {
  display: block;
  width: 0;
  height: 0;
  border-left: 10px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.wb-presence-label {
  display: block;
  margin-top: 2px;
  margin-left: 8px;
  padding: 0.1rem 0.45rem;
  font-size: 0.68rem;
  line-height: 1.2;
  color: #0f172a;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.wb-select-sm {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.3rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--wb-island-border);
  background: var(--wb-chrome-bg);
  color: var(--wb-chrome-text);
  max-width: 140px;
}

.wb-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--wb-inset) + 52px);
  transform: translateX(-50%);
  margin: 0;
  padding: 0.5rem 0.9rem;
  font-size: 0.8rem;
  color: var(--wb-chrome-muted);
  background: var(--wb-island-bg);
  border: 1px solid var(--wb-island-border);
  border-radius: var(--wb-island-radius);
  box-shadow: var(--wb-island-shadow);
  pointer-events: none;
  text-align: center;
  max-width: min(480px, 90vw);
}

.wb-hint[hidden],
.wb-link-hint[hidden] {
  display: none !important;
}

.wb-link-hint {
  bottom: calc(var(--wb-inset) + 52px);
  color: var(--wb-chrome-accent);
  border-color: color-mix(in srgb, var(--wb-chrome-accent) 25%, var(--wb-island-border));
}

.ws-link-popover {
  pointer-events: auto;
  z-index: 50;
}

body.notes-workspace .ws-toast {
  top: calc(var(--wb-inset, 20px) + 56px);
}

/* Lists in drawer */
.ws-project-list,
.ws-doc-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0.35rem 0;
  list-style: none;
}

/* ========== Side drawers ========== */
.ws-drawer {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--wb-chrome-bg);
  border: 1px solid var(--wb-chrome-border);
  box-shadow: 8px 0 24px rgba(0, 0, 0, 0.1);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), top 0.28s ease, bottom 0.28s ease;
  will-change: transform;
}

.ws-drawer-left {
  left: 0;
  width: var(--wb-drawer-width);
  transform: translateX(-105%);
  border-left: none;
}

.ws-drawer-left.open {
  transform: translateX(0);
}

.ws-drawer-right {
  right: 0;
  width: var(--wb-notes-width);
  transform: translateX(105%);
  border-right: none;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.1);
}

.ws-drawer-right.open {
  transform: translateX(0);
}

/* Desktop: float between top/bottom toolbars (do not cover chrome) */
@media (min-width: 961px) {
  .ws-drawer {
    top: var(--wb-panel-top);
    bottom: var(--wb-panel-bottom);
    border-radius: var(--wb-island-radius);
    overflow: hidden;
  }

  .ws-drawer-left {
    left: var(--wb-inset);
    border-left: 1px solid var(--wb-chrome-border);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  }

  .ws-drawer-right {
    right: var(--wb-inset);
    border-right: 1px solid var(--wb-chrome-border);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  }
}

.ws-drawer-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--wb-chrome-border);
  background: var(--wb-chrome-muted-bg);
  flex-shrink: 0;
}

.ws-drawer-title {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--wb-chrome-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-drawer-sub {
  font-size: 0.72rem;
  color: var(--wb-chrome-muted);
  font-weight: 400;
}

.ws-drawer-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ws-drawer-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 2;
  touch-action: none;
}

.ws-drawer-left .ws-drawer-resizer {
  right: -3px;
}

.ws-drawer-backdrop {
  position: absolute;
  inset: 0;
  z-index: 55;
  background: var(--ink-modal-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.ws-drawer-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Explorer inside drawer */
.ws-explorer-block {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ws-explorer-projects {
  flex: 0 0 var(--ws-explorer-projects-height);
  min-height: 72px;
  max-height: calc(100% - 96px);
}

.ws-explorer-docs {
  flex: 1;
  min-height: 72px;
}

.ws-explorer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--wb-chrome-muted);
  background: var(--wb-chrome-muted-bg);
}

.ws-resizer-explorer-inner {
  flex-shrink: 0;
  height: 4px;
  cursor: row-resize;
  background: var(--wb-chrome-border);
  touch-action: none;
}

.ws-resizer-explorer-inner:hover,
.ws-resizer-explorer-inner.is-dragging {
  background: var(--wb-chrome-accent);
}

/* Notes editor drawer */
.ws-notes-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.ws-editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 1.25rem 1rem 1.5rem;
  text-align: center;
  color: var(--ink-muted);
  overflow: auto;
  min-height: 0;
}

.ws-editor-empty-title {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--wb-chrome-text, var(--ink-text));
}

.ws-editor-empty-sub {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  opacity: 0.85;
}

.ws-editor-empty-docs {
  list-style: none;
  margin: 0.25rem 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  max-height: min(52vh, 420px);
  overflow: auto;
}

.ws-editor-empty-docs li {
  margin: 0;
}

.ws-editor-empty-docs .ws-editor-empty-doc-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--wb-chrome-border, var(--ink-border));
  border-radius: 8px;
  background: var(--wb-chrome-bg, #fff);
  color: var(--wb-chrome-text, var(--ink-text));
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}

.ws-editor-empty-docs .ws-editor-empty-doc-btn:hover {
  border-color: color-mix(in srgb, var(--wb-chrome-accent, #6965db) 45%, var(--wb-chrome-border, #e9ecef));
  background: var(--wb-chrome-accent-soft, rgba(105, 101, 219, 0.12));
}

.ws-editor-empty-docs .ws-editor-empty-doc-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-editor-empty-docs .ws-editor-empty-doc-ver {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--wb-chrome-muted, var(--ink-muted));
}

.ws-editor-empty-docs .ws-editor-empty-docs-hint {
  padding: 0.75rem 0.5rem;
  font-size: 0.8rem;
  color: var(--wb-chrome-muted, var(--ink-muted));
  text-align: center;
}

.ws-editor-empty #btn-new-doc-empty {
  align-self: center;
  margin-top: 0.15rem;
}

.ws-editor-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ws-editor-toolbar {
  flex-shrink: 0;
}

.ws-editor-active[hidden],
.ws-editor-empty[hidden] {
  display: none !important;
}

.ws-editor-title {
  flex-shrink: 0;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.85rem 1rem;
  border: none;
  border-bottom: 1px solid var(--ink-border);
  background: transparent;
  color: var(--ink-text);
}

.ws-editor-title:focus {
  outline: none;
  background: var(--ink-surface-2);
}

.ws-editor-content {
  flex: 1;
  min-height: 120px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.65;
  padding: 1rem;
  border: none;
  resize: none;
  background: transparent;
  color: var(--ink-text);
}

.ws-editor-content:focus {
  outline: none;
}

.ws-editor-statusbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--ink-border);
  background: var(--ink-surface-2);
}

.ws-editor-meta {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.ws-editor-save-state {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.ws-editor-save-state[data-state='pending'] {
  color: var(--ink-accent, #60a5fa);
}

.ws-editor-save-state[data-state='saved'] {
  color: #34d399;
}

.ws-editor-save-state[data-state='error'] {
  color: #f87171;
}

.ws-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  margin: 0.5rem 0 0.75rem;
}

.ws-revision-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--ink-border);
  border-radius: 8px;
}

.ws-revision-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--ink-border);
  font-size: 0.82rem;
}

.ws-revision-item:last-child {
  border-bottom: none;
}

.ws-revision-ver {
  font-weight: 600;
  min-width: 2.5rem;
}

.ws-revision-msg {
  flex: 1;
  color: var(--ink-text);
}

.ws-revision-time {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.ws-revision-empty {
  padding: 1rem;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.ws-editor-actions {
  display: flex;
  gap: 0.35rem;
}

/* Selection toolbar — island style */
.ws-selection-toolbar {
  position: fixed;
  z-index: 45;
  transform: translate(-50%, -100%);
  display: flex;
  gap: 0.25rem;
  padding: 0.3rem;
  border-radius: 8px;
  background: var(--wb-island-bg);
  border: 1px solid var(--wb-island-border);
  box-shadow: var(--wb-island-shadow);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.ws-selection-toolbar button {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.35rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--wb-chrome-text);
  cursor: pointer;
}

.ws-selection-toolbar button:hover {
  background: var(--wb-chrome-accent-soft);
  color: var(--wb-chrome-accent);
}

.ws-selection-toolbar .ws-toolbar-colors button[data-action="color"]:hover {
  background: inherit;
  color: inherit;
}

/* 画板内联卡片编辑 */
.wb-card-editor {
  position: fixed;
  z-index: 46;
  box-sizing: border-box;
  padding: 10px 12px 8px;
  border-radius: 4px;
  background: #fffef9;
  border: 2px solid var(--wb-chrome-accent, #6965db);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
  overflow: hidden;
}

.wb-card-editor-title {
  font: 600 13px "DM Sans", "PingFang SC", sans-serif;
  color: #1e1e1e;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  width: 100%;
  outline: none;
}

.wb-card-editor-body {
  font: 12px/1.45 "DM Sans", "PingFang SC", sans-serif;
  color: #64748b;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  width: 100%;
  flex: 1;
  min-height: 4.5em;
  resize: none;
  outline: none;
}

/* 白板公式叠加层（KaTeX DOM 渲染，仅覆盖画布区域） */
.wb-file-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.wb-file-overlay {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  pointer-events: none;
}

.wb-file-overlay.is-selected .wb-file-card-body,
.wb-file-overlay.is-selected .ofv-viewport {
  pointer-events: auto;
}

.wb-file-card-title {
  flex: 0 0 auto;
  height: 22px;
  line-height: 22px;
  padding: 0 10px;
  font: 600 12px/22px "DM Sans", "PingFang SC", sans-serif;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  pointer-events: none;
}

.wb-file-card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  pointer-events: none;
}

.wb-file-overlay-inner {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* 卡片内 OFV：仅去掉外边框，其余沿用 @open-file-viewer/core 默认布局 */
.wb-file-overlay-inner > .ofv-root {
  border: none;
  height: 100%;
  min-height: 0;
}

.wb-file-card-body .ofv-markdown-body {
  padding: 8px 10px 12px;
  font-size: 12px;
  line-height: 1.5;
}

.wb-file-preview-pdf {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.wb-file-preview-media {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.wb-file-preview-audio {
  width: calc(100% - 16px);
  margin: 8px;
}

.wb-file-preview-text {
  margin: 0;
  padding: 8px 10px;
  height: 100%;
  overflow: auto;
  box-sizing: border-box;
  font: 11px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
  background: #fff;
}

.wb-file-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 100%;
  padding: 12px;
  text-align: center;
  color: #64748b;
  font: 12px/1.4 "DM Sans", "PingFang SC", sans-serif;
}

.wb-file-fallback-title {
  margin: 0;
  font-weight: 600;
  color: #334155;
}

.wb-file-fallback-meta {
  margin: 0;
  word-break: break-all;
}

.wb-file-fallback-hint {
  margin: 0;
  font-size: 11px;
}

.wb-file-fallback-link {
  pointer-events: auto;
  color: #6965db;
  text-decoration: none;
  font-weight: 600;
}

.wb-file-fallback-link:hover {
  text-decoration: underline;
}

.wb-math-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

.wb-math-overlay {
  position: absolute;
  box-sizing: border-box;
  overflow: visible;
  color: #64748b;
  font: 12px/2.1 "DM Sans", "PingFang SC", sans-serif;
  pointer-events: none;
}

.wb-math-overlay .cmnote-math-block {
  margin: 0.35em 0;
  text-align: center;
}

.wb-math-overlay .cmnote-math-inline {
  display: inline;
}

.wb-math-overlay .katex {
  font-size: 1em;
}

/* ========== Responsive ========== */
@media (min-width: 901px) and (max-width: 1199px) {
  .wb-top-chrome {
    --wb-tl-reserve: clamp(260px, 32vw, 360px);
  }

  .wb-island-tl {
    max-width: min(360px, calc(100vw - var(--wb-inset) * 2));
  }
}

@media (max-width: 900px) {
  .wb-top-chrome {
    left: var(--wb-inset);
    right: var(--wb-inset);
    top: calc(var(--wb-inset) + 48px);
    justify-content: flex-start;
  }

  .wb-top-chrome .wb-island-tc {
    flex-wrap: nowrap;
    width: max-content;
    max-width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .wb-top-chrome .wb-tool-group {
    flex-wrap: nowrap;
    width: max-content;
  }

  .wb-island-tl {
    max-width: calc(100vw - var(--wb-inset) * 2);
    flex-wrap: wrap;
  }

  .wb-project {
    display: none;
  }

  .wb-bottom-chrome {
    left: var(--wb-inset);
    right: var(--wb-inset);
    bottom: var(--wb-inset);
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 8px;
  }

  .wb-island-bl {
    max-width: none;
  }

  .wb-island-br {
    max-width: none;
    margin-left: 0;
    justify-content: flex-end;
  }
}

@media (max-width: 640px) {
  #notes-app {
    --wb-inset: 10px;
  }

  .wb-user-strip .ws-user span:not(strong) {
    display: none;
  }

  .wb-zoom-strip input[type="range"] {
    width: 56px;
  }
}
