:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Monaco, Consolas, monospace;

  /* Neutral Matte Dark (Linear / Things 3 style) */
  --bg-app: #0f1012;
  --bg-sidebar: #141519;
  --bg-surface: #17191e;
  --bg-hover: #1e2027;
  --bg-input: #111216;
  --bg-canvas: #0c0d10;
  --grid-dot: rgba(255, 255, 255, 0.08);

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  --text-primary: #eceef2;
  --text-secondary: #989ca6;
  --text-muted: #5d616b;

  --accent: #5e6ad2;
  --accent-hover: #6e79e0;
  --accent-soft: rgba(94, 106, 210, 0.14);
  --green: #22c55e;
  --amber: #eab308;
  --red: #ef4444;

  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.65);
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; color: inherit; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* App Shell: Left Sidebar + Main Surface */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.app-sidebar {
  width: 224px;
  min-width: 224px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 12px;
  gap: 12px;
}

.sb-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 4px;
}

.sb-brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.sb-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.sb-clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-muted);
}

.sb-search-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
}
.sb-search-btn:hover { border-color: var(--border-strong); color: var(--text-secondary); }
.sb-search-btn span { flex: 1; text-align: left; }

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.sb-nav, .sb-bottom {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sb-spacer { flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  font-weight: 600;
}
.nav-item svg { opacity: 0.72; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; color: var(--accent); }
.nav-item span:first-of-type { flex: 1; }

.nav-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--accent-soft);
  padding: 0 6px;
  border-radius: 99px;
  line-height: 17px;
}

.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}
.conn-dot.ok { background: var(--green); }

.sb-timer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
}
.sb-timer .timer-clock { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--accent-hover); }

/* Main Surface */
.main-surface {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--bg-app);
  position: relative;
  overflow: hidden;
}

.os-view {
  display: none;
  height: 100%;
  width: 100%;
  overflow: hidden;
}
.os-view.active { display: flex; flex-direction: column; }

.page-container {
  flex: 1;
  overflow-y: auto;
  padding: 32px 44px 56px;
  max-width: 1220px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Shared Buttons & Inputs */
.btn-primary {
  padding: 6px 13px;
  border-radius: 7px;
  border: none;
  background: var(--text-primary);
  color: #0f1012;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary:hover { background: #ffffff; }

.btn-subtle {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn-subtle:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }

.btn-danger {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: transparent;
  color: var(--red);
  font-size: 12px;
  cursor: pointer;
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }

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

.icon-btn-sm {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn-sm:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn-sm.active { color: var(--amber); }
.icon-btn-sm.danger:hover { color: var(--red); }

.quiet-input, .quiet-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12.5px;
  outline: none;
  color: var(--text-primary);
}
.quiet-input:focus, .quiet-select:focus { border-color: var(--border-strong); }
.quiet-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.quiet-check input { accent-color: var(--accent); }

/* Page Header */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.page-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
}
.page-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Calm Notice Banner */
.notice-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-secondary);
}
.notice-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Up Next Strip (Clean, understated, zero gradients) */
.up-next-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
}
.up-next-info { min-width: 0; flex: 1; }
.up-next-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.up-next-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.up-next-reason {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.up-next-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Today 2-Column Layout */
.today-columns {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 40px;
  align-items: start;
}
.col-stack { display: flex; flex-direction: column; gap: 30px; min-width: 0; }

.work-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 42px;
  align-items: start;
}

.section-block { display: flex; flex-direction: column; gap: 10px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.section-head h2 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Clean List Rows (Generous spacing, full unwrapped titles) */
.clean-list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.list-row:last-child { border-bottom: none; }
.list-row.done .row-title { text-decoration: line-through; color: var(--text-muted); }

.study-card-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.study-card-row:last-child { border-bottom: none; }
.study-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.study-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.circle-chk {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #0f1012;
  flex-shrink: 0;
}
.circle-chk.checked { background: var(--green); border-color: var(--green); }

.row-main { flex: 1; min-width: 0; }
.row-title {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-primary);
  white-space: normal;
  word-break: break-word;
}
.row-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.row-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; font-size: 12px; color: var(--text-muted); padding-top: 1px; }

