:root {
  --bg: #0b0a10;
  --surface: #16141d;
  --surface-2: #211e2b;
  --line: #2c2838;
  --text: #f4f2f8;
  --muted: #9c97ab;
  --gold: #f2c14e;
  --gold-ink: #1d1500;
  --purple: #8b5cf6;
  --purple-soft: rgba(139, 92, 246, 0.18);
  --danger: #ff6b6b;
  --radius: 18px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.boot { min-height: 100dvh; display: grid; place-items: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--gold);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Shell ─────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(var(--bg) 70%, rgba(11,10,16,0));
}
.wordmark { font-weight: 900; font-size: 20px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.wordmark .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(242,193,78,.2); }
.wordmark small { font-weight: 700; font-size: 11px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.pill { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 4px 8px; border-radius: 99px; background: var(--purple-soft); color: #c4b5fd; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); }
.icon-btn svg { width: 20px; height: 20px; }

main { max-width: 560px; margin: 0 auto; padding: 0 0 calc(var(--nav-h) + var(--safe-b) + 24px); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: 1fr 1fr 88px 1fr 1fr; align-items: center;
  background: rgba(11,10,16,.92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.nav a { display: grid; justify-items: center; gap: 2px; font-size: 10px; font-weight: 600; color: var(--muted); padding: 8px 0; }
.nav a svg { width: 24px; height: 24px; }
.nav a.active { color: var(--text); }
.shutter {
  justify-self: center; width: 64px; height: 64px; margin-top: -26px; border-radius: 50%;
  background: var(--gold); color: var(--gold-ink);
  display: grid; place-items: center;
  box-shadow: 0 0 0 5px var(--bg), 0 8px 24px rgba(242,193,78,.35);
  transition: transform .15s;
}
.shutter:active { transform: scale(.92); }
.shutter svg { width: 30px; height: 30px; }

/* ── Feed ──────────────────────────────────────── */
.feed { display: grid; gap: 28px; padding: 4px 0 0; }
.card { padding: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 0 16px 10px; }
.card-head .who { flex: 1; min-width: 0; }
.card-head .line { font-weight: 600; line-height: 1.3; }
.card-head .line .verb { color: var(--gold); font-weight: 800; margin: 0 2px; }
.card-head .meta { color: var(--muted); font-size: 12.5px; }
.more { width: 32px; height: 32px; border-radius: 50%; color: var(--muted); font-size: 20px; line-height: 1; }

.photo { position: relative; margin: 0 8px; border-radius: var(--radius); overflow: hidden; background: var(--surface); aspect-ratio: 4 / 5; }
.photo img { width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.photo .stamp {
  position: absolute; left: 12px; bottom: 12px; padding: 5px 10px; border-radius: 99px;
  background: rgba(0,0,0,.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.burst { position: absolute; left: 50%; top: 50%; font-size: 96px; transform: translate(-50%,-50%) scale(0); pointer-events: none; animation: burst .7s ease-out forwards; }
@keyframes burst { 30% { transform: translate(-50%,-50%) scale(1.15); opacity: 1 } 70% { transform: translate(-50%,-50%) scale(1); opacity: 1 } 100% { transform: translate(-50%,-60%) scale(1); opacity: 0 } }

.react-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 11px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 600;
  transition: transform .1s, background .15s;
}
.chip:active { transform: scale(.94); }
.chip.on { background: var(--purple-soft); border-color: var(--purple); }
.chip .n { font-variant-numeric: tabular-nums; font-size: 13px; }
.chip.ghost { color: var(--muted); }
.chip.comments { margin-left: auto; }
.caption { margin: 8px 16px 0; }
.caption b { font-weight: 700; margin-right: 4px; }

.empty { text-align: center; color: var(--muted); padding: 60px 24px; }
.empty .big { font-size: 44px; margin-bottom: 8px; }
.sentinel { height: 1px; }
.loading-more { display: grid; place-items: center; padding: 24px; }

.new-banner {
  position: fixed; top: calc(var(--safe-t) + 64px); left: 50%; transform: translateX(-50%); z-index: 25;
  background: var(--gold); color: var(--gold-ink); font-weight: 800; font-size: 13px;
  padding: 8px 14px; border-radius: 99px; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

.notice {
  margin: 0 12px 20px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  display: flex; gap: 12px; align-items: flex-start;
}
.notice .ico { font-size: 22px; line-height: 1.1; }
.notice .body { flex: 1; font-size: 14px; }
.notice .body b { display: block; margin-bottom: 2px; }
.notice .actions { display: flex; gap: 8px; margin-top: 10px; }

/* ── Avatars ───────────────────────────────────── */
.av { flex: none; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.lg { width: 96px; height: 96px; font-size: 32px; }
.av.sm { width: 28px; height: 28px; font-size: 11px; }

/* ── Buttons & forms ───────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--line);
}
.btn.primary { background: var(--gold); color: var(--gold-ink); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); outline: none;
}
textarea.input { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: var(--purple); }
.err { color: var(--danger); font-size: 13.5px; min-height: 1.4em; margin: 4px 0 0; }

/* ── Login ─────────────────────────────────────── */
.login { min-height: 100dvh; display: grid; align-content: center; padding: 24px 24px calc(24px + var(--safe-b)); max-width: 420px; margin: 0 auto; }
.login .hero { font-size: 44px; font-weight: 900; letter-spacing: -0.04em; line-height: .95; margin: 0 0 10px; }
.login .hero span { color: var(--gold); }
.login p.lede { color: var(--muted); margin: 0 0 28px; }
.code-input { letter-spacing: .3em; font-size: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.linkish { color: var(--muted); font-size: 13.5px; text-decoration: underline; margin-top: 12px; }

/* ── Sheets & overlays ─────────────────────────── */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0 } }
.sheet {
  width: 100%; max-width: 560px; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 22px 22px 0 0; padding-bottom: var(--safe-b);
  animation: up .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes up { from { transform: translateY(40px); opacity: .6 } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 800; }
.sheet-body { overflow-y: auto; padding: 12px 16px; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.menu-list { display: grid; padding: 8px; }
.menu-list button { text-align: left; padding: 14px 12px; border-radius: 12px; font-weight: 600; }
.menu-list button:active { background: var(--surface-2); }

.comment { display: flex; gap: 10px; padding: 8px 0; }
.comment .c-body { flex: 1; min-width: 0; }
.comment .c-body b { font-weight: 700; margin-right: 6px; }
.comment .c-meta { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; gap: 10px; }
.comment .c-meta button { color: var(--muted); font-size: 12px; }

/* ── Compose ───────────────────────────────────── */
.compose { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; animation: fade .15s; }
.compose-head { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-t) + 10px) 16px 10px; }
.compose-body { flex: 1; overflow-y: auto; padding: 0 16px 16px; max-width: 560px; width: 100%; margin: 0 auto; }
.compose-photo { border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/5; width: min(100%, 40dvh); margin: 0 auto 18px; background: var(--surface); position: relative; }
.compose-photo img { width: 100%; height: 100%; object-fit: cover; }
.compose-photo .retake { position: absolute; right: 10px; bottom: 10px; }
.compose-foot { padding: 10px 16px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); max-width: 560px; width: 100%; margin: 0 auto; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; max-height: 196px; overflow-y: auto; }
.pick {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px 0 5px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 14px;
}
.pick.on { background: var(--gold); color: var(--gold-ink); border-color: transparent; }
.pick .av { width: 28px; height: 28px; font-size: 11px; }

/* ── Leaderboard ───────────────────────────────── */
.page { padding: 4px 16px 0; }
.page h1 { font-size: 28px; font-weight: 900; letter-spacing: -0.03em; margin: 4px 0 14px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { height: 34px; border-radius: 9px; font-weight: 700; font-size: 13.5px; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 8px; margin: 22px 0 18px; text-align: center; }
.podium .spot { display: grid; justify-items: center; gap: 6px; }
.podium .spot .av { width: 58px; height: 58px; font-size: 20px; box-shadow: 0 0 0 3px var(--surface-2); }
.podium .spot.first .av { width: 76px; height: 76px; font-size: 26px; box-shadow: 0 0 0 3px var(--gold); }
.podium .medal { font-size: 22px; line-height: 1; }
.podium .nm { font-weight: 700; font-size: 13.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .ct { font-weight: 900; font-size: 20px; color: var(--gold); font-variant-numeric: tabular-nums; }
.podium .block { width: 100%; border-radius: 12px 12px 0 0; background: var(--surface); }
.rank-list { display: grid; gap: 2px; }
.rank { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 12px; }
.rank:active { background: var(--surface); }
.rank .pos { width: 22px; text-align: right; color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.rank .nm { flex: 1; font-weight: 600; min-width: 0; }
.rank .bar { height: 4px; border-radius: 4px; background: var(--purple); margin-top: 5px; opacity: .8; }
.rank .ct { font-weight: 800; font-variant-numeric: tabular-nums; }
.rank.me { background: var(--purple-soft); }

/* ── Profile ───────────────────────────────────── */
.profile-head { display: grid; justify-items: center; gap: 8px; padding: 10px 16px 18px; text-align: center; }
.profile-head h1 { margin: 6px 0 0; font-size: 24px; font-weight: 900; letter-spacing: -0.02em; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; max-width: 360px; margin-top: 8px; }
.stat { background: var(--surface); border-radius: 14px; padding: 10px 6px; }
.stat .v { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 0 3px; }
.grid a { aspect-ratio: 4/5; background: var(--surface); overflow: hidden; border-radius: 6px; }
.grid img { width: 100%; height: 100%; object-fit: cover; }
.profile-tabs { margin: 0 16px 12px; }

/* ── Settings / roster ─────────────────────────── */
.group { background: var(--surface); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); min-height: 54px; }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .sub { color: var(--muted); font-size: 12.5px; }
.row .ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: #34c759; border-color: transparent; }
.switch.on::after { transform: translateX(20px); }
.section-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin: 0 4px 8px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 90;
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px;
  padding: 10px 16px; border-radius: 12px; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: up .2s;
}
