:root {
  --bg: #e8eef5;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0284c7;
  --border: #e2e8f0;
  --canvas-bg: #ffffff;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 56px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar-brand {
  flex: 0 1 auto;
  min-width: 0;
  /* 标题 + 用户名优先占用空间，避免被画布下拉挤成省略号 */
  max-width: min(520px, 52vw);
}

.topbar-board {
  flex: 0 0 auto;
  flex-shrink: 0;
  width: clamp(120px, 16vw, 168px);
  max-width: 168px;
  min-width: 112px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-new-board-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--accent);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.topbar-new-board-btn:hover:not(:disabled) {
  background: rgba(2, 132, 199, 0.12);
}

.topbar-new-board-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.topbar-board-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-overflow: ellipsis;
}

.topbar-board-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.topbar-toolbar {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  flex-wrap: wrap;
}

.toolbar-tool-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-soft);
}

.toolbar-divider {
  width: 1px;
  height: 26px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.toolbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 34px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  border-radius: 8px;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    opacity 0.15s ease;
}

.toolbar-tool-group .toolbar-icon-btn {
  border-radius: 0;
  width: 38px;
}

.toolbar-tool-group .toolbar-icon-btn + .toolbar-icon-btn {
  border-left: 1px solid var(--border);
}

.toolbar-icon-btn:hover:not(:disabled) {
  background: rgba(2, 132, 199, 0.1);
  color: var(--accent);
}

.toolbar-icon-btn--active {
  background: #e0f2fe;
  color: var(--accent);
}

.toolbar-icon-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.toolbar-batch-btn:not(:disabled) {
  opacity: 1;
}

.toolbar-svg {
  width: 20px;
  height: 20px;
  display: block;
}

.toolbar-svg--line {
  flex-shrink: 0;
  vector-effect: non-scaling-stroke;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
  flex-shrink: 0;
  margin-left: auto;
}

.tb-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

.batch-status-dialog {
  margin: auto;
  padding: 18px 20px;
  border: none;
  border-radius: 12px;
  max-width: 360px;
  background: var(--panel);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}

.batch-status-dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.batch-status-title {
  margin: 0 0 14px;
  font-size: 16px;
}

.batch-status-label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

.batch-status-select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.batch-status-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.batch-status-primary {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.batch-status-secondary {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  font-size: 13px;
  cursor: pointer;
}

.batch-color-hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.batch-color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.batch-color-swatch {
  width: 100%;
  aspect-ratio: 1;
  max-width: 28px;
  margin: 0 auto;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  box-sizing: border-box;
}

.batch-color-swatch:hover {
  transform: scale(1.08);
}

.batch-color-swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
}

.batch-color-more {
  margin-top: 4px;
}

.batch-color-picker-native {
  width: 100%;
  height: 38px;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-sizing: border-box;
  cursor: pointer;
  background: var(--panel-soft);
}

.canvas-marquee {
  position: absolute;
  z-index: 25;
  pointer-events: none;
  border: 2px dashed rgba(2, 132, 199, 0.88);
  background: rgba(2, 132, 199, 0.07);
  box-sizing: border-box;
  border-radius: 4px;
}

.canvas-root.canvas-root--select-mode {
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

/* 光标由 JS 写在 canvasRoot 上，子层继承，便于单选圆环节显示 nwse-resize、多选时统一小手 */
.canvas-root.canvas-root--select-mode .node-layer {
  cursor: inherit;
}

.canvas-root.canvas-root--select-mode .node {
  cursor: inherit;
}

.canvas-root.canvas-root--select-mode .node:active {
  cursor: grabbing;
}

/* 批量选中时禁止矩形节点原生缩放，避免拖动机误触改尺寸；缩放仅在双箭头出现时（单选 resize） */
.main-layout.main-layout--canvas-multi .node:not(.node-circle) {
  resize: none !important;
}

.main-layout.main-layout--canvas-multi .side-panel {
  pointer-events: none;
  opacity: 0.7;
  user-select: none;
}

.main-layout.main-layout--canvas-multi .sidebar-expand-tab {
  pointer-events: auto;
}

.tb-menu {
  position: relative;
}

.tb-menu summary.tb-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.tb-menu summary.tb-summary::-webkit-details-marker {
  display: none;
}

.tb-menu summary.tb-summary::after {
  content: " ▾";
  font-size: 10px;
  opacity: 0.65;
}

.tb-menu[open] summary.tb-summary {
  border-color: var(--accent);
  background: #e0f2fe;
}

.tb-body {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
  max-width: min(280px, calc(100vw - 24px));
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}

.tb-body-wide {
  min-width: 240px;
}

.tb-body .tb-full {
  width: 100%;
}

.tb-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tb-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.tb-auth-line {
  margin-bottom: 2px;
}

.tb-body button {
  margin: 0;
}

.hidden-file {
  display: none;
}

.auth-state {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.board-select {
  width: 100%;
}

button {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.main-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr minmax(0, 320px);
  transition: grid-template-columns 0.22s ease;
  position: relative;
}

.main-layout.sidebar-collapsed {
  grid-template-columns: 1fr 0;
}

.canvas-root {
  position: relative;
  overflow: hidden;
  cursor: grab;
  background: var(--canvas-bg);
  touch-action: none;
}

.canvas-root:active {
  cursor: grabbing;
}

.canvas-add-popover {
  position: absolute;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translate(-50%, -50%);
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.12);
  pointer-events: none;
}

.canvas-add-popover > * {
  pointer-events: auto;
}

.canvas-add-popover.hidden {
  display: none !important;
}

.canvas-add-circle-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #374151;
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.canvas-add-circle-btn:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
  color: #111827;
}

