:root {
  --bg: #07110d;
  --panel: rgba(10, 24, 17, .92);
  --panel2: rgba(14, 35, 23, .92);
  --line: rgba(112, 255, 154, .18);
  --text: #eaffef;
  --muted: #8db79b;
  --accent: #62ff90;
  --accent2: #1f9d55;
  --danger: #ff6b6b;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 25% 20%, rgba(62, 255, 132, .12), transparent 32%),
    radial-gradient(circle at 80% 70%, rgba(18, 111, 60, .20), transparent 35%),
    var(--bg);
}
button, input, select {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0,0,0,.28);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  font: inherit;
}
input, select { width: 100%; }
input:focus, select:focus, button:focus-visible {
  border-color: rgba(98,255,144,.65);
  box-shadow: 0 0 0 3px rgba(98,255,144,.08);
}
button {
  cursor: pointer;
  background: linear-gradient(180deg, rgba(47, 140, 78, .95), rgba(19, 82, 43, .95));
  font-weight: 700;
}
button:disabled, select:disabled { opacity: .48; cursor: not-allowed; }
.app { min-height: 100%; }
.is-hidden { display: none !important; }

.gallery-view {
  min-height: 100vh;
  padding: 26px;
  overflow: auto;
}
.hero {
  max-width: 1280px;
  margin: 0 auto 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, var(--panel), rgba(4, 12, 8, .86));
  box-shadow: 0 20px 60px rgba(0,0,0,.24);
}
.brand { display: flex; gap: 14px; align-items: center; min-width: 260px; }
.brand__logo {
  width: 52px; height: 52px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 16px;
  color: #06110b; background: linear-gradient(135deg, var(--accent), #b6ffd0);
  font-weight: 900; box-shadow: 0 0 30px rgba(98,255,144,.2);
  flex: 0 0 auto;
}
h1 { font-size: 24px; margin: 0 0 4px; }
p { margin: 0; color: var(--muted); }
.field { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.hero__actions {
  display: flex;
  align-items: end;
  gap: 10px;
  width: min(560px, 100%);
}
.hero__search { flex: 1 1 auto; min-width: 240px; }
.scan-button { flex: 0 0 auto; white-space: nowrap; }
.model-grid {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}
.model-card {
  padding: 0;
  overflow: hidden;
  text-align: left;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(8, 22, 14, .76);
  transition: transform .14s ease, border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
.model-card:hover, .model-card.active {
  transform: translateY(-2px);
  border-color: rgba(98,255,144,.55);
  background: rgba(17, 47, 28, .78);
  box-shadow: 0 16px 44px rgba(0,0,0,.28);
}
.model-card__preview {
  position: relative;
  overflow: hidden;
  height: 240px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(98,255,144,.10), transparent 54%),
    linear-gradient(180deg, rgba(9, 28, 17, .34), rgba(4, 14, 9, .20));
  border-bottom: 1px solid var(--line);
}
.model-card__preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: 0;
  object-position: center bottom;
  mix-blend-mode: normal;
}
.preview-missing {
  margin: 14px;
  padding: 18px 14px;
  border: 1px dashed rgba(98,255,144,.35);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  line-height: 1.35;
}
.model-card.no-preview .model-card__preview::after {
  content: 'Требуется сделать preview';
  margin: 14px;
  padding: 18px 14px;
  border: 1px dashed rgba(98,255,144,.35);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}
