:root {
  --bg: #f5f2eb;
  --card: #fffaf2;
  --ink: #25221f;
  --muted: #746e66;
  --line: #ded6c9;
  --accent: #456b4f;
  --accent-dark: #2f4a36;
  --danger: #a33a2f;
  --shadow: 0 12px 30px rgba(40, 32, 24, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(69, 107, 79, 0.12), transparent 32rem),
    var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.9);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.9rem;
  background: var(--accent);
  color: white;
  font-weight: 800;
  letter-spacing: -0.06em;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

.nav {
  display: flex;
  gap: 0.5rem;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.55rem 0.75rem;
  border-radius: 999px;
}

.nav a:hover {
  background: rgba(69, 107, 79, 0.1);
  color: var(--ink);
}

.page {
  padding: 1.5rem;
}

.flash-wrap {
  max-width: 72rem;
  margin: 0 auto 1rem;
}

.flash {
  padding: 0.8rem 1rem;
  border-radius: 0.9rem;
  margin-bottom: 0.5rem;
  background: white;
  border: 1px solid var(--line);
}

.flash.success {
  border-color: rgba(69, 107, 79, 0.4);
}

.flash.error {
  border-color: rgba(163, 58, 47, 0.4);
  color: var(--danger);
}

.calendar-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 25rem;
  gap: 1.25rem;
  max-width: 92rem;
  margin: 0 auto;
}

.calendar-main,
.panel-card {
  background: rgba(255, 250, 242, 0.92);
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  box-shadow: var(--shadow);
}

.calendar-main {
  padding: 1rem;
}

.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

h1,
h2,
h3 {
  margin-top: 0;
  letter-spacing: -0.03em;
}

.muted {
  color: var(--muted);
}

.toolbar-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button,
button {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.button.primary,
button.primary {
  background: var(--accent);
  color: white;
}

.button.primary:hover,
button.primary:hover {
  background: var(--accent-dark);
}

.button.secondary {
  background: white;
  border: 1px solid var(--line);
  color: var(--ink);
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 0.25rem 0.5rem;
}

.weekday-row div {
  padding: 0.35rem;
}

.calendar-grid {
  gap: 0.4rem;
}

.day-cell {
  min-height: 7.5rem;
  padding: 0.55rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: white;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.day-cell:hover {
  border-color: var(--accent);
}

.day-cell.outside {
  opacity: 0.42;
}

.day-cell.today {
  outline: 2px solid rgba(69, 107, 79, 0.35);
}

.day-cell.selected {
  background: rgba(69, 107, 79, 0.12);
  border-color: var(--accent);
}

.day-number {
  font-weight: 800;
}

.markers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.marker {
  width: 1.45rem;
  height: 1.45rem;
  display: grid;
  place-items: center;
  color: white;
  border-radius: 999px;
  font-size: 0.72rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.14);
}

.day-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-card {
  padding: 1rem;
}

.entry-form,
.category-form {
  display: grid;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: white;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.entry-list {
  display: grid;
  gap: 0.75rem;
}

.entry-card {
  background: white;
  border: 1px solid var(--line);
  border-left: 0.45rem solid var(--accent);
  border-radius: 1rem;
  padding: 0.85rem;
}

.entry-card p {
  margin-bottom: 0;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.entry-head span {
  display: block;
  color: var(--muted);
  margin-top: 0.15rem;
}

.entry-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.entry-actions a,
.entry-actions button,
.danger-link {
  font-size: 0.82rem;
  color: var(--muted);
  background: none;
  padding: 0;
  border-radius: 0;
  font-weight: 700;
}

.entry-actions button,
.danger-link {
  color: var(--danger);
}

.danger-link:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.entry-meta,
.tags {
  color: var(--muted);
  font-size: 0.88rem;
}

.tags {
  font-weight: 700;
}

.narrow-page {
  max-width: 56rem;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}

.category-form {
  grid-template-columns: 2fr 7rem 1fr 1fr auto auto;
  align-items: end;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.checkbox-label input {
  width: auto;
}

.checkbox-label.small {
  font-size: 0.8rem;
}

.category-list {
  display: grid;
  gap: 0.5rem;
}

.category-row {
  display: grid;
  grid-template-columns: 2fr 5rem 1fr 1fr auto auto auto;
  gap: 0.5rem;
  align-items: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.75rem;
}

.stat-card {
  background: white;
  border: 1px solid var(--line);
  border-top: 0.4rem solid var(--accent);
  border-radius: 1rem;
  padding: 1rem;
  display: grid;
  gap: 0.25rem;
}

.stat-card span {
  font-size: 1.4rem;
  font-weight: 800;
}

.stat-card small {
  color: var(--muted);
}

@media (max-width: 980px) {
  .calendar-shell {
    grid-template-columns: 1fr;
  }

  .day-cell {
    min-height: 5.8rem;
  }

  .category-form,
  .category-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-header,
  .calendar-toolbar,
  .entry-head {
    flex-direction: column;
    align-items: stretch;
  }

  .page {
    padding: 1rem;
  }

  .calendar-main,
  .panel-card {
    border-radius: 1rem;
  }

  .day-cell {
    min-height: 4.6rem;
    padding: 0.4rem;
  }

  .marker {
    width: 1.25rem;
    height: 1.25rem;
    font-size: 0.65rem;
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}

.quick-add-wrap {
  margin: 1rem 0;
  padding: 0.85rem;
  background: rgba(69, 107, 79, 0.07);
  border: 1px solid rgba(69, 107, 79, 0.18);
  border-radius: 1rem;
}

.quick-add-wrap h3 {
  margin-bottom: 0.65rem;
  font-size: 1rem;
}

.quick-add-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.5rem;
}

.quick-add-button {
  width: 100%;
  min-height: 2.8rem;
  border-radius: 0.9rem;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
}

.quick-add-button:hover {
  border-color: var(--cat-color);
  box-shadow: 0 6px 16px rgba(40, 32, 24, 0.08);
}

.quick-add-icon {
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  background: var(--cat-color);
  color: white;
  font-size: 0.85rem;
}

.stats-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stats-toolbar.compact {
  margin-bottom: 0.5rem;
}

.summary-list {
  display: grid;
  gap: 0.6rem;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  background: white;
  border: 1px solid var(--line);
  border-left: 0.45rem solid var(--cat-color);
  border-radius: 1rem;
  padding: 0.85rem;
}

.summary-name {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.summary-icon,
.streak-icon {
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 999px;
  background: var(--cat-color);
  color: white;
  font-size: 0.9rem;
}

.summary-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  color: var(--muted);
}

.summary-metrics span {
  background: rgba(69, 107, 79, 0.07);
  border: 1px solid rgba(69, 107, 79, 0.13);
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  white-space: nowrap;
}

.summary-metrics strong {
  color: var(--ink);
}

.streak-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.75rem;
}

.streak-card {
  background: white;
  border: 1px solid var(--line);
  border-top: 0.45rem solid var(--cat-color);
  border-radius: 1rem;
  padding: 0.9rem;
}

.streak-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.streak-numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.streak-numbers div {
  background: rgba(40, 32, 24, 0.04);
  border-radius: 0.8rem;
  padding: 0.55rem;
  text-align: center;
}

.streak-numbers span {
  display: block;
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 850;
}

.streak-numbers small {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (max-width: 720px) {
  .stats-toolbar,
  .summary-row {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .summary-row {
    display: grid;
  }

  .summary-metrics {
    justify-content: flex-start;
  }
}

.day-cell.heat-1 {
  background:
    linear-gradient(0deg, rgba(69, 107, 79, 0.07), rgba(69, 107, 79, 0.07)),
    white;
}

.day-cell.heat-2 {
  background:
    linear-gradient(0deg, rgba(69, 107, 79, 0.13), rgba(69, 107, 79, 0.13)),
    white;
}

.day-cell.heat-3 {
  background:
    linear-gradient(0deg, rgba(69, 107, 79, 0.20), rgba(69, 107, 79, 0.20)),
    white;
}

.day-cell.heat-4 {
  background:
    linear-gradient(0deg, rgba(69, 107, 79, 0.29), rgba(69, 107, 79, 0.29)),
    white;
}

.day-cell.selected {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.day-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.entry-count {
  min-width: 1.45rem;
  height: 1.45rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(37, 34, 31, 0.82);
  color: white;
  font-size: 0.72rem;
  font-weight: 850;
}

.heat-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.85rem;
}

.heat-swatch {
  width: 1rem;
  height: 1rem;
  border-radius: 0.3rem;
  border: 1px solid var(--line);
  background: white;
}

.heat-swatch.heat-1 {
  background: rgba(69, 107, 79, 0.07);
}

.heat-swatch.heat-2 {
  background: rgba(69, 107, 79, 0.13);
}

.heat-swatch.heat-3 {
  background: rgba(69, 107, 79, 0.20);
}

.heat-swatch.heat-4 {
  background: rgba(69, 107, 79, 0.29);
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.month-export-form {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) auto;
  align-items: end;
  gap: 0.75rem;
}

.backup-list {
  display: grid;
  gap: 0.65rem;
}

.backup-row {
  background: white;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.backup-row p {
  margin: 0.25rem 0 0;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.danger-button {
  background: rgba(163, 58, 47, 0.1);
  color: var(--danger);
  border: 1px solid rgba(163, 58, 47, 0.25);
}

.danger-button:hover {
  background: rgba(163, 58, 47, 0.16);
}

code {
  background: rgba(40, 32, 24, 0.07);
  padding: 0.15rem 0.35rem;
  border-radius: 0.35rem;
}

@media (max-width: 720px) {
  .month-export-form,
  .backup-row {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .backup-actions {
    justify-content: flex-start;
  }
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1rem;
}

.filter-chip {
  --cat-color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.45rem 0.65rem;
  font-size: 0.88rem;
  font-weight: 750;
}

.filter-chip span {
  color: var(--cat-color);
}

.filter-chip.active {
  color: var(--ink);
  border-color: var(--cat-color);
  background: rgba(69, 107, 79, 0.08);
}

.wide-review {
  max-width: 96rem;
}

.review-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.65rem;
}

.review-summary-card {
  background: white;
  border: 1px solid var(--line);
  border-top: 0.35rem solid var(--cat-color);
  border-radius: 1rem;
  padding: 0.8rem;
  display: grid;
  gap: 0.25rem;
}

.review-summary-card span {
  font-size: 1.5rem;
  font-weight: 850;
}

.week-review-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(11rem, 1fr));
  gap: 0.75rem;
}

.review-day {
  min-height: 20rem;
}

.review-today {
  outline: 2px solid rgba(69, 107, 79, 0.35);
}

.review-day-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.review-day-head h2 {
  margin-bottom: 0.15rem;
}

.compact-entry {
  font-size: 0.9rem;
}

.compact-entry p {
  margin-top: 0.35rem;
}

.dashboard-page {
  max-width: 82rem;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.78rem;
  font-weight: 850;
  margin: 0 0 0.3rem;
}

.dashboard-hero h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  margin-bottom: 0.3rem;
}

.dashboard-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr;
  gap: 1rem;
  align-items: start;
}

.dashboard-quick-grid {
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
}

.dashboard-quick-button {
  min-height: 3.4rem;
  font-size: 1rem;
}

.mini-streak-list {
  display: grid;
  gap: 0.55rem;
}

.mini-streak {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.65rem;
}

.mini-streak span {
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  background: var(--cat-color);
  color: white;
}

.mini-streak b {
  font-size: 1.2rem;
}

@media (max-width: 1100px) {
  .week-review-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }

  .site-header {
    position: static;
  }

  .filter-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.35rem;
  }

  .filter-chip {
    white-space: nowrap;
  }

  .week-review-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    flex-direction: column;
  }

  .dashboard-actions,
  .dashboard-actions .button {
    width: 100%;
  }

  .dashboard-actions .button {
    display: flex;
  }
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-page {
  width: min(100%, 28rem);
  padding: 1rem;
}

.login-card {
  background: rgba(255, 250, 242, 0.96);
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.login-brand {
  margin-bottom: 1.25rem;
}

.nav-logout {
  display: inline-flex;
}

.nav-logout button {
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 0.75rem;
  border-radius: 999px;
}

.nav-logout button:hover {
  background: rgba(69, 107, 79, 0.1);
  color: var(--ink);
}

@media (max-width: 720px) {
  .nav-logout button {
    white-space: nowrap;
  }
}

/* -------------------------------------------------------
   Phase 3B: Mobile Polish
------------------------------------------------------- */

:root {
  --mobile-nav-height: 4.8rem;
}

/* Better default tap behavior on phones */
button,
.button,
.day-cell,
.filter-chip,
.quick-add-button,
.nav a,
.nav-logout button {
  -webkit-tap-highlight-color: rgba(69, 107, 79, 0.18);
  touch-action: manipulation;
}

/* Active nav state for all screen sizes */
.nav a.active-nav-link {
  background: rgba(69, 107, 79, 0.12);
  color: var(--ink);
  font-weight: 800;
}

/* Slightly cleaner form spacing everywhere */
.entry-form input,
.entry-form select,
.entry-form textarea,
.category-form input,
.category-form select,
.month-export-form input {
  min-height: 2.9rem;
}

/* Mobile-first improvements */
@media (max-width: 720px) {
  body {
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
  }

  .site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 0.75rem 1rem;
    background: rgba(255, 250, 242, 0.96);
    backdrop-filter: blur(12px);
  }

  .brand {
    min-width: 0;
  }

  .brand-mark {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.75rem;
  }

  .brand strong {
    font-size: 1rem;
  }

  .brand small {
    font-size: 0.72rem;
  }

  /* Bottom nav bar */
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    gap: 0.35rem;
    width: 100%;
    padding: 0.45rem 0.55rem calc(0.45rem + env(safe-area-inset-bottom));
    overflow-x: auto;
    background: rgba(255, 250, 242, 0.98);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 22px rgba(40, 32, 24, 0.10);
    backdrop-filter: blur(14px);
  }

  .nav a,
  .nav-logout button {
    min-width: 4.75rem;
    min-height: 3rem;
    display: grid;
    place-items: center;
    text-align: center;
    border-radius: 0.95rem;
    font-size: 0.78rem;
    line-height: 1.1;
    padding: 0.55rem 0.65rem;
    background: transparent;
  }

  .nav a.active-nav-link {
    background: var(--accent);
    color: white;
  }

  .nav-logout {
    display: inline-flex;
    flex: 0 0 auto;
  }

  .nav-logout button {
    color: var(--danger);
    background: rgba(163, 58, 47, 0.08);
  }

  .page {
    padding: 0.85rem;
  }

  .calendar-shell,
  .dashboard-page,
  .narrow-page {
    gap: 0.85rem;
  }

  .calendar-main,
  .panel-card {
    border-radius: 1rem;
    padding: 0.85rem;
  }

  .calendar-toolbar {
    gap: 0.75rem;
  }

  .calendar-toolbar h1,
  .dashboard-hero h1,
  .panel-card h1 {
    font-size: clamp(1.65rem, 8vw, 2.35rem);
    line-height: 1;
  }

  .calendar-toolbar p,
  .panel-card p.muted,
  .dashboard-hero p {
    font-size: 0.92rem;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    width: 100%;
  }

  .toolbar-actions .button {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.55rem 0.5rem;
    font-size: 0.82rem;
  }

  /* Calendar becomes denser and more phone-friendly */
  .weekday-row {
    font-size: 0.68rem;
    padding-bottom: 0.35rem;
  }

  .weekday-row div {
    padding: 0.2rem;
    text-align: center;
  }

  .calendar-grid {
    gap: 0.25rem;
  }

  .day-cell {
    min-height: 4.15rem;
    border-radius: 0.75rem;
    padding: 0.35rem;
  }

  .day-number {
    font-size: 0.88rem;
  }

  .entry-count {
    min-width: 1.15rem;
    height: 1.15rem;
    font-size: 0.62rem;
  }

  .markers {
    gap: 0.15rem;
  }

  .marker {
    width: 1.05rem;
    height: 1.05rem;
    font-size: 0.56rem;
  }

  .heat-legend {
    justify-content: center;
    margin-top: 0.65rem;
  }

  /* Filter chips become a smooth horizontal scroller */
  .filter-bar {
    margin-left: -0.1rem;
    margin-right: -0.1rem;
    padding: 0.1rem 0.1rem 0.45rem;
    scroll-snap-type: x proximity;
  }

  .filter-chip {
    min-height: 2.4rem;
    scroll-snap-align: start;
  }

  /* Selected day panel */
  .day-panel {
    gap: 0.85rem;
  }

  .day-panel h2 {
    font-size: 1.35rem;
  }

  .quick-add-wrap {
    margin: 0.8rem 0;
    padding: 0.75rem;
  }

  .quick-add-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .quick-add-button {
    min-height: 3.15rem;
    border-radius: 0.85rem;
    font-size: 0.9rem;
    padding: 0.55rem;
  }

  .quick-add-icon {
    width: 1.85rem;
    height: 1.85rem;
  }

  .entry-form {
    gap: 0.65rem;
  }

  label {
    font-size: 0.84rem;
  }

  input,
  select,
  textarea {
    font-size: 16px; /* prevents iOS zoom-on-focus */
    border-radius: 0.75rem;
  }

  .entry-card {
    border-radius: 0.85rem;
    padding: 0.75rem;
  }

  .entry-head {
    gap: 0.55rem;
  }

  .entry-actions {
    justify-content: flex-start;
  }

  .entry-actions a,
  .entry-actions button {
    min-height: 2rem;
    padding: 0.25rem 0.35rem;
  }

  /* Dashboard polish */
  .dashboard-hero {
    padding: 1rem;
  }

  .dashboard-hero h1 {
    font-size: clamp(2rem, 11vw, 3.2rem);
  }

  .dashboard-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-actions .button {
    min-height: 3rem;
  }

  .dashboard-grid {
    gap: 0.85rem;
  }

  .dashboard-quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-quick-button {
    min-height: 3.5rem;
  }

  .mini-streak {
    min-height: 3.2rem;
  }

  /* Weekly review polish */
  .review-day {
    min-height: auto;
  }

  .review-day-head {
    align-items: center;
  }

  .review-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-row {
    gap: 0.75rem;
  }

  .summary-metrics span {
    font-size: 0.82rem;
  }

  /* Data page polish */
  .data-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .data-actions .button,
  .data-actions button {
    width: 100%;
    min-height: 3rem;
  }

  .month-export-form {
    grid-template-columns: 1fr;
  }

  .backup-row {
    align-items: stretch;
  }

  .backup-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .backup-actions .button,
  .backup-actions button {
    width: 100%;
  }

  /* Login page polish */
  .login-page {
    padding: 1rem;
  }

  .login-card {
    border-radius: 1.1rem;
  }
}

