/* ═══════════════════════════════════════════════════════════
   FORJA 3D — estúdio de peças generativas
   ═══════════════════════════════════════════════════════════ */

@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("../assets/fonts/space-grotesk-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #07080a;
  --bg-elev: #0b0d11;
  --panel: #0d0f14;
  --panel-2: #11141a;
  --panel-3: #151922;
  --line: rgba(255, 255, 255, 0.072);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #eef0f4;
  --text-soft: #c6cad3;
  --muted: #8a919e;
  --muted-2: #7c8492;
  --lime: #d6f84c;
  --lime-soft: #e8ff8a;
  --lime-dim: rgba(214, 248, 76, 0.12);
  --lime-line: rgba(214, 248, 76, 0.32);
  --blue: #7aa2ff;
  --amber: #ffb35c;
  --danger: #ff7a6b;
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(0.22, 0.75, 0.25, 1);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: var(--lime); color: #101205; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:disabled { cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
  border-radius: 4px;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #23272f; border-radius: 8px; border: 2px solid var(--panel); }
::-webkit-scrollbar-thumb:hover { background: #313641; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Screen-reader only: keeps the site name and headings in the accessible tree */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Skip link: hidden until keyboard focus, then pinned above the topbar */
.skip-link {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 200;
  transform: translate(-50%, -220%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--lime);
  color: #101205;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  transition: transform 0.18s ease;
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translate(-50%, 0);
  outline: 3px solid #101205;
  outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  .skip-link { transition: none; }
}

.ico {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] { display: none !important; }

/* Skip-link target: focus should not draw a box around the whole workspace */
#studio:focus { outline: none; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

/* ═══════════════ TOPBAR ═══════════════ */

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 62px;
  flex: none;
  padding: 0 20px;
  background: rgba(8, 9, 12, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 232px;
}
.brand-mark { width: 28px; height: 28px; }
.brand-word {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
}
.brand-word span { color: var(--lime); margin-left: 1px; }
.brand-tag {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 2px 7px;
  transform: translateY(1px);
}

.mainnav { display: flex; align-items: center; gap: 4px; }
.navlink {
  position: relative;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.01em;
  transition: color 0.18s, background 0.18s;
}
.navlink:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.navlink.is-active { color: var(--text); }
.navlink.is-active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 1px;
  height: 2px;
  border-radius: 2px;
  background: var(--lime);
  box-shadow: 0 0 12px rgba(214, 248, 76, 0.5);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 99px;
}
.local-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
}

.credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 11px;
  color: var(--muted);
}
.credit-pill .ico { width: 13px; height: 13px; color: var(--lime); }
.credit-pill b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); background: rgba(255, 255, 255, 0.05); }

.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #17190d;
  background: linear-gradient(135deg, var(--lime-soft), #9fc92c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.only-mobile { display: none; }

/* ═══════════════ WORKSPACE ═══════════════ */

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 316px minmax(0, 1fr) 344px;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
}
.panel-left { border-right: 1px solid var(--line); }
.panel-right { border-left: 1px solid var(--line); position: relative; }

.panel-scroll,
.analysis-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.panel-scroll { padding: 18px 18px 26px; }

.sect { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.sect:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }

.sect-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.sect-head h2 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.005em;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--lime);
  border: 1px solid var(--lime-line);
  background: rgba(214, 248, 76, 0.06);
  border-radius: 99px;
  padding: 3px 7px;
  white-space: nowrap;
}
.tag.muted { color: var(--muted-2); border-color: var(--line); background: transparent; }
.tag-dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }

/* ── Dropzone ── */

.dropzone {
  position: relative;
  height: 164px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  overflow: hidden;
  background:
    radial-gradient(90% 90% at 50% 0%, rgba(214, 248, 76, 0.055), transparent 65%),
    #0a0c10;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  outline: none;
}
.dropzone:hover,
.dropzone:focus-visible { border-color: rgba(214, 248, 76, 0.42); }
.dropzone.is-dragover {
  border-color: var(--lime);
  background: radial-gradient(90% 90% at 50% 0%, rgba(214, 248, 76, 0.14), transparent 70%), #0b0e09;
  transform: scale(1.005);
}
.dz-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 16px;
  border-radius: var(--radius);
}
.dz-empty:focus-visible { outline: 2px solid var(--lime); outline-offset: -6px; }
.dz-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 5px;
  border-radius: 11px;
  color: var(--lime);
  background: rgba(214, 248, 76, 0.08);
  border: 1px solid rgba(214, 248, 76, 0.18);
}
.dz-icon .ico { width: 17px; height: 17px; }
.dz-empty strong { font-size: 12.5px; font-weight: 500; color: var(--text-soft); }
.dz-sub { font-size: 10.5px; color: var(--muted-2); }
.dz-or { font-size: 10.5px; color: var(--muted); margin-top: 6px; }
.dz-or u { color: var(--lime); text-decoration: none; border-bottom: 1px solid rgba(214, 248, 76, 0.45); }

