/* ==========================================================================
   Logseq + Notion Platform - Modern UI Theme & Stylesheet
   ========================================================================== */

:root {
  --bg-app: #090d16;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-surface: #131d31;
  --bg-surface-elevated: #1e293b;
  --bg-card: #172339;
  --bg-card-hover: #1e2e4a;
  --bg-input: #0b1220;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-focus: #38bdf8;

  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-link: #38bdf8;

  --accent-primary: #38bdf8;
  --accent-primary-rgb: 56, 189, 248;
  --accent-secondary: #818cf8;
  --accent-purple: #c084fc;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;

  --priority-a: #f43f5e;
  --priority-a-bg: rgba(244, 63, 94, 0.15);
  --priority-b: #f59e0b;
  --priority-b-bg: rgba(245, 158, 11, 0.15);
  --priority-c: #06b6d4;
  --priority-c-bg: rgba(6, 182, 212, 0.15);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 15px rgba(56, 189, 248, 0.25);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

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

html, body {
  height: 100%;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* App Shell Layout */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  width: 270px;
  min-width: 270px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
  user-select: none;
  z-index: 20;
  transition: transform var(--transition-normal);
}

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

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  text-decoration: none;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #0284c7, #818cf8);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

/* Sidebar Search */
.sidebar-search-box {
  padding: 12px 16px 8px;
  position: relative;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper svg {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 10px 7px 32px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 16px;
  right: 16px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.search-dropdown.active {
  display: block;
}

.search-section-title {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.search-item {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-radius: 4px;
  margin: 2px 6px;
  transition: background var(--transition-fast);
}

.search-item:hover, .search-item.selected {
  background: rgba(56, 189, 248, 0.12);
}

.search-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
  flex-shrink: 0;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nav-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 6px 8px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-group-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}

.nav-group-action:hover {
  color: var(--text-main);
  background: var(--border-subtle);
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-primary);
  font-weight: 600;
}

.nav-item .icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quick-btn:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
}

/* Top App Bar */
.topbar {
  height: 52px;
  min-height: 52px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-sidebar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
}

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

.topbar-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-breadcrumbs .current {
  color: var(--text-main);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-medium);
}

.action-btn.btn-primary {
  background: #0284c7;
  border-color: #0284c7;
  color: #fff;
}

.action-btn.btn-primary:hover {
  background: #0369a1;
}

.action-btn.btn-success {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--success);
}

/* Workspace Views Container */
.content-area {
  flex: 1;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

.view-container {
  display: none;
  flex: 1;
  padding: 24px 32px 64px;
  max-width: 1060px;
  margin: 0 auto;
  width: 100%;
}

.view-container.active {
  display: flex;
  flex-direction: column;
}

/* Full Width View (Graph & Table) */
.view-container.full-width {
  max-width: 100%;
  padding: 16px 20px;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* Page Header */
.page-header {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.page-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
}

.page-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.badge-journal {
  background: rgba(129, 140, 248, 0.15);
  color: var(--accent-secondary);
}

.badge-page {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-primary);
}

.badge-published {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
}

/* ==========================================================================
   Logseq Interactive Outliner Editor
   ========================================================================== */
.outliner-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.block-tree-root {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.block-tree-children {
  list-style: none;
  padding-left: 28px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.block-tree-children::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 12px;
  left: 11px;
  width: 1.5px;
  background: var(--border-subtle);
}

.block-item {
  position: relative;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.block-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 4px;
  min-height: 28px;
}

.block-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.block-row.focused {
  background: rgba(56, 189, 248, 0.05);
}

/* Bullet and Toggle */
.bullet-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}

.bullet-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.bullet-wrapper:hover .bullet-dot {
  transform: scale(1.4);
  background: var(--accent-primary);
}

.bullet-wrapper.has-children.collapsed .bullet-dot {
  border: 1.5px solid var(--accent-primary);
  background: transparent;
  width: 8px;
  height: 8px;
}

.bullet-toggle-icon {
  position: absolute;
  left: -8px;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.bullet-wrapper.collapsed .bullet-toggle-icon {
  transform: rotate(-90deg);
}

/* Task Checkbox */
.task-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  transition: transform 0.1s ease;
}

.task-badge:active {
  transform: scale(0.95);
}

.task-badge.todo {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.3);
  color: var(--accent-primary);
}

