/* =====================
   RESET
   ===================== */

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

html, body {
  height: 100%;
}


/* =====================
   DARK THEME (default)
   ===================== */

:root {
  --bg:             #161920;
  --surface:        #1e2230;
  --surface-2:      #252a3a;
  --surface-hover:  #2a3045;
  --surface-active: #1c2438;

  --border:         #2c3350;
  --border-subtle:  #222840;

  --text:           #dde2f0;
  --text-dim:       #6b7494;
  --text-muted:     #3d4460;

  --accent:         #67c762;
  --accent-soft:    rgba(103, 199, 98, 0.10);
  --accent-border:  rgba(103, 199, 98, 0.22);

  --warning:        #f8da62;
  --warning-soft:   rgba(248, 218, 98, 0.10);

  --done-color:     #4a5270;
  --done-soft:      rgba(74, 82, 112, 0.18);

  --check-done:     #67c762;
  --check-open:     #3d4460;

  --heat-0:         rgba(255, 255, 255, 0.05);
  --heat-1:         rgba(74, 222, 128, 0.72);
  --heat-2:         rgba(163, 230, 53, 0.74);
  --heat-3:         rgba(234, 179, 8, 0.78);
  --heat-4:         rgba(249, 115, 22, 0.82);
  --heat-5:         rgba(239, 68, 68, 0.88);
  --heat-past:      rgba(255, 255, 255, 0.03);
  --heat-cell-text: rgba(0, 0, 0, 0.68);

  --radius:         8px;
  --radius-sm:      4px;
}


/* =====================
   LIGHT THEME OVERRIDE
   ===================== */

.theme-light {
  --bg:             #f0f2f7;
  --surface:        #ffffff;
  --surface-2:      #f5f6fa;
  --surface-hover:  #e8eaf2;
  --surface-active: #edf0ff;

  --border:         #d0d5e8;
  --border-subtle:  #e2e5f0;

  --text:           #1a1d2e;
  --text-dim:       #5a6082;
  --text-muted:     #a0a8c0;

  --accent:         #3a8e36;
  --accent-soft:    rgba(58, 142, 54, 0.08);
  --accent-border:  rgba(58, 142, 54, 0.20);

  --warning:        #967208;
  --warning-soft:   rgba(150, 114, 8, 0.09);

  --done-color:     #8090b0;
  --done-soft:      rgba(128, 144, 176, 0.14);

  --check-done:     #3a8e36;
  --check-open:     #c0c8dc;

  --heat-0:         rgba(0, 0, 0, 0.05);
  --heat-1:         rgba(22, 163, 74, 0.82);
  --heat-2:         rgba(101, 163, 13, 0.82);
  --heat-3:         rgba(161, 98, 7, 0.82);
  --heat-4:         rgba(194, 65, 12, 0.84);
  --heat-5:         rgba(185, 28, 28, 0.86);
  --heat-past:      rgba(0, 0, 0, 0.04);
  --heat-cell-text: rgba(255, 255, 255, 0.92);
}


/* =====================
   BODY
   ===================== */

body {
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", "IBM Plex Mono", "Fira Code", monospace;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}


/* =====================
   APP SHELL – 3-COLUMN GRID
   ===================== */

.app {
  display: grid;
  grid-template-columns: 220px 1fr 270px;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}


/* =====================
   SHARED PANEL HEADER
   ===================== */

.panel-header {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.panel-subtitle {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
}


/* =====================
   SIDEBAR
   ===================== */

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

.sidebar-header {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  min-height: 48px;
}

.sidebar-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-btn,
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
}

.sidebar-btn:hover,
.theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--accent);
}

.goal-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.goal-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 16px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 80ms ease, border-color 80ms ease;
  user-select: none;
}

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

.goal-item.selected {
  background: var(--surface-active);
  border-left-color: var(--accent);
}

.goal-item-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  line-height: 1.3;
}

.goal-item.selected .goal-item-title {
  color: var(--accent);
}

.goal-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.goal-item-count {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.goal-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 80ms ease, background 80ms ease, color 80ms ease;
}

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

.goal-delete-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}


/* =====================
   CENTER – PLAN LIST
   ===================== */

.center {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.plan-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}