.canvas-add-label {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  user-select: none;
  white-space: nowrap;
}

.circle-color-popover {
  position: fixed;
  z-index: 5000;
  width: min(220px, calc(100vw - 48px));
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.14);
  pointer-events: auto;
}

.circle-color-popover.hidden {
  display: none !important;
}

.node-material-popover {
  position: fixed;
  z-index: 5000;
  width: min(280px, calc(100vw - 40px));
  padding: 12px 14px 14px;
  background: linear-gradient(165deg, #fffbeb 0%, #fef9c3 48%, #fef08a 100%);
  border: 1px solid rgba(180, 83, 9, 0.35);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(120, 53, 15, 0.18), 0 1px 0 rgba(255, 255, 255, 0.65) inset;
  pointer-events: auto;
}

.node-material-popover.hidden {
  display: none !important;
}

.node-material-popover-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.node-material-popover-title {
  font-size: 14px;
  font-weight: 700;
  color: #78350f;
}

.node-material-popover-hint {
  font-size: 11px;
  color: rgba(120, 53, 15, 0.82);
  line-height: 1.35;
}

.node-material-notes-input {
  display: block;
  width: 100%;
  min-height: 132px;
  margin: 0;
  padding: 10px 11px;
  box-sizing: border-box;
  font-size: 13px;
  line-height: 1.45;
  color: #422006;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(180, 83, 9, 0.28);
  border-radius: 8px;
  resize: vertical;
  font-family: inherit;
}

.node-material-notes-input:focus {
  outline: none;
  border-color: rgba(217, 119, 6, 0.65);
  background: rgba(255, 255, 255, 0.78);
}

.node-material-notes-input[contenteditable="true"] {
  min-height: 132px;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.node-material-notes-input .material-att-link {
  display: inline;
  color: #1d4ed8;
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
  padding: 0 1px;
}

.node-material-notes-input .material-att-link:hover {
  color: #1e40af;
}

.node-material-notes-input .material-att-link--broken {
  color: #b91c1c;
  text-decoration: line-through;
}

.node-material-drop-zone {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.node-material-drop-zone--drag {
  outline: 2px dashed rgba(217, 119, 6, 0.75);
  outline-offset: 2px;
  border-radius: 8px;
}

.node-material-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.node-material-att-item {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 1px solid rgba(180, 83, 9, 0.35);
  background: rgba(255, 255, 255, 0.65);
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}

.node-material-att-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.node-material-att-file {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #78350f;
  padding: 2px 4px;
  text-align: center;
  word-break: break-all;
  line-height: 1.15;
}

.node-material-att-broken {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #b91c1c;
  font-weight: 700;
  user-select: none;
}

.node-material-att-remove {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.node-material-att-remove:hover {
  background: rgba(185, 28, 28, 0.9);
}

.attachment-preview-dialog {
  max-width: min(96vw, 920px);
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
}

.attachment-preview-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.attachment-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.attachment-preview-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #0f172a);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview-close {
  flex-shrink: 0;
}

.attachment-preview-body {
  padding: 12px;
  max-height: min(80vh, 720px);
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
}

.attachment-preview-img {
  max-width: 100%;
  max-height: min(76vh, 680px);
  width: auto;
  height: auto;
  object-fit: contain;
}

.attachment-preview-img.hidden {
  display: none !important;
}

.tb-note code {
  font-size: 11px;
}

.circle-color-popover-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.circle-color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.circle-color-swatch {
  width: 100%;
  aspect-ratio: 1;
  max-width: 28px;
  margin: 0 auto;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  box-sizing: border-box;
}

.circle-color-swatch:hover {
  transform: scale(1.08);
}

.circle-color-swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.25);
}

.circle-color-more-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.circle-color-picker-native {
  width: 48px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--panel-soft);
}

