/* ================= snaps ================= */
:root { --night: #2a1119; }

.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
body.modal-open { overflow: hidden; }

/* streak */
.streak { padding: 16px 16px 12px; display: grid; gap: 12px; }
.streak-top { display: flex; align-items: center; gap: 14px; }
.streak-num { display: grid; justify-items: center; flex: none; min-width: 4.4rem; }
.streak-num b {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 3rem;
  line-height: 0.9;
  color: var(--berry);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  font-variant-numeric: tabular-nums;
}
.streak-num b.zero { font-family: var(--f-hand); font-weight: 700; -webkit-text-stroke: 0; color: var(--ink-soft); }
.streak-num span { font-weight: 700; font-size: 0.98rem; color: var(--ink-soft); white-space: nowrap; }
.streak-msg { font-weight: 700; font-size: 1.18rem; line-height: 1.2; }
.week { list-style: none; margin: 0; padding: 8px 4px 0; display: flex; justify-content: space-between; border-top: 2px dashed var(--line); }
.week li { display: grid; justify-items: center; font-weight: 700; font-size: 0.95rem; color: var(--ink-soft); padding: 3px 5px 1px; border-radius: 12px; }
.week li.today { background: var(--butter); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.berry-ico { display: block; flex: none; }
.streak-best { font-size: 1rem; color: var(--ink-soft); text-align: center; }

/* days */
.days { display: grid; gap: 30px; }
.day { display: grid; gap: 14px; }
.day-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.day-head h2 { font-size: 1.5rem; }
.day-date { font-weight: 700; color: var(--ink-soft); font-size: 1.05rem; }
.day-head .chip { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; align-self: center; }
.add-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.add-btn { width: 100%; font-size: clamp(0.9rem, 4.2vw, 1.05rem); padding: 0.7em 0.5em 0.75em; gap: 6px; white-space: nowrap; cursor: pointer; }
.add-btn svg { flex: none; }
.add-btn:focus-within { outline: 3px dashed var(--berry-deep); outline-offset: 3px; }
.day-empty {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 16px;
  border: 2.5px dashed rgba(74, 31, 46, 0.35);
  border-radius: 18px;
  background: rgba(255, 248, 250, 0.7);
}
.day-empty p { margin-left: 8px; font-size: 1.15rem; line-height: 1.25; color: var(--ink-soft); }
.more-days { justify-self: center; }

/* polaroids */
.snap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 14px; align-items: start; padding-top: 6px; }
.polaroid {
  position: relative;
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 8px 8px 9px;
  text-align: left;
  background: var(--white);
  border: 2.5px solid var(--ink);
  border-radius: 6px;
  box-shadow: 3px 4px 0 var(--ink);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.15s;
}
.polaroid:active { transform: rotate(var(--tilt, 0deg)) scale(0.97); }
.polaroid .tape {
  position: absolute;
  z-index: 1;
  top: -11px;
  left: 50%;
  width: 56px;
  height: 18px;
  transform: translateX(-50%) rotate(-4deg);
  background: repeating-linear-gradient(45deg, var(--blush) 0 6px, var(--white) 6px 12px);
  opacity: 0.92;
  border-radius: 2px;
}
.polaroid.zaid .tape {
  background: repeating-linear-gradient(45deg, var(--butter) 0 6px, var(--white) 6px 12px);
  transform: translateX(-50%) rotate(3deg);
}
.pol-photo {
  display: block;
  aspect-ratio: 4 / 5;
  max-width: 100%;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: linear-gradient(110deg, var(--sky) 30%, var(--paper) 50%, var(--sky) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
.pol-photo img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.25s; }
.pol-photo img.in { opacity: 1; }
.pol-photo:has(img.in) { animation: none; }
.pol-photo.broken { animation: none; background: var(--blush); }
.pol-cap {
  font-size: 1.12rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pol-meta { display: flex; align-items: center; gap: 5px; font-weight: 700; font-size: 0.9rem; color: var(--ink-soft); min-width: 0; }
.pol-meta .pol-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: auto; }
.pol-heart { display: flex; }
.pol-heart svg { width: 17px; height: 16px; }
.pol-notes { display: inline-flex; align-items: center; gap: 2px; }
@keyframes shimmer { to { background-position: -300% 0; } }

/* composer: a bottom sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  align-items: end;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  background: rgba(42, 17, 25, 0.55);
}
/* while typing, the photo preview shrinks so the caption and Post button fit above the keyboard */
.composer.typing .composer-photo img, #composer.typing .composer-photo img { max-height: 18dvh; }
#composer.typing .composer-photo { min-height: 0; }
.sheet {
  width: min(100%, 30rem);
  margin: 0 auto;
  max-height: 100%;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 18px 16px 18px;
  animation: sheet-up 0.25s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.sheet h2 { font-size: 1.5rem; }
.composer-photo {
  padding: 8px 8px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 6px;
  box-shadow: 3px 4px 0 var(--ink);
  transform: rotate(-1deg);
  min-height: 140px;
  background: linear-gradient(110deg, var(--sky) 30%, var(--paper) 50%, var(--sky) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
.composer-photo:has(img[src]) { animation: none; background: var(--white); }
.composer-photo img { display: block; width: 100%; max-height: 40dvh; object-fit: contain; border-radius: 3px; }
.composer-photo img:not([src]) { visibility: hidden; height: 120px; }
.sheet .field-label { margin-top: 2px; }
.sheet .error:empty { display: none; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

/* viewer: photo on a cozy dark background, details on a paper sheet */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--night);
  padding-top: env(safe-area-inset-top, 0px);
}
.viewer-top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: var(--night);
  color: var(--paper);
}
.viewer-who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.viewer-who b { display: block; font-family: var(--f-display); font-weight: 400; font-size: 1.15rem; }
.viewer-who small { display: block; font-weight: 700; font-size: 0.98rem; opacity: 0.8; }
.viewer-close {
  flex: none;
  width: 44px;
  height: 44px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 700;
}
.viewer-photo {
  position: relative;
  display: grid;
  place-items: center;
  padding: 4px max(16px, env(safe-area-inset-left, 0px));
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.viewer-photo img {
  display: block;
  max-width: 100%;
  max-height: 62dvh;
  border: 6px solid var(--white);
  border-radius: 6px;
  box-shadow: 0 0 0 2.5px var(--ink);
  background: var(--white);
  min-width: 120px;
  min-height: 120px;
}
.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-display);
  font-size: 1.6rem;
  line-height: 1;
  padding-bottom: 4px;
}
.viewer-nav.prev { left: max(6px, env(safe-area-inset-left, 0px)); }
.viewer-nav.next { right: max(6px, env(safe-area-inset-right, 0px)); }
.big-heart { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0); opacity: 0; pointer-events: none; }
.big-heart svg { width: 110px; height: 100px; filter: drop-shadow(0 4px 0 var(--ink)); }
.big-heart.pop { animation: heart-pop 0.75s cubic-bezier(0.3, 1.5, 0.5, 1); }
@keyframes heart-pop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  40% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(1); opacity: 0; }
}
.viewer-sheet {
  margin: 14px max(12px, env(safe-area-inset-left, 0px)) calc(16px + env(safe-area-inset-bottom, 0px));
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: none;
}
.viewer-cap { font-size: 1.35rem; line-height: 1.2; overflow-wrap: anywhere; }
.viewer-cap.empty { color: var(--ink-soft); font-size: 1.1rem; }
.viewer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.viewer-actions:empty { display: none; }
.heart-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px 6px 8px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--white);
  box-shadow: 0 3px 0 var(--ink);
  font-weight: 700;
  font-size: 1.1rem;
}
.heart-btn.on { background: var(--blush); }
.heart-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.loved { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--berry-deep); }
.loved svg { width: 20px; height: 18px; }
.text-btn {
  padding: 4px 0;
  border: 0;
  background: none;
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--ink-soft);
  text-decoration: underline wavy var(--blush);
  text-underline-offset: 4px;
}
.text-btn.danger { color: var(--berry-deep); }
.notes-wrap { display: grid; gap: 10px; border-top: 2px dashed var(--line); padding-top: 12px; }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.notes:empty { display: none; }
.note { display: flex; align-items: flex-end; gap: 8px; }
.note p {
  min-width: 0;
  max-width: 78%;
  padding: 6px 12px 8px;
  border: 2px solid var(--ink);
  border-radius: 16px 16px 16px 4px;
  background: var(--white);
  font-size: 1.12rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.note.mine { flex-direction: row-reverse; }
.note.mine p { background: var(--butter); border-radius: 16px 16px 4px 16px; }
.note-del { align-self: center; border: 0; background: none; color: var(--ink-soft); font-weight: 700; padding: 4px; }
.note-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.note-form .btn { font-size: 1rem; padding: 0.5em 1em 0.6em; }

/* scoreboard streak line */
.board-streak { display: flex; align-items: center; gap: 10px; padding: 2px 2px 12px; margin-bottom: 4px; border-bottom: 2px dashed var(--line); }
.board-streak p { font-size: 1.15rem; line-height: 1.15; }
.board-streak b { font-family: var(--f-display); font-weight: 400; color: var(--berry-deep); }
.board-streak small { display: block; color: var(--ink-soft); font-size: 0.98rem; }

/* four tabs */
.tabs { gap: 6px; }
.tabs button { font-size: 1rem; }
.badge.dot { min-width: 0; width: 14px; height: 14px; padding: 0; top: 5px; right: calc(50% - 20px); }

@media (prefers-reduced-motion: reduce) {
  .pol-photo, .composer-photo, .sheet { animation: none !important; }
}
