/* ===========================================================================
   Task Chains Manager — layout & navigation
   Vanilla CSS, no build step. CSS variables drive light/dark themes.
   =========================================================================== */

:root {
  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --bg-sidebar: #fafbfc;
  --bg-hover: #eef0f3;
  --bg-active: #e3ecff;
  --border: #e2e5ea;
  --text: #1c2024;
  --text-muted: #6b7280;
  --accent: #3b6ef5;
  --accent-contrast: #ffffff;
  --danger: #d6453d;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
  --radius: 8px;
  --radius-sm: 6px;
  --topbar-h: 52px;
  --sidebar-w: 320px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --radius-md: 8px;
  --color-border: var(--border);
  --color-bg-secondary: var(--bg-sidebar);
  --color-primary: var(--accent);
  --color-text: var(--text);
  --color-text-muted: var(--text-muted);
  --color-text-inverse: var(--accent-contrast);
  --color-success: #1a7f37;
  --color-warning: #b45309;
  --color-danger: var(--danger);
  --calendar-slot-height: 40px;
}

[data-theme="dark"] {
  --bg: #15171c;
  --bg-elevated: #1e2128;
  --bg-sidebar: #1a1d23;
  --bg-hover: #262a32;
  --bg-active: #2a3a5e;
  --border: #2c3038;
  --text: #e6e8ec;
  --text-muted: #9aa1ad;
  --accent: #5b8bff;
  --accent-contrast: #0d1014;
  --danger: #f06a62;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.top-bar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 10;
}

.top-bar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-bar__logo {
  color: var(--accent);
  display: inline-flex;
}

.top-bar__title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.2px;
}

.top-bar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view-toggle {
  display: inline-flex;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-toggle__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

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

.view-toggle__btn.is-active {
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.app-version {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-radius: 8px;
  padding: 1px 7px;
  margin-left: 6px;
}

.api-status {
  margin-top: 8px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-muted);
}
.api-status.is-ok {
  color: #1a7f37;
  background: #e6f4ea;
}
.api-status.is-error {
  color: var(--danger);
  background: #fdecea;
  white-space: pre-wrap;
  word-break: break-word;
}

.diag-banner {
  margin: 0 0 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.diag-banner.is-ok {
  color: #1a7f37;
  background: #e6f4ea;
}
.diag-banner.is-error {
  color: #fff;
  background: var(--danger);
}

.icon-moon {
  display: none;
}
[data-theme="dark"] .icon-sun {
  display: none;
}
[data-theme="dark"] .icon-moon {
  display: inline;
}

.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
}

/* When TickTick mode is active, its section spans full width */
.layout.tt-mode {
  grid-template-columns: 1fr;
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  min-height: 0;
}

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

.sidebar__heading {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 0;
  font-weight: 600;
}

.sidebar__subheading {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 16px 0 8px;
  font-weight: 600;
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s ease;
}

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

.project-item.is-selected {
  background: var(--bg-active);
  border-color: var(--accent);
}

.project-item__swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.project-item__title {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-item__count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-radius: 10px;
  padding: 1px 7px;
}

.task-tree-wrap {
  margin-top: 4px;
}

.task-tree,
.task-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.task-tree ul {
  margin-left: 14px;
  border-left: 1px dashed var(--border);
  padding-left: 6px;
}

.task-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease;
}

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

.task-node.is-selected {
  background: var(--bg-active);
  outline: 1px solid var(--accent);
}

.task-node__toggle {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 3px;
  user-select: none;
}

.task-node__toggle:hover {
  background: var(--bg-active);
  color: var(--text);
}

.task-node__toggle.is-leaf {
  visibility: hidden;
}

.task-node__title {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-node__badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0 4px;
}

.task-node__status {
  font-size: 10px;
  color: var(--text-muted);
}

.task-tree__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 8px;
}

.task-tree__header .sidebar__subheading {
  margin: 0;
}

.task-tree__actions {
  display: flex;
  gap: 6px;
}

.task-tree__actions .icon-btn {
  width: 26px;
  height: 26px;
}

.task-tree__actions .icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--border);
}

.task-tree__actions .icon-btn:disabled:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
}