/* =====================
   PLAN CARD
   ===================== */

.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

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

.plan-title-area {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  overflow: hidden;
}

.plan-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.plan-today-preview {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.plan-card-content {
  overflow-y: auto;
  max-height: 540px;
}

.plan-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.plan-card-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 80ms ease, color 80ms ease, border-color 80ms ease;
}

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

.plan-card-btn.active {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.plan-card-btn.delete-btn:hover {
  background: rgba(239, 68, 68, 0.10);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
}


/* =====================
   PLAN DATE EDITOR
   ===================== */

.plan-date-editor {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-2);
}

.date-editor-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  flex-shrink: 0;
}

.date-input {
  font-family: inherit;
  font-size: 0.75rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  outline: none;
  color-scheme: dark;
  transition: border-color 100ms ease;
}

.theme-light .date-input {
  color-scheme: light;
}

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

.plan-status-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  background: var(--surface-2);
  color: var(--text-muted);
}

.plan-status-badge.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.plan-status-badge.upcoming {
  background: var(--warning-soft);
  color: var(--warning);
}

.plan-status-badge.completed {
  background: var(--done-soft);
  color: var(--done-color);
}

.plan-meta {
  padding: 6px 14px;
  font-size: 0.67rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-subtle);
}

.plan-body {
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}


/* =====================
   PROGRESS BAR
   ===================== */

.plan-progress {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.progress-bar-container {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.progress-day {
  font-size: 0.64rem;
  color: var(--text-dim);
}


/* =====================
   TODAY ACTION HIGHLIGHT (in plan card)
   ===================== */

.plan-today-action {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
}

.today-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
  flex-shrink: 0;
}

.today-action-text {
  font-size: 0.76rem;
  color: var(--text);
}


/* =====================
   ENTRIES LIST
   ===================== */

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

.entry-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 80ms ease;
}

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

.entry-item.entry-today {
  background: var(--accent-soft);
}

.entry-item.entry-today:hover {
  background: var(--accent-soft);
  filter: brightness(1.05);
}

.entry-check {
  font-size: 0.65rem;
  flex-shrink: 0;
  width: 14px;
  color: var(--check-open);
  transition: color 100ms ease;
}

.entry-item.entry-done .entry-check {
  color: var(--check-done);
}

.entry-day {
  font-size: 0.62rem;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 22px;
}

.entry-item.entry-today .entry-day {
  color: var(--accent);
  font-weight: 700;
}

.entry-item.entry-done .entry-day {
  color: var(--text-muted);
}

.entry-text {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.4;
  transition: color 100ms ease, text-decoration 100ms ease;
}

.entry-item.entry-today .entry-text {
  color: var(--text);
}

.entry-item.entry-done .entry-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.entry-item.entry-done.entry-today .entry-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.entry-item.entry-rest {
  cursor: default;
  opacity: 0.5;
}

.entry-item.entry-rest:hover {
  background: none;
}

.entry-item.entry-rest.entry-today {
  background: var(--surface-2);
  opacity: 0.7;
}

.entry-item.entry-rest .entry-check {
  color: var(--text-muted);
}

.entry-item.entry-rest .entry-text {
  font-style: italic;
}


/* =====================
   REST DAY TODAY INDICATOR
   ===================== */

.plan-today-rest {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  opacity: 0.7;
}

.today-rest-text {
  font-size: 0.76rem;
  color: var(--text-dim);
  font-style: italic;
}


/* =====================
   TODAY PANEL (right column)
   ===================== */

.today-panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.today-actions {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.today-action-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 80ms ease, opacity 100ms ease;
}

.today-action-item:hover {
  background: var(--surface-hover);
}

.today-action-item.today-action-done {
  opacity: 0.55;
}

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

.today-action-goal {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
}

.today-action-item.today-action-done .today-action-goal {
  color: var(--text-muted);
}

.today-action-check {
  font-size: 0.7rem;
  color: var(--check-open);
  flex-shrink: 0;
}

.today-action-item.today-action-done .today-action-check {
  color: var(--check-done);
}

.today-action-plan {
  font-size: 0.65rem;
  color: var(--text-dim);
}

