:root {
  --bg: #f4f1ed;
  --board: transparent;
  --card: #fffefa;
  --text: #181714;
  --muted: #817d75;
  --line: #ddd8ce;
  --shadow-sm: 0 4px 12px rgba(24, 23, 20, 0.05);
  --shadow-md: 0 10px 24px rgba(24, 23, 20, 0.09);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

button {
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}

label,
[role="button"],
[data-photo-trigger],
[data-page-link],
.photo-trigger,
.meal-photo-add,
.entry-photo-add,
.toilet-add,
.toilet-marker-icon-button,
.toilet-type-toggle,
.toilet-type-option,
.remove-toilet,
.remove-entry,
.remove-photo,
.note-card {
  cursor: pointer;
}

input, textarea {
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  resize: none;
}

p, ul, ol { margin: 0; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 2px;
}

/* ---- layout ---- */

.shell {
  width: min(1340px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 0;
}

/* ---- top bar ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  flex-wrap: wrap;
  padding-bottom: 10px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: left;
}

.kicker img {
  display: block;
  width: 44px;
  height: auto;
}

.brand-link:hover,
.brand-link[aria-current="page"] {
  color: var(--text);
}

.clock {
  font-size: 0.75rem;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.app-menu {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin-left: 12px;
}

.app-menu button {
  min-height: 24px;
  padding: 0 8px;
  font-size: 0.66rem;
  color: var(--muted);
  border: 1px solid transparent;
}

.app-menu button:hover,
.app-menu button[aria-current="page"] {
  color: var(--text);
  background: var(--board);
  border-color: var(--line);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--muted);
}

.icon-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:hover {
  color: var(--text);
}

/* ---- week controls ---- */

.week-controls {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 28px;
  gap: 2px;
  margin-bottom: 14px;
}

.week-controls button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--board);
}

.week-controls button:hover,
.week-controls button.active {
  color: var(--text);
}

.week-nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.week-nav-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#current-week {
  min-width: 0;
  text-align: center;
}

/* ---- weekly summary ---- */

.weekly-summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  padding: 1px 8px 1px 6px;
  font-size: 0.6rem;
  color: var(--muted);
  border-left: 1px solid var(--line);
}

.smry-dots {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  margin-right: 2px;
}

.smry-dot {
  font-size: 0.45rem;
  line-height: 1;
}

.smry-dot--none {
  color: var(--line);
}

.smry-dot--has {
  color: #9bbb7e;
}

.smry-badge {
  font-size: 0.5rem;
  padding: 0 5px;
  border-radius: 3px;
  text-transform: uppercase;
  line-height: 1.5;
}