.dz-preview { position: absolute; inset: 0; background: #0a0c10; }
.dz-preview::before {
  content: "";
  position: absolute;
  inset: -26px;
  z-index: 0;
  background-image: var(--ref-bg, none);
  background-size: cover;
  background-position: center;
  filter: blur(26px) saturate(0.8) brightness(0.55);
  opacity: 0.7;
  transform: scale(1.06);
}
.dz-preview img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.42));
}
.dz-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(to top, rgba(4, 5, 7, 0.72), transparent 42%);
  pointer-events: none;
}
.dz-badge {
  position: absolute;
  top: 9px;
  left: 9px;
  z-index: 2;
  font-size: 8.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #101205;
  background: var(--lime);
  padding: 3px 7px;
  border-radius: 99px;
  font-weight: 600;
}
.dz-badge.is-file { background: rgba(10, 12, 16, 0.76); color: var(--text); border: 1px solid var(--line-strong); backdrop-filter: blur(8px); }
.dz-actions {
  position: absolute;
  z-index: 2;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
}
.mini-btn {
  height: 26px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 10.5px;
  color: #0f1105;
  background: var(--lime-soft);
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: filter 0.15s;
}
.mini-btn:hover { filter: brightness(1.08); }
.mini-btn.ghost {
  display: grid;
  place-items: center;
  width: 27px;
  padding: 0;
  color: var(--text-soft);
  background: rgba(10, 12, 16, 0.7);
  border-color: var(--line-strong);
  backdrop-filter: blur(8px);
}
.mini-btn.ghost .ico { width: 13px; height: 13px; }

.dz-scan {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  top: 0;
  height: 28%;
  opacity: 0;
  background: linear-gradient(to bottom, transparent, rgba(214, 248, 76, 0.22), rgba(214, 248, 76, 0.5), transparent);
  border-bottom: 1px solid rgba(214, 248, 76, 0.8);
  pointer-events: none;
}
.dropzone.is-scanning .dz-scan { opacity: 1; animation: scan 1.4s var(--ease) infinite; }
@keyframes scan {
  0% { transform: translateY(-30%); opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(360%); opacity: 0; }
}

.samples {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 11px;
}
.samples-label { font-size: 10px; color: var(--muted-2); white-space: nowrap; }
.sample-row { display: flex; gap: 6px; flex: 1; }
.sample-btn {
  position: relative;
  width: 46px;
  height: 38px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  padding: 0;
  background: #0a0c10;
  transition: border-color 0.18s, transform 0.18s;
}
.sample-btn img { width: 100%; height: 100%; object-fit: cover; opacity: 0.82; transition: opacity 0.18s, transform 0.3s; }
.sample-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.sample-btn:hover img { opacity: 1; transform: scale(1.06); }
.sample-btn.is-active { border-color: var(--lime-line); box-shadow: 0 0 0 1px rgba(214, 248, 76, 0.22); }
.sample-btn.is-active img { opacity: 1; }

/* ── Prompt ── */

.field { position: relative; }
.field textarea {
  width: 100%;
  resize: none;
  padding: 10px 11px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #0a0c10;
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field textarea::placeholder { color: var(--muted-2); }
.field textarea:focus {
  outline: none;
  border-color: rgba(214, 248, 76, 0.45);
  box-shadow: 0 0 0 3px rgba(214, 248, 76, 0.07);
}
.field-foot {
  position: absolute;
  left: 11px;
  right: 10px;
  bottom: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: var(--muted-2);
  pointer-events: none;
}
.field-foot #promptHint { color: var(--lime); opacity: 0; transition: opacity 0.2s; }
.field-foot #promptHint.is-on { opacity: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 4px 8px;
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); background: rgba(255, 255, 255, 0.03); }

