:root {
  --bg: #16120c;
  --bg2: #201a11;
  --card: #241d13;
  --card2: #2e2517;
  --line: #3a2f1e;
  --text: #f5ead8;
  --muted: #a89877;
  --amber: #f59e0b;
  --amber2: #fbbf24;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 16px;
  --tabbar-h: calc(60px + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
}
#app { max-width: 560px; margin: 0 auto; padding-bottom: calc(var(--tabbar-h) + 16px); }
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: var(--text); }

/* ---------- barra inferior ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around; align-items: stretch;
  background: rgba(22, 18, 12, .92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom);
  max-width: 560px; margin: 0 auto;
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--muted);
}
.tabbar a .ico { font-size: 22px; line-height: 1; filter: grayscale(1) opacity(.65); }
.tabbar a.active { color: var(--amber2); }
.tabbar a.active .ico { filter: none; }
.tabbar a.tab-waffle .ico { font-size: 26px; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 10px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: linear-gradient(var(--bg) 75%, transparent);
}
.topbar h1 { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.topbar .spacer { flex: 1; }
.chip-streak {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; font-size: 14px; font-weight: 700;
}
.btn-icon { font-size: 20px; padding: 6px; border-radius: 12px; }
.btn-icon:active { background: var(--card2); }

/* ---------- genéricos ---------- */
.screen { padding: 0 16px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--amber); color: #1c1508; font-weight: 700;
  border-radius: 14px; padding: 13px 18px; width: 100%;
  transition: opacity .15s;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.secondary { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; border-radius: 11px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--amber); }
.field textarea { resize: vertical; min-height: 70px; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
.empty .big { font-size: 44px; margin-bottom: 10px; }
.error-text { color: var(--danger); font-size: 14px; margin-top: 8px; min-height: 18px; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--card2); object-fit: cover;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--amber2); font-size: 16px;
  border: 1px solid var(--line); overflow: hidden;
}
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.lg { width: 84px; height: 84px; font-size: 32px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- ecrã auth ---------- */
.auth-wrap { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px; }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo .waffle { font-size: 64px; }
.auth-logo h1 { font-size: 32px; font-weight: 900; letter-spacing: -.5px; }
.auth-logo p { color: var(--muted); margin-top: 4px; }
.auth-tabs { display: flex; background: var(--bg2); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button { flex: 1; padding: 10px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.auth-tabs button.active { background: var(--card2); color: var(--text); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#googleBtn { display: flex; justify-content: center; min-height: 44px; }

/* ---------- filtros feed ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.active { background: var(--amber); color: #1c1508; border-color: var(--amber); }
.seg { display: flex; margin: 0 16px 12px; background: var(--bg2); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; padding: 8px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--card2); color: var(--text); }

/* ---------- cartão waffle ---------- */
.waffle-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 16px 16px; overflow: hidden; }
.waffle-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.waffle-head .who { flex: 1; min-width: 0; }
.waffle-head .who b { display: block; font-size: 15px; }
.waffle-head .who span { font-size: 12px; color: var(--muted); }
.badge-new { font-size: 11px; font-weight: 700; color: var(--amber2); background: rgba(245,158,11,.15); padding: 3px 8px; border-radius: 999px; }
.waffle-video { width: 100%; aspect-ratio: 9/12; max-height: 66vh; background: #000; display: block; object-fit: contain; }
.waffle-caption { padding: 10px 14px 0; font-size: 15px; line-height: 1.4; }
.waffle-actions { display: flex; align-items: center; gap: 4px; padding: 10px 10px 12px; flex-wrap: wrap; }
.react-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 11px; border-radius: 999px; font-size: 15px;
  background: var(--bg2); border: 1px solid var(--line);
}
.react-btn .n { font-size: 13px; color: var(--muted); font-weight: 700; }
.react-btn.mine { background: rgba(245,158,11,.18); border-color: var(--amber); }
.comment-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 14px; color: var(--muted); font-weight: 600; }

/* ---------- círculos ---------- */
.circle-item { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.circle-emoji { font-size: 30px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: var(--bg2); border-radius: 14px; flex-shrink: 0; }
.circle-item b { display: block; font-size: 16px; }
.circle-item .muted { display: block; margin-top: 2px; }
.invite-box { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px dashed var(--amber); border-radius: 14px; padding: 12px 14px; }
.invite-box code { font-size: 22px; font-weight: 800; letter-spacing: 3px; color: var(--amber2); flex: 1; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: none; }
.member-row .grow b { font-size: 15px; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.tag.ok { color: var(--ok); background: rgba(34,197,94,.12); }
.tag.warn { color: var(--amber2); background: rgba(245,158,11,.12); }

/* memórias */
.mem-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mem-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--bg2); }

/* ---------- publicar ---------- */
.video-drop {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 36px 16px; text-align: center; color: var(--muted); background: var(--bg2);
}
.video-drop .big { font-size: 40px; display: block; margin-bottom: 8px; }
#previewVideo { width: 100%; border-radius: var(--radius); background: #000; max-height: 50vh; }
.select-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.progress { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0%; background: var(--amber); transition: width .2s; }
.rec-dot { display: inline-block; width: 10px; height: 10px; background: var(--danger); border-radius: 50%; animation: blink 1s infinite; margin-right: 6px; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- sheet (comentários etc.) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 90; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 91;
  max-width: 560px; margin: 0 auto;
  background: var(--bg2); border-radius: 20px 20px 0 0; border: 1px solid var(--line); border-bottom: none;
  max-height: 82dvh; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  animation: sheet-in .22s ease-out;
}
@keyframes sheet-in { from { transform: translateY(40%); opacity: .4; } }
.sheet-head { display: flex; align-items: center; padding: 14px 16px 8px; }
.sheet-head b { flex: 1; font-size: 16px; }
.sheet-body { overflow-y: auto; padding: 8px 16px; flex: 1; }
.sheet-foot { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.sheet-foot input { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; outline: none; }
.comment { display: flex; gap: 10px; padding: 8px 0; }
.comment .bubble { background: var(--card); border-radius: 14px; padding: 8px 12px; flex: 1; }
.comment .bubble b { font-size: 13px; }
.comment .bubble p { font-size: 14px; margin-top: 2px; word-break: break-word; }
.comment .bubble .muted { font-size: 11px; margin-top: 3px; }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: calc(var(--tabbar-h) + 14px); left: 0; right: 0; z-index: 99; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  animation: toast-in .2s ease-out; max-width: 90%;
}
.toast.err { border-color: var(--danger); color: #fecaca; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--amber); border-radius: 50%; animation: spin .8s linear infinite; margin: 32px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 640px) {
  .tabbar { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
