/* ===== Variables ===== */
:root {
  --bg: #FFF8F0;
  --bg-card: #FFFFFF;
  --text: #333333;
  --text-secondary: #7A6B5D;
  --text-muted: #B5A99A;
  --border: #F0E0D0;
  --primary: #D4845A;
  --primary-hover: #C0714A;
  --primary-light: #FFF0E6;
  --gradient-from: #D4845A;
  --gradient-to: #E8A87C;
  --danger: #D4845A;
  --success: #7CB485;
  --shadow: 0 4px 20px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --radius: 16px;
  --radius-full: 9999px;
}

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

body {
  font-family: 'M PLUS Rounded 1c', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, var(--gradient-from), var(--gradient-to));
  color: #fff;
  padding: 14px 16px 12px;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 640px;
  margin: 0 auto;
}
.header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
}
.header p {
  font-size: 11px;
  opacity: 0.9;
  margin-top: 1px;
  display: none;
}
.sub-header {
  background: linear-gradient(135deg, var(--gradient-to), #E8A87C);
  padding: 6px 16px;
}
.sub-header-inner {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  max-width: 640px;
  margin: 0 auto;
}
.header-guide-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  min-width: 72px;
  text-align: center;
  background: #fff;
  border: none;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}
.header-guide-link:hover { background: var(--primary-light); transform: scale(1.05); }
.header-mascot {
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ===== Ad Slots ===== */
.ad-slot {
  max-width: 640px;
  margin: 6px auto;
  padding: 0 12px;
}
.ad-placeholder {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  background: var(--bg-card);
}

/* ===== Layout ===== */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 12px;
}

/* ===== SEO Hero ===== */
.seo-hero {
  margin-bottom: 12px;
  padding: 0 2px;
}
.seo-hero h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.5;
}
.seo-hero p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ===== Card ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 8px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
}
.card-title .icon {
  font-size: 15px;
}

/* ===== Drop Zone ===== */
.dropzone {
  display: block;
  border: none;
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s;
  background: var(--primary-light);
}
.dropzone:hover, .dropzone.active {
  background: #FFECD8;
}
.dropzone .drop-icon {
  font-size: 22px;
  margin-bottom: 2px;
}
.dropzone p {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.3;
}
.dropzone .sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ===== Upload Actions (stacked layout) ===== */
.upload-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upload-actions .dropzone {
  width: 100%;
  padding: 32px 16px;
}
.upload-or {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.upload-actions .camera-btn {
  width: 100%;
  margin-top: 0;
  padding: 7px;
}

/* ===== Camera Button ===== */
.camera-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  margin-top: 6px;
  padding: 9px;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
.camera-btn:hover { background: #4A4A4A; }
.camera-btn .btn-icon { font-size: 15px; }

/* ===== Image Grid ===== */
.image-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.image-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg);
  border: 2px solid var(--border);
}
.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-item .delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.2s;
}
.image-item .delete-btn:hover { background: rgba(0,0,0,0.7); transform: scale(1.1); }
.image-item .delete-btn svg { width: 12px; height: 12px; }
.image-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ===== Accordion ===== */
.accordion-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.accordion-header .icon { font-size: 14px; transition: transform 0.2s; }
.accordion-header.open .icon { transform: rotate(90deg); }
.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.accordion-body.open { max-height: 500px; }
.accordion-body .inner { padding-top: 12px; }

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 12px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212,132,90,0.15);
}
.form-textarea { resize: vertical; }

/* ===== Generate Button ===== */
.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #B86A3C, #D4845A);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: inherit;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 16px rgba(160,90,40,0.35);
  min-width: 280px;
}
.generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(160,90,40,0.45);
}
.generate-btn:active { transform: translateY(0); }
.generate-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.generate-btn .btn-icon { font-size: 20px; }