/* ── Controls ── */

.control { display: block; margin-bottom: 14px; }
.control:last-of-type { margin-bottom: 12px; }
.control-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 11px;
  color: var(--muted);
}
.control-label b {
  font-weight: 500;
  font-size: 10px;
  color: var(--text-soft);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.select-wrap { position: relative; display: block; }
select {
  appearance: none;
  width: 100%;
  height: 38px;
  padding: 0 32px 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #0a0c10;
  color: var(--text-soft);
  font-size: 11.5px;
  cursor: pointer;
  outline: none;
}
select:hover { border-color: var(--line-strong); }
select:focus { border-color: rgba(214, 248, 76, 0.45); }
.select-chev {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}
select option { background: #10131a; }

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0a0c10;
}
.segmented button {
  height: 27px;
  border-radius: 7px;
  font-size: 10.5px;
  color: var(--muted);
  transition: color 0.16s, background 0.16s, box-shadow 0.16s;
}
.segmented button:hover { color: var(--text-soft); }
.segmented button.is-active {
  color: var(--lime);
  background: rgba(214, 248, 76, 0.1);
  box-shadow: inset 0 0 0 1px rgba(214, 248, 76, 0.2);
}

.range-control input[type="range"] {
  appearance: none;
  width: 100%;
  height: 16px;
  background: transparent;
  padding: 0;
  margin: 0;
}
.range-control input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--lime) var(--val, 50%), #22262e var(--val, 50%));
}
.range-control input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: #22262e;
}
.range-control input[type="range"]::-moz-range-progress {
  height: 3px;
  border-radius: 3px;
  background: var(--lime);
}
.range-control input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--lime-soft);
  border: 3px solid #0a0c10;
  box-shadow: 0 0 0 1px rgba(214, 248, 76, 0.55), 0 0 10px rgba(214, 248, 76, 0.25);
  transition: transform 0.15s;
}
.range-control input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.range-control input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--lime-soft);
  border: 3px solid #0a0c10;
  box-shadow: 0 0 0 1px rgba(214, 248, 76, 0.55);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 12px;
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative;
  width: 29px;
  height: 17px;
  border-radius: 99px;
  background: #1d2129;
  border: 1px solid var(--line);
  transition: background 0.18s, border-color 0.18s;
  flex: none;
}
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #6a7280;
  transition: transform 0.18s var(--ease), background 0.18s;
}
.switch input:checked + .switch-track { background: rgba(214, 248, 76, 0.18); border-color: var(--lime-line); }
.switch input:checked + .switch-track .switch-knob { transform: translateX(12px); background: var(--lime); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--lime); outline-offset: 2px; }

.seed-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.018);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  transition: border-color 0.16s, color 0.16s;
}
.seed-row:hover { border-color: var(--line); color: var(--muted); }
.seed-row code {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  margin-left: auto;
}
.seed-row .ico { width: 12px; height: 12px; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--muted);
  padding: 2px;
  transition: color 0.16s;
}
.link-btn:hover { color: var(--lime); }
.link-btn .ico { width: 12px; height: 12px; }
.link-btn.subtle { color: var(--muted-2); }
.link-btn.subtle:hover { color: var(--text-soft); }

/* ── Generate ── */

.generate-sect { padding-top: 2px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.005em;
  transition: transform 0.16s var(--ease), background 0.18s, border-color 0.18s, box-shadow 0.18s, filter 0.18s;
}
.btn .ico { width: 15px; height: 15px; }
.btn-block { width: 100%; }