.hover-act {
  opacity: 0;
  transition: opacity 0.12s ease;
}
.list-row:hover .hover-act,
.study-card-row:hover .hover-act,
.time-row:hover .hover-act,
.mail-item:hover .hover-act,
.habit-pill:hover .hover-act,
.note-list-item:hover .hover-act {
  opacity: 1;
}

.habit-pill-del {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
}
.habit-pill-del:hover { color: var(--red); }

.note-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.note-list-meta { min-width: 0; flex: 1; }

.inline-quick-form {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.inline-quick-form input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 6px 2px;
  font-size: 13px;
  outline: none;
  color: var(--text-primary);
}
.inline-quick-form input:focus { border-bottom-color: var(--accent); }

/* Timeline Rows */
.time-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 9px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
}
.time-row:hover { background: rgba(255,255,255,0.02); }
.time-col {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-muted);
  width: 88px;
  flex-shrink: 0;
}
.time-row.is-now .time-col { color: var(--accent-hover); font-weight: 600; }

/* Habits Strip */
.habit-pills { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
.habit-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 7px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
}
.habit-pill:hover { border-color: var(--border-strong); color: var(--text-primary); }
.habit-pill.done { border-color: rgba(34, 197, 94, 0.4); color: var(--text-primary); }
.habit-pill .h-streak { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* Subtle 2px progress bar */
.thin-bar { width: 70px; height: 3px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; cursor: pointer; }
.thin-fill { height: 100%; background: var(--accent); }

/* Inbox 2-Pane */
.inbox-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 26px;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
}
.inbox-list-col {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-sidebar);
}
.inbox-col-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.inbox-filter-tabs { display: flex; gap: 4px; }
.tab-link {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
}
.tab-link.active { background: var(--bg-hover); color: var(--text-primary); font-weight: 500; }

