:root {
  --brand: #4e0d0d; --accent: #7a1d1d; --accent-fg: #fff;
  --bg: #f2f2f7; --card: #fff; --text: #111; --muted: #6b6b73; --line: #e3e3e8; --field: #f2f2f7;
  --ok: #1f9d55; --warn: #e8830c; --bad: #d33; --info: #2f6fed; --purple: #8a4fd6; --teal: #12a8a0; --gray: #8e8e93;
  --tab-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --text: #f2f2f2; --muted: #9a9aa2; --line: #2c2c2e; --field: #2c2c2e; --accent: #b04a4a; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; }
body { padding-bottom: calc(var(--tab-h) + var(--safe-b)); min-height: 100vh; }
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
img, video { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* topo */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: calc(10px + var(--safe-t)) 16px 8px; display: flex; align-items: center; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 14px 5px 5px; max-width: 78%; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.me-t { min-width: 0; text-align: left; line-height: 1.15; }
.me-t b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-t small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.top .sp { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }
h1.title { font-size: 32px; font-weight: 800; padding: 4px 16px 10px; letter-spacing: -.5px; }
main { padding: 0 16px 24px; max-width: 760px; margin: 0 auto; }

/* abas */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); height: calc(var(--tab-h) + var(--safe-b)); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; min-width: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font-size: 10.5px; position: relative; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--accent); font-weight: 700; }
.badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

/* componentes */
.card { background: var(--card); border-radius: 16px; padding: 14px; }
.list > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--card); border-radius: 14px; width: 100%; text-align: left; border: 0; }
.row .grow { flex: 1; min-width: 0; }
.row b { display: block; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--c, var(--gray)) 16%, transparent); color: var(--c, var(--gray)); white-space: nowrap; }
.thumb { width: 56px; height: 56px; border-radius: 10px; background: var(--field); object-fit: cover; flex: none; display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.fmt { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff; flex: none; background: var(--c); }
.fmt svg { width: 20px; height: 20px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.cr { background: var(--card); border-radius: 16px; padding: 10px; border: 0; text-align: left; }
.cr .im { aspect-ratio: 1; border-radius: 11px; overflow: hidden; background: var(--field); }
.cr .im img { width: 100%; height: 100%; object-fit: cover; }
.cr b { display: block; margin: 8px 0 2px; font-size: 14.5px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; background: var(--accent); color: var(--accent-fg); }
.btn.sec { background: var(--field); color: var(--text); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .45; }
.btns { display: flex; gap: 10px; } .btns > * { flex: 1; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--field); border: 1px solid transparent; border-radius: 11px; padding: 11px 12px; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 12px 0 4px; }
.cap { font-size: 11.5px; font-weight: 800; letter-spacing: .5px; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
.seg { display: flex; background: var(--field); border-radius: 11px; padding: 3px; margin-bottom: 8px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.nav { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 10px; }
.nav h3 { font-size: 17px; text-align: center; }
.nav button.link { background: none; border: 0; color: var(--info); font-size: 12px; display: block; margin: 2px auto 0; }

/* telas */
.login { min-height: 100vh; display: grid; place-content: center; gap: 12px; padding: 32px; max-width: 380px; margin: 0 auto; text-align: center; }
.login img { width: 96px; margin: 0 auto; border-radius: 22px; }
.login h1 { font-size: 30px; }
.err { color: var(--bad); font-size: 14px; }

/* sheet */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 94vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 0 16px calc(24px + var(--safe-b)); animation: up .22s ease; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-h { position: sticky; top: 0; background: var(--bg); display: flex; align-items: center; justify-content: space-between; padding: 14px 0 10px; z-index: 2; }
.sheet-h h3 { font-size: 17px; }
.hero { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 16px; background: var(--field); }
.stack > * + * { margin-top: 14px; }
.stack > .btn, .stack > label.btn { display: block; width: 100%; text-align: center; }
.steps { display: flex; gap: 4px; } .steps div { flex: 1; text-align: center; font-size: 10px; color: var(--muted); }
.steps i { display: block; height: 6px; border-radius: 3px; background: var(--line); margin-bottom: 4px; } .steps .on i { background: var(--c); } .steps .cur { color: var(--text); font-weight: 700; }
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: 14px; gap: 0; scrollbar-width: none; position: relative; }
.carousel::-webkit-scrollbar { display: none; }
.carousel > * { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 1; object-fit: cover; background: var(--field); }
.counter { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.wrap-rel { position: relative; }
video.ex { width: 100%; max-height: 460px; background: #000; border-radius: 14px; }
.comment { padding: 10px 12px; border-radius: 12px; background: var(--card); } .comment.me { background: color-mix(in srgb, var(--info) 10%, var(--card)); }
.comment b { font-size: 12px; display: block; margin-bottom: 2px; }
.callout { padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--c, var(--info)) 12%, transparent); }
.md h4 { font-size: 14.5px; margin: 10px 0 2px; } .md p { margin: 3px 0; font-size: 14.5px; }

/* calendário */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal .h { font-size: 12px; font-weight: 800; color: var(--muted); padding: 6px 0; }
.cal button { border: 0; background: none; border-radius: 10px; padding: 6px 0 4px; min-height: 52px; }
.cal button.sel { background: color-mix(in srgb, var(--info) 12%, transparent); }
.cal .d { display: grid; place-items: center; width: 28px; height: 28px; margin: 0 auto; border-radius: 50%; font-size: 14px; }
.cal .today .d { background: var(--info); color: #fff; font-weight: 700; }
.dots { display: flex; justify-content: center; gap: 3px; height: 7px; margin-top: 3px; } .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.day-h { font-size: 13px; font-weight: 700; color: var(--muted); padding: 14px 4px 6px; display: flex; gap: 8px; align-items: center; } .day-h.today { color: var(--info); }
.tag { font-size: 10px; background: var(--info); color: #fff; padding: 2px 6px; border-radius: 999px; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; } .totals b { display: block; font-size: 15px; }
.pix { font: 12px ui-monospace, Menlo, monospace; word-break: break-all; background: var(--field); padding: 12px; border-radius: 12px; }
.qr { width: 200px; height: 200px; margin: 0 auto; image-rendering: pixelated; background: #fff; border-radius: 8px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); transform: translateX(-50%) translateY(20px); z-index: 99; background: #222; color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; }
#toast.on { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--bad); }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: s 0.8s linear infinite; margin: 30px auto; }
@keyframes s { to { transform: rotate(360deg); } }
