/* XMind-inspired clean, high-precision temporary Mind Map UI */

:root {
  --bg-canvas: #F6F7F9;
  --bg-dot: rgba(15, 23, 42, 0.06);
  --surface: rgba(255, 255, 255, 0.94);
  --surface-solid: #FFFFFF;
  --surface-hover: #F1F5F9;
  --surface-active: #E8EFFD;
  --border-subtle: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text-primary: #1E232E;
  --text-secondary: #5B6475;
  --text-muted: #8C95A6;
  --accent: #2563EB;
  --accent-ring: rgba(37, 99, 235, 0.28);
  --danger: #E8453C;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.07), 0 0 0 1px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(15, 23, 42, 0.06);
  --shadow-node: 0 2px 8px rgba(15, 23, 42, 0.06);
  --radius-pill: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Inter", "Segoe UI", sans-serif;
}

body.dark-ui {
  --surface: rgba(30, 35, 48, 0.94);
  --surface-solid: #1E2330;
  --surface-hover: #2A3142;
  --surface-active: rgba(96, 165, 250, 0.18);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text-primary: #F1F5F9;
  --text-secondary: #A1ACC0;
  --text-muted: #6E798E;
  --accent: #60A5FA;
  --accent-ring: rgba(96, 165, 250, 0.35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(255, 255, 255, 0.1);
  --shadow-node: 0 2px 10px rgba(0, 0, 0, 0.25);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ---- Top Floating Bars ---- */

.top-bar {
  position: fixed;
  top: 12px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 40;
}

.bar-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}

.brand-pill {
  gap: 8px;
  padding: 6px 10px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
}

.brand-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
}

.ephemeral-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-hover);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.main-toolbar {
  padding: 4px 8px;
  gap: 2px;
  flex: 0 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-toolbar::-webkit-scrollbar {
  display: none;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 4px;
  flex-shrink: 0;
}

.tool-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 44px;
  height: 40px;
  padding: 3px 7px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.14s ease, color 0.14s ease, opacity 0.14s ease;
  flex-shrink: 0;
}

.tool-btn:hover:not(:disabled) {
  background: var(--surface-hover);
}

.tool-btn.active {
  background: var(--surface-active);
  color: var(--accent);
}

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

.tool-label {
  font-size: 10.5px;
  line-height: 1.1;
  font-weight: 500;
  white-space: nowrap;
}

.icon-text-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
  white-space: nowrap;
}

.icon-text-btn:hover {
  background: var(--surface-hover);
}

.icon-text-btn.active {
  background: var(--surface-active);
  color: var(--accent);
}

.subtle-btn {
  color: var(--text-secondary);
  height: 26px;
  padding: 0 7px;
  font-size: 12px;
}

.icon-only-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.icon-only-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* ---- Mode Banner (Relationship Drawing) ---- */

.mode-banner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #1E232E;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
}

.banner-cancel-btn {
  border: none;
  border-radius: 6px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.banner-cancel-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ---- Canvas Viewport ---- */

.canvas-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  outline: none;
  background-color: var(--bg-canvas);
  background-image: radial-gradient(var(--bg-dot) 1.2px, transparent 1.2px);
  background-size: 24px 24px;
  cursor: default;
  touch-action: none;
}

.canvas-viewport.panning-ready {
  cursor: grab;
}

.canvas-viewport.panning-active {
  cursor: grabbing;
}

.canvas-viewport.rel-mode {
  cursor: crosshair;
}

.canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.canvas-svg {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}

.svg-overlay {
  z-index: 15;
}

.nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
}

/* ---- Mind Map Topics ---- */

.topic-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  cursor: pointer;
  border-style: solid;
  border-width: 1.5px;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
  word-break: break-word;
}

.topic-node.depth-0 {
  align-items: center;
  text-align: center;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
}

.topic-node.depth-1 {
  box-shadow: var(--shadow-node);
}

.topic-node.shape-rounded {
  border-radius: 10px;
}

.topic-node.depth-0.shape-rounded {
  border-radius: 14px;
}

.topic-node.shape-pill {
  border-radius: 999px;
}

.topic-node.shape-rect {
  border-radius: 3px;
}

.topic-node.shape-underline {
  border-radius: 4px 4px 0 0;
  border-top-width: 0 !important;
  border-left-width: 0 !important;
  border-right-width: 0 !important;
  border-bottom-width: 2px !important;
  box-shadow: none !important;
}

