/*
 * Munch UI layer — shared primitives (card, chip, list-row, hero-number,
 * cover, carousel, avatar-stack, sheet, stories) and the app shell.
 * Loaded after application.css, so rules here win on equal specificity.
 */

/* ---------- Shell ---------- */
.app-main { --gutter: 20px; }
@media (max-width: 390px) { .app-main { --gutter: 15px; } }
@media (min-width: 800px) { .app-main { --gutter: 24px; } }
.app-header {
  background: var(--bg);
  border-bottom-color: transparent;
  padding-top: env(safe-area-inset-top);
}
.app-header__inner { min-height: 62px; padding: 8px 16px; }
.brand-lockup--compact .brand-mark { width: 44px; height: 33px; }
.group-switcher > .current-group {
  padding: 8px 12px 8px 14px;
  border-radius: var(--r-control);
  background: var(--surface-3);
  color: var(--text);
  transition: background var(--dur-fast) ease;
}
.group-switcher > .current-group:hover,
.group-switcher[open] > .current-group { background: var(--surface-hover); }
.group-switcher__menu { border: 0; border-radius: var(--r-md); background: var(--surface-2); box-shadow: var(--shadow-2); }
.group-switcher__option { text-align: left; }
.group-switcher__option.is-current { background: var(--orange); color: var(--on-accent); }
.header-notifications__label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.header-notifications {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: var(--r-control); background: var(--surface-3); color: var(--text);
}
.header-notifications:hover { background: var(--surface-hover); }
.header-notifications__badge { background: var(--orange); color: var(--on-accent); }

/* Bottom nav: round outlined buttons; active and "+" in solid orange. */
.bottom-nav {
  background: var(--bg);
  border-top: 0;
  box-shadow: 0 -1px 0 var(--line);
}
.bottom-nav__item { color: var(--muted); touch-action: manipulation; }
.bottom-nav__item .nav-icon { display: grid; place-items: center; width: 46px; height: 46px; border: 2px solid var(--line); border-radius: var(--r-control); color: var(--text); }
.bottom-nav__item.is-active { color: var(--orange); }
.bottom-nav__item.is-active .nav-icon { border-color: var(--orange); background: var(--orange); color: var(--on-accent); }
.bottom-nav__item--create .nav-icon { border-color: var(--orange); border-radius: var(--r-control); background: var(--orange); color: var(--on-accent); }
.bottom-nav__item--create:hover .nav-icon, .bottom-nav__item--create:focus-visible .nav-icon { background: var(--orange-hover); }

/* Legal links live in Perfil → Sobre once you are inside the app. */
.has-bottom-nav .legal-footer { display: none; }

/* ---------- Motion ---------- */
@view-transition { navigation: auto; }
/* Troca de tela: só um cruzamento curto de opacidade, sem a tela nova subir. */
::view-transition-old(root) { animation: tide-out var(--t-state) ease both; }
::view-transition-new(root) { animation: tide-in var(--t-state) ease both; }
@keyframes tide-in { from { opacity: 0; } }
@keyframes tide-out { to { opacity: 0; } }
/* Cabeçalho e barra ficam parados na troca de tela; só o conteúdo faz a maré. */
.bottom-nav { view-transition-name: bottom-nav; }
.app-header { view-transition-name: app-header; }
::view-transition-group(app-header), ::view-transition-group(bottom-nav) { animation: none; }
.pressable { transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) ease; }
.pressable:active { transform: scale(.97); }
/* Gota no toque (press_controller): círculo curto na cor do texto. */
.has-drop { position: relative; overflow: hidden; }
.drop { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: currentColor; opacity: .18; pointer-events: none; animation: drop 600ms var(--ease) forwards; }
@keyframes drop { to { transform: scale(26); opacity: 0; } }
/* Botão redondo contornado: ação secundária em todo o app (voltar, fechar, ±). */
.round { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1.5px solid var(--line); border-radius: var(--r-control); background: transparent; color: var(--text); transition: transform var(--t-press), background var(--t-state), border-color var(--t-state); }
.round:hover { border-color: var(--line-strong); }
.round:active { transform: scale(.92); }
.round--sm { width: 40px; height: 40px; }
.round--solid { background: var(--c-you); border-color: var(--c-you); color: var(--on-color); }
.round--done, .round:disabled { background: var(--c-win); border-color: var(--c-win); color: var(--on-color); cursor: default; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  button:active:not(:disabled),
  input[type="submit"]:active:not(:disabled),
  .button:active:not([aria-disabled="true"]),
  .pressable:active { transform: none; }
}