.model-card__body { position: relative; z-index: 2; padding: 14px; background: rgba(8, 22, 14, .98); }
.model-card b { display: block; margin-bottom: 6px; font-size: 15px; }
.model-card span { color: var(--muted); font-size: 13px; line-height: 1.45; }
.empty-card, .gallery-status {
  max-width: 1280px;
  margin: 18px auto 0;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(0,0,0,.18);
}
.gallery-status.error { color: #ffd0d0; border-color: rgba(255,107,107,.35); }

.viewer-view {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    radial-gradient(circle at 25% 20%, rgba(62, 255, 132, .10), transparent 32%),
    var(--bg);
}
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 12, 8, .86);
  backdrop-filter: blur(8px);
  z-index: 3;
}
.toolbar__left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 240px;
}
.toolbar__left > div { display: grid; gap: 4px; }
.toolbar__left span { color: var(--muted); font-size: 13px; }
.toolbar__right {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.toolbar label {
  color: var(--muted);
  font-size: 12px;
  display: grid;
  gap: 5px;
  min-width: 145px;
}
.toolbar label:first-child { min-width: 210px; }
.toolbar button { width: auto; min-width: 86px; height: 41px; }
.ghost-button {
  background: rgba(0,0,0,.22);
  color: var(--text);
  border-color: rgba(112,255,154,.26);
}
.preview-button {
  background: linear-gradient(180deg, rgba(126, 255, 170, .95), rgba(36, 128, 66, .95));
  color: #031008;
}
.viewer { position: relative; overflow: hidden; min-height: 0; }
.viewer canvas { display: block; width: 100%; height: 100%; }
.controls-hint {
  position: absolute;
  left: 18px;
  top: 96px;
  z-index: 2;
  color: var(--muted);
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(2, 10, 6, .72);
  pointer-events: none;
}
.status {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 2;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(2, 10, 6, .82);
  color: var(--muted);
  box-shadow: 0 8px 35px rgba(0,0,0,.25);
  pointer-events: none;
}
.status.error { color: #ffd0d0; border-color: rgba(255,107,107,.35); }
@media (max-width: 900px) {
  .gallery-view { padding: 14px; }
  .hero { flex-direction: column; align-items: stretch; }
  .hero__actions { width: 100%; flex-direction: column; align-items: stretch; }
  .hero__search { width: 100%; min-width: 0; }
  .scan-button { width: 100%; }
  .model-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .model-card__preview { height: 190px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar__left { align-items: flex-start; flex-wrap: wrap; }
  .toolbar__right { justify-content: stretch; }
  .toolbar label { min-width: 0; flex: 1 1 150px; }
  .controls-hint { display: none; }
}

.mesh-debug {
  position: absolute;
  right: 18px;
  top: 92px;
  z-index: 4;
  width: min(440px, calc(100vw - 36px));
  max-height: calc(100vh - 130px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(2, 10, 6, .93);
  box-shadow: 0 16px 50px rgba(0,0,0,.35);
}
.mesh-debug__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.mesh-debug__head button,
.mesh-debug__row button {
  min-width: 0;
  height: auto;
  padding: 6px 8px;
  border-radius: 9px;
  font-size: 12px;
}
.mesh-debug p {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.35;
}
.mesh-debug__list {
  display: grid;
  gap: 8px;
}
.mesh-debug__row {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px;
  border: 1px solid rgba(112, 255, 154, .14);
  border-radius: 12px;
  background: rgba(255,255,255,.03);
}
.mesh-debug__row label {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 58px;
  color: var(--text);
}
.mesh-debug__row input {
  width: auto;
}
.mesh-debug__row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.mesh-debug__row b,
.mesh-debug__row small,
.mesh-debug__row em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mesh-debug__row small {
  color: var(--muted);
  font-size: 11px;
}
.mesh-debug__row em {
  color: var(--accent);
  font-style: normal;
  font-size: 12px;
}
@media (max-width: 900px) {
  .mesh-debug { top: 160px; left: 12px; right: 12px; width: auto; }
}

.mesh-debug__tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 8px 0 10px;
  padding: 8px;
  border: 1px solid rgba(112, 255, 154, .14);
  border-radius: 12px;
  background: rgba(98,255,144,.04);
}
.mesh-debug__tools label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-size: 13px;
}
.mesh-debug__tools input {
  width: auto;
}
.mesh-debug__tools button {
  min-width: 0;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12px;
}
@media (max-width: 900px) {
  .mesh-debug__tools { grid-template-columns: 1fr; }
}

.mesh-debug__tools--uv {
  grid-template-columns: repeat(3, 1fr) auto;
}
@media (max-width: 900px) {
  .mesh-debug__tools--uv { grid-template-columns: 1fr; }
}

.mesh-debug__tools--uv {
  grid-template-columns: repeat(3, minmax(90px, 1fr)) minmax(120px, auto);
}
.mesh-debug__tools--uv label {
  min-width: 0;
}
.mesh-debug__tools--uv input[type="range"] {
  width: 100%;
  padding: 0;
  accent-color: var(--accent);
}
.mesh-debug__tools--uv select {
  min-width: 86px;
  padding: 7px 9px;
  border-radius: 10px;
}
.mesh-debug__tools--uv span[data-uv-read] {
  color: var(--accent);
  font-size: 12px;
  justify-self: end;
}
.mesh-debug__buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  grid-column: 1 / -1;
}
@media (max-width: 900px) {
  .mesh-debug__tools--uv { grid-template-columns: 1fr; }
  .mesh-debug__buttons { justify-content: stretch; flex-direction: column; }
}

.mesh-debug__field {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(112, 255, 154, .14);
  border-radius: 12px;
  background: rgba(255,255,255,.02);
}
.mesh-debug__field > span {
  font-size: 12px;
  color: var(--muted);
}
.mesh-debug__field-controls {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  gap: 6px;
  align-items: center;
}
.mesh-debug__field-controls input[type="number"] {
  min-width: 0;
  width: 100%;
  text-align: center;
  padding: 8px 6px;
}
.mesh-debug__field-controls button {
  min-width: 0;
  padding: 8px 0;
}
.mesh-debug__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}
.mesh-debug__quick button {
  min-width: 0;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12px;
}
.mesh-debug__step {
  align-self: start;
}
.mesh-debug__tools--uv {
  grid-template-columns: repeat(4, minmax(90px, 1fr));
}
@media (max-width: 900px) {
  .mesh-debug__tools--uv {
    grid-template-columns: 1fr;
  }
}

