/* Life OS · Habits Tracker Styles (Pixel Fold Optimized) */

.habits-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 18px rgba(80, 70, 50, 0.05);
  box-sizing: border-box;
}

/* 1. TOPBAR (Left Aligned Navigator) */
.habits-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 8px 2px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
  flex-wrap: wrap;
}

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

.habits-period-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px 6px;
}

.habits-period-title {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 90px;
  text-align: center;
}

.btn-habits-current {
  margin-left: 8px;
}

.habits-minimal-legend {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-green {
  background: #2f9e77;
}

.status-yellow {
  background: #f59e0b;
}

.status-red {
  background: #ef4444;
}

/* 2. FULL-MONTH MATRIX */
.habits-matrix-card {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  overflow: hidden;
}

.habits-matrix-scroll-wrapper {
  overflow-x: auto;
}

.habits-matrix-inner {
  min-width: 660px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.habits-grid-header,
.habits-grid-row {
  display: grid;
  grid-template-columns: 140px repeat(var(--days-count, 30), minmax(0, 1fr)) 78px;
  align-items: center;
  gap: 2.5px;
}

.habits-grid-header {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.habits-hdr-label {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  padding-left: 4px;
}

.habits-day-header-btn {
  background: none;
  border: none;
  padding: 2px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1.1;
  transition: all 0.12s ease;
}

.habits-day-header-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.habits-day-header-btn.is-today {
  color: var(--accent-emerald);
  font-weight: 800;
}

.habits-day-header-btn.is-selected {
  background: var(--accent-indigo);
  color: #ffffff !important;
}

.habits-hdr-dayname {
  font-size: 0.62rem;
  opacity: 0.8;
}

.habits-hdr-daynum {
  font-size: 0.72rem;
}

.habits-hdr-rhythm {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: right;
  padding-right: 4px;
}

/* HABIT ROW */
.habits-grid-row {
  padding: 6px 0;
}

.habit-info-cell {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-left: 4px;
  min-width: 0;
}

.habit-icon {
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
}

.habit-name-wrap {
  min-width: 0;
}

.habit-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* DAY CELL */
.habit-day-cell {
  height: 24px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.habit-day-cell:hover {
  transform: scale(1.15);
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.habit-day-cell.wk-start {
  margin-left: 2px;
}

.habit-day-cell.is-selected {
  outline: 2px solid var(--accent-indigo);
  outline-offset: -1px;
}

.habit-day-cell.is-future {
  border-style: dashed;
  opacity: 0.45;
  cursor: default;
}

.habit-day-cell.cell-green {
  background: #2f9e77;
  border-color: #2f9e77;
  color: #ffffff;
}

.habit-day-cell.cell-yellow {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #ffffff;
}

.habit-day-cell.cell-red {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
}

.cell-dot-symbol {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffff;
}

.cell-sync-indicator {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
}

/* RHYTHM CELL */
.habit-rhythm-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-right: 4px;
}

.rhythm-grade-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.15);
}

.rhythm-grade-pct {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* 3. BOTTOM SPLIT DECK */
.habits-bottom-deck {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.habits-subcard {
  background: var(--bg-subcard);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
}

.habits-day-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.habits-day-title-wrap .subcard-title {
  white-space: nowrap;
}

.habits-selected-status-badge {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.habits-selected-status-badge.status-green {
  background: rgba(47, 158, 119, 0.15);
  color: #1f6f54;
  border-color: rgba(47, 158, 119, 0.35);
}

.habits-selected-status-badge.status-yellow {
  background: rgba(245, 158, 11, 0.15);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.35);
}

.habits-selected-status-badge.status-red {
  background: rgba(239, 68, 68, 0.15);
  color: #991b1b;
  border-color: rgba(239, 68, 68, 0.35);
}

.habits-sync-source-tag {
  font-size: 1.22rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  vertical-align: middle;
}

.habits-day-details-body {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.habits-bedtime-readout {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 10px;
}

.bedtime-time-icon {
  font-size: 1.4rem;
}

.bedtime-time-val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.bedtime-time-hint {
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.habits-quick-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-actions-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.habits-action-btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-habit-tier {
  font-weight: 700;
  cursor: pointer;
}

.btn-tier-green {
  border-color: rgba(47, 158, 119, 0.4);
  color: #2f9e77;
}

.btn-tier-green:hover {
  background: #2f9e77;
  color: #ffffff;
}

.btn-tier-yellow {
  border-color: rgba(245, 158, 11, 0.4);
  color: #d97706;
}

.btn-tier-yellow:hover {
  background: #f59e0b;
  color: #ffffff;
}

.btn-tier-red {
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

.btn-tier-red:hover {
  background: #ef4444;
  color: #ffffff;
}

/* GRADING CARD */
.habits-grade-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.grading-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}

.grading-kpi-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.kpi-val {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
}

.text-rose {
  color: #ef4444 !important;
}

.grading-rules-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.grading-rule-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.habits-metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.metric-val {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.habits-grading-body {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.grading-habit-block {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.grading-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.grading-habit-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.grading-threshold-hint {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* PLANNER MINI GENTLE HABITS STRIP (Option A Preview) */
.planner-habits-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin-bottom: 8px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.planner-habits-strip:hover {
  border-color: var(--accent-emerald);
}

.planner-habits-strip-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.planner-habits-strip-right {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* RESPONSIVE FOLDED SCREEN */
@media (max-width: 640px) {
  .habits-bottom-deck {
    grid-template-columns: 1fr;
  }
}
