@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("./assets/fonts/rubik-latin-v31.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --paper: #eceae5;
  --paper-deep: #d7d4cd;
  --surface: #faf9f6;
  --ink: #30251f;
  --ink-muted: #746860;
  --line: #b7b0a8;
  --accent: #23756c;
  --accent-dark: #155952;
  --accent-soft: #d6ebe6;
  --orb-sand: #c79d70;
  --orb-plum: #80637c;
  --orb-sky: #6a9caf;
  --success: #2c7367;
  --shadow: 0 16px 42px rgba(48, 37, 31, 0.12);
  --radius: 16px;
  font-family: "Rubik", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  width: 100%;
  max-width: 100%;
  background: var(--paper);
  overflow-x: clip;
  overscroll-behavior-x: none;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-width: 320px;
  overflow-x: clip;
  overscroll-behavior-x: none;
  color: var(--ink);
  background:
    linear-gradient(rgba(48, 37, 31, 0.035) 1px, transparent 1px) 0 0 / 100% 40px,
    var(--paper);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 3px;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  max-width: 100%;
  margin: 0 auto;
  overflow-x: clip;
  padding: 24px 0 40px;
}

.topbar,
.today-layout,
.ledger-heading {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  min-height: 52px;
  margin-bottom: 10px;
}

.view-tabs {
  display: flex;
  gap: 22px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.view-tab {
  position: relative;
  min-height: 44px;
  padding: 0 2px;
  border: 0;
  color: var(--ink-muted);
  background: transparent;
  cursor: pointer;
  font-weight: 750;
}

.view-tab::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  background: transparent;
  content: "";
}

.view-tab:hover {
  color: var(--ink);
}

.view-tab[aria-selected="true"] {
  color: var(--accent-dark);
}