/* Very small phones */
@media (max-width: 420px) {
  .page {
    padding: 0.65rem;
  }

  .calendar-main,
  .panel-card {
    padding: 0.7rem;
  }

  .day-cell {
    min-height: 3.55rem;
    padding: 0.3rem;
  }

  .day-number {
    font-size: 0.8rem;
  }

  .entry-count {
    min-width: 1rem;
    height: 1rem;
    font-size: 0.56rem;
  }

  .marker {
    width: 0.9rem;
    height: 0.9rem;
    font-size: 0.5rem;
  }

  .quick-add-grid,
  .dashboard-quick-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    grid-template-columns: 1fr;
  }

  .dashboard-actions {
    grid-template-columns: 1fr;
  }

  .review-summary-grid {
    grid-template-columns: 1fr;
  }
}

/* Landscape phones */
@media (max-width: 900px) and (orientation: landscape) {
  .day-cell {
    min-height: 3.25rem;
  }

  .calendar-shell {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* -------------------------------------------------------
   Phase 3B.1: Mobile calendar page optimization
------------------------------------------------------- */

.mobile-month-strip {
  display: none;
}

@media (max-width: 720px) {
  /* On mobile, replace the cramped 7-column month grid with a horizontal day picker. */
  .calendar-main .weekday-row,
  .calendar-main .calendar-grid,
  .calendar-main .heat-legend {
    display: none;
  }

  .mobile-month-strip {
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    padding: 0.2rem 0.05rem 0.75rem;
    margin: 0 0 0.65rem;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-month-strip::-webkit-scrollbar {
    height: 0;
  }

  .mobile-day-card {
    --mobile-day-bg: white;
    flex: 0 0 4.15rem;
    min-height: 5.15rem;
    display: grid;
    grid-template-rows: auto auto auto 1fr;
    justify-items: center;
    align-items: center;
    gap: 0.16rem;
    text-decoration: none;
    color: var(--ink);
    background: var(--mobile-day-bg);
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 0.5rem 0.35rem;
    scroll-snap-align: center;
    box-shadow: 0 6px 14px rgba(40, 32, 24, 0.05);
  }

  .mobile-day-card.heat-1 {
    --mobile-day-bg:
      linear-gradient(0deg, rgba(69, 107, 79, 0.07), rgba(69, 107, 79, 0.07)),
      white;
  }

  .mobile-day-card.heat-2 {
    --mobile-day-bg:
      linear-gradient(0deg, rgba(69, 107, 79, 0.13), rgba(69, 107, 79, 0.13)),
      white;
  }

  .mobile-day-card.heat-3 {
    --mobile-day-bg:
      linear-gradient(0deg, rgba(69, 107, 79, 0.20), rgba(69, 107, 79, 0.20)),
      white;
  }

  .mobile-day-card.heat-4 {
    --mobile-day-bg:
      linear-gradient(0deg, rgba(69, 107, 79, 0.29), rgba(69, 107, 79, 0.29)),
      white;
  }

  .mobile-day-card.today {
    border-color: rgba(69, 107, 79, 0.55);
  }

  .mobile-day-card.selected {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 10px 22px rgba(69, 107, 79, 0.26);
    transform: translateY(-1px);
  }

  .mobile-day-weekday {
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .mobile-day-card.selected .mobile-day-weekday {
    color: rgba(255, 255, 255, 0.78);
  }

  .mobile-day-card strong {
    font-size: 1.3rem;
    line-height: 1;
  }

  .mobile-day-count {
    display: grid;
    place-items: center;
    min-width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    background: rgba(37, 34, 31, 0.82);
    color: white;
    font-size: 0.68rem;
    font-weight: 850;
  }

  .mobile-day-count.empty {
    background: rgba(37, 34, 31, 0.08);
    color: transparent;
  }

  .mobile-day-card.selected .mobile-day-count {
    background: rgba(255, 255, 255, 0.22);
    color: white;
  }

  .mobile-day-markers {
    display: flex;
    justify-content: center;
    gap: 0.13rem;
    min-height: 0.45rem;
  }

  .mobile-day-markers i {
    width: 0.42rem;
    height: 0.42rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.35);
  }

  /* Make the calendar page itself read like a phone app. */
  .calendar-shell {
    display: flex;
    flex-direction: column;
  }

  .calendar-main {
    order: 1;
  }

  .day-panel {
    order: 2;
  }

  .calendar-toolbar {
    margin-bottom: 0.7rem;
  }

  .calendar-toolbar h1 {
    margin-bottom: 0.25rem;
  }

  .filter-bar {
    margin-bottom: 0.65rem;
  }

  .day-panel .panel-card:first-child {
    border-top: 0.35rem solid var(--accent);
  }

  .day-panel h2 {
    line-height: 1.05;
  }
}

@media (max-width: 420px) {
  .mobile-day-card {
    flex-basis: 3.75rem;
    min-height: 4.85rem;
    border-radius: 0.9rem;
  }

  .mobile-day-card strong {
    font-size: 1.15rem;
  }

  .mobile-day-weekday {
    font-size: 0.62rem;
  }
}

/* -------------------------------------------------------
   Phase 3B.2: Correct mobile calendar grid fix
   Keeps the real month grid; removes the failed date strip.
------------------------------------------------------- */

@media (max-width: 720px) {
  .mobile-month-strip {
    display: none !important;
  }

  .calendar-main .weekday-row {
    display: grid !important;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.18rem;
    padding: 0 0 0.35rem;
    font-size: 0.62rem;
    text-align: center;
  }

  .calendar-main .weekday-row div {
    padding: 0;
  }

  .calendar-main .calendar-grid {
    display: grid !important;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.18rem !important;
  }

  .calendar-main .heat-legend {
    display: flex !important;
  }

  .calendar-main {
    overflow: hidden;
  }

  .day-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    min-height: 0 !important;
    border-radius: 0.6rem !important;
    padding: 0.25rem !important;
    justify-content: flex-start !important;
    gap: 0.1rem;
  }

  .day-cell.outside {
    opacity: 0.22;
  }

  .day-cell.today {
    outline: 1.5px solid rgba(69, 107, 79, 0.4);
  }

  .day-cell.selected {
    background: var(--accent) !important;
    color: white;
    border-color: var(--accent);
    box-shadow: 0 5px 12px rgba(69, 107, 79, 0.25);
  }

  .day-topline {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
  }

  .day-number {
    font-size: 0.76rem;
    line-height: 1;
  }

  .entry-count {
    position: absolute;
    top: 0.18rem;
    right: 0.18rem;
    min-width: 0.9rem;
    height: 0.9rem;
    font-size: 0.5rem;
    line-height: 1;
    background: rgba(37, 34, 31, 0.78);
  }

  .day-cell.selected .entry-count {
    background: rgba(255, 255, 255, 0.24);
    color: white;
  }

  .markers {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.12rem;
    align-items: center;
    justify-content: flex-start;
  }

  .marker {
    width: 0.36rem !important;
    height: 0.36rem !important;
    min-width: 0.36rem;
    border-radius: 999px;
    font-size: 0 !important;
    color: transparent !important;
    box-shadow: none !important;
  }

  .marker:nth-child(n+5) {
    display: none;
  }

  .calendar-toolbar {
    margin-bottom: 0.65rem;
  }

  .calendar-toolbar h1 {
    font-size: 1.75rem;
  }

  .calendar-toolbar .muted {
    font-size: 0.86rem;
  }

  .filter-bar {
    margin-bottom: 0.65rem;
  }

  .heat-legend {
    margin-top: 0.55rem;
    justify-content: center;
    font-size: 0.68rem;
  }

  .heat-swatch {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 0.22rem;
  }
}

@media (max-width: 420px) {
  .calendar-main {
    padding: 0.55rem !important;
  }

  .calendar-main .calendar-grid {
    gap: 0.14rem !important;
  }

  .day-cell {
    border-radius: 0.48rem !important;
    padding: 0.2rem !important;
  }

  .day-number {
    font-size: 0.68rem;
  }

  .entry-count {
    min-width: 0.78rem;
    height: 0.78rem;
    font-size: 0.46rem;
  }

  .marker {
    width: 0.3rem !important;
    height: 0.3rem !important;
    min-width: 0.3rem;
  }
}

/* -------------------------------------------------------
   Phase 3B.3: Selected-day panel mobile polish
------------------------------------------------------- */

.selected-day-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.9rem;
  margin-bottom: 0.75rem;
}

.selected-day-header h2 {
  margin-bottom: 0.2rem;
}

.selected-day-pill {
  flex: 0 0 auto;
  min-width: 4.5rem;
  border-radius: 1rem;
  border: 1px solid rgba(69, 107, 79, 0.22);
  background: rgba(69, 107, 79, 0.08);
  padding: 0.55rem 0.65rem;
  text-align: center;
}

.selected-day-pill strong {
  display: block;
  font-size: 1.4rem;
  line-height: 1;
}

.selected-day-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.2rem;
}