/* ---------- Typography helpers ---------- */
.eyebrow {
  margin: 0 0 var(--s-1);
  color: var(--accent-text);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.screen-title { margin: var(--s-2) 0 var(--s-1); font-size: clamp(2.1rem, 9vw, 3rem); }
.screen-subtitle { margin: 0 0 var(--s-6); color: var(--muted); }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3);
  margin: var(--s-7) 0 var(--s-3);
}
.section-title h2 { margin: 0; font-size: 1.45rem; }
.section-title a { color: var(--muted); font-size: .85rem; font-weight: 800; white-space: nowrap; }
.section-title a:hover { color: var(--accent-text); }

/* Product mentions link to the Bite plan without changing button treatments. */
.bite-inline-link { color: var(--bite-hover); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.bite-inline-link:hover, .bite-inline-link:focus-visible { color: #72bce4; }

/* ---------- Buttons ---------- */
/* Buttons are pills: solid orange for the main action, outlined orange for secondary. */
.button { border-radius: var(--r-control); font-weight: 700; }
.button--orange { background: var(--orange); color: var(--on-accent); }
.button--orange:hover { background: var(--orange-hover); }
.button--secondary, .button--outline, .button--dark, .button--light { border: 2px solid var(--orange); background: transparent; color: var(--orange); }
.button--secondary:hover, .button--outline:hover, .button--dark:hover, .button--light:hover { background: color-mix(in srgb, var(--orange) 10%, transparent); }
.button--ink { border: 0; background: var(--on-accent); color: var(--text); }
.button--ghost { background: transparent; color: var(--text); }
.button--ghost:hover { background: var(--surface-2); }
.button--blue, .button--bite { background: var(--bite); color: #fff; }
.button--blue:hover, .button--bite:hover { background: var(--bite-hover); box-shadow: none; }
.button--orange:hover { box-shadow: none; }
.button--pill { border-radius: var(--r-control); }
.icon-button {
  display: inline-grid; place-items: center; flex: none;
  width: 42px; height: 42px; padding: 0;
  border: 0; border-radius: var(--r-control);
  background: var(--surface-2); color: var(--text);
  transition: background var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out);
}
.icon-button:hover { background: var(--surface-3); }
.icon-button .ui-icon { width: 20px; height: 20px; }
.icon-button--plain { background: transparent; }
.icon-button--sm { width: 34px; height: 34px; }
.icon-button--sm .ui-icon { width: 17px; height: 17px; }

/* ---------- Card ---------- */
.card {
  position: relative;
  padding: var(--s-5);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.card--flush { padding: 0; overflow: hidden; }
.card--link { display: block; color: inherit; transition: background var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out); }
.card--link:hover { background: var(--surface-3); }
.card--link:active { transform: scale(.985); }
.card--orange { background: var(--orange); color: var(--ink); }
.card--yellow { background: var(--yellow); color: var(--ink); }
.card + .card { margin-top: var(--s-3); }

/* ---------- Chips ---------- */
.chip-row { display: flex; gap: var(--s-2); overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter, 16px) * -1); padding: 2px var(--gutter, 16px); }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 38px; padding: 7px 16px;
  border: 0; border-radius: var(--r-control);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: .9rem; font-weight: 700; white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.chip:hover { background: var(--surface-3); }