/* ===== Result Section ===== */
.result-section { display: none; }
.result-section.visible { display: block; }
.result-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.result-label span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
  font-family: inherit;
}
.copy-btn:hover { background: var(--primary-light); color: var(--primary); transform: scale(1.05); }
.copy-btn.copied { background: #E8F5E8; color: var(--success); border-color: #C8E6C8; }
.copy-btn svg { width: 14px; height: 14px; }
.result-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  margin-bottom: 12px;
}
.result-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  min-height: 200px;
  line-height: 1.8;
}
.regenerate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  font-family: inherit;
}
.regenerate-btn:hover { background: var(--primary-light); color: var(--primary); transform: scale(1.02); }
.regenerate-btn .btn-icon { font-size: 16px; }

/* ===== Success Banner ===== */
.success-banner {
  display: none;
  padding: 12px 16px;
  background: #F0F9F0;
  border: 1px solid #C8E6C8;
  border-radius: 16px;
  color: #3D6B3D;
  font-size: 14px;
  margin-bottom: 12px;
  text-align: center;
}
.success-banner.visible { display: block; }

/* ===== Interstitial Ad Overlay ===== */
.interstitial {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(51,51,51,0.8);
  z-index: 100;
  justify-content: center;
  align-items: center;
}
.interstitial.visible {
  display: flex;
}
.interstitial-content {
  background: var(--bg-card);
  border-radius: 24px;
  padding: 28px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.interstitial-content h3 {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.interstitial-ad {
  min-height: 250px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 16px;
  background: var(--bg);
}
.interstitial-timer {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.interstitial-close {
  display: none;
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--gradient-from), var(--gradient-to));
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.2s;
}
.interstitial-close:hover { transform: scale(1.02); }
.interstitial-close.visible { display: block; }

/* ===== Loading Overlay ===== */
.loading {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(51,51,51,0.75);
  z-index: 200;
  justify-content: center;
  align-items: center;
}
.loading.visible { display: flex; }
.loading-content {
  background: var(--bg-card);
  border-radius: 24px;
  padding: 36px 32px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.loading-cat {
  width: 80px;
  height: 80px;
  object-fit: contain;
  animation: catBounce 0.6s ease-in-out infinite alternate;
  margin-bottom: 16px;
}
@keyframes catBounce {
  0%   { transform: translateY(0) rotate(-5deg); }
  100% { transform: translateY(-12px) rotate(5deg); }
}
.loading-content p {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.loading-content .sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== Error Banner ===== */
.error-banner {
  display: none;
  padding: 14px 16px;
  background: #FFF5F0;
  border: 1px solid #F0D0C0;
  border-radius: 16px;
  color: #8B4513;
  font-size: 14px;
  margin-bottom: 16px;
  position: relative;
}
.error-banner.visible { display: block; }
.error-banner .close-error {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: #8B4513;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 12px;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto;
}
.footer p { margin-bottom: 4px; }
.footer-links { margin-top: 8px; }
.footer-links a { color: var(--primary); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; }
.footer .paw-divider {
  font-size: 16px;
  letter-spacing: 8px;
  margin-bottom: 8px;
}

/* ===== Lightbox ===== */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 300;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.lightbox.visible { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 12px;
  cursor: default;
}
.lightbox .close-lightbox {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}
.lightbox .close-lightbox svg {
  width: 32px;
  height: 32px;
}

/* ===== Hint Box ===== */
.hint {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 0;
  margin-top: 6px;
}
.hint .icon {
  font-size: 12px;
  flex-shrink: 0;
}
.hint p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ===== Section Divider ===== */
.section-divider {
  text-align: center;
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--text-muted);
  margin: 12px 0;
}

/* ===== Responsive ===== */
@media (min-width: 480px) {
  .image-grid { grid-template-columns: repeat(4, 1fr); }
  .header { padding: 18px 20px 14px; }
  .header h1 { font-size: 26px; }
  .header p { display: block; }
  .header-mascot { width: 80px; height: 80px; }
  .header-nav { gap: 12px; }
  .header-guide-link { font-size: 13px; padding: 7px 16px; min-width: 80px; }
  .card { padding: 20px; }
  .container { padding: 16px; }
  .dropzone { padding: 24px 16px; }
  .dropzone .drop-icon { font-size: 32px; }
  .dropzone p { font-size: 14px; }
}