/* v16: more organized UV debug panel */
.mesh-debug {
  width: min(520px, calc(100vw - 36px));
}
.mesh-debug__tools--uv {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.mesh-debug__section {
  padding: 10px;
  border: 1px solid rgba(112, 255, 154, .14);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}
.mesh-debug__section-title {
  color: var(--accent);
  font-weight: 800;
  font-size: 12px;
  margin-bottom: 8px;
}
.mesh-debug__checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}
.mesh-debug__checks label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.mesh-debug__checks input {
  width: auto;
}
.mesh-debug__row-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.mesh-debug__row-controls label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}
.mesh-debug__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.mesh-debug__field {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid rgba(112, 255, 154, .12);
  border-radius: 12px;
  background: rgba(0,0,0,.14);
}
.mesh-debug__field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.mesh-debug__field-controls {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  gap: 6px;
}
.mesh-debug__field-controls input[type="number"] {
  min-width: 0;
  width: 100%;
  padding: 7px 6px;
  text-align: center;
  border-radius: 9px;
}
.mesh-debug__field-controls button {
  min-width: 0;
  padding: 7px 0;
  border-radius: 9px;
}
.mesh-debug__field input[type="range"] {
  width: 100%;
  padding: 0;
  accent-color: var(--accent);
}
.mesh-debug__quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.mesh-debug__quick button {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
}
.mesh-debug__buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.mesh-debug__buttons button {
  min-width: 0;
  padding: 9px 12px;
}
@media (max-width: 900px) {
  .mesh-debug__checks,
  .mesh-debug__row-controls,
  .mesh-debug__fields,
  .mesh-debug__quick {
    grid-template-columns: 1fr;
  }
  .mesh-debug__buttons {
    flex-direction: column;
  }
}

