/* ========== CSS Variables & Reset ========== */
:root {
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8edf2;
  --text-primary: #1a2332;
  --text-secondary: #5a6d80;
  --text-muted: #8a9bb0;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #dbeafe;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --border: #dde4ed;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ========== Top Bar ========== */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-logo { font-size: 24px; }

.app-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.topbar-center {
  flex: 1;
  max-width: 480px;
  margin: 0 40px;
  position: relative;
}

#global-search {
  width: 100%;
  height: 36px;
  padding: 0 16px;
  border: 2px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  background: var(--bg-primary);
  transition: var(--transition);
  font-family: var(--font-family);
}
#global-search:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-secondary);
}

.topbar-right { display: flex; gap: 8px; }

.top-btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-family);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}
.top-btn:hover { background: var(--accent-light); color: var(--accent); }
.settings-btn { font-size: 18px; width: 34px; padding: 0; justify-content: center; }

/* ========== Search Dropdown ========== */
.search-dropdown {
  position: absolute;
  top: 42px;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
}

.search-dropdown-small {
  position: absolute;
  top: 38px;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow-y: auto;
  z-index: 200;
}

.search-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--bg-tertiary);
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--accent-light); }
.search-item .si-number { font-weight: 600; color: var(--accent); font-size: 13px; }
.search-item .si-name { color: var(--text-primary); font-size: 13px; }

/* ========== Workspace & Pages ========== */
#workspace {
  height: calc(100vh - 52px);
  position: relative;
  overflow: hidden;
}

.page {
  display: none;
  height: 100%;
  overflow-y: auto;
}
.page.active { display: flex; flex-direction: column; }

/* ========== Home Page ========== */
#home-page {
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px;
}

.home-container {
  width: 100%;
  max-width: 700px;
  text-align: center;
}

.home-hero { margin-bottom: 32px; }

.home-logo-large {
  font-size: 72px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.home-hero h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.home-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

/* Home search */
.home-search-area {
  position: relative;
  margin-bottom: 24px;
}
#home-search {
  width: 100%;
  height: 48px;
  padding: 0 20px;
  border: 2px solid var(--border);
  border-radius: 24px;
  font-size: 15px;
  background: var(--bg-secondary);
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-family);
}
#home-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

/* Signature */
.home-signature {
  margin-bottom: 20px;
  padding: 12px;
  font-size: 18px;
  color: var(--text-secondary);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Home actions */
.home-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}

.home-recent {
  text-align: left;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.home-recent h3 {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.recent-item:hover { background: var(--accent-light); }
.recent-item .ri-number { font-weight: 600; color: var(--accent); font-size: 13px; }
.recent-item .ri-name { color: var(--text-primary); font-size: 14px; }

.list-search-input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-family);
  margin-bottom: 12px;
  background: var(--bg-primary);
  transition: var(--transition);
}
.list-search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-secondary);
}

/* ========== Buttons ========== */
.btn-primary, .btn-secondary, .btn-danger, .action-btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font-family);
  transition: var(--transition);
  font-weight: 500;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-tertiary); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 6px 14px; font-size: 12px; }

.action-btn {
  padding: 7px 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.action-btn:hover { background: var(--accent-light); color: var(--accent); }
.action-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.action-btn.primary:hover { background: var(--accent-hover); }
.action-btn.danger { color: var(--danger); }
.action-btn.danger:hover { background: #fef2f2; }

/* ========== Knowledge Point Page ========== */
#kp-page, #kp-edit-page { background: var(--bg-primary); }

.kp-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.back-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-family);
  transition: var(--transition);
}
.back-btn:hover { background: var(--bg-tertiary); }

.kp-title-area {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.kp-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 12px;
}
.kp-name {
  font-size: 20px;
  font-weight: 700;
}
.kp-header-actions { display: flex; gap: 8px; }

.title-input {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-family);
  background: var(--bg-secondary);
}
.title-input:focus { outline: none; border-color: var(--accent); }
#edit-number { width: 160px; }
#edit-name { flex: 1; max-width: 400px; }