.task-node__actions {
  display: inline-flex;
  gap: 2px;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.task-node:hover .task-node__actions,
.task-node.is-selected .task-node__actions {
  opacity: 1;
}

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

.task-node__btn:hover {
  background: var(--bg-active);
  color: var(--text);
}

.task-node__btn--danger:hover {
  background: var(--danger);
  color: #fff;
}

.task-node__edit-input {
  flex: 1 1 auto;
  font: inherit;
  font-size: 13px;
  padding: 2px 6px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text);
  outline: none;
  min-width: 0;
}

.workspace {
  padding: 20px;
  overflow-y: auto;
  min-height: 0;
}

.detail-panel {
  max-width: 820px;
  margin: 0 auto;
}

.detail-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.detail-card__title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
}

.detail-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 12px;
}

.detail-card__section {
  margin-top: 16px;
}

.detail-card__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-card__value {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-card__note {
  margin-top: 18px;
  padding: 10px 12px;
  background: var(--bg-hover);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 10px;
  color: var(--text);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 48px 16px;
  height: 100%;
}

.empty-state p {
  margin: 0;
}

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 80vw;
  z-index: 50;
}

.toast.is-info {
  background: var(--text);
}

/* ===========================================================================
   Mobile / iPhone — safe areas, touch targets, responsive layout
   =========================================================================== */

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* ---------- Task Chains mobile ---------- */
@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 40%) 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

/* ---------- Global mobile ---------- */
@media (max-width: 768px) {
  /* Top bar */
  .top-bar {
    padding: 0 10px;
    padding-top: var(--sat);
    height: calc(var(--topbar-h) + var(--sat));
    gap: 4px;
  }
  .top-bar__title {
    font-size: 14px;
  }
  .mode-switcher__btn {
    padding: 5px 10px;
    font-size: 12px;
  }
  .view-toggle__btn {
    padding: 4px 8px;
    font-size: 11px;
  }

  /* TickTick shell — stack sidebar below main */
  .ticktick-shell {
    flex-direction: column;
  }
  .ticktick-sidebar {
    flex-direction: row;
    width: 100% !important;
    min-width: 0;
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    padding: 6px 8px;
    overflow-x: auto;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
  }
  .ticktick-sidebar .sidebar__subheading {
    display: none;
  }
  .ticktick-sidebar .project-list {
    flex-direction: row;
    gap: 4px;
    width: auto;
    flex-shrink: 0;
  }
  .ticktick-sidebar .domain-item {
    min-width: 0;
    width: auto;
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 12px;
  }

  .ticktick-main {
    min-width: 0;
    flex: 1 1 0;
    overflow: hidden;
  }

  /* Right panel — hide on mobile */
  .ticktick-right-panel {
    display: none !important;
  }

  /* Search */
  .search__input {
    width: 150px;
    max-width: 50vw;
    font-size: 13px;
    padding: 8px 10px;
  }

  /* Modal — full screen on mobile */
  .modal-overlay {
    padding: 0 !important;
    align-items: flex-end !important;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    margin-bottom: var(--sab);
  }

  /* Touch-friendly targets: minimum 44px */
  .icon-btn,
  button,
  .domain-item,
  .tt-nav-item,
  .task-row,
  .task-card {
    min-height: 44px;
  }

  /* Canvas: hide on tiny screens, show list */
  canvas {
    max-width: 100%;
    height: auto !important;
  }

  /* Kanban columns */
  .kanban-columns {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--sab);
  }
  .kanban-column {
    min-width: 260px;
  }

  /* Calendar canvas scroll */
  .calendar-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Task detail */
  .detail-panel {
    padding: 12px;
  }

  /* Graph view */
  .graph-view {
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    padding-top: var(--sat);
  }
}

/* ---------- iPhone notch / Dynamic Island ---------- */
@supports (padding-top: env(safe-area-inset-top)) {
  body {
    padding-top: env(safe-area-inset-top);
  }
  .ticktick-shell {
    height: calc(100vh - var(--topbar-h) - env(safe-area-inset-top));
  }
  .modal {
    margin-bottom: env(safe-area-inset-bottom);
  }
}

/* ---------- Very small screens (SE, mini) ---------- */
@media (max-width: 380px) {
  .top-bar__title {
    display: none;
  }
  .mode-switcher__btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  .view-toggle__btn span:not(.view-toggle__icon) {
    display: none;
  }
  .ticktick-sidebar .domain-item {
    padding: 4px 6px;
    font-size: 11px;
  }
}

/* ---------- Touch device tweaks ---------- */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets */
  .icon-btn {
    width: 44px;
    height: 44px;
  }
  /* Disable hover effects on touch */
  .task-card:hover,
  .domain-item:hover,
  .task-row:hover {
    background: unset;
  }
}

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

