:root {
  --ink: #14213d;
  --ink-2: #2b3a5c;
  --muted: #6b7489;
  --line: #e3e0d8;
  --bg: #f5f2ea;
  --card: #fffdf8;
  --accent: #fca311;
  --accent-ink: #3d2600;
  --danger: #c0392b;
  --c-ask: #2f6fdb;
  --c-alert: #e2531d;
  --c-lost: #8e44ad;
  --c-offer: #1e9e63;
  --c-chat: #7a8094;
  --radius: 18px;
  --shadow: 0 1px 0 rgba(20, 33, 61, .04), 0 6px 18px -10px rgba(20, 33, 61, .25);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef1f8; --ink-2: #c4cbdc; --muted: #8d96ab; --line: #263150;
    --bg: #0d1426; --card: #141d33; --accent: #ffb52e; --accent-ink: #2a1a00;
    --c-chat: #9aa1b5;
    --shadow: 0 1px 0 rgba(0,0,0,.2), 0 10px 24px -14px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: 'Readex Pro', system-ui, 'Segoe UI', Tahoma, sans-serif; font-size: 16px; line-height: 1.6; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(110px + var(--safe-b)); }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 6px; }
.brand { display: flex; align-items: flex-end; gap: 10px; }
.wordmark { width: 92px; height: 47px; margin: 0; background: url(/wordmark.svg) no-repeat center / contain; }
@media (prefers-color-scheme: dark) { .wordmark { background-image: url(/wordmark-light.svg); } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.logo { width: 42px; height: 42px; display: grid; place-items: center; color: var(--ink); }
.logo svg { width: 42px; height: 42px; stroke: none; }
h1 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; direction: ltr; text-align: right; }
.tag { margin: 0 0 4px; font-size: .82rem; color: var(--muted); }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:active { background: var(--line); }

