#overlay {
  padding: max(54px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  gap: 0;
}

#overlay h1 {
  font-size: clamp(1.65rem, 5vw, 2.2rem);
  flex-shrink: 0;
}

#overlay .subtitle {
  margin-bottom: 20px;
  text-align: center;
  font-size: .88rem;
  line-height: 1.5;
  flex-shrink: 0;
}

#av-texture-panel {
  width: min(520px, 100%);
  max-height: min(680px, 72dvh);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 24px;
  border: 1px solid #30314c;
  border-radius: 16px;
  background: linear-gradient(160deg, #16172c, #101123);
  box-shadow: 0 18px 70px #0005;
  color: #e9eafa;
  line-height: 1.55;
  scrollbar-width: thin;
  scrollbar-color: #555b83 #101123;
}

#av-texture-panel[hidden],
#av-original-files[hidden],
#av-original-start[hidden] {
  display: none !important;
}

#av-texture-panel .av-eyebrow {
  color: #95a5f4;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
  margin: 0 0 7px;
}

#av-texture-panel h2 {
  color: #fff;
  margin: 0 0 10px;
  font-size: 1.35rem;
  letter-spacing: -.02em;
  line-height: 1.25;
}

#av-texture-panel p {
  margin: 0 0 16px;
  color: #bfc3dd;
  font-size: .9rem;
}

#av-texture-panel .av-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

#av-texture-panel button {
  width: 100%;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 11px 14px;
  color: #fff;
  background: #566be3;
  font: 600 .9rem/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s ease, border-color .15s ease;
}

#av-texture-panel button:hover {
  background: #657aec;
}

#av-texture-panel button:disabled {
  opacity: .6;
  cursor: progress;
}

#av-texture-panel #av-original-start {
  background: #263954;
  border-color: #48617c;
}

#av-texture-panel #av-original-start:hover {
  background: #314765;
}

#av-texture-panel #av-included-start {
  background: #191c33;
  border-color: #373c59;
  color: #c4c9e2;
  font-weight: 500;
}

#av-texture-panel #av-included-start:hover {
  background: #232741;
  border-color: #555e87;
}

#av-texture-panel .av-private {
  font-size: .76rem;
  color: #9299b8;
  margin: 11px 0 17px;
  text-align: center;
}

#av-texture-status {
  min-height: 1.5em;
  color: #afc2ff;
  font-size: .84rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  margin-bottom: 16px;
}

#av-texture-status:empty {
  min-height: 0;
  margin-bottom: 0;
}

#av-texture-status[data-tone='error'],
#av-texture-status.error {
  color: #ffb0ba;
}

#av-texture-status[data-tone='success'] {
  color: #a8e5ce;
}

#av-texture-panel details {
  border-top: 1px solid #2c3048;
  padding-top: 15px;
  color: #bfc3dd;
  font-size: .82rem;
}

#av-texture-panel summary {
  cursor: pointer;
  color: #d4daf5;
  font-weight: 600;
  padding: 3px 0;
  touch-action: manipulation;
}

#av-texture-panel details[open] summary {
  margin-bottom: 10px;
}

#av-texture-panel ol {
  margin: 0 0 13px;
  padding-left: 21px;
}

#av-texture-panel li + li {
  margin-top: 9px;
}

#av-texture-panel details p {
  margin: 0;
  font-size: .8rem;
}

#av-texture-panel a {
  color: #a6baff;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

#av-texture-panel code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #252943;
  color: #e1e8ff;
  font-size: .94em;
}

#av-open-textures {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(64px + env(safe-area-inset-left));
  z-index: 110;
  width: 60px;
  height: 34px;
  padding: 0 5px;
  border: 1px solid #59638788;
  border-radius: 8px;
  background: #11182ee6;
  color: #dce4ff;
  font: 600 10px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 2px 8px #0004;
}

#av-open-textures:hover {
  background: #243158;
}

#av-texture-panel button:focus-visible,
#av-texture-panel a:focus-visible,
#av-texture-panel summary:focus-visible,
#av-open-textures:focus-visible {
  outline: 2px solid #a6baff;
  outline-offset: 3px;
}

@media (max-width: 540px) {
  #av-texture-panel {
    padding: 19px;
    border-radius: 13px;
  }

  #overlay .subtitle {
    margin-bottom: 14px;
  }

  #av-texture-panel h2 {
    font-size: 1.2rem;
  }
}

@media (max-height: 560px) {
  #overlay {
    padding-top: max(50px, env(safe-area-inset-top));
    padding-bottom: 12px;
  }

  #overlay h1 {
    font-size: 1.35rem;
  }

  #overlay .subtitle {
    font-size: .75rem;
    margin-bottom: 9px;
  }

  #av-texture-panel {
    max-height: calc(100dvh - 132px);
    padding: 16px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #av-texture-panel button {
    transition: none;
  }
}