.search__input {
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  width: 240px;
  max-width: 40vw;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  outline: none;
}

.search__input:focus {
  border-color: var(--accent);
}

.search__results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 260px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 20;
  padding: 4px;
}

.search__result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
}

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

.search__result-title {
  font-size: 13px;
}

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

.search__empty {
  padding: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.chip--tag {
  background: rgba(214, 69, 61, 0.12);
  border-color: var(--danger);
  color: var(--danger);
}

.chip--keyword {
  background: rgba(59, 110, 245, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.chip__remove {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 0 0 0 4px;
  margin-left: 2px;
  opacity: 0.7;
}

.chip__remove:hover {
  opacity: 1;
}

.chip-input {
  font: inherit;
  font-size: 13px;
  margin-top: 8px;
  padding: 5px 8px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  outline: none;
}

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

.detail-card__section.is-warning {
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.start-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
}

.start-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.start-toggle__label {
  font-size: 13px;
}

.start-warning {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
  background: rgba(214, 69, 61, 0.08);
  font-size: 12px;
}

.goal-card {
  background: linear-gradient(135deg, rgba(59, 110, 245, 0.10), rgba(59, 110, 245, 0.04));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 auto 16px;
  max-width: 820px;
  box-shadow: var(--shadow);
}

.goal-card__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  margin-bottom: 6px;
  font-weight: 600;
}

.goal-card__textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  outline: none;
  resize: vertical;
}

.goal-card__textarea:focus {
  border-color: var(--accent);
}

.plan-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin: 16px auto 0;
  max-width: 820px;
}

.plan-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.plan-card__count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-radius: 10px;
  padding: 2px 8px;
}

.plan-card__done {
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  background: rgba(59, 110, 245, 0.10);
  font-size: 13px;
  font-weight: 600;
}

.progress {
  width: 100%;
  height: 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.plan-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plan-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: 1px solid transparent;
}

.plan-step:hover {
  border-color: var(--border);
}

.plan-step__check {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}

.plan-step__text {
  flex: 1 1 auto;
  cursor: text;
  word-break: break-word;
}

.plan-step__text.is-done {
  text-decoration: line-through;
  color: var(--text-muted);
}

.plan-step__edit-input {
  flex: 1 1 auto;
  font: inherit;
  font-size: 13px;
  padding: 2px 6px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text);
  outline: none;
  min-width: 0;
}

.plan-step__delete {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  flex: 0 0 auto;
}

.plan-step__delete:hover {
  background: var(--danger);
  color: #fff;
}

.plan-add-input {
  font: inherit;
  font-size: 13px;
  margin-top: 10px;
  padding: 6px 10px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  outline: none;
}

.plan-add-input:focus {
  border-color: var(--accent);
}

/* CRITICAL: [hidden] must win over any display rule */
[hidden] {
  display: none !important;
  pointer-events: none;
}

.graph-view {
  position: absolute;
  inset: var(--topbar-h) 0 0 0;
  background: var(--bg);
  display: flex;
  overflow: auto;
  z-index: 5;
}

.graph-canvas {
  position: relative;
  flex: 1 1 auto;
  min-width: 100%;
  min-height: 100%;
}

.graph-svg-wrap {
  display: block;
}

.graph-svg {
  display: block;
  font-family: var(--font);
}

.graph-edge {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.5;
}

.graph-edge--plan {
  stroke: var(--accent);
  stroke-dasharray: 4 3;
  stroke-width: 1.25;
  opacity: 0.8;
}

.graph-arrow {
  fill: var(--text-muted);
}

.graph-node {
  cursor: pointer;
  outline: none;
}

.graph-node__rect {
  fill: var(--bg-elevated);
  stroke: var(--border);
  stroke-width: 1.5;
  transition: stroke 0.12s ease, fill 0.12s ease;
}

.graph-node__text {
  fill: var(--text);
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
}

.graph-node:hover .graph-node__rect {
  stroke: var(--accent);
}

.graph-node:focus .graph-node__rect {
  stroke: var(--accent);
  stroke-width: 2;
}

.graph-node.is-selected .graph-node__rect {
  stroke: var(--accent);
  stroke-width: 2.5;
  fill: var(--bg-active);
}