.smry-badge--good { background: #e1f0da; color: #2d6a2d; }
.smry-badge--fair { background: #fcf0cf; color: #856404; }
.smry-badge--alert { background: #f5dbd6; color: #9d3228; }
.smry-badge--neutral { background: #eae7e2; color: #5c5850; }

.smry-sep {
  color: var(--line);
  margin: 0 1px;
}

.smry-stat {
  white-space: nowrap;
}

.smry-alerts {
  display: inline-flex;
  gap: 4px;
}

.smry-alert {
  font-size: 0.5rem;
  color: #9d3228;
  text-transform: uppercase;
}

.week-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 0.55rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease;
}

.week-copy:hover {
  color: var(--text);
  background: rgba(24, 23, 20, 0.06);
}

/* ---- board ---- */

.week-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  overflow-x: auto;
  background: transparent;
}

.day-column {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: calc(100vh - 80px);
  padding: 10px 8px 8px;
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  opacity: 0.62;
  transition: opacity 180ms ease, box-shadow 180ms ease;
}

.day-column + .day-column {
  border-left: 0;
}

.day-column.is-today {
  background: var(--card);
  opacity: 1;
  box-shadow: var(--shadow-md);
}

.day-column:hover {
  opacity: 0.9;
}

.day-column.is-today:hover {
  opacity: 1;
}

.day-column.has-open-toilet-type {
  z-index: 25;
}

/* ---- day header ---- */

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  padding: 0;
}

.day-name {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  color: var(--text);
}

.day-date {
  font-size: 0.62rem;
  color: var(--muted);
}

.day-tools {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.day-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 0.6rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease;
}

.day-copy:hover {
  color: var(--text);
  background: rgba(24, 23, 20, 0.06);
}

/* ---- categories (food + trackers) ---- */

.day-group {
  padding: 0;
}

.day-group + .day-group {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

h2 {
  margin: 0 0 6px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text);
  letter-spacing: 0;
}

/* ---- food ---- */

.food-group {
  flex: 0 0 auto;
  padding-top: 2px;
}

.recipes {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recipes li {
  margin: 0;
}

.recipes li + li {
  border-top: 0;
}

.meal-card,
.toilet-card,
.tracker,
.day-note {
  background: var(--card);
  border: 0;
  border-radius: 8px;
  box-shadow: none;
}

.slot-tone-0,
.slot-tone-1,
.slot-tone-2,
.slot-tone-3,
.slot-tone-4 {
  background: #f8f7f4;
}

.meal-card {
  padding: 8px 10px 10px;
}

.meal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  opacity: 0.4;
  transition: opacity 180ms ease;
}

.meal-card:hover .meal-card-header,
.meal-card:focus-within .meal-card-header {
  opacity: 1;
}

.toilet-card {
  padding: 0 10px;
  background: #fffefa;
  box-shadow: var(--shadow-sm);
}

.toilet-card-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.meal-input-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.meal-delete {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  font-size: 0.7rem;
  line-height: 1;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.meal-delete:hover {
  color: #9d3228;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-drag-handle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 100%;
  font-size: 0.6rem;
  line-height: 1;
  color: var(--line);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.card-drag-handle:active {
  cursor: grabbing;
}

.toilet-card-row .card-drag-handle {
  height: 24px;
}

.meal-card.dnd-ghost,
.toilet-card.dnd-ghost {
  opacity: 0.4;
  box-shadow: none;
}

.meal-card.dnd-chosen,
.toilet-card.dnd-chosen {
  box-shadow: var(--shadow-sm);
}

.meal-card.dnd-drag,
.toilet-card.dnd-drag,
.meal-card.dnd-fallback,
.toilet-card.dnd-fallback {
  box-shadow: 0 12px 28px rgba(24, 23, 20, 0.16);
  opacity: 0.92;
}

.meal-card.is-dragging,
.toilet-card.is-dragging {
  opacity: 0.6;
}

.card-add-bar {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.card-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
  transition: opacity 180ms ease, color 180ms ease;
}

.card-add-toilet {
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  border-radius: 50%;
  opacity: 0.5;
}

.card-add-toilet:hover {
  opacity: 1;
  color: var(--text);
  background: rgba(24, 23, 20, 0.06);
}

.card-add-meal {
  font-size: 0.5rem;
  padding: 1px 6px;
  min-height: 18px;
  opacity: 0.4;
}

.card-add-meal:hover {
  opacity: 0.8;
  color: var(--text);
  background: rgba(24, 23, 20, 0.04);
}

.tracker {
  padding: 12px;
  background: #fbfaf7;
}

.meal-card:focus-within,
.toilet-card:focus-within,
.tracker:focus-within,
.day-note:focus-within {
  border-color: rgba(24, 23, 20, 0.18);
  box-shadow: inset 0 0 0 1px rgba(24, 23, 20, 0.08);
}

.meal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 1px;
}

.meal-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.meal {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  flex: 1 1 auto;
  min-width: 0;
}

.slot-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.slot-input {
  min-width: 0;
  min-height: 22px;
  font-size: 0.58rem;
  line-height: 1.1;
}

.slot-delete {
  flex: 0 0 auto;
  min-width: 16px;
  min-height: 22px;
  color: var(--muted);
}

.slot-delete:hover {
  color: #9d3228;
}

.slot-gap {
  display: flex;
  justify-content: center;
}

.slot-add {
  color: var(--muted);
  font-size: 0.8rem;
}

.slot-add:hover {
  color: var(--text);
}

.fav-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 0.7rem;
  color: #d4cfc4;
  line-height: 1;
  margin-left: auto;
  transition: color 180ms ease, transform 180ms ease;
}

.fav-star:hover {
  color: #d4a84b;
  transform: scale(1.2);
}

.fav-star.is-active {
  color: #d4a84b;
}

.meal-photo-add,
.entry-photo-add {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}

.photo-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0;
  font-size: 0.8rem;
  color: inherit;
  pointer-events: auto;
  user-select: none;
  cursor: pointer;
}