.task-badge.doing {
  background: rgba(251, 191, 36, 0.18);
  border-color: rgba(251, 191, 36, 0.4);
  color: var(--warning);
}

.task-badge.done {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--success);
}

/* Priority Badges */
.priority-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  margin-top: 2px;
  cursor: pointer;
}

.priority-pill.priority-a {
  background: var(--priority-a-bg);
  color: var(--priority-a);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.priority-pill.priority-b {
  background: var(--priority-b-bg);
  color: var(--priority-b);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.priority-pill.priority-c {
  background: var(--priority-c-bg);
  color: var(--priority-c);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* Block Content */
.block-content-text {
  flex: 1;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-main);
  outline: none;
  min-height: 24px;
  word-break: break-word;
}

.block-row.task-done .block-content-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* WikiLinks & Tags */
.wikilink {
  color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.wikilink:hover {
  background: rgba(56, 189, 248, 0.25);
  text-decoration: underline;
}

.tag-pill {
  color: var(--accent-purple);
  background: rgba(192, 132, 252, 0.12);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.tag-pill:hover {
  background: rgba(192, 132, 252, 0.25);
}

/* Block Actions on hover */
.block-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.block-row:hover .block-actions {
  opacity: 1;
}

.block-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 12px;
}

.block-action-btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

.block-action-btn.btn-delete:hover {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.15);
}

/* New block input at bottom */
.new-block-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-top: 12px;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.new-block-trigger:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.05);
}

/* Backlinks Section */
.backlinks-section {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.backlinks-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.backlinks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.backlink-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  cursor: pointer;
}

.backlink-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

.backlink-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.backlink-page-name {
  font-weight: 600;
  color: var(--accent-primary);
}

.backlink-content {
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.5;
}

/* ==========================================================================
   Notion Polymorphic Database Views
   ========================================================================== */
.database-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.database-header {
  margin-bottom: 16px;
}

.db-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.db-title {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
}

.db-description {
  font-size: 13px;
  color: var(--text-muted);
}

/* View Switcher Tabs */
.view-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
  gap: 12px;
}

.view-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.view-tab:hover {
  color: var(--text-main);
}

.view-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.view-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Table View */
.table-container {
  overflow-x: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.notion-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.notion-table th {
  background: var(--bg-surface-elevated);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-medium);
  border-right: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.notion-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.notion-table tr:last-child td {
  border-bottom: none;
}

.notion-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.cell-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-main);
  font-size: 13px;
  padding: 4px 6px;
  outline: none;
}

.cell-input:focus {
  background: var(--bg-input);
  border-color: var(--accent-primary);
}

.cell-select {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-main);
  font-size: 12px;
  padding: 4px 8px;
  outline: none;
  cursor: pointer;
}

.table-footer-bar {
  padding: 10px 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Kanban Board View */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  height: calc(100vh - 230px);
}

.kanban-column {
  flex: 0 0 290px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

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

.column-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}

.column-color-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.column-count {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.kanban-cards-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.kanban-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kanban-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.kanban-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.kanban-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.advance-btn {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: var(--accent-primary);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.advance-btn:hover {
  background: rgba(56, 189, 248, 0.25);
}

.kanban-add-card-btn {
  padding: 10px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--transition-fast);
}

.kanban-add-card-btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

/* Gallery View */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 4px 0;
}

.gallery-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.gallery-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.gallery-card-cover {
  height: 90px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 12px;
}

.gallery-card-icon {
  font-size: 24px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.gallery-card-body {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gallery-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.gallery-card-props {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.gallery-prop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   Interactive 2D Knowledge Graph Visualizer
   ========================================================================== */
.graph-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background: #070b12;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

#graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#graph-canvas:active {
  cursor: grabbing;
}

.graph-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.graph-btn {
  width: 34px;
  height: 34px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
}

.graph-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.graph-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.graph-hint {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   AI Agent / Model Context Protocol (MCP) Console
   ========================================================================== */
.mcp-console-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.mcp-header-banner {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.2), rgba(192, 132, 252, 0.15));
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.mcp-banner-info h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mcp-banner-info p {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 600px;
}

/* Tool Execution Grid */
.mcp-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.mcp-preset-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.mcp-preset-btn:hover, .mcp-preset-btn.active {
  border-color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.08);
}

.preset-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.preset-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* Interactive Playground Panels */
.mcp-playground-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .mcp-playground-layout {
    grid-template-columns: 1fr;
  }
}