.graph-node--task.is-start .graph-node__rect {
  stroke: var(--accent);
  stroke-width: 2.5;
  fill: rgba(59, 110, 245, 0.14);
}

.graph-node__badge {
  fill: var(--accent);
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
}

.graph-node__goal {
  fill: var(--text-muted);
  font-size: 10px;
  font-style: italic;
  pointer-events: none;
}

.graph-node--step .graph-node__rect {
  fill: var(--bg-hover);
  stroke: var(--accent);
  stroke-dasharray: 3 2;
  stroke-width: 1;
}

.graph-node--step .graph-node__text {
  font-size: 11px;
  fill: var(--text-muted);
}

.graph-node--step.is-done .graph-node__rect {
  fill: rgba(59, 110, 245, 0.10);
}

.graph-node--step.is-done .graph-node__text {
  text-decoration: line-through;
  fill: var(--text-muted);
}

.graph-popover {
  position: absolute;
  z-index: 10;
  min-width: 200px;
  max-width: 280px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  transform: translateX(-50%);
}

.graph-popover__title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.graph-popover__meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.graph-popover__goal {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
  word-break: break-word;
}

.graph-popover__btn {
  font: inherit;
  font-size: 12px;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.graph-popover__btn:hover {
  filter: brightness(1.05);
}

/* ===========================================================================
   TickTick shell — sidebar + main layout
   =========================================================================== */

.ticktick-shell {
  display: flex;
  width: 100%;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.ticktick-sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 8px;
  flex-shrink: 0;
}

.ticktick-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ticktick-right-panel {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 8px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ticktick-right-panel:empty {
  display: none;
}

.ticktick-right-panel.drag-over {
  border-left: 2px solid var(--accent, #5B6EF5);
  background: rgba(91, 110, 245, 0.05);
}

.ticktick-right-panel.drag-over .right-panel__heading {
  color: var(--accent, #5B6EF5);
}

.right-panel__heading {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 0 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.right-panel__domain {
  margin-bottom: 6px;
}

.right-panel__domain-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  cursor: default;
  user-select: none;
}

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

.right-panel__domain-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 1px 5px;
  border-radius: 8px;
}

.right-panel__task {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin: 1px 0 1px 14px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s ease;
  line-height: 1.3;
}

.right-panel__task:hover {
  background: var(--bg-hover);
}

.right-panel__task.dragging {
  opacity: 0.5;
  transform: scale(0.97);
}

.right-panel__task-check {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.right-panel__task-check:hover {
  border-color: var(--accent);
  background: rgba(59,110,245,0.1);
}

.right-panel__task-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.right-panel__priority {
  font-size: 10px;
  flex-shrink: 0;
}

.right-panel__empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 16px 8px;
  line-height: 1.5;
}

.right-panel__empty-icon {
  font-size: 24px;
  margin-bottom: 6px;
  opacity: 0.5;
}

.right-panel__divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2px 0;
}

/* --- Canvas horizontal scroll --- */
.canvas-body.canvas-scrollable {
  overflow-x: auto;
}

/* --- Compact month grid --- */
.month-week-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
}

.month-week-row.header-row {
  border-bottom: 2px solid var(--border);
  background: var(--bg-hover);
  position: sticky;
  top: 0;
  z-index: 2;
}

.month-week-row.header-row .month-day-header {
  padding: 6px 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
}

.month-week-row.header-row .month-day-header:last-child {
  border-right: none;
}

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

.month-compact-cell {
  position: relative;
  min-height: 72px;
  max-height: 100px;
  padding: 3px 4px;
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: background 0.1s ease;
}

.month-compact-cell:last-child {
  border-right: none;
}

.month-compact-cell.other-month {
  opacity: 0.3;
}

.month-compact-cell.today {
  background: var(--bg-active);
}

.month-compact-cell.drag-over {
  background: var(--bg-active) !important;
  border-color: var(--accent);
}

.month-compact-number {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 2px;
  line-height: 1;
}

.month-compact-cell.today .month-compact-number {
  color: var(--accent);
  font-weight: 700;
}

.month-compact-dots {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.month-compact-dot {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  line-height: 1.2;
  padding: 1px 3px;
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  cursor: grab;
}

.month-compact-dot:active {
  cursor: grabbing;
}

.month-compact-more {
  font-size: 9px;
  color: var(--text-muted);
  padding: 1px 3px;
  font-weight: 500;
}

.month-compact-cell.drag-over {
  background: var(--bg-active) !important;
  border-color: var(--accent);
  border-radius: var(--radius-sm);
}

/* ===========================================================================
   Calendar — views & drag-and-drop
   =========================================================================== */

.calendar-view {
  --calendar-slot-height: 40px;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#calendar-grid {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

/* --- Month View --- */
.month-day-header {
  padding: 6px 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.month-day-cell {
  position: relative;
  min-height: 80px;
  padding: 4px;
  border: 1px solid transparent;
  transition: background 0.1s ease, border-color 0.1s ease;
  overflow: hidden;
}

.month-day-cell.other-month {
  opacity: 0.4;
}

.month-day-cell.today {
  background: var(--bg-active);
}

.month-day-number {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 2px;
  color: var(--text-muted);
}

.month-day-cell.today .month-day-number {
  color: var(--accent);
  font-weight: 700;
}

.month-event {
  padding: 3px 6px;
  margin: 1px 0;
  border-radius: 4px;
  font-size: 11px;
  cursor: grab;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.1s ease;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.month-event:active {
  cursor: grabbing;
}

.month-event.dragging {
  opacity: 0.4;
  transform: scale(0.95);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.month-event:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 3;
}

.month-day-cell.drag-over {
  background: var(--bg-active) !important;
  border-color: var(--accent);
  border-radius: var(--radius-sm);
}

.month-task {
  padding: 2px 5px;
  margin: 1px 0;
  border-radius: 3px;
  font-size: 10px;
  cursor: grab;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  line-height: 1.3;
}

.month-task:active {
  cursor: grabbing;
}

.month-task.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.month-task:hover {
  filter: brightness(0.95);
  z-index: 3;
}

.month-task-time {
  font-weight: 600;
  font-size: 9px;
  opacity: 0.7;
}

/* --- Week View --- */
.week-event {
  position: absolute;
  left: 3px;
  right: 3px;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 11px;
  cursor: grab;
  user-select: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.1s ease;
  z-index: 1;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.week-event:active {
  cursor: grabbing;
}

.week-event.dragging {
  opacity: 0.4;
  transform: scale(0.96);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 10;
}

.week-event:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 5;
}

/* --- Day View --- */
.day-event {
  position: absolute;
  left: 3px;
  right: 3px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: grab;
  user-select: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.1s ease;
  z-index: 1;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.day-event:active {
  cursor: grabbing;
}

.day-event.dragging {
  opacity: 0.4;
  transform: scale(0.96);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  z-index: 10;
}

.day-event:hover {
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 5;
}

/* --- Time slots (shared Week / Day) --- */
.time-slot {
  position: relative;
  border-bottom: 1px solid var(--border);
  min-height: var(--calendar-slot-height);
  transition: background 0.1s ease;
}

.time-slot-label {
  position: absolute;
  top: -7px;
  left: 4px;
  font-size: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.time-slot.drag-over {
  background: var(--bg-active) !important;
  border: 2px dashed var(--accent);
}

/* --- Timeline View --- */
.timeline-header {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.timeline-bars {
  padding: 12px 16px;
}

.timeline-task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  cursor: grab;
  user-select: none;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
  border: 1px solid transparent;
}

.timeline-task-row:active {
  cursor: grabbing;
}

.timeline-task-row.dragging {
  opacity: 0.4;
  transform: scale(0.98);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.timeline-task-row.drag-over {
  background: var(--bg-active);
  border-color: var(--accent);
  border-style: dashed;
}

.timeline-task-label {
  width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  font-size: 13px;
}

.timeline-bar-container {
  flex: 1;
  position: relative;
  height: 28px;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow: hidden;
}

.timeline-bar {
  position: absolute;
  height: 100%;
  border-radius: 4px;
  transition: width 0.15s ease;
}

.timeline-bar-resize {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  background: transparent;
}

.timeline-bar-resize:hover {
  background: rgba(255,255,255,0.3);
}

/* --- Task item (draggable from task list to calendar) --- */
.task-item[draggable="true"] {
  cursor: grab;
  transition: transform 0.1s ease, opacity 0.1s ease, box-shadow 0.1s ease;
}

.task-item[draggable="true"]:active {
  cursor: grabbing;
}

.task-item[draggable="true"].dragging {
  opacity: 0.4;
  transform: scale(0.98);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* --- Calendar header buttons --- */
.calendar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 3;
}

/* ── Canvas zoom controls ── */
.canvas-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--bg-surface, rgba(255,255,255,0.06));
  border: 1px solid var(--border);
}

.zoom-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.zoom-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

.zoom-label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 36px;
  text-align: center;
  user-select: none;
  font-variant-numeric: tabular-nums;
}

/* --- Task Canvas (Tasks view) --- */
.task-canvas {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.task-canvas .calendar-grid {
  flex: 1;
  overflow-y: auto;
}

.task-canvas.timeline-mode .calendar-grid {
  overflow-x: auto;
  overflow-y: hidden;
}

.task-tree-section {
  padding: 8px 0;
}

.task-tree-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 43px;
  padding: 0 16px;
  border-top: 3px solid var(--accent, #3b82f6);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.task-tree-title {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.task-tree-count {
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-hover, #eef0f3);
  color: var(--text-muted, #6b7280);
  font-size: 12px;
  text-align: center;
}

.task-tree-root-drop {
  min-height: 112px;
  padding: 8px;
  transition: background 0.15s ease, outline-color 0.15s ease;
}

.task-tree-root-drop.task-tree-root-drop-active {
  background: rgba(59, 110, 245, 0.06);
  outline: 2px dashed var(--accent, #3b6ef5);
  outline-offset: -4px;
}

.task-tree-item {
  margin-left: calc(var(--task-depth) * 24px);
  border-left: 2px solid var(--border);
}

.task-tree-toggle,
.task-tree-spacer {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
}

.task-tree-toggle {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.task-tree-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.task-tree-spacer {
  display: inline-block;
}

.task-item-drop-target {
  background: rgba(59, 110, 245, 0.15);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  border-left-color: var(--accent, #3b6ef5);
  outline: 1px dashed var(--accent, #3b6ef5);
  outline-offset: -1px;
}

.calendar-view-switcher {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.cal-view-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.12s ease, color 0.12s ease;
}

.cal-view-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.cal-view-btn.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.btn-today {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.12s ease;
}

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

/* ===========================================================================
   Canvas 3-Day View — Google Calendar–style
   =========================================================================== */

/* Flex column layout for the canvas view */

/* --- Header (day names + dates) --- */
.canvas-header {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 4;
  flex-shrink: 0;
}

.canvas-time-gutter-header {
  width: 56px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

.canvas-day-header {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-right: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.canvas-day-header:last-child {
  border-right: none;
}

.canvas-day-dow {
  display: block;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
}

.canvas-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 600;
  margin-top: 2px;
}

.canvas-day-header.today .canvas-day-dow {
  color: var(--accent);
  font-weight: 700;
}

.canvas-day-num.today-num {
  background: var(--accent);
  color: var(--accent-contrast) !important;
}

/* --- All-day row --- */
.canvas-allday-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  min-height: 32px;
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.canvas-allday-label {
  width: 56px;
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
}

.canvas-allday-cell {
  flex: 1;
  padding: 2px;
  border-right: 1px solid var(--border);
  min-height: 28px;
}

.canvas-allday-cell:last-child {
  border-right: none;
}

.canvas-allday-task {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
  cursor: grab;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
}

/* --- Body (time gutter + day columns) --- */
.canvas-body {
  flex: 1;
  display: flex;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  min-height: 0;
}

.canvas-time-gutter {
  width: 56px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  position: relative;
}

.canvas-hour-label {
  position: relative;
  border-bottom: 1px solid var(--border);
}

.canvas-hour-label span {
  position: absolute;
  top: -7px;
  right: 6px;
  font-size: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.canvas-day-col {
  flex: 1;
  position: relative;
  border-right: 1px solid var(--border);
}

.canvas-day-col:last-child {
  border-right: none;
}

.canvas-day-col.today-col {
  background: rgba(59, 110, 245, 0.04);
}

.canvas-hour-slot {
  border-bottom: 1px solid var(--border);
  position: relative;
  cursor: crosshair;
}

.canvas-hour-slot::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-bottom: 1px dashed var(--border);
  opacity: 0.3;
}

.canvas-hour-slot:hover {
  background: rgba(100, 149, 237, 0.06);
}

/* --- Task blocks --- */
.canvas-task-block {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: 6px;
  color: #fff;
  overflow: hidden;
  z-index: 2;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: box-shadow 0.15s ease, opacity 0.15s ease;
  user-select: none;
}

.canvas-task-block:hover {
  box-shadow: 0 3px 8px rgba(0,0,0,0.28);
  z-index: 3;
}

.canvas-task-block:active {
  cursor: grabbing;
}

.canvas-task-block.resizing {
  opacity: 0.85;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  z-index: 10;
  cursor: ns-resize;
}

.canvas-task-block.canvas-block-placeholder {
  opacity: 0.25;
  pointer-events: none;
}

.canvas-task-block.dragging {
  opacity: 0.4;
  transform: scale(0.97);
  z-index: 10;
}

/* Overlap indicator — red border on overlapping tasks */
.canvas-task-block.overlap {
  outline: 2px solid #ef4444;
  outline-offset: -1px;
  z-index: 5;
}
.canvas-task-block.overlap:hover {
  outline-width: 3px;
  z-index: 6;
}

/* Overlap labels — show task titles for overlapping blocks */
.canvas-overlap-label {
  position: absolute;
  bottom: 2px;
  left: 4px;
  right: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  pointer-events: none;
  z-index: 10;
}

.canvas-overlap-title {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(2px);
}

.canvas-overlap-many {
  flex-direction: column;
  gap: 3px;
}

.canvas-overlap-count {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #ef4444;
  background: rgba(0, 0, 0, 0.55);
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.3;
  backdrop-filter: blur(2px);
}

/* Block inner layout */
.canvas-block-content {
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
  overflow: hidden;
  cursor: pointer;
}

.canvas-block-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.canvas-block-time {
  font-size: 10px;
  opacity: 0.85;
  white-space: nowrap;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

/* Resize handles */
.canvas-block-resize-top,
.canvas-block-resize-bottom {
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  z-index: 5;
}

.canvas-block-resize-top {
  top: 0;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}

.canvas-block-resize-bottom {
  bottom: 0;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

.canvas-block-resize-top:hover,
.canvas-block-resize-bottom:hover {
  background: rgba(255,255,255,0.2);
}

/* ===========================================================================
   Modal — draggable centered overlay
   =========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
.modal-overlay[hidden] {
  display: none !important;
}
.modal {
  background: var(--bg-elevated, #1e1e2e);
  border: 1px solid var(--border, #333);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.25);
  min-width: 360px;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border, #333);
  cursor: grab;
  user-select: none;
  background: var(--bg-elevated, #1e1e2e);
  flex-shrink: 0;
}
.modal__header:active {
  cursor: grabbing;
}
.modal__header span {
  font-size: 15px;
  font-weight: 600;
  color: var(--text, #eee);
}
.modal__close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted, #888);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
}
.modal__close:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text, #eee);
}
.modal__body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}
.modal__footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border, #333);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg-elevated, #1e1e2e);
}
/* Task form fields inside modal */
.task-form, .task-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.task-input, .task-textarea, .task-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--bg, #12121e);
  color: var(--text, #eee);
  font-size: 13px;
  box-sizing: border-box;
}
.task-input:focus, .task-textarea:focus, .task-select:focus {
  outline: none;
  border-color: var(--accent, #3b82f6);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.25);
}
.task-textarea {
  resize: vertical;
  min-height: 60px;
}
.field-row {
  display: flex;
  gap: 10px;
}
.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.btn {
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border, #333);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-primary {
  background: var(--accent, #3b82f6);
  color: #fff;
  border-color: var(--accent, #3b82f6);
}
.btn-primary:hover {
  filter: brightness(1.1);
}
.btn-ghost {
  background: transparent;
  color: var(--text, #eee);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.08);
}

/* --- Checklist --- */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.checklist-item:hover {
  background: rgba(255,255,255,0.06);
  border-color: var(--border, #333);
}
.checklist-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #3b82f6);
  flex-shrink: 0;
  cursor: pointer;
}
.checklist-text {
  flex: 1;
  font-size: 13px;
  color: var(--text, #eee);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.checklist-text.done {
  text-decoration: line-through;
  opacity: 0.5;
}
.checklist-delete {
  background: none;
  border: none;
  color: var(--text-muted, #888);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s;
}
.checklist-item:hover .checklist-delete {
  opacity: 1;
}
.checklist-delete:hover {
  color: #ef4444;
  background: rgba(239,68,68,0.1);
}
.task-checklist {
  font-size: 11px;
  color: var(--text-muted, #888);
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Drag ghost */
.canvas-drag-ghost {
  border-radius: 6px;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  z-index: 1000 !important;
}

/* Drop target highlight */
.canvas-day-col.drop-target {
  background: rgba(59, 110, 245, 0.06);
}

.canvas-day-col.drag-over {
  background: rgba(59, 110, 245, 0.10);
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* Now indicator */
.canvas-now-indicator {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #ef4444;
  z-index: 3;
  pointer-events: none;
}

.canvas-now-indicator::before {
  content: '';
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  background: #ef4444;
  border-radius: 50%;
}

/* ──────────────────────────────────────────────
   Kanban Board
   ────────────────────────────────────────────── */

.kanban-board {
  display: flex;
  gap: 12px;
  height: 100%;
  min-height: 400px;
  padding: 8px 0;
  overflow-x: auto;
}

.kanban-column {
  flex: 1;
  min-width: 250px;
  max-width: 400px;
  background: var(--bg, #f5f6f8);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  border-top: 3px solid #6b7280;
  background: var(--bg-elevated, #fff);
  border-radius: 8px 8px 0 0;
}

.kanban-column-icon {
  font-size: 16px;
}

.kanban-column-title {
  flex: 1;
  text-transform: capitalize;
}

.kanban-column-count {
  font-size: 12px;
  background: var(--bg-hover, #eef0f3);
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--text-muted, #6b7280);
  font-weight: 500;
}

.kanban-column-body {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 100px;
  transition: background 0.15s;
}

.kanban-column-body.drag-over {
  background: rgba(59, 110, 245, 0.06);
  outline: 2px dashed var(--accent, #3b6ef5);
  outline-offset: -2px;
  border-radius: 4px;
}

.kanban-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-muted, #6b7280);
  font-size: 13px;
  font-style: italic;
  border: 2px dashed var(--border, #e2e5ea);
  border-radius: 6px;
}

.kanban-card {
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--border, #e2e5ea);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: grab;
  transition: box-shadow 0.15s, transform 0.1s;
  user-select: none;
}

.kanban-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.kanban-card:active {
  cursor: grabbing;
  transform: scale(1.02);
}

.kanban-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.kanban-card-enter {
  animation: kanban-card-enter 180ms ease-out;
}

@keyframes kanban-card-enter {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.kanban-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #1c2024);
  margin-bottom: 4px;
  line-height: 1.3;
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted, #6b7280);
  flex-wrap: wrap;
}

.kanban-card-domain {
  font-size: 11px;
}

.kanban-card-due {
  font-size: 11px;
  color: var(--text-muted, #6b7280);
  margin-top: 4px;
}

/* ===========================================================================
   Timeline Domain Tracks — horizontal tracks by domain
   =========================================================================== */

.timeline-domain-tracks {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.timeline-axis {
  display: flex;
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  z-index: 2;
  min-height: 32px;
}

.timeline-axis-day {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0;
  border-right: 1px solid var(--border);
}

.timeline-axis-day:last-child {
  border-right: none;
}

.timeline-tracks-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-track {
  display: flex;
  min-height: 80px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.timeline-track-label {
  width: 100px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-hover);
  border-right: 1px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.timeline-track-content {
  flex: 1;
  position: relative;
  padding: 8px;
  overflow: hidden;
}

.timeline-root-task {
  position: absolute;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  cursor: grab;
  user-select: none;
  transition: opacity 0.1s ease;
  z-index: 2;
}

.timeline-root-task:active {
  cursor: grabbing;
}

.timeline-root-task.dragging {
  opacity: 0.4;
}

.timeline-root-task.timeline-task-highlighted {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  z-index: 3;
}

.timeline-task-title {
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-subtasks {
  position: absolute;
  left: 0;
  right: 0;
  height: 24px;
  top: 40px;
  pointer-events: none;
}

.timeline-subtask {
  position: absolute;
  height: 20px;
  border-radius: 3px;
  opacity: 0.7;
}

.timeline-subtask[title]::before {
  content: attr(title);
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  font-size: 8px;
  color: #fff;
  display: flex;
  align-items: center;
  padding-left: 4px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.timeline-subtask[title] {
  cursor: grab;
  pointer-events: auto;
}

.timeline-subtask[title]:active {
  cursor: grabbing;
}

.timeline-subtask-late {
  outline: 2px solid #ef4444;
  outline-offset: -1px;
}

/* Timeline range selector */
.timeline-range-selector {
  display: flex;
  gap: 4px;
  margin-left: 16px;
}

.range-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.range-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.range-btn.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