.mesh-debug__section-title span { color: var(--text); }
.mesh-debug__target-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.mesh-debug__target-actions button { min-width: 0; padding: 7px 10px; border-radius: 10px; font-size: 12px; }
.mesh-debug__row { grid-template-columns: auto auto auto auto 1fr; }
.mesh-debug__row button.active {
  border-color: rgba(98,255,144,.8);
  box-shadow: 0 0 0 2px rgba(98,255,144,.12) inset;
  color: #06110b;
  background: linear-gradient(180deg, rgba(126, 255, 170, .95), rgba(65, 190, 96, .95));
}
@media (max-width: 900px) {
  .mesh-debug__row { grid-template-columns: auto auto auto auto; }
  .mesh-debug__row > div { grid-column: 1 / -1; }
}

.mesh-debug__checks label:nth-last-child(-n+2) {
  color: #c8ffd7;
}

.model-details {
  position: absolute;
  left: 18px;
  top: 96px;
  z-index: 2;
  width: min(360px, calc(100vw - 36px));
  max-height: calc(100vh - 110px);
  overflow: auto;
  pointer-events: auto;
}
.model-details__card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    radial-gradient(circle at 20% 0%, rgba(98,255,144,.10), transparent 35%),
    rgba(2, 10, 6, .84);
  box-shadow: 0 16px 45px rgba(0,0,0,.34);
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.model-details__head {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(98,255,144,.055);
  display: grid;
  gap: 3px;
}
.model-details__head b {
  font-size: 15px;
}
.model-details__head span {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-details__section {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(112,255,154,.11);
}
.model-details__section h3 {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.price-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.price-grid > div {
  padding: 10px;
  border: 1px solid rgba(112,255,154,.14);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
}
.price-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}
.price-grid b {
  font-size: 18px;
  color: var(--text);
}
.model-details ul {
  margin: 0;
  padding-left: 17px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.42;
}
.model-details li + li {
  margin-top: 5px;
}
.skin-legend {
  display: grid;
  gap: 7px;
}
.skin-legend__row {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 9px;
  align-items: start;
  padding: 8px;
  border: 1px solid rgba(112,255,154,.12);
  border-radius: 12px;
  background: rgba(0,0,0,.14);
}
.skin-legend__row > span {
  color: #06110b;
  background: linear-gradient(135deg, var(--accent), #b6ffd0);
  border-radius: 9px;
  padding: 5px 7px;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}
.skin-legend__row b {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}
.skin-legend__row small {
  display: block;
  color: var(--muted);
  line-height: 1.3;
  font-size: 12px;
}
.model-details__controls {
  padding: 11px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.model-details__controls span {
  padding: 5px 7px;
  border: 1px solid rgba(112,255,154,.13);
  border-radius: 999px;
  background: rgba(255,255,255,.03);
  color: var(--muted);
  font-size: 11px;
}

.model-share-link {
  display: block;
  padding: 9px 10px;
  border: 1px solid rgba(112,255,154,.16);
  border-radius: 12px;
  background: rgba(0,0,0,.18);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  word-break: break-all;
}
.model-share-link:hover {
  border-color: rgba(112,255,154,.38);
  background: rgba(112,255,154,.06);
}
.model-share-note {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

#setDefaultSeqButton {
  background: rgba(0,0,0,.22);
  color: var(--text);
  border-color: rgba(112,255,154,.26);
}
@media (max-width: 900px) {
  .model-details {
    left: 12px;
    right: 12px;
    top: 96px;
    width: auto;
    max-height: 46vh;
  }
  .price-grid {
    grid-template-columns: 1fr;
  }
  .skin-legend__row {
    grid-template-columns: 64px 1fr;
  }
}

.viewer-control-hints {
  position: absolute;
  z-index: 2;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  max-width: min(760px, calc(100vw - 420px));
  pointer-events: none;
}
.viewer-control-hints span {
  padding: 7px 10px;
  border: 1px solid rgba(112,255,154,.16);
  border-radius: 999px;
  background: rgba(2, 10, 6, .72);
  color: var(--muted);
  font-size: 12px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
@media (max-width: 1200px) {
  .viewer-control-hints {
    max-width: min(680px, calc(100vw - 36px));
    top: 90px;
  }
}
@media (max-width: 900px) {
  .viewer-control-hints {
    top: 82px;
    left: 12px;
    right: 12px;
    transform: none;
    max-width: none;
  }
  .viewer-control-hints span {
    font-size: 11px;
    padding: 6px 8px;
  }
}

/* v22: final UI polish for native selects/dropdowns */
select,
input[type="search"],
input[type="number"] {
  color-scheme: dark;
}

select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  color: var(--text);
  border: 1px solid rgba(112, 255, 154, .28);
  background:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%) calc(100% - 18px) 50% / 6px 6px no-repeat,
    linear-gradient(135deg, var(--accent) 50%, transparent 50%) calc(100% - 13px) 50% / 6px 6px no-repeat,
    radial-gradient(circle at 0 0, rgba(98,255,144,.10), transparent 42%),
    rgba(2, 12, 7, .92);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.025),
    0 8px 22px rgba(0,0,0,.18);
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

select:hover {
  border-color: rgba(112, 255, 154, .48);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.035),
    0 0 0 3px rgba(98,255,144,.08),
    0 10px 26px rgba(0,0,0,.22);
}

select:focus {
  outline: none;
  border-color: rgba(112, 255, 154, .78);
  box-shadow:
    0 0 0 3px rgba(98,255,144,.16),
    0 12px 30px rgba(0,0,0,.24);
}

select:disabled {
  opacity: .48;
  cursor: not-allowed;
}

/* Стилизация пунктов работает не во всех браузерах одинаково, но в Chrome/Edge обычно помогает. */
select option {
  color: #eaffef;
  background: #06140c;
}

select option:checked,
select option:hover {
  color: #06110b;
  background: #70ff9a;
}

.toolbar label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toolbar__right select {
  min-width: 190px;
  padding-right: 38px;
}

#skinSelect {
  min-width: 140px;
}