.topic-node:hover:not(.selected):not(.editing) {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.topic-node.selected {
  box-shadow: 0 0 0 2.5px var(--accent), 0 0 0 5px var(--accent-ring) !important;
  z-index: 12;
}

.topic-node.editing {
  box-shadow: 0 0 0 2.5px var(--accent), 0 6px 20px rgba(37, 99, 235, 0.18) !important;
  z-index: 25;
  cursor: text;
  user-select: text;
}

.topic-node.dragging-source {
  opacity: 0.42;
}

.topic-node.drop-inside {
  box-shadow: 0 0 0 3px #10B981, 0 0 0 7px rgba(16, 185, 129, 0.25) !important;
}

.topic-node.rel-source {
  box-shadow: 0 0 0 2.5px #E8453C, 0 0 0 6px rgba(232, 69, 60, 0.22) !important;
}

.topic-row {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
}

.topic-node.depth-0 .topic-row {
  justify-content: center;
}

.topic-markers {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.topic-text {
  white-space: pre-wrap;
  line-height: 1.42;
  outline: none;
  min-width: 14px;
  flex: 1 1 auto;
}

.topic-text.editing-active {
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

.topic-note-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  opacity: 0.72;
  flex-shrink: 0;
  cursor: pointer;
}

.topic-note-badge:hover {
  opacity: 1;
  background: rgba(128, 128, 128, 0.16);
}

.topic-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.topic-label-chip {
  font-size: 10.5px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.12);
  color: #1D4ED8;
  line-height: 1.45;
}

body.dark-ui .topic-label-chip {
  background: rgba(96, 165, 250, 0.2);
  color: #93C5FD;
}

/* Collapse / Expand Badge on Topic Edge */
.collapse-badge {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  background: var(--surface-solid);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 14;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.collapse-badge.side-right {
  right: -13px;
}

.collapse-badge.side-left {
  left: -13px;
}

.collapse-badge.side-down {
  top: auto;
  bottom: -13px;
  left: 50%;
  transform: translateX(-50%);
}

.collapse-badge.expanded-btn {
  opacity: 0;
}

.topic-node:hover .collapse-badge.expanded-btn,
.topic-node.selected .collapse-badge.expanded-btn,
.collapse-badge:hover {
  opacity: 1;
}

/* SVG Interactive Elements (Relationships & Boundaries) */
.svg-interactive {
  pointer-events: auto;
  cursor: pointer;
}

.rel-hit-path {
  fill: none;
  stroke: transparent;
  stroke-width: 16px;
  pointer-events: stroke;
  cursor: pointer;
}

.rel-label-pill,
.boundary-label-pill {
  position: absolute;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  z-index: 16;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.rel-label-pill.selected,
.boundary-label-pill.selected {
  box-shadow: 0 0 0 2px var(--accent);
}

.rel-handle {
  pointer-events: auto;
  cursor: move;
}

/* Marquee Selection */
.marquee-box {
  position: fixed;
  border: 1.5px solid var(--accent);
  background: rgba(37, 99, 235, 0.1);
  border-radius: 4px;
  pointer-events: none;
  z-index: 30;
}

/* Invisible IME Catcher positioned over selected node */
.ime-catcher {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 2px;
  height: 20px;
  opacity: 0;
  padding: 0;
  border: none;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  pointer-events: none;
  z-index: 26;
}

.ime-catcher.composing {
  opacity: 1;
  color: var(--text-primary);
  caret-color: var(--accent);
  background: var(--surface-solid);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 4px 10px;
  pointer-events: auto;
  box-shadow: var(--shadow-md);
}

/* ---- Right Collapsible Format Panel ---- */

.format-panel {
  position: fixed;
  top: 70px;
  right: 14px;
  bottom: 66px;
  width: 272px;
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  z-index: 38;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-tabs {
  display: inline-flex;
  background: var(--surface-hover);
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}

.panel-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
}

.panel-tab.active {
  background: var(--surface-solid);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.panel-close {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.panel-close:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 16px;
}

.inspector-section {
  margin-bottom: 16px;
}

.section-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.sub-label {
  font-size: 11px;
  color: var(--text-muted);
  margin: 8px 0 5px;
}

.empty-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  padding: 28px 12px;
}

.seg-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.seg-grid.seg-3 {
  grid-template-columns: repeat(3, 1fr);
}

.seg-btn {
  border: 1px solid var(--border-subtle);
  background: var(--surface-solid);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 7px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.seg-btn:hover {
  border-color: var(--border-strong);
}

.seg-btn.active {
  border-color: var(--accent);
  background: var(--surface-active);
  color: var(--accent);
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.swatch-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  padding: 0;
  position: relative;
}

.swatch-btn.transparent-swatch {
  background: linear-gradient(135deg, #fff 45%, #ef4444 45%, #ef4444 55%, #fff 55%);
}

.swatch-btn.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.text-style-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.compact-select {
  flex: 1;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-solid);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
}

.fmt-toggle-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
}

.fmt-toggle-btn.active {
  border-color: var(--accent);
  background: var(--surface-active);
  color: var(--accent);
}

.full-btn {
  width: 100%;
  height: 34px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-solid);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.full-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.structure-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.structure-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--surface-solid);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}

.structure-card:hover {
  border-color: var(--border-strong);
}

.structure-card.active {
  border-color: var(--accent);
  background: var(--surface-active);
  color: var(--accent);
}

.theme-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--surface-solid);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.theme-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

.theme-dots {
  display: flex;
  gap: 3px;
}

.theme-dot {
  flex: 1;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12.5px;
  cursor: pointer;
}

/* ---- Bottom Floating Bars ---- */

.bottom-left-bar {
  position: fixed;
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 40;
}