.mcp-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.mcp-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mcp-form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mcp-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.mcp-select, .mcp-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
}

.mcp-textarea {
  font-family: var(--font-mono);
  font-size: 12.5px;
  min-height: 180px;
  resize: vertical;
}

.mcp-select:focus, .mcp-textarea:focus {
  border-color: var(--accent-primary);
}

.mcp-result-viewer {
  background: #060911;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: #38bdf8;
  overflow-x: auto;
  min-height: 240px;
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================================================
   Modals & Popups
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-primary);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.2s ease forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.toast-success {
  border-color: var(--success);
}

.toast.toast-error {
  border-color: var(--danger);
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   Notion-Style Workspace Switcher
   ========================================================================== */
.workspace-switcher-wrapper {
  position: relative;
  margin: 4px 12px 14px 12px;
}

.workspace-switcher-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  color: var(--text-main);
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}

.workspace-switcher-btn:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-medium);
}

.workspace-current-icon {
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.workspace-current-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.workspace-current-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.workspace-current-role {
  font-size: 11px;
  color: var(--text-muted);
}

.workspace-switcher-arrow {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.workspace-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.workspace-dropdown.hidden {
  display: none;
}

.workspace-dropdown-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 10px;
  letter-spacing: 0.5px;
}

.workspace-list-items {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.workspace-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.workspace-item:hover {
  background: var(--bg-surface);
}

.workspace-item.active {
  background: rgba(56, 189, 248, 0.12);
}

.workspace-item.active .workspace-item-name {
  color: var(--accent-primary);
  font-weight: 600;
}

.workspace-item-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.workspace-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.workspace-item-name {
  font-size: 13px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-item-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.workspace-item-check {
  color: var(--accent-primary);
  font-size: 13px;
  font-weight: 700;
}

.workspace-dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 6px 0;
}

.workspace-dropdown-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.workspace-dropdown-action:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}

/* ==========================================================================
   Page Permission Badges & Topbar Share Button
   ========================================================================== */
.badge-permission {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.badge-permission.badge-full {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
  color: var(--accent-primary);
}

.badge-permission.badge-edit {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--success);
}

.badge-permission.badge-view {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.3);
  color: var(--warning);
}

.badge-permission.badge-private {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

.btn-share {
  background: var(--accent-primary) !important;
  color: #000 !important;
  font-weight: 600 !important;
  border: none !important;
  padding: 6px 14px !important;
}

.btn-share:hover {
  background: #7dd3fc !important;
}

/* Read-only notification banner when user has view-only access */
.read-only-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-sm);
  color: var(--warning);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ==========================================================================
   Notion-Style Share Modal
   ========================================================================== */
.modal-share-card {
  max-width: 540px;
  width: 95%;
}

.modal-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.share-modal-body {
  padding: 16px 24px;
}

.share-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.share-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.share-row-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.share-row-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.share-row-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.share-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 16px 0;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  transition: 0.2s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: 0.2s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
  background-color: #000;
}

.share-web-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.share-web-details.hidden {
  display: none;
}

.share-link-box {
  display: flex;
  gap: 8px;
  align-items: center;
}

.share-url-input {
  flex: 1;
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--bg-input);
  color: var(--accent-primary);
}

.share-web-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.permission-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.invite-member-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.share-members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
}

.member-perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.member-perm-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.member-avatar {
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.member-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.member-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.member-role-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
}

.member-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Simulate User Cards */
.simulate-users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.simulate-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.simulate-user-card:hover {
  border-color: var(--border-medium);
  background: var(--bg-surface-elevated);
}

.simulate-user-card.active {
  border-color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.08);
}

/* ==========================================================================
   Topbar Workspace Switcher & User Profile Button
   ========================================================================== */
.topbar-ws-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.topbar-ws-badge:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-primary);
}

.topbar-ws-arrow {
  font-size: 11px;
  color: var(--text-muted);
}

.breadcrumb-separator {
  color: var(--text-muted);
  margin: 0 4px;
}

.btn-user-profile {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-user-profile:hover {
  border-color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.1);
}

.user-avatar-badge {
  font-size: 14px;
}