.btn-primary {
  height: 46px;
  color: #0e1004;
  font-weight: 600;
  font-size: 13px;
  background: linear-gradient(135deg, #efffa0 0%, #d6f84c 48%, #b8e42e 100%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 26px rgba(180, 220, 50, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(180, 220, 50, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  filter: saturate(1.05);
}
.btn-primary:active { transform: translateY(0) scale(0.995); }
.btn-primary .cost {
  margin-left: auto;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--lime-soft);
  background: rgba(12, 15, 5, 0.82);
}
.btn-primary .ico:first-child { color: #2a3507; }
.btn-primary.is-busy { pointer-events: none; filter: grayscale(0.12); }
.btn-primary.is-busy .ico:first-child { animation: spin 1.6s linear infinite; }

.btn-secondary {
  margin-top: 7px;
  height: 40px;
  color: var(--text-soft);
  border: 1px solid var(--line);
  background: #10131a;
}
.btn-secondary:hover { border-color: var(--line-strong); background: #151922; color: var(--text); }
.btn-secondary .ico { color: var(--muted); }

.btn-outline {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}
.btn-outline:hover { border-color: rgba(214, 248, 76, 0.45); background: rgba(214, 248, 76, 0.06); }
.btn-outline .chev { margin-left: auto; color: var(--muted); width: 14px; height: 14px; }

@keyframes spin { to { transform: rotate(360deg); } }

.hint {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 9px;
  font-size: 9.5px;
  line-height: 1.4;
  color: var(--muted-2);
}
.hint .ico { width: 11px; height: 11px; color: rgba(214, 248, 76, 0.65); margin-top: 1px; }

/* ═══════════════ STAGE ═══════════════ */

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: 50px;
  flex: none;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 17, 0.65);
}
.piece-id {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
}
.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px rgba(214, 248, 76, 0.7);
  animation: pulse 2.6s ease-in-out infinite;
  flex: none;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.piece-name {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.piece-code {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted-2);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.example-tag {
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 2px 6px;
  white-space: nowrap;
}

.stage-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 10px;
  color: var(--muted);
  transition: color 0.16s, background 0.16s;
}
.tool-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.tool-btn.is-active { color: var(--lime); background: rgba(214, 248, 76, 0.09); }
.tool-btn .ico { width: 14px; height: 14px; }
.tool-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }

.viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(85% 70% at 68% 8%, #1a1f27 0%, transparent 62%),
    radial-gradient(60% 55% at 24% 78%, rgba(94, 112, 64, 0.1) 0%, transparent 70%),
    radial-gradient(90% 90% at 50% 100%, #0b0d11 0%, #07080a 70%);
}
.viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 130px 30px rgba(0, 0, 0, 0.55);
}
.viewport canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  z-index: 1;
}
.viewport canvas:active { cursor: grabbing; }

.viewport-hud {
  position: absolute;
  z-index: 3;
  display: flex;
  gap: 5px;
  pointer-events: none;
}
.hud-left { left: 14px; top: 14px; flex-wrap: wrap; }
.hud-right { right: 14px; top: 14px; }
.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 25px;
  padding: 0 9px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(9, 11, 15, 0.55);
  backdrop-filter: blur(10px);
  font-size: 9.5px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.hud-key { font-size: 8px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); }
.hud-pill b { font-weight: 500; }
.hud-pill.accent { border-color: rgba(214, 248, 76, 0.2); }
.hud-pill.accent b { color: var(--lime); }
.hud-pill.ghost { color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; font-size: 8.5px; }

.axis-widget {
  position: absolute;
  z-index: 3;
  right: 22px;
  bottom: 24px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(9, 11, 15, 0.4);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.axis-widget .axis {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 7.5px;
  color: var(--muted);
}
.axis-y { left: 24px; top: 5px; color: var(--lime) !important; }
.axis-x { right: 7px; bottom: 12px; }
.axis-z { left: 7px; bottom: 12px; }
.axis-origin {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--muted-2);
}
.axis-widget::before,
.axis-widget::after {
  content: "";
  position: absolute;
  background: var(--line-strong);
}
.axis-widget::before { left: 26px; top: 14px; width: 1px; height: 28px; }
.axis-widget::after { left: 12px; top: 34px; width: 30px; height: 1px; }

.orbit-hint {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 13px;
  transform: translateX(-50%);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.22);
  white-space: nowrap;
  pointer-events: none;
}

