/* Look and feel: Google Photos-style Material 3 (colours, shapes, type), without Google branding or
   downloaded fonts. Roboto is native on Android; other devices use their system font. */
:root {
  color-scheme: only light;   /* block auto dark mode */
  --primary: #0b57d0;         /* M3 primary */
  --on-primary: #fff;
  --primary-container: #d3e3fd;
  --on-primary-container: #041e49;
  --surface: #fff;
  --surface-low: #f8fafd;     /* surface container low */
  --surface-high: #f0f4f9;    /* surface container */
  --text: #1f1f1f;            /* on-surface */
  --muted: #444746;           /* on-surface-variant */
  --outline: #747775;
  --line: #c4c7c5;            /* outline-variant */
  --tile-bg: #e8eaed;         /* placeholder grey (QA detects this exact colour) */
  --accent: var(--primary);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px 1px rgba(0, 0, 0, .15);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 6px 2px rgba(0, 0, 0, .15);
  --font: Roboto, "Google Sans Text", "Google Sans", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;   /* no pull-to-refresh */
  background: var(--surface);
  color: var(--text);
  font: 16px/1.4 var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  touch-action: pan-x pan-y;   /* no pinch zoom */
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---- top app bar ---- */
.app-header {
  flex: none;
  min-height: 64px;
  display: flex;
  align-items: center;
  padding: 0 8px 0 16px;
  background: var(--surface);
}
.app-header h1 { margin: 0; font-size: 22px; font-weight: 400; letter-spacing: 0; flex: 1; }
.phone-btn {   /* M3 tonal button */
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 20px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .1px;
  cursor: pointer;
}

/* ---- timeline ---- */
.timeline { position: relative; flex: 1; min-height: 0; }
.scroller {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: pan-y;
  scrollbar-width: none;
}
.scroller::-webkit-scrollbar { display: none; }
.content { position: relative; contain: layout style; }
.day-header {   /* 44 px tall: must match DAY_HEADER_HEIGHT */
  position: absolute;
  left: 0;
  right: 0;
  height: 44px;
  box-sizing: border-box;
  padding: 0 56px 10px 16px;
  display: flex;
  align-items: flex-end;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .1px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
}
.row {
  position: absolute;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--tile));
  gap: 2px;
}
.tile {
  height: var(--tile);
  background: var(--tile-bg);
  border-radius: 4px;
  cursor: pointer;
}
/* Rounded corners on the image, not a clip on the tile: per-tile clips made fast scrolling janky. */
.tile img { width: 100%; height: 100%; display: block; border-radius: 4px; }

/* ---- moment view (Version B) ---- */
.moment-row {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 56px 0 12px;
  height: var(--cover);
  cursor: pointer;
}
.moment-cover {
  flex: none;
  width: var(--cover);
  height: var(--cover);
  border-radius: 12px;
  background: var(--tile-bg);
}
.moment-cover img { width: 100%; height: 100%; display: block; border-radius: 12px; }
.moment-text { min-width: 0; }
.moment-date { font-size: 16px; font-weight: 500; letter-spacing: .15px; }
.moment-count { font-size: 14px; color: var(--muted); margin-top: 2px; }
.moments-pill {   /* M3 assist chip, top-left over the cover, so the top moment's date stays readable */
  position: absolute;
  top: 8px;
  left: 8px;
  min-height: 32px;
  padding: 0 16px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  box-shadow: var(--shadow-1);
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
}

/* ---- ?debug=1 overlay ---- */
.debug-overlay {   /* top of the timeline, so it never hides the strip */
  position: absolute;
  left: 8px;
  top: 56px;
  z-index: 5;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .75);
  color: #fff;
  font: 14px/1.3 ui-monospace, monospace;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  max-width: calc(100% - 80px);
}
.debug-overlay button { min-height: 32px; font-size: 14px; color: #1f1f1f; background: #fff; border: 0; border-radius: 8px; }

/* ---- fast-scroll thumb (scrubber) ---- */
.scrubber {
  position: absolute;
  top: 8px;
  bottom: 8px;
  right: 0;
  width: 0;
  pointer-events: none;
}
.scrub-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 48px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}
.scrub-handle span {   /* rounded thumb with up/down arrows */
  width: 28px;
  height: 44px;
  margin-right: 2px;
  border-radius: 14px 0 0 14px;
  background: var(--surface-high);
  color: var(--muted);
  box-shadow: var(--shadow-1);
  display: flex;
  align-items: center;
  justify-content: center;
}
.scrub-handle svg { display: block; }
.scrubber.dragging .scrub-handle span { width: 34px; background: var(--primary-container); color: var(--on-primary-container); }
.scrub-bubble {
  position: absolute;
  top: 4px;
  right: 56px;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  box-shadow: var(--shadow-2);
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
}
.scrub-years { position: absolute; top: 0; right: 22px; }
.scrub-year {
  position: absolute;
  right: 0;
  height: 40px;
  padding: 0 4px;
  border: 0;
  background: none;
  display: flex;
  align-items: center;
  pointer-events: auto;
  cursor: pointer;
}
.scrub-year span {
  padding: 2px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .9);
  color: var(--muted);
  box-shadow: var(--shadow-1);
  font-size: 14px;
  font-weight: 500;
}

