:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e5e7eb;
  --border-subtle: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.09);
  --accent: #0284c7;
  --purple: #7c3aed;
  --purple-soft: rgba(124, 58, 237, 0.09);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.09);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.16);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 260px;
  --transition: 0.16s ease;
}

[data-theme="dark"] {
  --bg: #0b0f19;
  --surface: #111827;
  --surface-2: #1a2234;
  --border: #243044;
  --border-subtle: #1a2234;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --primary-soft: rgba(96, 165, 250, 0.14);
  --accent: #38bdf8;
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.14);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

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

/* App Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Left Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.sidebar-backdrop {
  display: none;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1px;
  line-height: 1.2;
}

.file-status-badge {
  display: inline-block;
  font-size: 11px;
  color: var(--text-muted);
  max-width: 165px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sidebar-section-header .sidebar-section-title {
  margin-bottom: 0;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 5px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.action-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--primary);
  color: var(--primary);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.action-btn.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  color: #fff;
}

.action-btn.accent {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
}

.action-btn.accent:hover:not(:disabled) {
  border-color: var(--primary);
}

.action-btn.sm {
  padding: 5px 6px;
  font-size: 11.5px;
}

/* Nav Items */
.nav-section {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.nav-item.active .nav-icon {
  color: var(--primary);
}

.nav-label {
  flex: 1;
}

.nav-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.nav-badge.accent { background: var(--primary-soft); color: var(--primary); }
.nav-badge.purple { background: var(--purple-soft); color: var(--purple); }
.nav-badge.warn { background: var(--warn-soft); color: var(--warn); }
.nav-badge.danger { background: var(--danger-soft); color: var(--danger); }

/* Groups */
.groups-section {
  flex: 1;
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.group-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13px;
}

.group-item:hover { background: var(--surface-2); }
.group-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.group-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.group-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-actions {
  display: none;
  gap: 2px;
}

.group-item:hover .group-actions {
  display: flex;
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  border-bottom: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
}

.toggle-row input { display: none; }

.toggle-slider {
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}

.toggle-row input:checked + .toggle-slider { background: var(--primary); }
.toggle-row input:checked + .toggle-slider::after { transform: translateX(14px); }

.sync-card {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 9px;
}

.sync-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.offline { background: var(--text-muted); }
.status-dot.synced { background: var(--success); }
.status-dot.syncing { background: var(--warn); animation: pulse 1s infinite; }
.status-dot.error { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.sync-status-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.sync-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.footer-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  font-size: 12px;
}

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

.save-indicator {
  font-size: 11px;
  color: var(--success);
}

/* Main Content */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 28px 48px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

/* Minimal Topbar */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

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

.view-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.25;
}

.view-meta-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
  flex-wrap: wrap;
}

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

.summary-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.meta-link {
  border: none;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
}

.meta-link strong {
  color: var(--primary);
  margin-left: 2px;
}

.meta-link:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.meta-link.purple strong { color: var(--purple); }
.meta-link.danger { background: var(--danger-soft); color: var(--danger); }
.meta-link.danger strong { color: var(--danger); }

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

.search-box {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  gap: 6px;
  min-width: 200px;
  color: var(--text-muted);
  transition: border-color var(--transition);
}

.search-box:focus-within {
  border-color: var(--primary);
  color: var(--text);
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 13px;
  color: var(--text);
}

.filter-controls {
  display: flex;
  gap: 6px;
}

.select-sm, .input-sm {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12.5px;
  outline: none;
}

.select-sm:focus, .input-sm:focus {
  border-color: var(--primary);
}

.select-ghost {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
  color: var(--text-muted);
  outline: none;
  cursor: pointer;
}

.select-ghost:hover, .select-ghost:focus {
  background: var(--surface-2);
  color: var(--text);
}

/* Streamlined Quick Add Bar */
.quick-add-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.quick-add-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.quick-add-icon {
  color: var(--primary);
  display: inline-flex;
  align-items: center;
}

