:root {
  --bg: #f5f1ea;
  --surface: #fffdf9;
  --surface-2: #ece6db;
  --fg: #1e1b16;
  --muted: #6e675c;
  --line: #ddd5c7;
  --accent: #e8590c;
  --accent-fg: #fff;
  --shade: 20 16 10;
  --shadow: 0 1px 2px rgb(30 27 22 / 6%), 0 12px 32px rgb(30 27 22 / 12%);
  --radius: 14px;
  /* Largura do cartão: grande, mas cabe na altura da tela (a foto é quadrada). */
  --card-w: min(1320px, calc(100vw - 280px), calc((100vh - 220px - 9.8vmin) * 1.85));
  --card-gap: 36px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14120f;
    --surface: #1d1a16;
    --surface-2: #2a2620;
    --fg: #f3eee6;
    --muted: #a59d90;
    --line: #36312a;
    --accent: #ff7a2e;
    --accent-fg: #160c05;
    --shade: 0 0 0;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 16px 40px rgb(0 0 0 / 45%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
main { flex: 1; width: 100%; display: flex; flex-direction: column; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
kbd {
  font: 600 11px/1 ui-monospace, monospace;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgb(0 0 0 / 15%);
  margin-left: 8px;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Barra do topo: logo à esquerda, filtros no centro, idioma à direita.
   Tamanhos em vmin: crescem com a tela (Mac ≈ 14 px de texto, 4K bem maior). */
.topbar {
  --logo: clamp(22px, 2.6vmin, 64px);
  --pill: clamp(14px, 1.5vmin, 34px);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: calc(var(--pill) * 1.1) clamp(16px, 2vw, 48px) 4px;
  font-size: var(--pill);
}
.logo { margin: 0; justify-self: start; font-weight: 850; font-size: var(--logo); line-height: 1; letter-spacing: -0.03em; }
.logo span { color: var(--accent); margin-left: 0.06em; }
/* Centro: etiquetas dos filtros aplicados e o botão de filtros. */
.controls { display: flex; align-items: center; gap: 0.6em; min-width: 0; max-width: min(62vw, 980px); }
.active-chips { display: flex; gap: 0.4em; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.active-chips::-webkit-scrollbar { display: none; }
.active-chip {
  display: inline-flex; align-items: center; gap: 0.25em; flex: none;
  padding: 0.45em 0.35em 0.45em 0.9em; border-radius: 999px; font-size: 0.93em; font-weight: 600;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--fg);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
}
.active-chip-x {
  display: grid; place-items: center; width: 1.5em; height: 1.5em; padding: 0;
  background: none; border: 0; border-radius: 999px; color: var(--muted);
}
.active-chip-x svg { width: 0.9em; height: 0.9em; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.active-chip-x:hover { color: var(--fg); background: rgb(0 0 0 / 15%); }
/* Botão de filtros. Sem filtros: pílula "Filtros +". Com filtros: só o ícone, redondo. */
.filter-btn {
  flex: none; display: inline-flex; align-items: center; gap: 0.55em;
  height: 2.75em; padding: 0 0.45em 0 1.15em; font-size: 1em; font-weight: 700;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
  transition: border-color .15s;
}
.filter-btn:hover { border-color: var(--accent); }
/* Sem filtros: o mesmo tom laranja das etiquetas de filtro (fundo escuro alaranjado, borda laranja). */
.controls:not(.has-filters) .filter-btn {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--fg);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}
.controls:not(.has-filters) .filter-btn:hover { border-color: var(--accent); }
.filter-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-btn-icon { display: grid; place-items: center; }
.filter-btn-icon svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.filter-btn-icon.plus {
  width: 1.9em; height: 1.9em; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--fg);
}
.filter-btn-icon.plus svg { width: 1em; height: 1em; stroke-width: 2.6; }
.filter-btn-icon.sliders { display: none; }
.controls.has-filters .filter-btn { width: 2.75em; padding: 0; justify-content: center; }
.controls.has-filters .filter-btn-label,
.controls.has-filters .filter-btn-icon.plus { display: none; }
.controls.has-filters .filter-btn-icon.sliders { display: grid; }

/* Botão redondo (+ dos filtros). */
.round-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 2.75em; height: 2.75em; padding: 0; font-size: 1em;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
}
.round-btn svg { width: 1.3em; height: 1.3em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.round-btn:hover, .round-btn[aria-expanded="true"] { color: var(--fg); border-color: var(--accent); }
.round-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Direita: seletor de idioma. */
.right { justify-self: end; display: flex; align-items: center; gap: 0.6em; }
.lang select {
  appearance: none; height: 2.75em; padding: 0 2.1em 0 1em; cursor: pointer;
  font-family: inherit; font-size: 0.93em; font-weight: 700; letter-spacing: .04em; color: var(--muted);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23999' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.85em center; background-size: 0.7em auto;
  border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
}
.lang select:hover { color: var(--fg); border-color: var(--accent); }
.lang select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Opções em botões (usadas no modal de filtros) */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.4em; }
.chip {
  font-size: 0.93em; padding: 0.35em 0.8em; border-radius: 999px;
  background: transparent; color: var(--fg); border: 1px solid var(--line);
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: var(--accent); color: var(--fg); }
.text-btn { background: none; border: 0; padding: 0.3em 0.2em; color: var(--muted); font-size: 0.93em; text-decoration: underline; text-underline-offset: 3px; }
.text-btn:hover { color: var(--fg); }
.primary:disabled { opacity: .45; cursor: default; }


/* Roleta */
/* A roleta ocupa a altura livre e fica centralizada na vertical. */
.spin { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 16px 0 24px; }
.stage { position: relative; overflow: hidden; padding: 28px 0; }
/* Laterais escurecidas. O fundo é o mesmo da página; o escuro some aos poucos em cima
   e embaixo (máscara), para não criar linhas de corte nem uma faixa de outra cor. */
.stage::before, .stage::after {
  content: ""; position: absolute; top: 0; bottom: 0; z-index: 2; pointer-events: none;
  width: calc((100vw - var(--card-w)) / 2 + 40px);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 22%, #000 78%, transparent);
}
.stage::before { left: 0; background: linear-gradient(90deg, rgb(var(--shade) / 70%), rgb(var(--shade) / 25%) 70%, transparent); }
.stage::after { right: 0; background: linear-gradient(270deg, rgb(var(--shade) / 70%), rgb(var(--shade) / 25%) 70%, transparent); }

.track { position: relative; z-index: 1; display: flex; gap: var(--card-gap); align-items: center; will-change: transform; }

/* Cartão do modelo */
.card {
  --dim: 0;
  position: relative;
  flex: 0 0 var(--card-w);
  min-width: 0;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 36px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 24px; box-shadow: var(--shadow);
  transform-origin: center;
  pointer-events: none;
}
.card::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  background: rgb(var(--shade)); opacity: calc(var(--dim) * 0.55); pointer-events: none;
}
/* No desktop, a foto define a altura. Todos os cartões ficam iguais e a roleta não pula. */
@media (min-width: 761px) {
  .card .info { contain: size; overflow-y: auto; scrollbar-width: thin; padding-right: 4px; }
}
/* Expandir e salvar: ícones discretos no canto superior direito. Só no cartão do meio. */
.card-tools { position: absolute; top: 14px; right: 14px; z-index: 1; display: none; gap: 2px; }
.card.active .card-tools { display: flex; }
.tool {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  background: transparent; color: var(--muted); border: 0; border-radius: 10px;
}
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { color: var(--fg); background: var(--surface-2); }
.tool.save[aria-pressed="true"] { color: var(--accent); }
.tool.save[aria-pressed="true"] svg { fill: currentColor; }
.in-modal .tool.expand { display: none; }
/* Ícone do MakerWorld no cartão: só no celular (no desktop fica o link acima do cartão). */
.tool.mw { display: none; }
/* Botão de filtros da barra flutuante: só no celular. */
.mobile-filter { display: none; }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--accent); color: #140c05; font-size: 12px; font-weight: 800;
}
.card.active { pointer-events: auto; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card.active::after { opacity: 0; }

.hero { display: block; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
/* Clicar na foto do cartão do meio abre o modal. */
button.hero { width: 100%; padding: 0; border: 0; font: inherit; color: inherit; }
.card.active:not(.in-modal) .hero { cursor: pointer; }
/* Toque responde na hora (sem esperar o toque duplo de zoom). */
.hero, .tool, .spacebar, .mobile-filter, .back-link, .filter-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs { display: flex; gap: 10px; margin-top: 12px; min-height: 76px; overflow: hidden; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; width: 76px; height: 76px; background: var(--surface-2); }
.thumbs button[aria-current="true"] { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

.eyebrow { margin: 0; color: var(--accent); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; }
.card h2 { font-size: clamp(24px, 2.7vw, 42px); line-height: 1.15; letter-spacing: -0.02em; margin: 6px 0 4px; }
.original { margin: 0; color: var(--muted); font-size: 15px; }
.creator { margin: 6px 0 22px; color: var(--muted); font-size: 15px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 18px; }
.stats div { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font-weight: 750; font-size: 22px; font-variant-numeric: tabular-nums; }

.filaments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filament { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 5px; }
.filament i { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgb(0 0 0 / 20%); }

.profiles { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.profiles:empty { display: none; }
.profiles .label { font-size: 13px; color: var(--muted); }
.profile {
  display: flex; justify-content: space-between; gap: 12px; text-align: left;
  border: 1px solid var(--line); background: transparent; color: var(--fg);
  border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.profile[aria-current="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.profile span:last-child { color: var(--muted); white-space: nowrap; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }
.tags li { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 2px 8px; }

/* Ações (fora da roleta) */
.actions { width: var(--card-w); margin: 10px auto 0; display: flex; justify-content: center; }

/* Barra de espaço: tecla larga com sombra de baixo, que "afunda" ao apertar. */
.spacebar {
  --key-h: clamp(52px, 5.4vmin, 96px);
  position: relative; display: flex; align-items: center; justify-content: center;
  width: min(100%, clamp(320px, 36vw, 760px)); height: var(--key-h);
  background: var(--accent); color: var(--accent-fg);
  border: 0; border-radius: 14px;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--accent) 55%, #000), 0 10px 24px rgb(0 0 0 / 30%);
  font-size: calc(var(--key-h) * 0.32); font-weight: 750;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.spacebar:hover { filter: brightness(1.05); }
.spacebar:active, .spacebar.pressed {
  transform: translateY(4px);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 55%, #000), 0 4px 12px rgb(0 0 0 / 25%);
}
.spacebar:focus-visible { outline: 2px solid var(--fg); outline-offset: 4px; }
.spacebar-hint {
  position: absolute; right: 1.1em; bottom: 0.7em;
  font-size: 0.5em; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .6;
}
.primary {
  display: inline-flex; align-items: center; border-radius: 12px; padding: 12px 18px;
  font-weight: 700; text-decoration: none; border: 0;
  background: var(--accent); color: var(--accent-fg);
}
/* Voltar: link pequeno acima do cartão, alinhado à borda esquerda dele. */
.above { position: relative; z-index: 4; width: var(--card-w); margin: 0 auto -20px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; min-height: 26px; }
.above .back-link { grid-column: 1; grid-row: 1; justify-self: start; }
/* Voltar e Abrir no MakerWorld: pílulas pequenas com fundo. Visíveis, sem competir com a barra de espaço. */
.top-link, .back-link {
  display: inline-flex; align-items: center; gap: 0.35em;
  font-size: clamp(13px, 1.4vmin, 26px); font-weight: 600; line-height: 1;
  color: color-mix(in srgb, var(--fg) 78%, var(--muted));
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.55em 1em; text-decoration: none; white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.top-link:hover, .back-link:hover { color: var(--fg); border-color: var(--muted); background: var(--surface-2); }
.top-link:focus-visible, .back-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.top-link { grid-column: 3; grid-row: 1; justify-self: end; }
.top-link.pending { visibility: hidden; }
.back-link { padding-left: 0.75em; }
.back-link svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
/* Sem sugestão anterior: some, mas guarda o espaço para a roleta não pular. */
.back-link:disabled { visibility: hidden; }
.spinning .actions { opacity: .5; }
/* Antes da primeira sugestão: ocupa o espaço, mas não aparece. */
.actions.pending { visibility: hidden; }

.empty { color: var(--muted); text-align: center; padding: 40px 16px; }


@media (max-width: 760px) {
  :root { --card-w: calc(100vw - 48px); --card-gap: 14px; }
  /* No celular a roleta fica no topo (sem centralizar na vertical). Assim o cartão não desce
     em telas altas e o "Voltar", posicionado a partir do topo, fica sempre sobre a foto. */
  .spin { padding-top: 6px; justify-content: flex-start; }
  /* Sem vão entre linhas: a linha das etiquetas só ocupa espaço quando há filtro. */
  .topbar { grid-template-columns: 1fr auto; grid-template-areas: "logo user" "controls controls"; row-gap: 0; padding-bottom: 0; }
  .topbar .controls { margin-top: 10px; }
  .topbar .logo { grid-area: logo; }
  .topbar .right { grid-area: user; }
  .topbar .controls { grid-area: controls; justify-self: center; max-width: 100%; }
  .stage { padding: 10px 0 20px; }
  .card { grid-template-columns: minmax(0, 1fr); padding: 14px; gap: 16px; }
  /* No celular os cartões têm alturas diferentes: alinha pelo topo. */
  .track { align-items: flex-start; }
  /* No celular o ícone fica sobre a foto: fundo para dar contraste. */
  .card-tools { top: 16px; right: 16px; }
  .tool { background: color-mix(in srgb, var(--surface) 75%, transparent); }
  /* Celular: a barra de "Nova sugestão" flutua presa embaixo da tela. */
  .actions {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; width: auto; margin: 0;
    padding: 28px 16px calc(14px + env(safe-area-inset-bottom));
    background: linear-gradient(to bottom, transparent, var(--bg) 45%);
    pointer-events: none;
  }
  .actions .spacebar { pointer-events: auto; }
  .spin { padding-bottom: 110px; } /* espaço para o fim do cartão não ficar atrás da barra */
  .spacebar { width: 100%; }
  .spacebar-hint { display: none; } /* telefone não tem barra de espaço */
  .actions { gap: 10px; }
  .actions .spacebar { flex: 1; width: auto; }
  /* Filtros à esquerda da barra, no tom laranja das etiquetas. */
  .mobile-filter {
    position: relative; flex: none; display: grid; place-items: center; pointer-events: auto;
    width: 48px; height: 48px; padding: 0; border-radius: 14px; font-size: 16px;
    background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--fg);
    border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
    box-shadow: 0 10px 24px rgb(0 0 0 / 30%);
  }
  .mobile-filter svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  /* No topo ficam só as etiquetas dos filtros ativos; sem filtros, a linha some. */
  .topbar .filter-btn { display: none; }
  .topbar .controls:not(.has-filters) { display: none; }
  /* MakerWorld vira ícone no cartão; o link acima do cartão some. */
  .above .top-link { display: none; }
  .tool.mw { display: grid; }
  .in-modal .tool.mw { display: none; }
  /* Perfis de impressão só no modo tela cheia. */
  .card:not(.in-modal) .profiles { display: none; }
  .top-link, .back-link { font-size: 12px; }
  /* Voltar flutua sobre o canto superior esquerdo da foto (espelha os ícones da direita).
     Assim não ocupa uma linha. 6 + 10 + 14 + 6 = recuo da seção + faixa + cartão + respiro. */
  .above { position: absolute; z-index: 5; top: 32px; left: 40px; width: auto; margin: 0; display: block; min-height: 0; }
  .back-link { background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(6px); }
  /* Palavras-chave só no modo tela cheia. */
  .card:not(.in-modal) .tags { display: none; }

  /* Cartão da roleta compacto: foto 3:2, textos e números menores.
     Assim foto, título, números e filamento cabem acima da barra (num celular de ~660 px úteis).
     O modo tela cheia (modal) mantém os tamanhos maiores. */
  .spacebar { --key-h: 48px; }
  .track .card { padding: 10px; gap: 10px; border-radius: 16px; }
  .track .card .hero { aspect-ratio: 3 / 2; border-radius: 10px; }
  .track .card .thumbs { min-height: 44px; gap: 6px; margin-top: 8px; }
  .track .card .thumbs button { width: 44px; height: 44px; border-radius: 8px; }
  .track .card .eyebrow { font-size: 11px; }
  .track .card h2 { font-size: 19px; line-height: 1.2; margin: 3px 0 2px; }
  .track .card .original { font-size: 12px; }
  .track .card .creator { font-size: 12px; margin: 2px 0 10px; }
  .track .card .stats { gap: 6px; margin-bottom: 10px; }
  .track .card .stats div { padding: 6px 9px; border-radius: 9px; }
  .track .card .stats dt { font-size: 11px; }
  .track .card .stats dd { font-size: 14px; }
  .track .card .filaments { margin-bottom: 0; }
  .track .card .filament { font-size: 12px; padding: 2px 9px 2px 3px; }
  .track .card .filament i { width: 14px; height: 14px; }
  .track .card .tool { width: 32px; height: 32px; }
  .track .card .tool svg { width: 18px; height: 18px; }
  .thumbs { min-height: 60px; gap: 8px; }
  .thumbs button { width: 60px; height: 60px; }
  .stats dd { font-size: 16px; }
}

/* Modal do cartão grande */
.modal {
  padding: 0; border: 0; background: transparent; color: var(--fg);
  max-width: none; max-height: none; width: 100vw; height: 100vh; overflow: auto;
}
.modal::backdrop { background: rgb(0 0 0 / 72%); backdrop-filter: blur(6px); }
.modal-body { min-height: 100%; display: grid; place-items: center; padding: 48px 24px; }
.modal .card {
  /* Altura ≈ 0,512 × largura + 117 px (foto quadrada + miniaturas + respiro). Cabe em 100vh - 96 px. */
  --card-w: min(1700px, calc(100vw - 96px), calc((100vh - 220px) * 1.95));
  width: var(--card-w); transform: none; padding: 32px; gap: 44px;
}
.modal .card h2 { font-size: clamp(28px, 3.2vw, 56px); }
.modal .thumbs { min-height: 96px; }
.modal .thumbs button { width: 96px; height: 96px; }
.modal-close {
  position: fixed; top: 18px; right: 18px; z-index: 2;
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 999px;
}
.modal-close svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.modal-close:hover { border-color: var(--accent); }
@media (max-width: 760px) {
  .modal-body { padding: 64px 12px 24px; }
  .modal .card { --card-w: calc(100vw - 24px); padding: 16px; gap: 16px; }
  /* Miniaturas menores e coluna limitada: senão a coluna estica além da tela. */
  .modal .card { grid-template-columns: minmax(0, 1fr); }
  .modal .thumbs { min-height: 60px; }
  .modal .thumbs button { width: 60px; height: 60px; }
}

/* Abrir no MakerWorld dentro do modal: canto inferior direito do cartão. */
.modal .card .info { padding-bottom: 3.6em; }
/* grid-column/row: auto anula a coluna 3 do link de cima, que aqui estreitava o botão. */
.modal-mw { position: absolute; right: 32px; bottom: 32px; z-index: 1; grid-column: auto; grid-row: auto; white-space: nowrap; }
@media (max-width: 760px) {
  .modal-mw { position: static; justify-self: end; }
  .modal .card .info { padding-bottom: 0; }
}

/* Modal de filtros.
   Todas as medidas são em em. A fonte cresce com a tela até o limite que ainda cabe:
   altura ≈ 43em ≤ 96vh (2.15vh) e largura 70em ≤ 96vw (1.37vw). Assim não há rolagem. */
.fmodal {
  width: min(70em, 96vw); max-width: none; max-height: 96vh; padding: 0;
  display: none; flex-direction: column;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--line); border-radius: 1.4em; box-shadow: 0 30px 80px rgb(0 0 0 / 45%);
  font-size: clamp(13px, min(2.15vh, 1.37vw), 30px);
}
.fmodal[open] { display: flex; }
.fmodal::backdrop { background: rgb(0 0 0 / 60%); backdrop-filter: blur(4px); }
.fmodal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1em 1.6em 0.4em; }
.fmodal-head h2 { margin: 0; font-size: 1.45em; letter-spacing: -0.02em; }
.fmodal-x {
  display: grid; place-items: center; width: 2.2em; height: 2.2em; padding: 0;
  background: var(--surface-2); color: var(--fg); border: 0; border-radius: 999px;
}
.fmodal-x svg { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
/* Duas colunas: temas à esquerda, os outros filtros à direita. Rolagem só como último recurso. */
.fmodal-body {
  overflow-y: auto; padding: 0.4em 1.6em 1em;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 2.4em;
}
.fcol { min-width: 0; }
.fcol-themes { padding-right: 2.4em; margin-right: -1.2em; border-right: 1px solid var(--line); }
.fsec { padding: 0.8em 0; border-top: 1px solid var(--line); }
.fsec:first-child { border-top: 0; padding-top: 0.3em; }
.fsec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1em; margin-bottom: 0.6em; }
.fsec-head h3 { margin: 0; font-size: 0.95em; font-weight: 700; }
.fsec-value { font-size: 0.95em; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.fmodal .chip-row { gap: 0.35em; }
.fmodal .chip { font-size: 0.88em; padding: 0.42em 0.85em; white-space: nowrap; }
/* Cartões de tema: ícone à esquerda; nome e contagem à direita. Baixos, para caber sem rolagem. */
.theme-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5em; }
.theme-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto;
  column-gap: 0.65em; align-items: center; text-align: left;
  padding: 0.6em 0.7em; border-radius: 0.8em; font-size: 0.9em;
  background: var(--surface-2); color: var(--fg); border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.theme-card:hover { border-color: var(--muted); }
.theme-card[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.theme-icon {
  grid-row: 1 / 3; display: grid; place-items: center; width: 2.3em; height: 2.3em; border-radius: 0.6em;
  background: var(--surface); color: var(--muted);
}
.theme-card[aria-pressed="true"] .theme-icon { background: var(--accent); color: var(--accent-fg); }
.theme-icon svg { width: 1.3em; height: 1.3em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-icon svg .dot { fill: currentColor; stroke: none; }
.theme-name { font-weight: 650; line-height: 1.2; align-self: end; }
.theme-count { font-size: 0.85em; color: var(--muted); font-variant-numeric: tabular-nums; align-self: start; }
.slider { width: 100%; margin: 0; accent-color: var(--accent); height: 1.5em; cursor: pointer; }
.slider-scale { display: flex; justify-content: space-between; margin-top: 0.1em; font-size: 0.8em; color: var(--muted); }
.fmodal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 1em;
  padding: 0.9em 1.6em; border-top: 1px solid var(--line);
}
.fmodal-foot .primary { padding: 0.7em 1.4em; border-radius: 0.75em; font-size: 1em; }
/* Celular: folha que sobe de baixo, numa coluna. Aqui a rolagem é necessária. */
@media (max-width: 760px) {
  .fmodal { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 22px 22px 0 0; font-size: 14px; }
  .fmodal-body { grid-template-columns: minmax(0, 1fr); }
  .fcol-themes { padding-right: 0; margin-right: 0; border-right: 0; }
  .theme-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fmodal .chip { white-space: normal; }
}