.circle-color-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.circle-color-confirm {
  padding: 7px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.circle-color-confirm:hover {
  filter: brightness(1.05);
}

.circle-color-cancel {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.circle-color-cancel:hover {
  background: #f1f5f9;
}

.edge-layer,
.node-layer {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

/* 与 node-layer 相同：整层只做相机 transform；实际网格在 .grid-plane 世界坐标块上 */
.grid-layer {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}

.grid-plane {
  position: absolute;
  transform-origin: 0 0;
  box-sizing: border-box;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
}

.edge-layer {
  width: 100%;
  height: 100%;
  overflow: visible;
  z-index: 5;
}

.edge-hit-group {
  cursor: pointer;
}

.edge-line-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
  pointer-events: stroke;
}

.edge-hit-group .edge-line {
  fill: none;
  stroke: #0284c7;
  stroke-width: 2.5;
  pointer-events: none;
}

.edge-hit-group.is-selected .edge-line {
  stroke: #0369a1;
  stroke-width: 3.5;
}

.edge-unbind {
  cursor: pointer;
}

.edge-unbind-bg {
  fill: #ffffff;
  stroke: #e11d48;
  stroke-width: 2;
  filter: drop-shadow(0 2px 8px rgba(15, 23, 42, 0.18));
}

.edge-unbind-x {
  stroke: #be123c;
  stroke-width: 2.5;
  pointer-events: none;
}

.edge-cp-handles {
  pointer-events: none;
}

.edge-cp-handle {
  pointer-events: all;
  fill: #ffffff;
  stroke: #0284c7;
  stroke-width: 2.5;
  cursor: grab;
  filter: drop-shadow(0 1px 3px rgba(15, 23, 42, 0.2));
}

.edge-cp-handle:hover {
  stroke: #0369a1;
}

.edge-preview {
  fill: none;
  stroke: #d97706;
  stroke-width: 2;
  stroke-dasharray: 5 5;
}

.node-layer {
  pointer-events: none;
  z-index: 10;
}

.node {
  position: absolute;
  min-width: 120px;
  min-height: 84px;
  width: 180px;
  height: 120px;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid rgba(15, 23, 42, 0.14);
  color: #f8fafc;
  background: #475569;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  resize: both;
  overflow: auto;
  pointer-events: auto;
}

@keyframes node-selected-glow {
  0%,
  100% {
    box-shadow:
      0 0 0 3px rgba(255, 255, 255, 1),
      0 0 0 9px rgba(2, 132, 199, 0.52),
      0 0 0 14px rgba(56, 189, 248, 0.18),
      0 0 36px rgba(2, 132, 199, 0.42),
      0 0 56px rgba(14, 165, 233, 0.2),
      0 10px 28px rgba(15, 23, 42, 0.14);
  }
  50% {
    box-shadow:
      0 0 0 3px rgba(255, 255, 255, 1),
      0 0 0 12px rgba(2, 132, 199, 0.68),
      0 0 0 18px rgba(56, 189, 248, 0.28),
      0 0 48px rgba(2, 132, 199, 0.55),
      0 0 72px rgba(14, 165, 233, 0.28),
      0 10px 28px rgba(15, 23, 42, 0.14);
  }
}

.node.selected {
  border-color: #0369a1;
  border-width: 3px;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 1),
    0 0 0 9px rgba(2, 132, 199, 0.52),
    0 0 0 14px rgba(56, 189, 248, 0.18),
    0 0 36px rgba(2, 132, 199, 0.42),
    0 0 56px rgba(14, 165, 233, 0.2),
    0 10px 28px rgba(15, 23, 42, 0.14);
  animation: node-selected-glow 2.2s ease-in-out infinite;
  z-index: 2;
}

.node.node-circle {
  border-radius: 50%;
  resize: none;
  overflow: visible;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: none;
  min-width: 0;
  min-height: 0;
}

.node.node-square,
.node.node-rectangle,
.node.node-diamond {
  resize: none;
  overflow: visible;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: none;
  min-width: 0;
  min-height: 0;
}

.node.node-square {
  border-radius: 10px;
}

.node.node-rectangle {
  border-radius: 12px;
}

.node.node-diamond {
  background: transparent !important;
}

.node.node-diamond::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--node-fill, #0078d4);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  z-index: 0;
  pointer-events: none;
}

.node.node-diamond .node-circle-label {
  position: relative;
  z-index: 1;
}

.node.node-diamond .port,
.node.node-diamond .node-child-expand,
.node.node-diamond .node-circle-status-badge,
.node.node-diamond .node-circle-due-badge {
  z-index: 1;
}

.node.node-square.selected,
.node.node-rectangle.selected,
.node.node-diamond.selected {
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 1),
    0 0 0 9px rgba(2, 132, 199, 0.55),
    0 0 0 14px rgba(56, 189, 248, 0.2),
    0 0 40px rgba(2, 132, 199, 0.45),
    0 0 60px rgba(14, 165, 233, 0.22);
  animation: node-selected-glow 2.2s ease-in-out infinite;
  z-index: 2;
}

