/* Sideload-inspired minimalist style */
:root {
  color-scheme: dark;
  --color-primary: #00FF88;
  --color-primary-hover: #00CC6E;
  --color-bg-primary: #0C0C0C;
  --color-bg-secondary: #0A0A0A;
  --color-bg-tertiary: #1A1A1A;
  --color-bg-modal: #080808;
  --color-text-primary: #FFFFFF;
  --color-text-secondary: #8A8A8A;
  --color-text-tertiary: #6A6A6A;
  --color-border-primary: #1A1A1A;
  --color-border-accent: rgba(0, 255, 136, 0.25);
}

/* Supply font */
@font-face {
  font-family: 'Supply';
  src: url('/fonts/Supply.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

html, body { height: 100%; }
body {
  margin: 0;
  padding: 1.25rem 1rem 2rem;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-family: 'Supply', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Noto Sans", Arial, sans-serif;
  overflow-x: hidden;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* Selection */
::selection {
  background-color: rgba(0, 255, 136, 0.3);
  color: var(--color-text-primary);
}

/* Layout */
header {
  max-width: 920px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  z-index: 10;
}
header h1 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1;
  background: linear-gradient(90deg, #fff, var(--color-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

main {
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  gap: 1.5rem;
  position: relative;
  z-index: 10;
}

/* Panels/Sections */
.panel-box {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-primary);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Uploader */
.uploader {
  display: grid;
  gap: 1rem;
}

.upload-area {
  border: 2px dashed var(--color-border-primary);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: transparent;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--color-primary);
  background: rgba(0, 255, 136, 0.05);
  transform: translateY(-2px);
}
.upload-icon { font-size: 3rem; margin-bottom: 1rem; filter: drop-shadow(0 0 10px rgba(255,255,255,0.3)); }
.upload-text { color: #e5e7eb; margin-bottom: 0.5rem; font-size: 1.1rem; }
.upload-hint { color: #9ca3af; font-size: 0.9rem; }

#file-input { display: none; }

/* Previews */
.preview-container { display: none; margin-top: 1rem; }
.preview-container.visible { display: block; }
#preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  max-width: 320px;
  margin: 0 auto;
}
.preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #2d2d34;
  aspect-ratio: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.remove-btn:hover { transform: scale(1.1); background: #ef4444; }

/* Forms */
.form-group { margin-top: 1rem; }
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--color-primary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group textarea, .form-group input[type="text"] {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-primary);
  border-radius: 8px;
  color: var(--color-text-primary);
  font-family: 'Supply', monospace;
  font-size: 0.95rem;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.form-group textarea:focus, .form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-bg-modal);
}
.hint { color: #9ca3af; font-size: 0.8rem; margin-top: 0.5rem; }

/* Buttons */
.button-19 {
  appearance: button;
  position: relative;
  background-color: var(--color-primary);
  border: solid transparent;
  border-radius: 8px;
  border-width: 0;
  box-sizing: border-box;
  color: var(--color-bg-modal);
  cursor: pointer;
  display: inline-block;
  font-family: 'Supply', sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 20px;
  margin: 0;
  outline: none;
  padding: 16px 24px;
  text-align: center;
  text-transform: none;
  transform: translateZ(0);
  transition: background-color 0.15s ease;
  vertical-align: middle;
  white-space: nowrap;
  width: auto;
  text-decoration: none;
}
.button-19:after {
  content: none;
}
.button-19:hover:not(:disabled) { background-color: var(--color-primary-hover); }
.button-19:disabled { cursor: not-allowed; opacity: .6; }
.button-19:active { transform: translateY(1px); }
.button-19.full-width { width: 100%; margin-top: 1.5rem; }
.button-19.secondary { background-color: var(--color-bg-tertiary); color: var(--color-text-primary); }
.button-19.secondary:hover:not(:disabled) { background-color: #252525; }

/* Sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: #2d2d34;
  border-radius: 3px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--color-primary);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* Progress Section */
.panel { display: none; }
.panel.visible { display: block; animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.progress-bar-container { height: 6px; background: #121214; border-radius: 3px; overflow: hidden; margin-bottom: 1rem; }
.progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}

.progress-steps { display: flex; flex-direction: column; gap: 0.5rem; }
.step {
  display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem;
  background: rgba(18, 18, 20, 0.5);
  border-radius: 8px;
  border-left: 3px solid transparent;
  opacity: 0.5;
  font-size: 0.9rem;
  transition: all 0.3s;
}
.step.active { opacity: 1; border-left-color: var(--color-primary); background: rgba(0, 255, 136, 0.05); }
.step.completed { opacity: 1; border-left-color: var(--color-primary); color: var(--color-primary); }
.step-icon { width: 24px; text-align: center; font-size: 1.2rem; }

/* Viewer */
.viewer {
  position: relative;
  margin: 1.5rem auto 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #333;
  max-width: 500px;
  aspect-ratio: 1 / 1;
}
.viewer-canvas, model-viewer {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1a1a1c 0%, #000 100%);
  display: block;
}

/* Intermediate Results */
.intermediate-results { display: none; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid #2d2d34; }
.intermediate-results.visible { display: block; }
.preview-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.preview-compare img {
  max-width: 100%; max-height: 200px; border-radius: 8px; border: 1px solid #2d2d34;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.stacked-preview { position: relative; width: 140px; height: 140px; margin: 0 auto; }
.stacked-preview img {
  position: absolute; width: 90px; height: 90px; object-fit: cover;
  border-radius: 8px; border: 2px solid #2d2d34; box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.stacked-preview img:nth-child(1) { top: 0; left: 0; z-index: 4; }
.stacked-preview img:nth-child(2) { top: 10px; left: 45px; z-index: 3; }
.stacked-preview img:nth-child(3) { top: 45px; left: 0; z-index: 2; }
.stacked-preview img:nth-child(4) { top: 45px; left: 45px; z-index: 1; }
.stacked-preview.single img { width: 140px; height: 140px; top: 0; left: 0; }
.image-count-badge {
  position: absolute; bottom: -8px; right: -8px; background: #1899D6; color: white;
  font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; z-index: 5;
}

/* Result Section */
.result { display: none; margin-top: 1rem; }
.result.visible { display: block; animation: fadeIn 0.5s ease; }
.result-header { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1.5rem; }
.result-header h3 { margin: 0; color: var(--color-primary); font-size: 1.4rem; }

.download-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem;
}
.download-card {
  background: rgba(18, 18, 20, 0.5); border: 1px solid #2d2d34; border-radius: 12px; padding: 1.5rem; text-align: center;
  transition: transform 0.2s;
}
.download-card:hover { transform: translateY(-3px); border-color: var(--color-primary); }
.download-card h4 { margin: 0 0 0.5rem 0; font-size: 1.1rem; }
.download-card p { color: #9ca3af; font-size: 0.85rem; margin: 0 0 1.25rem 0; }

.mml-section { background: rgba(18, 18, 20, 0.5); border-radius: 12px; padding: 1.5rem; border: 1px solid #2d2d34; }
.mml-code {
  background: #0b0b0c; padding: 1rem; border-radius: 8px; font-family: 'Monaco', monospace;
  font-size: 0.85rem; overflow-x: auto; margin-bottom: 1rem; border: 1px solid #2d2d34; color: #1CB0F6;
}

/* AI MML Enhancement Section */
.ai-enhance-section {
  background: rgba(18, 18, 20, 0.5);
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #1a3a4a;
  margin-top: 1rem;
  background: linear-gradient(135deg, rgba(18,18,20,0.6), rgba(24,40,60,0.3));
}
.ai-enhance-section h4 { font-size: 1rem; color: #e5e7eb; }
.ai-enhance-section .mml-code {
  margin-bottom: 0;
  font-size: 0.78rem;
  line-height: 1.4;
}

/* Footer */
footer {
  max-width: 920px; margin: 2rem auto 0; color: #6b7280; font-size: 0.85rem; text-align: center;
  position: relative; z-index: 10;
}
footer a { color: var(--color-primary); text-decoration: none; transition: color 0.2s; }
footer a:hover { color: var(--color-primary-hover); text-decoration: underline; }

/* Utilities */
.hidden { display: none !important; }
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--color-border-primary); border-top-color: var(--color-primary);
  border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.login-box {
  background: #121214; border: 1px solid #2d2d34; border-radius: 16px; padding: 2.5rem;
  width: 100%; max-width: 360px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.login-box h2 { margin: 0 0 1.5rem 0; text-align: center; color: #1899D6; }
.login-box input {
  width: 100%; padding: 0.8rem; background: #0a0a0a; border: 1px solid #2d2d34;
  border-radius: 8px; color: #e5e7eb; margin-bottom: 1rem; box-sizing: border-box;
}
.login-box input:focus { outline: none; border-color: #1899D6; }
.login-box .btn {
  width: 100%; padding: 0.8rem; background: #1899D6; border: none; border-radius: 8px;
  color: white; font-weight: bold; cursor: pointer; transition: background 0.2s;
}
.login-box .btn:hover { background: #1CB0F6; }

/* Loading/Animation Status */
.vrm-loading-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.7); display: flex;
  align-items: center; justify-content: center; border-radius: 8px;
}
.animation-status { display: none; }

/* VRM Viewer Container */
.vrm-viewer-container {
  display: flex;
  align-items: center;
  justify-content: center;
}
.vrm-viewer-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Service Toggle */
.service-toggle {
  display: flex;
  gap: 0.5rem;
  padding: 4px;
  background: #121214;
  border-radius: 10px;
  border: 1px solid #2d2d34;
}

.service-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #9ca3af;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.service-btn:hover {
  background: rgba(0, 255, 136, 0.05);
  color: var(--color-text-primary);
}

.service-btn.active {
  background: var(--color-primary);
  color: var(--color-bg-modal);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 255, 136, 0.3);
}

.service-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.service-btn.disabled:hover {
  background: transparent;
  color: #9ca3af;
}

.service-icon {
  font-size: 1rem;
}

.service-name {
  font-size: 0.85rem;
}
