/* Layout: dark page on a faint engineering-paper grid; centered header; share buttons and filters; a scattered scrapbook board of paper cards. */
:root {
  --bg: #161917;
  --grid-major: #222824;
  --grid-minor: #1b1f1c;
  --surface: #1e2320;
  --fg: #dcdfdc;
  --fg-strong: #eef0ee;
  --muted: #8d958f;
  --line: #2e3531;
  --line-strong: #3a423d;
  --accent: #9bb5a4;
  --accent-fg: #132017;
  --danger: #e07a6e;

  --paper: #f1efe9;
  --note: #e9e6dc;
  --index: #f8f7f2;
  --ink: #26261f;
  --ink-soft: #5d5d55;
  --tape: rgba(214, 205, 170, .72);
  --rule: #d3dbe2;
  --redline: #c99090;
  --photo-bg: #59625c;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--fg); font: 16px/1.6 var(--sans);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 60px 60px, 60px 60px, 12px 12px, 12px 12px;
  background-position: -1px -1px;
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 20px; }
.narrow { max-width: 680px; }

/* Header */
.hero { padding-block: 56px 28px; text-align: center; }
.hero .portrait {
  width: 190px; height: 228px; object-fit: cover; margin: 0 auto 24px;
  border-radius: 4px; background: var(--line);
}
.hero h1 { font: 600 clamp(2rem, 6vw, 3rem)/1.15 var(--serif); margin: 0 0 6px; color: var(--fg-strong); text-wrap: balance; }
.hero .dates { color: var(--muted); margin: 0; font-variant-numeric: tabular-nums; }

.info { padding-block: 24px; }
.info h2 { font: 600 1.4rem/1.3 var(--serif); margin: 0 0 12px; color: var(--fg-strong); }
.info p { margin: 0 0 1em; }
.service dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0; }
.service dt { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; padding-top: 3px; }
.service dd { margin: 0; }

/* Buttons */
.btn {
  font: 600 .92rem/1 var(--sans); padding: 11px 16px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--bg); color: var(--fg); cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger.armed { background: var(--danger); color: var(--bg); }
.btn:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Wall controls */
.wall-section { padding-block: 16px 40px; }
.share-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.filter-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 28px 0 8px; }
.filters { display: flex; gap: 18px; flex-wrap: wrap; flex: 1; }
.chip {
  background: none; border: 0; padding: 4px 0; cursor: pointer;
  font: 400 .9rem var(--sans); color: var(--muted); border-bottom: 1.5px solid transparent;
}
.chip.on { color: var(--fg-strong); border-bottom-color: var(--fg-strong); }
.order select {
  font: .85rem var(--sans); color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px;
}

/* Board */
.board { position: relative; min-height: 120px; margin-top: 20px; }
.status { color: var(--muted); text-align: center; padding-block: 32px; }

.item {
  position: absolute; left: 0; top: 0;
  transform: translate(var(--x, 0), var(--y, 0)) rotate(var(--r, 0deg));
  transition: transform .2s ease, box-shadow .2s ease;
  color: var(--ink); font-size: .9rem; line-height: 1.5;
  box-shadow: 0 3px 10px rgb(0 0 0 / .45);
  cursor: pointer;
}
.item:hover, .item:focus-visible { transform: translate(var(--x, 0), var(--y, 0)) rotate(0deg) scale(1.03); z-index: 5; box-shadow: 0 8px 22px rgb(0 0 0 / .55); }
.tape {
  position: absolute; top: -9px; left: 50%; width: 64px; height: 18px; margin-left: -32px;
  background: var(--tape); transform: rotate(var(--tr, -2deg));
}
.by { color: var(--ink-soft); font-size: .8rem; margin-top: 8px; }
.by strong { color: var(--ink); font-weight: 600; }

/* Photo: polaroid */
.item.photo .pol { background: var(--paper); padding: 8px 8px 12px; }
.item.photo .frame { position: relative; background: var(--photo-bg); }
.item.photo .frame img { width: 100%; height: 100%; object-fit: cover; }
.item.photo .count {
  position: absolute; right: 6px; bottom: 6px; background: rgb(0 0 0 / .6); color: #fff;
  font-size: .75rem; padding: 2px 7px; border-radius: 10px;
}
.item.photo .cap { font-family: var(--serif); margin-top: 8px; color: var(--ink); }
.item.photo.stack::before {
  content: ""; position: absolute; inset: 0; background: #dedbd2; z-index: -1;
  transform: rotate(5deg) translate(6px, 3px);
}