.node.node-circle.selected {
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 1),
    0 0 0 9px rgba(2, 132, 199, 0.55),
    0 0 0 14px rgba(56, 189, 248, 0.2),
    0 0 40px rgba(2, 132, 199, 0.45),
    0 0 60px rgba(14, 165, 233, 0.22);
  animation: node-selected-glow 2.2s ease-in-out infinite;
  z-index: 2;
}

@media (prefers-reduced-motion: reduce) {
  .node.selected,
  .node.node-circle.selected {
    animation: none;
    box-shadow:
      0 0 0 3px rgba(255, 255, 255, 1),
      0 0 0 10px rgba(2, 132, 199, 0.58),
      0 0 0 15px rgba(56, 189, 248, 0.22),
      0 0 40px rgba(2, 132, 199, 0.48),
      0 0 60px rgba(14, 165, 233, 0.24),
      0 10px 28px rgba(15, 23, 42, 0.14);
  }

  .node.node-circle.selected {
    box-shadow:
      0 0 0 3px rgba(255, 255, 255, 1),
      0 0 0 10px rgba(2, 132, 199, 0.58),
      0 0 0 15px rgba(56, 189, 248, 0.22),
      0 0 42px rgba(2, 132, 199, 0.48),
      0 0 64px rgba(14, 165, 233, 0.26);
  }
}

.node.node-circle.node-circle-ring--red::before,
.node.node-circle.node-circle-ring--yellow::before,
.node.node-circle.node-circle-ring--green::before,
.node.node-circle.node-circle-ring--gray::before {
  content: "";
  position: absolute;
  inset: calc(-5px * var(--node-scale, 1));
  border-radius: 50%;
  border: calc(3px * var(--node-scale, 1)) solid transparent;
  pointer-events: none;
  z-index: 0;
  box-sizing: border-box;
}

.node.node-circle.node-circle-ring--red::before {
  border-color: #ef4444;
}

.node.node-circle.node-circle-ring--yellow::before {
  border-color: #eab308;
}

.node.node-circle.node-circle-ring--green::before {
  border-color: #22c55e;
}

.node.node-circle.node-circle-ring--gray::before {
  border-color: #94a3b8;
}

.node-circle-status-badge {
  position: absolute;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.24);
}

.node-circle-status-badge svg {
  width: 66%;
  height: 66%;
  flex-shrink: 0;
}

.node-circle-status-badge--not_started {
  background: #e5e7eb;
  color: #4b5563;
}

.node-circle-status-badge--in_progress {
  background: #c4b5fd;
  color: #3b0764;
}

.node-circle-status-badge--paused {
  background: #fef9c3;
  color: #a16207;
}

.node-circle-status-badge--done {
  background: #d1fae5;
  color: #15803d;
}

.node-circle-status-badge--cancelled {
  background: #fecaca;
  color: #b91c1c;
}

.node-circle-due-badge {
  position: absolute;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.24);
  font-weight: 700;
  color: #fff;
  line-height: 1;
  white-space: nowrap;
  padding: 0 2px;
  box-sizing: border-box;
}

.node-circle-due-badge--remain {
  background: #16a34a;
}

.node-circle-due-badge--overdue {
  background: #dc2626;
}

.node-circle-label {
  position: relative;
  z-index: 2;
  margin: 0;
  text-align: center;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.25;
  max-width: 86%;
  word-break: break-word;
  outline: none;
  cursor: text;
  user-select: none;
  pointer-events: auto;
}

.node-circle-label[contenteditable="true"] {
  user-select: text;
  cursor: text;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 2px 8px;
  max-width: 92%;
}

.node-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  user-select: none;
  outline: none;
  cursor: default;
}

.node-title[contenteditable="true"] {
  user-select: text;
  cursor: text;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 2px 6px;
  margin: -2px -6px;
}

.node-meta {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(248, 250, 252, 0.92);
}

.node-meta + .node-meta {
  margin-top: 4px;
}

.port {
  position: absolute;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--canvas-bg);
  background: #2563eb;
  right: -7px;
  cursor: crosshair;
}

.port.port-on-rect-left {
  right: auto;
  left: -7px;
}

.port:not(.port-on-circle):hover {
  transform: scale(1.1);
}

.port.port-on-circle:hover {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.92);
}

.node-circle .port.port-on-circle {
  z-index: 3;
}

.edge-snap-ring {
  fill: none;
  stroke: #d97706;
  stroke-width: 2.5;
  pointer-events: none;
  animation: edge-snap-pulse 0.85s ease-in-out infinite;
}

@keyframes edge-snap-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.38;
  }
}

.node-quick-menu {
  position: absolute;
  z-index: 15;
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.1);
}

.node-quick-menu.hidden {
  display: none;
}

.node-quick-menu button {
  padding: 6px 9px;
}

.circle-arc-menu {
  position: absolute;
  inset: 0;
  z-index: 16;
  pointer-events: none;
  overflow: visible;
}

.circle-arc-menu.hidden {
  display: none !important;
}