.today-action-entry {
  font-size: 0.8rem;
  color: var(--text);
  margin-top: 4px;
  line-height: 1.4;
}

.today-action-item.today-action-done .today-action-entry {
  text-decoration: line-through;
  color: var(--text-muted);
}

.no-actions {
  padding: 20px 16px;
  font-size: 0.75rem;
  color: var(--text-dim);
}


/* =====================
   HEATMAP
   ===================== */

.heatmap {
  padding: 12px 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.heatmap-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

.heatmap-wd {
  font-size: 0.58rem;
  color: var(--text-muted);
  text-align: center;
  user-select: none;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: default;
  transition: filter 80ms ease;
}

.heatmap-cell:hover {
  filter: brightness(1.12);
}

.heat-past { background: var(--heat-past); }
.heat-0    { background: var(--heat-0); }
.heat-1    { background: var(--heat-1); }
.heat-2    { background: var(--heat-2); }
.heat-3    { background: var(--heat-3); }
.heat-4    { background: var(--heat-4); }
.heat-5    { background: var(--heat-5); }

.heat-today {
  outline: 1.5px solid var(--accent);
  outline-offset: -1px;
}

.cell-day {
  font-size: 0.48rem;
  color: var(--text-muted);
  user-select: none;
  line-height: 1;
}

.cell-count {
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-muted);
  user-select: none;
}

.heat-1 .cell-day,
.heat-2 .cell-day,
.heat-3 .cell-day,
.heat-4 .cell-day,
.heat-5 .cell-day {
  color: var(--heat-cell-text);
  opacity: 0.72;
}

.heat-1 .cell-count,
.heat-2 .cell-count,
.heat-3 .cell-count,
.heat-4 .cell-count,
.heat-5 .cell-count {
  color: var(--heat-cell-text);
}


/* =====================
   SCROLLBAR
   ===================== */

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}


/* =====================
   PANEL TAB BAR (tablet only)
   ===================== */

.panel-tab-bar {
  display: none;
  gap: 4px;
  padding-top: 6px;
}

.panel-tab-btn {
  padding: 3px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: color 100ms ease, border-color 100ms ease, background 100ms ease;
}

.panel-tab-btn:hover {
  color: var(--text);
}

.panel-tab-btn.active {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}


/* =====================
   MOBILE NAVIGATION
   ===================== */

.mobile-nav {
  display: none;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 0 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  cursor: pointer;
  transition: color 100ms ease, background 100ms ease;
}

.mobile-nav-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.mobile-nav-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.mobile-nav-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}


/* =====================
   RESPONSIVE – TABLET (640px – 1023px)
   ===================== */

@media (min-width: 640px) and (max-width: 1023px) {
  .app {
    grid-template-columns: 200px 1fr;
  }

  .center,
  .today-panel {
    grid-column: 2;
    grid-row: 1;
  }

  .today-panel {
    display: none;
    border-left: none;
  }

  .app.panel-today .center {
    display: none;
  }

  .app.panel-today .today-panel {
    display: flex;
  }

  .panel-tab-bar {
    display: flex;
  }
}


/* =====================
   RESPONSIVE – MOBILE (< 640px)
   ===================== */

@media (max-width: 639px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: 100dvh;
  }

  .sidebar,
  .center,
  .today-panel {
    grid-column: 1;
    grid-row: 1;
    display: none;
  }

  .today-panel {
    border-left: none;
  }

  .app.panel-goals .sidebar {
    display: flex;
  }

  .app.panel-plans .center {
    display: flex;
  }

  .app.panel-today .today-panel {
    display: flex;
  }

  .mobile-nav {
    display: flex;
    grid-column: 1;
    grid-row: 2;
  }

  /* Increase touch targets for entries and action items */
  .entry-item {
    padding: 7px 6px;
  }

  .today-action-item {
    padding: 13px 12px;
  }
}


/* =====================
   CENTER EMPTY STATE
   ===================== */

.center-empty {
  padding: 40px 24px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}


/* =====================
   SHARED ICON BUTTONS (confirm / cancel)
   ===================== */

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  transition: background 80ms ease, color 80ms ease, border-color 80ms ease;
}

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

.icon-btn-cancel:hover {
  background: rgba(239, 68, 68, 0.10);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
}