.user-name-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role-pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-primary);
  padding: 2px 6px;
  border-radius: 10px;
}

.auth-current-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
}

.auth-current-avatar {
  font-size: 28px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Mobile Responsive Layout System (Smartphones & Tablets)
   ========================================================================== */

/* Hamburger Menu Button (Desktop: Hidden) */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.mobile-menu-btn:hover, .mobile-menu-btn:active {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-primary);
}

/* Sidebar Backdrop Overlay */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Bottom Quick Nav (Desktop: Hidden) */
.mobile-bottom-nav {
  display: none;
}

/* Mobile Outliner Toolbar (Desktop: Hidden) */
.mobile-outliner-toolbar {
  display: none;
}

/* Tablet & Mobile Media Query (<= 768px) */
@media (max-width: 768px) {
  #app {
    flex-direction: column;
  }

  /* Sliding Drawer Sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 82vw;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .main-wrapper {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
  }

  .content-area {
    padding-bottom: 64px; /* Space for bottom nav */
  }

  /* Mobile Topbar */
  .topbar {
    padding: 0 8px;
    height: 48px;
    min-height: 48px;
    gap: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .topbar-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  .topbar-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    min-width: 0;
    overflow: hidden;
  }

  .topbar-ws-badge {
    padding: 3px 6px;
    font-size: 11.5px;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
  }

  #topbar-title {
    max-width: 75px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }

  #page-permission-badge {
    display: none !important; /* Keep topbar uncluttered on small screens */
  }

  #btn-topbar-graph {
    display: none !important; /* Already accessible via mobile bottom nav */
  }

  #btn-topbar-share {
    padding: 5px 8px;
    font-size: 12px;
  }

  .user-name-text {
    display: none !important; /* Hide long name on phone screens */
  }

  .user-role-pill {
    display: none !important; /* Hide role pill on mobile topbar */
  }

  .btn-user-profile {
    padding: 4px 6px;
    gap: 0;
  }

  .user-avatar-badge {
    margin: 0;
  }

  .action-btn {
    padding: 5px 8px;
    font-size: 12px;
  }

  /* Mobile Bottom Quick Navigation Bar */
  .mobile-bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 54px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-subtle);
    z-index: 900;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    height: 100%;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s;
    user-select: none;
  }

  .mobile-nav-item.active,
  .mobile-nav-item:active {
    color: var(--accent-primary);
  }

  .mobile-nav-icon {
    font-size: 17px;
    line-height: 1;
  }

  .mobile-nav-label {
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
  }

  /* Mobile Outliner Editor Touch Optimization */
  .page-container {
    padding: 14px 10px 80px 10px;
  }

  .page-title-input {
    font-size: 24px;
  }

  .block-children {
    margin-left: 12px;
    padding-left: 8px;
    border-left-width: 1.5px;
  }

  .block-bullet {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .block-task-status {
    min-height: 24px;
    padding: 2px 7px;
    font-size: 11px;
  }

  .block-content-text {
    font-size: 14px;
    line-height: 1.5;
  }

  .block-actions {
    display: none; /* Hide hover action icons that interfere with touch */
  }

  /* Mobile Outliner Floating Keyboard Accessory Toolbar */
  .mobile-outliner-toolbar {
    display: flex;
    position: fixed;
    bottom: 54px;
    left: 0;
    right: 0;
    background: var(--bg-surface-elevated);
    border-top: 1px solid var(--border-medium);
    padding: 5px 10px;
    z-index: 950;
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  .mobile-outliner-toolbar.hidden {
    display: none;
  }

  .mobile-toolbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
  }

  .mobile-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    touch-action: manipulation;
  }

  .mobile-tool-btn:active {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--accent-primary);
  }

  /* Notion Databases on Mobile */
  .database-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .db-view-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .db-view-controls {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /* Kanban Board Swipe & Snap Scroll */
  .kanban-board {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 12px;
    padding-bottom: 16px;
  }

  .kanban-column {
    min-width: 82vw;
    max-width: 85vw;
    scroll-snap-align: center;
    flex-shrink: 0;
  }

  .notion-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Mobile Modals (Bottom Sheet) */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-card {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px 16px env(safe-area-inset-bottom, 20px) 16px;
    animation: slideUpMobile 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes slideUpMobile {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
}