.circle-arc-btn {
  position: absolute;
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  border: none;
  background: #eceef2;
  color: #4b5563;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: none;
  transform: translate(-50%, -50%);
}

.circle-arc-btn:hover {
  background: #e2e5eb;
  color: #374151;
}

.circle-arc-btn:active {
  background: #d8dce4;
}

.circle-arc-btn.circle-arc-btn--has-note::after {
  content: "";
  position: absolute;
  right: var(--arc-note-inset, 5px);
  top: var(--arc-note-inset, 5px);
  width: var(--arc-note-dot, 6px);
  height: var(--arc-note-dot, 6px);
  border-radius: 50%;
  background: #2563eb;
  pointer-events: none;
}

.circle-arc-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  display: block;
}

.kanban-root {
  position: absolute;
  inset: 0;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  overflow: auto;
}

.kanban-root.hidden {
  display: none;
}

.gantt-root {
  position: absolute;
  inset: 0;
  padding: 14px;
  overflow: auto;
}

.gantt-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.gantt-track {
  position: relative;
  height: 20px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
}

.gantt-bar {
  position: absolute;
  top: 2px;
  height: 14px;
  border-radius: 6px;
  background: #0ea5e9;
}

.kanban-col {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.kanban-col h4 {
  margin: 0 0 10px;
  font-size: 13px;
}

.kanban-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
  background: var(--panel);
  font-size: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.side-panel {
  border-left: 1px solid var(--border);
  background: var(--panel);
  padding: 16px;
  overflow: auto;
  min-width: 0;
  transition:
    opacity 0.2s ease,
    padding 0.22s ease,
    border-width 0.22s ease;
}

.main-layout.sidebar-collapsed .side-panel {
  opacity: 0;
  pointer-events: none;
  padding: 0;
  border-left-width: 0;
  overflow: hidden;
}

.side-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.side-panel-header h2 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-panel-collapse-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  border-radius: 8px;
}

.sidebar-expand-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 120;
  width: 30px;
  height: 72px;
  padding: 0;
  margin: 0;
  border-radius: 10px 0 0 10px;
  border: 1px solid var(--border);
  border-right: none;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  box-shadow: -4px 0 18px rgba(15, 23, 42, 0.08);
}

.sidebar-expand-tab:hover {
  background: var(--panel-soft);
}

.empty-hint {
  color: var(--muted);
  margin: 12px 0;
}

.side-panel-board-name {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 4px 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: text;
}

.side-panel-board-name:hover:not(:disabled) {
  border-color: var(--border);
  background: var(--panel-soft);
}

.side-panel-board-name:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.side-panel-board-name:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.side-panel-board-name.hidden {
  display: none !important;
}

.task-form {
  display: grid;
  gap: 10px;
  margin-bottom: 4px;
}

.task-form.hidden {
  display: none;
}

/* 侧栏折叠区块（原生 details） */
.panel-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--panel-soft);
}

.panel-section-summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  user-select: none;
  border-radius: 10px;
}

.panel-section-summary::-webkit-details-marker {
  display: none;
}

.panel-section-summary::after {
  content: "";
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  transition: transform 0.18s ease;
}

.panel-section[open] > .panel-section-summary::after {
  transform: rotate(180deg);
}

.panel-section-summary:hover {
  background: rgba(2, 132, 199, 0.06);
}

.panel-section-body {
  padding: 0 12px 12px;
  display: grid;
  gap: 10px;
}

.field-inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: -2px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.field-inline-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.field-hint {
  margin: -4px 0 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.appearance-field {
  margin-bottom: 12px;
}

.appearance-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 8px;
}

.appearance-shape-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.appearance-shape-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.appearance-shape-btn:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.appearance-shape-btn.is-selected {
  border-color: #0284c7;
  background: #e0f2fe;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
}

.appearance-shape-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  background: #0284c7;
}

.appearance-shape-icon--circle {
  border-radius: 50%;
}

.appearance-shape-icon--square {
  border-radius: 3px;
}

.appearance-shape-icon--rectangle {
  width: 22px;
  height: 14px;
  border-radius: 3px;
}

.appearance-shape-icon--diamond {
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  border-radius: 2px;
}

.appearance-color-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.appearance-color-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  border: 2px solid rgba(15, 23, 42, 0.12);
  cursor: pointer;
  padding: 0;
  min-height: 0;
}

.appearance-color-btn:hover {
  transform: scale(1.06);
}

.appearance-color-btn.is-selected {
  border-color: #0f172a;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0284c7;
}

.appearance-color-btn[data-appearance-color="#ffffff"] {
  border-color: #cbd5e1;
}

.appearance-apply-btn {
  width: 100%;
  margin-top: 4px;
  appearance: none;
  border: none;
  border-radius: 10px;
  background: #0284c7;
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  padding: 10px 14px;
  cursor: pointer;
}