.chip.is-active, .chip--active, .chip[aria-current="page"], .chip[aria-pressed="true"],
input:checked + .chip { background: var(--orange); color: var(--ink); }
.chip .ui-icon { width: 16px; height: 16px; }
/* Tamanho mínimo: herdava width: 100% dos inputs e, absoluto, passava da borda criando rolagem horizontal. */
.chip-input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.chip-input:focus-visible + .chip { outline: 3px solid var(--orange); outline-offset: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: var(--r-control);
  background: var(--surface-3); color: var(--text);
  font-size: .74rem; font-weight: 800; line-height: 1.6;
}
.badge--orange { background: #ff6a0024; color: var(--accent-text); }
.badge--yellow { background: #ffc43d24; color: var(--yellow); }
.badge--bite { background: var(--bite); color: #fff; }
.badge--success { background: #5ed39a22; color: var(--success); }

/* ---------- Avatars ---------- */
.avatar {
  display: grid; place-items: center; flex: none; overflow: hidden;
  width: var(--avatar-size, 40px); height: var(--avatar-size, 40px);
  border-radius: 50%;
  background: var(--orange); color: var(--ink);
  font-weight: 800; font-size: calc(var(--avatar-size, 40px) * .42);
  line-height: 1;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { --avatar-size: 28px; }
.avatar--lg { --avatar-size: 64px; }
.avatar--xl { --avatar-size: 92px; }
.avatar--yellow { background: var(--yellow); }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar { box-shadow: 0 0 0 3px var(--avatar-ring, var(--bg)); }
.avatar-stack .avatar + .avatar { margin-left: calc(var(--avatar-size, 40px) * -.32); }
.avatar-stack__more { background: var(--surface-3); color: var(--text); }

/* ---------- List rows (Nubank-style) ---------- */
.list { display: grid; border-radius: var(--r-lg); background: var(--surface-2); overflow: hidden; }
.list--plain { background: transparent; border-radius: 0; }
.list-row {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; min-height: 64px; padding: var(--s-3) var(--s-4);
  border: 0; background: transparent; color: inherit; font: inherit; text-align: left;
}
.list > .list-row + .list-row, .list > * + * > .list-row { box-shadow: inset 0 1px 0 #ffffff0f; }
a.list-row, button.list-row, .list-row--link { transition: background var(--dur-fast) ease; cursor: pointer; }
a.list-row:hover, button.list-row:hover, .list-row--link:hover { background: #ffffff08; }
.list--plain .list-row { padding-inline: 0; }
.list-row__lead { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--surface-3); color: var(--accent-text); }
.list-row__lead .ui-icon { width: 20px; height: 20px; }
.list-row__body { flex: 1; min-width: 0; display: grid; gap: 1px; }
.list-row__title { font-weight: 800; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row__meta { color: var(--muted); font-size: .82rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row__value { flex: none; font-weight: 800; text-align: right; }
.list-row__value small { display: block; color: var(--muted); font-weight: 700; }
.list-row__chevron { display: grid; place-items: center; flex: none; color: var(--text-subtle); width: 18px; height: 18px; }
.list-row__chevron .ui-icon { width: 18px; height: 18px; }
.list-row--danger { color: var(--danger); }
.list-row--danger .list-row__lead { color: var(--danger); }
.list-row form { margin: 0; }
.list-row--me { background: #ff6a0014; }

/* ---------- Hero numbers ---------- */
.hero-number { display: grid; gap: 2px; }
.hero-number__value {
  font-family: var(--font-display); font-size: clamp(2.6rem, 13vw, 4.2rem);
  line-height: .95; letter-spacing: -.02em; color: var(--text);
}
.hero-number__value--orange { color: var(--orange); }
.hero-number__value--yellow { color: var(--yellow); }
.hero-number__label { color: var(--muted); font-size: .9rem; font-weight: 700; }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: var(--s-2); }
.stat-strip > div { min-width: 0; padding: var(--s-4) var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.stat-strip strong { display: block; font-family: var(--font-display); font-size: 1.9rem; font-weight: 400; line-height: 1; }
.stat-strip span { color: var(--muted); font-size: .8rem; font-weight: 700; }

/* ---------- Covers ---------- */
.cover {
  position: relative; display: grid; place-items: center; flex: none; overflow: hidden;
  width: var(--cover-w, 72px); aspect-ratio: 2 / 3; height: auto;
  --cover-radius: var(--r-sm); border-radius: var(--cover-radius);
  background: linear-gradient(135deg, var(--surface-3), var(--surface-2));
  color: var(--muted);
  object-fit: cover;
}
img.cover { display: block; }
.cover--xs { --cover-w: 40px; --cover-radius: 6px; border-radius: var(--cover-radius); }
.cover--sm { --cover-w: 56px; --cover-radius: 8px; border-radius: var(--cover-radius); }
.cover--md { --cover-w: 96px; }
.cover--lg { --cover-w: 140px; --cover-radius: var(--r-sm); border-radius: var(--cover-radius); }
.cover--xl { --cover-w: min(220px, 56vw); --cover-radius: var(--r-sm); border-radius: var(--cover-radius); }
.cover--fluid { --cover-w: 100%; }
.cover.media-cover--empty { border: 0; }
.cover .ui-icon { width: 36%; height: auto; }
.cover-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.cover-grid > * { min-width: 0; }
.cover-tile { display: grid; gap: 6px; color: inherit; }
.cover-tile .cover { --cover-w: 100%; }
.cover-tile__title { font-size: .82rem; font-weight: 700; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cover-tile__meta { color: var(--muted); font-size: .74rem; font-weight: 700; }

/* Blurred cover behind a hero (Spotify-style). No CORS needed. */
.backdrop {
  position: relative; isolation: isolate;
  margin: -12px calc(var(--gutter) * -1) 0; padding: var(--s-6) var(--gutter) var(--s-5);
  overflow: hidden;
}
.backdrop::before {
  content: ""; position: absolute; inset: -40px; z-index: -2;
  background: var(--backdrop-image, none) center / cover no-repeat, hsl(var(--backdrop-hue, 24) 60% 28%);
  filter: blur(40px);
  opacity: .45;
}
.backdrop::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, #0f0f1066 0%, #0f0f10cc 60%, var(--bg) 100%);
}

/* ---------- Carousel ---------- */
.carousel {
  display: grid; grid-auto-flow: column; grid-auto-columns: var(--carousel-item, 112px);
  gap: var(--s-3);
  margin: 0 calc(var(--gutter) * -1); padding: 2px var(--gutter) var(--s-2);
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: var(--gutter);
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.carousel > * { scroll-snap-align: start; min-width: 0; }
/* Setas só para mouse (carousel_controller.js); ficam sobre as capas, na altura delas. */
.carousel-shell { position: relative; }
.carousel-shell__arrow { position: absolute; top: 34%; z-index: 2; width: 38px; height: 38px;
  background: var(--surface-3); color: var(--text); box-shadow: 0 4px 12px #00000066; }
.carousel-shell__arrow:hover { background: var(--surface-hover); }
.carousel-shell__arrow[hidden] { display: none; }
.carousel-shell__arrow--previous { left: -8px; }
.carousel-shell__arrow--next { right: -8px; }
.carousel-shell__arrow .ui-icon { width: 20px; height: 20px; }

/* ---------- Progress ---------- */
.progress-bar { position: relative; height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress-bar > span {
  position: absolute; inset: 0 auto 0 0; width: var(--progress, 0%);
  border-radius: inherit; background: var(--orange);
  transition: width 600ms var(--ease-out);
}
.progress-bar--done > span { background: var(--success); }

/* ---------- Empty states ---------- */
.empty {
  display: grid; justify-items: center; gap: var(--s-2);
  padding: var(--s-7) var(--s-5); border-radius: var(--r-lg);
  background: var(--surface-1); text-align: center;
}
.empty__art { width: 88px; height: auto; margin-bottom: var(--s-2); }
.empty h2, .empty h3 { margin: 0; font-size: 1.4rem; }
.empty p { margin: 0 0 var(--s-2); max-width: 32ch; color: var(--muted); }

/* ---------- Bottom sheet ---------- */
.sheet {
  width: 100%; max-width: 560px; max-height: min(86dvh, 720px);
  margin: auto auto 0; padding: 0;
  border: 0; border-radius: 18px 18px 0 0;
  background: var(--surface-1); color: var(--text);
  box-shadow: 0 -20px 60px #000c;
  overflow: hidden;
}
.sheet:focus-visible { outline: none; }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in var(--t-screen) var(--ease); }
.sheet::backdrop { background: color-mix(in srgb, var(--c-ground-deep) 72%, transparent); animation: sheet-fade var(--t-state) ease; }
.sheet.is-closing { animation: sheet-out var(--t-state) ease-in forwards; }
.sheet__handle {
  flex: none; display: block; width: 100%; padding: 10px 0 4px; border: 0; background: transparent; cursor: grab; touch-action: none;
}
.sheet__handle::before { content: ""; display: block; width: 40px; height: 5px; margin: auto; border-radius: 99px; background: var(--line-strong); }
.sheet__header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-2) var(--s-5) var(--s-3); }
.sheet__header h2 { margin: 0; font-size: 1.4rem; }
.sheet__body { padding: 0 var(--s-5) calc(var(--s-6) + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
.sheet__body > .list { background: var(--surface-2); }
.sheet__body > :last-child { margin-bottom: 0; }
body.has-sheet { overflow: hidden; }
@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: 18px; }
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes sheet-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .sheet[open], .sheet.is-closing, .sheet::backdrop { animation: none; }
}

/* ---------- Toast-style flash ---------- */
.flash { border: 0; border-radius: var(--r-md); background: var(--surface-3); box-shadow: var(--shadow-2); }
.flash--alert { background: color-mix(in srgb, var(--danger) 24%, var(--surface-2)); }


/* ---------- Misc ---------- */
.visually-hidden { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.stack { display: grid; gap: var(--s-3); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.tile {
  display: grid; align-content: space-between; gap: var(--s-4);
  min-height: 104px; padding: var(--s-4);
  border-radius: var(--r-md); background: var(--surface-2); color: inherit;
  transition: background var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out);
}
.tile:hover { background: var(--surface-3); }
.tile:active { transform: scale(.97); }
.tile__icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: #ff6a001f; color: var(--orange); }
.tile__icon .ui-icon { width: 20px; height: 20px; }
.tile strong { display: block; font-weight: 800; line-height: 1.2; }
.tile small { color: var(--muted); font-weight: 700; }

/* Barra inferior (direção D): pílula flutuante, botões redondos contornados,
   o ativo em creme sólido com forma levemente orgânica e o "+" coral maior.
   Os rótulos ficam no markup para leitores de tela. */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; transform: none;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; gap: 0;
  width: auto; max-width: none; height: calc(76px + env(safe-area-inset-bottom)); margin: 0;
  padding: 0 max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
  overflow: visible; border: 0; border-top: 1px solid var(--line); border-radius: 0;
  background: var(--bg); box-shadow: none;
}
.bottom-nav__item {
  position: relative; display: grid; place-items: center; place-content: center; min-width: 0; min-height: 0; height: 100%; padding: 0;
  color: var(--muted); font-size: 0;
}
.bottom-nav__item .nav-icon,
.bottom-nav__item--create .nav-icon {
  position: static; top: auto; left: auto; transform: none;
  display: grid; place-items: center; width: 48px; height: 48px; border: 2px solid var(--line); border-radius: var(--r-control);
  background: transparent; color: var(--muted); box-shadow: none;
  transition: background var(--t-state) ease, color var(--t-state) ease, border-color var(--t-state) ease,
    border-radius var(--t-state) var(--ease), transform var(--t-press) var(--ease);
}
.bottom-nav .nav-icon .ui-icon { width: 24px; height: 24px; stroke-width: 2; }
.bottom-nav__item:not(.bottom-nav__item--create):hover .nav-icon { color: var(--text); border-color: var(--line-strong); }
.bottom-nav__item:not(.bottom-nav__item--create).is-active .nav-icon {
  background: var(--text); border-color: var(--text); color: var(--on-color);
  border-radius: var(--r-control);
}
.bottom-nav__item:active .nav-icon { transform: scale(.9); }
/* Toque com resposta imediata: o item tocado assume o estado ativo e o anterior se apaga
   antes da tela nova chegar. Se demorar, um anel Mint gira em volta (dado: está carregando). */
.bottom-nav__item.was-active:not(.bottom-nav__item--create) .nav-icon { background: transparent; border-color: var(--line); color: var(--muted); border-radius: var(--r-control); }
.bottom-nav__item.is-pending:not(.bottom-nav__item--create) .nav-icon {
  background: var(--text); border-color: var(--text); color: var(--on-color);
  border-radius: var(--r-control);
}
/* Carregando: um arco Mint corre pelo contorno do quadrado arredondado (o quadrado fica parado).
   Anel = conic-gradient recortado por máscara; o ângulo anima via @property. */
@property --nav-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.bottom-nav__item.is-loading .nav-icon::after {
  /* O ícone tem borda de 2px e o ::after parte de dentro dela: inset = borda + 5px de recuo, e o raio
     de fora = raio do ícone + 5px, para o anel ser concêntrico ao botão. */
  content: ""; position: absolute; inset: calc(-2px - 5px); padding: 2px; border-radius: calc(var(--r-control) + 5px); pointer-events: none;
  background: conic-gradient(from var(--nav-angle), var(--c-data) 0 28%, transparent 28%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: nav-spin 900ms linear infinite;
}
.bottom-nav__item .nav-icon { position: relative; }
@keyframes nav-spin { to { --nav-angle: 360deg; } }
/* Sem o quadrado de toque do navegador nem contorno no foco por clique: o retorno é a própria
   bolinha (ativa na hora) e o foco por teclado aparece no ícone. */
.bottom-nav__item { -webkit-tap-highlight-color: transparent; }
.bottom-nav__item:focus, .bottom-nav__item:focus-visible { outline: none; }
.bottom-nav__item:focus-visible .nav-icon { outline: 2px solid var(--c-data); outline-offset: 3px; }
.bottom-nav__item--create .nav-icon { width: 56px; height: 56px; border-color: var(--c-you); background: var(--c-you); color: var(--on-color); }
.bottom-nav__item--create:hover .nav-icon { background: var(--orange-hover); border-color: var(--orange-hover); }
.bottom-nav__item--create .register-plus::before { width: 20px; height: 3px; }
.bottom-nav__item--create .register-plus::after { width: 3px; height: 20px; }
/* Distância da pílula até a borda: no iPhone ela entra na área segura e para logo acima da
   barrinha de início, em vez de somar 12px aos 34px da área inteira. */
:root { --bottom-nav-offset: max(12px, calc(env(safe-area-inset-bottom) - 14px)); }
.has-bottom-nav .app-main { padding-bottom: calc(92px + var(--bottom-nav-offset)); }
/* Flutuante em qualquer largura: pílula centralizada acima da borda, livre da
   área segura do celular. */
/* Centralizada por margem, não por translateX(-50%): o transform deixava a barra em meio pixel
   e o navegador a desenhava borrada, como se estivesse em outra resolução. */
.bottom-nav { left: 0; right: 0; bottom: var(--bottom-nav-offset); width: min(480px, calc(100% - 24px)); margin-inline: auto;
  height: 72px; padding: 0 8px; transform: none; border: 1px solid var(--line); border-radius: calc(var(--r-control) + 12px);
  background: var(--surface-1); }
@media (min-width: 800px) { .bottom-nav { bottom: 16px; width: min(480px, calc(100% - 32px)); padding: 0 12px; } }
@media (prefers-reduced-motion: reduce) {
  .bottom-nav__item .nav-icon { transition: none; }
  .bottom-nav__item:active .nav-icon { transform: none; }
  .bottom-nav__item.is-loading .nav-icon::after { animation: none; background: var(--c-data); opacity: .6; }
}
}

/* Paywall contextual: superfície sólida, sem brilho. */
.paywall { display: grid; gap: var(--s-2); margin: var(--s-4) 0; padding: var(--s-4); border-radius: var(--r-md); background: var(--surface-2); }
.paywall__teaser { margin: 0; color: var(--mustard); font-weight: 700; }
.paywall__title { margin: 0; font-size: 1.05rem; }
.paywall__body, .paywall__hint { margin: 0; color: var(--muted); font-size: .92rem; }

/* ---------- Carregamento entre telas ----------
   A barra de progresso do Turbo fica escondida; o conteúdo esmaece só se
   a troca demorar, para navegações rápidas não piscarem. Só em navegações que a pessoa iniciou
   (html.is-navigating), nunca nos refreshes ao vivo. */
.turbo-progress-bar { display: none; }
.app-main { transition: opacity var(--dur-fast) ease; }
html.is-navigating .app-main { opacity: .7; transition: opacity 200ms ease 600ms; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  html.is-navigating .app-main { transition: none; }
}

/* ---------- Direção D: primitivos de composição ---------- */
/* Rótulo pequeno acima do título da tela. */
.over { display: block; margin: 0; font-size: .8rem; font-weight: 600; color: var(--muted); }
/* Lista numa superfície só, com divisórias internas, no lugar de um card por item. */
.surface-list { gap: 0; padding: 0 var(--s-4); border-radius: var(--radius-xl); background: var(--surface-1); }
.surface-list > .list-row { border-radius: 0; background: transparent; padding-left: 0; padding-right: 0; }
.surface-list > .list-row + .list-row { border-top: 1px solid var(--line); }

/* Barra com crista de onda: mesma máscara do seletor de nota. Só no desafio do grupo. */
.progress-bar--wave { display: block; height: 16px; background: var(--surface-3); }
.progress-bar--wave > span {
  background: var(--c-win); border-radius: 0;
  -webkit-mask: var(--wave) 0 0 / 24px 20px repeat-x, linear-gradient(#000, #000) 0 6px / 100% 100% no-repeat;
  mask: var(--wave) 0 0 / 24px 20px repeat-x, linear-gradient(#000, #000) 0 6px / 100% 100% no-repeat;
  animation: wave-crest 2.6s linear infinite, wave-fill var(--t-data) var(--ease) both;
  transition: width var(--t-data) var(--ease-spring);
}
@keyframes wave-crest { to { -webkit-mask-position: 24px 0, 0 6px; mask-position: 24px 0, 0 6px; } }
@keyframes wave-fill { from { width: 0; } }
@media (prefers-reduced-motion: reduce) { .progress-bar--wave > span { animation: none; transition: none; } }

/* <details> com seta própria: esconde o triângulo nativo e gira a seta ao abrir. */
details > summary:has(.ui-icon) { list-style: none; cursor: pointer; }
details > summary:has(.ui-icon)::-webkit-details-marker { display: none; }
details > summary:has(.ui-icon)::marker { content: ""; }
details > summary > .ui-icon:last-child { transition: transform var(--t-state) var(--ease); }
details[open] > summary > .ui-icon:last-child { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { details > summary > .ui-icon:last-child { transition: none; } }

/* ---------- Raios encaixados ----------
   Quando uma forma arredondada fica dentro de outra, os cantos precisam ser concêntricos:
   raio de dentro = raio de fora − distância entre as bordas (nunca o mesmo raio).
   Toda capa expõe o próprio raio em --cover-radius; quem fica dentro dela calcula a partir dele. */
.pattern-poster { border-radius: var(--cover-radius, 10px); }

/* ---------- Placar do registro (activity_tally) ----------
   Chips planos como os de curtir/comentar (surface-2, raio 10px). Nota: estrelas coral
   preenchidas até a nota, com quase a altura do número e centradas nele; lime no 5,0
   (conquista). Pontos: número Mint (dado). O tempo é uma linha de apoio. :sm no feed, :lg no detalhe. */
.tally { --tally-h: 30px; --tally-pad: 10px; --tally-num: 1.05rem; --tally-text: .78rem;
  display: grid; gap: 6px; justify-items: start; margin-top: var(--s-2); }
.tally--lg { --tally-h: 40px; --tally-pad: 14px; --tally-num: 1.5rem; --tally-text: .88rem; gap: var(--s-2); margin-top: var(--s-4); }
.tally__chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.tally__chip { display: inline-flex; align-items: center; gap: .5em; height: var(--tally-h); padding: 0 var(--tally-pad);
  border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: var(--tally-text); font-weight: 600; line-height: 1; white-space: nowrap; }
.tally__chip b { font: 400 var(--tally-num)/1 var(--font-display); letter-spacing: .01em; text-box: trim-both cap alphabetic; }
/* Estrelas com ~90% da altura das maiúsculas do número (Anton tem cap height ~.73em). */
/* Largura explícita em vez de aspect-ratio: no Safari do iOS o chip media o SVG pelo tamanho
   padrão (300px) e esticava, empurrando os pontos para a linha de baixo. */
.tally__stars { --stars-h: calc(var(--tally-num) * .68);
  display: inline-grid; flex: none; height: var(--stars-h); width: calc(var(--stars-h) * 126 / 24); }
.tally__stars > svg { grid-area: 1 / 1; width: 100%; height: 100%; display: block; }
.tally__stars-base { fill: var(--line-strong); }
.tally__stars-fill { fill: var(--c-you); clip-path: inset(0 calc(100% - var(--fill)) 0 0); }
.tally__rating b { color: var(--text); }
.tally__rating.is-max .tally__stars-fill { fill: var(--c-win); }
.tally__rating.is-max b { color: var(--c-win); }
.tally__points b { color: var(--c-data); }
/* O "+" do Anton é pequeno e fica na altura das minúsculas; na fonte do corpo, com o tamanho
   das maiúsculas do número e centrado nelas, ele acompanha o número. */
.tally__points b { display: inline-flex; align-items: center; gap: .04em; }
.tally__sign { font: 700 .78em/1 var(--font-body); text-box: trim-both cap alphabetic; }
.tally__num { text-box: trim-both cap alphabetic; }
.tally__time { margin: 0; color: var(--muted); font-size: var(--tally-text); font-weight: 600; }

/* ---------- Campo de busca (search_input) ----------
   O botão de limpar aparece sempre que há texto, também no celular sem foco. O "x" nativo sai. */
.search-input { position: relative; display: flex; flex: 1 1 0; min-width: 0; }
.search-input > input[type="search"] { flex: 1 1 auto; width: 100%; min-width: 0; padding-right: 44px; }
.search-input > input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
.search-input__clear { position: absolute; top: 50%; right: 6px; translate: 0 -50%; display: grid; place-items: center;
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--r-control-sm); background: transparent; color: var(--muted); cursor: pointer;
  transition: color var(--t-press) ease, background var(--t-press) ease; }
.search-input__clear[hidden] { display: none; }
.search-input__clear:hover { color: var(--text); background: var(--surface-2); }
.search-input__clear:focus-visible { outline: 2px solid var(--c-data); outline-offset: 1px; }
.search-input__clear .ui-icon { width: 18px; height: 18px; }
@media (prefers-reduced-motion: reduce) { .search-input__clear { transition: none; } }
