/* Family Memories - simple, flat styles with light and dark themes.
   Layout from the sketch: dotted page, notes side by side joined by a line,
   three buttons along the bottom. */

:root,
[data-theme="light"] {
  --bg: #ffffff;
  --dot: #e3e3e3;
  --card: #ffffff;
  --card-border: #e5e5e5;
  --text: #0f0f0f;
  --text-2: #606060;
  --soft: #f2f2f2;
  --soft-hover: #e5e5e5;
  --line: #d0d0d0;
  --blue: #065fd4;
  --dark: #0f0f0f;
  --dark-text: #ffffff;
  --red: #e62117;
  --overlay: rgba(0, 0, 0, 0.5);
  --brand: #a8604a;
  --brand-soft: #f6ebe6;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --dot: #262626;
  --card: #1f1f1f;
  --card-border: #303030;
  --text: #f1f1f1;
  --text-2: #aaaaaa;
  --soft: #2a2a2a;
  --soft-hover: #3a3a3a;
  --line: #3a3a3a;
  --blue: #3ea6ff;
  --dark: #f1f1f1;
  --dark-text: #0f0f0f;
  --red: #ff4e45;
  --overlay: rgba(0, 0, 0, 0.65);
  --brand: #d9917a;
  --brand-soft: #3a2721;
  color-scheme: dark;
}

:root { --serif: "Fraunces", Georgia, "Times New Roman", serif; }

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }
html, body { overscroll-behavior: none; } /* no pull-to-refresh or rubber-banding of the whole page: swipes only scroll */
.canvas, .page-view, .dialog { overscroll-behavior: contain; } /* reaching the end of a list never passes the swipe on to the page */
html { touch-action: pan-x pan-y; } /* no pinch or double-tap zoom on the page; the photo viewer zooms on its own */

body {
  color: var(--text);
  font-family: "Roboto", Arial, sans-serif;
  font-size: 14px;
  line-height: 20px;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 20px 20px;
  background-attachment: fixed;
}

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

/* No blinking text cursor in ordinary text (it shows up when the browser's caret browsing, F7, is on).
   Places you can type keep theirs. */
body { caret-color: transparent; }
input, textarea, select, [contenteditable="true"] { caret-color: auto; }
button { cursor: pointer; }
a { color: inherit; }
svg { display: block; flex-shrink: 0; }
[hidden] { display: none !important; }

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.content { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 9px;
  background: var(--soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--soft-hover); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.heart:disabled { opacity: 1; } /* stays the same color while the heart animation plays */
.btn.has-icon { padding-left: 12px; }

/* Stitched label: the signature button style. A dashed "stitch" sewn inside
   the edge, like a fabric label sewn onto the family thread. */
.btn-dark,
.action {
  outline: 1.5px dashed rgba(255, 255, 255, 0.45);
  outline-offset: -5px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn-dark:active:not(:disabled),
.action:active { transform: translateY(2px); box-shadow: none; }

.btn-dark { background: var(--dark); color: var(--dark-text); }
.btn-dark:hover:not(:disabled) { background: var(--dark); opacity: 0.88; }
[data-theme="dark"] .btn-dark { outline-color: rgba(0, 0, 0, 0.35); }
.btn-text { background: transparent; color: var(--blue); }
.btn-text:hover:not(:disabled) { background: var(--soft); }
.btn-danger { background: var(--red); color: #fff; outline: 1.5px dashed rgba(255, 255, 255, 0.45); outline-offset: -5px; }
.btn-danger:hover:not(:disabled) { background: var(--red); opacity: 0.85; }
.btn-lg { height: 46px; border-radius: 11px; font-size: 15px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--soft); }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text-2); }

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  outline: none;
}
.input:focus { border-color: var(--blue); }

.textarea {
  width: 100%;
  min-height: 140px;
  padding: 0;
  border: none;
  background: transparent;
  outline: none;
  resize: vertical;
  font-size: 16px;
  line-height: 24px;
}

.error { color: var(--red); font-size: 13px; margin: 0; min-height: 18px; }
.hint { margin: 0; font-size: 12px; color: var(--text-2); }

/* ---------- Avatars ---------- */

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 500;
  font-size: 14px;
  flex-shrink: 0;
  user-select: none;
}
.avatar-sm { width: 24px; height: 24px; font-size: 11px; }
.avatar-md { width: 40px; height: 40px; font-size: 17px; }

.avatar-stack { display: flex; border: none; background: none; padding: 2px; border-radius: 16px; }
.avatar-stack:hover { background: var(--soft); }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--bg); margin-left: -6px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--card-border);
}

.family-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 16px;
  flex-shrink: 0;
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 26px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-title .meta { font-size: 12px; color: var(--text-2); }

/* ---------- Notes side by side, joined by a line ---------- */

.canvas {
  flex: 1;
  display: flex;
  align-items: flex-start; /* the track centers itself with auto margins (below), so tall notes */
  overflow-x: auto;        /* never get their tops cut off on short screens */
  overflow-y: auto;
  padding-bottom: 84px; /* room for the bottom buttons */
  cursor: grab;
  scrollbar-width: thin;
}
.canvas.panning { cursor: grabbing; user-select: none; }
.canvas button, .canvas a { cursor: pointer; }
.canvas input { cursor: text; }

.track {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 56px;
  width: max-content;
  min-width: 100%;
  margin: auto 0; /* centered when it fits; starts at the top (and scrolls) when it doesn't */
  padding: 32px 120px 32px 72px;
}

/* the connecting line */
.track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px; /* centered exactly on the middle */
  background: var(--line);
}

.note {
  position: relative;
  z-index: 1;
  /* bigger cards on bigger screens, so a laptop shows more and has less empty space */
  width: clamp(300px, 22vw, 380px);
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  /* no overflow: hidden, so the knots where the line meets the card show in full */
}

.note-head { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0 14px; }
.note-who { flex: 1; min-width: 0; }
.note-author { font-weight: 500; display: block; }
.note-time { font-size: 12px; color: var(--text-2); }

.badge-new {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--soft);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
}

.note-text {
  margin: 0;
  padding: 10px 14px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 22px;
  max-height: 260px;
  overflow-y: auto;
}
.note-text.clickable { cursor: pointer; }
.note-text.clamped { max-height: none; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; padding-bottom: 0; }
.read-more { margin: 2px 14px 10px; padding: 0; border: none; background: none; color: var(--blue); font-weight: 500; font-size: 14px; cursor: pointer; }
.read-more:hover { text-decoration: underline; }
.note-open { width: 30px; height: 30px; color: var(--text-2); }

/* ---------- One post, big (openPost) ---------- */

