.habit-page,
.habit-weekdays {
  --text: var(--theme-text);
  --text-muted: var(--theme-text-muted);
  --border: var(--theme-line);
  --accent: var(--mn-accent, #329f96);
}
.habit-page {
  display: grid;
  gap: 16px;
  min-width: 0;
  color: var(--text);
}
.habit-page h1 {
  font-size: clamp(24px, 7vw, 36px);
  line-height: 1.25;
}
.habit-intro,
.habit-row-head p,
.habit-history p,
.habit-empty p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}
.habit-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}
.habit-toolbar label {
  display: grid;
  gap: 6px;
  flex: 1;
  min-width: 160px;
  font-size: 14px;
}
.habit-toolbar input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
}
.habit-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.habit-card,
.habit-empty {
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  padding: 16px;
}
.habit-row-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: start;
}
.habit-row-head h2,
.habit-empty h2 {
  font-size: 18px;
  line-height: 1.4;
  margin: 0 0 5px;
  overflow-wrap: anywhere;
}
.habit-edit {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 12px;
}
.habit-edit svg {
  width: 20px;
  height: 20px;
}
.habit-status {
  margin: 12px 0 10px;
  font-size: 14px;
  color: var(--text-muted);
}
.habit-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.habit-page .btn {
  min-height: 44px;
  min-width: 0;
}
.habit-actions .btn {
  flex: 1;
  font-size: 14px;
  padding: 10px;
}
.habit-link {
  min-height: 44px;
  padding: 8px 0;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.habit-actions .habit-link {
  flex-basis: 100%;
}
.habit-history {
  margin-top: 12px;
}
.habit-history summary,
.habit-paused > summary {
  min-height: 44px;
  padding: 12px 0;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
}
.habit-calendar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
  margin-top: 10px;
}
.habit-day {
  min-width: 0;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 4px 0;
  background: transparent;
  color: var(--text-muted);
}
.habit-day small {
  min-height: 12px;
  line-height: 12px;
}
.habit-day.planned {
  border-color: var(--border);
}
.habit-day.done {
  background: var(--accent);
  color: var(--mn-accent-ink);
}
.habit-day.skipped {
  border: 1px dashed var(--text-muted);
}
.habit-day.selected {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}
.habit-weekdays {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  border: 0;
  padding: 0;
  min-width: 0;
}
.habit-weekdays legend {
  padding: 0 0 10px;
}
.habit-weekdays label {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.habit-weekdays input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.habit-page button:focus-visible,
.habit-weekdays input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
