:root {
  --bg: #14121c;
  --surface: #1d1a29;
  --surface-2: #272336;
  --text: #ece9f6;
  --muted: #9a96ad;
  --accent: #b9a2ff;
  --accent-ink: #1a1230;
  --border: #2f2b40;
  --danger: #ff8fa3;
  --boost: #7fe0b0;
  --fav: #ffd27f;
  --tabbar-h: 56px;
  --topbar-h: 48px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f5fc;
    --surface: #ffffff;
    --surface-2: #eeeaf8;
    --text: #1d1a29;
    --muted: #6d6882;
    --accent: #6d4bd6;
    --accent-ink: #ffffff;
    --border: #e1dcf0;
    --danger: #c0334f;
    --boost: #1b8a57;
    --fav: #b87800;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  overscroll-behavior-y: none;
}

[hidden] { display: none !important; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 600;
}

button.link {
  background: none;
  border: 0;
  color: var(--accent);
  padding: 10px 4px;
}

input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  /* 16px+ evita o zoom automático do Safari ao focar */
  font-size: 16px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1.4em; }

/* Login */
#login {
  max-width: 420px;
  margin: 0 auto;
  padding: calc(var(--sat) + 48px) 20px 32px;
}
#login #logo { display: block; margin-bottom: 12px; }
#login h1 { margin: 0 0 4px; color: var(--accent); }
#login form { display: grid; gap: 12px; margin: 20px 0; }
#login details { margin-top: 24px; }
#login summary { color: var(--muted); cursor: pointer; }

/* Estrutura do app */
#app { height: 100%; }

#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + var(--sat));
  padding-top: var(--sat);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
#topbar h2 { margin: 0; font-size: 18px; }
#refresh { background: none; border: 0; font-size: 22px; padding: 8px 12px; }

#view {
  padding: calc(var(--topbar-h) + var(--sat) + 8px) 0 calc(var(--tabbar-h) + var(--sab) + 80px);
}

#tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--sab));
  padding-bottom: var(--sab);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  z-index: 10;
}
#tabs button {
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--muted);
}
#tabs button.active { color: var(--accent); font-weight: 600; }

#fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tabbar-h) + var(--sab) + 16px);
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 24px;
  padding: 0;
  border: 0;
  box-shadow: 0 6px 20px rgb(0 0 0 / .35);
  z-index: 11;
}

/* Publicações */
.status {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.status .boost-note { color: var(--boost); font-size: 13px; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.status header { display: flex; gap: 10px; align-items: center; }
.status img.avatar { width: 44px; height: 44px; border-radius: 10px; flex: none; background: var(--surface-2); }
.status .who { min-width: 0; flex: 1; }
.status .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status .acct, .status time { color: var(--muted); font-size: 13px; }
.status .acct { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.status .body { margin-top: 8px; overflow-wrap: anywhere; }
.status .body p { margin: 0 0 .6em; }
.status .body p:last-child { margin-bottom: 0; }
.status .body a { color: var(--accent); text-decoration: none; }
.status .body a:hover { text-decoration: underline; }
.status .body .invisible { display: none; }
.status .body .ellipsis::after { content: "…"; }
.status .body blockquote { margin: .5em 0; padding-left: 10px; border-left: 3px solid var(--border); color: var(--muted); }
.status .body pre, .status .body code { background: var(--surface-2); border-radius: 6px; }
.status .body pre { padding: 8px; overflow-x: auto; }
.status img.emoji { height: 1.2em; width: auto; vertical-align: -0.25em; }

.status details.cw { margin-top: 8px; }
.status details.cw summary { cursor: pointer; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }

.media { display: grid; gap: 4px; margin-top: 10px; grid-template-columns: 1fr 1fr; }
.media.one { grid-template-columns: 1fr; }
.media img, .media video {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--surface-2);
}
.media.sensitive img, .media.sensitive video { filter: blur(24px); }

.actions { display: flex; gap: 6px; margin-top: 10px; }
.actions button {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.actions button.on.boost { color: var(--boost); }
.actions button.on.fav { color: var(--fav); }

.notif-kind { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.notif-kind strong { color: var(--text); }

.more, .empty { display: block; margin: 16px auto; }
.empty { text-align: center; color: var(--muted); }

.account-card { padding: 20px 16px; display: grid; gap: 12px; }
.account-card img { width: 72px; height: 72px; border-radius: 16px; }

/* Compositor */
dialog#composer {
  width: min(560px, 100%);
  max-width: 100%;
  margin: 0 auto;
  top: 0;
  background: var(--bg);
  color: var(--text);
  border: 0;
  border-radius: 0 0 16px 16px;
  padding: calc(var(--sat) + 8px) 16px 16px;
}
dialog#composer::backdrop { background: rgb(0 0 0 / .55); }
#compose-form { display: grid; gap: 10px; }
.compose-head, .compose-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.compose-foot select { width: auto; }

/* Avisos */
.notif { border-bottom: 1px solid var(--border); }
.notif .status { border-bottom: 0; padding-top: 4px; }
.notif .notif-kind { padding: 12px 16px 0; }
.notif .notif-kind img.emoji { height: 1.1em; vertical-align: -0.2em; }

/* Aviso temporário */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--sab) + 84px);
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 30;
  max-width: 90%;
  box-shadow: 0 6px 20px rgb(0 0 0 / .35);
}

.media.sensitive { overflow: hidden; border-radius: 12px; }

/* ---------- Ícones (Hugeicons) e microanimações ---------- */
.ico { display: block; flex: none; }
#tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; }
#refresh, #fab { display: grid; place-items: center; }
.actions button { display: inline-flex; align-items: center; gap: 6px; }
.actions button:disabled { opacity: .4; }
.actions .open { margin-left: auto; padding: 6px 10px; color: var(--muted); display: grid; place-items: center; }
.with-icon { display: flex; align-items: center; justify-content: center; gap: 8px; }

.actions button.on.fav .ico circle { fill: currentColor; }
.actions button.on.fav .ico path { stroke: var(--bg); stroke-width: 2; }
.actions button.on.boost .ico path { stroke-width: 2.2; }

@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.4); } 100% { transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-16deg); } 75% { transform: rotate(16deg); } }
@keyframes bump { 0% { transform: translateY(0); } 40% { transform: translateY(-4px); } 100% { transform: translateY(0); } }

.fav.pulse .ico { animation: pop .45s ease; }
.boost.pulse .ico { animation: spin .5s ease; }
.reply:active .ico { transform: translateX(-3px); }
#fab:active .ico { animation: wiggle .4s ease; }
#refresh.spinning .ico { animation: spin .9s linear infinite; }
#tabs button.active .ico.bump { animation: bump .4s ease; }

@media (prefers-reduced-motion: reduce) {
  .ico, .ico.bump { animation: none !important; }
}