.dialog.post-dialog { max-width: 760px; }
/* the close button and the Older / Newer bar stay put while the post scrolls */
.post-dialog .dialog-head { position: sticky; top: 0; z-index: 2; padding-top: 8px; padding-bottom: 0; background: var(--card); }
.post-dialog .dialog-foot { position: sticky; bottom: 0; z-index: 2; justify-content: space-between; border-top: 1px solid var(--card-border); padding-top: 10px; background: var(--card); }
.post-dialog .icon-after { flex-direction: row-reverse; padding-left: 16px; padding-right: 12px; }
.post-counter { color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.post-view { display: flex; flex-direction: column; gap: 14px; padding-bottom: 6px; }
.post-head { display: flex; align-items: center; gap: 12px; }
.post-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.post-author { font-size: 16px; font-weight: 600; }
.post-date { color: var(--text-2); font-size: 14px; }
.post-posted { color: var(--text-2); font-size: 12px; }
.post-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.post-tags:empty { display: none; }
.post-tags .note-place { margin: 0; }
.post-thread { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 14px; background: var(--soft); font-size: 13px; font-weight: 500; }
.post-thread .thread-dot { background: var(--tab-color); }
.post-text {
  margin: 0;
  font-family: var(--serif, Georgia, serif);
  font-size: 19px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
}
.post-photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.post-photos.single { grid-template-columns: 1fr; }
.post-photo { padding: 0; border: none; border-radius: 12px; overflow: hidden; background: var(--soft); cursor: zoom-in; aspect-ratio: 4 / 3; }
.post-photos.single .post-photo { aspect-ratio: auto; }
.post-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-photos.single .post-photo img { height: auto; max-height: 70vh; object-fit: contain; }
.post-photo-count, .post-edited { margin: -6px 0 0; color: var(--text-2); font-size: 13px; }
.post-files { display: flex; flex-direction: column; gap: 8px; }
.post-files .note-video { width: 100%; max-height: 70vh; border-radius: 12px; background: #000; }
.post-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--card-border); padding-top: 12px; }
.post-hearts { color: var(--text-2); font-size: 14px; }
.post-replies { display: flex; flex-direction: column; gap: 4px; }
.post-replies h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.post-replies .reply-form { padding: 8px 0 0; border-top: none; }
/* a reply you just sent glows for a moment */
.reply.just-sent { animation: just-sent 1.6s ease-out; border-radius: 8px; }
@keyframes just-sent { from { background: color-mix(in srgb, var(--blue) 16%, transparent); } to { background: transparent; } }
@media (max-width: 600px) {
  .post-photos { grid-template-columns: 1fr; }
  .post-text { font-size: 17px; }
  .post-counter { display: none; }
}

/* ---------- Attachments ---------- */

/* several photos: a tidy grid of up to four */
.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin: 0 12px;
  border-radius: 10px;
  overflow: hidden;
}
.photo-grid.count-3 .photo-tile:first-child { grid-row: span 2; aspect-ratio: auto; }
.photo-tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  background: var(--soft);
  cursor: zoom-in;
  overflow: hidden;
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s; }
.photo-tile:hover img { transform: scale(1.04); }
.photo-more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
}
.photo-count { margin: -4px 14px 0; font-size: 12px; color: var(--text-2); }

.note-attachments { display: flex; flex-direction: column; gap: 10px; padding-bottom: 4px; }

.note-video { display: block; width: calc(100% - 24px); margin: 0 12px; max-height: 320px; border-radius: 8px; background: #000; }

/* a video before it plays: a still frame with a big ▶ */
.video-poster { position: relative; padding: 0; border: none; overflow: hidden; aspect-ratio: 16 / 10; cursor: pointer; }
.video-poster video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.video-play {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 3px; /* the ▶ looks centred */
  transition: transform 0.15s, background 0.15s;
}
.video-poster:hover .video-play { transform: translate(-50%, -50%) scale(1.08); background: rgba(0, 0, 0, 0.75); }
.post-files .video-poster { width: 100%; margin: 0; max-height: 70vh; }

.note-audio { margin: 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--soft); }
.note-audio .file-name { font-size: 13px; color: var(--text-2); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Audio player ---------- */

.audio-player { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; }
.ap-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ap-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ap-time { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; margin-right: auto; }

.ap-btn {
  border: none;
  background: transparent;
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.ap-btn:hover { background: var(--card-border); }
.ap-play { width: 38px; height: 38px; background: var(--dark); color: var(--dark-text); }
.ap-play:hover { background: var(--dark); opacity: 0.85; }
.ap-play .mi { margin-left: 2px; }
.audio-player.playing .ap-play .mi { margin-left: 0; }
.ap-speed { width: auto; min-width: 34px; padding: 0 6px; border-radius: 12px; font-size: 12px; font-weight: 600; color: var(--text-2); }

.ap-volume-group { display: flex; align-items: center; gap: 2px; }

/* sliders: a thin track that fills up to the value, with a round handle */
.ap-seek, .ap-volume {
  --fill: 0%;
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.ap-seek { width: 100%; }
.ap-volume { width: 64px; }
.ap-seek::-webkit-slider-runnable-track, .ap-volume::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--text) var(--fill), var(--card-border) var(--fill));
}
.ap-seek::-moz-range-track, .ap-volume::-moz-range-track { height: 4px; border-radius: 2px; background: var(--card-border); }
.ap-seek::-moz-range-progress, .ap-volume::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--text); }
.ap-seek::-webkit-slider-thumb, .ap-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--text);
  border: none;
}
.ap-seek::-moz-range-thumb, .ap-volume::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: none; }
.ap-seek:focus-visible, .ap-volume:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

.note-file {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  text-decoration: none;
}
.note-file:hover { background: var(--soft); }
.file-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--soft); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; color: var(--text-2); }

/* files waiting to be posted: previews, each with upload progress and a remove button */
.attach-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.attach-media:empty { display: none; }
.attach-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--soft);
  animation: tile-in 0.2s ease-out;
}
@keyframes tile-in { from { opacity: 0; transform: scale(0.92); } }
.attach-tile img, .attach-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-tile video { cursor: pointer; }
.attach-tile .attach-doc { height: 100%; flex-direction: column; justify-content: center; padding: 8px; text-align: center; }
.tile-play {
  position: absolute;
  left: 6px;
  bottom: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.attach-tile .progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; border-radius: 0; background: rgba(0, 0, 0, 0.25); }
.attach-tile .progress.done { opacity: 0; transition: opacity 0.6s 0.4s; }
.attach-tile.failed::after {
  content: "Didn’t upload";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 49, 43, 0.75);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
}

.attach-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 1;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.attach-remove:hover { background: rgba(0, 0, 0, 0.8); }

