/* Extrusor — mesma família visual do Fatiador de preço:
   mesa de aço (fundo), folha (painéis), tinta, PEI dourado. */

:root {
  --plate: #E6E8EB;
  --sheet: #FFFFFF;
  --ink: #15171C;
  --muted: #5D636D;
  --rule: #D3D7DD;
  --field: #F4F5F7;
  --pei: #B8862B;
  --pei-deep: #8C6316;
  /* cor de destaque dos controles: o roxo dos Personalizados (o dourado fica só na mesa de impressão) */
  --acento: var(--ferramenta, #7B50C8);
  --loss: #CF3F2B;
  --stage: #DCDFE3;

  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Martian Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --radius: 6px;
  --gutter: clamp(16px, 2.4vw, 28px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --plate: #111317; --sheet: #1A1D23; --ink: #ECEEF1; --muted: #9AA1AC;
    --rule: #2B3038; --field: #22262D; --pei: #D3A447; --pei-deep: #E8C072; --stage: #16191E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --plate: #111317; --sheet: #1A1D23; --ink: #ECEEF1; --muted: #9AA1AC;
  --rule: #2B3038; --field: #22262D; --pei: #D3A447; --pei-deep: #E8C072; --stage: #16191E;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--plate);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
}
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

/* ---------- Topo ---------- */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  padding: 16px var(--gutter);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; fill: var(--ink); }
.brand-mark .trace { fill: none; stroke: var(--ferramenta, var(--pei)); stroke-width: 2.6; stroke-linecap: round; }
.brand-name {
  display: flex; align-items: baseline; gap: 8px;
  font-family: var(--display);
  font-variation-settings: "wdth" 125;
  font-weight: 800;
  font-size: 24px;
  line-height: 1;
}
.brand-sub { font-variation-settings: "wdth" 62; font-weight: 500; font-size: 17px; color: var(--muted); }


/* ---------- Estúdio ---------- */
.studio {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 380px;
  gap: 14px;
  padding: 0 var(--gutter) var(--gutter);
  min-height: 0;
}
@media (min-width: 821px) {
  /* barra, faixa de camadas, convite para a Gestão (às vezes), cabeçalho, estúdio: o estúdio fica sempre na última linha */
  body { display: grid; grid-template-rows: auto auto auto auto minmax(560px, 1fr); height: 100dvh; }
  body > .studio { grid-row: -2; }
}

/* Catálogo */
.catalog { display: flex; flex-direction: column; gap: 8px; min-width: 0; overflow: auto; }
.piece {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 4px 12px;
  align-items: start;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s;
}
.piece:hover { border-color: var(--muted); }
.piece[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--acento); }
.piece svg {
  grid-row: span 2;
  width: 36px; height: 36px;
  padding: 4px;
  border-radius: 6px;
  background: var(--field);
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.piece[aria-pressed="true"] svg { background: var(--acento); stroke: #fff; }
.piece-name { font-weight: 700; font-size: 14px; line-height: 1.25; }
.piece-blurb { font-size: 12.5px; color: var(--muted); line-height: 1.35; }

/* Palco 3D */
.stage {
  position: relative;
  min-width: 0;
  border-radius: var(--radius);
  background: var(--stage);
  border: 1px solid var(--rule);
  overflow: hidden;
}
.viewport { position: absolute; inset: 0; }
.viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stage-status {
  position: absolute;
  left: 14px; top: 14px;
  margin: 0;
  max-width: calc(100% - 28px - 280px);
  padding: 6px 10px;
  border-radius: 5px;
  background: var(--sheet);
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.stage-status:empty { display: none; }
.stage-status.is-error { background: var(--loss); color: #fff; }
.stage-tools { position: absolute; right: 12px; top: 12px; display: flex; gap: 4px; }
.tool {
  border: 1px solid var(--rule);
  background: var(--sheet);
  color: var(--ink);
  border-radius: 5px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.tool:hover { border-color: var(--muted); }
.stage-size {
  position: absolute;
  left: 14px; bottom: 12px;
  margin: 0;
  padding: 4px 9px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--sheet);
  font-family: var(--mono);
  font-variation-settings: "wdth" 87.5;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.stage-size:empty { display: none; }

/* Painel */
.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  overflow: hidden;
}
.panel-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--rule); }
.panel-title {
  margin: 0;
  font-family: var(--display);
  font-variation-settings: "wdth" 112;
  font-weight: 800;
  font-size: 22px;
  line-height: 1.15;
}
.panel-blurb { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

.params { flex: 1; overflow: auto; padding: 4px 20px 16px; }
.section { margin: 0; padding: 14px 0 4px; border: 0; border-bottom: 1px solid var(--rule); min-width: 0; }
.section:last-child { border-bottom: 0; }
.section-title {
  float: left; width: 100%;
  margin: 0 0 10px; padding: 0;
  font-family: var(--display);
  font-variation-settings: "wdth" 125;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.section-title + * { clear: both; }

.param { display: grid; gap: 5px; margin-bottom: 12px; min-width: 0; }
.param-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.param-label { font-size: 13px; font-weight: 500; color: var(--muted); }

.text-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
.text-input:focus { outline: none; border-color: var(--acento); background: var(--sheet); }

/* Número: régua + valor editável */
.number { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 10px; align-items: center; }
.number input[type="range"] { width: 100%; accent-color: var(--acento); }
.number-box {
  display: flex; align-items: center; gap: 4px;
  height: 34px; padding: 0 8px;
  border-radius: var(--radius);
  background: var(--field);
  border: 1px solid transparent;
}
.number-box:focus-within { border-color: var(--acento); background: var(--sheet); }
.number-box input {
  width: 100%; min-width: 0;
  border: 0; background: transparent; color: var(--ink);
  font-family: var(--mono); font-variation-settings: "wdth" 87.5; font-size: 13px;
  text-align: right; outline: none;
}
.number-box i { font-style: normal; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }

/* Opções segmentadas */
.segments { display: flex; flex-wrap: wrap; gap: 6px; }
.segments label { position: relative; flex: 1 1 auto; cursor: pointer; }
.segments input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segments span {
  display: block;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}
.segments label:hover span { border-color: var(--muted); }
.segments input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.segments input:focus-visible + span { outline: 2px solid var(--acento); outline-offset: 2px; }

/* Fontes: cada nome escrito na própria fonte */
.fonts { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.fonts label { position: relative; cursor: pointer; }
.fonts input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.fonts span {
  display: grid;
  place-items: center;
  height: 46px;
  padding: 0 6px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: 19px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
}
.fonts small { display: block; font-family: var(--body); font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.fonts label:hover span { border-color: var(--muted); }
.fonts input:checked + span { border-color: var(--ink); box-shadow: inset 0 -3px 0 var(--acento); }
.fonts input:focus-visible + span { outline: 2px solid var(--acento); outline-offset: 2px; }

/* Cores: carretéis de filamento */
.spools { display: flex; flex-wrap: wrap; gap: 6px; }
.spools label { position: relative; cursor: pointer; }
.spools input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.spool {
  display: block;
  width: 30px; height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--sheet) 0 3.5px, var(--ink) 3.5px 5px, transparent 5px),
    repeating-radial-gradient(circle, var(--c) 0 1.6px, color-mix(in srgb, var(--c) 82%, #000) 1.6px 2.2px);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
  transition: transform .12s;
}
.spools label:hover .spool { transform: scale(1.08); }
.spools input:checked + .spool { box-shadow: 0 0 0 2px var(--sheet), 0 0 0 4px var(--ink); }
.spools input:focus-visible + .spool { outline: 2px solid var(--acento); outline-offset: 4px; }
.spool-name { font-size: 12.5px; color: var(--ink); font-weight: 600; }

/* Liga/desliga */
.toggle { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch {
  flex: none;
  position: relative;
  width: 38px; height: 22px;
  border-radius: 99px;
  background: var(--rule);
  transition: background .15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--sheet);
  transition: transform .15s;
}
.toggle input:checked + .switch { background: var(--acento); }
.toggle input:checked + .switch::after { transform: translateX(16px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--acento); outline-offset: 2px; }

/* Nota do QR */
.note { margin: 0 20px 12px; padding: 12px; border-radius: var(--radius); background: var(--field); }
.note-head { display: flex; justify-content: space-between; align-items: baseline; }
.note-label { font-size: 12.5px; font-weight: 700; }
.note-text {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-variation-settings: "wdth" 75;
  font-size: 11px;
  line-height: 1.5;
  word-break: break-all;
  max-height: 64px;
  overflow: auto;
}
.note-hint { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }

/* Saída */
.output { padding: 14px 20px 16px; border-top: 1px solid var(--rule); background: var(--sheet); }
.usage { display: grid; gap: 4px; margin: 0 0 12px; }
.usage div { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 13px; }
.usage dt { margin: 0; }
.usage dd {
  margin: 0;
  font-family: var(--mono);
  font-variation-settings: "wdth" 87.5;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.usage .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.usage .total { padding-top: 6px; margin-top: 2px; border-top: 1px solid var(--rule); font-weight: 700; }
.usage .total dd { font-size: 14px; color: var(--pei-deep); font-weight: 600; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { grid-column: 1 / -1; background: var(--ink); border-color: var(--ink); color: var(--sheet); }
.btn-primary:hover { background: var(--pei-deep); border-color: var(--pei-deep); color: #fff; }
.btn-ghost { border-style: dashed; }
.fine { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.45; }

.link {
  border: 0; background: none; padding: 0;
  color: var(--muted); font: inherit; font-size: 12.5px;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.link:hover { color: var(--ink); }

/* ---------- Arte enviada ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.arte { display: grid; gap: 8px; }
.arte-nome { margin: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arte-envio { display: grid; place-items: center; padding: 12px; border: 1.5px dashed var(--rule); border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 600; }
.arte-envio:hover, .arte-envio:focus-within { border-color: var(--pei, var(--ink)); }
.arte-exemplos { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; font-size: 12.5px; color: var(--muted); }
.arte-dica { margin: 0; font-size: 11.5px; color: var(--muted); }

/* ---------- Telas menores ---------- */
@media (max-width: 1180px) {
  .studio { grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: auto minmax(0, 1fr); }
  .catalog { grid-column: 1 / -1; flex-direction: row; overflow-x: auto; padding-bottom: 2px; }
  .piece { flex: 0 0 240px; }
}
@media (max-width: 820px) {
  .studio { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .stage { height: 56vh; min-height: 300px; flex: none; }
  .panel { overflow: visible; }
  .params { overflow: visible; }
  .output { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .stage-status { max-width: calc(100% - 28px); top: 54px; }
  .piece { flex-basis: 200px; }
  .piece-blurb { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .spool, .switch, .switch::after { transition: none; }
}