.detailed-entry-details {
  margin-top: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: white;
  overflow: hidden;
}

.detailed-entry-details summary {
  list-style: none;
  cursor: pointer;
  padding: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-weight: 850;
}

.detailed-entry-details summary::-webkit-details-marker {
  display: none;
}

.detailed-entry-details summary::after {
  content: "+";
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(69, 107, 79, 0.1);
  color: var(--accent);
  font-size: 1.1rem;
  line-height: 1;
}

.detailed-entry-details[open] summary::after {
  content: "–";
}

.detailed-entry-details summary small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  margin-top: 0.15rem;
}

.detailed-entry-details .entry-form {
  padding: 0 0.85rem 0.85rem;
}

@media (max-width: 720px) {
  .selected-day-header {
    align-items: center;
    margin-bottom: 0.65rem;
  }

  .selected-day-header h2 {
    font-size: 1.25rem;
    line-height: 1.05;
  }

  .selected-day-header .muted {
    font-size: 0.82rem;
    margin: 0;
  }

  .selected-day-pill {
    min-width: 3.9rem;
    border-radius: 0.85rem;
    padding: 0.45rem 0.55rem;
  }

  .selected-day-pill strong {
    font-size: 1.25rem;
  }

  .selected-day-pill span {
    font-size: 0.62rem;
  }

  .quick-add-wrap {
    background: rgba(69, 107, 79, 0.09);
  }

  .quick-add-wrap h3 {
    font-size: 0.95rem;
    margin-bottom: 0.55rem;
  }

  .quick-add-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-add-button {
    justify-content: center;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 4.15rem;
    font-size: 0.84rem;
    line-height: 1.1;
  }

  .quick-add-icon {
    width: 2rem;
    height: 2rem;
  }

  .detailed-entry-details {
    margin-top: 0.75rem;
    border-radius: 0.9rem;
  }

  .detailed-entry-details summary {
    min-height: 3.35rem;
    padding: 0.75rem;
  }

  .detailed-entry-details summary span {
    font-size: 0.95rem;
  }

  .detailed-entry-details summary small {
    font-size: 0.68rem;
  }

  .detailed-entry-details .entry-form {
    padding: 0 0.75rem 0.75rem;
  }

  /* Make entries easier to scan and tap on phone */
  .day-panel .panel-card:nth-child(2) h3 {
    margin-bottom: 0.65rem;
  }

  .entry-list {
    gap: 0.6rem;
  }

  .entry-card {
    padding: 0.8rem;
    border-radius: 0.9rem;
  }

  .entry-head {
    align-items: flex-start;
  }

  .entry-head strong {
    font-size: 0.98rem;
  }

  .entry-head span {
    font-size: 0.86rem;
  }

  .entry-actions {
    min-width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 0.65rem;
  }

  .entry-actions a,
  .entry-actions button {
    width: 100%;
    min-height: 2.45rem;
    border-radius: 0.75rem;
    background: rgba(40, 32, 24, 0.05);
    display: grid;
    place-items: center;
    text-decoration: none;
  }

  .entry-actions button {
    background: rgba(163, 58, 47, 0.09);
  }

  .entry-meta,
  .tags {
    font-size: 0.82rem;
  }

  .entry-card p {
    font-size: 0.93rem;
    line-height: 1.35;
  }
}

@media (max-width: 420px) {
  .selected-day-header {
    gap: 0.55rem;
  }

  .selected-day-header h2 {
    font-size: 1.12rem;
  }

  .selected-day-pill {
    min-width: 3.4rem;
    padding: 0.4rem;
  }

  .quick-add-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.38rem;
  }

  .quick-add-button {
    min-height: 3.85rem;
  }
}

/* -------------------------------------------------------
   Phase 2E / 4B: Habit Goals
------------------------------------------------------- */

.goal-form,
.goal-edit-form {
  display: grid;
  gap: 0.75rem;
}

.goal-form {
  grid-template-columns: 1.2fr 1.4fr 1.2fr 0.7fr 0.8fr auto;
  align-items: end;
}

.goal-notes-field {
  grid-column: 1 / -1;
}

.goal-list {
  display: grid;
  gap: 0.85rem;
}

.goal-card {
  background: white;
  border: 1px solid var(--line);
  border-left: 0.45rem solid var(--cat-color);
  border-radius: 1rem;
  padding: 0.95rem;
}

.goal-card.inactive {
  opacity: 0.58;
}

.goal-card-head,
.goal-mini-head,
.section-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.section-head-row {
  margin-bottom: 0.75rem;
}

.section-head-row a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.goal-percent {
  flex: 0 0 auto;
  min-width: 3.4rem;
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  background: rgba(40, 32, 24, 0.07);
  color: var(--muted);
  text-align: center;
  font-weight: 850;
}

.goal-percent.complete {
  background: rgba(69, 107, 79, 0.14);
  color: var(--accent);
}

.goal-progress-bar {
  height: 0.65rem;
  background: rgba(40, 32, 24, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.75rem 0 0.55rem;
}

.goal-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--cat-color);
  border-radius: inherit;
}

.goal-progress-copy {
  color: var(--muted);
  margin-bottom: 0;
}

.goal-progress-copy strong {
  color: var(--ink);
}

.goal-edit-details {
  margin-top: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
}

.goal-edit-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 850;
}

.goal-edit-form {
  margin-top: 0.75rem;
  grid-template-columns: 1.2fr 1.4fr 1.2fr 0.7fr 0.8fr auto;
  align-items: end;
}

.goal-card-actions {
  display: flex;
  gap: 0.5rem;
}

.goal-delete-button {
  margin-top: 0.6rem;
}

.goal-progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.65rem;
}

.goal-mini-card {
  background: white;
  border: 1px solid var(--line);
  border-top: 0.35rem solid var(--cat-color);
  border-radius: 1rem;
  padding: 0.8rem;
}

.goal-mini-card.complete {
  background:
    linear-gradient(0deg, rgba(69, 107, 79, 0.06), rgba(69, 107, 79, 0.06)),
    white;
}

.goal-mini-head strong {
  font-size: 0.92rem;
}

.goal-mini-head span {
  color: var(--accent);
  font-weight: 850;
}

.dashboard-goals-panel {
  grid-column: 1 / -1;
}

.review-goals-panel {
  max-width: 96rem;
}

@media (max-width: 900px) {
  .goal-form,
  .goal-edit-form {
    grid-template-columns: 1fr;
  }

  .goal-notes-field {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .goal-card {
    border-radius: 0.9rem;
    padding: 0.85rem;
  }

  .goal-card-head,
  .goal-mini-head,
  .section-head-row {
    align-items: flex-start;
  }

  .goal-progress-grid {
    grid-template-columns: 1fr;
  }

  .goal-mini-card {
    border-radius: 0.9rem;
  }

  .goal-form {
    gap: 0.65rem;
  }

  .goal-edit-form {
    gap: 0.65rem;
  }

  .goal-edit-details summary {
    min-height: 2.6rem;
    display: flex;
    align-items: center;
  }
}

/* -------------------------------------------------------
   Phase 4C: Mobile More menu
------------------------------------------------------- */

.nav-more-mobile {
  display: none;
}

.more-page {
  max-width: 48rem;
}

.more-grid {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.more-card {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  text-decoration: none;
  background: white;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.9rem;
}

.more-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(40, 32, 24, 0.08);
}

.more-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.9rem;
  background: rgba(69, 107, 79, 0.1);
}

.more-card strong {
  display: block;
  margin-bottom: 0.15rem;
}

.more-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.more-logout-button {
  width: 100%;
  min-height: 3rem;
}

@media (max-width: 720px) {
  .nav-more-mobile {
    display: grid;
  }

  .nav .nav-extra {
    display: none;
  }

  .nav {
    justify-content: space-around;
  }

  .nav a,
  .nav-logout button {
    min-width: 4.2rem;
  }

  .more-grid {
    gap: 0.65rem;
  }

  .more-card {
    min-height: 4.8rem;
    border-radius: 0.95rem;
    padding: 0.85rem;
  }

  .more-icon {
    width: 2.25rem;
    height: 2.25rem;
  }
}

/* -------------------------------------------------------
   Phase 4D: Quick-add presets
------------------------------------------------------- */

.preset-form,
.preset-edit-form {
  display: grid;
  grid-template-columns: 1.1fr 1.1fr 1.2fr 0.65fr 0.75fr 0.55fr auto;
  gap: 0.75rem;
  align-items: end;
}

.preset-wide {
  grid-column: 1 / -1;
}

.preset-list {
  display: grid;
  gap: 0.85rem;
}

.preset-card {
  background: white;
  border: 1px solid var(--line);
  border-left: 0.45rem solid var(--cat-color);
  border-radius: 1rem;
  padding: 0.95rem;
}

.preset-card.inactive {
  opacity: 0.58;
}

.preset-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.preset-edit-details {
  margin-top: 0.8rem;
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
}

.preset-edit-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 850;
}

.preset-edit-form {
  margin-top: 0.75rem;
}

.preset-delete-button {
  margin-top: 0.6rem;
}

.quick-section-label {
  margin: 0.75rem 0 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.preset-add-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.5rem;
}