/* KP Body */
.kp-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.kp-content-area {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
  background: var(--bg-secondary);
  margin: 12px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* Markdown content styling */
.kp-content-area h1 { font-size: 26px; margin: 20px 0 12px; font-weight: 700; }
.kp-content-area h2 { font-size: 22px; margin: 18px 0 10px; font-weight: 600; color: var(--text-primary); }
.kp-content-area h3 { font-size: 18px; margin: 14px 0 8px; font-weight: 600; }
.kp-content-area p { line-height: 1.8; margin: 8px 0; }
.kp-content-area ul, .kp-content-area ol { margin: 8px 0; padding-left: 24px; }
.kp-content-area li { line-height: 1.8; }
.kp-content-area code { background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.kp-content-area pre { background: #1a2332; color: #e0e6ed; padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; margin: 12px 0; }
.kp-content-area pre code { background: none; color: inherit; }
.kp-content-area img { max-width: 40%; height: auto; border-radius: var(--radius-sm); margin: 8px 0; cursor: pointer; transition: transform 0.2s; }
.kp-content-area img:hover { transform: scale(1.05); }
.kp-content-area blockquote { border-left: 3px solid var(--accent); padding: 8px 16px; margin: 12px 0; background: var(--accent-light); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.kp-content-area table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.kp-content-area th, .kp-content-area td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.kp-content-area th { background: var(--bg-tertiary); font-weight: 600; }
.kp-content-area a { color: var(--accent); text-decoration: none; }
.kp-content-area a:hover { text-decoration: underline; }

/* KP Sidebar */
.kp-sidebar {
  width: 280px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kp-related-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.kp-related-section h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-tertiary);
}

.related-item {
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.related-item:hover { background: var(--accent-light); }
.related-item .rel-relation {
  font-size: 11px;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.related-item .rel-number {
  font-weight: 600;
  color: var(--accent);
  font-size: 12px;
}

/* ========== Edit Page ========== */
.kp-edit-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.edit-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
  overflow-y: auto;
}

.edit-section h3 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#edit-content {
  width: 100%;
  height: 300px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Microsoft YaHei', monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  background: var(--bg-secondary);
}
#edit-content:focus { outline: none; border-color: var(--accent); }

.markdown-preview {
  min-height: 300px;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-y: auto;
}
.markdown-preview h1 { font-size: 22px; margin: 16px 0 10px; }
.markdown-preview h2 { font-size: 19px; margin: 14px 0 8px; }
.markdown-preview h3 { font-size: 16px; margin: 12px 0 6px; }
.markdown-preview p { line-height: 1.7; margin: 6px 0; }
.markdown-preview img { max-width: 40%; border-radius: var(--radius-sm); }
.markdown-preview code { background: var(--bg-tertiary); padding: 2px 5px; border-radius: 3px; font-size: 13px; }
.markdown-preview pre { background: #1a2332; color: #e0e6ed; padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; }
.markdown-preview blockquote { border-left: 3px solid var(--accent); padding: 6px 12px; background: var(--accent-light); }

.edit-toolbar {
  display: flex;
  gap: 8px;
}
.tool-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-family);
  transition: var(--transition);
}
.tool-btn:hover { background: var(--bg-tertiary); }

.edit-sidebar {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.edit-related {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.edit-related h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-tertiary);
}

.edit-related-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13px;
}
.edit-related-item .del-rel-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  padding: 2px 6px;
}
.edit-related-item .del-rel-btn:hover { color: var(--danger); }

.add-related-area {
  position: relative;
  margin-top: 8px;
}
.add-related-area input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-family);
}
.add-related-area input:focus { outline: none; border-color: var(--accent); }

/* ========== Mind Map Page ========== */
.mindmap-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#mindmap-title { font-weight: 600; font-size: 15px; }
.mindmap-controls { display: flex; gap: 6px; margin-left: auto; align-items: center; }

