/* Habit collection: cards stay human-sized instead of stretching with workspace. */

.habit-library-shell {
  display: grid;
  gap: 14px;
  min-width: 0;
}

/* Kaizen is an internal implementation term, not user-facing information. */
[data-habit-card] .eyebrow {
  display: none;
}

.habit-library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  padding: 0 2px;
}
.habit-library-toolbar h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.habit-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 340px));
  justify-content: start;
  gap: 14px;
  min-width: 0;
}

.habit-library-card {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 300px;
  padding: 16px;
  overflow: hidden;
}
.habit-library-card.is-primary {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}
.habit-library-card.is-paused {
  opacity: .78;
}

.habit-library-card-head,
.habit-library-kicker,
.habit-library-progress > div:first-child,
.habit-library-actions,
.habit-detail-badges {
  display: flex;
  align-items: center;
}
.habit-library-card-head,
.habit-library-progress > div:first-child,
.habit-detail-badges {
  justify-content: space-between;
}
.habit-library-kicker {
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.habit-primary-label {
  color: var(--accent);
}
.habit-star-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 19px;
}
.habit-star-button:hover,
.habit-star-button:focus-visible {
  background: var(--surface-2);
  color: var(--accent);
  outline: none;
}

.habit-library-open {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.habit-library-open strong {
  overflow: hidden;
  font-size: 20px;
  line-height: 1.24;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.habit-library-open .muted {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.habit-library-open:hover strong,
.habit-library-open:focus-visible strong {
  color: var(--accent);
}
.habit-library-open:focus-visible {
  outline: none;
}

.habit-library-progress {
  display: grid;
  gap: 7px;
}
.habit-library-progress > div:first-child {
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}
.habit-library-progress strong {
  color: var(--text);
  font-size: 14px;
}
.habit-library-card .habit-progress-bar {
  height: 5px;
}

.habit-library-stats {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
}
.habit-library-stats span {
  white-space: nowrap;
}
.habit-library-stats strong {
  color: var(--text);
  font-size: 14px;
}

.habit-library-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.habit-library-day {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
}
.habit-library-day b {
  max-width: 100%;
  overflow: hidden;
  font-size: 10px;
  font-weight: 650;
  text-overflow: clip;
  white-space: nowrap;
}
.habit-library-day i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface-3);
}
.habit-library-day.checked i {
  background: var(--accent);
}
.habit-week-compact {
  margin-top: 1px;
}

.habit-library-actions {
  gap: 8px;
  margin-top: auto;
  padding-top: 2px;
}
.habit-library-actions .button {
  font-size: 13px;
}
.habit-library-actions .button:first-child {
  flex: 1 1 auto;
}
.habit-library-actions .button:last-child {
  flex: 0 0 auto;
}

.habit-library-empty {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 28px 2px;
  color: var(--muted);
}
.habit-library-empty p {
  margin: 0;
}

/* Catalog is also a card grid, but adding a preset remains a single small action. */
.habit-catalog,
.habit-create-custom {
  display: grid;
  gap: 14px;
}
.habit-catalog .habit-lead,
.habit-create-custom .habit-lead {
  max-width: 620px;
  margin: 0;
}
.habit-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 260px));
  justify-content: start;
  gap: 12px;
}
.habit-catalog-card {
  display: grid;
  align-content: space-between;
  gap: 20px;
  min-height: 150px;
  padding: 16px;
}
.habit-catalog-card h3 {
  margin: 5px 0 0;
  font-size: 15px;
}
.habit-catalog-category {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.habit-catalog-card .button {
  justify-self: start;
}
.habit-catalog-custom {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

.habit-custom-create-form {
  width: min(680px, 100%);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}
.habit-custom-create-form [data-custom-habit-label],
.habit-custom-create-form .habit-new-actions {
  grid-column: 1 / -1;
}
.habit-custom-create-form .habit-new-actions {
  justify-content: flex-start;
}

/* Focused detail stays intentionally narrower than the collection workspace. */
.habit-detail-shell {
  width: min(860px, 100%);
}
.habit-detail-shell .habit-back-link {
  margin-bottom: 11px;
}
.habit-detail-badges {
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.habit-primary-badge {
  color: var(--accent);
}
.habit-detail-shell .habit-week-inline {
  max-width: 620px;
}

/* Do not let the older Kaizen presentation layer stretch nested habit cards. */
.kaizen-polished .kaizen-habit-card.habit-library-shell .card-header {
  min-height: initial;
  padding: initial;
}

@media (max-width: 900px) {
  .habit-library-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
  .habit-catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  }
}

@media (max-width: 700px) {
  .habit-library-toolbar {
    align-items: flex-start;
  }
  .habit-library-grid,
  .habit-catalog-grid,
  .habit-custom-create-form {
    grid-template-columns: 1fr;
  }
  .habit-custom-create-form [data-custom-habit-label],
  .habit-custom-create-form .habit-new-actions {
    grid-column: 1;
  }
  .habit-library-card {
    min-height: 0;
  }
  .habit-library-actions {
    flex-wrap: wrap;
  }
}