.preset-add-button {
  width: 100%;
  min-height: 3.35rem;
  border-radius: 0.9rem;
  background:
    linear-gradient(0deg, rgba(69, 107, 79, 0.05), rgba(69, 107, 79, 0.05)),
    white;
  color: var(--ink);
  border: 1px solid var(--line);
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  display: grid;
  grid-template-columns: auto 1fr;
  text-align: left;
}

.preset-add-button:hover {
  border-color: var(--cat-color);
  box-shadow: 0 6px 16px rgba(40, 32, 24, 0.08);
}

.preset-add-button span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  background: var(--cat-color);
  color: white;
}

.preset-add-button strong {
  line-height: 1.1;
}

.preset-add-button small {
  color: var(--muted);
  font-weight: 700;
}

.dashboard-preset-grid {
  margin-bottom: 0.5rem;
}

@media (max-width: 900px) {
  .preset-form,
  .preset-edit-form {
    grid-template-columns: 1fr;
  }

  .preset-wide {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .preset-card {
    border-radius: 0.9rem;
    padding: 0.85rem;
  }

  .preset-add-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preset-add-button {
    min-height: 4.15rem;
    border-radius: 0.85rem;
    padding: 0.55rem;
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 0.25rem;
  }

  .preset-add-button span {
    grid-row: auto;
    width: 2rem;
    height: 2rem;
  }

  .preset-add-button strong {
    font-size: 0.84rem;
  }

  .preset-add-button small {
    font-size: 0.72rem;
  }

  .preset-edit-details summary {
    min-height: 2.6rem;
    display: flex;
    align-items: center;
  }
}

@media (max-width: 420px) {
  .preset-add-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.38rem;
  }

  .preset-add-button {
    min-height: 3.85rem;
  }
}

/* -------------------------------------------------------
   Phase 4E: Automated backup status
------------------------------------------------------- */

.backup-status-card {
  background:
    linear-gradient(0deg, rgba(69, 107, 79, 0.07), rgba(69, 107, 79, 0.07)),
    white;
  border: 1px solid rgba(69, 107, 79, 0.18);
  border-radius: 1rem;
  padding: 0.9rem;
  margin: 1rem 0;
}

.backup-status-card p {
  margin: 0.3rem 0 0;
}

/* -------------------------------------------------------
   Phase 4F: Weekly Review Intelligence + Better Charts
------------------------------------------------------- */

.intelligence-panel {
  border-top: 0.35rem solid var(--accent);
}

.intelligence-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.score-ring {
  --score: 0%;
  flex: 0 0 auto;
  width: 5.6rem;
  height: 5.6rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--card) 58%, transparent 59%),
    conic-gradient(var(--accent) var(--score), rgba(40, 32, 24, 0.1) 0);
  border: 1px solid rgba(69, 107, 79, 0.15);
  text-align: center;
}

.score-ring strong {
  font-size: 1.65rem;
  line-height: 1;
}

.score-ring span {
  margin-top: -1.4rem;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 800;
}

.intelligence-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
}

.intel-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem;
}

.intel-card strong {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.intel-card p {
  font-size: 1.1rem;
  font-weight: 850;
  margin: 0.4rem 0 0.15rem;
}

.intel-card small {
  color: var(--muted);
}

.weekly-value-totals {
  margin-top: 1rem;
}

.weekly-value-totals h3,
.focus-box h3 {
  margin-bottom: 0.55rem;
}

.value-total-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.value-total-list span {
  border: 1px solid rgba(69, 107, 79, 0.16);
  background: rgba(69, 107, 79, 0.07);
  border-left: 0.35rem solid var(--cat-color);
  border-radius: 999px;
  padding: 0.45rem 0.65rem;
  color: var(--muted);
}

.value-total-list strong {
  color: var(--ink);
}

.focus-box {
  margin-top: 1rem;
  background: rgba(40, 32, 24, 0.04);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem;
}

.focus-box ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.focus-box li + li {
  margin-top: 0.3rem;
}

.charts-panel {
  overflow: hidden;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.chart-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.9rem;
}

.wide-chart {
  grid-column: 1 / -1;
}

.chart-card h3 {
  margin-bottom: 0.75rem;
}

.daily-bar-chart {
  height: 8.5rem;
  display: grid;
  grid-template-columns: repeat(30, minmax(0, 1fr));
  gap: 0.18rem;
  align-items: end;
  padding: 0.45rem;
  background: rgba(40, 32, 24, 0.035);
  border-radius: 0.85rem;
}

.daily-bar-wrap {
  height: 100%;
  display: flex;
  align-items: end;
}

.daily-bar {
  display: block;
  width: 100%;
  min-height: 0.25rem;
  border-radius: 999px 999px 0.2rem 0.2rem;
  background: rgba(40, 32, 24, 0.12);
}

.daily-bar.active {
  background: var(--accent);
}

.horizontal-chart {
  display: grid;
  gap: 0.6rem;
}

.h-chart-row {
  --cat-color: var(--accent);
  display: grid;
  grid-template-columns: minmax(5rem, 8rem) 1fr auto;
  gap: 0.55rem;
  align-items: center;
}

.h-chart-label {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.h-chart-track {
  height: 0.7rem;
  background: rgba(40, 32, 24, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.h-chart-track span {
  display: block;
  height: 100%;
  background: var(--cat-color);
  border-radius: inherit;
}

.h-chart-value {
  min-width: 1.8rem;
  text-align: right;
  color: var(--muted);
  font-weight: 850;
}

.goal-chart-list {
  display: grid;
  gap: 0.65rem;
}

.goal-chart-row {
  border: 1px solid var(--line);
  border-left: 0.35rem solid var(--cat-color);
  border-radius: 0.9rem;
  padding: 0.75rem;
}

.goal-chart-row.complete {
  background: rgba(69, 107, 79, 0.06);
}

.goal-chart-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.goal-chart-head span {
  color: var(--accent);
  font-weight: 850;
}

@media (max-width: 900px) {
  .intelligence-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .intelligence-head {
    align-items: center;
  }

  .score-ring {
    width: 4.7rem;
    height: 4.7rem;
  }

  .score-ring strong {
    font-size: 1.35rem;
  }

  .intelligence-grid {
    grid-template-columns: 1fr;
  }

  .intel-card {
    border-radius: 0.9rem;
    padding: 0.8rem;
  }

  .daily-bar-chart {
    height: 7rem;
    gap: 0.12rem;
    padding: 0.35rem;
  }

  .h-chart-row {
    grid-template-columns: minmax(4.8rem, 6.8rem) 1fr auto;
    gap: 0.45rem;
  }

  .h-chart-label {
    font-size: 0.78rem;
  }
}

@media (max-width: 420px) {
  .intelligence-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .score-ring {
    width: 100%;
    height: auto;
    min-height: 4rem;
    border-radius: 1rem;
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    background: rgba(69, 107, 79, 0.08);
  }

  .score-ring span {
    margin-top: 0.3rem;
  }

  .daily-bar-chart {
    height: 6rem;
  }
}

/* -------------------------------------------------------
   Phase 4G: Category analytics exclusions
------------------------------------------------------- */

.category-row {
  grid-template-columns: 1.6fr 5rem 0.8fr 0.9fr auto auto auto auto;
}

.category-form {
  grid-template-columns: 1.6fr 7rem 0.8fr 0.9fr auto auto auto;
}

@media (max-width: 980px) {
  .category-form,
  .category-row {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------
   Phase 4H: Health / Status page
------------------------------------------------------- */

.status-page {
  max-width: 72rem;
}

.status-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.status-hero.ok {
  border-top: 0.35rem solid var(--accent);
}

.status-hero.warn {
  border-top: 0.35rem solid var(--danger);
}

.status-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  font-weight: 900;
}

.status-badge.ok {
  background: rgba(69, 107, 79, 0.12);
  color: var(--accent);
}

.status-badge.warn {
  background: rgba(163, 58, 47, 0.1);
  color: var(--danger);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.status-card.ok {
  border-top: 0.3rem solid var(--accent);
}

.status-card.warn {
  border-top: 0.3rem solid var(--danger);
}

.status-line {
  margin: 0.35rem 0;
}

.status-error {
  color: var(--danger);
  font-weight: 750;
}

.status-count-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.status-count-grid div {
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.75rem;
  text-align: center;
}

.status-count-grid strong {
  display: block;
  font-size: 1.55rem;
  line-height: 1;
}

.status-count-grid span {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.service-list {
  display: grid;
  gap: 0.55rem;
}

.service-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  background: white;
  border: 1px solid var(--line);
  border-left: 0.35rem solid var(--muted);
  border-radius: 0.9rem;
  padding: 0.75rem;
}

.service-row.ok {
  border-left-color: var(--accent);
}

.service-row.warn {
  border-left-color: var(--danger);
}

.service-row p {
  margin: 0.2rem 0 0;
}

.service-row span {
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--muted);
}

.service-row.ok span {
  color: var(--accent);
}

.service-row.warn span {
  color: var(--danger);
}

.status-link-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

@media (max-width: 800px) {
  .status-grid {
    grid-template-columns: 1fr;
  }

  .status-hero {
    flex-direction: column;
  }

  .status-link-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .status-link-grid .button {
    width: 100%;
  }
}

/* -------------------------------------------------------
   Phase 4I: Settings page
------------------------------------------------------- */

.settings-page {
  max-width: 52rem;
}

.settings-form {
  display: grid;
  gap: 1rem;
}

.settings-section {
  background: white;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.95rem;
  display: grid;
  gap: 0.75rem;
}

.settings-section h2 {
  margin-bottom: 0.2rem;
}

.settings-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  background: rgba(40, 32, 24, 0.035);
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 0.75rem;
}

.settings-toggle input {
  width: auto;
  margin-top: 0.2rem;
}

.settings-toggle strong {
  display: block;
  color: var(--ink);
}

.settings-toggle small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.accent-preview-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.accent-dot {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(40, 32, 24, 0.18);
}

.settings-future-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.settings-future-list span {
  background: rgba(40, 32, 24, 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.6rem;
  font-weight: 750;
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  .settings-section {
    border-radius: 0.9rem;
    padding: 0.8rem;
  }

  .settings-toggle {
    border-radius: 0.8rem;
  }
}

/* -------------------------------------------------------
   Phase 4J: Daily Note / Journal mode
------------------------------------------------------- */

.journal-page {
  max-width: 76rem;
}

.journal-hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  border-top: 0.35rem solid var(--accent);
}

.journal-date-actions {
  flex: 0 0 auto;
}

.journal-form {
  display: grid;
  gap: 0.85rem;
}

.journal-ratings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.journal-delete-form {
  margin-top: 0.85rem;
}

.journal-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
}

.recent-note-list {
  display: grid;
  gap: 0.55rem;
}

.recent-note-card {
  display: grid;
  gap: 0.2rem;
  text-decoration: none;
  background: white;
  border: 1px solid var(--line);
  border-left: 0.35rem solid var(--line);
  border-radius: 0.9rem;
  padding: 0.75rem;
}

.recent-note-card.active {
  border-left-color: var(--accent);
  background: rgba(69, 107, 79, 0.06);
}

.recent-note-card span,
.recent-note-card small {
  color: var(--muted);
}

.dashboard-journal-card {
  grid-column: 1 / -1;
  border-top: 0.3rem solid var(--accent);
}

.journal-mini-ratings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.journal-mini-ratings span {
  background: rgba(69, 107, 79, 0.08);
  border: 1px solid rgba(69, 107, 79, 0.16);
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.8rem;
}

.selected-day-journal-link {
  margin: 0.65rem 0 0.75rem;
}

.selected-day-journal-link a {
  display: block;
  text-decoration: none;
  border: 1px solid rgba(69, 107, 79, 0.18);
  background: rgba(69, 107, 79, 0.07);
  color: var(--accent);
  font-weight: 850;
  border-radius: 0.85rem;
  padding: 0.65rem 0.75rem;
}

@media (max-width: 900px) {
  .journal-grid {
    grid-template-columns: 1fr;
  }

  .journal-ratings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .journal-hero {
    flex-direction: column;
  }

  .journal-date-actions {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .journal-ratings-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
  }

  .journal-date-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .journal-date-actions .button {
    width: 100%;
  }
}

/* -------------------------------------------------------
   Phase 4K: PWA + Visual Polish
------------------------------------------------------- */

html {
  color-scheme: light;
}

body {
  min-height: 100vh;
}

.app-mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(69, 107, 79, 0.18);
  background: rgba(69, 107, 79, 0.08);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 850;
  margin-bottom: 0.7rem;
}

.app-mini-badge img {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 0.35rem;
}

.login-icon {
  width: 3.1rem;
  height: 3.1rem;
  border-radius: 1rem;
  box-shadow: 0 10px 24px rgba(40, 32, 24, 0.12);
}

.login-card h1 {
  font-size: clamp(2rem, 8vw, 2.8rem);
  margin-bottom: 0.3rem;
}

.panel-card {
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.more-card,
.quick-add-button,
.preset-add-button,
.button.secondary {
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, background-color 140ms ease;
}

.more-card:hover,
.quick-add-button:hover,
.preset-add-button:hover,
.button.secondary:hover {
  transform: translateY(-1px);
}

.button.primary {
  box-shadow: 0 8px 18px rgba(69, 107, 79, 0.16);
}

.button.primary:hover {
  box-shadow: 0 10px 22px rgba(69, 107, 79, 0.22);
}

.empty-state {
  border: 1px dashed rgba(40, 32, 24, 0.18);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 1rem;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.soft-divider {
  height: 1px;
  background: var(--line);
  margin: 0.85rem 0;
}

.site-header {
  box-shadow: 0 3px 18px rgba(40, 32, 24, 0.045);
}

.brand-mark {
  box-shadow: 0 8px 20px rgba(69, 107, 79, 0.18);
}

.dashboard-hero {
  background:
    radial-gradient(circle at top right, rgba(69, 107, 79, 0.16), transparent 18rem),
    rgba(255, 250, 242, 0.94);
}

.dashboard-hero .muted {
  max-width: 38rem;
}

@media (display-mode: standalone) {
  .site-header {
    padding-top: calc(0.75rem + env(safe-area-inset-top));
  }

  @media (max-width: 720px) {
    .nav {
      padding-bottom: calc(0.55rem + env(safe-area-inset-bottom));
    }
  }
}

@media (max-width: 720px) {
  .login-icon {
    width: 3.4rem;
    height: 3.4rem;
  }

  .app-mini-badge {
    margin-bottom: 0.6rem;
  }

  .dashboard-hero {
    border-top: 0.35rem solid var(--accent);
  }

  .panel-card {
    box-shadow: 0 8px 18px rgba(40, 32, 24, 0.06);
  }

  .more-card:hover,
  .quick-add-button:hover,
  .preset-add-button:hover,
  .button.secondary:hover {
    transform: none;
  }
}

/* -------------------------------------------------------
   Phase 4L: Change PIN / Password
------------------------------------------------------- */

.security-page {
  max-width: 48rem;
}

.security-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-top: 0.35rem solid var(--accent);
}

.security-status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  background: rgba(69, 107, 79, 0.1);
  color: var(--accent);
  font-weight: 900;
}

.security-form {
  display: grid;
  gap: 0.85rem;
}

.security-note-list {
  display: grid;
  gap: 0.65rem;
}

.security-note-list article {
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.8rem;
}

.security-note-list p {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

@media (max-width: 720px) {
  .security-hero {
    flex-direction: column;
  }
}

/* -------------------------------------------------------
   Phase 4M: Yesterday Correction / Backfill Shortcuts
------------------------------------------------------- */

.yesterday-correction-card {
  border-top: 0.35rem solid var(--accent);
}

.yesterday-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.yesterday-details {
  margin-top: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: white;
  overflow: hidden;
}

.yesterday-details summary {
  list-style: none;
  cursor: pointer;
  padding: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-weight: 850;
}

.yesterday-details summary::-webkit-details-marker {
  display: none;
}

.yesterday-details summary::after {
  content: "+";
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(69, 107, 79, 0.1);
  color: var(--accent);
  font-size: 1.1rem;
  line-height: 1;
}

.yesterday-details[open] summary::after {
  content: "–";
}

.yesterday-details summary small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  margin-top: 0.15rem;
}

.yesterday-preset-grid,
.yesterday-quick-grid {
  padding: 0 0.85rem 0.85rem;
}

.yesterday-details .quick-section-label {
  padding: 0 0.85rem;
}

.yesterday-entry-preview {
  margin-top: 0.85rem;
}

.yesterday-entry-preview h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.mini-entry-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.mini-entry-row span {
  border: 1px solid rgba(69, 107, 79, 0.16);
  background: rgba(69, 107, 79, 0.07);
  border-left: 0.35rem solid var(--cat-color);
  border-radius: 999px;
  padding: 0.4rem 0.6rem;
  color: var(--muted);
  font-weight: 750;
  font-size: 0.82rem;
}

@media (max-width: 720px) {
  .yesterday-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .yesterday-actions .button {
    width: 100%;
  }

  .yesterday-details summary {
    align-items: flex-start;
  }

  .yesterday-preset-grid,
  .yesterday-quick-grid {
    padding: 0 0.75rem 0.75rem;
  }

  .yesterday-details .quick-section-label {
    padding: 0 0.75rem;
  }

  .mini-entry-row span {
    border-radius: 0.8rem;
    width: 100%;
  }
}

/* -------------------------------------------------------
   Phase 4N: Preset Groups
------------------------------------------------------- */

.preset-group-list {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.preset-group {
  --cat-color: var(--accent);
  border: 1px solid var(--line);
  border-left: 0.35rem solid var(--cat-color);
  border-radius: 0.95rem;
  background: white;
  overflow: hidden;
}

.preset-group summary {
  list-style: none;
  cursor: pointer;
  min-height: 3rem;
  padding: 0.65rem 0.75rem;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.55rem;
}

.preset-group summary::-webkit-details-marker {
  display: none;
}

.preset-group summary::after {
  content: "+";
  width: 1.55rem;
  height: 1.55rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(69, 107, 79, 0.1);
  color: var(--accent);
  font-weight: 900;
}

.preset-group[open] summary::after {
  content: "–";
}

.preset-group-icon {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: var(--cat-color);
  color: white;
  font-size: 0.9rem;
}

.preset-group summary strong {
  line-height: 1.1;
}

.preset-group summary small {
  display: grid;
  place-items: center;
  min-width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: rgba(40, 32, 24, 0.06);
  color: var(--muted);
  font-weight: 850;
}

.preset-group .preset-add-grid {
  padding: 0 0.65rem 0.65rem;
}

.dashboard-preset-groups .preset-group[open] {
  background:
    linear-gradient(0deg, rgba(69, 107, 79, 0.035), rgba(69, 107, 79, 0.035)),
    white;
}

@media (max-width: 720px) {
  .preset-group-list {
    gap: 0.55rem;
  }

  .preset-group {
    border-radius: 0.85rem;
  }

  .preset-group summary {
    min-height: 3.15rem;
    padding: 0.6rem 0.65rem;
  }

  .preset-group-icon {
    width: 1.8rem;
    height: 1.8rem;
  }

  .preset-group .preset-add-grid {
    padding: 0 0.55rem 0.55rem;
  }
}

/* -------------------------------------------------------
   Phase 4O: Yearly Heatmap
------------------------------------------------------- */

.heatmap-page {
  max-width: 86rem;
}

.heatmap-hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  border-top: 0.35rem solid var(--accent);
}

.heatmap-year-actions {
  flex: 0 0 auto;
}

.heatmap-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.heatmap-scroll-wrap {
  overflow-x: auto;
  padding-bottom: 0.35rem;
  -webkit-overflow-scrolling: touch;
}

.year-heatmap {
  display: grid;
  grid-template-columns: 2.5rem auto;
  gap: 0.45rem;
  min-width: 52rem;
}

.year-heatmap-weekdays {
  display: grid;
  grid-template-rows: repeat(7, 1rem);
  gap: 0.22rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  align-items: center;
}

.year-heatmap-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1rem);
  grid-auto-columns: 1rem;
  gap: 0.22rem;
}