.pen-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
}
.pen-btn.active { border-color: var(--text-primary); }
.pen-red:hover, .pen-red.active { border-color: #ef4444; background: #fef2f2; }
.pen-green:hover, .pen-green.active { border-color: #10b981; background: #ecfdf5; }
.pen-blue:hover, .pen-blue.active { border-color: #3b82f6; background: #dbeafe; }

#mindmap-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
}
#mindmap-canvas {
  display: block;
}

/* KP Bubble on mind map */
.bubble {
  position: absolute;
  background: #fefcf0;
  border: 2px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  width: 240px;
  z-index: 50;
  pointer-events: auto;
}
.bubble-number { font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.bubble-name { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.bubble-preview { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; line-height: 1.5; }
.bubble-jump { display: block; width: 100%; }

/* ========== Modals ========== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 { margin-bottom: 16px; font-size: 18px; }
.modal-content label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--text-secondary); }
.modal-content input[type="text"],
.modal-content input[type="password"],
.modal-content input[type="number"],
.modal-content select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-family);
  margin-top: 4px;
}
.modal-content input:focus, .modal-content select:focus { outline: none; border-color: var(--accent); }

.mode-options {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.mode-btn {
  flex: 1;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  cursor: pointer;
  text-align: center;
  font-size: 14px;
  font-family: var(--font-family);
  transition: var(--transition);
}
.mode-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.mode-btn small { display: block; color: var(--text-muted); font-size: 11px; margin-top: 4px; }

#free-mode-controls {
  margin-bottom: 16px;
}
#free-mode-controls label {
  display: inline-block;
  margin-right: 16px;
  font-size: 14px;
}
#free-mode-controls input {
  width: 60px;
  margin-left: 6px;
  padding: 4px 8px;
}

.confirm-content { text-align: center; }
.confirm-content p { font-size: 15px; margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 12px; justify-content: center; }

.settings-content { max-width: 520px; }
.settings-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--bg-tertiary);
}
.settings-section h3 { margin-bottom: 14px; color: var(--accent); }
.settings-actions { display: flex; justify-content: space-between; margin-top: 20px; }

.cloud-actions { display: flex; gap: 12px; margin-top: 14px; }
.cloud-status { margin-top: 10px; font-size: 13px; padding: 8px; border-radius: var(--radius-sm); }
.cloud-status.success { background: #ecfdf5; color: #065f46; }
.cloud-status.error { background: #fef2f2; color: #991b1b; }

/* ========== Images Page ========== */
#images-page {
  background: var(--bg-primary);
  padding: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.modal-header h1 { font-size: 22px; }

.images-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.images-toolbar input {
  flex: 1;
  min-width: 200px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-family);
}
.images-toolbar input:focus { outline: none; border-color: var(--accent); }

.img-manager-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.img-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
}
.img-card:hover { box-shadow: var(--shadow-md); }
.img-card.selected { border-color: var(--accent); }
.img-card-thumb {
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.img-card-info {
  padding: 10px;
}
.img-card-info .img-card-number {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}
.img-card-info .img-card-name {
  font-size: 13px;
  color: var(--text-primary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.img-preview-content {
  max-width: 90vw;
  max-height: 90vh;
  text-align: center;
}
.img-preview-content img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  margin: 12px 0;
}
.img-grid-item {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: var(--transition);
}
.img-grid-item:hover { border-color: var(--accent); }
.img-grid-item.selected { border-color: var(--accent); }
.img-grid-item img {
  width: 100%;
  height: 80px;
  object-fit: cover;
}
.img-grid-item .img-grid-label {
  font-size: 10px;
  padding: 3px;
  text-align: center;
  color: var(--text-muted);
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a2332;
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  transition: opacity 0.3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

/* ========== Scrollbar ========== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ========== Hidden ========== */
.hidden { display: none !important; }

/* ========== KaTeX Formula ========== */
.markdown-preview .katex-display,
#kp-content-rendered .katex-display {
  margin: 12px 0;
  padding: 8px 0;
  overflow-x: auto;
}
.markdown-preview .katex,
#kp-content-rendered .katex {
  font-size: 1.05em;
}

/* ========== Responsive (Tablet & Mobile) ========== */
@media (max-width: 900px) {
  #topbar { padding: 0 10px; height: 50px; }
  .app-title { font-size: 14px; }
  .app-logo { font-size: 20px; }
  .topbar-center { margin: 0 10px; }
  .top-btn { padding: 0 8px; font-size: 12px; }
  #workspace { height: calc(100vh - 50px); }
  #home-page { padding: 20px 12px; }
  .home-hero h1 { font-size: 28px; }
  .kp-header { flex-wrap: wrap; padding: 10px 12px; }
  .kp-body { padding: 12px; }
  .mindmap-header { flex-wrap: wrap; padding: 8px 10px; gap: 6px; }
  .mindmap-controls { margin-left: 0; width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .modal-content { width: 92%; max-height: 85vh; margin: 8vh auto 0; padding: 16px; }
  .kp-edit-body { padding: 12px; }
}

@media (max-width: 600px) {
  #topbar { padding: 0 8px; }
  .topbar-left .app-title { display: none; }
  .topbar-left { gap: 4px; }
  .top-btn { height: 32px; padding: 0 6px; font-size: 11px; }
  .settings-btn { font-size: 16px; width: 32px; }
  .topbar-center { margin: 0 6px; }
  #global-search { height: 32px; font-size: 12px; padding: 0 10px; }
  .home-container { max-width: 100%; }
  .home-hero h1 { font-size: 24px; }
  .home-subtitle { font-size: 14px; }
  .home-search-area input { font-size: 14px; height: 40px; }
  .kp-title-area { flex-direction: column; align-items: stretch; gap: 6px; }
  .kp-title-area .title-input { font-size: 15px; }
  .kp-header-actions { flex-wrap: wrap; }
  .related-item { font-size: 13px; padding: 8px; }
  .mindmap-header #mindmap-title { font-size: 13px; }
  .mindmap-controls button { font-size: 11px; padding: 4px 8px; }
  #mindmap-mode-modal .modal-content { width: 94%; }
  .mode-options { flex-direction: column; }
  .mode-btn { width: 100%; padding: 10px; }
  .edit-preview { min-height: 200px; }
  .modal-content h3 { font-size: 16px; }
  .img-grid { grid-template-columns: repeat(2, 1fr); }
  .bubble { width: 200px; }
}

@media (max-width: 480px) {
  #global-search { display: none; }
  .topbar-center { display: none; }
  .topbar-right { margin-left: auto; }
  .img-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .btn-primary, .btn-secondary { padding: 8px 12px; font-size: 13px; }
  .home-actions { flex-direction: column; gap: 10px; }
  .home-actions .btn-primary, .home-actions .btn-secondary { width: 100%; }
}

/* ========== Login Page ========== */
.login-page {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 20px;
}
.login-page.hidden { display: none; }

.login-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo { font-size: 56px; margin-bottom: 8px; }
.login-card h1 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.login-sub { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-family);
  margin-bottom: 12px;
  box-sizing: border-box;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-remember {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 4px 0 16px;
  text-align: left;
}
.login-card .btn-primary { width: 100%; padding: 12px; }
.login-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
}

/* ========== Current user / account ========== */
.current-user {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  margin-right: 4px;
  align-self: center;
  white-space: nowrap;
}
.settings-account-line { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }
.user-list { margin-bottom: 14px; }
.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13px;
}
.user-badge {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 10px;
}