.appearance-apply-btn:hover {
  background: #0369a1;
}

.node-child-expand {
  position: absolute;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  border: 2px solid var(--canvas-bg, #fff);
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  box-sizing: border-box;
}

.node-child-expand:hover {
  background: #1d4ed8;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.92);
}

.node-child-expand svg,
.node-child-expand-arrow {
  width: 70%;
  height: 70%;
  display: block;
  pointer-events: none;
  flex-shrink: 0;
}

.node-child-expand-arrow--right {
  transform: none;
}

.node-child-expand-arrow--left {
  transform: rotate(180deg);
}

.node-child-expand-arrow--top {
  transform: rotate(-90deg);
}

.node-child-expand-arrow--bottom {
  transform: rotate(90deg);
}

.panel-section--in-form {
  margin-bottom: 0;
}

.side-panel--node-selected .panel-section--hide-when-node-selected {
  display: none !important;
}

.panel-section--show-when-node-selected {
  display: none !important;
}

.side-panel--node-selected .panel-section--show-when-node-selected {
  display: block !important;
}

.node-todos-list {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.node-todo-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 6px 6px 8px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
}

.node-todo-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.45;
}

.node-todo-delete {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.node-todo-delete:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.node-todo-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  cursor: pointer;
}

.node-todo-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.node-todo-item--done .node-todo-text {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  color: var(--muted);
}

.board-todos-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.board-todo-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.board-todo-item:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.board-todo-item:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.board-todo-node {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.board-todo-text {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}

.board-todos-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.node-todo-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: #fff;
  color: var(--text);
}

.node-todo-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.12);
}

.node-todos-hide-done {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.node-todos-hide-done input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.side-panel--node-selected .panel-section--flat-when-node-selected > .panel-section-summary {
  pointer-events: none;
  cursor: default;
  border-radius: 10px 10px 0 0;
}

.side-panel--node-selected .panel-section--flat-when-node-selected > .panel-section-summary:hover {
  background: transparent;
}

.side-panel--node-selected .panel-section--flat-when-node-selected > .panel-section-summary::after,
.side-panel--node-selected .panel-section--flat-when-node-selected[open] > .panel-section-summary::after {
  display: none;
}

.panel-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.panel-btn-grid--pair {
  grid-template-columns: 1fr 1fr;
}

.panel-sub-block {
  display: grid;
  gap: 8px;
}

.panel-sub-block + .panel-sub-block {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.panel-sub-block-title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel-soft);
  color: var(--text);
}

textarea {
  resize: vertical;
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.danger {
  border-color: #fca5a5;
  color: #991b1b;
  background: #fef2f2;
}

.danger:hover {
  border-color: #f87171;
  background: #fee2e2;
}

/* 统一美化提示框（替代原生 alert/confirm/prompt） */
.app-msg-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  background: transparent;
  max-width: min(420px, calc(100vw - 32px));
  width: 100%;
  box-shadow: none;
}

.app-msg-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
}

.app-msg-shell {
  margin: 0;
  background: #fff;
  color: #0f172a;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

.app-msg-header {
  padding: 16px 18px 0;
}

.app-msg-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #0f172a;
}

.app-msg-body {
  padding: 12px 18px 6px;
}

.app-msg-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
}

.app-msg-input {
  display: block;
  width: 100%;
  margin-top: 12px;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

.app-msg-input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.18);
}

.app-msg-input.hidden {
  display: none;
}

.app-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 18px 16px;
}

.app-msg-btn {
  appearance: none;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  line-height: 1.2;
}

.app-msg-btn:hover {
  background: #f1f5f9;
}

.app-msg-btn--primary {
  border-color: #0284c7;
  background: #0284c7;
  color: #fff;
}

.app-msg-btn--primary:hover {
  background: #0369a1;
  border-color: #0369a1;
}

.app-msg-btn--ghost {
  background: #fff;
  color: #64748b;
}

.app-msg-btn--danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

@media (max-width: 480px) {
  .app-msg-actions {
    flex-direction: column-reverse;
  }
  .app-msg-btn {
    width: 100%;
  }
}

.auth-dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
}

.auth-form {
  width: 320px;
  padding: 18px;
  display: grid;
  gap: 10px;
}

.auth-form h3 {
  margin: 0 0 8px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.task-filters {
  display: grid;
  gap: 8px;
}

.task-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.task-item {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
}

.task-item-title {
  font-weight: 600;
}

.task-item > .task-item-title {
  margin-bottom: 4px;
}

.task-item-meta {
  color: #9ca3af;
  font-size: 12px;
}

.task-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.task-item-head .task-item-title {
  margin-bottom: 0;
  min-width: 0;
  flex: 1;
  line-height: 1.35;
  word-break: break-word;
}

.task-item-head .task-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  cursor: pointer;
}

.task-item-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.task-item-meta-row .task-item-meta {
  flex: 1;
  min-width: 0;
}