.heatmap-day {
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
  background: white;
  border: 1px solid var(--line);
  text-decoration: none;
}

.heatmap-day.heat-1 {
  background: rgba(69, 107, 79, 0.18);
}

.heatmap-day.heat-2 {
  background: rgba(69, 107, 79, 0.34);
}

.heatmap-day.heat-3 {
  background: rgba(69, 107, 79, 0.56);
}

.heatmap-day.heat-4 {
  background: rgba(69, 107, 79, 0.82);
}

.heatmap-day.outside {
  opacity: 0.22;
}

.heatmap-day.today {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.heatmap-day:hover {
  transform: scale(1.18);
  box-shadow: 0 5px 14px rgba(40, 32, 24, 0.16);
}

.heatmap-month-chart {
  margin-top: 0.75rem;
}

@media (max-width: 900px) {
  .heatmap-hero {
    flex-direction: column;
  }

  .heatmap-year-actions {
    width: 100%;
  }

  .heatmap-summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .heatmap-page {
    max-width: 100%;
  }

  .year-heatmap {
    min-width: 48rem;
  }

  .heatmap-scroll-wrap {
    margin-left: -0.2rem;
    margin-right: -0.2rem;
  }

  .heatmap-year-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
  }

  .heatmap-year-actions .button {
    width: 100%;
  }

  .heatmap-day:hover {
    transform: none;
    box-shadow: none;
  }
}

@media (max-width: 420px) {
  .heatmap-year-actions {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------
   Phase 4O.1: Mobile Heatmap Optimization
------------------------------------------------------- */

.mobile-heatmap-months {
  display: none;
}

@media (max-width: 720px) {
  .desktop-year-heatmap-panel {
    display: none;
  }

  .mobile-heatmap-months {
    display: grid;
    gap: 0.85rem;
  }

  .mobile-month-card {
    padding: 0.8rem;
  }

  .mobile-month-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
  }

  .mobile-month-head h2 {
    margin: 0 0 0.15rem;
    font-size: 1.25rem;
  }

  .mobile-month-head .button {
    flex: 0 0 auto;
    min-height: 2.4rem;
    padding: 0.45rem 0.65rem;
  }

  .mobile-month-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.18rem;
    margin-bottom: 0.25rem;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 850;
    text-align: center;
  }

  .mobile-month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.18rem;
  }

  .mobile-month-day {
    aspect-ratio: 1 / 1;
    min-height: 2.15rem;
    border-radius: 0.55rem;
    display: grid;
    place-items: center;
    text-decoration: none;
    background: white;
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 0.72rem;
    font-weight: 800;
  }

  .mobile-month-day.heat-1 {
    background: rgba(69, 107, 79, 0.18);
  }

  .mobile-month-day.heat-2 {
    background: rgba(69, 107, 79, 0.34);
  }

  .mobile-month-day.heat-3 {
    background: rgba(69, 107, 79, 0.56);
    color: white;
  }

  .mobile-month-day.heat-4 {
    background: rgba(69, 107, 79, 0.82);
    color: white;
  }

  .mobile-month-day.outside {
    opacity: 0.18;
  }

  .mobile-month-day.today {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
  }

  .heatmap-page .heat-legend {
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .mobile-month-card {
    padding: 0.65rem;
  }

  .mobile-month-grid,
  .mobile-month-weekdays {
    gap: 0.14rem;
  }

  .mobile-month-day {
    min-height: 1.85rem;
    border-radius: 0.45rem;
    font-size: 0.64rem;
  }

  .mobile-month-head {
    flex-direction: column;
  }

  .mobile-month-head .button {
    width: 100%;
  }
}

/* -------------------------------------------------------
   Phase 4O.2: Heatmap mobile width containment fix
------------------------------------------------------- */

