#goals-section {
  flex-shrink: 0;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10), 0 1px 2px rgba(0, 0, 0, 0.06);
  margin: 0 0 4px 0;
}

#goals-container {
  flex: 1;
  padding: 8px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.placeholder {
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

/* === Goals Progress Bar (in header) === */
#goals-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 100%;
  margin-left: 16px;
}

#goals-progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
}

#goals-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease, background 0.3s ease;
}

#goals-progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

/* === Goals Tree === */
.goals-toolbar {
  display: flex;
  gap: 4px;
}

#goals-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.goals-add-bottom {
  display: block;
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.goals-add-bottom:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.goal-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.goal-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ── Tree connection lines for nested goal-container structure ── */

/* Each goal-container provides padding-left for indentation.
   The goal-item inside has padding: 6px 8px, and the checkbox (18×18px)
   is the first flex child. Checkbox center X from container left edge:
     padding-left(container) + 8px(goal-item padding) + 9px(half checkbox) = padding-left + 17px
   level-0: 8px  → center = 25px
   level-1: 40px → center = 57px
   level-2: 72px → center = 89px
   level-3: 104px → center = 121px

   Each level-N container is nested inside goal-children of level-(N-1).
   goal-children starts at padding-left of parent container (no extra padding).
   So parent's checkbox center relative to child container is always:
     (padding-left(parent) + 17px) - padding-left(parent) = 17px
   Vertical line left = 17px for all levels > 0.
   Horizontal width = padding-left(container) (from 17px to checkbox center).
*/
.goal-container.level-0 { padding-left: 8px; }
.goal-container.level-1 { padding-left: 40px; }
.goal-container.level-2 { padding-left: 72px; }
.goal-container.level-3 { padding-left: 104px; }

/* Container is relative so pseudo-elements position correctly */
.goal-container {
  position: relative;
}

/* Children wrapper — needed so vertical line can pass through */
.goal-children {
  position: relative;
}

/* ── Vertical line: from parent's checkbox center, passing through all children ──
   ::before is on .goal-container (level > 0).
   For non-last: height 100% (through entire container including children).
   For last-child: height = 17px (stops at horizontal elbow, no continuation). */
.goal-container.level-1::before,
.goal-container.level-2::before,
.goal-container.level-3::before {
  content: '';
  position: absolute;
  top: 0;
  left: 17px; /* parent checkbox center relative to this container */
  width: 2px;
  background: var(--border, rgba(128, 128, 128, 0.3));
  pointer-events: none;
}

/* Non-last: vertical line goes full height (through all children) */
.goal-container.level-1:not(.last-child)::before,
.goal-container.level-2:not(.last-child)::before,
.goal-container.level-3:not(.last-child)::before {
  height: 100%;
}

/* Last child: vertical line stops at horizontal elbow (checkbox center height) */
.goal-container.level-1.last-child::before,
.goal-container.level-2.last-child::before,
.goal-container.level-3.last-child::before {
  height: 17px; /* checkbox center Y = 6px padding-top + 2px margin-top + 9px radius */
}

/* ── Horizontal elbow: from parent's vertical line to own checkbox center ──
   ::after is on .goal-container (level > 0).
   Positioned at checkbox center Y (17px from top of container).
   Width equals padding-left (from 17px to checkbox center). */
.goal-container.level-1::after,
.goal-container.level-2::after,
.goal-container.level-3::after {
  content: '';
  position: absolute;
  top: 16px; /* checkbox center Y = 17px - 1px half-height */
  left: 17px; /* parent checkbox center relative to this container */
  height: 2px;
  background: var(--border, rgba(128, 128, 128, 0.3));
  pointer-events: none;
}

.goal-container.level-1::after { width: 40px; } /* padding-left of level-1 */
.goal-container.level-2::after { width: 72px; } /* padding-left of level-2 */
.goal-container.level-3::after { width: 104px; } /* padding-left of level-3 */

.goal-number {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 22px;
  text-align: right;
  margin-right: 6px;
  margin-top: 2px;
  line-height: 18px;
  user-select: none;
  opacity: 0.7;
}

.goal-checkbox {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-secondary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  transition: all 0.15s;
  background: none;
  color: transparent;
  font-size: 10px;
}

.goal-checkbox:hover {
  border-color: var(--accent);
}

.goal-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.goal-title {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
  min-height: 20px;
  color: var(--text-primary);
  border: none;
  background: transparent;
  font-family: inherit;
  padding: 0;
}

.goal-title:focus {
  border-bottom: 1px solid var(--accent);
}

.goal-item.completed .goal-title {
  text-decoration: line-through;
  color: var(--text-secondary);
}

.goal-delete-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: all 0.15s;
}

.goal-item:hover .goal-delete-btn {
  opacity: 1;
}

.goal-delete-btn:hover {
  color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

.goal-add-sub {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: all 0.15s;
}

.goal-item:hover .goal-add-sub {
  opacity: 1;
}

.goal-add-sub:hover {
  color: var(--success);
  background: rgba(76, 175, 80, 0.1);
}

/* === Drag and Drop === */
.goal-item.dragging { opacity: 0.5; }
.goal-item.drag-over { border: 2px dashed var(--success) !important; }

/* === Goal Deadline === */
.goal-deadline {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--accent, #e74c3c);
  background: rgba(233, 69, 96, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  white-space: nowrap;
  cursor: default;
}

/* === Goal Menu Button === */
.goal-menu-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0;
  transition: all 0.15s;
  line-height: 1;
}

.goal-item:hover .goal-menu-btn {
  opacity: 1;
}

.goal-menu-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* === Goal Menu Popup === */
.goal-menu-popup {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--bg-secondary, #1e1e2e);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 1000;
  min-width: 200px;
  padding: 4px 0;
}

.goal-item { position: relative; }

.goal-menu-popup.hidden { display: none; }

.goal-menu-item {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background 0.12s;
  white-space: nowrap;
}

.goal-menu-item:hover {
  background: var(--bg-hover, rgba(255,255,255,0.05));
}

.goal-menu-item-danger {
  color: var(--accent, #e74c3c);
}

.goal-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.goal-deadline-input-wrap {
  padding: 6px 0 0 0;
}

.goal-deadline-input {
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 100%;
  box-sizing: border-box;
}

/* === Calendar Goal Star === */
.calendar-goal-star {
  pointer-events: none;
}