/* place + radius */
.place { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; }
.place-chip { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 500; font-size: .92rem; min-width: 0; }
.place-chip span:not(.pulse) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place-chip .chev { width: 16px; height: 16px; flex: none; opacity: .7; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; box-shadow: 0 0 0 0 rgba(252,163,17,.7); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(252,163,17,0); } 100% { box-shadow: 0 0 0 0 rgba(252,163,17,0); } }
.radius { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; flex: none; }
.radius button { padding: 5px 11px; border-radius: 999px; font-size: .82rem; color: var(--muted); }
.radius button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* filters */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: .88rem; color: var(--ink-2); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chip.on { background: var(--c, var(--ink)); border-color: transparent; color: #fff; }
.chip.on i { background: #fff; }
.chip.on:not([style]) { color: var(--bg); }

.sortbar { display: flex; align-items: center; justify-content: space-between; padding: 2px 16px 6px; }
.sort { display: flex; gap: 14px; }
.sort button { font-size: .85rem; color: var(--muted); padding: 4px 0; border-bottom: 2px solid transparent; }
.sort button.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.refresh { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.refresh.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }

/* feed */
.feed { padding: 4px 12px; display: flex; flex-direction: column; gap: 12px; }
.card { position: relative; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 10px; border-inline-start: 4px solid var(--c); animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.card-head { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; color: var(--c); font-weight: 600; }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.dot { opacity: .5; }
.card-head .more { margin-inline-start: auto; width: 32px; height: 32px; margin-block: -6px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.card-text { margin: 8px 0 10px; white-space: pre-wrap; word-wrap: break-word; font-size: 1.02rem; }
.card-img { display: block; width: 100%; max-height: 380px; object-fit: cover; border-radius: 12px; margin: 0 0 10px; background: var(--line); }
.card-foot { display: flex; align-items: center; gap: 4px; }
.vote { display: flex; align-items: center; background: var(--bg); border-radius: 999px; }
.vote button { width: 36px; height: 34px; display: grid; place-items: center; color: var(--muted); border-radius: 999px; }
.vote button svg { width: 20px; height: 20px; }
.vote button.on.up { color: var(--c-offer); }
.vote button.on.down { color: var(--danger); }
.vote b { min-width: 22px; text-align: center; font-size: .9rem; }
.reply-btn { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; color: var(--ink-2); font-size: .88rem; }
.reply-btn svg { width: 19px; height: 19px; }
.life { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.life svg { width: 22px; height: 22px; transform: rotate(-90deg); }
.life .track { stroke: var(--line); stroke-width: 3; }
.life .left { stroke: var(--accent); stroke-width: 3; }
.mine-tag { font-size: .72rem; background: var(--accent); color: var(--accent-ink); padding: 1px 8px; border-radius: 999px; font-weight: 600; }

/* empty / states */
.empty { text-align: center; padding: 44px 24px; color: var(--muted); }
.empty .art { width: 120px; height: 120px; margin: 0 auto 12px; }
.empty .art svg { width: 120px; height: 120px; stroke-width: 1.2; }
.empty h3 { color: var(--ink); margin: 0 0 6px; font-size: 1.1rem; }
.empty p { margin: 0 0 18px; }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card) 25%, var(--line) 50%, var(--card) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* FAB */
.fab { position: fixed; z-index: 10; bottom: calc(20px + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 15px 26px; border-radius: 999px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 1rem; box-shadow: 0 10px 30px -8px rgba(20,33,61,.55); }
.fab svg { color: var(--accent); }
.fab:active { transform: translateX(-50%) scale(.97); }

/* sheets */
.scrim { position: fixed; inset: 0; background: rgba(8, 12, 24, .45); z-index: 20; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; z-index: 21; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; background: var(--card); border-radius: 24px 24px 0 0; padding: 8px 18px calc(18px + var(--safe-b)); max-height: 92dvh; overflow-y: auto; animation: up .25s cubic-bezier(.2,.8,.2,1); }
.sheet.tall { height: 88dvh; display: flex; flex-direction: column; overflow: hidden; }
@keyframes up { from { transform: translateY(100%); } }
.grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 1.15rem; }
.muted { color: var(--muted); font-size: .92rem; margin: 0 0 14px; }
.label { font-size: .85rem; color: var(--muted); margin: 18px 0 8px; }

.cats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.field { border: 1.5px solid var(--line); border-radius: 16px; padding: 12px; background: var(--bg); }
.field:focus-within { border-color: var(--ink-2); }
textarea { width: 100%; border: 0; outline: 0; resize: none; background: transparent; font-size: 1.05rem; line-height: 1.6; }
.field-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.photo-btn { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: .85rem; color: var(--ink-2); }
.photo-btn svg { width: 18px; height: 18px; }
.count { font-size: .8rem; color: var(--muted); }
.count.near { color: var(--c-alert); }
.preview { position: relative; margin-top: 10px; }
.preview img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; display: block; }
.preview .icon-btn { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.55); color: #fff; width: 34px; height: 34px; }
.promises { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 6px; font-size: .88rem; color: var(--ink-2); }
.promises li { display: flex; gap: 8px; align-items: baseline; }
.form-error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: 10px 12px; border-radius: 12px; font-size: .9rem; margin: 0 0 12px; }
.primary { width: 100%; padding: 15px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 1.05rem; }
.primary:disabled { opacity: .55; }
.primary.small { width: auto; padding: 10px 18px; font-size: .95rem; border-radius: 12px; }
.ghost { width: 100%; padding: 13px; border-radius: 14px; border: 1px solid var(--line); color: var(--ink-2); }

.spots { display: grid; gap: 8px; }
.spot { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--line); text-align: start; }
.spot::before { content: '📍'; }
.spot.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* thread */
.thread-post .card { box-shadow: none; border: 1px solid var(--line); border-inline-start-width: 4px; }
.replies { flex: 1; overflow-y: auto; padding: 10px 2px; display: flex; flex-direction: column; gap: 10px; }
.reply { background: var(--bg); border-radius: 14px; padding: 9px 12px; max-width: 92%; }
.reply.op { background: color-mix(in srgb, var(--accent) 16%, var(--bg)); }
.reply.mine { align-self: flex-end; }
.reply-head { display: flex; gap: 8px; font-size: .76rem; color: var(--muted); align-items: center; }
.reply-head b { color: var(--ink-2); font-weight: 600; }
.reply-head button { margin-inline-start: auto; font-size: .74rem; color: var(--muted); }
.reply p { margin: 2px 0 0; white-space: pre-wrap; word-wrap: break-word; }
.reply-bar { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.reply-bar input { flex: 1; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); outline: 0; }
.reply-bar input:focus { border-color: var(--ink-2); }

/* menu */
.menu { display: grid; gap: 4px; padding-bottom: 6px; }
.menu h3 { margin: 0 0 6px; font-size: 1rem; }
.menu button { display: flex; align-items: center; gap: 12px; padding: 14px 10px; border-radius: 12px; text-align: start; font-size: 1rem; }
.menu button:active { background: var(--bg); }
.menu button.danger { color: var(--danger); }

.karma { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.karma div { background: var(--bg); border-radius: 16px; padding: 14px; text-align: center; }
.karma b { display: block; font-size: 1.8rem; line-height: 1.2; }
.karma span { font-size: .82rem; color: var(--muted); }

.toast { position: fixed; z-index: 40; bottom: calc(90px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: .9rem; max-width: calc(100% - 32px); text-align: center; animation: rise .25s; }

@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; } }