@media (max-width: 720px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .heatmap-page,
  .heatmap-page *,
  .mobile-heatmap-months,
  .mobile-heatmap-months *,
  .mobile-month-card,
  .mobile-month-card * {
    box-sizing: border-box;
    min-width: 0;
  }

  .heatmap-page {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .heatmap-page .panel-card {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  /* Force the desktop heatmap off on phones even if earlier CSS partially applies. */
  .desktop-year-heatmap-panel,
  .heatmap-scroll-wrap,
  .year-heatmap,
  .year-heatmap-grid,
  .year-heatmap-weekdays {
    display: none !important;
  }

  .mobile-heatmap-months {
    display: grid !important;
    width: 100%;
    max-width: 100%;
    gap: 0.75rem;
    overflow: hidden;
  }

  .mobile-month-card {
    width: 100%;
    max-width: 100%;
    padding: 0.65rem;
    overflow: hidden;
  }

  .mobile-month-head {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 0.55rem;
  }

  .mobile-month-head .button {
    min-width: 0;
    white-space: nowrap;
  }

  .mobile-month-weekdays,
  .mobile-month-grid {
    width: 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.12rem;
  }

  .mobile-month-day {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    aspect-ratio: 1 / 1;
    border-radius: 0.42rem;
    padding: 0;
    font-size: clamp(0.55rem, 2.5vw, 0.72rem);
  }

  .mobile-month-day span {
    overflow: hidden;
    line-height: 1;
  }

  .heatmap-summary-grid {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .heatmap-page .filter-bar {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
  }

  .heatmap-page .filter-chip {
    flex: 0 0 auto;
  }

  .heatmap-year-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .heatmap-year-actions .button {
    width: 100%;
    min-width: 0;
  }

  .heatmap-month-chart .h-chart-row {
    grid-template-columns: 3.25rem minmax(0, 1fr) auto;
  }
}

@media (max-width: 380px) {
  .mobile-month-card {
    padding: 0.55rem;
  }

  .mobile-month-weekdays,
  .mobile-month-grid {
    gap: 0.1rem;
  }

  .mobile-month-day {
    border-radius: 0.35rem;
    font-size: 0.56rem;
  }

  .mobile-month-head {
    grid-template-columns: 1fr;
  }

  .mobile-month-head .button {
    width: 100%;
  }
}

/* -------------------------------------------------------
   Phase 4P: Import / Restore Tools
------------------------------------------------------- */

.import-restore-page {
  max-width: 58rem;
}

.import-restore-hero {
  border-top: 0.35rem solid var(--accent);
}

.restore-backup-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.restore-backup-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem;
  display: grid;
  gap: 0.65rem;
}

.restore-confirm-details {
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}

.restore-confirm-details summary {
  cursor: pointer;
  color: var(--danger);
  font-weight: 850;
}

.restore-confirm-details form {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.65rem;
}

.import-form {
  display: grid;
  gap: 0.85rem;
}

.sample-csv {
  overflow-x: auto;
  background: rgba(40, 32, 24, 0.055);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.85rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

@media (max-width: 720px) {
  .restore-backup-card {
    border-radius: 0.9rem;
  }

  .sample-csv {
    font-size: 0.74rem;
  }
}

/* -------------------------------------------------------
   Phase 4R: Dark Mode / Theme Polish
------------------------------------------------------- */

:root {
  --shadow-soft: 0 12px 28px rgba(40, 32, 24, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #101410;
  --card: #171d18;
  --ink: #f3f0e8;
  --muted: #b8b3aa;
  --line: rgba(255, 255, 255, 0.12);
  --danger: #ff7b6e;

  --shadow-soft: 0 14px 30px rgba(0, 0, 0, 0.32);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    color-scheme: dark;

    --bg: #101410;
    --card: #171d18;
    --ink: #f3f0e8;
    --muted: #b8b3aa;
    --line: rgba(255, 255, 255, 0.12);
    --danger: #ff7b6e;

    --shadow-soft: 0 14px 30px rgba(0, 0, 0, 0.32);
  }
}

[data-theme="dark"] body,
[data-theme="system"] body {
  background:
    radial-gradient(circle at top left, rgba(69, 107, 79, 0.16), transparent 24rem),
    var(--bg);
  color: var(--ink);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] body {
    background:
      radial-gradient(circle at top left, rgba(69, 107, 79, 0.16), transparent 24rem),
      var(--bg);
    color: var(--ink);
  }
}

[data-theme="dark"] .panel-card,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .intel-card,
[data-theme="dark"] .status-count-grid div,
[data-theme="dark"] .service-row,
[data-theme="dark"] .settings-section,
[data-theme="dark"] .settings-toggle,
[data-theme="dark"] .recent-note-card,
[data-theme="dark"] .restore-backup-card,
[data-theme="dark"] .goal-chart-row,
[data-theme="dark"] .preset-group,
[data-theme="dark"] .yesterday-details,
[data-theme="dark"] .entry-card,
[data-theme="dark"] .mobile-month-card,
[data-theme="dark"] .calendar-day,
[data-theme="dark"] .category-row,
[data-theme="dark"] .quick-add-button,
[data-theme="dark"] .preset-add-button {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .panel-card,
  [data-theme="system"] .chart-card,
  [data-theme="system"] .intel-card,
  [data-theme="system"] .status-count-grid div,
  [data-theme="system"] .service-row,
  [data-theme="system"] .settings-section,
  [data-theme="system"] .settings-toggle,
  [data-theme="system"] .recent-note-card,
  [data-theme="system"] .restore-backup-card,
  [data-theme="system"] .goal-chart-row,
  [data-theme="system"] .preset-group,
  [data-theme="system"] .yesterday-details,
  [data-theme="system"] .entry-card,
  [data-theme="system"] .mobile-month-card,
  [data-theme="system"] .calendar-day,
  [data-theme="system"] .category-row,
  [data-theme="system"] .quick-add-button,
  [data-theme="system"] .preset-add-button {
    background: var(--card);
    border-color: var(--line);
    color: var(--ink);
    box-shadow: var(--shadow-soft);
  }
}

[data-theme="dark"] .site-header,
[data-theme="dark"] .nav {
  background: rgba(16, 20, 16, 0.92);
  border-color: var(--line);
  backdrop-filter: blur(16px);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .site-header,
  [data-theme="system"] .nav {
    background: rgba(16, 20, 16, 0.92);
    border-color: var(--line);
    backdrop-filter: blur(16px);
  }
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .sample-csv {
  background: #0f130f;
  color: var(--ink);
  border-color: var(--line);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] input,
  [data-theme="system"] select,
  [data-theme="system"] textarea,
  [data-theme="system"] .sample-csv {
    background: #0f130f;
    color: var(--ink);
    border-color: var(--line);
  }
}

[data-theme="dark"] .empty-state,
[data-theme="dark"] .focus-box,
[data-theme="dark"] .dashboard-hero,
[data-theme="dark"] .backup-status-card,
[data-theme="dark"] .app-mini-badge,
[data-theme="dark"] .journal-mini-ratings span,
[data-theme="dark"] .value-total-list span,
[data-theme="dark"] .mini-entry-row span {
  background: rgba(255, 255, 255, 0.045);
  border-color: var(--line);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .empty-state,
  [data-theme="system"] .focus-box,
  [data-theme="system"] .dashboard-hero,
  [data-theme="system"] .backup-status-card,
  [data-theme="system"] .app-mini-badge,
  [data-theme="system"] .journal-mini-ratings span,
  [data-theme="system"] .value-total-list span,
  [data-theme="system"] .mini-entry-row span {
    background: rgba(255, 255, 255, 0.045);
    border-color: var(--line);
  }
}

[data-theme="dark"] .heatmap-day,
[data-theme="dark"] .mobile-month-day {
  background: #111611;
  border-color: var(--line);
  color: var(--ink);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .heatmap-day,
  [data-theme="system"] .mobile-month-day {
    background: #111611;
    border-color: var(--line);
    color: var(--ink);
  }
}

[data-theme="dark"] .heatmap-day.heat-1,
[data-theme="dark"] .mobile-month-day.heat-1 {
  background: rgba(91, 145, 105, 0.28);
}

[data-theme="dark"] .heatmap-day.heat-2,
[data-theme="dark"] .mobile-month-day.heat-2 {
  background: rgba(91, 145, 105, 0.48);
}

[data-theme="dark"] .heatmap-day.heat-3,
[data-theme="dark"] .mobile-month-day.heat-3 {
  background: rgba(91, 145, 105, 0.68);
}

[data-theme="dark"] .heatmap-day.heat-4,
[data-theme="dark"] .mobile-month-day.heat-4 {
  background: rgba(91, 145, 105, 0.92);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .heatmap-day.heat-1,
  [data-theme="system"] .mobile-month-day.heat-1 {
    background: rgba(91, 145, 105, 0.28);
  }

  [data-theme="system"] .heatmap-day.heat-2,
  [data-theme="system"] .mobile-month-day.heat-2 {
    background: rgba(91, 145, 105, 0.48);
  }

  [data-theme="system"] .heatmap-day.heat-3,
  [data-theme="system"] .mobile-month-day.heat-3 {
    background: rgba(91, 145, 105, 0.68);
  }

  [data-theme="system"] .heatmap-day.heat-4,
  [data-theme="system"] .mobile-month-day.heat-4 {
    background: rgba(91, 145, 105, 0.92);
  }
}

[data-theme="dark"] code {
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] code {
    background: rgba(255, 255, 255, 0.07);
    color: var(--ink);
  }
}

/* -------------------------------------------------------
   Phase 4S: Timer Mode
------------------------------------------------------- */

.timer-page {
  max-width: 58rem;
}

.timer-hero {
  border-top: 0.35rem solid var(--accent);
}

.active-timer-card {
  border-top: 0.35rem solid var(--accent);
}

.active-timer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.timer-display {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.5rem, 10vw, 4.8rem);
  line-height: 1;
  font-weight: 950;
  color: var(--accent);
  letter-spacing: -0.05em;
}

.timer-note-preview {
  margin-top: 1rem;
  background: rgba(69, 107, 79, 0.07);
  border: 1px solid rgba(69, 107, 79, 0.16);
  border-radius: 1rem;
  padding: 0.85rem;
}

.timer-note-preview p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.timer-action-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.timer-action-grid .button,
.timer-save-form .button,
.timer-start-form .button {
  width: 100%;
}

.timer-save-form,
.timer-start-form {
  margin-top: 1rem;
  display: grid;
  gap: 0.85rem;
}