.photo-add-icon {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.meal-photo-add:hover,
.entry-photo-add:hover {
  color: var(--text);
}

.meal-photo-add input,
.entry-photo-add input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  clip-path: inset(50%);
  margin: 0;
}

.recipe-input,
.fav-recipe-input {
  min-height: 22px;
  max-height: 2.2rem;
  font-size: 0.58rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
  overflow: hidden;
  transition: max-height 180ms ease;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 3px;
  padding: 2px 4px;
  margin: 0 -4px;
  width: calc(100% + 8px);
}

.recipe-input:focus-visible,
.fav-recipe-input:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.7);
}

.recipe-input.is-expanded,
.fav-recipe-input.is-expanded {
  max-height: none;
  overflow: auto;
}

.toilet-gap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  min-height: 36px;
  padding: 6px 10px;
  overflow: visible;
}

.toilet-gap.has-marker {
  background: #fffefa;
  border: 0;
  box-shadow: var(--shadow-sm);
}

.toilet-gap:not(.has-marker) {
  position: relative;
  place-items: center;
  height: 34px;
  min-height: 34px;
  margin: 0;
  padding: 0 !important;
  background: transparent;
  border: 0;
  box-shadow: none;
  opacity: 0.58;
}

.toilet-gap:not(.has-marker) .toilet-add {
  position: absolute;
  top: 50%;
  left: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  min-height: 18px;
  line-height: 1;
  transform: translate(-50%, -50%);
}

.toilet-markers {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 16px;
}

.toilet-marker-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 14px;
  grid-template-rows: auto;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}

.toilet-add {
  flex: 0 0 auto;
  min-width: 20px;
  min-height: 20px;
  padding: 0;
  line-height: 1;
  color: var(--muted);
  font-size: 0.82rem;
}

.toilet-marker-icon-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 24px;
}

.toilet-marker-icon {
  display: block;
  width: 42px;
  height: 24px;
  object-fit: contain;
}

.toilet-marker-icon-button:hover .toilet-marker-icon {
  filter: brightness(0.96);
}

.toilet-type-menu {
  flex: 0 0 auto;
  position: relative;
  width: 42px;
  min-width: 42px;
  pointer-events: none;
}

.toilet-type-toggle {
  position: absolute;
  inset: 0;
  width: 42px;
  min-height: 24px;
  color: transparent;
  border: 0;
  pointer-events: auto;
}

.toilet-type-toggle:hover {
  border-bottom-color: transparent;
}

.toilet-type-toggle > span {
  display: none;
}

