:root {
  --brand: #ff5a1f;
  --brand-2: #ff2d55;
  --brand-soft: #fff1ea;
  --green: #12b886;
  --green-soft: #e6fcf5;
  --blue: #3b82f6;
  --blue-soft: #eaf2ff;
  --purple: #7c3aed;
  --yellow: #f59f00;
  --red: #e03131;
  --bg: #f5f6fa;
  --card: #ffffff;
  --ink: #141729;
  --ink-2: #4a5068;
  --muted: #8a90a6;
  --line: #e7e9f0;
  --side: #0f1220;
  --side-ink: #c9cde0;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 23, 41, .04), 0 4px 16px rgba(20, 23, 41, .06);
  --grad: linear-gradient(135deg, var(--brand), var(--brand-2));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d17; --card: #151827; --ink: #eef0f8; --ink-2: #b8bdd3; --muted: #7d83a0; --line: #252a40;
    --brand-soft: #2a1a14; --green-soft: #10261f; --blue-soft: #131f36; --side: #070912; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d17; --card: #151827; --ink: #eef0f8; --ink-2: #b8bdd3; --muted: #7d83a0; --line: #252a40;
  --brand-soft: #2a1a14; --green-soft: #10261f; --blue-soft: #131f36; --side: #070912; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
a, button, label, summary, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 700; }
.pre { white-space: pre-wrap; word-break: break-word; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr)); }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side {
  background: var(--side); color: var(--side-ink); padding: 20px 14px; position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 20px; padding: 4px 10px 18px; letter-spacing: -.02em; }
.logo img { width: 34px; height: 34px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-weight: 600; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: rgba(255, 90, 31, .16); color: #fff; }
.nav a.active svg { color: var(--brand); }
.nav svg { width: 20px; height: 20px; flex: none; }
.nav .sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 10px 8px; }
.side-foot { margin-top: auto; padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, .05); }
.side-foot .xpbar { height: 6px; background: rgba(255, 255, 255, .1); border-radius: 9px; overflow: hidden; margin-top: 8px; }
.side-foot .xpbar span { display: block; height: 100%; background: var(--grad); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 14px 28px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.top .title { font-weight: 800; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; }
.scrim { display: none; }
.content { padding: 24px 28px 80px; max-width: 1200px; width: 100%; margin: 0 auto; }
.content.narrow { max-width: 720px; }
.bell { position: relative; }
.bell .dot {
  position: absolute; top: -3px; right: -3px; background: var(--brand-2); color: #fff; font-size: 10px; font-weight: 800;
  min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--bg);
}
.bottom-nav { display: none; }

