:root {
  --bg: #f5f1ea;
  --card: #fffdf9;
  --ink: #2a2622;
  --muted: #7b7268;
  --line: #e6dfd3;
  --soft: #efe9de;
  --accent: #7a5c3b;
  --accent-ink: #ffffff;
  --err: #b3261e;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .05);
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171512;
    --card: #211e1a;
    --ink: #efe9df;
    --muted: #a0968a;
    --line: #38332c;
    --soft: #2b2722;
    --accent: #d1a970;
    --accent-ink: #1b1710;
    --err: #ff8a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); }
a { color: var(--accent); }
img, video { max-width: 100%; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.muted { color: var(--muted); }

/* header */
.hero { text-align: center; padding: 44px 20px 24px; max-width: 720px; margin: 0 auto; }
.hero-photo { width: 168px; height: 168px; object-fit: cover; border-radius: 50%; border: 5px solid var(--card); box-shadow: var(--shadow); margin-bottom: 18px; }
.hero h1 { font: 600 clamp(28px, 6vw, 42px)/1.15 var(--serif); margin: 0 0 6px; letter-spacing: .2px; }
.hero-sub { font: italic 20px var(--serif); color: var(--muted); margin: 0 0 14px; }
.hero-text { color: var(--muted); max-width: 520px; margin: 0 auto; }
.music { max-width: 680px; margin: 0 auto 18px; padding: 0 16px; }
.music iframe { display: block; border: 0; border-radius: 12px; }
.music-note { color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0 0; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 14px 60px; }
.wrap.narrow { padding-top: 24px; }
.wrap.wide { max-width: 1240px; }

/* Wall: one column on phones, more columns as the window gets wider (newest at the top of each column) */
.wrap.wall { max-width: 2200px; padding-left: clamp(12px, 2vw, 32px); padding-right: clamp(12px, 2vw, 32px); }
.wall .composer, .wall .notice { max-width: 680px; margin-left: auto; margin-right: auto; }
.wall .composer { margin-bottom: 22px; }
#feed { display: flex; justify-content: center; align-items: flex-start; gap: 16px; }
.mcol { flex: 1 1 0; min-width: 0; max-width: 640px; }
.mcol > .card { margin-bottom: 16px; }
.wall .empty, .wall .end { text-align: center; color: var(--muted); }
.back { margin: 0 0 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); margin: 0 0 16px; }
.notice { text-align: center; color: var(--muted); }

/* buttons + inputs */
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 96px; }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 9px 22px; font-weight: 600; }
.primary.small { padding: 8px 16px; }
.primary:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; color: var(--muted); padding: 8px 10px; }
.form-msg { margin: 8px 2px 0; min-height: 1.2em; font-size: 14px; color: var(--muted); }
.form-msg.err { color: var(--err); }