.toilet-type-value {
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.toilet-type-text {
  min-width: 0;
  font-size: 0.5rem;
  line-height: 1.05;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toilet-type-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  display: none;
  width: min(210px, calc(100vw - 36px));
  padding: 5px;
  background: var(--card);
  border: 0;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(24, 23, 20, 0.16);
}

.toilet-type-menu.is-open .toilet-type-options {
  display: grid;
  gap: 3px;
}

.toilet-type-option {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 40px auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 30px;
  padding: 3px 5px;
  text-align: left;
  background: transparent;
}

.toilet-type-option:hover,
.toilet-type-option.is-selected {
  background: #f3f0e9;
}

.toilet-type-option img {
  display: block;
  width: 36px;
  height: 22px;
  object-fit: contain;
}

.toilet-comment {
  flex: 1 1 auto;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 16px;
  font-size: 0.54rem;
  line-height: 1.18;
  padding-bottom: 1px;
  color: var(--text);
  overflow: hidden;
  overflow-wrap: anywhere;
}

.toilet-comment::placeholder {
  color: #bcb6aa;
}

.toilet-gap.has-marker .toilet-add {
  display: none;
}

.toilet-add:hover,
.remove-toilet:hover {
  color: #9d3228;
}

.remove-toilet {
  flex: 0 0 auto;
  width: 14px;
  height: 18px;
  color: var(--muted);
  text-align: right;
}

/* ---- tracker form ---- */

form {
  display: grid;
  grid-template-columns: 1fr 16px;
  gap: 4px;
}

form input {
  min-height: 22px;
  font-size: 0.56rem;
  line-height: 1.1;
}

input::placeholder {
  color: #bbb6a8;
}

form button {
  min-width: 16px;
  min-height: 22px;
  color: var(--muted);
  text-align: right;
}

form button:hover {
  color: var(--text);
}

/* ---- tracker entries ---- */

.entries {
  display: grid;
  max-height: 72px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.entries li {
  padding: 4px 0;
}

.entries li + li {
  border-top: 0;
}

.entry-time { display: none; }

.entry-text {
  font-size: 0.58rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
  flex: 1 1 auto;
}

.remove-entry {
  width: 14px;
  height: 16px;
  color: var(--muted);
  text-align: right;
}

.remove-entry:hover { color: #9d3228; }
.remove-photo:hover { color: #9d3228; }

.empty {
  display: block;
  padding: 4px 0;
  font-size: 0.58rem;
  color: var(--muted);
}

.day-note {
  margin-top: auto;
  padding: 8px 10px;
  background: #fbfaf7;
}

.day-note-preview {
  display: block;
  width: 100%;
  min-height: 26px;
  padding: 0;
  font-size: 0.58rem;
  line-height: 1.2;
  color: var(--text);
  background: transparent;
  overflow: hidden;
  text-align: left;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.day-note-preview.is-empty {
  color: #c5bfb2;
}

/* ---- photos ---- */

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(var(--photo-columns, 1), minmax(0, 1fr));
  gap: 5px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.meal-card > .photo-gallery {
  margin: 8px 0 0;
}

.photo-gallery li {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--line);
  border-radius: 8px;
  transition: transform 180ms ease, opacity 180ms ease, box-shadow 180ms ease;
}

.photo-thumb {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.photo-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(24, 23, 20, 0.04);
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.photo-thumb,
.note-card {
  cursor: grab;
}

.photo-thumb:active,
.note-card:active {
  cursor: grabbing;
}

.photo-gallery:not(.is-reordering) li:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(24, 23, 20, 0.12);
}

.photo-gallery:not(.is-reordering) li:hover .photo-thumb::after {
  opacity: 1;
}

.photo-gallery:not(.is-reordering) li:hover .photo-thumb img {
  transform: scale(1.025);
}

.is-reordering .photo-gallery li,
.photo-gallery.is-reordering li,
.notes-board.is-reordering .note-card {
  transition: transform 180ms ease, opacity 180ms ease, box-shadow 180ms ease;
}

.note-card.dnd-ghost {
  opacity: 0.28;
  box-shadow: none !important;
}

li[data-photo-id].dnd-ghost {
  opacity: 1;
  box-shadow: none !important;
}

.dnd-chosen {
  box-shadow: 0 10px 24px rgba(24, 23, 20, 0.16);
}

.dnd-drag,
.dnd-fallback {
  z-index: 1000;
  opacity: 0.94;
  box-shadow: 0 16px 34px rgba(24, 23, 20, 0.2);
  cursor: grabbing;
  pointer-events: none;
  transition: none !important;
  will-change: auto;
}

.dnd-fallback *,
.dnd-drag * {
  transition: none !important;
}

.dnd-ghost,
.is-dragging {
  transition: none !important;
}

.notes-board.is-dragging-note .dnd-ghost {
  opacity: 0.1;
  color: transparent;
  box-shadow: none !important;
}

.notes-board.is-dragging-note .dnd-ghost::after {
  opacity: 0;
}

.note-card.dnd-fallback {
  opacity: 0.98;
  transform-origin: center;
  box-shadow: 0 18px 36px rgba(24, 23, 20, 0.22);
}

li[data-photo-id].dnd-fallback,
li[data-photo-id].dnd-drag {
  position: relative;
  overflow: hidden;
  background: var(--line);
}

li[data-photo-id].dnd-fallback .photo-thumb,
li[data-photo-id].dnd-drag .photo-thumb {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.photo-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
  opacity: 1;
  color: transparent;
  font-size: 0;
  transition: transform 180ms ease, filter 180ms ease;
}

.remove-photo {
  position: absolute;
  top: 2px;
  right: 3px;
  width: 16px;
  height: 16px;
  color: #fff;
  background: rgba(0,0,0,0.35);
}

/* ---- photo modal ---- */

.photo-modal[hidden] {
  display: none;
}

.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(24, 23, 20, 0.22);
}

.photo-modal__backdrop {
  position: absolute;
  inset: 0;
}

.photo-modal__sheet {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100vw - 12px));
  max-height: min(90vh, 840px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: #fbfaf6;
  border: 1px solid rgba(24, 23, 20, 0.16);
  box-shadow: var(--shadow-md);
}

.photo-modal__head,
.photo-modal__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.photo-modal__head h3 {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.photo-modal__close,
.photo-modal__nav {
  color: var(--muted);
}

.photo-modal__close {
  min-width: 24px;
  min-height: 24px;
}

.photo-modal__nav {
  width: 28px;
  height: 28px;
  font-size: 1rem;
  line-height: 1;
}

.photo-modal__close:hover,
.photo-modal__nav:hover {
  color: var(--text);
}

.photo-modal__stage {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  min-height: 50vh;
  flex: 1 1 auto;
}

.photo-modal__stage img {
  grid-column: 2;
  display: block;
  width: 100%;
  height: 100%;
  max-height: calc(94vh - 140px);
  object-fit: contain;
  background: #f4f1ea;
}

.photo-modal__counter,
.photo-modal__caption {
  font-size: 0.58rem;
  color: var(--muted);
}

/* ---- upload status ---- */

.upload-toast[hidden] {
  display: none;
}

.upload-toast {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 8px;
  color: var(--text);
  background: rgba(251, 250, 246, 0.96);
  border: 1px solid rgba(24, 23, 20, 0.12);
  box-shadow: var(--shadow-sm);
  transform: translateX(-50%);
  font-size: 0.5rem;
}

.upload-toast__spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(24, 23, 20, 0.18);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: upload-spin 0.8s linear infinite;
}

@keyframes upload-spin {
  to { transform: rotate(360deg); }
}

/* ---- server note ---- */

.server-note {
  padding: 24px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---- about ---- */

.about-page {
  background: var(--board);
  border: 1px solid var(--line);
}

.about-content {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 52px;
}

.about-content h1,
.about-content h2,
.about-content h3 {
  margin: 0;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.about-content h1 {
  margin-bottom: 26px;
  font-size: 3.2rem;
  line-height: 0.92;
}

.about-content h2 {
  margin: 38px 0 14px;
  font-size: 1rem;
  line-height: 1.15;
}

.about-content h3 {
  margin: 26px 0 10px;
  font-size: 0.82rem;
  line-height: 1.2;
}

.about-content p,
.about-content li {
  font-size: 0.9rem;
  line-height: 1.55;
}

.about-content p + p {
  margin-top: 16px;
}

.about-content ul {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding-left: 18px;
}

.about-content section {
  padding: 18px 0 22px;
  border-top: 1px solid var(--line);
}

/* ---- notes ---- */

.notes-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.notes-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.notes-head h2 {
  margin-bottom: 0;
}

#add-note,
#add-note-photo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--board);
  line-height: 1;
  font-size: 0.75rem;
}

#add-note:hover,
#add-note-photo:hover {
  color: var(--text);
}

.notes-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, 96px);
  grid-auto-rows: 96px;
  justify-content: start;
  gap: 10px;
}