.view-tab[aria-selected="true"]::after {
  background: var(--accent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -0.015em;
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 42px;
  height: 42px;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.full-date,
.section-heading p,
.mood-title p,
.ledger-heading p,
.save-status {
  margin: 0;
  color: var(--ink-muted);
}

.full-date {
  font-size: 0.9rem;
  font-weight: 600;
}

.today-layout {
  align-items: stretch;
  gap: 18px;
}

.pet-panel,
.daily-panel,
.week-ledger {
  min-width: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pet-panel {
  position: sticky;
  top: 18px;
  align-self: flex-start;
  width: 36%;
  min-width: 320px;
  overflow: hidden;
  padding: 20px;
  color: #fffaf2;
  background: var(--ink);
}

.pet-panel::after {
  position: absolute;
  inset: auto -60px -80px auto;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: #493a31;
  content: "";
}

.pet-stage {
  position: relative;
  display: grid;
  min-height: 214px;
  place-items: center;
  border-radius: 13px;
  background: #000;
  overflow: hidden;
}

.pet-image {
  position: relative;
  top: 18px;
  z-index: 2;
  width: 210px;
  height: 210px;
  object-fit: contain;
  image-rendering: auto;
  transform-origin: 50% 84%;
}

.pet-image.react {
  animation: pet-hop 620ms cubic-bezier(.16, 1, .3, 1);
}

.pet-image.complete {
  top: -22px;
  width: 210px;
  height: 210px;
  animation: pet-celebrate 880ms cubic-bezier(.16, 1, .3, 1);
}

.poop-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.poop-prop {
  position: absolute;
  bottom: 7px;
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
}

.poop-prop--1 { left: 7%; }
.poop-prop--2 { right: 7%; }
.poop-prop--3 { left: 22%; bottom: 4px; }
.poop-prop--4 { right: 22%; bottom: 4px; }
.poop-prop--5 { left: calc(50% - 14px); bottom: 2px; }

.spark {
  position: absolute;
  z-index: 3;
  width: 9px;
  height: 9px;
  opacity: 0;
  background: var(--accent);
  clip-path: polygon(50% 0, 61% 35%, 100% 50%, 61% 65%, 50% 100%, 39% 65%, 0 50%, 39% 35%);
}

.spark-one { left: 15%; top: 24%; }
.spark-two { right: 13%; top: 34%; transform: scale(.7); }
.spark-three { left: 25%; bottom: 19%; transform: scale(.55); }

.pet-stage.celebrate .spark {
  animation: spark-pop 760ms ease-out;
}

.spark-two { animation-delay: 90ms !important; }
.spark-three { animation-delay: 160ms !important; }

.pet-copy {
  position: relative;
  z-index: 1;
  padding: 22px 4px 16px;
}

.pet-copy h1 {
  max-width: 12ch;
  margin: 0 0 7px;
  color: #fffaf2;
  font-size: 2rem;
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.pet-copy p {
  max-width: 31ch;
  margin: 0;
  color: #cec3bb;
  line-height: 1.45;
}

.progress-track {
  position: relative;
  z-index: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #5b4b41;
}

.progress-track span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 300ms cubic-bezier(.16, 1, .3, 1);
}

.save-status {
  position: relative;
  z-index: 1;
  margin-top: 11px;
  color: #b7aaa1;
  font-size: 0.78rem;
}

.pet-environment-status {
  position: relative;
  z-index: 1;
  margin: 4px 0 0;
  color: #d6c9bf;
  font-size: 0.72rem;
}

.daily-panel {
  flex: 1;
  padding: 24px;
}

.section-heading,
.ledger-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.section-heading {
  align-items: flex-start;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.task-editor-toggle,
.task-remove,
.add-task-form button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.task-editor-toggle {
  padding: 0 10px;
}

.task-editor-toggle:hover,
.task-remove:hover,
.add-task-form button:hover {
  border-color: var(--accent-dark);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

h2,
h3 {
  margin: 0;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.45rem;
}

h3 {
  font-size: 1rem;
}

.section-heading p,
.mood-title p,
.ledger-heading p {
  margin-top: 4px;
  font-size: 0.88rem;
}

.progress-count {
  color: var(--accent-dark);
  font-size: 1.15rem;
}

.week-picker {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin: 20px 0;
}

.day-button {
  position: relative;
  min-width: 0;
  min-height: 58px;
  border: 0;
  border-radius: 12px;
  color: var(--ink-muted);
  background: transparent;
  cursor: pointer;
}

.day-button:hover {
  background: var(--paper);
}

.day-button.has-data:not([aria-pressed="true"]) {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.day-button.has-data:not([aria-pressed="true"])::after {
  position: absolute;
  bottom: 6px;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
  transform: translateX(-50%);
}

.day-button[aria-pressed="true"] {
  color: var(--surface);
  background: var(--ink);
}

.day-button .day-name,
.day-button .day-number {
  display: block;
}

.day-button .day-name {
  margin-bottom: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.day-button .day-number {
  font-size: 1rem;
  font-weight: 750;
}

.task-list {
  border-top: 1px solid var(--line);
}

.task-button {
  display: grid;
  grid-template-columns: 52px 1fr 28px;
  align-items: center;
  width: 100%;
  min-height: 62px;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 6px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.task-button:hover {
  background: #f2f0eb;
}

.task-button:active {
  background: var(--accent-soft);
}

.task-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: var(--ink);
  background: transparent;
}

.task-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.task-pixel-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  image-rendering: pixelated;
}

.task-pixel-icon[src*="/orb-"] {
  width: 30px;
  height: 30px;
}

.task-orb {
  width: 30px;
  height: 30px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: inset -5px -5px 0 rgba(48, 37, 31, 0.2), 2px 2px 0 rgba(48, 37, 31, 0.22);
}

.task-orb--teal { background: var(--accent); }
.task-orb--sand { background: var(--orb-sand); }
.task-orb--plum { background: var(--orb-plum); }
.task-orb--sky { background: var(--orb-sky); }

.task-label {
  display: flex;
  align-items: center;
  min-height: 62px;
  font-size: 1.06rem;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.task-check {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  color: white;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.task-check svg {
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.task-button[aria-pressed="true"] .task-label {
  color: var(--ink-muted);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.task-button[aria-pressed="true"] .task-icon {
  color: var(--accent-dark);
  background: transparent;
}

.task-button[aria-pressed="true"] .task-check {
  border-color: var(--accent);
  background: var(--accent);
  transform: scale(1.04);
}

.task-button[aria-pressed="true"] .task-check svg {
  opacity: 1;
}

.task-editor {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.task-editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 13px;
}

.task-editor-heading h3,
.task-editor-heading p {
  margin: 0;
}

.task-editor-heading p {
  margin-top: 4px;
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.task-editor-status {
  max-width: 18ch;
  text-align: right;
}

.task-editor-list {
  display: grid;
  gap: 7px;
}

.task-editor-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) minmax(104px, 132px) auto;
  align-items: center;
  gap: 9px;
}

.task-editor-row input,
.task-editor-row select,
.add-task-form input {
  min-width: 0;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
}

.task-editor-row input:focus,
.task-editor-row select:focus,
.add-task-form input:focus {
  border-color: var(--accent-dark);
  outline: 3px solid color-mix(in srgb, var(--accent-soft), transparent 20%);
}

.task-editor-row select {
  padding: 0 8px;
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
}

.task-remove {
  padding: 0 9px;
  color: var(--ink-muted);
}

.add-task-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  margin-top: 12px;
}

.add-task-form button {
  padding: 0 12px;
  border-color: var(--accent-dark);
  color: var(--surface);
  background: var(--accent-dark);
}

.add-task-form button:hover {
  color: var(--surface);
  background: var(--accent);
}

.add-task-form button:disabled,
.add-task-form input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.mood-check {
  padding-top: 22px;
}

.mood-title {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 0 6px;
}

.mood-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.mood-button {
  min-width: 0;
  min-height: 72px;
  padding: 7px 3px;
  border: 0;
  border-radius: 12px;
  color: var(--ink-muted);
  background: var(--paper);
  cursor: pointer;
}

.mood-button:hover {
  color: var(--ink);
  background: var(--paper-deep);
}

.mood-button[aria-pressed="true"] {
  color: var(--surface);
  background: var(--accent-dark);
}

.three-rbt,
.data-tools {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.data-tools--footer {
  margin-top: 22px;
  padding-top: 4px;
}

.three-rbt-toggle {
  display: flex;
  width: 100%;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.three-rbt-title,
.three-rbt-summary {
  display: flex;
  align-items: center;
}

.three-rbt-title {
  min-width: 0;
  gap: 12px;
}

.three-rbt-title strong,
.three-rbt-title small {
  display: block;
}

.three-rbt-title strong {
  font-size: 1rem;
  font-weight: 760;
}

.three-rbt-title small {
  margin-top: 2px;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.three-rbt-summary {
  flex: 0 0 auto;
  gap: 8px;
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.three-rbt-summary span:first-child {
  color: var(--ink);
  font-size: 0.86rem;
}

.three-rbt-summary svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  transition: transform 160ms ease;
}

.three-rbt-toggle[aria-expanded="true"] .three-rbt-summary svg {
  transform: rotate(180deg);
}

.three-rbt-toggle.is-complete .three-rbt-summary,
.three-rbt-toggle.is-complete .three-rbt-summary span:first-child {
  color: var(--accent-dark);
}

.three-rbt-fields {
  padding: 4px 0 18px;
}

.three-rbt-hint,
.data-tools p {
  margin: 0 0 14px;
  color: var(--ink-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

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

.reflection-field {
  display: grid;
  min-width: 0;
  gap: 7px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
}

.reflection-field span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.reflection-field img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  image-rendering: pixelated;
}

.reflection-field textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fffefa;
  font: inherit;
  font-size: 1rem;
  line-height: 1.35;
}

.reflection-field textarea:focus {
  border-color: var(--accent-dark);
  outline: 3px solid var(--accent-soft);
}

.reflection-field--notes {
  margin-top: 14px;
}

.reflection-field--notes textarea {
  min-height: 112px;
}

.data-tools {
  padding-top: 14px;
  color: var(--ink-muted);
}

.data-tools summary {
  min-height: 44px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.data-actions button,
.restore-button,
.sync-actions button,
.sync-form button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 42px;
}

.sync-tools {
  display: grid;
  gap: 14px;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--line);
  padding: 2px 0 18px;
}

.sync-tools h3 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 1rem;
}

.sync-tools p {
  margin-bottom: 0;
}

.sync-form {
  display: grid;
  gap: 7px;
}

.sync-form label {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.sync-form > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.sync-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--ink);
  background: #fffefa;
  font: inherit;
}

.sync-form input:focus {
  border-color: var(--accent-dark);
  outline: 3px solid var(--accent-soft);
}

.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sync-direction-control {
  display: grid;
  grid-template-columns: auto minmax(0, max-content);
  align-items: center;
  gap: 7px 12px;
}

.sync-direction-control > span {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.sync-direction-control p {
  grid-column: 1 / -1;
  margin: 0;
}

.sync-direction-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 230px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
  background: var(--paper);
}

.sync-direction-switch label {
  position: relative;
  cursor: pointer;
}

.sync-direction-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.sync-direction-switch span {
  display: grid;
  min-height: 36px;
  place-items: center;
  border-radius: 12px;
  padding: 0 11px;
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 700;
  transition: color 160ms ease, background-color 160ms ease;
}

.sync-direction-switch input:checked + span {
  color: var(--surface);
  background: var(--accent-dark);
}

.sync-direction-switch input:focus-visible + span {
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}

.sync-direction-switch input:disabled + span {
  cursor: not-allowed;
  opacity: 0.48;
}

.sync-actions button:disabled,
.sync-form button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.sync-privacy {
  max-width: 68ch;
  color: var(--ink-muted);
  font-size: 0.76rem !important;
}

#restore-backup {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.backup-status {
  min-height: 1.2em;
  margin-top: 10px !important;
}

.update-ready {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--surface);
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
}

.update-ready button {
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  padding: 0 12px;
  color: var(--surface);
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.mood-pixel-icon {
  display: block;
  width: 30px;
  height: 30px;
  margin: 0 auto 4px;
  object-fit: contain;
  image-rendering: pixelated;
}

.mood-button span {
  font-size: 0.7rem;
  font-weight: 700;
}

.week-ledger {
  margin-top: 18px;
  overflow: hidden;
  padding: 24px;
}

.ledger-heading {
  align-items: flex-end;
  margin-bottom: 18px;
}

.week-range {
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.ledger-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  contain: inline-size;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 45px;
  border: 1px solid var(--line);
  text-align: center;
}

thead th {
  height: 39px;
  color: var(--ink-muted);
  background: var(--paper-deep);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.ledger-day-name,
.ledger-day-date {
  display: block;
  line-height: 1.05;
}

.ledger-day-date {
  margin-top: 2px;
  font-size: 0.63rem;
  font-weight: 650;
}

.ledger-label {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 180px;
  padding: 0 12px;
  background: var(--paper-deep);
  text-align: left;
}

thead .ledger-label {
  z-index: 2;
}

.ledger-label > span {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 45px;
  font-size: 0.88rem;
  font-weight: 680;
}

.ledger-icon-slot {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  min-height: 0;
  place-items: center;
}

.ledger-label .task-pixel-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.ledger-label .task-pixel-icon[src*="/orb-"] {
  width: 29px;
  height: 29px;
}

.ledger-label .mood-pixel-icon {
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  margin: 0;
}

.ledger-label svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ledger-cell {
  position: relative;
  background: var(--surface);
}

.ledger-cell.is-today {
  background: #f4f1ec;
}

.ledger-dot {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--accent);
}

.ledger-dot svg {
  width: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
}

.mood-cell {
  display: grid;
  place-items: center;
  color: var(--accent-dark);
}

.mood-cell .mood-pixel-icon {
  width: 24px;
  height: 24px;
  margin: 0;
}

.ledger-total {
  width: 54px;
  color: var(--ink);
  background: var(--paper-deep);
  font-weight: 800;
}

.stats-panel {
  min-width: 0;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stats-heading,
.chart-heading,
.mix-legend-row,
.streak-task,
.streak-metrics {
  display: flex;
  align-items: center;
}

.stats-heading,
.chart-heading {
  justify-content: space-between;
  gap: 18px;
}

.stats-heading {
  align-items: flex-end;
  padding-bottom: 22px;
}

.stats-heading p,
.chart-heading p,
.stats-empty p {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.period-control {
  display: grid;
  gap: 4px;
  min-width: 124px;
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.period-control select {
  min-height: 42px;
  padding: 0 32px 0 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 0.82rem;
  text-transform: none;
}

.period-control select:focus-visible {
  border-color: var(--accent-dark);
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}

.stats-navigator {
  display: grid;
  grid-template-columns: 38px minmax(0, auto) 38px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 0 18px;
}

.stats-navigator button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.stats-navigator button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.stats-navigator button:disabled {
  cursor: default;
  opacity: 0.35;
}

.stats-navigator button:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}

.stats-navigator svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stats-navigator strong {
  min-width: 170px;
  font-size: 0.88rem;
  text-align: center;
}

.stats-empty {
  padding: 58px 20px 64px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.stats-empty strong {
  font-size: 1.1rem;
}

.stats-section {
  min-width: 0;
}

.stats-section--completion {
  padding: 22px 0 26px;
  border-top: 1px solid var(--line);
}

.chart-heading {
  align-items: flex-start;
  margin-bottom: 18px;
}

.chart-summary {
  color: var(--accent-dark);
  font-size: 1.45rem;
}

.stacked-chart {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  height: 264px;
  gap: 8px;
}

.chart-y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 216px;
  color: var(--ink-muted);
  font-size: 0.66rem;
  text-align: right;
}

.stacked-bar-plot {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(42px, 1fr);
  align-items: stretch;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  background:
    linear-gradient(to bottom, var(--line) 1px, transparent 1px) 0 0 / 100% 50%,
    linear-gradient(to bottom, transparent calc(100% - 1px), var(--line) calc(100% - 1px));
}

.stacked-bar-item {
  display: grid;
  grid-template-rows: 216px 42px;
  min-width: 42px;
  place-items: end center;
}

.stacked-bar-label {
  display: grid;
  align-self: center;
  max-width: 8ch;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 0.64rem;
  line-height: 1.15;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stacked-bar-label strong {
  color: var(--ink);
  font-size: 0.68rem;
}

.stacked-bar-stack {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  width: min(42px, 74%);
  height: 100%;
  overflow: hidden;
  border-radius: 7px 7px 2px 2px;
  background: var(--paper-deep);
}

.stack-segment {
  display: grid;
  flex: 0 0 auto;
  min-height: 0;
  place-items: center;
}

.chart-color-key {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 8px;
  margin: 14px 0 0 46px;
}

.chart-color-key-item {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  border-radius: 5px;
  padding: 3px 6px;
  color: var(--ink);
  background: color-mix(in srgb, var(--legend-color), transparent 67%);
  font-size: 0.7rem;
  font-weight: 720;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-lower-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  border-top: 1px solid var(--line);
}

.stats-section--mix {
  padding: 24px 24px 2px 0;
  border-right: 1px solid var(--line);
}

.stats-section--streaks {
  padding: 24px 0 2px 24px;
}

.mix-layout {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  align-items: center;
  gap: 20px;
}

.mix-donut {
  position: relative;
  display: grid;
  width: 148px;
  height: 148px;
  place-items: center;
  border-radius: 50%;
}

.mix-donut::after {
  position: absolute;
  inset: 30px;
  border-radius: 50%;
  background: var(--surface);
  content: "";
}

.mix-donut > span {
  position: relative;
  z-index: 1;
  display: grid;
  text-align: center;
}

.mix-donut strong {
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1;
}

.mix-donut small {
  margin-top: 4px;
  color: var(--ink-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.mix-legend {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.mix-legend-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--ink-muted);
  font-size: 0.76rem;
}

.mix-legend-row > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mix-legend-row strong {
  color: var(--ink);
}

.mix-legend-icon {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--legend-color);
}

.streak-chart {
  display: grid;
}

.streak-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  padding: 10px 0;
  border-top: 1px solid color-mix(in srgb, var(--line), transparent 35%);
}

.streak-row:first-child {
  border-top: 0;
}

.streak-task {
  min-width: 0;
  gap: 9px;
}

.streak-task > strong {
  overflow: hidden;
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.streak-task-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
}

.streak-task-icon .task-pixel-icon {
  width: 34px;
  height: 34px;
}

.streak-task-icon .task-pixel-icon[src*="/orb-"] {
  width: 26px;
  height: 26px;
}

.streak-metrics {
  justify-content: flex-end;
  gap: 10px;
  color: var(--ink-muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.streak-metrics strong {
  color: var(--accent-dark);
  font-size: 0.86rem;
}

.heat-track {
  display: grid;
  grid-column: 1 / -1;
  grid-auto-flow: column;
  grid-auto-columns: minmax(3px, 1fr);
  gap: 2px;
  height: 11px;
}

.heat-cell {
  border-radius: 2px;
  background: var(--paper-deep);
}

.heat-cell[data-level="1"] { background: #b8d9d4; }
.heat-cell[data-level="2"] { background: #7fbcb4; }
.heat-cell[data-level="3"] { background: #438f86; }
.heat-cell[data-level="4"] { background: var(--accent-dark); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes pet-hop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-13px) scale(1.02); }
  64% { transform: translateY(2px) scale(.99); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes pet-celebrate {
  0% { transform: scale(.98) rotate(0); }
  30% { transform: scale(1.01) rotate(-1deg); }
  62% { transform: scale(1) rotate(1deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes spark-pop {
  0% { opacity: 0; scale: .25; }
  35% { opacity: 1; scale: 1; }
  100% { opacity: 0; scale: 1.6; }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 650px);
    padding-top: 12px;
  }

  .full-date {
    display: none;
  }

  .today-layout {
    display: block;
  }

  .pet-panel {
    position: sticky;
    top: max(0px, env(safe-area-inset-top));
    z-index: 20;
    display: grid;
    grid-template-columns: 126px 1fr;
    width: 100%;
    min-width: 0;
    margin-bottom: 12px;
    padding: 14px;
    contain: paint;
  }

  .pet-stage {
    grid-row: 1 / 4;
    min-height: 126px;
  }

  .pet-image {
    top: 9px;
    width: 132px;
    height: 132px;
  }

  .pet-image.complete {
    top: -14px;
    width: 132px;
    height: 132px;
  }

  .pet-copy {
    align-self: end;
    padding: 6px 0 10px 15px;
  }

  .pet-copy h1 {
    max-width: 14ch;
    font-size: 1.45rem;
  }

  .pet-copy p {
    font-size: 0.82rem;
  }

  .progress-track,
  .save-status {
    margin-left: 15px;
  }

  .save-status {
    margin-top: 8px;
  }

  .pet-environment-status {
    grid-column: 2;
    margin-left: 15px;
  }

  .poop-prop {
    bottom: 4px;
    width: 20px;
    height: 20px;
  }

  .poop-prop--3,
  .poop-prop--4 { bottom: 2px; }
  .poop-prop--5 { left: calc(50% - 10px); bottom: 1px; }

  .daily-panel,
  .week-ledger,
  .stats-panel {
    padding: 18px;
  }

  .stats-lower-grid {
    display: block;
  }

  .stats-section--mix {
    padding-right: 0;
    padding-bottom: 24px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stats-section--streaks {
    padding-left: 0;
  }
}

@media (max-width: 480px) {

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

  .sync-form > div {
    grid-template-columns: 1fr;
  }

  .sync-direction-control {
    grid-template-columns: 1fr;
  }

  .sync-direction-control p {
    grid-column: 1;
  }

  .sync-direction-switch {
    width: 100%;
  }

  .three-rbt-summary #three-rbt-state {
    display: none;
  }
  .brand span:last-child {
    font-size: 0.92rem;
  }

  .pet-panel {
    grid-template-columns: 112px 1fr;
  }

  .pet-stage {
    min-height: 116px;
  }

  .pet-image {
    top: 11px;
    width: 120px;
    height: 120px;
  }

  .pet-image.complete {
    top: -10px;
    width: 120px;
    height: 120px;
  }

  .pet-copy h1 {
    font-size: 1.25rem;
  }

  .pet-copy p {
    line-height: 1.3;
  }

  .day-button {
    min-height: 52px;
  }

  .day-button.has-data:not([aria-pressed="true"])::after {
    bottom: 4px;
  }

  .daily-panel {
    padding: 16px 14px;
  }

  .stats-panel {
    padding: 16px 14px;
  }

  .stats-heading {
    gap: 10px;
  }

  .stats-heading p {
    max-width: 25ch;
    font-size: 0.78rem;
  }

  .period-control {
    min-width: 102px;
  }

  .stacked-chart {
    grid-template-columns: 31px minmax(0, 1fr);
    height: 238px;
    gap: 6px;
  }

  .chart-y-axis {
    height: 188px;
  }

  .stacked-bar-item {
    grid-template-rows: 188px 42px;
  }

  .stacked-bar-plot {
    grid-auto-columns: minmax(36px, 1fr);
    gap: 5px;
  }

  .mix-layout {
    grid-template-columns: 116px minmax(0, 1fr);
    gap: 14px;
  }

  .mix-donut {
    width: 116px;
    height: 116px;
  }

  .mix-donut::after {
    inset: 24px;
  }

  .streak-row {
    gap: 7px 10px;
  }

  .section-actions {
    gap: 6px;
  }

  .task-editor-toggle {
    padding: 0 8px;
    font-size: 0.72rem;
  }

  .task-editor-row {
    grid-template-columns: 40px minmax(0, 1fr) auto;
  }

  .task-editor-row select {
    grid-column: 2 / 4;
    width: 100%;
  }

  .task-editor-status {
    display: none;
  }

  .mood-options {
    gap: 4px;
  }

  .mood-button span {
    font-size: 0.62rem;
  }

  .mood-pixel-icon {
    width: 30px;
    height: 30px;
  }

  .week-ledger {
    padding: 16px 0 16px 14px;
  }

  .ledger-heading {
    padding-right: 14px;
  }

  .week-range {
    display: none;
  }

  .ledger-scroll {
    width: calc(100% + 0px);
  }

  #ledger-table {
    min-width: 500px;
  }

  #ledger-table .ledger-label {
    width: 102px;
    padding: 0 4px;
  }

  #ledger-table .ledger-label > span {
    width: 100%;
    gap: 4px;
    font-size: 0.72rem;
  }

  #ledger-table .ledger-icon-slot {
    width: 29px;
    height: 34px;
    flex-basis: 29px;
  }

  #ledger-table .ledger-label .task-pixel-icon {
    width: 29px;
    height: 29px;
  }

  #ledger-table .ledger-label .task-pixel-icon[src*="/water-"] {
    width: 25px;
    height: 29px;
  }

  #ledger-table .ledger-label .task-pixel-icon[src*="/orb-"] {
    width: 23px;
    height: 23px;
  }

  #ledger-table .ledger-label .mood-pixel-icon {
    width: 23px;
    height: 23px;
  }

  #ledger-table .ledger-label > span > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #ledger-table .ledger-total {
    width: 34px;
  }

  .data-tools--footer {
    margin-right: 14px;
  }

  .chart-color-key {
    margin-left: 37px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
