.model-section {
  position: relative;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% 15%, rgba(155, 132, 90, .15), transparent 34rem),
    linear-gradient(180deg, #ece8dd 0%, #f4f1e9 100%);
}

.model-section::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: .36;
  background-image:
    linear-gradient(rgba(21, 23, 26, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 23, 26, .04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
}

.model-shell {
  position: relative;
  z-index: 1;
  overflow: hidden;
  contain: layout paint;
  border: 1px solid rgba(21, 23, 26, .16);
  border-radius: 2px;
  background: #171b1c;
  box-shadow: 0 26px 80px rgba(21, 23, 26, .16);
}

.model-canvas {
  position: relative;
  min-height: clamp(480px, 67vw, 780px);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 35%, rgba(126, 139, 130, .32), transparent 36%),
    linear-gradient(160deg, #1d2425 0%, #101516 70%, #0b0f10 100%);
  touch-action: none;
}

.model-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.model-canvas canvas:active {
  cursor: grabbing;
}

.model-loading,
.model-error {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  display: grid;
  width: min(330px, calc(100% - 48px));
  gap: 12px;
  padding: 22px;
  color: var(--paper);
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(14, 15, 16, .78);
  backdrop-filter: blur(12px);
  transform: translate(-50%, -50%);
}

.model-loading.is-hidden {
  pointer-events: none;
  opacity: 0;
  transition: opacity .45s ease;
}

.model-loading-label,
.model-error span {
  color: rgba(244, 241, 233, .64);
  font: 500 11px/1.5 Manrope, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.model-loading strong {
  font: 500 clamp(34px, 5vw, 62px)/1 "Playfair Display", serif;
}

.model-loading-track {
  display: block;
  height: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, .14);
}

.model-loading-track i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--paper);
  transform: translateX(-100%);
  transition: transform .2s ease;
}

.model-error[hidden] {
  display: none;
}

.model-hint {
  position: absolute;
  z-index: 3;
  right: 20px;
  bottom: 18px;
  padding: 9px 12px;
  color: rgba(244, 241, 233, .72);
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(14, 15, 16, .46);
  backdrop-filter: blur(8px);
  font: 500 10px/1.35 Manrope, sans-serif;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.model-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
  color: var(--paper);
  border-top: 1px solid rgba(255, 255, 255, .1);
}

.model-toolbar p {
  max-width: 680px;
  margin: 6px 0 0;
  color: rgba(244, 241, 233, .58);
  font-size: 13px;
}

.model-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.model-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.model-button {
  min-height: 42px;
  padding: 0 14px;
  color: var(--paper);
  border: 1px solid rgba(244, 241, 233, .24);
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  font: 600 11px/1 Manrope, sans-serif;
  letter-spacing: .06em;
  transition: color .25s ease, border-color .25s ease, background .25s ease;
}

.model-button:hover,
.model-button:focus-visible {
  color: var(--ink);
  border-color: var(--paper);
  outline: none;
  background: var(--paper);
}

@media (max-width: 760px) {
  .model-canvas {
    min-height: clamp(420px, 68svh, 540px);
  }

  .model-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .model-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .model-hint {
    right: 12px;
    bottom: 12px;
    left: 12px;
    text-align: center;
  }

  .model-section::before {
    background-size: 32px 32px;
  }

  .model-loading,
  .model-error {
    width: calc(100% - 32px);
    padding: 18px;
    backdrop-filter: none;
  }

  .model-toolbar p {
    font-size: 12px;
    line-height: 1.55;
  }

  .model-button {
    min-height: 46px;
    padding: 0 10px;
    font-size: 10px;
  }
}

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

  .model-canvas {
    min-height: 410px;
  }

  .model-hint {
    font-size: 9px;
    letter-spacing: .06em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .model-loading-track i,
  .model-button {
    transition: none;
  }
}