/* composer */
.composer { padding: 14px; }
.composer-open { width: 100%; text-align: left; background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 13px 18px; color: var(--muted); }
#composer-form { display: grid; gap: 10px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar .spacer { flex: 1; }
.tool { background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 14px; cursor: pointer; }
.tool:hover { border-color: var(--accent); }
.emoji-pop { display: flex; flex-wrap: wrap; gap: 2px; max-height: 190px; overflow: auto; padding: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.emoji-pop[hidden] { display: none; }
.emoji-pop button { font-size: 24px; line-height: 1; background: none; border: 0; padding: 6px; border-radius: 8px; }
.emoji-pop button:hover { background: var(--soft); }

.previews { display: flex; flex-wrap: wrap; gap: 8px; }
.previews:empty { display: none; }
.prev { position: relative; width: 92px; height: 92px; border-radius: 10px; overflow: hidden; background: var(--soft); border: 1px solid var(--line); }
.prev img, .prev video { width: 100%; height: 100%; object-fit: cover; display: block; }
.prev .ph { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 13px; }
.prev .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0, 0, 0, .25); }
.prev .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.prev[data-state=done] .bar { display: none; }
.prev[data-state=error] { border-color: var(--err); }
.prev[data-state=error] .bar i { background: var(--err); width: 100% !important; }
.prev .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; line-height: 22px; padding: 0; font-size: 16px; }
.prev .tag { position: absolute; left: 4px; bottom: 8px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.prev .state { position: absolute; left: 4px; top: 4px; font-size: 11px; color: #fff; background: rgba(0, 0, 0, .55); border-radius: 6px; padding: 0 5px; }
.prev .state:empty { display: none; }

/* posts */
.post { padding: 14px 14px 8px; }
.post-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 600 18px var(--serif); }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.author { font-weight: 600; }
.when { color: var(--muted); font-size: 13px; text-decoration: none; }
.when:hover { text-decoration: underline; }
.post-body { white-space: normal; overflow-wrap: anywhere; font-size: 17px; margin-bottom: 8px; }

.media-grid { display: grid; gap: 3px; margin: 10px -14px 0; overflow: hidden; background: var(--line); }
.media-grid .tile { position: relative; display: block; background: var(--soft); overflow: hidden; }
.media-grid img, .media-grid video { display: block; width: 100%; }
.g1 .tile img, .g1 .tile video { height: auto; max-height: 640px; object-fit: contain; background: #000; }
.g1 .tile:has(img) img { object-fit: cover; background: none; }
.g1 .tile { display: flex; justify-content: center; }
.g2 { grid-template-columns: 1fr 1fr; }
.g2 .tile { aspect-ratio: 1 / 1; }
.g2 .tile img, .g3 .tile img, .g2 .tile video, .g3 .tile video { height: 100%; object-fit: cover; }
.g3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 4 / 3; }
.g3 .tile:first-child { grid-row: 1 / 3; }
.badge { position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .55); color: #fff; font: 600 clamp(26px, 6vw, 38px) var(--sans); }
.pending { display: grid; place-items: center; min-height: 140px; height: 100%; color: var(--muted); font-size: 14px; padding: 10px; text-align: center; }
.pending.block { border: 1px dashed var(--line); border-radius: 10px; }

.counts { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px 8px; color: var(--muted); font-size: 14px; min-height: 40px; }
.rx-summary { display: inline-flex; align-items: center; gap: 6px; }
.rx-summary[hidden] { display: none; }
.rx-emojis { letter-spacing: -2px; font-size: 16px; }
.comment-count { margin-left: auto; background: none; border: 0; color: var(--muted); padding: 2px 0; }
.comment-count:hover { text-decoration: underline; }
.actions { display: flex; border-top: 1px solid var(--line); padding: 4px 0; gap: 4px; }
.act { flex: 1; background: none; border: 0; border-radius: 10px; padding: 9px 4px; color: var(--muted); font-weight: 600; font-size: 14px; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.act:hover { background: var(--soft); }
.react-btn.on { color: var(--accent); }
.react-wrap { position: relative; flex: 1; display: flex; }
.react-wrap .react-btn { flex: 1; }
.react-pop { position: absolute; bottom: 100%; left: 0; z-index: 5; display: flex; gap: 2px; padding: 6px; margin-bottom: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 6px 22px rgba(0, 0, 0, .18); }
.react-pop[hidden] { display: none; }
.react-pop button { font-size: 28px; line-height: 1; background: none; border: 0; padding: 4px 6px; border-radius: 50%; transition: transform .12s; }
.react-pop button:hover { transform: scale(1.3) translateY(-3px); }

.comments { border-top: 1px solid var(--line); padding: 10px 0 8px; }
.comment { display: flex; gap: 8px; margin-bottom: 10px; }
.bubble { background: var(--soft); border-radius: 14px; padding: 8px 12px; min-width: 0; }
.c-author { font-weight: 600; font-size: 14px; }
.c-body { overflow-wrap: anywhere; }
.c-when { color: var(--muted); font-size: 12px; margin-top: 2px; }
.comment-form { display: grid; gap: 6px; margin-top: 6px; }
.comment-row { display: flex; gap: 8px; }

.new-banner { display: block; margin: 0 auto 14px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 9px 20px; font-weight: 600; position: sticky; top: 10px; z-index: 6; box-shadow: var(--shadow); }
.new-banner[hidden] { display: none; }
.empty, .end { text-align: center; color: var(--muted); margin: 30px 0; }
.empty[hidden], .end[hidden] { display: none; }

/* photo page */
.gallery-title { font: 600 24px var(--serif); margin: 0 0 4px; }
.gallery { display: grid; gap: 14px; margin-top: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; }
.gallery-item { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.gallery-item img, .gallery-item video { display: block; width: 100%; height: auto; }
.gallery-item.focus { outline: 3px solid var(--accent); }

/* GIF picker */
dialog { width: min(560px, 94vw); max-height: 86vh; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); padding: 14px; }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.gif-head { display: flex; gap: 8px; margin-bottom: 10px; }
.gif-grid { columns: 3 120px; column-gap: 6px; max-height: 60vh; overflow: auto; }
.gif-grid button { display: block; width: 100%; padding: 0; border: 0; background: none; margin-bottom: 6px; border-radius: 8px; overflow: hidden; }
.gif-grid img { display: block; width: 100%; }
.gif-credit { color: var(--muted); font-size: 12px; text-align: right; margin: 6px 0 0; }

/* misc */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; z-index: 30; background: #2a2622; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: min(92vw, 460px); text-align: center; transition: .25s; box-shadow: 0 8px 28px rgba(0, 0, 0, .3); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.ts-box { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); z-index: 40; }
.enter { text-align: center; padding-top: 70px; }
.enter h1 { font: 600 32px var(--serif); }
.enter-card { padding: 18px; display: grid; gap: 12px; margin-top: 18px; }

@media (max-width: 520px) {
  .hero { padding-top: 30px; }
  .hero-photo { width: 132px; height: 132px; }
  .post { padding-left: 12px; padding-right: 12px; }
  .media-grid { margin-left: -12px; margin-right: -12px; }
  .card { border-radius: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
