* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #efefef;
  color: #222;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  line-height: 1.7;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.hero {
  text-align: center;
  margin-bottom: 28px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: 42px;
  line-height: 1.25;
}

.lead {
  margin: 0;
  font-size: 18px;
  color: #555;
}

.sub-lead {
  margin: 8px 0 0;
  font-size: 16px;
  color: #777;
}

.card {
  background: #f7f7f7;
  border-radius: 24px;
  padding: 28px;
}

.sample-section,
.upload-section,
.controls,
.notes {
  margin-bottom: 32px;
}

.sample-section h2,
.upload-section h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.sample-lead {
  margin: 0 0 16px;
  color: #666;
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.sample-card {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 16px;
  padding: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.sample-card:hover {
  transform: translateY(-2px);
  border-color: #222;
}

.sample-card.active {
  border: 2px solid #222;
}

.sample-card img {
  width: 100%;
  display: block;
  border-radius: 12px;
  aspect-ratio: 1 / 1.2;
  object-fit: cover;
}

.sample-card span {
  display: block;
  margin-top: 10px;
  text-align: center;
  font-weight: 700;
}

.upload-area {
  border: 2px dashed #bdbdbd;
  border-radius: 18px;
  padding: 24px;
  text-align: center;
  background: #fafafa;
}

.file-button,
.sub-button {
  display: inline-block;
  background: #222;
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 24px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.file-name {
  margin-top: 12px;
  color: #666;
  font-size: 16px;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.preview-box h2 {
  text-align: center;
  margin: 0 0 12px;
  font-size: 28px;
}

.image-stage {
  position: relative;
  min-height: 420px;
  background: #e8e8e8;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
}

#resultCanvas,
.result-transparent {
  background-image:
    linear-gradient(45deg, #e3e3e3 25%, transparent 25%),
    linear-gradient(-45deg, #e3e3e3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e3e3e3 75%),
    linear-gradient(-45deg, transparent 75%, #e3e3e3 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

canvas {
  display: none;
  max-width: 100%;
  max-height: 520px;
  height: auto;
  border-radius: 12px;
}

.placeholder {
  color: #444;
  font-size: 18px;
  text-align: center;
}

.controls h3 {
  margin: 0 0 12px;
  font-size: 22px;
}

.color-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.color-preset {
  background: #fff;
  border: 1px solid #bbb;
  border-radius: 14px;
  padding: 14px 10px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.color-preset.active {
  border: 2px solid #222;
}

.custom-color-box {
  background: #ececec;
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 24px;
}

.custom-help {
  margin: 0 0 14px;
  color: #666;
}

.custom-color-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

#customColor {
  width: 72px;
  height: 48px;
  border: 1px solid #bbb;
  border-radius: 10px;
  padding: 4px;
  background: #fff;
  cursor: pointer;
}

.color-preview {
  width: 56px;
  height: 48px;
  border-radius: 10px;
  border: 1px solid #bbb;
  background: #d2b48c;
}

.strength-wrap {
  margin-bottom: 20px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.range-row input[type="range"] {
  flex: 1;
}

.range-row output {
  min-width: 40px;
  text-align: right;
  font-weight: 700;
}

.bleach-box {
  background: #f1eada;
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 20px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  cursor: pointer;
}

.bleach-help {
  margin: 8px 0 14px;
  color: #555;
}

.save-button {
  width: 100%;
  border: none;
  background: #222;
  color: #fff;
  border-radius: 16px;
  padding: 18px;
  font-size: 28px;
  font-weight: 700;
  cursor: pointer;
}

.status {
  margin-top: 14px;
  font-size: 16px;
  color: #555;
  text-align: center;
  min-height: 1.8em;
}

.notes {
  background: #ececec;
  border-radius: 18px;
  padding: 18px;
}

.notes h3 {
  margin-top: 0;
}

.notes ul {
  margin: 0;
  padding-left: 20px;
}

@media (max-width: 900px) {
  .sample-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .color-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero h1 {
    font-size: 34px;
  }
}

@media (max-width: 520px) {
  .card {
    padding: 18px;
  }

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

  .hero h1 {
    font-size: 30px;
  }

  .preview-box h2 {
    font-size: 24px;
  }

  .image-stage {
    min-height: 300px;
  }

  .save-button {
    font-size: 24px;
  }
}
#reloadAI {
  display: block !important;
  width: 100% !important;
  min-height: 64px !important;
  padding: 16px 20px !important;
  margin: 14px 0 !important;
  font-size: 22px !important;
  font-weight: 700 !important;
  line-height: 1.4 !important;
  border: 2px solid #222 !important;
  border-radius: 16px !important;
  background: #ffffff !important;
  color: #222 !important;
}

.reload-button:hover {
  background: #f0f0f0;
}