.task-item-edit {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
}

.task-item-edit:hover {
  border-color: var(--accent);
  background: #e0f2fe;
}

.stats-summary {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.stats-bar-wrap {
  height: 10px;
  border-radius: 6px;
  background: #e2e8f0;
  overflow: hidden;
}

.stats-bar {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, #0284c7, #059669);
  transition: width 0.25s ease;
}

.comments-box {
  display: grid;
  gap: 6px;
}

.comment-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 140px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.comment-item {
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--panel-soft);
}

.comment-meta {
  color: #64748b;
  font-size: 11px;
  margin-bottom: 4px;
}

.comment-body {
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.comment-body .comment-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92em;
  background: #e2e8f0;
  padding: 1px 5px;
  border-radius: 4px;
  color: #0f172a;
}

.comment-body .comment-link {
  color: #0369a1;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.comment-body strong {
  font-weight: 700;
  color: #0f172a;
}

.comment-body em {
  font-style: italic;
  color: #334155;
}

.label-hint {
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
}

.comment-input-area {
  display: grid;
  gap: 6px;
}

.comment-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.comment-tool {
  min-width: 28px;
  height: 26px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.comment-tool:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.comment-tool-italic {
  font-style: italic;
  font-family: Georgia, serif;
}

.comment-tool-code {
  font-size: 10px;
  font-weight: 500;
}

.comment-hint {
  font-size: 11px;
  color: #64748b;
  line-height: 1.3;
}

.comment-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: end;
}

.comment-input-row textarea {
  margin: 0;
  resize: vertical;
  min-height: 56px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.4;
}

.audit-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 160px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.audit-item {
  font-size: 11px;
  color: var(--text);
  border-left: 2px solid #cbd5e1;
  padding-left: 8px;
}

.audit-time {
  color: #64748b;
  display: block;
  margin-bottom: 2px;
}

.audit-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.audit-item.audit-server {
  border-left-color: var(--accent);
}

.mention {
  color: #b45309;
  font-weight: 600;
}

.dialog-edit-hint {
  margin: 4px 0 8px;
}

.node-edit-dialog {
  margin: auto;
  padding: 0;
  border: none;
  border-radius: 12px;
  width: min(520px, calc(100vw - 32px));
  max-height: min(90vh, 720px);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
}

.node-edit-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.node-edit-dialog-shell {
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 720px);
}

.node-edit-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.node-edit-dialog-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.node-edit-dialog-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.node-edit-dialog-close:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.node-edit-dialog-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.panel-section--in-dialog {
  margin-bottom: 8px;
}

.onboarding-tour {
  position: fixed;
  inset: 0;
  z-index: 12000;
  pointer-events: auto;
}

.onboarding-tour.hidden {
  display: none !important;
}

.onboarding-tour--interactive {
  pointer-events: none;
}

.onboarding-tour--interactive .onboarding-card {
  pointer-events: auto;
}

.onboarding-hint {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  line-height: 1.45;
}

.onboarding-hint.hidden {
  display: none !important;
}

.onboarding-hint--done {
  background: #ecfdf5;
  color: #15803d;
}

.onboarding-spotlight {
  position: fixed;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.58);
  pointer-events: none;
  transition:
    top 0.22s ease,
    left 0.22s ease,
    width 0.22s ease,
    height 0.22s ease;
  z-index: 1;
}

.onboarding-card {
  position: fixed;
  z-index: 2;
  width: min(360px, calc(100vw - 32px));
  padding: 18px 20px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
  transition:
    top 0.22s ease,
    left 0.22s ease;
}

.onboarding-progress {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
}