.drop-hint {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 46px;
  transform: translate(-50%, 10px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 99px;
  border: 1px dashed rgba(214, 248, 76, 0.5);
  background: rgba(10, 13, 8, 0.85);
  color: var(--lime);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  backdrop-filter: blur(10px);
}
.viewport.is-dragging .drop-hint { opacity: 1; transform: translate(-50%, 0); }
.drop-hint .ico { width: 15px; height: 15px; }

/* ── Pipeline overlay ── */

.pipeline {
  position: absolute;
  z-index: 6;
  left: 16px;
  bottom: 16px;
  width: 286px;
  padding: 13px 14px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(9, 11, 15, 0.88);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(18px);
  animation: pipe-in 0.35s var(--ease);
}
@keyframes pipe-in { from { opacity: 0; transform: translateY(10px); } }
.pipe-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.pipe-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.pipe-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime);
  animation: pulse 1.2s ease-in-out infinite;
}
.pipe-head b {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--lime);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.pipe-bar {
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
  margin-bottom: 11px;
}
.pipe-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(to right, #a8d81f, var(--lime));
  box-shadow: 0 0 12px rgba(214, 248, 76, 0.6);
  transition: width 0.45s var(--ease);
}
.pipe-stages { display: grid; gap: 2px; }
.pipe-stages li {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 17px;
  font-size: 10px;
  color: var(--muted-2);
  transition: color 0.25s;
}
.pipe-stages li i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #2b3038;
  flex: none;
  transition: background 0.25s, box-shadow 0.25s;
}
.pipe-stages li.is-active { color: var(--text); }
.pipe-stages li.is-active i { background: var(--lime); box-shadow: 0 0 8px var(--lime); animation: pulse 0.9s ease-in-out infinite; }
.pipe-stages li.is-done { color: var(--muted); }
.pipe-stages li.is-done i { background: rgba(214, 248, 76, 0.55); }
.pipe-log {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 8.5px;
  line-height: 1.45;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pipe-log span { color: var(--muted); }

/* ── Stage foot / history ── */

.stage-foot {
  flex: none;
  height: 92px;
  border-top: 1px solid var(--line);
  background: rgba(10, 12, 16, 0.6);
  padding: 10px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.history-wrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.history-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.history-head b {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 500;
  color: var(--text-soft);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 1px 5px;
}
.history-head .link-btn { margin-left: auto; letter-spacing: 0.08em; }
.history {
  display: flex;
  gap: 6px;
  min-height: 49px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.history-empty {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  border: 1px dashed rgba(255, 255, 255, 0.09);
  border-radius: 9px;
  padding: 0 12px;
  font-size: 10px;
  color: var(--muted-2);
}
.history-item {
  position: relative;
  flex: none;
  width: 70px;
  height: 47px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  padding: 0;
  background: #0a0c10;
  transition: border-color 0.18s, transform 0.18s;
}
.history-item img { width: 100%; height: 100%; object-fit: cover; opacity: 0.82; transition: opacity 0.2s, transform 0.3s; }
.history-item span {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 2px;
  font-family: var(--font-mono);
  font-size: 6.5px;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 1px 3px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.history-item:hover img { opacity: 1; }
.history-item.is-active { border-color: var(--lime); box-shadow: 0 0 0 1px rgba(214, 248, 76, 0.3); }
.history-item.is-active img { opacity: 1; }

/* ═══════════════ RIGHT PANEL ═══════════════ */

.analysis-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 17px 18px 13px;
  flex: none;
}
.analysis-head h2 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
}
.ai-mark {
  font-size: 8px;
  letter-spacing: 0.1em;
  color: #131604;
  background: var(--lime);
  border-radius: 3px;
  padding: 2px 4px;
  font-family: var(--font);
  font-weight: 700;
}
.analysis-sub {
  display: block;
  margin-top: 3px;
  font-size: 9.5px;
  color: var(--muted-2);
}

.analysis-scroll { padding: 0 18px 18px; }

.confidence-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(214, 248, 76, 0.07), transparent 58%),
    #0b0d12;
  position: relative;
  overflow: hidden;
}
.ring-wrap { position: relative; width: 64px; height: 64px; flex: none; }
.ring { width: 64px; height: 64px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #23272f; stroke-width: 5; }
.ring-fg {
  fill: none;
  stroke: var(--lime);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 188.5;
  stroke-dashoffset: 188.5;
  transition: stroke-dashoffset 1s var(--ease), stroke 0.3s;
  filter: drop-shadow(0 0 5px rgba(214, 248, 76, 0.45));
}
.ring-wrap b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ring-wrap b small { font-size: 8px; color: var(--muted); margin-left: 1px; }
.confidence-copy { min-width: 0; }
.confidence-label {
  display: block;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lime);
  margin-bottom: 3px;
}
.confidence-copy p { font-size: 10px; line-height: 1.45; color: var(--muted); }