#sequenceSelect {
  min-width: 210px;
}

button,
.ghost-button,
.preview-button,
.scan-button {
  transition: transform .14s ease, box-shadow .18s ease, border-color .18s ease, filter .18s ease;
}

button:hover,
.ghost-button:hover,
.preview-button:hover,
.scan-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button:active,
.ghost-button:active,
.preview-button:active,
.scan-button:active {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(98,255,144,.18),
    0 8px 28px rgba(0,0,0,.24);
}

/* Scrollbars in model lists / panels */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(112,255,154,.55) rgba(3,12,7,.85);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: rgba(3,12,7,.82);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(112,255,154,.75), rgba(34,145,69,.75));
  border: 2px solid rgba(3,12,7,.82);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(145,255,180,.95), rgba(48,190,82,.95));
}

.model-card,
.model-details__card,
.mesh-debug,
.toolbar,
.status,
.viewer-control-hints span {
  backdrop-filter: blur(10px);
}

.model-card {
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.model-card:hover {
  transform: translateY(-3px);
  border-color: rgba(112,255,154,.52);
  box-shadow:
    0 18px 45px rgba(0,0,0,.28),
    0 0 0 1px rgba(112,255,154,.08) inset;
}

.model-card.active {
  border-color: rgba(112,255,154,.72);
  box-shadow:
    0 0 0 2px rgba(112,255,154,.14) inset,
    0 20px 48px rgba(0,0,0,.34);
}

/* More compact toolbar on medium widths */
@media (max-width: 1400px) {
  .toolbar__right select {
    min-width: 160px;
  }
  #sequenceSelect {
    min-width: 180px;
  }
}

/* v23: public build + mobile adaptation */
.is-hidden {
  display: none !important;
}

