@charset "UTF-8";

/* =========================================
   リセット & 基本設定
   ========================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -webkit-text-size-adjust: 100%;
}

/* モバイルモード時のbody調整 */
html.mobile-mode body {
  padding: 0 !important;
}

/* =========================================
   レイアウトコンテナ
   ========================================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}

html.mobile-mode .container {
  max-width: 100% !important;
  margin: 0 !important;
  border-radius: 0 !important;
  min-height: 100vh !important;
}

/* =========================================
   ヘッダーエリア
   ========================================= */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 40px 30px;
  text-align: center;
}

html.mobile-mode .header {
  padding: 25px 15px !important;
}

.header h1 {
  font-size: 36px;
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

html.mobile-mode .header h1 {
  font-size: 24px !important;
}

.header p {
  font-size: 14px;
  opacity: 0.9;
  font-weight: 300;
}

/* =========================================
   デバイス切り替えスイッチ
   ========================================= */
.device-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.device-toggle input {
  display: none;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  width: 120px;
  height: 60px;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 30px;
  transition: background-color 0.3s ease;
  border: 3px solid rgba(255, 255, 255, 0.5);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 32px;
  transition: all 0.3s ease;
  display: none;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  background-color: white;
  border-radius: 50%;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.device-toggle input:checked + .toggle-slider {
  background-color: rgba(255, 255, 255, 0.5);
}

.device-toggle input:checked + .toggle-slider::before {
  content: '';
  left: auto;
  right: 50px;
  display: none;
}

.device-toggle input:checked + .toggle-slider::after {
  left: 6px;
  right: auto;
}

/* =========================================
   メインコンテンツエリア
   ========================================= */
.content {
  padding: 40px 30px;
}

html.mobile-mode .content {
  padding: 15px !important;
}

.section {
  margin-bottom: 40px;
}

html.mobile-mode .section {
  margin-bottom: 30px !important;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #667eea;
  display: inline-block;
}

html.mobile-mode .section-title {
  font-size: 26px !important;
  margin-bottom: 12px !important;
  padding-bottom: 8px !important;
}

/* =========================================
   アップロード・プレビュー
   ========================================= */
.upload-area {
  background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
  border: 2px dashed #667eea;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  margin-bottom: 30px;
  transition: all 0.3s ease;
  cursor: pointer;
}

html.mobile-mode .upload-area {
  padding: 25px !important;
}

.upload-area:hover {
  background: linear-gradient(135deg, #667eea25 0%, #764ba225 100%);
  border-color: #764ba2;
}

.upload-btn {
  display: inline-block;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  color: white;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.upload-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.upload-btn:active {
  transform: translateY(0);
}

#preview {
  text-align: center;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#preview img {
  max-width: 250px;
  max-height: 250px;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  margin-top: 15px;
}

html.mobile-mode #preview img {
  max-width: 220px !important;
  max-height: 220px !important;
}

/* =========================================
   選択ボタン（形状・スタイルなど）
   ========================================= */
.button-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-bottom: 30px;
}

html.mobile-mode .button-group {
  grid-template-columns: repeat(2, 1fr) !important;
}

/* スタイル選択用 - 8個を2段（4列）で表示 */
.section:nth-child(2) .button-group {
  grid-template-columns: repeat(4, 1fr);
}

/* 演出選択用 - 5個を複数段で表示 */
.section:nth-child(3) .button-group {
  grid-template-columns: repeat(5, 1fr);
}

html.mobile-mode .section:nth-child(3) .button-group {
  grid-template-columns: repeat(2, 1fr) !important;
}

.btn {
  padding: 12px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  background: white;
  color: #666;
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
}

html.mobile-mode .btn {
  padding: 14px 10px !important;
  font-size: 26px !important;
  min-height: 50px !important;
}

.btn:hover {
  border-color: #667eea;
  background: #f5f7ff;
  transform: translateY(-2px);
}

.btn.selected {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* =========================================
   生成ボタン
   ========================================= */
.generate-btn {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  margin-bottom: 20px;
}

html.mobile-mode .generate-btn {
  padding: 26px !important;
  font-size: 26px !important;
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.generate-btn:active:not(:disabled) {
  transform: translateY(0);
}

.generate-btn:disabled {
  background: #ccc;
  color: #999;
  cursor: not-allowed;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* =========================================
   結果表示カード
   ========================================= */
#result {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 30px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

html.mobile-mode #result {
  flex-direction: column !important;
  gap: 15px !important;
}

.card {
  max-width: 250px;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
  margin: 0 auto;
}

html.mobile-mode .card {
  width: 100% !important;
  max-width: 100% !important;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 25px rgba(0,0,0,0.15);
}

.card img {
  width: 100%;
  height: 250px;
  object-fit: contain;
  padding: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

html.mobile-mode .card img {
  height: 250px !important;
  object-fit: contain !important;
}

.card img:hover {
  opacity: 0.8;
}

.card-content {
  padding: 15px;
  background: white;
  position: relative;
}

.card-label {
  font-size: 14px;
  font-weight: 600;
  color: #666;
  margin-bottom: 10px;
}

.card-download {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(102, 126, 234, 0.9);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.3s ease;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.card:hover .card-download {
  opacity: 1;
  transform: scale(1.1);
}

.card-download:hover {
  background: rgba(102, 126, 234, 1);
  transform: scale(1.15);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.card-download:active {
  transform: scale(1);
}

/* =========================================
   履歴セクション
   ========================================= */
.history-section {
  margin-top: 50px;
  padding-top: 40px;
  border-top: 2px solid #f0f0f0;
}

#history {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

html.mobile-mode #history {
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
  gap: 10px !important;
}

.history-item {
  position: relative;
  overflow: visible;
  border-radius: 8px;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.history-item.selected {
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
  border: 3px solid #667eea;
}

.history-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  cursor: pointer;
  border-radius: 8px;
  display: block;
  transition: all 0.3s ease;
}

.history-item.selected img {
  opacity: 0.7;
}

.history-item:hover img {
  transform: scale(1.05);
  opacity: 0.8;
}

.history-item:hover .history-download {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.history-checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  z-index: 15;
  appearance: none;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #667eea;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.history-checkbox:checked {
  background: #667eea;
}

.history-checkbox:checked::after {
  content: '✓';
  position: absolute;
  color: white;
  font-size: 16px;
  font-weight: bold;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.history-download {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  background: rgba(102, 126, 234, 0.9);
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.3s ease;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.history-download:hover {
  background: rgba(102, 126, 234, 1);
  transform: translate(-50%, -50%) scale(1.15);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.history-download:active {
  transform: translate(-50%, -50%) scale(1);
}

/* =========================================
   モーダル
   ========================================= */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.8);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 800px;
  margin: 50px auto;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal img {
  width: 100%;
  display: block;
}

.modal .close {
  position: absolute;
  top: 15px;
  right: 20px;
  color: white;
  font-size: 32px;
  cursor: pointer;
  background: rgba(0,0,0,0.5);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.modal .close:hover {
  background: rgba(0,0,0,0.8);
}

/* =========================================
   メッセージ (エラー・ローディング)
   ========================================= */
#error,
#loading {
  padding: 15px;
  margin-bottom: 20px;
  border-radius: 8px;
  font-weight: 600;
}

#error {
  background: #fee;
  color: #c33;
  border-left: 4px solid #c33;
  display: none;
}

#loading {
  background: #efe;
  color: #3a3;
  border-left: 4px solid #3a3;
  display: none;
}

/* =========================================
   切り抜きエディタ
   ========================================= */
.crop-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
  background: #f5f5f5;
  border-radius: 8px;
  overflow: hidden;
  padding: 20px;
}

#cropImage {
  display: block;
  max-width: 100%;
  max-height: 400px;
}

.crop-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 15px;
  flex-wrap: wrap;
}

.crop-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.crop-btn.primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.crop-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.crop-btn.secondary {
  background: #e0e0e0;
  color: #333;
}

.crop-btn.secondary:hover {
  background: #d0d0d0;
}

/* =========================================
   メディアクエリ (タブレット調整)
   ========================================= */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    max-width: 95%;
  }

  .button-group {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========== 追記：HTMLをシンプルにするためのスタイル ========== */

/* ヘッダーレイアウト */
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
}
.header-left, .header-right {
  width: 130px;
  display: flex;
  align-items: center;
}
.header-left { justify-content: flex-start; padding-right: 10px; }
.header-right { justify-content: flex-end; gap: 10px; }

.header-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

/* ロゴまわり */
.logo-svg {
  filter: drop-shadow(0 6px 15px rgba(0,0,0,0.3));
}
.logo-title {
  font-size: 48px; font-weight: 900; color: white;
  text-shadow: 4px 4px 8px rgba(0,0,0,0.4); letter-spacing: -1px;
}
.logo-subtitle {
  font-size: 14px; color: rgba(255,255,255,0.95);
  letter-spacing: 3px; margin-top: 8px; font-weight: 600;
}

/* ヘッダーアイコンボタン */
.icon-btn {
  font-size: 32px; line-height: 1; min-width: 40px;
  background: none; border: none; cursor: pointer; padding: 10px;
  transition: all 0.3s ease;
}

/* アップロードエリアのグリッド */
.upload-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 30px;
}