.note-photos {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 2px;
}

.note-photos-board .photo-gallery {
  margin-top: 0;
  grid-template-columns: repeat(auto-fill, 96px);
  grid-auto-rows: 96px;
  gap: 8px;
}

.note-photos-board .photo-gallery li {
  width: 96px;
  height: 96px;
  aspect-ratio: auto;
  transform: none;
  will-change: auto;
}

.note-photos-board .photo-gallery:not(.is-reordering) li:hover {
  transform: none;
  box-shadow: 0 4px 10px rgba(24, 23, 20, 0.1);
}

.note-photos-board .photo-thumb::after {
  display: none;
}

.note-photos-board .photo-thumb img {
  opacity: 1;
  transform: none;
  filter: none;
}

.notes-empty {
  padding: 4px 0 2px;
  font-size: 0.7rem;
  color: var(--muted);
}

.note-card {
  position: relative;
  width: 96px;
  height: 96px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  text-align: left;
  border: 1px solid rgba(24, 23, 20, 0.08);
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, opacity 180ms ease;
}

.note-card::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.notes-board:not(.is-reordering) .note-card:hover {
  transform: translateY(-2px);
  border-color: rgba(24, 23, 20, 0.16);
  box-shadow: 0 8px 18px rgba(24, 23, 20, 0.12);
}

