:root {
  --paper:        #E5E6DC;
  --paper-sheet:  #F3F3EA;
  --ink:          #1B1E1C;
  --ink-soft:     #666B62;
  --rule:         #C9CCBD;

  /* Two accents, one per person. Sage is people[0], blue is people[1]. */
  --sage:         #6B8065;
  --sage-faint:   rgba(107, 128, 101, 0.22);
  --blue:         #2F5D8C;
  --blue-faint:   rgba(47, 93, 140, 0.20);

  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body:    "Inter Tight", system-ui, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 4vh 1.15rem 3rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
}

.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;
}

/* The page as a single sheet of paper laid on a desk. */
.sheet {
  max-width: 46rem;
  margin: 0 auto;
  background: var(--paper-sheet);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 var(--rule), 0 18px 40px -34px rgba(27, 30, 28, 0.8);
  padding: clamp(1.6rem, 5vw, 3.2rem);
}

.sheet > section { padding-block: clamp(1.7rem, 5vw, 2.6rem); }
.sheet > section + section { border-top: 1px solid var(--rule); }

/* ---------- shared bits ---------- */

.label, .eyebrow, .whoami-label, .tally-key, .status, .hint {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}

.hint { margin-top: 0.5rem; letter-spacing: 0.08em; text-transform: none; font-size: 0.78rem; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1.2rem;
  align-items: baseline;
  justify-content: space-between;
}

.btn {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper-sheet);
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
}
.btn:hover { background: var(--sage); border-color: var(--sage); }
.btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- masthead ---------- */

.masthead { padding-bottom: clamp(1.4rem, 4vw, 2.2rem); }

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.4rem, 10vw, 4.1rem);
  line-height: 0.94;
  letter-spacing: -0.035em;
  margin: 0.7rem 0 0;
}

/* ---------- the note ---------- */

.note p {
  margin: 0 0 1rem;
  font-size: clamp(1.02rem, 2.6vw, 1.14rem);
  max-width: 34em;
}
.note p:last-of-type { margin-bottom: 0; }

.note-signoff {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 1.4rem;
}

/* ---------- the counter ---------- */

.clock {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2.1rem, 9.5vw, 3.6rem);
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0.85rem 0 0;
  font-variant-numeric: tabular-nums;
}

.clock-unit + .clock-unit { margin-left: 0.55em; }

.clock-unit .suffix {
  font-family: var(--mono);
  font-size: 0.3em;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-left: 0.12em;
  vertical-align: 0.55em;
}

.clock-unit.sec .num { color: var(--blue); }

/* ---------- milestone + tally ---------- */

.headline {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.5rem, 5.4vw, 2.15rem);
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin: 0;
}

.subline {
  margin: 0.55rem 0 0;
  color: var(--ink-soft);
  max-width: 36em;
}

/* Signature: one pen mark per day, struck through in fives.
   Inked marks are days gone. Faint marks are days left. */
.tally {
  display: flex;
  flex-wrap: wrap;
  gap: 0.62rem 0.85rem;
  margin-top: 1.7rem;
}

.tally-group {
  position: relative;
  display: flex;
  gap: 3px;
  height: 26px;
}

.tally-mark {
  width: 2px;
  height: 100%;
  background: var(--blue-faint);
  border-radius: 1px;
}
.tally-mark.inked { background: var(--blue); }

.tally-slash {
  position: absolute;
  left: -3px;
  top: 50%;
  width: 26px;
  height: 2px;
  border-radius: 1px;
  background: var(--blue-faint);
  transform: rotate(-24deg);
  transform-origin: center;
}
.tally-slash.inked { background: var(--blue); }

.tally-key { margin-top: 1.1rem; }

/* ---------- check-in ---------- */

.whoami { display: flex; align-items: baseline; gap: 0.5rem; }

.whoami-btn {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--sage);
  color: var(--sage);
  padding: 0 0 1px;
  cursor: pointer;
}

.moods {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.2rem;
}

.mood {
  font-family: var(--body);
  font-size: 0.95rem;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.mood:hover { border-color: var(--sage); }
.mood[aria-pressed="true"] {
  background: var(--sage);
  border-color: var(--sage);
  color: var(--paper-sheet);
}
.mood:disabled { opacity: 0.45; cursor: default; }

.status { margin-top: 0.95rem; min-height: 1.1em; }

.today-list {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
}

.today-list li {
  display: flex;
  gap: 0.9rem;
  align-items: baseline;
  padding: 0.6rem 0;
  border-top: 1px solid var(--rule);
}

.who {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  flex: 0 0 auto;
}
.who.p1 { color: var(--sage); }
.who.p2 { color: var(--blue); }

.today-list .who { min-width: 5.5rem; }

.today-list .when {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-left: auto;
  flex: 0 0 auto;
}

/* ---------- weekly question ---------- */

.question {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.35rem, 4.6vw, 1.85rem);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0.75rem 0 0;
  max-width: 22em;
}

.answers { margin-top: 1.6rem; }

.answer {
  border-left: 2px solid var(--rule);
  padding: 0.15rem 0 0.15rem 1rem;
  margin-bottom: 1.2rem;
}
.answer.p1 { border-left-color: var(--sage); }
.answer.p2 { border-left-color: var(--blue); }

.answer p { margin: 0.35rem 0 0; white-space: pre-wrap; }

.answers-empty { color: var(--ink-soft); margin: 0; }

/* ---------- composers ---------- */

.composer { margin-top: 1.5rem; }

.composer textarea {
  width: 100%;
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.8rem 0.9rem;
  resize: vertical;
}
.composer textarea:focus { border-color: var(--sage); outline: none; }

.composer-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.8rem;
}
.composer-foot .status { margin-top: 0; }