/* =====================
   GOAL RENAME
   ===================== */

.goal-item-editing {
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
}

.goal-rename-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  outline: none;
}

.goal-rename-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 80ms ease, background 80ms ease, color 80ms ease;
}

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

.goal-rename-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}


/* =====================
   PLAN COLLAPSE BUTTON
   ===================== */

.plan-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 2px 6px 2px 2px;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color 80ms ease;
  font-family: inherit;
}

.plan-collapse-btn:hover {
  color: var(--text-dim);
}


/* =====================
   PLAN RENAME INPUT
   ===================== */

.plan-rename-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  outline: none;
}

.plan-card-title {
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background 80ms ease, color 80ms ease;
}

.plan-card-title:hover {
  background: var(--surface-hover);
  color: var(--accent);
}


/* =====================
   ADD PLAN FORM
   ===================== */

.plan-add-row {
  display: flex;
  gap: 8px;
}

.plan-add-row .add-plan-btn {
  flex: 1;
}

.add-plan-btn {
  display: block;
  width: 100%;
  padding: 9px 14px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: color 100ms ease, border-color 100ms ease, background 100ms ease;
}

.add-plan-btn:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.add-plan-form {
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.add-plan-title-row {
  display: flex;
}

.add-plan-input {
  flex: 1;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  outline: none;
  transition: border-color 100ms ease;
}

.add-plan-input::placeholder {
  color: var(--text-muted);
}

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

.add-plan-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.add-plan-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
  flex-shrink: 0;
}

.add-plan-weeks {
  font-family: inherit;
  font-size: 0.75rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  outline: none;
  width: 52px;
  transition: border-color 100ms ease;
}

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

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

.add-plan-create-btn {
  padding: 5px 14px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background 80ms ease;
}

.add-plan-create-btn:hover {
  background: var(--accent);
  color: var(--bg);
}

.add-plan-cancel-btn {
  padding: 5px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  background: none;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background 80ms ease, color 80ms ease;
}

.add-plan-cancel-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}


/* =====================
   ADD ENTRY FORM
   ===================== */

.add-entry-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 5px 6px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: color 100ms ease, border-color 100ms ease, background 100ms ease;
}

.add-entry-btn:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.add-entry-form {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.add-entry-type-row {
  display: flex;
  gap: 4px;
}

.entry-type-btn {
  padding: 3px 10px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background 80ms ease, color 80ms ease, border-color 80ms ease;
}

.entry-type-btn:hover {
  background: var(--surface-hover);
  color: var(--text-dim);
}

.entry-type-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}

.add-entry-input-row {
  display: flex;
  gap: 4px;
  align-items: center;
}

.add-entry-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 0.75rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  outline: none;
  transition: border-color 100ms ease;
}

.add-entry-input::placeholder {
  color: var(--text-muted);
}

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


/* =====================
   CONFIRM MODAL
   ===================== */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  max-width: 340px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.confirm-message {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-btn {
  padding: 5px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  transition: background 80ms ease, color 80ms ease, border-color 80ms ease;
}

.confirm-cancel {
  background: var(--surface-2);
  color: var(--text-dim);
}

.confirm-cancel:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.confirm-yes {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
}

.confirm-yes:hover {
  background: rgba(239, 68, 68, 0.22);
}


/* =====================
   ADD GOAL
   ===================== */

.add-goal-btn {
  display: block;
  width: calc(100% - 24px);
  margin: 6px 12px 8px;
  padding: 7px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: color 100ms ease, border-color 100ms ease, background 100ms ease;
}

.add-goal-btn:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.add-goal-form {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 8px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.add-goal-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 0.75rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  outline: none;
  transition: border-color 100ms ease;
}

.add-goal-input::placeholder {
  color: var(--text-muted);
}

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

.add-goal-confirm,
.add-goal-cancel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 80ms ease, color 80ms ease, border-color 80ms ease;
}

.add-goal-confirm:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}

.add-goal-cancel:hover {
  background: rgba(239, 68, 68, 0.10);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
}


/* =====================
   PLAN COLLAPSE
   ===================== */