.notes-board:not(.is-reordering) .note-card:hover::after {
  opacity: 1;
}

.note-card:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 2px;
}

.note-card.is-active {
  outline: none;
  border-color: transparent;
}

.note-card--sun,
.note-card--mint,
.note-card--sky,
.note-card--rose,
.note-card--lavender {
  background: #f3f0eb;
}

.note-tone-picker {
  display: flex;
  gap: 6px;
  padding: 2px 0;
}

.note-tone-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: border-color 180ms ease, transform 180ms ease;
}

.note-tone-btn:hover {
  transform: scale(1.15);
}

.note-tone-btn.is-selected {
  border-color: var(--text);
}

.note-tone-btn--sun,
.note-tone-btn--mint,
.note-tone-btn--sky,
.note-tone-btn--rose,
.note-tone-btn--lavender {
  background: #d4cfc4;
}

.note-card__label {
  font-size: 0.56rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.note-card__preview {
  font-size: 0.66rem;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  white-space: normal;
  overflow-wrap: anywhere;
}

.note-modal[hidden] {
  display: none;
}

.note-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(24, 23, 20, 0.16);
}

.note-modal__backdrop {
  position: absolute;
  inset: 0;
}

.note-modal__sheet {
  position: relative;
  z-index: 1;
  width: min(360px, calc(100vw - 24px));
  max-height: min(72vh, 480px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--card);
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

.note-modal__sheet--sun,
.note-modal__sheet--mint,
.note-modal__sheet--sky,
.note-modal__sheet--rose,
.note-modal__sheet--lavender {
  background: var(--card);
}

.note-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.note-modal__head h3 {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.note-modal__close,
.note-modal__delete {
  min-height: 24px;
  color: var(--muted);
}

.note-modal__close {
  width: 24px;
}

.note-modal__delete {
  align-self: flex-end;
  font-size: 0.65rem;
  text-transform: uppercase;
}

.note-modal__close:hover,
.note-modal__delete:hover {
  color: #9d3228;
}

.note-input,
.day-note-modal-input {
  display: block;
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
  padding: 6px 8px;
  font-size: 0.58rem;
  line-height: 1.25;
  color: var(--text);
  background: rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  overflow: auto;
}

.note-input:focus-visible,
.day-note-modal-input:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.7);
}

.note-input[readonly],
.day-note-modal-input[readonly] {
  cursor: pointer;
}

.note-input--modal,
.day-note-modal-input {
  min-height: 220px;
}

/* ---- favourites ---- */