@media (max-width: 900px) {
  html, body {
    min-height: 100%;
    overflow-x: hidden;
  }

  .app {
    min-height: 100dvh;
  }

  .gallery-view {
    padding: 14px;
  }

  .hero {
    display: grid;
    gap: 14px;
    padding: 14px;
    border-radius: 22px;
  }

  .brand {
    gap: 10px;
  }

  .brand__logo {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    font-size: 16px;
  }

  .brand h1 {
    font-size: 22px;
    line-height: 1.05;
  }

  .brand p {
    font-size: 13px;
    line-height: 1.35;
  }

  .hero__actions {
    display: grid;
    gap: 10px;
    width: 100%;
  }

  .hero__search {
    min-width: 0;
  }

  .model-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
  }

  .model-card {
    border-radius: 18px;
    min-height: 0;
  }

  .model-card__preview {
    height: 180px;
  }

  .model-card__body {
    padding: 11px;
  }

  .model-card__body b {
    font-size: 13px;
  }

  .model-card__body span {
    font-size: 11px;
    line-height: 1.25;
  }

  .viewer-view {
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
  }

  .toolbar {
    position: relative;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px 12px;
    max-height: 44dvh;
    overflow: auto;
  }

  .toolbar__left {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
  }

  .toolbar__left .ghost-button {
    height: 40px;
    min-width: 0;
    padding: 0 12px;
    border-radius: 13px;
    white-space: nowrap;
  }

  .toolbar__left strong {
    font-size: 15px;
  }

  .toolbar__left span {
    font-size: 12px;
  }

  .toolbar__right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    align-items: end;
  }

  .toolbar__right label {
    min-width: 0;
    display: grid;
    gap: 5px;
  }

  .toolbar__right select,
  #skinSelect,
  #sequenceSelect {
    min-width: 0;
    width: 100%;
    height: 40px;
    padding: 0 34px 0 11px;
    border-radius: 13px;
    font-size: 12px;
  }

  #modelSelect {
    grid-column: auto;
  }

  #playButton,
  #resetCameraButton {
    height: 40px;
    min-width: 0;
    width: 100%;
    padding: 0 10px;
    border-radius: 13px;
    font-size: 12px;
  }

  .viewer {
    min-height: 0;
    height: auto;
    width: 100%;
  }

  .viewer canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
  }

  .viewer-control-hints {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    transform: none;
    max-width: none;
    justify-content: center;
    gap: 6px;
    z-index: 3;
  }

  .viewer-control-hints span {
    font-size: 10.5px;
    padding: 5px 7px;
    background: rgba(2, 10, 6, .78);
  }

  .model-details {
    position: absolute;
    top: auto;
    bottom: 68px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 34dvh;
    z-index: 3;
  }

  .model-details__card {
    border-radius: 18px;
  }

  .model-details__head {
    padding: 10px 12px;
  }

  .model-details__section {
    padding: 10px 12px;
  }

  .model-details__section h3 {
    margin-bottom: 7px;
    font-size: 11px;
  }

  .price-grid {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }

  .price-grid > div {
    padding: 8px;
    border-radius: 12px;
  }

  .price-grid b {
    font-size: 15px;
  }

  .skin-legend {
    gap: 6px;
  }

  .skin-legend__row {
    grid-template-columns: 58px 1fr;
    gap: 7px;
    padding: 7px;
  }

  .skin-legend__row > span {
    padding: 5px 6px;
    font-size: 10.5px;
  }

  .skin-legend__row b {
    font-size: 12px;
  }

  .skin-legend__row small {
    font-size: 11px;
  }

  .status {
    left: 12px;
    right: 12px;
    bottom: 12px;
    transform: none;
    width: auto;
    text-align: center;
    font-size: 12px;
    padding: 8px 10px;
    display: none;
  }
}