.onboarding-title {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.onboarding-body {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.55;
  color: #334155;
}

.onboarding-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.onboarding-actions-main {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.onboarding-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.onboarding-btn--primary {
  background: #0284c7;
  color: #fff;
}

.onboarding-btn--primary:hover {
  background: #0369a1;
}

.onboarding-btn--secondary {
  background: #e2e8f0;
  color: #334155;
}

.onboarding-btn--secondary:hover {
  background: #cbd5e1;
}

.onboarding-btn--secondary:disabled {
  opacity: 0.45;
  cursor: default;
}

.onboarding-btn--ghost {
  background: transparent;
  color: var(--muted);
  padding-left: 0;
}

.onboarding-btn--ghost:hover {
  color: #334155;
}

.tb-note--mobile-only {
  display: none;
}

.mobile-sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .topbar {
    height: auto;
    min-height: 56px;
    padding: max(8px, env(safe-area-inset-top, 0px)) 10px 8px;
    flex-wrap: wrap;
    gap: 8px;
    align-content: flex-start;
  }

  .topbar-brand {
    flex: 1 1 120px;
    max-width: none;
    order: 1;
  }

  .topbar-board {
    flex: 1 1 132px;
    order: 2;
    width: auto;
    max-width: none;
    min-width: 108px;
  }

  .topbar-actions {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-left: 0;
    padding-bottom: 2px;
  }

  .topbar-actions::-webkit-scrollbar {
    display: none;
  }

  .topbar-toolbar {
    order: 4;
    flex: 1 1 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .topbar-toolbar::-webkit-scrollbar {
    display: none;
  }

  .topbar-toolbar .toolbar-batch-btn {
    display: none;
  }

  .topbar h1 {
    font-size: 15px;
  }

  .tb-menu summary.tb-summary {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .toolbar-icon-btn {
    width: 40px;
    height: 38px;
    flex-shrink: 0;
  }

  .toolbar-tool-group .toolbar-icon-btn {
    width: 42px;
  }
}

@media (max-width: 768px) {
  html,
  body {
    overscroll-behavior: none;
  }

  .tb-note--mobile-only {
    display: block;
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.45;
  }

  .main-layout {
    grid-template-columns: 1fr !important;
  }

  .main-layout .side-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(calc(100vw - 40px), 360px);
    z-index: 190;
    box-shadow: -12px 0 40px rgba(15, 23, 42, 0.18);
    transform: translateX(0);
    transition: transform 0.24s ease;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }

  .main-layout.sidebar-collapsed .side-panel {
    transform: translateX(100%);
    opacity: 1;
    pointer-events: none;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    border-left-width: 1px;
    overflow: hidden;
  }

  .mobile-sidebar-backdrop:not(.hidden) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 180;
    background: rgba(15, 23, 42, 0.42);
  }

  .sidebar-expand-tab {
    width: 38px;
    height: 58px;
    top: auto;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    transform: none;
    z-index: 170;
  }

  .kanban-root {
    grid-template-columns: 1fr;
    padding: 10px;
    gap: 10px;
  }

  .gantt-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .gantt-root {
    padding: 10px;
  }

  .node-edit-dialog,
  .batch-status-dialog {
    width: calc(100vw - 24px);
    max-width: none;
    margin: auto;
  }

  .onboarding-card {
    width: calc(100vw - 24px);
    max-width: none;
  }

  .onboarding-btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  .tb-body {
    position: fixed;
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    max-width: none;
    min-width: 0;
  }

  .task-form input,
  .task-form select,
  .task-form textarea,
  .side-panel-board-name {
    font-size: 16px;
  }

  .auth-form {
    width: calc(100vw - 32px);
    max-width: 360px;
  }

  .auth-form input {
    font-size: 16px;
  }

  .side-panel-collapse-btn {
    width: 40px;
    height: 40px;
  }
}

@media print {
  .no-print {
    display: none !important;
  }
}

.tb-summary-btn {
  list-style: none;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.tb-summary-btn:hover {
  border-color: var(--accent);
  background: #e0f2fe;
}
.tb-account-btn {
  position: relative;
  padding-right: 14px;
}
.tb-account-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
  box-shadow: 0 0 0 2px var(--panel, #fff);
  pointer-events: none;
}
.tb-account-badge.hidden {
  display: none;
}

.profile-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(720px, calc(100vw - 24px));
  max-height: min(88vh, 900px);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}
.profile-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.profile-shell {
  display: flex;
  flex-direction: column;
  max-height: min(88vh, 900px);
}
.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.profile-header h3 {
  margin: 0;
  font-size: 18px;
}
.profile-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
}
.profile-close:hover {
  background: var(--panel-soft);
  color: var(--text);
}
.profile-body {
  padding: 16px 18px 22px;
  overflow: auto;
  display: grid;
  gap: 18px;
}
.profile-section {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 12px;
  background: var(--panel-soft);
}
.profile-section h4 {
  margin: 0 0 12px;
  font-size: 15px;
}
.profile-field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}
.profile-field input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}
.profile-field input[readonly] {
  background: #f1f5f9;
  color: var(--muted);
}
.profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.profile-stat-card {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 14px 10px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.profile-stat-card:hover,
.profile-stat-card.is-active {
  border-color: #7dd3fc;
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.12);
  transform: translateY(-1px);
}
.profile-stat-card--warn.is-active,
.profile-stat-card--warn:hover {
  border-color: #fbbf24;
  box-shadow: 0 8px 20px rgba(180, 83, 9, 0.12);
}
.profile-stat-num {
  display: block;
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}
.profile-stat-card--warn .profile-stat-num {
  color: #b45309;
}
.profile-stat-label {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.profile-list-title {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}
.profile-list {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.profile-list-item {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.profile-list-item:last-child {
  border-bottom: none;
}
.profile-list-item:hover {
  background: #f0f9ff;
}
.profile-list-item-title {
  font-size: 14px;
  font-weight: 600;
}
.profile-list-item-meta {
  font-size: 12px;
  color: var(--muted);
}
.profile-list-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 640px) {
  .profile-stats {
    grid-template-columns: 1fr;
  }
}