.favourites {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.favourites__head {
  margin-bottom: 10px;
}

.favourites__title {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.favourites__grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.favourites__col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.favourites__col-label {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.favourites .meal-card {
  padding: 10px;
  background: transparent;
  border: 1px solid rgba(24, 23, 20, 0.06);
}

.fav-card-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.fav-plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.fav-plan-btn {
  padding: 3px 8px;
  border: 1px solid rgba(24, 23, 20, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.fav-plan-btn:hover {
  color: var(--ink);
  border-color: rgba(24, 23, 20, 0.22);
}

.recipe-plan-confirm,
.recipe-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 0.7rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.recipe-plan-confirm:hover {
  color: #2d6a3e;
}

.recipe-clear:hover {
  color: #9d3228;
}

/* ---- footer ---- */

.statusline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 6px;
  font-size: 0.65rem;
  color: var(--muted);
}

#completion-count {
  min-width: 0;
  flex: 1 1 auto;
}

/* ---- responsive ---- */

@media (max-width: 980px) {
  .shell {
    width: min(100% - 16px, 760px);
    padding-top: 10px;
  }

  .week-board {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .day-column {
    flex: 0 0 calc((100% - 16px) / 3);
    scroll-snap-align: start;
    scroll-snap-stop: normal;
    min-width: 0;
    min-height: calc(100vh - 80px);
    padding: 8px 6px 6px;
  }

  .day-column + .day-column {
    border-left: 0;
  }

  .favourites__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .shell {
    width: calc(100% - 12px);
  }

  .week-board {
    gap: 6px;
  }

  .day-column {
    flex: 0 0 calc((100% - 6px) / 2);
    min-height: calc(100vh - 70px);
    padding: 8px 5px 5px;
  }

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

@media (max-width: 520px) {
  .shell { width: calc(100% - 10px); }

  .topbar {
    align-items: flex-start;
    padding-bottom: 8px;
  }

  .app-menu {
    order: 3;
    width: 100%;
    margin-left: 0;
  }

  .topbar-right {
    gap: 6px;
  }

  .week-controls {
    grid-template-columns: 26px minmax(0, 1fr) 26px;
    gap: 4px;
  }

  .week-controls button {
    min-height: 26px;
    padding: 0 6px;
    font-size: 0.62rem;
  }

  .icon-button {
    width: 18px;
    height: 18px;
  }

  .week-board {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .week-board::-webkit-scrollbar {
    display: none;
  }

  .day-column {
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    min-width: 0;
    min-height: calc(100vh - 70px);
    padding: 8px 8px 6px;
  }

  .day-column + .day-column {
    border-left: 0;
  }

  .day-name { font-size: 0.72rem; }

  .meal-card { padding-inline: 10px; padding-block: 10px; }

  .toilet-card { padding-inline: 10px; }

  .meal-card > .photo-gallery {
    margin-inline: 0;
    margin-bottom: 0;
  }

  .recipe-input { font-size: 0.56rem; }
  .slot-input { font-size: 0.52rem; }

  .day-group { padding: 0; }
  .tracker,
  .day-note { padding: 8px 10px; }
  .day-group + .day-group {
    padding-top: 0;
    margin-top: 0;
  }

  .notes-board {
    grid-template-columns: repeat(auto-fill, 80px);
    grid-auto-rows: 80px;
    justify-content: start;
    gap: 6px;
  }

  .note-card {
    width: 80px;
    height: 80px;
    padding: 6px;
  }

  .note-card__preview {
    -webkit-line-clamp: 3;
  }

  .note-modal__sheet {
    width: min(100%, 400px);
    max-height: 80vh;
    padding: 8px;
  }

  .about-content {
    width: calc(100% - 16px);
    padding: 20px 0 30px;
  }

  .about-content h1 {
    font-size: 2rem;
  }

  .day-note {
    padding: 6px 8px;
  }

  .day-note-preview {
    min-height: 22px;
    font-size: 0.5rem;
  }

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

/* ---- auth / landing ---- */

.landing-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

body.auth--logged-in .landing-page {
  display: none;
}

.landing-card {
  width: min(320px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.landing-card > img {
  display: block;
}

.landing-tagline {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

#auth-signin {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#auth-signin input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--board);
  color: var(--text);
}

#auth-signin button {
  padding: 10px 12px;
  border: none;
  border-radius: 6px;
  background: var(--text);
  color: var(--card);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

#auth-signin button:hover {
  opacity: 0.85;
}

#auth-signin button:disabled {
  opacity: 0.5;
}

.auth-message {
  margin: 0;
  font-size: 0.7rem;
  color: #9d3228;
  min-height: 1.2em;
}

.auth-link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px;
}

.auth-link-btn:hover {
  color: var(--text);
}

.auth-logout {
  color: #9d3228;
}

body.auth--logged-in .auth-logout {
  display: inline-flex;
}

body.auth--logged-out .auth-logout {
  display: none;
}

#auth-logout-topbar {
  width: 30px;
  height: 30px;
  padding: 4px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

#auth-logout-topbar:hover {
  color: #9d3228;
  background: rgba(157, 50, 40, 0.08);
}

body:not(.auth--logged-in):not(.auth--logged-out) {
  visibility: hidden;
}
body.auth--logged-out .app-shell {
  display: none;
}


