* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: #f4f4f6;
  color: #1a1a1a;
  min-height: 100vh;
}

body.result-page {
  background: #1a1a1a;
  color: #fff;
  overflow: hidden;
}

#header {
  position: sticky;
  top: 0;
  height: 48px;
  background: #fff;
  border-bottom: 1px solid #e0e0e3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10;
}

body.result-page #header {
  position: fixed;
  left: 0; right: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  color: #fff;
}

#title {
  font-size: 14px;
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 1px 6px;
  margin-left: 4px;
  background: #ffd54f;
  color: #4a3a00;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
}

.header-link, .header-btn {
  font-size: 13px;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

.header-link:hover, .header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

#main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

#intro h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}
#intro p {
  font-size: 14px;
  line-height: 1.7;
  color: #555;
  margin-bottom: 24px;
}

#guide {
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
#guide h2 {
  font-size: 14px;
  margin-bottom: 8px;
}
#guide ul {
  list-style: none;
}
#guide li {
  font-size: 13px;
  line-height: 1.8;
  color: #444;
  padding-left: 18px;
  position: relative;
}
#guide li::before {
  content: "•";
  position: absolute;
  left: 6px;
  color: #4fc3f7;
}

#dropzone {
  background: #fff;
  border: 2px dashed #c0c0c8;
  border-radius: 12px;
  padding: 48px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  outline: none;
}
#dropzone:hover, #dropzone:focus, #dropzone.dragging {
  border-color: #4fc3f7;
  background: #f0faff;
}
.dz-icon { font-size: 36px; margin-bottom: 8px; }
.dz-text { font-size: 14px; line-height: 1.6; }
.dz-hint { font-size: 11px; color: #888; margin-top: 8px; }

#preview {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
#preview-img {
  max-width: 100%;
  max-height: 360px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.preview-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-block;
}
.btn-primary {
  background: #4fc3f7;
  color: #003c5a;
}
.btn-primary:hover { background: #29b6f6; }
.btn-secondary {
  background: #e0e0e3;
  color: #1a1a1a;
}
.btn-secondary:hover { background: #d0d0d6; }

#progress {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}
#progress h2 { font-size: 16px; margin-bottom: 16px; }

.progress-bar {
  height: 12px;
  background: #f0f0f3;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4fc3f7, #29b6f6);
  width: 0%;
  transition: width 0.3s ease;
}
#progress-text {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  margin-bottom: 4px;
}
#progress-msg {
  font-size: 13px;
  color: #555;
  margin-bottom: 12px;
}
.progress-hint {
  font-size: 12px;
  color: #888;
}

#error {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  border: 1px solid #ffcdd2;
}
#error h2 { font-size: 16px; color: #c62828; margin-bottom: 12px; }
#error-msg {
  font-size: 14px;
  color: #555;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

/* ---- Result page ---- */

body.result-page #viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}
body.result-page #viewer canvas {
  display: block;
  outline: none;
  touch-action: none;
}

body.result-page #loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 20, 0.85);
  z-index: 20;
  gap: 16px;
}
body.result-page #loading[hidden] { display: none; }

body.result-page .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #4fc3f7;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

body.result-page #error {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 20, 0.9);
  z-index: 20;
  gap: 16px;
  border: none;
  border-radius: 0;
}
body.result-page #error[hidden] { display: none; }
body.result-page .error-message {
  color: #ff8080;
  font-size: 14px;
  max-width: 80%;
  text-align: center;
}

body.result-page #controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
  align-items: center;
  justify-content: center;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}
.control-group .label {
  font-size: 11px;
  opacity: 0.7;
}
.control-group label {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.control-group input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer;
}

.bg-swatch {
  width: 24px !important;
  height: 24px !important;
  border-radius: 50% !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  padding: 0;
  cursor: pointer;
}

body.result-page .btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 12px;
  padding: 6px 12px;
}
body.result-page .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.22);
}

@media (max-width: 600px) {
  #intro h1 { font-size: 18px; }
  .btn-primary, .btn-secondary { padding: 14px 20px; }
}