.quick-input {
  flex: 1;
  min-width: 140px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14.5px;
  padding: 4px 2px;
}

.quick-add-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: all var(--transition);
}

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

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

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

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

.btn.danger:hover { opacity: 0.9; }

.btn.sm {
  padding: 5px 10px;
  font-size: 12px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}

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

.icon-btn.xs {
  width: 24px;
  height: 24px;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.chip-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.chip-btn.primary-soft {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
}

.chip-btn.primary-soft:hover {
  border-color: var(--primary);
}

.chip-btn.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.chip-btn.file-btn {
  position: relative;
}

/* Content Area & Clean Day Cards */
.content-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.day-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.day-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.day-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.day-tag.future { background: var(--purple-soft); color: var(--purple); }
.day-tag.past { background: var(--warn-soft); color: var(--warn); }

.day-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Task Rows - Content First */
.task-list {
  display: flex;
  flex-direction: column;
}

.task-row {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}

.task-row:last-child {
  border-bottom: none;
}

.task-row:hover {
  background: var(--bg);
}

.task-row-top {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.task-row.completed .task-title-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.task-checkbox.lg {
  width: 20px;
  height: 20px;
  margin-top: 0;
}

.task-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.task-title-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}

.task-title-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  line-height: 1.45;
}

.priority-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  align-self: center;
}

.priority-dot.urgent { background: var(--danger); }
.priority-dot.high { background: var(--warn); }
.priority-dot.medium { background: var(--primary); }
.priority-dot.low { background: var(--text-muted); opacity: 0.45; }

.task-detail-snippet {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.pill-priority-urgent { background: var(--danger-soft); color: var(--danger); }
.pill-priority-high { background: var(--warn-soft); color: var(--warn); }
.pill-priority-medium { background: var(--primary-soft); color: var(--primary); }
.pill-priority-low { background: var(--surface-2); color: var(--text-muted); }

.pill-status-todo { background: var(--surface-2); color: var(--text-muted); }
.pill-status-in_progress { background: var(--primary-soft); color: var(--primary); }
.pill-status-blocked { background: var(--danger-soft); color: var(--danger); }
.pill-status-done { background: var(--success-soft); color: var(--success); }
.pill-status-suspended { background: var(--warn-soft); color: var(--warn); }

.pill-group {
  color: var(--text-muted);
  background: transparent;
  padding: 0;
}

.task-quick-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity var(--transition);
}

.task-row:hover .task-quick-actions,
.task-row:focus-within .task-quick-actions {
  opacity: 1;
}

.task-action-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11.5px;
  transition: all var(--transition);
}

.task-action-mini:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--primary);
}

.task-action-mini.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.task-action-mini.danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* Mobile collapsed single action button + dropdown menu */
.task-mobile-more-wrap {
  display: none;
  position: relative;
  flex-shrink: 0;
}

.task-mobile-menu {
  position: absolute;
  top: 32px;
  right: 0;
  min-width: 148px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.task-mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.task-mobile-menu-item:hover {
  background: var(--surface-2);
}

.task-mobile-menu-item.danger {
  color: var(--danger);
}

/* Task-level Thumbnails Strip (All task + thought images directly visible on row) */
.task-thumbs-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-left: 29px;
}

.task-thumb-item {
  width: 52px;
  height: 52px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: zoom-in;
  background: var(--surface-2);
  transition: transform var(--transition), border-color var(--transition);
}

.task-thumb-item:hover {
  transform: scale(1.05);
  border-color: var(--primary);
}

.task-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Inline Thought Panel right on the task row */
.inline-thought-panel {
  margin-top: 10px;
  margin-left: 29px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-thought-composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inline-thought-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.inline-thought-input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}

.inline-thought-input:focus {
  border-color: var(--primary);
}

