:root {
  --bg: #060607; --pan: #0E0E11; --raised: #141418; --raised2: #1A1A1F; --line: rgba(255,255,255,.07); --line2: rgba(255,255,255,.12);
  --text: #ECEBE7; --hi: #F6F5F1; --t2: #C9C7C1; --muted: #8B8B91; --faint: #66666C;
  --gold: #C9B37E; --gold-soft: rgba(201,179,126,.14); --gold-line: rgba(201,179,126,.32);
  --ok: #5FB98A; --bad: #E5484D;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 Inter, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif; overscroll-behavior: none; }
body { background: radial-gradient(900px 500px at 10% -10%, rgba(201,179,126,.06), transparent 60%), var(--bg); }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.inp { width: 100%; height: 46px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(255,255,255,.03); outline: none; font-size: 16px; }
.inp:focus { border-color: var(--gold-line); box-shadow: 0 0 0 3px var(--gold-soft); }
.btn { height: 46px; padding: 0 22px; border-radius: 999px; border: 1px solid var(--line2); background: rgba(255,255,255,.03); font-weight: 600; }
.btn.gold { border: 0; background: linear-gradient(180deg, #F3F0E8, #D6CFBF); color: #111; box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 8px 20px rgba(0,0,0,.4); }
.btn.small { height: 34px; padding: 0 14px; font-size: 13px; }
.btn.danger { color: #F0A39B; border-color: rgba(229,72,77,.4); }
.err { color: #F0A39B; font-size: 13.5px; margin: 0; text-align: center; }

/* entrada */
.login { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: calc(30px + var(--safe-t)) 20px calc(30px + var(--safe-b)); }
.lg-brand { display: flex; align-items: center; gap: 14px; }
.lg-brand img { width: 54px; }
.lg-brand b { display: block; font-size: 15px; letter-spacing: .32em; }
.lg-brand span { font-size: 11px; letter-spacing: .3em; color: var(--muted); }
.lg-correia { width: 170px; opacity: .9; }
.lg-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; padding: 18px; border-radius: 22px; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(255,255,255,.025), transparent 120px), var(--pan); }
.lg-pane p { margin: 0 0 12px; font-size: 14px; color: var(--t2); line-height: 1.5; }
.inp.code { text-align: center; font-size: 26px; letter-spacing: .4em; font-weight: 700; height: 58px; }
.lg-foot { max-width: 420px; text-align: center; font-size: 12.5px; color: var(--muted); margin: 0; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(0,0,0,.35); border: 1px solid var(--line); }
.seg button { flex: 1; height: 38px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg button.on { background: linear-gradient(180deg, var(--raised2), #202026); color: var(--hi); box-shadow: 0 0 0 1px var(--gold-line) inset; }

/* app */
.app { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: calc(10px + var(--safe-t)) 16px 10px; border-bottom: 1px solid var(--line); background: rgba(10,10,12,.85); backdrop-filter: blur(12px); }
.top-mark { width: 30px; }
.top-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top-t b { font-size: 17px; }
.top-t span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me { width: 38px; height: 38px; border-radius: 30%; border: 0; padding: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff; }
.me img, .av img { width: 100%; height: 100%; object-fit: cover; }
.tabs { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.tab { padding: 10px 12px 24px; }
.cat { margin: 14px 4px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: color-mix(in srgb, var(--gold) 60%, var(--muted)); }
.row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 8px 12px; border: 0; border-radius: 14px; background: transparent; text-align: left; color: var(--t2); }
.row:active { background: var(--raised); }
.row .ico { width: 22px; text-align: center; color: var(--faint); font-weight: 700; }
.row .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15.5px; }
.row.unread .nm { color: var(--hi); font-weight: 700; }
.row .cnt { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--gold); color: #111; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.row .sub { font-size: 12px; color: var(--muted); }
.room { margin: 6px 0; border-radius: 16px; border: 1px solid var(--line); background: rgba(255,255,255,.015); }
.room.here { border-color: var(--gold-line); background: linear-gradient(180deg, var(--gold-soft), transparent 70%); }
.room .people { padding: 0 12px 10px 46px; display: flex; flex-direction: column; gap: 6px; }
.pp { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--t2); }
.av { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 30%; overflow: hidden; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 10px; font-weight: 700; }
.av.big { width: 40px; height: 40px; flex-basis: 40px; font-size: 13px; }
.flag { font-size: 12px; color: #F08A8A; }
.live { font-size: 9px; font-weight: 800; padding: 2px 6px; border-radius: 4px; background: var(--bad); color: #fff; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); line-height: 1.6; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: 0 0 9px; }
.dot.on { background: var(--ok); }

/* barra da voz */
.vbar { display: flex; align-items: center; gap: 10px; margin: 0 10px 8px; padding: 10px 12px; border-radius: 18px; border: 1px solid var(--gold-line); background: linear-gradient(180deg, rgba(201,179,126,.12), rgba(20,20,24,.95)); }
.vbar .vt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vbar .vt b { font-size: 14px; } .vbar .vt span { font-size: 12px; color: var(--muted); }
.cbtn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line2); background: rgba(255,255,255,.04); display: flex; align-items: center; justify-content: center; }
.cbtn.off { color: #F0A39B; border-color: rgba(229,72,77,.45); background: rgba(229,72,77,.12); }
.cbtn.leave { color: #fff; background: #C93C40; border-color: #C93C40; }

/* navegação */
.nav { display: flex; padding: 6px 8px calc(6px + var(--safe-b)); border-top: 1px solid var(--line); background: rgba(10,10,12,.92); backdrop-filter: blur(12px); }
.nav button { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; }
.nav button.on { color: var(--gold); }
.nav i { position: absolute; top: 2px; left: calc(50% + 8px); width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }

/* conversa */
.chat { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--bg); }
.ch-top { display: flex; align-items: center; gap: 6px; padding: calc(8px + var(--safe-t)) 10px 8px; border-bottom: 1px solid var(--line); background: rgba(10,10,12,.9); }
.back { width: 42px; height: 42px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; }
.ch-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-t b { font-size: 16.5px; } .ch-t span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 2px; -webkit-overflow-scrolling: touch; }
.day { align-self: center; margin: 12px 0 6px; font-size: 11px; letter-spacing: .14em; color: var(--faint); text-transform: uppercase; }
.m { display: flex; gap: 10px; padding: 4px 2px; }
.m.cont { padding-top: 0; }
.m.cont .av { visibility: hidden; height: 0; }
.mb { flex: 1; min-width: 0; }
.mh { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.mh b { font-size: 14.5px; } .mh .bot { font-size: 9px; font-weight: 800; padding: 1px 5px; border-radius: 4px; background: var(--raised2); color: var(--muted); }
.mh time { font-size: 11px; color: var(--faint); }
.mt { font-size: 15px; color: var(--t2); white-space: pre-wrap; overflow-wrap: anywhere; }
.mt a, .card a.link { color: var(--gold); }
.mimg { display: block; max-width: min(100%, 320px); max-height: 360px; margin-top: 6px; border-radius: 14px; }
.card { margin-top: 6px; border-radius: 16px; border: 1px solid var(--line2); background: var(--raised); overflow: hidden; }
.card .ci { height: 160px; background: #111 center/cover; }
.card .cb { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.card .ck { font-size: 10px; font-weight: 800; letter-spacing: .14em; color: var(--gold); }
.card b { font-size: 15px; color: var(--hi); }
.card p { margin: 0; font-size: 13px; color: var(--t2); }
.card .btn { align-self: flex-start; height: 36px; display: inline-flex; align-items: center; text-decoration: none; font-size: 13px; }
.composer { display: flex; align-items: center; gap: 8px; padding: 8px 10px calc(8px + var(--safe-b)); border-top: 1px solid var(--line); background: rgba(10,10,12,.92); }
.composer .inp { height: 44px; }
.att, .send { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; border: 1px solid var(--line2); background: rgba(255,255,255,.03); display: flex; align-items: center; justify-content: center; }
.send { border: 0; background: var(--gold); color: #111; }
.readonly { padding: 14px 16px calc(14px + var(--safe-b)); text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

/* voz */
.vz-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 4px 12px; }
.vz-head b { font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; border-radius: 18px; border: 1px solid var(--line); background: rgba(255,255,255,.02); font-size: 13px; text-align: center; }
.tile .av { width: 54px; height: 54px; flex-basis: 54px; font-size: 16px; }
.tile.speak .av { box-shadow: 0 0 0 3px var(--ok); }
.tile .sh { font-size: 11px; color: var(--gold); }
.shares { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.share { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 16px; border: 1px solid var(--gold-line); background: var(--gold-soft); }
.share span { flex: 1; font-size: 14px; }

/* ver ecrã */
.viewer { position: fixed; inset: 0; z-index: 40; background: #000; display: flex; align-items: center; justify-content: center; }
.viewer video { width: 100%; height: 100%; object-fit: contain; }
.vw-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 14px 10px; background: linear-gradient(180deg, rgba(0,0,0,.7), transparent); }
.vw-top b { flex: 1; }
.vw-wait { position: absolute; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 60; max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 14px; background: #1C1C21; border: 1px solid var(--line2); font-size: 13.5px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }

.mic-help { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; padding: 12px 12px calc(12px + var(--safe-b)); }
.mh-card { width: 100%; padding: 18px; border-radius: 22px; background: var(--pan); border: 1px solid var(--gold-line); display: flex; flex-direction: column; gap: 10px; }
.mh-card b { font-size: 17px; } .mh-card p { margin: 0; font-size: 14px; color: var(--t2); } .mh-card .muted { color: var(--faint); font-size: 12px; }
.mh-card ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.5; }

.mrx { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.mrx span { font-size: 14px; padding: 2px 8px; border-radius: 8px; background: rgba(255,255,255,.07); }
.mrx b { font-size: 12px; color: #B5B8BE; }