/* ---- Back pill: M3 tonal button ---- */
.back-pill {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  min-height: 40px;
  padding: 0 20px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 20px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  box-shadow: var(--shadow-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* ---- photo viewer ---- */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #000;
  color: #fff;
  overscroll-behavior: none;
  touch-action: none;
}
.viewer-top { align-self: stretch; padding: 8px 4px; }
.icon-btn {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #fff;
  cursor: pointer;
}
.viewer-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; align-self: stretch; }
.viewer-photo { display: block; touch-action: none; }
.viewer-prev, .viewer-next { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(32, 33, 36, .6); }
.viewer-prev { left: 8px; }
.viewer-next { right: 8px; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.viewer-date { margin: 12px 0 8px; font-size: 14px; letter-spacing: .25px; color: #e3e3e3; }
.viewer-actions { padding: 0 16px calc(20px + env(safe-area-inset-bottom)); align-self: stretch; display: flex; flex-direction: column; align-items: center; }
.primary {   /* M3 filled button */
  min-height: 48px;
  min-width: 200px;
  padding: 0 24px;
  border: 0;
  border-radius: 24px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .1px;
  cursor: pointer;
}
.viewer .primary { background: #a8c7fa; color: #062e6f; }   /* M3 primary on dark */

/* ---- faces (Version B) ---- */
.face-row {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2px;
  padding: 8px 8px 6px;
  background: var(--surface);
}
.face {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 2px 0;
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.face-pic { position: relative; width: 48px; height: 48px; border-radius: 50%; }
.face-pic canvas { width: 48px; height: 48px; border-radius: 50%; display: block; }
.face-check {
  display: none;
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--primary);
  color: #fff;
  align-items: center;
  justify-content: center;
}
/* Selected: thick outline plus check icon plus bold name, never colour alone */
.face[aria-pressed="true"] .face-pic { box-shadow: 0 0 0 2px #fff, 0 0 0 5px var(--primary); }
.face[aria-pressed="true"] .face-check { display: flex; }
.face[aria-pressed="true"] .face-name { font-weight: 700; }
.face-name { font-size: 14px; line-height: 1.2; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.face-clear {   /* M3 text button */
  flex: none;
  align-self: center;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 20px;
  background: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.tile.dim img, .moment-row.dim { opacity: var(--dim, .35); }
.scrub-ticks { position: absolute; top: 0; right: 0; }
.scrub-tick {
  position: absolute;
  right: 0;
  width: 36px;
  padding: 0;
  border: 0;
  background: none;
  pointer-events: auto;
  cursor: pointer;
}
.scrub-tick span {
  position: absolute;
  right: 3px;
  top: 50%;
  width: 14px;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 2px;
  background: var(--primary);
  box-shadow: 0 0 0 1px #fff;
}
.never-together {   /* M3 snackbar-like note */
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  min-height: 40px;
  padding: 0 16px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  background: #313033;
  color: #f4eff4;
  box-shadow: var(--shadow-2);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}

/* ---- "Same people, other times": M3 bottom sheet, sticky footer inside the scroller ---- */
.strip {   /* touches on it scroll the timeline */
  position: sticky;
  bottom: 0;
  z-index: 4;    /* above the grid rows; the viewer (fixed, z-index 10) is always above it */
  margin-right: 48px;   /* keeps the scroll bar column free */
  padding: 6px 12px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface-low);
  border-top-right-radius: 28px;
  box-shadow: var(--shadow-2);
  transition: opacity .12s;
}
.strip::before {   /* drag-handle look */
  content: "";
  display: block;
  width: 32px;
  height: 4px;
  margin: 2px auto 8px;
  border-radius: 2px;
  background: var(--outline);
  opacity: .4;
}
.strip.faded { opacity: 0; visibility: hidden; transition: opacity .12s, visibility 0s .12s; }
.strip-label { font-size: 16px; font-weight: 500; margin-bottom: 4px; }
.strip-items { display: flex; gap: 12px; padding-top: 8px; }
.strip-item {
  position: relative;
  flex: none;
  width: 68px;
  padding: 0;
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.strip-thumb { width: 64px; height: 64px; border-radius: 12px; background: var(--tile-bg); display: block; }
.strip-thumb img { width: 100%; height: 100%; display: block; border-radius: 12px; }
.strip-date { font-size: 14px; color: var(--muted); white-space: nowrap; }
/* Current moment: thick outline plus the word "Here", never colour alone */
.strip-item.here .strip-thumb { box-shadow: 0 0 0 2px var(--surface-low), 0 0 0 5px var(--primary); }
.strip-item.here .strip-date { font-weight: 700; color: var(--text); }
.strip-here {   /* sits across the top edge of the outline, so it hides little of the photo */
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 8px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
}

/* ---- test flow ---- */
.task-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 8px 4px;
  padding: 6px 8px 6px 6px;
  border-radius: 16px;
  background: var(--surface-high);
}
.task-note {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font-size: 14px;
  line-height: 1.4;
  letter-spacing: .25px;
  color: var(--text);
  cursor: pointer;
}
.task-note[aria-expanded="false"] { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.giveup-btn {   /* M3 outlined button */
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--outline);
  border-radius: 20px;
  background: transparent;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.viewer-msg {   /* M3 snackbar */
  margin: 0 0 12px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #e6e1e5;
  color: #1c1b1f;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}
.screen {
  position: fixed;
  inset: 0;
  z-index: 30;   /* above the viewer */
  overflow-y: auto;
  overscroll-behavior: none;
  background: var(--surface);
}
.screen-inner { max-width: 560px; margin: 0 auto; padding: 32px 24px calc(32px + env(safe-area-inset-bottom)); }
.screen h1 { font-size: 28px; font-weight: 400; line-height: 1.25; margin: 0 0 16px; }
.screen h2 { font-size: 22px; font-weight: 400; margin: 24px 0 12px; }
.screen p, .screen li { font-size: 16px; line-height: 1.5; letter-spacing: .15px; }
.screen .lead { font-size: 16px; color: var(--text); }
.screen .primary { width: 100%; margin-top: 24px; }
.screen .primary:disabled { background: rgba(31, 31, 31, .12); color: rgba(31, 31, 31, .38); cursor: default; }
.banner { padding: 12px 16px; border-radius: 12px; background: #fdefc4; color: #3d2e00; font-size: 14px; font-weight: 500; }
.field { display: block; margin: 20px 0; }
.field span { display: block; font-size: 14px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {   /* M3 outlined text field */
  box-sizing: border-box;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--outline);
  border-radius: 4px;
  background: var(--surface);
  font: inherit;
  font-size: 16px;
  color: var(--text);
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.choice { margin: 20px 0; padding: 0; border: 0; }
.choice legend { font-size: 16px; font-weight: 500; margin-bottom: 4px; padding: 0; }
.choice label { display: flex; align-items: center; gap: 12px; min-height: 48px; font-size: 16px; }
.choice input { width: 20px; height: 20px; accent-color: var(--primary); }
.hint { color: var(--muted); font-size: 14px; }
.people, .events, .howto { list-style: none; padding: 0; margin: 0; }
.people li { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.people .pic canvas { display: block; border-radius: 50%; }
.events li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.howto li { display: flex; align-items: center; gap: 16px; margin: 16px 0; padding: 12px; border-radius: 16px; background: var(--surface-high); font-size: 16px; }
.howto svg { flex: none; width: 120px; height: 60px; }
.tag { display: inline-block; padding: 6px 12px; border-radius: 8px; background: var(--primary-container); color: var(--on-primary-container); font-size: 14px; font-weight: 500; }
.preview { display: block; margin: 0 auto; border-radius: 12px; }
.countdown { text-align: center; font-size: 36px; font-weight: 400; color: var(--primary); margin: 16px 0 0; }
.memory { font-size: 22px; line-height: 1.4; margin-top: 24px; }
.progress { height: 4px; border-radius: 2px; background: var(--primary-container); overflow: hidden; }   /* M3 linear progress */
.progress div { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.pct { text-align: center; color: var(--muted); }
.copy-status { font-weight: 500; min-height: 1.4em; }
.results { box-sizing: border-box; width: 100%; font: 13px/1.4 ui-monospace, monospace; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-low); }

/* target thumbnail in the task bar, and its enlarged view */
.task-thumb { flex: none; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 12px; background: none; cursor: zoom-in; }
.task-thumb canvas { width: 48px; height: 48px; display: block; border-radius: 12px; }
.peek { position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .85); cursor: zoom-out; }
.peek canvas { border-radius: 12px; }