/* Memory: taped note */
.item.memory { background: var(--note); padding: 18px 16px 14px; }
.item.memory .text { font-family: var(--serif); font-size: .98rem; white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 10; -webkit-box-orient: vertical; overflow: hidden; }
.item.memory .mini { margin-top: 10px; position: relative; background: var(--photo-bg); }
.item.memory .mini img { width: 100%; height: 100%; object-fit: cover; }

/* Verse: index card */
.item.verse {
  background-color: var(--index);
  background-image: linear-gradient(transparent 23px, var(--rule) 24px);
  background-size: 100% 24px; background-position: 0 30px;
  border-top: 3px solid var(--redline); padding: 10px 16px 12px;
}
.item.verse .vtext { font-family: var(--serif); font-size: 1rem; line-height: 24px; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 12; -webkit-box-orient: vertical; overflow: hidden; }
.item.verse .ref { font-size: .8rem; font-weight: 600; letter-spacing: .02em; line-height: 24px; margin-top: 4px; }
.item.verse .why { font-size: .85rem; line-height: 24px; color: var(--ink-soft); margin-top: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.item.verse .by { margin-top: 0; line-height: 24px; }

/* Dialogs */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--fg);
  padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
}
dialog::backdrop { background: rgb(0 0 0 / .65); }
.dialog-inner { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; font: 600 1.4rem/1.3 var(--serif); color: var(--fg-strong); }
.close { background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
label .hint { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], textarea {
  font: 1rem/1.5 var(--sans); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg); color: var(--fg); width: 100%;
}
input::placeholder { color: #5f6862; }
textarea { min-height: 140px; resize: vertical; }
textarea.short { min-height: 80px; }
textarea.serif { font-family: var(--serif); }
input[type="file"] { font: .9rem var(--sans); color: var(--muted); }
.ref-row { display: flex; gap: 8px; }
.ref-row input { flex: 1; min-width: 0; }
.field-msg { margin: 6px 0 0; font-size: .85rem; color: var(--muted); min-height: 0; }
.field-msg:empty { display: none; }
.field-msg.error, .msg.error { color: var(--danger); }
.hp { position: absolute; left: -9999px; }
#share-form .mode-memory, #share-form .mode-photo, #share-form .mode-verse { display: flex; flex-direction: column; gap: 8px; }

.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.previews:empty { display: none; }
.previews div { position: relative; aspect-ratio: 1; border-radius: 4px; overflow: hidden; background: var(--line); }
.previews img { width: 100%; height: 100%; object-fit: cover; }
.previews button {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: rgb(0 0 0 / .65); color: #fff; cursor: pointer; font-size: 14px; line-height: 1;
}
.form-actions { display: flex; gap: 12px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.msg { font-size: .9rem; color: var(--muted); margin-right: auto; }

/* Detail view */
#detail-dialog { width: min(640px, calc(100vw - 32px)); }
#detail-body .d-text { font-family: var(--serif); font-size: 1.08rem; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 16px; color: var(--fg-strong); }
#detail-body .d-ref { font-weight: 600; margin: -6px 0 16px; }
#detail-body .d-why { color: var(--fg); white-space: pre-wrap; margin: 0 0 16px; }
#detail-body .d-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin-bottom: 16px; }
#detail-body .d-photos button { padding: 0; border: 0; aspect-ratio: 1; overflow: hidden; cursor: zoom-in; background: var(--line); }
#detail-body .d-photos img { width: 100%; height: 100%; object-fit: cover; }
#detail-body .d-by { color: var(--muted); font-size: .9rem; }
#detail-body .d-by strong { color: var(--fg-strong); font-weight: 600; }

/* Lightbox */
#lightbox { width: auto; max-width: calc(100vw - 32px); background: #000; border: 0; }
#lightbox .lb { position: relative; }
#lightbox img { max-height: calc(100dvh - 48px); max-width: calc(100vw - 32px); margin: 0 auto; }
#lightbox button {
  position: absolute; top: 50%; transform: translateY(-50%); background: rgb(0 0 0 / .5); color: #fff;
  border: 0; width: 44px; height: 44px; border-radius: 50%; font-size: 1.4rem; cursor: pointer;
}
#lightbox .prev { left: 8px; } #lightbox .next { right: 8px; }
#lightbox .x { top: 24px; right: 8px; transform: none; }

footer { padding-block: 32px; text-align: center; font-size: .85rem; }
footer a { color: var(--muted); }

@media (max-width: 480px) {
  .hero { padding-block: 36px 20px; }
  .hero .portrait { width: 150px; height: 180px; }
  .service dl { grid-template-columns: 1fr; gap: 0; }
  .service dd { margin-bottom: 10px; }
  .share-row .btn { flex: 1 1 100%; }
  .filters { gap: 16px; flex: 1 1 100%; }
  .filter-row { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { .item { transition: none; } }