/* ---------- primitives ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card.flat { box-shadow: none; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); padding: 9px 16px; border-radius: 12px; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  transition: transform .06s, background .15s, border-color .15s, opacity .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 4px 14px rgba(255, 90, 31, .3); }
.btn.green { background: var(--green); color: #fff; border: 0; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.icon { padding: 8px; width: 38px; height: 38px; }
.btn svg { width: 18px; height: 18px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--bg); color: var(--ink-2); border: 1px solid var(--line);
}
.pill.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pill.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.pill.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.tabs::-webkit-scrollbar { display: none; }
.tabs { position: relative; scrollbar-width: none; display: flex; max-width: 100%; gap: 4px; background: var(--card); border: 1px solid var(--line); padding: 4px; border-radius: 14px; overflow-x: auto; }
.tabs a, .tabs button {
  padding: 8px 14px; border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--ink-2); white-space: nowrap;
  border: 0; background: none; font-family: inherit; cursor: pointer;
}
.tabs .active { background: var(--ink); color: var(--card); }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  width: 100%; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255, 90, 31, .15); }
textarea { resize: vertical; min-height: 80px; }
input[type="checkbox"] { width: auto; accent-color: var(--brand); }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; cursor: pointer; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form .grid { gap: 12px; }

.avatar {
  border-radius: 50%; flex: none; object-fit: cover; display: inline-grid; place-items: center; color: #fff; font-weight: 800;
  background: var(--grad); overflow: hidden; position: relative;
}
.avatar.online::after { content: ''; position: absolute; }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar span { display: block; height: 100%; background: var(--grad); border-radius: 99px; transition: width .6s; }
.bar.green span { background: var(--green); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card), var(--line), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- dashboard ---------- */
.hero {
  background: var(--grad); color: #fff; border: 0; position: relative; overflow: hidden;
}
.hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.hero .bar { background: rgba(255, 255, 255, .25); border: 0; }
.hero .bar span { background: #fff; }
.hero .pill { background: rgba(255, 255, 255, .2); color: #fff; border: 0; }
.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 96px; height: 96px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-weight: 800; font-size: 15px; line-height: 1.1; }
.ring .lbl small { display: block; font-size: 10px; color: var(--muted); font-weight: 600; }
.chart { width: 100%; height: 160px; display: flex; gap: 8px; }
.chart .cb { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart .area { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.chart .b { width: 100%; min-height: 1px; border-radius: 5px; background: var(--brand); opacity: .85; }
.chart .b.today { background: var(--brand-2); opacity: 1; }
.chart .v, .chart .d { font-size: 10px; color: var(--muted); line-height: 1.2; white-space: nowrap; }
.insight { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 14px; background: var(--green-soft); }
.insight.down { background: var(--brand-soft); }
.mood { display: flex; gap: 6px; }
.mood button { font-size: 24px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; cursor: pointer; transition: transform .1s; }
@media (hover: hover) { .mood button:hover { transform: scale(1.12); } }
.mood button.sel { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- posts ---------- */
.post { padding: 0; }
.post-h { display: flex; gap: 12px; align-items: center; padding: 16px 18px 10px; }
.post-body { padding: 0 18px 12px; }
.post-img { width: 100%; max-height: 520px; object-fit: cover; background: var(--bg); }
.post.achievement .post-body .pre { font-weight: 700; font-size: 16px; }
.post-actions { display: flex; align-items: center; gap: 4px; padding: 8px 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.react { border: 1px solid transparent; background: none; font: inherit; padding: 6px 10px; border-radius: 10px; cursor: pointer; font-size: 14px; display: inline-flex; gap: 4px; align-items: center; color: var(--ink-2); font-weight: 700; }
.react:hover { background: var(--bg); }
.react.mine { background: var(--brand-soft); border-color: rgba(255, 90, 31, .35); color: var(--brand); }
.react .e { font-size: 17px; transition: transform .15s; }
@media (hover: hover) { .react:hover .e { transform: scale(1.25); } }
.comments { border-top: 1px solid var(--line); padding: 12px 18px; display: flex; flex-direction: column; gap: 10px; background: color-mix(in srgb, var(--bg) 50%, var(--card)); }
.comment { display: flex; gap: 10px; }
.comment .bubble { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; flex: 1; min-width: 0; }
.embed { border: 1px solid var(--line); border-radius: 14px; margin: 0 18px 12px; overflow: hidden; }
.act-box { margin: 0 18px 12px; border-radius: 14px; border: 1px solid var(--line); padding: 14px; background: color-mix(in srgb, var(--brand-soft) 40%, var(--card)); }
.act-stats { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 8px; }
.act-stats .stat b { font-size: 18px; }
.route { width: 100%; height: 180px; border-radius: 12px; background: var(--bg); margin-top: 10px; }
.route path { fill: none; stroke: var(--brand); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.composer textarea { border: 0; padding: 4px 0; min-height: 60px; box-shadow: none !important; font-size: 16px; }
.preview-img { max-height: 200px; border-radius: 12px; margin-top: 8px; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 10; min-width: 150px; padding: 6px; }
.menu-pop button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 14px; cursor: pointer; color: var(--ink); }
.menu-pop button:hover { background: var(--bg); }

/* ---------- challenges / groups ---------- */
.ch-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.ch-cover { height: 110px; position: relative; display: flex; align-items: flex-end; padding: 12px 16px; color: #fff; background-size: cover; background-position: center; }
.ch-cover .icon { font-size: 34px; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25)); }
.ch-cover .pill { position: absolute; top: 12px; right: 12px; background: rgba(0, 0, 0, .35); color: #fff; border: 0; }
.ch-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.m-distance { background: linear-gradient(135deg, #ff7a1a, #ff2d55); }
.m-duration { background: linear-gradient(135deg, #7c3aed, #db2777); }
.m-count { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.m-calories { background: linear-gradient(135deg, #f59f00, #e8590c); }
.m-steps { background: linear-gradient(135deg, #12b886, #0ca678); }
.m-elevation { background: linear-gradient(135deg, #475569, #0f766e); }
.m-active_days { background: linear-gradient(135deg, #e64980, #ff8787); }
.cause { padding: 10px 14px; border-radius: 12px; background: var(--green-soft); color: var(--green); font-weight: 700; font-size: 14px; }
.group-cover { height: 180px; border-radius: var(--radius); background: var(--grad); background-size: cover; background-position: center; position: relative; overflow: hidden; }
.group-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 30%, rgba(0, 0, 0, .6)); }
.group-cover .in { position: absolute; left: 20px; bottom: 16px; right: 20px; color: #fff; z-index: 1; }
.rank { width: 30px; font-weight: 800; text-align: center; color: var(--muted); }
.rank.r1 { color: #f59f00; } .rank.r2 { color: #868e96; } .rank.r3 { color: #c2410c; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 12px; align-items: end; }
.podium .p { min-width: 0; text-align: center; padding: 16px 10px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.podium .p.first { background: var(--grad); color: #fff; border: 0; padding: 24px 10px; }
.podium .p .medal { font-size: 28px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr.me td { background: var(--brand-soft); }
.tbl-wrap { overflow-x: auto; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: min(70vh, 640px); height: min(70dvh, 640px); padding: 0; overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; gap: 8px; max-width: 80%; align-items: flex-end; }
.msg .b { background: var(--bg); border: 1px solid var(--line); padding: 8px 12px; border-radius: 16px 16px 16px 4px; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.mine .b { background: var(--grad); color: #fff; border: 0; border-radius: 16px 16px 4px 16px; }
.msg.mine .b .muted { color: rgba(255, 255, 255, .75); }
.msg.sys { align-self: center; max-width: 100%; }
.msg.sys .b { background: none; border: 0; color: var(--muted); font-size: 13px; padding: 2px; }
.msg img { border-radius: 10px; max-height: 220px; margin-top: 4px; }
.chat-in { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: center; }
.typing { font-size: 12px; color: var(--muted); padding: 0 16px 6px; min-height: 18px; }

/* ---------- connectors ---------- */
.conn { display: flex; flex-direction: column; gap: 10px; }
.conn-h { display: flex; align-items: center; gap: 12px; }
.conn-logo { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; flex: none; }
.conn.on { border-color: color-mix(in srgb, var(--green) 50%, var(--line)); }
.conn.off { opacity: .55; filter: grayscale(1); pointer-events: none; }
.howto { font-size: 13px; color: var(--ink-2); background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12.5px; background: #0f1220; color: #d7dcf0; padding: 12px 14px; border-radius: 12px; overflow-x: auto; white-space: pre; }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 24px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- badges ---------- */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.badge { text-align: center; padding: 14px 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }
.badge .i { font-size: 32px; }
.badge.locked { opacity: .4; filter: grayscale(1); }
.badge b { display: block; font-size: 13px; margin-top: 4px; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(8, 10, 20, .55); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .15s; backdrop-filter: blur(3px); }
.modal { background: var(--card); border-radius: 20px; width: min(560px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); animation: pop .18s; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.modal-b { padding: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }
.toast { background: var(--ink); color: var(--card); padding: 12px 16px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-weight: 600; font-size: 14px; animation: pop .2s; cursor: pointer; }
.toast.err { background: var(--red); color: #fff; }
.toast.ok { background: var(--green); color: #fff; }
.celebrate { position: fixed; inset: 0; pointer-events: none; z-index: 300; overflow: hidden; }
.celebrate i { position: absolute; top: -20px; font-style: normal; font-size: 22px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: .6; } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: var(--side); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::before { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: var(--grad); filter: blur(90px); opacity: .45; right: -160px; bottom: -160px; }
.auth-art > * { position: relative; }
.auth-art h1 { font-size: 46px; line-height: 1.05; letter-spacing: -.03em; max-width: 520px; }
.auth-art .feat { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 520px; }
.auth-art .feat div { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); border-radius: 14px; padding: 14px; font-size: 14px; color: var(--side-ink); }
.auth-art .feat b { display: block; color: #fff; margin-bottom: 2px; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-form .card { width: min(420px, 100%); padding: 28px; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; left: 0; top: 0; z-index: 90; width: min(280px, 85vw); transform: translateX(-100%); transition: transform .2s;
    padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: calc(14px + env(safe-area-inset-bottom)); overscroll-behavior: contain;
  }
  .side.open { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .5); }
  .side.open + .scrim { display: block; position: fixed; inset: 0; z-index: 85; background: rgba(8, 10, 20, .5); animation: fade .15s; }
  .menu-btn { display: inline-flex; }
  .top { padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); gap: 8px; }
  .top .title { font-size: 17px; }
  .content { padding: 16px max(16px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .modal .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-h { flex-wrap: wrap; }
  .card-h > .row { flex-wrap: wrap; }
  .pill { white-space: nowrap; }
  /* iOS zooms into any focused field under 16px */
  input, select, textarea { font-size: 16px; }
  /* wrapped header rows: let action buttons drop to a new line instead of squeezing the text column */
  .between.wrap > .row { flex-wrap: wrap; }
  .row.wrap > .grow { flex-basis: 220px; }
  .group-cover { height: auto; min-height: 180px; display: flex; align-items: flex-end; }
  .group-cover .in { position: relative; left: auto; right: auto; bottom: auto; padding: 56px 16px 16px; width: 100%; }
  .chat { height: calc(100vh - 150px); height: calc(100dvh - 150px); min-height: 360px; max-height: 640px; }
  .msg { max-width: 88%; }
  table.t th, table.t td { padding: 8px; }
  /* modals become bottom sheets */
  .modal-bg { place-items: end center; padding: 0; }
  .modal { width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); animation: sheet .22s ease-out; }
  .modal-h { padding: 14px 16px; }
  .modal-b { padding: 16px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line);
    justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  /* the on-screen keyboard pushes fixed elements up on Android - hide the tab bar while typing */
  body:has(:is(input:not([type="checkbox"]):not([type="file"]), textarea):focus) .bottom-nav { display: none; }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 8px; gap: 2px; }
  .bottom-nav a.active { color: var(--brand); }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav .plus { background: var(--grad); color: #fff; border-radius: 16px; padding: 8px 14px; margin-top: -2px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 32px 24px; gap: 24px; }
  .auth-art h1 { font-size: 32px; }
  .auth-art .feat { display: none; }
  .auth-form { padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
  .hide-m { display: none !important; }
  #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); right: 12px; left: 12px; max-width: none; align-items: flex-end; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
@media (max-width: 560px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-art .feat { grid-template-columns: 1fr; }
  .podium { gap: 6px; }
  .podium .p { padding: 12px 6px; }
  .podium .p.first { padding: 18px 6px; }
  h1 { font-size: 22px; }
  .card { padding: 16px; }
  .auth-form .card { padding: 22px 18px; }
  .post-h { padding: 14px 14px 10px; }
  .post-body { padding: 0 14px 12px; }
  .embed, .act-box { margin-left: 14px; margin-right: 14px; }
  .comments { padding: 12px 14px; }
  .act-stats { gap: 16px; }
  .stat b { font-size: 19px; }
  /* list rows with several buttons: buttons wrap under the text rather than crushing it */
  .list-item { flex-wrap: wrap; }
  .list-item > .grow { flex-basis: 140px; }
  .list-item > .row:last-child { margin-left: auto; }
  .chart { gap: 4px; }
  .chart.dense .v { display: none; }
}

/* dashboard two-column layout */
.dash { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1080px) { .dash { grid-template-columns: minmax(0, 1fr); } }