/* ---------- timeline ---------- */

.day { margin-top: 1.6rem; }

.day-head {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
  margin: 0;
}

.entry { padding: 0.85rem 0; border-bottom: 1px solid var(--rule); }

.entry-meta {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  margin-bottom: 0.25rem;
}

.entry-kind {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-left: auto;
}

.entry-body { margin: 0; white-space: pre-wrap; }

.entry-q {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-soft);
  margin: 0 0 0.3rem;
}

.timeline-empty { color: var(--ink-soft); margin: 1.2rem 0 0; }

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

.colophon {
  margin-top: clamp(1.8rem, 5vw, 2.6rem);
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
}
.colophon p {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}

/* ---------- name picker ---------- */

.picker {
  position: fixed;
  inset: 0;
  background: rgba(27, 30, 28, 0.55);
  display: grid;
  place-items: center;
  padding: 1.2rem;
  z-index: 10;
}
.picker[hidden] { display: none; }

.picker-card {
  background: var(--paper-sheet);
  border: 1px solid var(--rule);
  padding: 1.8rem;
  max-width: 24rem;
  width: 100%;
}
.picker-card h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}
.picker-card p { margin: 0 0 1.3rem; color: var(--ink-soft); }

.picker-btns { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.picker-btns button {
  font-family: var(--body);
  font-size: 1rem;
  flex: 1 1 auto;
  color: var(--paper-sheet);
  border-radius: 2px;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
}
.picker-btns button.p1 { background: var(--sage); border: 1px solid var(--sage); }
.picker-btns button.p2 { background: var(--blue); border: 1px solid var(--blue); }

/* ---------- accessibility floor ---------- */

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- edit + delete controls ---------- */

.row-actions {
  display: flex;
  gap: 0.9rem;
  margin-top: 0.5rem;
}

.today-list .row-actions { margin-top: 0; margin-left: 0.9rem; flex: 0 0 auto; }

.link-btn {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--ink-soft);
  padding: 0 0 1px;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); border-bottom-color: var(--ink); }
.link-btn.armed { color: #8C3A2F; border-bottom-color: #8C3A2F; }

/* ---------- the front door ---------- */

body.locked { overflow: hidden; }

body.locked .sheet {
  filter: blur(9px) saturate(0.85);
  pointer-events: none;
  user-select: none;
}

.sheet { transition: filter 0.5s ease; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(229, 230, 220, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.gate[hidden] { display: none; }

.gate.opening {
  opacity: 0;
  transition: opacity 0.45s ease;
}

.gate-card {
  width: 100%;
  max-width: 25rem;
  background: var(--paper-sheet);
  border: 1px solid var(--rule);
  box-shadow: 0 24px 60px -30px rgba(27, 30, 28, 0.55);
  padding: clamp(1.9rem, 6vw, 2.6rem);
  text-align: center;
}

.gate-eyebrow {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}

.gate-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.9rem, 7vw, 2.5rem);
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0.9rem 0 0;
}

.gate-sub {
  color: var(--ink-soft);
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
}

.code {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.9rem;
}

.code input {
  width: 3.1rem;
  height: 3.6rem;
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 600;
  text-align: center;
  text-transform: lowercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 3px;
  caret-color: var(--blue);
  transition: border-color 0.18s ease, background 0.18s ease;
}
.code input:focus {
  outline: none;
  border-color: var(--blue);
  background: rgba(47, 93, 140, 0.05);
}
.code input.filled { border-bottom-color: var(--blue); }

.gate-error {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8C3A2F;
  margin: 1.1rem 0 0;
  min-height: 1.1em;
}

.code.wrong { animation: shake 0.4s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}

@media (max-width: 380px) {
  .code { gap: 0.45rem; }
  .code input { width: 2.7rem; height: 3.2rem; font-size: 1.4rem; }
}

/* ---------- photo wall ---------- */

.photo-count {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.uploader {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem 0.9rem;
  margin-top: 1.2rem;
}

.file-btn { display: inline-block; }

.caption-input {
  flex: 1 1 12rem;
  font-family: var(--body);
  font-size: 0.95rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.55rem 0.7rem;
}
.caption-input:focus { outline: none; border-color: var(--blue); }

.uploader .status { margin-top: 0; flex-basis: 100%; }

/* Columns rather than a grid, so portraits and landscapes both sit at
   their own height instead of being cropped to a square. */
.wall {
  margin-top: 1.6rem;
  column-count: 3;
  column-gap: 0.6rem;
}

@media (max-width: 640px) { .wall { column-count: 2; } }

.wall-item {
  break-inside: avoid;
  margin-bottom: 0.6rem;
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--rule);
  background: var(--paper);
  cursor: zoom-in;
  line-height: 0;
}

.wall-item img { width: 100%; height: auto; display: block; }

.wall-item .stripe {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
}
.wall-item.p1 .stripe { background: var(--sage); }
.wall-item.p2 .stripe { background: var(--blue); }

.wall-empty { color: var(--ink-soft); margin: 1.4rem 0 0; }

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(27, 30, 28, 0.88);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.lightbox[hidden] { display: none; }

.lightbox-fig {
  margin: 0;
  max-width: min(60rem, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.lightbox-fig img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border: 1px solid rgba(243, 243, 234, 0.25);
}

.lightbox-fig figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: rgba(243, 243, 234, 0.75);
}

.lightbox-close {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(243, 243, 234, 0.5);
  color: rgba(243, 243, 234, 0.85);
  padding: 0 0 2px;
  cursor: pointer;
}

.lightbox .link-btn { color: rgba(243, 243, 234, 0.7); }
.lightbox .link-btn:hover { color: #F3F3EA; border-bottom-color: #F3F3EA; }