.inbox-scroll { flex: 1; overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.mail-item {
  padding: 10px 12px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mail-item:hover { background: var(--bg-hover); }
.mail-item.active { background: var(--bg-hover); }
.mail-item-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); }
.mail-item.unread .mail-item-from { color: var(--text-primary); font-weight: 600; }
.mail-item.unread .mail-item-subj { color: var(--text-primary); font-weight: 600; }
.mail-item-subj { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-item-snip { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.inbox-reader-pane {
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
.mail-reader-head { padding-bottom: 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.mail-reader-head h2 { margin: 0; font-size: 19px; font-weight: 600; }
.mail-reader-meta { font-size: 12.5px; color: var(--text-secondary); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mail-actions-bar { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.mail-body-text { white-space: pre-wrap; line-height: 1.7; font-size: 13.5px; color: var(--text-primary); max-width: 700px; }

/* Notes Workspace */
.notes-workspace { flex: 1; display: flex; min-height: 0; }
.notes-list-col {
  width: 230px;
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
}
.notes-col-head { padding: 12px; display: flex; gap: 6px; border-bottom: 1px solid var(--border); }
.notes-col-head input { flex: 1; min-width: 0; }
.notes-col-scroll { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 16px; }
.notes-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.note-list-item { padding: 7px 9px; border-radius: 6px; cursor: pointer; }
.note-list-item:hover { background: var(--bg-hover); }
.note-list-item.active { background: var(--bg-hover); font-weight: 600; }
.note-item-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item-sub { font-size: 11px; color: var(--text-muted); }

.muted-heading { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; padding: 0 4px; }
.tags-cloud { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chip { border: 1px solid var(--border); background: transparent; color: var(--text-secondary); font-size: 11.5px; padding: 2px 8px; border-radius: 99px; cursor: pointer; }
.tag-chip.active { border-color: var(--accent); color: var(--text-primary); background: var(--accent-soft); }

.editor-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.empty-state { margin: auto; text-align: center; color: var(--text-muted); }
.editor-container { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.editor-topbar { padding: 9px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.editor-meta-left, .editor-mode-controls { display: flex; align-items: center; gap: 8px; }
.muted-meta { font-size: 11.5px; color: var(--text-muted); }

.segmented-sm,
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}
.seg-btn { border: none; background: transparent; color: var(--text-secondary); font-size: 12px; padding: 4px 10px; border-radius: 5px; cursor: pointer; font-weight: 500; }
.seg-btn:hover { color: var(--text-primary); }
.seg-btn.active { background: var(--bg-hover); color: var(--text-primary); font-weight: 600; }

.editor-title-area { padding: 20px 28px 10px; display: flex; flex-direction: column; gap: 6px; }
.note-title-input { width: 100%; border: none; outline: none; background: transparent; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.note-tags-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.note-tags-list { display: flex; gap: 5px; flex-wrap: wrap; }
.editable-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-secondary); background: var(--bg-surface); border: 1px solid var(--border); padding: 1px 8px; border-radius: 99px; }
.editable-tag button { border: none; background: transparent; color: inherit; cursor: pointer; padding: 0; }
.add-tag-input { border: none; background: transparent; outline: none; font-size: 12px; width: 70px; color: var(--text-muted); }

.editor-split-body { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.markdown-input-wrap { flex: 1; position: relative; display: flex; min-width: 0; }
.note-content-input { flex: 1; width: 100%; height: 100%; border: none; outline: none; resize: none; background: transparent; padding: 14px 28px; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; }
.note-preview { flex: 1; overflow-y: auto; padding: 14px 28px 48px; border-left: 1px solid var(--border); min-width: 0; }
.editor-split-body.mode-edit .note-preview { display: none; }
.editor-split-body.mode-preview .markdown-input-wrap { display: none; }
.editor-split-body.mode-preview .note-preview { border-left: none; max-width: 760px; margin: 0 auto; width: 100%; }

.autocomplete-popup { position: absolute; left: 28px; bottom: 16px; width: 260px; max-height: 190px; overflow-y: auto; background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 40; padding: 4px; }
.autocomplete-item { padding: 6px 10px; border-radius: 5px; cursor: pointer; display: flex; justify-content: space-between; font-size: 12.5px; }
.autocomplete-item:hover, .autocomplete-item.selected { background: var(--bg-hover); }

.right-inspector { width: 250px; border-left: 1px solid var(--border); background: var(--bg-sidebar); display: flex; flex-direction: column; }
.right-inspector.collapsed { display: none; }
.inspector-header { padding: 11px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; font-weight: 600; }
.inspector-scroll { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.link-cards-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.link-card-item { padding: 7px 9px; border-radius: 6px; background: var(--bg-surface); border: 1px solid var(--border); cursor: pointer; font-size: 12px; }
.link-card-item:hover { border-color: var(--border-strong); }
.link-card-snippet { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.empty-mini { font-size: 12px; color: var(--text-muted); }

/* Rendered Markdown */
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin-top: 1.2em; margin-bottom: 0.45em; font-weight: 600; }
.markdown-body h1 { font-size: 1.5em; }
.markdown-body p { margin: 0.6em 0; line-height: 1.7; }
.markdown-body code { font-family: var(--font-mono); font-size: 0.88em; background: var(--bg-surface); padding: 2px 5px; border-radius: 4px; }
.md-code-block { margin: 0.9em 0; border-radius: 7px; border: 1px solid var(--border); background: var(--bg-input); overflow: hidden; }
.md-code-header { display: flex; justify-content: space-between; padding: 4px 10px; background: var(--bg-surface); font-size: 11px; color: var(--text-muted); }
.md-code-block pre { margin: 0; padding: 12px; overflow-x: auto; font-family: var(--font-mono); font-size: 12px; }
.wiki-link { color: var(--accent-hover); text-decoration: none; border-bottom: 1px solid rgba(94, 106, 210, 0.35); }
.wiki-link.missing { color: var(--amber); border-bottom-style: dashed; }
.inline-tag { color: var(--text-secondary); background: var(--bg-surface); padding: 1px 6px; border-radius: 99px; font-size: 0.88em; cursor: pointer; }
.md-checklist { list-style: none; padding-left: 2px; }
.md-checklist li { display: flex; gap: 8px; align-items: flex-start; }
.md-checklist input { margin-top: 4px; accent-color: var(--accent); }
.md-checklist li.checked span { text-decoration: line-through; color: var(--text-muted); }
.md-callout { margin: 0.9em 0; padding: 10px 14px; border-radius: 7px; border: 1px solid var(--border); border-left: 3px solid var(--accent); background: var(--bg-surface); }
.md-callout-title { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 4px; }

/* Map (Canvas & Graph) */
.map-header { padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg-sidebar); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.map-tools-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.map-body { flex: 1; position: relative; min-height: 0; display: flex; }
.graph-canvas-wrap { flex: 1; position: relative; background: var(--bg-canvas); overflow: hidden; }
#knowledge-graph-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.graph-tooltip { position: absolute; pointer-events: none; background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: 6px 10px; font-size: 12px; }

.spatial-viewport { flex: 1; position: relative; overflow: hidden; background-color: var(--bg-canvas); background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px); background-size: 24px 24px; cursor: grab; user-select: none; }
.spatial-viewport.panning { cursor: grabbing; }
.spatial-world { position: absolute; top: 0; left: 0; width: 0; height: 0; transform-origin: 0 0; }
.spatial-edges-svg { position: absolute; top: -4000px; left: -4000px; width: 8000px; height: 8000px; overflow: visible; pointer-events: none; }
.spatial-edges-svg path.edge-hit { pointer-events: stroke; cursor: pointer; }
.spatial-cards-layer { position: absolute; top: 0; left: 0; }

.canvas-card { position: absolute; background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: 9px; display: flex; flex-direction: column; min-width: 180px; min-height: 90px; }
.canvas-card.selected { border-color: var(--accent); }
.canvas-card.type-group { background: rgba(255, 255, 255, 0.02); border: 1.5px dashed var(--border-strong); z-index: 0; }
.canvas-card.type-sticky { background: #1d1b14; border-color: rgba(234, 179, 8, 0.35); }
.canvas-card-header { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--border); cursor: move; font-size: 12.5px; font-weight: 600; }
.canvas-card.type-group .canvas-card-header { border-bottom: none; color: var(--text-secondary); }
.card-header-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-header-actions { display: flex; gap: 2px; opacity: 0.5; }
.canvas-card:hover .card-header-actions { opacity: 1; }
.card-act-btn { border: none; background: transparent; color: var(--text-secondary); cursor: pointer; }
.canvas-card-body { flex: 1; padding: 9px 11px; font-size: 12.5px; overflow-y: auto; color: var(--text-secondary); }
.canvas-card-body textarea { width: 100%; background: transparent; border: none; outline: none; resize: none; font-size: 12.5px; }
.card-port { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); opacity: 0; cursor: crosshair; z-index: 5; }
.canvas-card:hover .card-port { opacity: 1; }
.card-port.top { top: -5px; left: 50%; margin-left: -5px; }
.card-port.right { right: -5px; top: 50%; margin-top: -5px; }
.card-port.bottom { bottom: -5px; left: 50%; margin-left: -5px; }
.card-port.left { left: -5px; top: 50%; margin-top: -5px; }
.card-resize-handle { position: absolute; right: 2px; bottom: 2px; width: 10px; height: 10px; cursor: nwse-resize; }

/* Connections View */
.conn-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.conn-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.conn-card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.conn-card-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-secondary); }
.status-tag { font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 99px; background: var(--bg-hover); color: var(--text-muted); }
.status-tag.connected { color: var(--green); background: rgba(34, 197, 94, 0.12); }
.conn-form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.conn-form-row input { flex: 1; min-width: 200px; }
.help-steps { font-size: 12px; color: var(--text-muted); margin: 0; padding-left: 18px; line-height: 1.6; }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65); display: flex; align-items: flex-start; justify-content: center; padding-top: 9vh; z-index: 100; }
.command-palette { width: min(580px, 92vw); background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-lg); overflow: hidden; }
.cp-input-row { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.cp-input-row input { flex: 1; border: none; background: transparent; outline: none; font-size: 14.5px; }
.cp-results { list-style: none; margin: 0; padding: 6px; max-height: 340px; overflow-y: auto; }
.cp-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: 6px; cursor: pointer; }
.cp-item:hover, .cp-item.active { background: var(--bg-hover); }
.cp-item-title { font-size: 13px; font-weight: 500; }
.cp-item-sub { font-size: 11.5px; color: var(--text-muted); }
.cp-item-kind { font-size: 11px; color: var(--text-muted); }

.modal-card { width: min(500px, 92vw); background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-card-sm { width: min(400px, 92vw); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.modal-close { border: none; background: transparent; color: var(--text-muted); font-size: 19px; cursor: pointer; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-input, .modal-textarea, .modal-input-sm { width: 100%; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; outline: none; font-size: 13px; }
.modal-input:focus, .modal-textarea:focus { border-color: var(--border-strong); }
.qc-type-tabs { display: flex; gap: 2px; background: var(--bg-input); padding: 3px; border-radius: 7px; border: 1px solid var(--border); }
.qc-tab { flex: 1; padding: 5px; border: none; border-radius: 5px; background: transparent; color: var(--text-muted); font-size: 12px; cursor: pointer; }
.qc-tab.active { background: var(--bg-hover); color: var(--text-primary); font-weight: 500; }
.qc-extra-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.modal-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.np-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.np-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; }
.np-item:hover { background: var(--bg-hover); }
.vault-actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vault-action-btn { text-align: left; padding: 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg-input); cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.vault-action-btn:hover { border-color: var(--border-strong); }
.vault-action-btn strong { font-size: 12.5px; }
.vault-action-btn span { font-size: 11px; color: var(--text-muted); }
.modal-hr { border: none; border-top: 1px solid var(--border); width: 100%; }
.vault-danger-row { display: flex; justify-content: space-between; }
.muted-text { margin: 0; font-size: 12.5px; color: var(--text-secondary); }
.field-lbl { display: block; font-size: 11.5px; color: var(--text-secondary); margin-bottom: 4px; }
.field-lbl-row { display: flex; justify-content: space-between; align-items: center; }

.toast-container { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--bg-surface); border: 1px solid var(--border-strong); padding: 9px 14px; border-radius: 7px; box-shadow: var(--shadow-lg); font-size: 12.5px; display: flex; align-items: center; gap: 12px; }
.toast-undo { border: none; background: var(--accent-soft); color: var(--accent-hover); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 5px; cursor: pointer; }
.toast-undo:hover { background: var(--accent); color: #fff; }

@media (max-width: 960px) {
  .app-sidebar { width: 185px; min-width: 185px; }
  .today-columns, .work-grid { grid-template-columns: 1fr; }
  .inbox-shell { grid-template-columns: 1fr; }
  .page-container { padding: 20px; }
}

/* =========================================================
   NOTION + GOOGLE CALENDAR + GMAIL POWER FEATURES
   ========================================================= */

/* Calendar Month & Week Grids */
.cal-nav-group { display: inline-flex; align-items: center; gap: 4px; }
.cal-month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
}
.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.cal-day-cell {
  min-height: 108px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  background: var(--bg-app);
  transition: background 0.1s;
}
.cal-day-cell:hover { background: rgba(255,255,255,0.02); }
.cal-day-cell.other-month { opacity: 0.42; }
.cal-day-cell.is-today { background: rgba(94, 106, 210, 0.06); }
.cal-day-num {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  align-self: flex-start;
  padding: 1px 6px;
  border-radius: 99px;
}
.cal-day-cell.is-today .cal-day-num { background: var(--accent); color: #fff; font-weight: 600; }

.cal-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-surface);
  border-left: 2.5px solid var(--accent);
  font-size: 11px;
  color: var(--text-primary);
  cursor: pointer;
  overflow: hidden;
}
.cal-chip.cat-meeting { border-left-color: var(--amber); }
.cal-chip.cat-study { border-left-color: #38bdf8; }
.cal-chip.cat-personal { border-left-color: var(--green); }
.cal-chip-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.cal-chip:hover { background: var(--bg-hover); }

.cal-time-grid-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  max-height: 620px;
  background: var(--bg-app);
}
.cal-week-head {
  display: grid;
  grid-template-columns: 56px repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  position: sticky;
  top: 0;
  z-index: 4;
}
.cal-week-head.day-only { grid-template-columns: 56px 1fr; }
.cal-wh-cell {
  padding: 8px 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  border-left: 1px solid var(--border);
}
.cal-wh-cell.is-today { color: var(--accent-hover); font-weight: 600; }
.cal-week-body {
  display: grid;
  grid-template-columns: 56px repeat(7, minmax(0, 1fr));
  position: relative;
}
.cal-week-body.day-only { grid-template-columns: 56px 1fr; }
.cal-hours-col { display: flex; flex-direction: column; }
.cal-hour-lbl {
  height: 44px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  text-align: right;
  padding: 2px 8px 0 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.cal-day-col {
  position: relative;
  border-left: 1px solid var(--border);
}
.cal-slot {
  height: 44px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
}
.cal-slot:hover { background: rgba(255,255,255,0.025); }
.cal-grid-ev {
  position: absolute;
  left: 3px;
  right: 3px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 11px;
  overflow: hidden;
  cursor: pointer;
  z-index: 2;
}
.cal-grid-ev.cat-meeting { border-left-color: var(--amber); }
.cal-grid-ev.cat-study { border-left-color: #38bdf8; }
.cal-grid-ev.cat-personal { border-left-color: var(--green); }
.cal-grid-ev:hover { background: var(--bg-hover); z-index: 3; }

/* Kanban Board & Notion Table */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.kanban-col {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 280px;
}
.kanban-col.drag-over { border-color: var(--accent); background: rgba(94, 106, 210, 0.05); }
.kanban-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}
.kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: grab;
}
.kanban-card:hover { border-color: var(--border-strong); }
.kanban-card-title { font-size: 13px; color: var(--text-primary); line-height: 1.4; cursor: pointer; }
.kanban-card-foot { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text-muted); gap: 6px; }

.db-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  background: var(--bg-surface);
}
.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.db-table th, .db-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.db-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-sidebar);
}
.db-table tr:last-child td { border-bottom: none; }
.db-table tr:hover td { background: rgba(255,255,255,0.02); }