.timer-save-form {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.timer-info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.timer-info-grid article {
  background: white;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem;
}

.timer-info-grid p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

[data-theme="dark"] .timer-info-grid article,
[data-theme="dark"] .timer-note-preview {
  background: rgba(255, 255, 255, 0.045);
  border-color: var(--line);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .timer-info-grid article,
  [data-theme="system"] .timer-note-preview {
    background: rgba(255, 255, 255, 0.045);
    border-color: var(--line);
  }
}

@media (max-width: 720px) {
  .active-timer-head {
    display: grid;
    gap: 0.75rem;
  }

  .timer-display {
    width: 100%;
    text-align: center;
    background: rgba(69, 107, 79, 0.08);
    border: 1px solid rgba(69, 107, 79, 0.16);
    border-radius: 1rem;
    padding: 0.85rem;
  }

  .timer-action-grid {
    grid-template-columns: 1fr;
  }

  .timer-info-grid {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------
   Phase 4S.1: Timer Quality-of-Life
------------------------------------------------------- */

.timer-nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.timer-nav-link.active-timer {
  color: var(--accent);
  font-weight: 900;
}

.timer-nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 2.4rem;
  border-radius: 999px;
  padding: 0.15rem 0.35rem;
  background: rgba(69, 107, 79, 0.12);
  border: 1px solid rgba(69, 107, 79, 0.2);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 0.68rem;
  font-weight: 900;
}

.dashboard-active-timer-card {
  border-top: 0.35rem solid var(--accent);
}

.dashboard-timer-pill {
  flex: 0 0 auto;
  min-width: 7rem;
  text-align: center;
  border-radius: 1rem;
  padding: 0.6rem 0.75rem;
  background: rgba(69, 107, 79, 0.1);
  border: 1px solid rgba(69, 107, 79, 0.18);
  color: var(--accent);
  font-size: 1.45rem;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.timer-quick-start {
  margin-top: 1rem;
}

.timer-quick-start h3 {
  margin-bottom: 0.25rem;
}

.timer-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.timer-quick-button {
  width: 100%;
  min-height: 3.2rem;
}

[data-theme="dark"] .timer-nav-badge,
[data-theme="dark"] .dashboard-timer-pill {
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .timer-nav-badge,
  [data-theme="system"] .dashboard-timer-pill {
    background: rgba(255, 255, 255, 0.055);
    border-color: var(--line);
  }
}

@media (max-width: 720px) {
  .dashboard-active-timer-card .section-head-row {
    display: grid;
    gap: 0.75rem;
  }

  .dashboard-timer-pill {
    width: 100%;
    min-width: 0;
  }

  .timer-quick-grid {
    grid-template-columns: 1fr 1fr;
  }

  .timer-nav-badge {
    display: none;
  }
}

@media (max-width: 420px) {
  .timer-quick-grid {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------
   Phase 4U-A: Insights shell
------------------------------------------------------- */

.insights-page {
  max-width: 76rem;
}

.insights-hero {
  border-top: 0.35rem solid var(--accent);
}

.insights-shell-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 760px) {
  .insights-shell-grid {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------
   Phase 4U-B: Habit Consistency Trends
------------------------------------------------------- */

.insights-wide-card {
  grid-column: 1 / -1;
}

.insight-trend-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.insight-trend-card {
  background: white;
  border: 1px solid var(--line);
  border-left: 0.35rem solid var(--cat-color, var(--accent));
  border-radius: 1rem;
  padding: 0.85rem;
}

.insight-trend-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.65rem;
}

.insight-status {
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.5rem;
  background: rgba(40, 32, 24, 0.08);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.insight-status.good {
  background: rgba(69, 107, 79, 0.12);
  color: var(--accent);
}

.insight-status.warn {
  background: rgba(163, 58, 47, 0.1);
  color: var(--danger);
}

.insight-status.steady,
.insight-status.quiet {
  background: rgba(40, 32, 24, 0.08);
  color: var(--muted);
}

.insight-trend-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.insight-trend-metrics div {
  background: rgba(40, 32, 24, 0.045);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 0.6rem;
  text-align: center;
}

.insight-trend-metrics span {
  display: block;
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 950;
  color: var(--ink);
}

.insight-trend-metrics small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
}

[data-theme="dark"] .insight-trend-card,
[data-theme="system"] .insight-trend-card {
  background: var(--card);
  border-color: var(--line);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .insight-trend-card {
    background: var(--card);
    border-color: var(--line);
  }
}

@media (max-width: 520px) {
  .insight-trend-list {
    grid-template-columns: 1fr;
  }

  .insight-trend-head {
    display: grid;
  }

  .insight-trend-metrics {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------
   Phase 4U-C: Time-of-Week Patterns
------------------------------------------------------- */

.weekday-pattern-chart {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.weekday-pattern-row {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) 3rem;
  gap: 0.55rem;
  align-items: center;
}

.weekday-pattern-label,
.weekday-pattern-value {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.weekday-pattern-value {
  text-align: right;
}

.weekday-pattern-track {
  height: 0.75rem;
  border-radius: 999px;
  background: rgba(40, 32, 24, 0.08);
  overflow: hidden;
}

.weekday-pattern-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.category-pattern-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.category-pattern-list span {
  border: 1px solid var(--line);
  border-left: 0.35rem solid var(--cat-color, var(--accent));
  border-radius: 999px;
  padding: 0.4rem 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

[data-theme="dark"] .weekday-pattern-track {
  background: rgba(255, 255, 255, 0.08);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .weekday-pattern-track {
    background: rgba(255, 255, 255, 0.08);
  }
}

@media (max-width: 520px) {
  .weekday-pattern-row {
    grid-template-columns: 2.6rem minmax(0, 1fr) 2.4rem;
  }

  .category-pattern-list span {
    width: 100%;
    border-radius: 0.8rem;
  }
}

/* -------------------------------------------------------
   Phase 4U-D: Goal Pacing
------------------------------------------------------- */

.goal-pacing-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.goal-pacing-card {
  background: white;
  border: 1px solid var(--line);
  border-left: 0.35rem solid var(--cat-color, var(--accent));
  border-radius: 1rem;
  padding: 0.85rem;
}

.goal-pacing-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.goal-pacing-head p {
  margin: 0.25rem 0 0;
}

.goal-pacing-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.goal-pacing-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

[data-theme="dark"] .goal-pacing-card {
  background: var(--card);
  border-color: var(--line);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .goal-pacing-card {
    background: var(--card);
    border-color: var(--line);
  }
}

@media (max-width: 520px) {
  .goal-pacing-head {
    display: grid;
  }

  .goal-pacing-meta span {
    width: 100%;
    border-radius: 0.75rem;
  }
}

/* -------------------------------------------------------
   Phase 4U-E: Milestones / Personal Bests
------------------------------------------------------- */

.milestone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.milestone-card,
.next-milestone-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem;
}

.milestone-card span {
  display: block;
  margin-top: 0.45rem;
  color: var(--accent);
  font-size: 2.1rem;
  line-height: 1;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.milestone-card p,
.next-milestone-card p {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.next-milestone-card {
  margin-top: 0.85rem;
}

.next-milestone-card .progress-bar {
  margin-top: 0.75rem;
}

[data-theme="dark"] .milestone-card,
[data-theme="dark"] .next-milestone-card {
  background: var(--card);
  border-color: var(--line);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .milestone-card,
  [data-theme="system"] .next-milestone-card {
    background: var(--card);
    border-color: var(--line);
  }
}

@media (max-width: 520px) {
  .milestone-grid {
    grid-template-columns: 1fr;
  }

  .milestone-card span {
    font-size: 1.9rem;
  }
}

/* -------------------------------------------------------
   Phase 4U-F: Best Next Action
------------------------------------------------------- */

.best-next-action-card {
  border-top: 0.35rem solid var(--accent);
  background:
    radial-gradient(circle at top right, rgba(69, 107, 79, 0.14), transparent 18rem),
    var(--card);
}

.best-next-action-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.best-next-action-layout h2 {
  margin-top: 0.15rem;
}

.best-next-action-layout .button {
  flex: 0 0 auto;
}

.best-next-action-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.best-next-action-meta span {
  border: 1px solid rgba(69, 107, 79, 0.18);
  background: rgba(69, 107, 79, 0.08);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 850;
}

[data-theme="dark"] .best-next-action-card {
  background:
    radial-gradient(circle at top right, rgba(69, 107, 79, 0.2), transparent 18rem),
    var(--card);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .best-next-action-card {
    background:
      radial-gradient(circle at top right, rgba(69, 107, 79, 0.2), transparent 18rem),
      var(--card);
  }
}

@media (max-width: 720px) {
  .best-next-action-layout {
    display: grid;
  }

  .best-next-action-layout .button {
    width: 100%;
  }
}


/* 4U-D review and more polish */

.nav-primary.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
}

.more-page .panel-card {
  margin-bottom: 1rem;
}

.more-page h2 {
  margin-bottom: 0.25rem;
}

.more-grid {
  gap: 0.75rem;
}

.more-card {
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.more-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

.review-selected-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.review-selected-summary > div {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.85rem;
  background: var(--surface-soft);
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
}

.review-filter-form {
  display: grid;
  gap: 0.9rem;
}

.range-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.range-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.15rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  font-weight: 700;
}

.range-chip.active {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

.review-filter-actions {
  justify-content: flex-start;
}

.review-history-entry {
  display: grid;
  gap: 0.35rem;
}

@media (max-width: 720px) {
  .review-selected-summary {
    grid-template-columns: 1fr;
  }

  .range-chip {
    flex: 1 1 auto;
  }
}


/* 4U-E2 dashboard cleanup */

.dashboard-date-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.45rem 0 0.35rem;
}

.dashboard-small-add-entry {
  min-height: 2rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
}

.compact-dashboard-quick-add {
  align-self: start;
}

.compact-dashboard-quick-add h2 {
  margin-bottom: 0.6rem;
}

.compact-dashboard-quick-add .quick-section-label {
  margin-top: 0.75rem;
  margin-bottom: 0.45rem;
}

.compact-dashboard-quick-add .preset-group-list {
  gap: 0.45rem;
}

.compact-dashboard-quick-add .preset-group summary {
  min-height: 2.25rem;
  padding: 0.45rem 0.65rem;
}

.compact-dashboard-quick-add .preset-add-grid,
.compact-dashboard-quick-add .quick-add-grid {
  gap: 0.45rem;
}

.compact-dashboard-quick-add .preset-add-button,
.compact-dashboard-quick-add .quick-add-button {
  min-height: 2.35rem;
  padding: 0.45rem 0.6rem;
}

.compact-dashboard-quick-add .quick-add-icon {
  font-size: 1rem;
}


/* 4U-E3 timer and calendar cleanup */

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
  align-items: center;
  text-align: center;
}

.weekday-row span,
.weekday-row div {
  min-width: 0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-correction-card {
  margin: 1rem 0;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

.calendar-correction-card h3 {
  margin: 0.15rem 0 0.35rem;
}

.calendar-correction-card .toolbar-actions {
  justify-content: flex-start;
  margin-top: 0.75rem;
}

#calendar-quick-add,
#calendar-manual-entry {
  scroll-margin-top: 1rem;
}

@media (max-width: 720px) {
  .weekday-row {
    gap: 0.2rem;
    font-size: 0.78rem;
  }

  .calendar-correction-card .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}


/* 4V-A2 daily check-in */

.dashboard-checkin-form {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.85rem;
  margin: 0.85rem 0 1rem;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.dashboard-checkin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.dashboard-checkin-head .eyebrow {
  margin-bottom: 0.15rem;
}

.dashboard-checkin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.dashboard-checkin-grid label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.86rem;
  font-weight: 700;
}

.dashboard-checkin-grid select {
  min-height: 2.25rem;
}

.dashboard-checkin-save {
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
}

@media (max-width: 720px) {
  .dashboard-checkin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* 4V-B1 flow timer reflection */

.timer-flow-reflection {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.9rem;
  margin: 0.75rem 0;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.timer-flow-reflection h3 {
  margin: 0.15rem 0 0.25rem;
}

.timer-flow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.75rem 0;
}

.timer-flow-grid label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.86rem;
  font-weight: 700;
}

.timer-flow-grid select {
  min-height: 2.25rem;
}

@media (max-width: 720px) {
  .timer-flow-grid {
    grid-template-columns: 1fr;
  }
}


/* 4V-C1 mindful insights */

.mindful-insights-card {
  display: grid;
  gap: 1rem;
}

.mindful-state-grid,
.mindful-flow-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.mindful-flow-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mindful-state-card,
.mindful-flow-summary > div {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.85rem;
  background: var(--surface-soft);
}

.mindful-state-card strong,
.mindful-flow-summary strong {
  display: block;
  font-size: 1.35rem;
}

.mindful-state-card small,
.mindful-flow-summary small {
  color: var(--muted);
}

.mindful-recommendation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: 1rem;
  padding: 0.9rem;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.mindful-recommendation p {
  margin-bottom: 0;
}

.mindful-flow-list {
  display: grid;
  gap: 0.65rem;
}

.mindful-flow-list h3 {
  margin-bottom: 0;
}

.mindful-flow-card {
  border-left: 4px solid var(--cat-color, var(--accent));
  border-radius: 0.9rem;
  padding: 0.75rem;
  background: var(--surface-soft);
}

.mindful-flow-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.mindful-flow-tags span {
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  font-size: 0.82rem;
  font-weight: 700;
}

@media (max-width: 720px) {
  .mindful-state-grid,
  .mindful-flow-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mindful-recommendation {
    align-items: stretch;
    flex-direction: column;
  }

  .mindful-recommendation .button {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .mindful-state-grid,
  .mindful-flow-summary {
    grid-template-columns: 1fr;
  }
}


/* 4V-D1 state-aware best next action */

.best-next-action-card .best-next-action-meta span {
  white-space: nowrap;
}

.best-next-action-card {
  border-color: color-mix(in srgb, var(--accent) 24%, var(--border));
}


/* 4U-G3 compact daily check-in */

.dashboard-checkin-compact-form {
  padding: 0.75rem;
}

.dashboard-checkin-compact-form .dashboard-checkin-grid {
  gap: 0.5rem;
}

.dashboard-checkin-compact-form .dashboard-checkin-grid label {
  font-size: 0.82rem;
}

.dashboard-checkin-compact-form .dashboard-checkin-grid select {
  min-height: 2rem;
  padding: 0.25rem 0.45rem;
}

.dashboard-checkin-compact-form .dashboard-checkin-head {
  margin-bottom: 0.6rem;
}

@media (max-width: 720px) {
  .dashboard-checkin-compact-form .dashboard-checkin-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .dashboard-checkin-compact-form .dashboard-checkin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* 4U-H1 minimalist UI pass */

:root {
  --minimal-radius: 0.9rem;
}

body {
  letter-spacing: -0.01em;
}

h1,
h2,
h3 {
  letter-spacing: -0.035em;
}

h1 {
  font-size: clamp(1.65rem, 5vw, 2.35rem);
}

h2 {
  font-size: clamp(1.12rem, 3.4vw, 1.45rem);
}

h3 {
  font-size: 1rem;
}

.panel-card,
.more-card,
.entry-card,
.goal-mini-card,
.mindful-state-card,
.mindful-flow-card,
.review-history-entry {
  box-shadow: none !important;
}

.panel-card {
  border-radius: var(--minimal-radius);
  border-color: color-mix(in srgb, var(--border) 76%, transparent);
  padding: clamp(0.85rem, 3vw, 1.05rem);
}

.dashboard-page,
.narrow-page,
.more-page,
.review-entries-page {
  gap: 0.85rem;
}

.dashboard-hero {
  align-items: flex-start;
  gap: 0.75rem;
}

.app-mini-badge {
  display: none;
}

.dashboard-actions,
.toolbar-actions {
  gap: 0.45rem;
}

.button,
.danger-button,
.more-card,
.range-chip {
  box-shadow: none !important;
}

.button,
.danger-button {
  border-radius: 0.75rem;
  min-height: 2.2rem;
  padding: 0.45rem 0.75rem;
}

.button.secondary {
  background: transparent;
}

.section-head-row {
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.section-head-row h2,
.section-head-row p {
  margin-bottom: 0;
}

.muted {
  line-height: 1.35;
}

.dashboard-checkin-form,
.timer-flow-reflection,
.calendar-correction-card,
.mindful-recommendation {
  box-shadow: none !important;
}

.dashboard-checkin-form {
  margin: 0.7rem 0 0.85rem;
}

.dashboard-checkin-head {
  margin-bottom: 0.55rem;
}

.dashboard-checkin-grid {
  gap: 0.45rem;
}

.dashboard-checkin-grid select,
.review-filter-form select,
.entry-form select,
.entry-form input,
.entry-form textarea {
  border-radius: 0.65rem;
}

.journal-mini-ratings,
.mindful-flow-tags,
.range-chip-row {
  gap: 0.35rem;
}

.journal-mini-ratings span,
.mindful-flow-tags span,
.range-chip {
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.78rem;
}

.dashboard-grid,
.more-grid,
.goal-progress-grid,
.mindful-state-grid,
.mindful-flow-summary,
.review-selected-summary {
  gap: 0.65rem;
}

.more-section {
  margin-top: 0.75rem;
}

.more-section-header {
  margin-bottom: 0.7rem;
}

.more-section-icon {
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
}

.more-card {
  border-radius: 0.85rem;
  padding: 0.75rem;
}

.more-card:hover {
  transform: none;
}

.entry-list {
  gap: 0.55rem;
}

.entry-card,
.review-history-entry {
  border-radius: 0.75rem;
  padding: 0.7rem;
}

.insights-shell-grid {
  gap: 0.85rem;
}

.mindful-insights-card {
  gap: 0.75rem;
}

.mindful-state-card,
.mindful-flow-summary > div {
  border-radius: 0.8rem;
  padding: 0.7rem;
}

.mindful-state-card strong,
.mindful-flow-summary strong {
  font-size: 1.15rem;
}

.mindful-recommendation {
  border-radius: 0.8rem;
  padding: 0.75rem;
}

.calendar-correction-card {
  display: none !important;
}

@media (max-width: 720px) {
  .panel-card {
    padding: 0.85rem;
  }

  .dashboard-actions,
  .toolbar-actions {
    display: flex;
    flex-wrap: wrap;
  }

  .dashboard-actions .button,
  .toolbar-actions .button {
    flex: 1 1 auto;
  }

  .dashboard-checkin-compact-form .dashboard-checkin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* 4U-I2 todays journal check-in */

.checkin-timestamp {
  color: var(--muted);
  font-size: 0.78rem;
  margin: -0.25rem 0 0.55rem;
}

.dashboard-checkin-compact-form .dashboard-checkin-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 720px) {
  .dashboard-checkin-compact-form .dashboard-checkin-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .dashboard-checkin-compact-form .dashboard-checkin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* 4U-I16 clean dashboard reset */

/*
  Clean replacement for the stacked Dashboard experiments.
  Goal: stable mobile/web width first, minimalist styling second.
*/

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

main.page {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.dashboard-page {
  display: grid;
  gap: 0.75rem;
  width: 100%;
  max-width: 760px;
  min-width: 0;
  margin: 0 auto;
  padding: 0.65rem;
  overflow-x: hidden;
  box-sizing: border-box;
}

.dashboard-page *,
.dashboard-page *::before,
.dashboard-page *::after {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
}

.dashboard-page .panel-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  overflow: hidden;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: start;
}

.dashboard-hero > div:first-child {
  min-width: 0;
}

.dashboard-hero h1 {
  font-size: clamp(1.8rem, 9vw, 3.2rem);
  line-height: 1;
  overflow-wrap: anywhere;
}

.dashboard-date-actions {
  margin: 0.45rem 0;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  grid-column: 1 / -1;
}

.dashboard-actions .button,
.dashboard-small-add-entry {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
}

.dashboard-week-score-only {
  display: inline-flex;
  width: 3.25rem;
  min-width: 3.25rem;
  max-width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  justify-self: end;
  overflow: hidden;
}

.dashboard-score-ring {
  width: 3.25rem;
  min-width: 3.25rem;
  max-width: 3.25rem;
  height: 3.25rem;
}

.dashboard-score-ring strong {
  font-size: 0.88rem;
}

.dashboard-score-ring span {
  font-size: 0.5rem;
}

.dashboard-journal-capture-lite {
  display: grid;
  gap: 0.65rem;
  width: 100%;
}

.dashboard-journal-lite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.dashboard-journal-lite-actions .button {
  flex: 1 1 auto;
  min-width: 0;
}

.journal-mini-ratings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.journal-mini-ratings span {
  white-space: normal;
}

.dashboard-grid {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.dashboard-grid > .panel-card {
  width: 100%;
  max-width: 100%;
}

.dashboard-quick-add-safe,
.dashboard-quick-grid-safe,
.dashboard-preset-grid-safe {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.dashboard-quick-grid-safe,
.dashboard-preset-grid-safe {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.dashboard-quick-grid-safe form,
.dashboard-preset-grid-safe form {
  width: 100%;
  max-width: 100%;
}

.dashboard-quick-grid-safe .dashboard-quick-button,
.dashboard-preset-grid-safe .preset-add-button {
  display: flex;
  width: 100%;
  max-width: 100%;
  min-height: 2.25rem;
  padding: 0.42rem 0.5rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.goal-progress-grid,
.mini-streak-list,
.entry-list {
  width: 100%;
  max-width: 100%;
}

.goal-progress-grid,
.mini-streak-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.entry-card,
.goal-mini-card,
.mini-streak {
  width: 100%;
  max-width: 100%;
  overflow-wrap: anywhere;
}

@media (min-width: 620px) {
  .goal-progress-grid,
  .mini-streak-list,
  .dashboard-quick-grid-safe,
  .dashboard-preset-grid-safe {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .dashboard-page {
    padding: 0.5rem;
  }

  .dashboard-hero {
    grid-template-columns: minmax(0, 1fr) 3.25rem;
  }

  .dashboard-hero h1 {
    font-size: clamp(1.65rem, 8.5vw, 2.75rem);
  }
}


/* 4U-I17 force dashboard single column */

/*
  Width debugger showed the remaining offender:
  div.dashboard-grid still computed as display:grid with ~921px scrollWidth.
  Force Dashboard's capture/content area into one safe column.
*/

body:has(section.dashboard-page) {
  overflow-x: hidden !important;
}

main.page:has(section.dashboard-page) {
  overflow-x: hidden !important;
  max-width: 100vw !important;
}

section.dashboard-page {
  overflow-x: hidden !important;
  max-width: min(760px, 100vw) !important;
}

section.dashboard-page .dashboard-grid,
section.dashboard-page div.dashboard-grid,
.dashboard-page .dashboard-grid,
div.dashboard-grid {
  display: block !important;
  grid-template-columns: none !important;
  grid-auto-flow: row !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
}

section.dashboard-page .dashboard-grid > *,
section.dashboard-page div.dashboard-grid > *,
.dashboard-page .dashboard-grid > *,
div.dashboard-grid > * {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  overflow-x: hidden !important;
}

section.dashboard-page .dashboard-grid > .panel-card + .panel-card {
  margin-top: 0.75rem !important;
}

@media (max-width: 820px) {
  section.dashboard-page,
  section.dashboard-page .dashboard-grid,
  section.dashboard-page .dashboard-grid > * {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
}


/* 4U-I18 force dashboard page block layout */

/*
  Width debugger showed the remaining offender:
  section.dashboard-page itself computed as display:grid with scrollWidth ~921px.
  Force the Today page shell and all top-level Dashboard cards into normal
  block flow so no grid track can widen the iOS viewport.
*/

body,
html {
  overflow-x: hidden !important;
  max-width: 100% !important;
}

main.page {
  display: block !important;
  width: 100% !important;
  max-width: 100vw !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
}

main.page section.dashboard-page,
section.dashboard-page.dashboard-page,
section.dashboard-page {
  display: block !important;
  grid-template-columns: none !important;
  grid-auto-columns: auto !important;
  grid-auto-flow: row !important;
  width: calc(100vw - 28px) !important;
  max-width: 760px !important;
  min-width: 0 !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

main.page section.dashboard-page > *,
section.dashboard-page.dashboard-page > *,
section.dashboard-page > * {
  display: block !important;
  grid-column: auto !important;
  grid-row: auto !important;
  justify-self: stretch !important;
  align-self: auto !important;
  width: auto !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  margin-bottom: 0.75rem !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

main.page section.dashboard-page .panel-card,
section.dashboard-page .panel-card,
section.dashboard-page .dashboard-hero,
section.dashboard-page .dashboard-journal-card,
section.dashboard-page .dashboard-goals-panel,
section.dashboard-page .dashboard-streaks-panel,
section.dashboard-page .dashboard-grid,
section.dashboard-page .dashboard-grid > * {
  display: block !important;
  width: auto !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

section.dashboard-page .dashboard-hero {
  grid-template-columns: none !important;
}

section.dashboard-page .dashboard-actions,
section.dashboard-page .dashboard-journal-lite-actions,
section.dashboard-page .journal-mini-ratings {
  display: flex !important;
  flex-wrap: wrap !important;
  width: 100% !important;
  max-width: 100% !important;
}

section.dashboard-page .dashboard-week-score-only {
  display: inline-flex !important;
  width: 3.25rem !important;
  min-width: 3.25rem !important;
  max-width: 3.25rem !important;
  height: 3.25rem !important;
}

section.dashboard-page .goal-progress-grid,
section.dashboard-page .mini-streak-list,
section.dashboard-page .entry-list {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}

section.dashboard-page .goal-progress-grid,
section.dashboard-page .mini-streak-list {
  display: grid !important;
  grid-template-columns: 1fr !important;
}

@media (max-width: 430px) {
  main.page section.dashboard-page,
  section.dashboard-page.dashboard-page,
  section.dashboard-page {
    width: calc(100vw - 18px) !important;
  }
}


/* 4U-I21 safe quick add scroll */

.safe-quick-add-scroll-shell,
.safe-preset-scroll-shell {
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden !important;
}

.safe-quick-add-scroll-viewport,
.safe-preset-scroll-viewport {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.safe-quick-add-scroll-rail,
.safe-preset-scroll-rail {
  display: inline-flex !important;
  flex-wrap: nowrap !important;
  gap: 0.45rem !important;
  width: max-content !important;
  max-width: none !important;
  min-width: 100% !important;
  overflow: visible !important;
  white-space: nowrap !important;
  padding: 0.05rem 0 0.45rem !important;
}

.safe-quick-add-scroll-rail form,
.safe-preset-scroll-rail form {
  flex: 0 0 auto !important;
  width: auto !important;
  max-width: none !important;
}

.safe-quick-add-scroll-rail .dashboard-quick-button,
.safe-preset-scroll-rail .preset-add-button {
  width: 7rem !important;
  min-width: 7rem !important;
  max-width: 7rem !important;
  white-space: normal !important;
}


/* 4U-J4 simplified todays journal card */

.dashboard-journal-capture-lite {
  padding-block: 0.55rem;
}

.dashboard-journal-capture-lite .eyebrow {
  margin-bottom: 0;
}

.dashboard-journal-card .journal-mini-ratings {
  margin-top: 0.55rem;
}

.dashboard-journal-card > p {
  margin-top: 0.45rem;
}