.pending-img-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pending-img-chip {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.pending-img-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pending-img-chip button {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inline-thought-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inline-thought-item {
  font-size: 12.5px;
  padding-left: 8px;
  border-left: 2px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.inline-thought-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* Long-term task card */
.longterm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--purple);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.longterm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.longterm-range {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--purple);
  background: var(--purple-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Reminder Box & Notes Lock Gate */
.reminder-box {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.pill-reminder {
  background: var(--primary-soft);
  color: var(--primary);
}

.pill-reminder.due {
  background: var(--danger-soft);
  color: var(--danger);
}

.notes-lock-gate {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 54px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  max-width: 440px;
  margin: 40px auto;
  width: 100%;
}

.notes-lock-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.notes-lock-form {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.notes-lock-form input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--surface);
  outline: none;
}

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

/* Notes Workspace */
.notes-workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  min-height: 68vh;
}

.notes-list-pane,
.notes-editor-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notes-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 8px;
}

.notes-list-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.note-list-item {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.note-list-item:hover { background: var(--bg); }
.note-list-item.active {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
}

.note-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}

.note-item-snippet {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.note-editor-body {
  flex: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note-title-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  width: 100%;
}

.note-split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 1;
  min-height: 380px;
}

.note-split-grid.mode-edit {
  grid-template-columns: 1fr;
}

.note-split-grid.mode-preview {
  grid-template-columns: 1fr;
}

/* Single-screen Typora/Obsidian-style Live Markdown Editor */
.note-live-canvas {
  flex: 1;
  min-height: 380px;
  padding: 6px 2px 64px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: text;
}

.note-live-line {
  min-height: 28px;
  padding: 3px 6px;
  border-radius: 6px;
  line-height: 1.7;
  font-size: 14.5px;
  word-break: break-word;
  transition: background var(--transition);
}

.note-live-line:hover {
  background: var(--bg);
}

.note-live-line.editing {
  background: var(--primary-soft);
  padding: 4px 8px;
}

.note-live-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "PingFang SC", monospace;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

.note-live-line h1 { font-size: 22px; font-weight: 700; margin: 6px 0 2px; }
.note-live-line h2 { font-size: 18px; font-weight: 700; margin: 6px 0 2px; border-bottom: 1px solid var(--border-subtle); padding-bottom: 3px; }
.note-live-line h3 { font-size: 16px; font-weight: 600; margin: 4px 0 2px; }
.note-live-line h4 { font-size: 14.5px; font-weight: 600; color: var(--primary); margin: 4px 0 2px; }
.note-live-line code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.note-live-line img { max-width: 100%; max-height: 260px; border-radius: 8px; border: 1px solid var(--border); margin: 4px 0; display: block; cursor: zoom-in; }

.note-live-placeholder {
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 6px;
  opacity: 0.7;
}

.note-content-textarea {
  flex: 1;
  min-height: 360px;
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  outline: none;
  resize: vertical;
  background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "PingFang SC", monospace;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
}

.note-content-textarea:focus {
  border-color: var(--primary);
}

.note-live-preview {
  min-height: 360px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow-y: auto;
}

@media (max-width: 860px) {
  .note-split-grid {
    grid-template-columns: 1fr;
  }
}

/* Markdown Editor View */
.markdown-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-height: 68vh;
}

.md-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.md-pane-header {
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
}

.md-textarea {
  flex: 1;
  width: 100%;
  min-height: 520px;
  border: none;
  outline: none;
  resize: vertical;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
  background: var(--surface);
}

.markdown-preview {
  padding: 14px;
  overflow-y: auto;
  line-height: 1.7;
}

.markdown-preview h2 {
  font-size: 18px;
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.markdown-preview h4 {
  font-size: 14.5px;
  margin: 16px 0 8px;
  color: var(--primary);
}

.markdown-preview img {
  max-width: 100%;
  border-radius: 8px;
  margin: 6px 0;
  border: 1px solid var(--border);
}

.markdown-preview code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}

