.habit-page {
  background: var(--paper);
  --display: 'Literata', Georgia, serif;
  --sans: 'Golos Text', system-ui, sans-serif;
  font-family: var(--sans);
}
.habit-header { background: var(--surface); border-bottom: 1px solid var(--rule); }
.habit-header .header-inner { min-height: 4.25rem; padding-block: .55rem; }
.habit-return, .habit-link { color: var(--green-dark); text-decoration: underline; text-underline-offset: .2em; }
.habit-return { display: inline-flex; align-items: center; min-height: 2.75rem; font-size: .94rem; }
.habit-main { padding-block: clamp(1.8rem, 6vw, 4.5rem); }
.habit-intro h1 { max-width: 25ch; font-size: clamp(1.85rem, 3.4vw, 2.55rem); }
.habit-intro p { margin-top: .65rem; color: var(--muted); max-width: 52ch; }
.habit-spread { margin-top: 1.8rem; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.habit-work { padding: clamp(1.3rem, 3.1vw, 2.5rem); min-width: 0; container-type: inline-size; }
.habit-art { min-width: 0; overflow: hidden; background: var(--sage-soft); }
.habit-art img { display: block; width: 100%; height: 100%; max-height: 42rem; object-fit: cover; object-position: 53% center; }
.habit-heading, #current-habit { font: 500 1.38rem/1.32 var(--display); display: block; overflow-wrap: anywhere; }
#habit-name { margin-top: .75rem; width: 100%; min-height: 2.9rem; }
#habit-name::placeholder { color: var(--muted); opacity: 1; }
.suggestions { display: grid; justify-items: start; margin-block: .5rem 1.25rem; }
.suggestions button, .habit-link { min-height: 2.75rem; padding: .4rem 0; border: 0; background: none; cursor: pointer; font-size: .91rem; text-align: left; }
.suggestions button { color: var(--green-dark); text-decoration: underline dotted; text-underline-offset: .23em; }
.suggestions button:hover, .habit-link:hover, .habit-return:hover { text-decoration-style: solid; text-decoration-thickness: 2px; }
#show-schedule { margin-block: -.6rem .55rem; }
#schedule-fields { margin-block: .45rem 1rem; }
.weekday-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.weekday-field legend { font: 500 1.13rem/1.4 var(--display); padding-bottom: .65rem; }
#weekdays { display: grid; grid-template-columns: repeat(7, 2.75rem); gap: .3rem; }
@container (max-width: 21.1rem) {
  #weekdays { grid-template-columns: repeat(4, minmax(2.75rem, 3.25rem)); }
}
.weekday-choice {
  min-width: 2.75rem; min-height: 2.75rem; padding: .4rem; border: 1px solid var(--rule-strong);
  border-radius: .45rem; background: var(--sheet); color: var(--ink); font: inherit; cursor: pointer;
}
.weekday-choice[aria-pressed="true"] { background: var(--green-dark); border-color: var(--green-dark); color: #fff; font-weight: 600; }
.schedule-hint, .schedule-summary { margin-top: .5rem; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.schedule-error { color: var(--error); margin-top: .5rem; }
.calendar-option { display: flex; align-items: center; gap: .6rem; min-height: 2.75rem; margin-top: .55rem; cursor: pointer; }
.calendar-option input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--green-dark); }
#calendar-time-field { margin-top: .35rem; }
#calendar-time-field label { display: block; margin-bottom: .35rem; }
#calendar-time { min-height: 2.75rem; max-width: 100%; padding: .35rem .6rem; font: inherit; color: var(--ink); background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: .45rem; }
.schedule-actions, .schedule-form-actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem 1rem; }
.day.is-planned small { text-decoration: underline; text-underline-offset: .18em; }
.retention { color: var(--muted); font-size: .9rem; line-height: 1.48; }
.retention label { color: var(--ink); display: flex; align-items: center; gap: .6rem; min-height: 2.75rem; font-weight: 550; cursor: pointer; }
.retention input { margin: 0; width: 1.1rem; height: 1.1rem; flex: none; accent-color: var(--green-dark); }
.habit-primary { margin-top: 1.15rem; padding: .68rem 1.1rem; min-height: 2.8rem; border: 1px solid var(--green-dark); border-radius: .55rem; background: var(--green-dark); color: white; font-weight: 550; cursor: pointer; }
.habit-primary:hover { background: var(--green); }
.habit-primary:disabled { background: var(--sage-soft); color: var(--green-dark); border-color: var(--rule); cursor: default; }
.today-action[aria-pressed="true"] { background: var(--sage); color: var(--green-dark); }
.week-heading span, .week-hint { font-size: .88rem; color: var(--muted); }
.week-heading { margin-top: 1.65rem; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .2rem .6rem; }
.week-heading h3 { margin: 0; font-size: 1rem; }
.habit-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .23rem; margin-top: .75rem; }
.day { display: grid; justify-items: center; gap: .2rem; padding: .4rem 0; border: 1px solid var(--rule-strong); border-radius: .45rem; background: var(--sheet); color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.15; cursor: pointer; }
.day small { font-size: .76rem; color: var(--muted); }
.day[aria-current="date"] { border-color: var(--green-dark); }
.day[aria-pressed="true"] { background: var(--sage); }
.day-mark { display: grid; place-content: center; height: 13px; width: 13px; }
.day-mark::after { content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--control); }
.day[aria-pressed="true"] .day-mark::after { width: 11px; height: 6px; border: solid var(--green-dark); border-width: 0 0 2px 2px; border-radius: 0; background: transparent; transform: translateY(-1px) rotate(-45deg); }
@media (prefers-reduced-motion: no-preference) { .day { transition: background-color 170ms ease-out; } }
.week-hint { margin-top: .65rem; }
#total-days { margin-block: .9rem; font-weight: 550; }
#notice:not(:empty) { margin-bottom: .85rem; padding: .7rem .85rem; background: var(--sage-soft); border-radius: .45rem; }
@media (max-width: 47rem) {
  .habit-spread { grid-template-columns: 1fr; }
  .habit-art { aspect-ratio: 3 / 1; }
  .habit-art img { object-position: center 71%; }
}
@media (max-width: 31rem) {
  .habit-header .frame { flex-direction: row; gap: .25rem; }
  .habit-header .brand { font-size: 1rem; }
  .habit-return { font-size: .83rem; }
  .habit-main { padding-top: 1.45rem; }
  .habit-spread { margin-top: 1.1rem; }
  .habit-work { padding: 1rem; }
  .habit-intro h1 { font-size: 1.85rem; }
}
@media (max-width: 22rem) { .habit-days { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