@media (max-width: 520px) {
  .model-grid {
    grid-template-columns: 1fr;
  }

  .model-card__preview {
    height: 220px;
  }

  .toolbar__right {
    grid-template-columns: 1fr;
  }

  .toolbar {
    max-height: 52dvh;
  }

  .model-details {
    max-height: 30dvh;
  }

  .viewer-control-hints {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .toolbar {
    max-height: 55dvh;
  }
  .model-details {
    display: none;
  }
  .viewer-control-hints {
    display: none;
  }
}

/* v24: mobile layout fix — model first, info below, no overlay */
@media (max-width: 900px) {
  .viewer-view {
    display: block;
    min-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .toolbar {
    position: relative;
    max-height: none;
    overflow: visible;
    border-bottom: 1px solid var(--line);
  }

  .toolbar__right {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar__right label:first-child {
    grid-column: 1 / -1;
  }

  .viewer {
    height: 44dvh;
    min-height: 320px;
    max-height: 520px;
    border-bottom: 1px solid rgba(112,255,154,.12);
  }

  .model-details {
    position: static;
    width: auto;
    max-height: none;
    margin: 12px;
    overflow: visible;
  }

  .model-details__card {
    max-height: none;
  }

  .viewer-control-hints {
    position: static;
    transform: none;
    max-width: none;
    margin: 10px 12px 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
  }

  .status {
    position: static;
    display: block;
    margin: 10px 12px 0;
    transform: none;
    width: auto;
  }
}

@media (max-width: 520px) {
  .toolbar {
    padding: 10px;
  }

  .toolbar__right {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .toolbar__right label:first-child,
  .toolbar__right label:nth-child(3) {
    grid-column: 1 / -1;
  }

  #playButton,
  #resetCameraButton {
    grid-column: auto;
  }

  .viewer {
    height: 42dvh;
    min-height: 300px;
  }

  .model-details {
    margin: 10px;
  }

  .price-grid {
    grid-template-columns: 1fr 1fr;
  }

  .viewer-control-hints {
    display: flex;
    flex-wrap: wrap;
  }

  .viewer-control-hints span {
    font-size: 10px;
    padding: 5px 7px;
  }
}

@media (max-width: 380px) {
  .toolbar__right {
    grid-template-columns: 1fr;
  }

  .toolbar__right label:first-child,
  .toolbar__right label:nth-child(3) {
    grid-column: auto;
  }

  .price-grid {
    grid-template-columns: 1fr;
  }

  .viewer {
    min-height: 280px;
  }
}

/* v25: mobile status under toolbar, cleaner controls */
.mobile-status {
  display: none;
}

@media (max-width: 900px) {
  .status {
    display: none !important;
  }

  .viewer-control-hints {
    display: none !important;
  }

  .mobile-status {
    display: block;
    margin: 10px 12px 0;
    padding: 9px 12px;
    border: 1px solid rgba(112,255,154,.16);
    border-radius: 14px;
    background: rgba(2, 10, 6, .72);
    color: var(--muted);
    text-align: center;
    font-size: 12px;
    line-height: 1.35;
    backdrop-filter: blur(8px);
  }

  .mobile-status.error {
    border-color: rgba(255, 90, 90, .4);
    color: #ffd0d0;
  }

  #playButton,
  #resetCameraButton {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
  }
}

@media (max-width: 520px) {
  #playButton,
  #resetCameraButton {
    height: 42px;
  }
}

/* v26: compact mobile toolbar */
@media (max-width: 900px) {
  .toolbar__right {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .toolbar__right label:nth-child(1) {
    grid-column: 1 / -1;
  }

  .toolbar__right label:nth-child(2),
  .toolbar__right label:nth-child(3) {
    grid-column: auto;
  }

  .toolbar__right label {
    gap: 4px;
  }

  .toolbar__right label span,
  .toolbar label {
    font-size: 12px;
  }

  #skinSelect,
  #sequenceSelect,
  #playButton,
  #resetCameraButton {
    height: 40px;
  }

  #playButton,
  #resetCameraButton {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .toolbar__right {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar__right label:nth-child(1) {
    grid-column: 1 / -1;
  }

  .toolbar__right label:nth-child(2),
  .toolbar__right label:nth-child(3) {
    grid-column: auto !important;
  }

  #playButton,
  #resetCameraButton {
    grid-column: auto !important;
    width: 100%;
  }

  #modelSelect,
  #skinSelect,
  #sequenceSelect {
    font-size: 13px;
  }
}

@media (max-width: 380px) {
  .toolbar__right {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar__right label:nth-child(1) {
    grid-column: 1 / -1;
  }

  .toolbar__right label:nth-child(2),
  .toolbar__right label:nth-child(3),
  #playButton,
  #resetCameraButton {
    grid-column: auto !important;
  }
}