.analysis-summary {
  margin: 12px 0 16px;
  font-size: 11px;
  line-height: 1.55;
  color: var(--muted);
  padding-left: 9px;
  border-left: 2px solid rgba(214, 248, 76, 0.35);
}
.analysis-summary strong { color: var(--text-soft); font-weight: 500; }

.a-sect { padding: 14px 0; border-top: 1px solid var(--line); }
.a-sect:first-child { border-top: 0; padding-top: 0; }
.a-sect h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 500;
  margin-bottom: 10px;
}
.a-note { font-size: 8px; letter-spacing: 0.02em; text-transform: none; color: rgba(255, 255, 255, 0.55); }

.class-list { display: grid; gap: 9px; }
.class-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: baseline; }
.class-row .class-name { font-size: 10.5px; color: var(--muted); }
.class-row .class-pct { font-family: var(--font-mono); font-size: 9px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.class-row .class-bar {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 3px;
  background: #1b1f27;
  overflow: hidden;
}
.class-row .class-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: #3a404b;
  transition: width 0.8s var(--ease), background 0.3s;
}
.class-row.top .class-name { color: var(--text); font-weight: 500; }
.class-row.top .class-pct { color: var(--lime); }
.class-row.top .class-bar span { background: linear-gradient(to right, rgba(214, 248, 76, 0.55), var(--lime)); }
.class-row.is-forced .class-name::after {
  content: "forçado";
  font-size: 7px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--lime);
  border: 1px solid var(--lime-line);
  border-radius: 3px;
  padding: 1px 3px;
  margin-left: 5px;
  vertical-align: 1px;
}

.skeleton-row {
  height: 21px;
  border-radius: 5px;
  background: linear-gradient(90deg, #14171d 25%, #1b1f27 50%, #14171d 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.silhouette-card {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
  height: 124px;
}
.mask-wrap, .profile-wrap {
  position: relative;
  background:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px) 0 0 / 100% 20px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px) 0 0 / 20px 100%,
    #090b0f;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.mask-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.mask-empty {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.profile-wrap svg { width: 100%; height: 100%; }
.profile-axis {
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-family: var(--font-mono);
  font-size: 6.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.18);
}

.metric-list { display: grid; gap: 8px; }
.metric-row {
  display: grid;
  grid-template-columns: 60px 1fr 30px;
  align-items: center;
  gap: 8px;
  font-size: 9.5px;
  color: var(--muted);
}
.metric-row .metric-val {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--text-soft);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.metric-track { height: 3px; border-radius: 3px; background: #1b1f27; overflow: hidden; }
.metric-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(to right, #5d6a35, var(--lime));
  transition: width 0.9s var(--ease);
}

.palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.swatch { min-width: 0; }
.swatch-chip {
  height: 34px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 0.18s;
}
.swatch:hover .swatch-chip { transform: translateY(-2px); }
.swatch-code {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 6.5px;
  letter-spacing: 0.02em;
  color: var(--muted-2);
  text-transform: uppercase;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}
.swatch:first-child .swatch-chip { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.26); }
.swatch:first-child .swatch-code { color: var(--text-soft); }

.material-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a0c11;
}
.material-sphere {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.85), transparent 28%),
    radial-gradient(circle at 62% 70%, rgba(0, 0, 0, 0.5), transparent 60%),
    radial-gradient(circle at 40% 35%, #8d949c, #3a4048 68%, #15181d);
  box-shadow: inset -4px -6px 12px rgba(0, 0, 0, 0.55), inset 3px 4px 10px rgba(255, 255, 255, 0.16);
}
.material-copy { min-width: 0; display: grid; gap: 1px; }
.material-copy strong { font-size: 11px; font-weight: 500; color: var(--text-soft); }
.material-copy span { font-size: 9px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.material-pbr { margin-left: auto; display: flex; gap: 8px; }
.material-pbr span { display: grid; gap: 1px; text-align: right; }
.material-pbr i { font-style: normal; font-size: 6.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-2); }
.material-pbr b { font-family: var(--font-mono); font-size: 9px; font-weight: 500; color: var(--text-soft); font-variant-numeric: tabular-nums; }

.console {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.055);
  background: #07090c;
  padding: 8px 9px;
  font-family: var(--font-mono);
  font-size: 8px;
  line-height: 1.6;
  color: var(--muted);
  max-height: 98px;
  overflow: hidden;
}
.console div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.console .c-k { color: var(--lime); }
.console .c-muted { color: var(--muted-2); }
.console .c-warn { color: var(--amber); }

