:root {
  --bg: #111418;
  --bg2: #1a1f26;
  --bg3: #242b34;
  --fg: #eef1f4;
  --muted: #8b95a1;
  --line: #2c343e;
  --accent: #e53935;
  --ok: #43a047;
  --nav-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
[hidden] { display: none !important; }
h1 { margin: 4px 0; font-size: 32px; }
h2 { font-size: 17px; margin: 18px 0 8px; display: flex; align-items: center; justify-content: space-between; }
a { color: #6cb4ff; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; margin: 8px 0 4px; }
.error { color: #ff6b6b; margin: 10px 0 0; }
.hint { text-align: center; font-size: 13px; padding: 12px 0 0; }

input, select, button { font: inherit; }
input[type=text], input[type=password], input:not([type]), select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--fg); outline: none; margin: 4px 0 10px;
}
input:focus, select:focus { border-color: #4a90e2; }
label { display: block; font-size: 14px; color: var(--muted); }
button {
  border: 0; border-radius: 12px; padding: 12px 16px; background: var(--bg3); color: var(--fg);
  cursor: pointer; user-select: none;
}
button:active { filter: brightness(1.2); }
button.primary { background: #2f6fdb; color: #fff; }
button.danger { background: #7a2020; color: #fff; }
button.small { padding: 6px 12px; font-size: 13px; font-weight: 400; }
button.big { width: 100%; padding: 16px; font-size: 18px; font-weight: 600; margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row input { margin: 0; }

/* telas */
.screen { min-height: 100%; }
#auth { display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-box { width: 100%; max-width: 360px; text-align: center; }
.auth-box .logo { font-size: 56px; }
.auth-box form { margin-top: 20px; text-align: left; }
.auth-box form button { width: 100%; margin-top: 6px; }
.auth-toggle { margin-top: 16px; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; }
.banner { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 10px 16px 0; padding: 10px 12px;
  background: #3a2f12; border: 1px solid #7a6320; border-radius: 12px; font-size: 13px; }
#content { padding: 12px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

/* grid de botões de envio */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.sendbtn { position: relative; min-height: 120px; border-radius: 18px; padding: 14px; color: #fff; text-align: left;
  display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.sendbtn .em { font-size: 34px; line-height: 1; }
.sendbtn .lb { font-size: 17px; font-weight: 700; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.sendbtn .tg { font-size: 12px; opacity: .85; margin-top: 4px; }
.sendbtn.free { background: var(--bg3); color: var(--fg); box-shadow: none; border: 1px dashed var(--line); }
.sendbtn.sending { transform: scale(.96); opacity: .7; }

/* listas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li .grow { flex: 1; min-width: 0; }
.list li .title { font-weight: 600; }
.list li .sub { font-size: 13px; color: var(--muted); }
.list .empty { color: var(--muted); justify-content: center; padding: 24px; border: 0; }
.msg { border-left: 5px solid var(--accent); padding-left: 12px !important; }
.msg .em { font-size: 26px; }
.msg.unseen { background: linear-gradient(90deg, rgba(255,255,255,.05), transparent); }
.msg .seen { font-size: 12px; color: var(--ok); }
.msg .unseen-mark { font-size: 12px; color: var(--muted); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--bg3); display: flex; align-items: center; justify-content: center; font-weight: 700; }

.subtabs { display: flex; gap: 6px; margin-bottom: 6px; }
.subtab { flex: 1; background: var(--bg2); color: var(--muted); }
.subtab.active { background: var(--bg3); color: var(--fg); font-weight: 600; }

.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card-title { font-weight: 700; margin-bottom: 6px; }
.card p { margin: 6px 0 12px; }

/* nav inferior */
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--bg2); border-top: 1px solid var(--line); z-index: 5; }
.nav { flex: 1; background: none; border-radius: 0; color: var(--muted); font-size: 20px; padding: 8px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.nav span { font-size: 11px; }
.nav.active { color: var(--fg); }
.badge { position: absolute; top: 6px; left: calc(50% + 8px); background: var(--accent); color: #fff; font-style: normal; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; display: flex; align-items: center; justify-content: center; }

/* folhas (bottom sheets) */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; background: var(--bg2); border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.close { background: none; font-size: 20px; padding: 4px 8px; color: var(--muted); }
.preview { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 8px 12px; border-radius: 12px; color: #fff; flex: 1; margin-right: 8px; }
.pick-section { font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick input { width: 22px; height: 22px; margin: 0; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatch.on { border-color: #fff; }
.member { display: flex; align-items: center; gap: 10px; padding: 8px 4px; }
.member input { width: 20px; height: 20px; margin: 0; }

/* toast e alerta em tela cheia */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%); background: #2c343e; color: #fff;
  padding: 10px 16px; border-radius: 12px; z-index: 30; box-shadow: 0 4px 16px rgba(0,0,0,.5); max-width: 90vw; text-align: center; }
.alert-overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 24px; animation: flash .6s ease-out; }
@keyframes flash { from { filter: brightness(2); } to { filter: none; } }
.alert-box { width: 100%; max-width: 420px; background: var(--bg2); border-radius: 24px; padding: 28px 22px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.alert-emoji { font-size: 72px; line-height: 1; }
.alert-text { font-size: 28px; font-weight: 800; margin: 12px 0 6px; }
.alert-from { font-size: 15px; }