/* Empty State */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* Detail Drawer */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  z-index: 80;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(540px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  display: flex;
  flex-direction: column;
}

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

.drawer-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.detail-title-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16.5px;
  font-weight: 700;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 32px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.field > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.field input, .field select, .field textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  background: var(--surface);
  outline: none;
}

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

.field-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.quick-move-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

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

.timestamps-box {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.timestamps-box span { color: var(--text-muted); }

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.section-header-row h3 {
  font-size: 13.5px;
  font-weight: 600;
}

.inline-actions {
  display: flex;
  gap: 6px;
}

.drawer-section textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: var(--surface);
  outline: none;
  resize: vertical;
  width: 100%;
}

.drawer-section textarea:focus {
  border-color: var(--primary);
}

.images-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.image-thumb-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.image-thumb-card img {
  width: 100%;
  height: 78px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.image-thumb-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Thoughts Timeline */
.thought-composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thought-composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.thoughts-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.thought-item {
  border-left: 2px solid var(--primary);
  background: var(--surface-2);
  padding: 8px 11px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.thought-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
  font-size: 11px;
  color: var(--text-muted);
}

.thought-item-body {
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.thought-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.thought-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: zoom-in;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(560px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-dialog.lg { width: min(680px, 100%); }
.modal-dialog.sm { width: min(420px, 100%); }

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.quick-date-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Streamlined Morning Review Modal */
.morning-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.morning-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  padding: 0 2px 6px;
  color: var(--text-muted);
}

.morning-group.overdue .morning-group-label { color: var(--warn); }
.morning-group.longterm .morning-group-label { color: var(--purple); }

.morning-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.morning-row {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.morning-row:last-child { border-bottom: none; }

.morning-row-main {
  flex: 1;
  min-width: 200px;
}

.morning-row-title {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.morning-row-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.morning-row-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

/* Sync Config Panels */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--primary-soft);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
}

.info-banner .icon {
  color: var(--primary);
  margin-top: 2px;
}

.sync-subpanel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sync-subpanel-title {
  font-weight: 600;
  font-size: 13px;
}

.sync-log-box {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
}

/* Image Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 24, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 250;
  padding: 24px;
}

.lightbox-stage {
  max-width: 90vw;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.lightbox-stage img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}

.lightbox-caption {
  color: rgba(255, 255, 255, 0.8);
  font-size: 12.5px;
}

.lightbox-btn {
  position: fixed;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition);
}

.lightbox-btn:hover { background: rgba(255, 255, 255, 0.28); }
.lightbox-close { top: 18px; right: 20px; }
.lightbox-nav.prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lightbox-nav.next { right: 20px; top: 50%; transform: translateY(-50%); }

/* Highlight */
mark {
  background: #fef08a;
  color: #0f172a;
  padding: 0 2px;
  border-radius: 3px;
}

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

.toast {
  background: #0f172a;
  color: #fff;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.2s ease;
}

.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
.toast.warn { background: #b45309; }

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

.mobile-only { display: none; }

/* Responsive Mobile Layout */
@media (max-width: 860px) {
  .mobile-only { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    box-shadow: var(--shadow-lg);
    width: min(290px, 85vw);
  }

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

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 35;
  }

  .main-content { padding: 14px 12px 36px; }
  .topbar-right { width: 100%; }
  .search-box { flex: 1; min-width: 0; }
  .filter-controls { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }

  .quick-add-bar { flex-wrap: wrap; }
  .quick-input { flex: 1 1 80%; }
  .quick-add-controls { width: 100%; justify-content: flex-end; }

  .markdown-workspace { grid-template-columns: 1fr; }
  .notes-workspace { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: 1fr; }

  .task-quick-actions { display: none; }
  .task-mobile-more-wrap { display: flex; align-items: center; }
  .task-thumbs-strip, .inline-thought-panel { margin-left: 0; padding-left: 0; }
}
