/* =========================================================
   Sistema visual partilhado — galeria e todas as ferramentas
   Muda os valores em :root e todo o site acompanha.
   ========================================================= */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400&display=swap");

:root {
  --bg: #0e0e0e;          /* fundo da página */
  --surface: #191919;     /* janelas / painéis */
  --surface-hover: #202020;
  --control: #222222;     /* botões secundários, segmentos */
  --control-hover: #2a2a2a;
  --shape: #d4d4d4;       /* formas nas miniaturas */
  --text: #ededed;
  --text-2: #9a9a9a;      /* texto secundário */
  --meta: #8a8a8a;        /* categorias, valores, legendas */
  --track: #333333;       /* trilho dos sliders */
  --radius: 6px;
  --font: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --max: 1240px;
  --gutter: 24px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--text); text-decoration: none; }
a:hover { color: #fff; }
button { font-family: var(--font); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 32px; }
@media (max-width: 600px) { .wrap { padding: 0 20px; } }

/* ---------- Cabeçalho e rodapé ---------- */
.site-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; padding: 28px 0; }
.brand { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.nav { display: flex; gap: 28px; font-size: 14px; }
.nav a { color: #bdbdbd; }
.back { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; color: #bdbdbd; }
.site-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 96px 0 40px; font-size: 13px; color: var(--meta); }
.site-footer a { color: var(--meta); }
.site-footer nav { display: flex; gap: 24px; }

/* ---------- Galeria ---------- */
.hero { padding: 72px 0 48px; max-width: 640px; }
.hero h1 { margin: 0 0 16px; font-size: 56px; font-weight: 600; letter-spacing: -0.035em; line-height: 1.02; }
.hero p { margin: 0; font-size: 17px; line-height: 1.55; color: var(--text-2); }
@media (max-width: 600px) { .hero { padding: 40px 0 32px; } .hero h1 { font-size: 40px; } }

.toolbar-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 32px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--surface); color: #bdbdbd; font-size: 13px; font-weight: 500; cursor: pointer; }
.pill:hover { background: var(--control); color: var(--text); }
.pill .count { font-family: var(--mono); font-size: 11px; color: var(--meta); }
.pill[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.pill[aria-pressed="true"] .count { color: #555; }
.sort { display: flex; gap: 4px; }
.sort button { min-height: 36px; padding: 0 8px; border: 0; background: none; color: var(--meta); font-size: 13px; cursor: pointer; }
.sort button[aria-pressed="true"] { color: var(--text); }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: var(--gutter); row-gap: 40px; }
@media (max-width: 960px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr; } }
.card { display: flex; flex-direction: column; gap: 14px; }
.win { aspect-ratio: 1 / 1; background: var(--surface); border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; transition: background .2s; }
.card:hover .win { background: var(--surface-hover); }
.win img { display: block; }
.win.cobrir img { width: 100%; height: 100%; object-fit: cover; }
.win.centro img { width: 62%; height: auto; }
.card-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card-meta .name { font-size: 15px; font-weight: 500; }
.card-meta .cat { font-family: var(--mono); font-size: 12px; color: var(--meta); }
.empty { color: var(--meta); font-size: 14px; }

/* ---------- Página de ferramenta ---------- */
.tool-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px; padding: 24px 0 28px; }
.tool-head .cat { font-family: var(--mono); font-size: 12px; color: var(--meta); display: block; margin-bottom: 8px; }
.tool-head h1 { margin: 0; font-size: 40px; font-weight: 600; letter-spacing: -0.03em; }
.tool-head p { margin: 0; max-width: 420px; font-size: 15px; line-height: 1.55; color: var(--text-2); }
.tool-layout { display: flex; flex-wrap: wrap; gap: var(--gutter); align-items: flex-start; padding-bottom: 48px; }

/* Painel de parâmetros (sempre à esquerda) */
.panel { flex: 1 1 300px; background: var(--surface); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 28px; }
.section { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.label { font-family: var(--mono); font-size: 11px; color: var(--meta); text-transform: uppercase; letter-spacing: 0.06em; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: flex; justify-content: space-between; font-size: 13px; }
.field-row label, .field-name { color: #bdbdbd; font-size: 13px; }
.field-row .val { font-family: var(--mono); color: var(--meta); }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--track); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--shape); margin-top: -6px; }
input[type=range]::-moz-range-track { height: 2px; background: var(--track); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--shape); }
input[type=color] { -webkit-appearance: none; appearance: none; width: 36px; height: 36px; border: 0; padding: 0; border-radius: var(--radius); background: none; cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: var(--radius); }
input[type=color]::-moz-color-swatch { border: 0; border-radius: var(--radius); }

/* Botões segmentados (opções) */
.seg { display: grid; gap: 6px; }
.seg button { min-height: 40px; border: 0; border-radius: var(--radius); background: var(--control); color: #bdbdbd; font-size: 13px; font-weight: 500; cursor: pointer; }
.seg button:hover { background: var(--control-hover); color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.seg.mono button { font-family: var(--mono); }
.seg .tile-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 64px; font-size: 11px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 12px; border: 0; border-radius: var(--radius); background: var(--control); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--control-hover); }
.btn:disabled { color: #4a4a4a; cursor: default; background: var(--control); }
.btn.square { width: 36px; padding: 0; }
.btn-primary { min-height: 44px; border: 0; border-radius: var(--radius); background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary:hover { background: #fff; }

/* Área de pré-visualização */
.stage { position: relative; flex: 999 1 560px; min-width: 0; height: 720px; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
@media (max-width: 700px) { .stage { height: 480px; } }
.stage > svg.preview { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-tools { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: var(--radius); background: rgba(14,14,14,.78); color: var(--text); display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.icon-btn:hover { background: rgba(40,40,40,.92); }
.icon-btn[aria-pressed="true"], .icon-btn[aria-expanded="true"] { background: var(--text); color: var(--bg); }
.chip { position: absolute; left: 14px; bottom: 14px; font-family: var(--mono); font-size: 11px; color: var(--text); background: rgba(14,14,14,.78); padding: 7px 10px; border-radius: 4px; }
.toast { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 13px; color: var(--bg); background: var(--text); padding: 8px 14px; border-radius: 999px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.on { opacity: 1; }
.popover { position: absolute; top: 62px; right: 14px; width: 280px; background: #141414; border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.popover[hidden] { display: none; }
.popover .title { font-size: 14px; font-weight: 600; }
.popover .sub { font-size: 12px; color: var(--meta); }
.icon-close { width: 32px; height: 32px; border: 0; border-radius: var(--radius); background: transparent; color: var(--text-2); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }

/* Guardados */
.saved { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.saved .item { position: relative; }
.saved .thumb { display: block; width: 100%; aspect-ratio: 1 / 1; padding: 0; border: 0; border-radius: var(--radius); overflow: hidden; cursor: pointer; background: none; }
.saved .thumb:hover { opacity: .85; }
.saved .thumb svg { width: 100%; height: 100%; display: block; }
.saved .del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border: 0; border-radius: 4px; background: rgba(14,14,14,.78); color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.hint { margin: 0; font-size: 13px; line-height: 1.5; color: var(--meta); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