.analysis-foot {
  position: relative;
  flex: none;
  padding: 11px 18px 14px;
  border-top: 1px solid var(--line);
  background: rgba(9, 11, 15, 0.72);
}
.analysis-foot .btn { height: 40px; }

.export-menu {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 60px;
  z-index: 10;
  padding: 5px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: #0e1117;
  box-shadow: var(--shadow);
  animation: menu-in 0.18s var(--ease);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(5px) scale(0.99); } }
.export-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border-radius: 7px;
  text-align: left;
  transition: background 0.15s;
}
.export-menu button:hover { background: rgba(255, 255, 255, 0.05); }
.export-menu button span { display: grid; gap: 1px; }
.export-menu b { font-size: 10.5px; font-weight: 500; }
.export-menu i { font-style: normal; font-size: 8.5px; color: var(--muted-2); }
.export-menu small { font-family: var(--font-mono); font-size: 8px; color: var(--muted-2); }
.export-menu button:hover small { color: var(--lime); }

/* ═══════════════ MODALS ═══════════════ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 6, 0.72);
  backdrop-filter: blur(7px);
  animation: fade-in 0.2s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal-card {
  position: relative;
  width: min(880px, 100%);
  max-height: min(84vh, 900px);
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(#10131a, #0c0e13);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.65);
  animation: modal-in 0.3s var(--ease);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(0.99); } }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-head p { margin-top: 4px; font-size: 11px; color: var(--muted); max-width: 580px; }
.eyebrow {
  display: block;
  margin-bottom: 6px;
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--lime);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 18px 24px 22px;
}
.gallery-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: #0a0c10;
  transition: border-color 0.18s, transform 0.18s;
}
.gallery-item:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.gallery-thumb {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  border: 0;
  padding: 0;
  display: block;
  background: #0a0c10;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb .gallery-open {
  position: absolute;
  inset: auto 8px 8px auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(9, 11, 15, 0.8);
  border: 1px solid var(--line-strong);
  font-size: 8.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.18s, transform 0.18s;
  backdrop-filter: blur(8px);
}
.gallery-thumb:hover .gallery-open { opacity: 1; transform: none; }
.gallery-meta { padding: 8px 9px 9px; }
.gallery-meta strong {
  display: block;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-size: 8px;
  color: var(--muted-2);
}
.gallery-meta span b { font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.04em; color: var(--muted); }
.gallery-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 62px 24px;
  text-align: center;
}
.gallery-empty.is-on { display: flex; }
.gallery-empty .ico { width: 28px; height: 28px; color: var(--muted-2); margin-bottom: 4px; }
.gallery-empty strong { font-size: 13px; font-weight: 500; }
.gallery-empty span { font-size: 10.5px; color: var(--muted-2); }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  font-size: 9.5px;
  color: var(--muted-2);
}
.modal-foot .btn { height: 34px; font-size: 11px; }

.how-card { width: min(760px, 100%); }
.how-steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  margin: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.how-steps li {
  display: flex;
  gap: 11px;
  padding: 14px;
  background: #0c0e13;
}
.how-num {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: rgba(214, 248, 76, 0.5);
  line-height: 1.1;
  flex: none;
}
.how-steps b { display: block; font-size: 11px; font-weight: 500; color: var(--text-soft); }
.how-steps p { margin-top: 3px; font-size: 9.5px; line-height: 1.5; color: var(--muted-2); }
.how-note { display: flex; align-items: center; gap: 6px; max-width: 520px; line-height: 1.45; }
.how-note .ico { color: var(--amber); flex: none; }
.how-card .btn-primary { height: 34px; font-size: 11px; box-shadow: none; }

/* ═══════════════ TOASTS ═══════════════ */