.plan-collapse-icon {
  font-size: 0.5rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-right: 4px;
  transition: color 80ms ease;
  user-select: none;
}

.plan-card-header:hover .plan-collapse-icon {
  color: var(--text-dim);
}


/* =====================
   ENTRY REORDER BUTTONS
   ===================== */

.entry-move-btns {
  display: flex;
  gap: 1px;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 80ms ease;
}

.entry-item:hover .entry-move-btns {
  opacity: 1;
}

.entry-move-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 2px;
  background: none;
  color: var(--text-dim);
  font-size: 0.62rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-family: inherit;
  transition: background 80ms ease, color 80ms ease;
}

.entry-move-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.entry-move-btn.invisible {
  visibility: hidden;
  pointer-events: none;
}


/* =====================
   PLAN STATS BADGE
   ===================== */

.plan-stats-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: default;
}


/* =====================
   PLAN STATS ROW (body)
   ===================== */

.plan-stats-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.67rem;
  color: var(--text-muted);
}

.plan-stats-done {
  color: var(--text-dim);
}

.plan-stats-rate {
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.63rem;
}

.rate-good {
  background: var(--accent-soft);
  color: var(--accent);
}

.rate-mid {
  background: var(--warning-soft);
  color: var(--warning);
}

.rate-low {
  background: rgba(239, 68, 68, 0.10);
  color: #ef4444;
}


/* =====================
   ADD ENTRY ACTIONS (two-button row)
   ===================== */

.add-entry-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.add-entry-actions .add-entry-btn {
  flex: 1;
  margin-top: 0;
}

.add-week-btn {
  flex: 1;
  padding: 5px 6px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: color 100ms ease, border-color 100ms ease, background 100ms ease;
}

.add-week-btn:hover {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}


/* =====================
   ADD WEEK FORM
   ===================== */

.add-week-form {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.week-day-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}

.week-day-num {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  min-width: 26px;
  flex-shrink: 0;
}

.week-type-btn {
  padding: 2px 8px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 80ms ease, color 80ms ease, border-color 80ms ease;
}

.week-type-btn:hover {
  background: var(--surface-hover);
  color: var(--text-dim);
}

.week-type-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}

.week-type-rest {
  background: var(--done-soft);
  color: var(--done-color);
  border-color: transparent;
}

.week-type-rest:hover {
  background: var(--done-soft);
  color: var(--done-color);
  filter: brightness(1.1);
}

.week-day-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 0.72rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  outline: none;
  transition: border-color 100ms ease;
}

.week-day-input::placeholder {
  color: var(--text-muted);
}

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

.week-day-input:disabled {
  opacity: 0.4;
  cursor: default;
}

.add-week-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.add-week-create-btn {
  padding: 5px 14px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background 80ms ease;
}

.add-week-create-btn:hover {
  background: var(--accent);
  color: var(--bg);
}

.add-week-cancel-btn {
  padding: 5px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  background: none;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background 80ms ease, color 80ms ease;
}

.add-week-cancel-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}


/* =====================
   WEEK COLUMN GRID (inside plan card)
   ===================== */

.weeks-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.week-column {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.week-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 2px 4px 6px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2px;
}

.week-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 2px;
  background: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  opacity: 0;
  transition: opacity 80ms ease, background 80ms ease, color 80ms ease;
}

.week-column:hover .week-delete-btn {
  opacity: 1;
}

.week-delete-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

/* Single column on mobile */
@media (max-width: 639px) {
  .weeks-grid {
    grid-template-columns: 1fr;
  }
}


/* =====================
   ENTRY EDIT / DELETE BUTTONS
   ===================== */

.entry-edit-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.entry-del-btn:hover {
  background: rgba(239, 68, 68, 0.10);
  color: #ef4444;
}


/* =====================
   ENTRY INLINE EDIT FORM
   ===================== */

.entry-edit-form {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 5px 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-border);
}

.entry-edit-type-row {
  display: flex;
  gap: 4px;
}

.entry-edit-input-row {
  display: flex;
  gap: 4px;
  align-items: center;
}

.entry-edit-input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 0.72rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
  outline: none;
  transition: border-color 100ms ease;
}

.entry-edit-input::placeholder {
  color: var(--text-muted);
}

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