.subtask-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 2px 26px;
}
.subtask-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
}
.subtask-row.done span { text-decoration: line-through; color: var(--text-muted); }

/* Notes Notion Enhancements */
.note-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.bc-btn { border: none; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 12px; padding: 1px 4px; border-radius: 4px; }
.bc-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.note-icon-btn {
  border: none;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  line-height: 1;
}
.note-icon-btn:hover { background: var(--bg-hover); }
.editor-format-bar {
  padding: 5px 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}
.fmt-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
}
.fmt-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.md-toggle {
  margin: 0.7em 0;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
}
.md-toggle summary { cursor: pointer; font-weight: 500; color: var(--text-primary); }
.md-toggle-body { padding-top: 6px; padding-left: 14px; }
.md-table { width: 100%; border-collapse: collapse; margin: 0.9em 0; font-size: 12.5px; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md-table th { background: var(--bg-surface); }

/* Inbox Enhancements */
.mail-label-chip {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.inbox-bulk-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

/* Today Scratchpad */
.scratchpad-box {
  width: 100%;
  min-height: 95px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  color: var(--text-primary);
}
.scratchpad-box:focus { border-color: var(--border-strong); }

@media (max-width: 960px) {
  .kanban-board { grid-template-columns: 1fr; }
  .inbox-shell { padding: 14px; }
}

/* Dark Matte Checkboxes & Button Polish */
.inbox-shell input[type="checkbox"],
.work-section input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1px solid var(--border-strong, #353945);
  background: var(--bg-base, #0f1012);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  flex-shrink: 0;
}
.inbox-shell input[type="checkbox"]:checked,
.work-section input[type="checkbox"]:checked {
  background: var(--accent, #5e6ad2);
  border-color: var(--accent, #5e6ad2);
}
.inbox-shell input[type="checkbox"]:checked::after,
.work-section input[type="checkbox"]:checked::after {
  content: "✓";
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
}
.btn-sm {
  padding: 5px 10px !important;
  font-size: 12px !important;
}