.segmented-pill {
  padding: 3px;
  gap: 2px;
}

.view-tab {
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}

.view-tab.active {
  background: var(--surface-active);
  color: var(--accent);
}

.count-pill {
  padding: 7px 11px;
  font-size: 12px;
  color: var(--text-secondary);
}

.bottom-right-bar {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 40;
}

.zoom-pill {
  padding: 4px 6px;
  gap: 2px;
}

.zoom-btn,
.zoom-pct-btn {
  height: 28px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn {
  width: 28px;
  font-size: 16px;
}

.zoom-pct-btn {
  min-width: 48px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.zoom-btn:hover,
.zoom-pct-btn:hover {
  background: var(--surface-hover);
}

/* ---- Popovers (Markers, Labels, Notes) ---- */

.floating-popover {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  background: var(--surface-solid);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 12px 14px;
  z-index: 50;
}

.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.popover-clear-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 5px;
}

.popover-clear-btn:hover {
  background: var(--surface-hover);
  color: var(--danger);
}

.marker-group {
  margin-bottom: 10px;
}

.marker-group-title {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.marker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.marker-btn {
  width: 30px;
  height: 30px;
  border: 1.5px solid transparent;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.marker-btn:hover {
  background: var(--surface-hover);
}

.marker-btn.active {
  border-color: var(--accent);
  background: var(--surface-active);
}

.popover-input,
.note-textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface-solid);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  user-select: text;
}

.popover-input:focus,
.note-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.note-textarea {
  resize: vertical;
  line-height: 1.55;
}

.label-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  min-height: 24px;
}

.label-edit-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-active);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

.label-edit-chip button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

/* ---- Context Menu ---- */

.context-menu {
  position: fixed;
  min-width: 210px;
  padding: 6px;
  background: var(--surface-solid);
  border-radius: 11px;
  box-shadow: var(--shadow-md);
  z-index: 60;
}

.ctx-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}

.ctx-item:hover:not(:disabled) {
  background: var(--surface-hover);
}

.ctx-item.danger {
  color: var(--danger);
}

.ctx-item:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ctx-kbd {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.ctx-sep {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 6px;
}

/* ---- Outliner View ---- */

.outliner-view {
  position: fixed;
  inset: 0;
  background: var(--bg-canvas);
  overflow-y: auto;
  padding: 84px 24px 80px;
  z-index: 20;
  user-select: text;
}

.outliner-container {
  max-width: 780px;
  margin: 0 auto;
  background: var(--surface-solid);
  border-radius: 16px;
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
}

.outliner-tip {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.outliner-item {
  margin-bottom: 4px;
}

.outliner-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 7px;
}

.outliner-row:hover {
  background: var(--surface-hover);
}

.outliner-bullet {
  width: 18px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 11px;
  border: none;
  background: transparent;
}

.outliner-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  outline: none;
  padding: 1px 4px;
  border-radius: 4px;
}

.outliner-input.depth-0 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.outliner-input.depth-1 {
  font-size: 16px;
  font-weight: 600;
}

.outliner-children {
  margin-left: 22px;
  padding-left: 10px;
  border-left: 1.5px solid var(--border-subtle);
}

/* ---- Modals ---- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 16px;
}

.modal-card {
  background: var(--surface-solid);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  max-width: 100%;
}

.shortcuts-card {
  width: 680px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.shortcuts-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.shortcut-group h3 {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border-subtle);
  font-size: 12.5px;
}

.shortcut-row kbd {
  background: var(--surface-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.confirm-card {
  width: 360px;
  padding: 20px 22px;
}

.confirm-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.confirm-card p {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-secondary,
.btn-danger,
.btn-primary {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.paste-import-card {
  width: 560px;
  overflow: hidden;
}

.paste-import-body {
  padding: 14px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.paste-import-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.paste-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  background: rgba(232, 69, 60, 0.1);
  border-radius: 7px;
  padding: 6px 10px;
}

.file-drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(37, 99, 235, 0.14);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  pointer-events: none;
}

.file-drop-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 40px;
  border-radius: 18px;
  border: 2px dashed var(--accent);
  background: var(--surface-solid);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  background: #1E232E;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 95;
  pointer-events: none;
}

body.dark-ui .toast {
  background: #F1F5F9;
  color: #0F172A;
}

/* ---- Responsive Adjustments ---- */

@media (max-width: 1120px) {
  .tool-btn {
    min-width: 38px;
    padding: 3px 5px;
  }
}

@media (max-width: 900px) {
  .ephemeral-pill {
    display: none;
  }
  .tool-label {
    display: none;
  }
  .tool-btn {
    min-width: 34px;
    height: 34px;
  }
}

@media (max-width: 640px) {
  .top-bar {
    flex-wrap: wrap;
    top: 8px;
    left: 8px;
    right: 8px;
  }
  .main-toolbar {
    order: 3;
    max-width: 100%;
    width: 100%;
    justify-content: space-between;
  }
  .format-panel {
    width: calc(100vw - 20px);
    right: 10px;
    top: 112px;
  }
}