.toasts {
  position: fixed;
  z-index: 200;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: rgba(13, 16, 21, 0.94);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px);
  font-size: 11px;
  color: var(--text-soft);
  animation: toast-in 0.3s var(--ease);
  white-space: nowrap;
}
.toast::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
}
.toast.is-error::before { background: #ff7a6b; box-shadow: 0 0 8px rgba(255, 122, 107, 0.8); }
.toast.is-error { border-color: rgba(255, 122, 107, 0.3); }
.toast.is-out { animation: toast-out 0.25s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

body.modal-open { overflow: hidden; }

.webgl-fallback {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 30px;
  text-align: center;
  background: radial-gradient(80% 80% at 50% 40%, #14181f, #07080a);
}
.webgl-fallback strong { font-family: var(--font-display); font-size: 15px; color: var(--text); }
.webgl-fallback span { max-width: 340px; font-size: 11px; line-height: 1.6; color: var(--muted); }

/* ═══════════════ RESPONSIVE ═══════════════ */

@media (max-width: 1440px) {
  .workspace { grid-template-columns: 300px minmax(0, 1fr) 330px; }
  .brand { min-width: 214px; }
}

@media (max-width: 1240px) {
  .workspace { grid-template-columns: 286px minmax(0, 1fr) 312px; }
  .tool-btn span { display: none; }
  .tool-btn { width: 30px; justify-content: center; padding: 0; }
  .local-badge { display: none; }
  .brand-tag { display: none; }
  .panel-scroll { padding: 16px 15px 22px; }
  .analysis-scroll { padding: 0 15px 16px; }
  .analysis-head { padding: 15px 15px 12px; }
  .analysis-foot { padding: 10px 15px 13px; }
  .export-menu { left: 15px; right: 15px; }
  .stage { border-left: 0; }
}

@media (max-width: 1080px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .topbar { position: sticky; top: 0; }
  .workspace {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }
  .stage { order: 1; height: 66vh; min-height: 460px; border-bottom: 1px solid var(--line); }
  .panel-left { order: 2; border-right: 0; border-bottom: 1px solid var(--line); }
  .panel-right { order: 3; border-left: 0; }
  .panel-scroll, .analysis-scroll { overflow: visible; }
  .panel-right { min-height: 0; }
  .only-mobile { display: grid; }
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
  .analysis-scroll { padding-bottom: 20px; }
  .silhouette-card { height: 210px; }
}

@media (max-width: 720px) {
  .topbar { height: 54px; padding: 0 13px; gap: 10px; }
  .brand { min-width: 0; }
  .brand-mark { width: 24px; height: 24px; }
  .brand-word { font-size: 14px; }
  .mainnav { display: none; }
  .credit-pill span { display: none; }
  .avatar { display: none; }
  .workspace { display: flex; flex-direction: column; }
  .stage { height: 60vh; min-height: 400px; }
  .stage-head { padding: 0 10px 0 13px; }
  .piece-code { display: none; }
  .example-tag { display: none; }
  .stage-tools { gap: 0; }
  .tool-btn { width: 27px; height: 27px; }
  .tool-sep { display: none; }
  .viewport-hud.hud-right { display: none; }
  .hud-left .hud-pill:nth-child(2) { display: none; }
  .pipeline { left: 10px; right: 10px; width: auto; bottom: 10px; padding: 11px 12px; }
  .pipe-stages { grid-template-columns: 1fr 1fr; gap: 1px 10px; }
  .pipe-stages li { font-size: 9px; height: 16px; }
  .pipe-stages li:nth-child(7) { grid-column: 1 / -1; }
  .axis-widget { right: 12px; bottom: 84px; width: 46px; height: 46px; transform: scale(0.92); }
  .orbit-hint { display: none; }
  .stage-foot { height: 86px; padding: 8px 12px 10px; }
  .panel-scroll { padding: 15px 14px 22px; }
  .analysis-head, .analysis-scroll, .analysis-foot { padding-left: 14px; padding-right: 14px; }
  .export-menu { left: 14px; right: 14px; }
  .modal { padding: 10px; }
  .modal-card { max-height: 92vh; border-radius: 14px; }
  .modal-head { padding: 18px 16px 14px; }
  .modal-head h2 { font-size: 17px; }
  .modal-foot { padding: 12px 16px; flex-direction: column; align-items: stretch; gap: 10px; }
  .modal-foot .btn { width: 100%; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); padding: 14px 16px 18px; gap: 9px; }
  .how-steps { grid-template-columns: 1fr; margin: 14px 16px; }
  .how-card .modal-head p { font-size: 10px; }
  .toasts { bottom: 12px; width: calc(100% - 24px); }
  .toast { white-space: normal; text-align: center; border-radius: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