.attach-list { display: flex; flex-direction: column; gap: 6px; }
.attach-list:empty { display: none; }
.attach-row { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 40px 12px 10px; border-radius: 10px; background: var(--soft); overflow: hidden; }
.attach-row.failed { box-shadow: inset 0 0 0 1px var(--red); }
.attach-row .progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 0; }
.attach-row .attach-remove { top: 50%; margin-top: -12px; right: 8px; background: transparent; color: var(--text-2); }
.attach-row .attach-remove:hover { background: var(--card-border); color: var(--text); }
.attach-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--card); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.attach-doc { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.doc-badge {
  min-width: 42px;
  height: 50px;
  padding: 0 4px;
  border-radius: 6px;
  background: #64748b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  flex-shrink: 0;
  clip-path: polygon(0 0, 72% 0, 100% 22%, 100% 100%, 0 100%); /* a page with a folded corner */
}
.doc-pdf { background: #d93025; }
.doc-doc, .doc-docx, .doc-odt, .doc-rtf { background: #2b579a; }
.doc-xls, .doc-xlsx { background: #217346; }
.doc-ppt, .doc-pptx { background: #c43e1c; }
.doc-txt { background: #475569; }

.attach-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.attach-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.progress { height: 3px; border-radius: 2px; background: var(--card-border); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--blue); transition: width 0.2s; }
.progress.done > div { width: 100%; background: #16a34a; }
.progress.failed > div { width: 100%; background: var(--red); }

.storage .btn { align-self: flex-start; margin-top: 4px; }
.storage-bar.full > div { background: var(--red); }

.menu-divider { height: 1px; background: var(--card-border); margin: 6px 0; }

.faq { border-bottom: 1px solid var(--card-border); padding: 4px 0 10px; }
.faq summary { cursor: pointer; font-weight: 500; padding: 6px 0; }
.faq p { margin: 4px 0 0; color: var(--text-2); }
.hint a, .fine a { color: var(--text-2); }

/* photos look like a printed photo: a white frame with a deeper bottom edge */
.note-photo-print {
  display: block;
  margin: 2px 12px 0;
  padding: 8px 8px 22px;
  background: #ffffff;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transform: rotate(-0.8deg);
}
.note:nth-of-type(even) .note-photo-print { transform: rotate(0.8deg); }
button.note-photo-print { width: calc(100% - 24px); border: none; font: inherit; cursor: zoom-in; }
.note-photo { display: block; width: 100%; max-height: clamp(190px, 26vh, 280px); object-fit: cover; background: #eee; }

/* ---------- The thread: start knot, date tags, next-memory spot ---------- */

/* knots where the thread meets each note */
.note::before,
.note::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--line);
  box-shadow: 0 0 0 2px var(--bg); /* a little gap around the knot, like a bead on the thread */
}
/* centered on the card's 1px border */
.note::before { left: -5.5px; }
.note::after { right: -5.5px; }

/* The knot sits on the line with its caption underneath. The caption takes up real space
   (so the year never covers it), and an equal gap above keeps the knot exactly on the line. */
.thread-start {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding-top: 26px; /* = caption height + gap */
  flex-shrink: 0;
}
.thread-start .knot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 4px var(--bg);
}
.thread-start .label {
  height: 18px;
  line-height: 18px;
  white-space: nowrap;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--text-2);
}
.thread-start + .year-marker { margin-left: 0; }

.date-tag {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  margin: 0 -28px; /* sits on the thread between notes without widening the gap much */
}

.next-card {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 200px;
  height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--serif);
  font-size: 15px;
}
.next-card:hover { border-color: var(--text-2); color: var(--text); }

.note-actions { display: flex; gap: 4px; padding: 6px 8px; }
.note-actions .btn { height: 32px; padding: 0 10px; background: transparent; font-weight: 400; }
.note-actions .btn:hover:not(:disabled) { background: var(--soft); }
.note-actions .heart.active { color: var(--red); }

.replies { border-top: 1px solid var(--card-border); padding: 4px 14px 10px; }
/* ---------- Hidden after reports ---------- */
.note.note-hidden { background: var(--soft); border-style: dashed; }
.hidden-msg { display: flex; align-items: center; gap: 8px; margin: 0; padding: 12px 14px 16px; color: var(--text-2); font-size: 14px; font-style: italic; }
.hidden-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.4;
}
[data-theme="dark"] .hidden-banner { background: #3a2410; color: #fdba74; }
.hidden-banner-text { display: flex; gap: 8px; align-items: flex-start; }
.hidden-banner-text .mi { flex-shrink: 0; margin-top: 1px; }
.hidden-banner-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.hidden-banner-actions .btn { height: 30px; padding: 0 12px; font-size: 13px; }
.reply .hidden-banner { margin: 6px 0 0; }
.reply.is-hidden .reply-body > span { opacity: 0.6; }
.reply-hidden { display: flex; align-items: center; gap: 8px; padding-top: 8px; color: var(--text-2); font-size: 13px; font-style: italic; }
.view-all-replies { display: block; margin: 6px 0 0; padding: 0; border: none; background: none; color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; }
.view-all-replies:hover { color: var(--text); text-decoration: underline; }
.replies:empty { display: none; }
.reply { display: flex; gap: 10px; padding-top: 8px; }
.reply-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.reply-body strong { font-weight: 500; margin-right: 6px; }
.reply-time { color: var(--text-2); font-size: 12px; }
.reply .icon-btn { width: 24px; height: 24px; opacity: 0; color: var(--text-2); }
.reply:hover .icon-btn, .reply .icon-btn:focus-visible { opacity: 1; }
@media (hover: none) { .reply .icon-btn { opacity: 1; } }

.reply-form { display: flex; gap: 8px; padding: 8px 10px 10px; border-top: 1px solid var(--card-border); }
.reply-form .input { height: 32px; border-radius: 16px; }
.reply-form .btn { height: 32px; }

.empty-note { padding: 32px 24px; text-align: center; }
.empty-note h2 { margin: 0 0 6px; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.empty-note p { margin: 0; color: var(--text-2); }

/* ---------- Places ---------- */

/* the 📍 tag on a note */
.note-place {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100% - 28px);
  margin: 8px 14px 0;
  padding: 3px 10px 3px 7px;
  border: none;
  border-radius: 12px;
  background: var(--soft);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.note-place span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-place .mi { color: var(--red); flex-shrink: 0; }
.note-place:hover { background: var(--soft-hover); color: var(--text); }

/* the "Where was this?" field in the note window */
.place-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 10px;
  border-radius: 10px;
  background: var(--soft);
}
.place-pin { color: var(--red); display: flex; }
.place-input { flex: 1; min-width: 0; height: 34px; border: none; background: transparent; outline: none; font-size: 14px; }
.place-check { font-size: 13px; white-space: nowrap; }
.place-clear { width: 30px; height: 30px; color: var(--text-2); }
.place-row { position: relative; }

/* the suggestions under the place field: floats above the whole page (placed by app.js) so the dialog can't cut it off */
.place-suggest {
  position: fixed;
  z-index: 55;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.25);
}
.place-option { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.place-option.active, .place-option:hover { background: var(--soft); }
.place-option-icon { width: 30px; height: 30px; border-radius: 50%; background: var(--soft); color: var(--red); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.place-option.here .place-option-icon { color: var(--blue); }
.place-option.here .place-option-name { color: var(--blue); }
.place-option-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.place-option-name { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-option-detail { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-option-dist { font-size: 12px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.place-note { padding: 10px 12px; font-size: 13px; color: var(--text-2); }

/* the map window */
.map-box { margin: 0 -20px; height: min(360px, 55vh); background: var(--soft); }
.map-frame { display: block; width: 100%; height: 100%; border: 0; }

/* ---------- Search highlights ---------- */

mark.hit {
  background: #ffe27a;
  color: #111;
  border-radius: 3px;
  padding: 0 2px;
  margin: 0 -1px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
[data-theme="dark"] mark.hit { background: #c9a227; color: #111; }

/* ---------- Thread tabs ---------- */

.thread-bar {
  display: flex;
  gap: 6px;
  padding: 10px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
}
.thread-bar::-webkit-scrollbar { display: none; }

.thread-tab {
  --tab-color: var(--text-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 240px;
}
.thread-tab:hover { border-color: var(--tab-color); }
.thread-tab.active {
  border-color: var(--tab-color);
  box-shadow: inset 0 -3px 0 var(--tab-color);
}
.thread-tab .thread-name { overflow: hidden; text-overflow: ellipsis; }
.thread-tab .mi { color: var(--text-2); }
.thread-tab.add { border-style: dashed; color: var(--text-2); font-weight: 400; }
.thread-tab.add:hover { color: var(--text); border-color: var(--text-2); }

.thread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tab-color); flex-shrink: 0; }
.thread-new {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* the thread's own color on its line */
.content .track::before { background: var(--thread-color, var(--line)); height: 3px; margin-top: -1.5px; }
.content .note::before, .content .note::after { background: var(--thread-color, var(--line)); }
.content .thread-start .knot { background: var(--thread-color, var(--text)); }
.content .year-marker { color: var(--thread-color, var(--text)); }
.content .date-tag { border-color: var(--thread-color, var(--line)); }
.content .ruler-cell:not(.empty) .ruler-bar { background: var(--thread-color, var(--text-2)); }
.content .ruler-cell.active .ruler-bar { background: var(--red); }

/* thread settings */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 30px;
  height: 30px;
  border: 3px solid var(--card);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--card-border);
  cursor: pointer;
}
.swatch.active { box-shadow: 0 0 0 2px var(--text); }

/* the rainbow circle: opens the color picker, then shows the picked color */
.swatch.custom {
  position: relative;
  background: conic-gradient(#f43f5e, #f59e0b, #eab308, #22c55e, #06b6d4, #3b82f6, #8b5cf6, #ec4899, #f43f5e);
  overflow: hidden;
}
.swatch.custom.active { background: var(--picked, #888); }
.swatch.custom.active::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--card);
  background: conic-gradient(#f43f5e, #eab308, #22c55e, #3b82f6, #8b5cf6, #f43f5e);
}
.color-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }

.color-preview-row { margin-top: 10px; }
.color-preview { cursor: default; }

/* the new-post window: a bit wider, with the tool buttons grouped on the left */
.dialog.composer { max-width: 540px; }
.dialog-foot { flex-wrap: wrap; }
.composer-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.composer-tools .btn { height: 34px; padding: 0 12px 0 10px; font-size: 13.5px; }
.dialog-foot .end { flex-shrink: 0; }

.radio-row { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; cursor: pointer; color: var(--text); font-size: 14px; }
.radio-row input { margin-top: 3px; accent-color: var(--blue); }
.radio-row strong { font-weight: 500; }
.people-list { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 0 26px; padding: 6px 10px; border-radius: 10px; background: var(--soft); }
.person-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; cursor: pointer; color: var(--text); font-size: 14px; }
.person-row input { accent-color: var(--blue); }

/* "Who can post" in the Members window */
.who-can-post { padding-top: 12px; border-top: 1px solid var(--card-border); }
.who-can-post .people-list { margin-left: 26px; }
.action.muted-action { opacity: 0.55; }

/* "Post to" thread picker in the new-note window */
.post-to { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.post-to .dd { height: 34px; min-width: 0; }
.post-to .multi-dd { max-width: 300px; }

/* ---------- Voice memo recorder ---------- */

.recorder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--soft);
}
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: rec-pulse 1.2s ease-in-out infinite; flex-shrink: 0; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.rec-time { font-family: Consolas, monospace; font-size: 15px; min-width: 42px; }
.rec-meter { flex: 1; display: flex; align-items: center; gap: 2px; height: 32px; min-width: 0; overflow: hidden; }
.rec-meter span { flex: 1; min-width: 2px; max-width: 5px; height: 3px; border-radius: 2px; background: var(--red); transition: height 0.06s linear; }
.attach-listen { width: 100%; height: 32px; }

/* ---------- Controls: views, search, filters ---------- */

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
}
.controls::-webkit-scrollbar { display: none; }

.seg { display: flex; padding: 3px; border-radius: 10px; background: var(--soft); flex-shrink: 0; }
.seg-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
}
.seg-btn.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 220px;
  min-width: 180px;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  background: var(--soft);
  color: var(--text-2);
}
.search-box:focus-within { outline: 2px solid var(--blue); outline-offset: -2px; }
.search-input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; color: var(--text); }

/* ---------- Dropdowns (dropdown() in app.js) ---------- */

.dd {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  max-width: 100%;
  padding: 0 10px 0 10px;
  border: none;
  border-radius: 9px;
  background: var(--soft);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s;
}
.dd:hover, .dd.open { background: var(--card-border); }
.dd:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.dd-face { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dd-face .dd-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-chevron { display: flex; color: var(--text-2); transition: transform 0.15s; }
.dd.open .dd-chevron { transform: rotate(180deg); }

/* the menu: a card with a stitch sewn inside the edge, like the buttons */
.dd-menu {
  position: fixed;
  z-index: 55;
  max-width: calc(100vw - 16px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 14px 34px -10px rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.06);
  outline: 1.5px dashed var(--card-border);
  outline-offset: -5px;
  animation: dd-in 0.12s ease-out;
}
@keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } }
.dd-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
}
.dd-option.active { background: var(--soft); }
.dd-option.selected .dd-label { font-weight: 600; }
.dd-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dd-option .dd-label { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-hint { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-check { display: flex; color: var(--blue); flex-shrink: 0; }

/* what sits in front of each option: a thread's color, an icon or a person */
.dd-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}
.dd-option .dd-dot { margin: 0 1px; } /* line up with 16px icons */
.dd-icon { display: flex; color: var(--text-2); flex-shrink: 0; }
.dd-lang { width: 24px; height: 18px; border-radius: 4px; background: var(--soft); color: var(--text-2); font-size: 10px; font-weight: 700; letter-spacing: 0.5px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dd-option .dd-lang { background: var(--card-border); }
.dd-option.selected .dd-icon { color: var(--text); }
.avatar-xs { width: 20px; height: 20px; font-size: 10px; flex-shrink: 0; }

.today-pill { background: #fef3c7; color: #92400e; flex-shrink: 0; }
.today-pill:hover:not(:disabled) { background: #fde68a; }
[data-theme="dark"] .today-pill { background: #3d2e0a; color: #fcd34d; }
.surprise { flex-shrink: 0; }

/* ---------- Time ruler ---------- */

/* legend on the left, the months in the middle (scrolls), "Today" on the right */
.ruler-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--card-border);
  background: var(--bg);
}
.ruler-legend {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 12px 8px 16px;
  font-size: 11px;
  line-height: 13px;
  color: var(--text-2);
  cursor: help;
}
.ruler-legend span:first-child { font-weight: 600; color: var(--text); }
@media (max-width: 600px) { .ruler-legend { display: none; } }
.ruler-today { flex-shrink: 0; align-self: center; margin: 0 12px 0 8px; height: 32px; padding: 0 10px 0 12px; flex-direction: row-reverse; gap: 4px; font-size: 13px; }

.ruler {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 4px;
}
.ruler::-webkit-scrollbar { display: none; }
.ruler-track { display: flex; align-items: flex-end; gap: 3px; width: max-content; min-width: 100%; padding: 22px 0 6px; }

.ruler-cell {
  position: relative;
  width: 24px;
  height: 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
}
.ruler-cell:hover:not(:disabled) { background: var(--soft); }
.ruler-cell:disabled { cursor: default; opacity: 0.5; }
.ruler-cell.year-start { margin-left: 14px; }
.ruler-cell.year-start:first-child { margin-left: 0; }
.ruler-bar { width: 10px; height: calc(8px + var(--v, 0) * 32px); border-radius: 3px; background: var(--line); transition: background 0.2s, height 0.3s; }
.ruler-cell.empty .ruler-bar { height: 3px; }
.ruler-cell:not(.empty) .ruler-bar { background: var(--text-2); }
.ruler-cell.active .ruler-bar { background: var(--red); width: 12px; }
/* how many memories: above the month on screen, and above any bar you point at */
.ruler-count { font-size: 10px; font-weight: 700; line-height: 11px; color: var(--text-2); opacity: 0; transition: opacity 0.15s; }
.ruler-cell:hover .ruler-count { opacity: 1; }
.ruler-cell.active .ruler-count { opacity: 1; color: var(--red); }
.ruler-cell.active .ruler-month { color: var(--red); font-weight: 700; }
.ruler-month { font-size: 10px; line-height: 12px; }
.ruler-year {
  position: absolute;
  top: -16px;
  left: 0;
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* ---------- Thread: years, months, entrance ---------- */

.year-marker {
  position: relative;
  top: 0.06em; /* the numerals sit high in their box; this centers them on the line */
  z-index: 1;
  flex-shrink: 0;
  padding: 0 14px;
  background: var(--bg);
  font-family: var(--serif);
  font-size: 56px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -2px;
  color: var(--text);
  margin: 0 -20px;
}

.canvas.intro .note,
.canvas.intro .year-marker,
.canvas.intro .date-tag {
  animation: rise-in 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.canvas.intro .track::before { animation: draw-thread 0.9s ease-out both; transform-origin: left; }
@keyframes draw-thread { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes draw-thread-down { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* a note you jumped to glows for a moment */
.note.flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  0%, 30% { box-shadow: 0 0 0 4px var(--red); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.next-card.no-match { width: 220px; height: auto; padding: 18px 12px; cursor: default; }

/* ---------- Gallery and Files views ---------- */

.page-view { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 110px; }
.action .label-short { display: none; } /* "Create family" becomes "Create" on small screens */
.view-summary { margin: 8px 0 0; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ---------- Import photos & videos (import.js) ---------- */

.dialog.import-dialog { max-width: 680px; }
.import-summary { margin: 0; color: var(--text); }
.import-summary .hint { display: block; margin-top: 2px; }
.import-space { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--soft); color: var(--text-2); font-size: 13px; }
.import-space span { flex: 1; }
.import-space.full { background: #fef2f2; color: #b91c1c; }
[data-theme="dark"] .import-space.full { background: #3b1414; color: #fca5a5; }
.import-groups { display: flex; flex-direction: column; gap: 12px; }
.import-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card);
}
.import-group-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.import-group-head .grow { flex: 1; }
.import-group-head .btn { height: 30px; padding: 0 10px; font-size: 13px; }
.import-date { width: auto; height: 34px; padding: 0 10px; font-weight: 500; }
.import-count { color: var(--text-2); font-size: 13px; }
.import-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.import-tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: 8px;
  overflow: hidden;
  background: var(--soft);
  cursor: pointer;
}
.import-tile img, .import-tile video { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity 0.15s, filter 0.15s; }
.import-tile.off img, .import-tile.off video, .import-tile.off .import-tile-placeholder { opacity: 0.35; filter: grayscale(1); }
.import-tile-placeholder { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-2); font-size: 11px; font-weight: 600; }
.import-tick {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}
.import-tile.off .import-tick { background: rgba(0, 0, 0, 0.55); }
.import-tile .play-badge { transform: translate(-50%, -50%) scale(0.75); }
/* one line tall, text centred; grows as you type more (see import.js) */
.import-text { height: auto; min-height: 44px; padding: 11px 12px; line-height: 20px; resize: none; overflow: hidden; display: block; }
.import-status { margin: 0; font-weight: 500; }
.import-failures { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.import-failures li { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 8px; background: var(--soft); font-size: 13px; }
.import-failures span { color: var(--text-2); }
.import-source { align-items: flex-start; text-align: left; }
.import-source .grow { flex: 1; }

.month-section { padding-top: 18px; scroll-margin-top: 8px; }
.month-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
}
.month-title span { font-family: "Roboto", Arial, sans-serif; font-size: 13px; font-weight: 400; color: var(--text-2); }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: 8px;
  overflow: hidden;
  background: var(--soft);
}
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s; }
.tile:hover img, .tile:hover video { transform: scale(1.05); }
.play-badge {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-list { display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.file-row { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--card-border); }
.file-row .note-file, .file-row .note-audio { margin: 0; }
.file-meta { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; }
.file-meta .btn { margin-left: auto; height: 28px; padding: 0 8px; }

.empty-view { text-align: center; padding: 56px 16px; color: var(--text-2); }
.empty-view .empty-icon {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%;
  background: var(--soft); display: flex; align-items: center; justify-content: center;
}
.empty-view h2 { margin: 0 0 6px; font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--text); }
.empty-view p { margin: 0 auto 12px; max-width: 360px; }

/* ---------- Photo viewer ---------- */

.lightbox {
  padding: 0;
  background: rgba(0, 0, 0, 0.92);
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  grid-template-rows: 1fr auto;
  align-items: center;
}
.lightbox .icon-btn { color: #fff; width: 48px; height: 48px; justify-self: center; }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.lightbox > .icon-btn:first-child { position: absolute; top: 12px; right: 12px; z-index: 2; }
.lb-stage { height: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 56px 0 8px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.lb-caption {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 20px;
  color: #eee;
}
.lb-text { flex: 1; min-width: 0; font-size: 14px; }
.lb-note { color: #bbb; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-count { color: #999; font-size: 13px; white-space: nowrap; }
.lb-link { background: rgba(255, 255, 255, 0.12); color: #fff; }
.lb-link:hover:not(:disabled) { background: rgba(255, 255, 255, 0.22); }

/* ---------- Bottom buttons ---------- */

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 16px 16px max(20px, env(safe-area-inset-bottom));
  pointer-events: none;
}
.actionbar > * { pointer-events: auto; }

.action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 22px;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-decoration: none;
  white-space: nowrap;
}
.action:hover { filter: brightness(1.08); }
.action-blue { background: #2457c5; }
.action-dark { background: #1c1917; }
[data-theme="dark"] .action-dark { background: #f5f0e8; color: #1c1917; outline-color: rgba(0, 0, 0, 0.3); }

/* ---------- Dialogs ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dialog {
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px); /* the screen you can see, so the close button never ends up under a phone's address bar */
  overflow-y: auto;
  background: var(--card);
  border-radius: 12px;
}

.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 20px; }
.dialog-head h2 { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 600; }
.dialog-body { padding: 8px 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-body > p { margin: 0; color: var(--text-2); }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 8px 16px 16px; }
.dialog-foot .end { display: flex; gap: 8px; margin-left: auto; }
/* in a long window (an import, a post being written) the title with its close button stays at the
   top and the buttons stay at the bottom, so they never scroll out of reach */
.dialog-head { position: sticky; top: 0; z-index: 3; background: var(--card); }
.dialog-foot { position: sticky; bottom: 0; z-index: 3; background: var(--card); }
.import-dialog .dialog-foot, .dialog.composer .dialog-foot { border-top: 1px solid var(--card-border); padding-top: 10px; } /* the long ones: a line where the content scrolls under */
@media (max-width: 560px) {
  .dialog-foot { padding-bottom: max(16px, env(safe-area-inset-bottom)); } /* clear of the iPhone's home bar */
}

.menu-list { display: flex; flex-direction: column; margin: 0 -20px; padding-bottom: 8px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 44px;
  padding: 4px 20px;
  border: none;
  background: none;
  text-align: left;
  text-decoration: none;
}
.menu-item:hover { background: var(--soft); }

.radio-list { display: flex; flex-direction: column; margin: 0 -20px; }
.radio { display: flex; align-items: center; gap: 14px; padding: 10px 20px; cursor: pointer; }
.radio:hover { background: var(--soft); }
.radio input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.settings-section h3 { margin: 0 0 2px; font-size: 15px; font-weight: 500; }
.settings-section p { margin: 0 0 6px; color: var(--text-2); font-size: 13px; }

.composer-who { display: flex; align-items: center; gap: 10px; font-weight: 500; }

.photo-preview { position: relative; }
.photo-preview img { width: 100%; max-height: 280px; object-fit: cover; border-radius: 8px; display: block; }
.photo-preview .icon-btn { position: absolute; top: 6px; right: 6px; background: rgba(0, 0, 0, 0.6); color: #fff; }

.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--soft);
}
.notice .grow { flex: 1; color: var(--text-2); }
.notice strong { display: block; color: var(--text); font-weight: 500; }

.copy-box { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border-radius: 8px; background: var(--soft); }
.copy-box code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: Consolas, monospace;
  font-size: 13px;
  color: var(--text-2);
}

.member-list { display: flex; flex-direction: column; margin: 0 -20px; }
.member { display: flex; align-items: center; gap: 14px; padding: 6px 12px 6px 20px; min-height: 52px; }
.member-name { flex: 1; min-width: 0; }
.member-name div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-name .sub { color: var(--text-2); font-size: 12px; }

.storage { display: flex; flex-direction: column; gap: 6px; }
.storage-label { display: flex; justify-content: space-between; color: var(--text-2); font-size: 13px; }
.storage-bar { height: 4px; border-radius: 2px; background: var(--soft); overflow: hidden; }
.storage-bar > div { height: 100%; background: var(--blue); }

/* ---------- Welcome ---------- */

.welcome { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; overflow-y: auto; }
.welcome-card {
  width: 100%;
  max-width: 420px;
  padding: 32px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-weight: 600; font-size: 19px; margin-bottom: 24px; }
.brand img { display: block; }
.brand { color: var(--brand); }
.welcome h1 { margin: 0 0 8px; font-family: var(--serif); font-size: 30px; line-height: 36px; font-weight: 600; letter-spacing: -0.3px; }
.welcome .lead { margin: 0 0 20px; color: var(--text-2); font-size: 15px; line-height: 22px; }
.features { list-style: none; margin: 0 0 24px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.features li { display: flex; gap: 10px; color: var(--text-2); }
.features strong { color: var(--text); font-weight: 500; }
.fine { margin: 12px 0 0; font-size: 12px; color: var(--text-2); text-align: center; }

/* ---------- Welcome: pitch on the left, sign-in on the right ---------- */

.welcome-grid {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 56px;
  align-items: center;
}
.welcome-pitch .brand { margin-bottom: 28px; }
.pitch-title { font-family: var(--serif); font-size: 44px; line-height: 1.08; font-weight: 600; letter-spacing: -1px; margin: 0 0 14px; }
.welcome-grid .welcome-card { max-width: none; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Sign-in box ---------- */

.auth { display: flex; flex-direction: column; gap: 12px; }
.auth h1 { margin: 0; font-family: var(--serif); font-size: 26px; line-height: 32px; font-weight: 600; }
.auth h2 { margin: 4px 0 0; font-family: var(--serif); font-size: 22px; font-weight: 600; }
.auth .lead { margin: 0 0 4px; }
.auth-buttons { display: flex; flex-direction: column; gap: 10px; }
.muted { margin: 0; color: var(--text-2); }

.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 46px;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.oauth-google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.oauth-google:hover { background: #f8f9fa; }
.oauth-apple { background: #000; color: #fff; border: 1px solid #000; }
.oauth-apple:hover { background: #1c1c1c; }
[data-theme="dark"] .oauth-apple { background: #fff; color: #000; border-color: #fff; }

.auth-alt { height: 44px; justify-content: flex-start; padding: 0 16px; gap: 12px; }
.auth-alt.has-icon { padding-left: 16px; }

.or { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: 13px; margin: 4px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--card-border); }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: center;
  padding: 4px 6px;
  border: none;
  background: none;
  color: var(--blue);
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.back { align-self: flex-start; padding-left: 0; color: var(--text-2); }
.link-btn.inline { padding: 0 2px; align-self: auto; font-size: inherit; }
.email-line { overflow-wrap: anywhere; }

.code-input { height: 52px; text-align: center; font-size: 26px; letter-spacing: 10px; font-family: Consolas, monospace; }
.code-input.recovery { letter-spacing: 4px; font-size: 20px; }
.mfa-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--soft); display: flex; align-items: center; justify-content: center; }

/* ---------- Account & security ---------- */

.sec-heading { margin: 6px 0 -4px; font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-2); }
.sec-list { display: flex; flex-direction: column; border: 1px solid var(--card-border); border-radius: 12px; overflow: hidden; }
.sec-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.sec-row + .sec-row { border-top: 1px solid var(--card-border); }
.sec-icon { width: 34px; height: 34px; border-radius: 50%; background: var(--soft); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sec-text { flex: 1; min-width: 0; }
.sec-title { font-weight: 500; }
.sec-value { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }
.sec-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover:not(:disabled) { background: var(--soft); color: var(--red); }
.sec-foot { display: flex; justify-content: center; }

.qr { width: 200px; height: 200px; margin: 0 auto; padding: 8px; border-radius: 12px; background: #fff; display: flex; align-items: center; justify-content: center; text-align: center; }
.qr svg { width: 100%; height: 100%; }
.secret { font-family: Consolas, monospace; font-size: 13px; letter-spacing: 1px; user-select: all; }
.secret-box { display: flex; flex-direction: column; gap: 6px; }
.secret-box .hint { margin: 0; }
.secret-box .copy-box code.secret { font-size: 14px; cursor: pointer; white-space: normal; word-break: normal; overflow-wrap: normal; }
.secret-box .btn { flex-shrink: 0; }
.secret-box .btn.copied { background: #15803d; }
.steps { margin: 0; padding-left: 20px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }

.recovery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.recovery-grid code { padding: 8px; border-radius: 8px; background: var(--soft); text-align: center; font-family: Consolas, monospace; font-size: 15px; letter-spacing: 1px; }

@media (max-width: 860px) {
  .welcome-grid { grid-template-columns: 1fr; gap: 24px; max-width: 460px; }
  .welcome-pitch .features, .welcome-pitch .fine { display: none; }
  .welcome-pitch .brand { margin-bottom: 12px; }
  .pitch-title { font-size: 30px; }
}

/* ---------- Message at the bottom ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--dark);
  color: var(--dark-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Phones ---------- */

@media (max-width: 560px) {
  /* the thread runs top to bottom: oldest at the top, the newest (and the next memory) at the bottom */
  .canvas { display: block; overflow-x: hidden; padding-bottom: 0; cursor: auto; }
  .track { flex-direction: column; gap: 28px; width: auto; min-width: 0; margin: 0; padding: 24px 16px 110px; }
  .track::before, .content .track::before { left: 50%; right: auto; top: 0; bottom: 0; width: 3px; height: auto; margin: 0 0 0 -1.5px; }
  .canvas.intro .track::before { animation-name: draw-thread-down; transform-origin: top; }
  .note { width: 100%; max-width: 420px; }
  .note::before, .note::after { left: 50%; right: auto; margin: 0 0 0 -5px; }
  .note::before { top: -5.5px; }
  .note::after { top: auto; bottom: -5.5px; }
  .thread-start { align-items: center; padding-top: 0; }
  .thread-start .label { background: var(--bg); padding: 0 6px; }
  .year-marker { top: 0; margin: -8px 0; padding: 2px 12px; font-size: 44px; }
  .date-tag { margin: -14px 0; }
  .next-card { width: 100%; max-width: 420px; height: 100px; }

  /* the months run down the right side: tap one to go there */
  .content { position: relative; }
  .content .canvas, .content .page-view { padding-right: 44px; }
  .ruler-wrap { position: absolute; top: 0; right: 0; bottom: 0; z-index: 4; width: 40px; flex-direction: column; border-bottom: none; border-left: 1px solid var(--card-border); }
  /* every month fits on the strip (no scrolling of its own): slide a finger along it to scrub */
  .ruler { position: relative; overflow: hidden; padding: 0; touch-action: none; cursor: pointer; }
  .ruler-track { flex-direction: column; align-items: stretch; gap: 0; width: auto; min-width: 0; height: 100%; padding: 8px 0 96px; box-sizing: border-box; }
  .ruler-cell { flex: 1 1 0; min-height: 0; max-height: 18px; width: 40px; height: auto; flex-direction: row; justify-content: flex-end; gap: 3px; padding: 0 5px 0 0; border-radius: 0; }
  .ruler-cell:disabled { opacity: 1; }
  .ruler-cell.year-start { margin-left: 0; margin-top: 14px; }
  .ruler-cell.year-start:first-child { margin-top: 12px; }
  .ruler-bar { order: 2; height: 6px; width: calc(4px + var(--v, 0) * 18px); }
  .ruler-cell.empty .ruler-bar { height: 3px; width: 3px; }
  .ruler-cell.active .ruler-bar { width: calc(6px + var(--v, 0) * 18px); }
  .ruler-month { display: none; }
  .ruler-count, .ruler-today { display: none; }
  .ruler-year { top: -13px; left: auto; right: 4px; font-size: 10px; line-height: 12px; }

  /* nothing scrolls inside a card: one swipe always moves the thread */
  .note-text { max-height: none; overflow: visible; }
  .topbar .avatar-stack { display: none; }
  .actionbar { gap: 8px; padding-left: 8px; padding-right: 8px; }
  .action { height: 42px; padding: 0 14px; font-size: 14px; }
  .action .label-long { display: none; }
  .action .label-short { display: inline; }
  .overlay { align-items: flex-end; padding: 0; }
  .dialog { max-width: none; border-radius: 12px 12px 0 0; max-height: 92vh; max-height: 92dvh; }
  .welcome-card { padding: 24px 20px; }
}

/* ---------- Heirthread Plus ---------- */
.plus-dialog p { margin: 0; }
.plus-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.plus-features li { display: flex; gap: 12px; align-items: flex-start; }
.plus-features.compact { gap: 6px; }
.plus-features.compact li { align-items: center; color: var(--text-2); }
.plus-feature-icon {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.plus-features.compact .plus-feature-icon { width: 24px; height: 24px; border-radius: 7px; }
.plus-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plus-plan {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: 12px 14px; border-radius: 12px; border: 2px solid var(--card-border);
  background: var(--card); cursor: pointer;
}
.plus-plan:hover { border-color: var(--line); }
.plus-plan.active { border-color: var(--brand); background: var(--brand-soft); }
.plus-plan-title { font-size: 13px; color: var(--text-2); }
.plus-plan-price { font-size: 17px; font-weight: 600; }
.plus-plan-note { font-size: 12px; font-weight: 500; color: var(--brand); }
.plus-have { color: var(--brand); font-weight: 500; }
.plus-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plus-badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; margin-left: 6px;
  border: 0; border-radius: 10px; background: var(--brand-soft); color: var(--brand);
  font-size: 12px; font-weight: 600; cursor: pointer; vertical-align: middle;
}
.plus-status .plus-badge { margin-left: 0; cursor: default; }
.plus-notice > .mi { color: var(--brand); flex: none; }
@media (max-width: 420px) { .plus-plans { grid-template-columns: 1fr; } }
/* ---------- Time capsules ---------- */
.capsule-line {
  display: inline-flex; align-items: flex-start; gap: 6px; align-self: flex-start; max-width: calc(100% - 28px);
  margin: 8px 14px 0; padding: 4px 10px 4px 8px; border-radius: 12px; line-height: 17px;
  background: var(--brand-soft); color: var(--brand); font-size: 12.5px; font-weight: 500;
}
.capsule-line .mi { flex: none; margin-top: 1px; }
.post-view .capsule-line { margin: 0 0 4px; }
.capsule-line.sealed { background: var(--soft); color: var(--text-2); }
.note-sealed { background: var(--brand-soft); border-style: dashed; border-color: var(--brand); }
.sealed-body { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 18px 8px 22px; }
.sealed-icon {
  display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 6px;
  border-radius: 50%; background: var(--card); color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand) inset;
}
.sealed-title { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.sealed-date { color: var(--text); font-size: 13.5px; }
.sealed-countdown { color: var(--brand); font-size: 13px; font-weight: 500; }
.capsule-row {
  display: flex; flex-direction: column; gap: 10px; padding: 12px 14px;
  border: 1.5px dashed var(--brand); border-radius: 12px; background: var(--brand-soft);
}
.capsule-row .hint { margin: 0; }
.capsule-head { display: flex; align-items: center; gap: 8px; color: var(--brand); }
.capsule-head strong { flex: 1; color: var(--text); font-weight: 500; }
.capsule-field { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-2); flex-wrap: wrap; }
.capsule-input { width: auto; flex: 1; min-width: 200px; background: var(--card); }
.capsule-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 28px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--card-border);
  background: var(--card); font-size: 12.5px; cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Photo viewer layout: photo centred, poster and text along the bottom ---------- */
.lightbox { display: flex; flex-direction: column; }
.overlay.lightbox { background: rgba(0, 0, 0, 0.92); } /* darker than other windows, so the photo stands out */
.lightbox > .icon-btn:nth-child(2) { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); z-index: 2; }
.lightbox > .icon-btn:nth-child(4) { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); z-index: 2; }
.lb-stage { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; padding: 64px 72px 12px; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.lb-caption { width: 100%; max-height: 34vh; overflow-y: auto; padding: 14px 22px 20px; border-top: 1px solid rgba(255, 255, 255, 0.12); background: rgba(0, 0, 0, 0.45); }
.lb-note { white-space: pre-wrap; overflow: visible; text-overflow: clip; }

/* ---------- Icons: the phone app's set (Material Symbols Rounded), drawn from a font ---------- */

.mi {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  direction: ltr;
  display: inline-flex; /* the glyph stays centred even when a row stretches the box */
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  transition: font-variation-settings 0.15s;
}
.mi-fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

/* ---------- Animations (the same as the phone app) ---------- */

/* the heart: dips, pops, sparks fly out, and the count rolls */
.heart { position: relative; overflow: visible; }
.heart.pop .mi { animation: heart-pop 0.75s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes heart-pop {
  0% { transform: scale(1); }
  25% { transform: scale(0.75); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.heart-count { display: inline-block; min-width: 0; }
.heart-count.roll-up { animation: roll-up 0.42s ease-out; }
.heart-count.roll-down { animation: roll-down 0.42s ease-out; }
@keyframes roll-up { from { transform: translateY(70%); opacity: 0; } }
@keyframes roll-down { from { transform: translateY(-70%); opacity: 0; } }
.heart-sparks { position: absolute; width: 0; height: 0; pointer-events: none; }
.heart-sparks i {
  position: absolute;
  width: 5px; height: 5px; margin: -2.5px;
  border-radius: 50%;
  background: var(--red);
  animation: spark 0.9s ease-out forwards;
}
.heart-sparks i:nth-child(odd) { background: #ff9500; }
@keyframes spark {
  from { transform: rotate(var(--a)) translateY(-8px) scale(1); opacity: 1; }
  to { transform: rotate(var(--a)) translateY(-24px) scale(0.2); opacity: 0; }
}
.heart-sparks b {
  position: absolute;
  width: 12px; height: 12px; margin: -6px;
  border-radius: 50%;
  border: 2px solid var(--red);
  animation: spark-ring 0.3s ease-out forwards;
}
@keyframes spark-ring { to { transform: scale(2.6); opacity: 0; border-width: 0; } }

/* cards shrink a touch while pressed, and spring back */
.note { transition: transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1); }
.canvas:not(.panning) .note:active { transform: scale(0.985); transition-duration: 0.1s; }

/* Add Post: spins its + a quarter turn and sends out a ring */
.action-dark { --ring: #1c1917; }
[data-theme="dark"] .action-dark { --ring: #f5f0e8; }
.action-dark.spin .mi { animation: plus-spin 0.42s cubic-bezier(0.3, 1.5, 0.5, 1); }
@keyframes plus-spin { to { transform: rotate(90deg); } }
.action-dark.spin::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  border: 2px solid var(--ring);
  pointer-events: none;
  animation: add-ring 0.42s ease-out forwards;
}
@keyframes add-ring { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(1.18, 1.45); } }
.action { position: relative; }

/* Thread / Gallery / Files fade into each other */
.content.fade-through > * { animation: fade-through 0.22s ease-out; }
@keyframes fade-through { from { opacity: 0; transform: scale(0.985); } }

/* the chosen tab's icon gives a small bounce */
.seg-btn.active .mi { animation: icon-bounce 0.3s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes icon-bounce { from { transform: scale(0.8); } }

/* photos fade in */
.note-photo, .post-photos img, .gallery img { animation: photo-in 0.3s ease-out; }
@keyframes photo-in { from { opacity: 0; } }

/* loading: grey outlines of the page with a shimmer moving across */
.skeleton { padding: 18px 16px; max-width: 1100px; }
.sk {
  border-radius: 8px;
  background: linear-gradient(100deg, var(--soft) 30%, var(--soft-hover) 50%, var(--soft) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.sk-title { width: 220px; height: 28px; margin-bottom: 18px; }
.sk-row { display: flex; gap: 8px; margin-bottom: 26px; }
.sk-chip { width: 100px; height: 34px; border-radius: 10px; }
.sk-cards { display: flex; gap: 24px; overflow: hidden; }
.sk-card { flex: 0 0 300px; padding: 14px; border: 1px solid var(--card-border); border-radius: 12px; }
.sk-head { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.sk-avatar { width: 32px; height: 32px; border-radius: 50%; }
.sk-line { height: 12px; margin-top: 8px; }
.sk-photo { height: 170px; border-radius: 10px; margin-bottom: 6px; }

/* people who prefer less motion get none of it */
@media (prefers-reduced-motion: reduce) {
  .heart.pop .mi, .heart-count, .heart-sparks, .action-dark.spin .mi, .action-dark.spin::after,
  .content.fade-through > *, .seg-btn.active .mi, .note-photo, .post-photos img, .gallery img, .sk,
  .canvas.intro .note, .canvas.intro .year-marker, .canvas.intro .date-tag, .canvas.intro .track::before { animation: none !important; }
  .note { transition: none; }
}
/* double-tap a photo: a big red heart pops up on it and floats away */
.note-photo-print, .photo-tile { position: relative; }
.dbl-heart {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -48px 0 0 -48px;
  color: var(--red);
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.35));
  animation: dbl-heart 1.15s ease-out forwards;
}
@keyframes dbl-heart {
  0% { transform: scale(0.3); opacity: 0; }
  15% { transform: scale(1.15); opacity: 1; }
  30% { transform: scale(0.95); }
  45% { transform: scale(1); }
  80% { opacity: 1; }
  100% { transform: scale(1.05) translateY(-14px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .dbl-heart { animation-duration: 0.01s; } }
/* ---------- Zoom in the photo viewer (the same bar as the phone app) ---------- */
.zoom-bar {
  position: relative;
  align-self: center;
  flex-shrink: 0;
  margin: 4px 0 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 48px;
  padding: 0 6px;
  border-radius: 24px;
  background: rgba(31, 31, 31, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
}
.zoom-bar[hidden] { display: none; }
.lightbox .zoom-bar .icon-btn { width: 36px; height: 36px; }
.lightbox .zoom-bar .icon-btn:disabled { opacity: 0.3; }
.zoom-slider { width: 130px; accent-color: #fff; cursor: pointer; }
.zoom-box { display: flex; align-items: center; gap: 1px; height: 32px; padding: 0 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.13); color: #fff; font-weight: 600; cursor: text; }
.zoom-input { width: 3ch; border: none; background: none; color: #fff; font: inherit; text-align: right; outline: none; font-variant-numeric: tabular-nums; }
.zoom-box:focus-within { box-shadow: 0 0 0 1.5px #fff; }
/* zoomed photos can go past the frame; the frame clips them */
.lb-stage { overflow: hidden; }
.lb-stage img { transform-origin: center center; user-select: none; touch-action: none; }
.lb-stage.zoomed img { max-width: 100%; max-height: 100%; }
@media (max-width: 600px) {
  .zoom-bar, .zoom-bar[hidden] { display: none; }
}
/* Delete my account */
.danger-text { color: var(--red); }
.danger-text:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 10%, transparent); }
.danger-notice { background: color-mix(in srgb, var(--red) 9%, var(--card)); }
.danger-notice .mi { color: var(--red); }
.sec-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
/* the month bubble next to a finger sliding along the months (phones) */
.scrub-bubble {
  position: fixed;
  right: 52px;
  z-index: 20;
  transform: translateY(-50%);
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--dark);
  color: var(--dark-text);
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