/* ボタン内部の配置 */
.btn-inner {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; width: 100%; height: 100%; background: none; border: none; cursor: pointer;
}
.icon-large { font-size: 50px; line-height: 1; }
.text-small { font-size: 14px; font-weight: 600; color: #666; text-align: center; }

/* ヘルプモーダルの装飾 */
.help-modal-inner { padding: 30px; }
.help-title { font-size: 28px; font-weight: 700; margin-bottom: 20px; color: #333; }
.help-steps-container { display: flex; flex-direction: column; gap: 20px; }

.help-step { border-left: 4px solid; padding-left: 15px; }
.help-step h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.help-step p { color: #666; line-height: 1.6; }

/* ステップごとの色分け */
.step-blue { border-color: #667eea; }
.step-blue h3 { color: #667eea; }
.step-purple { border-color: #764ba2; }
.step-purple h3 { color: #764ba2; }

.help-hint { background: #f5f5f5; padding: 15px; border-radius: 8px; }
.help-hint h3 { font-size: 16px; font-weight: 600; color: #333; margin-bottom: 8px; }
.help-hint ul { color: #666; line-height: 1.8; margin-left: 20px; }

.help-close-btn {
  width: 100%; margin-top: 20px; padding: 12px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white; border: none; border-radius: 8px;
  font-size: 16px; font-weight: 600; cursor: pointer; transition: all 0.3s ease;
}