/* NanoCanvas PWA Styles */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ヘッダー */
.app-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 122, 255, 0.1);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.app-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: #007aff;
  flex: 1;
}

.app-version-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: #007aff;
  background: rgba(0, 122, 255, 0.12);
  border: 1px solid rgba(0, 122, 255, 0.2);
  text-transform: lowercase;
}

.settings-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.settings-btn:hover {
  background: rgba(0, 122, 255, 0.1);
}

/* 初期設定セクション */
.setup-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.setup-content {
  text-align: center;
  max-width: 400px;
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.setup-content h2 {
  font-size: 28px;
  margin-bottom: 16px;
  color: #333;
}

.setup-content .info {
  color: #666;
  margin-bottom: 32px;
  font-size: 16px;
}

/* メインアプリ */
.main-app {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

/* メインナビゲーション */
.main-nav {
  margin-bottom: 24px;
}

.main-nav h2 {
  font-size: 20px;
  font-weight: 600;
  color: #1d1d1f;
  text-align: center;
  padding: 16px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 画像生成コンテンツ */
.generate-content {
  display: block;
}

/* 入力セクション */
.input-section {
  background: white;
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.prompt-section {
  margin-bottom: 32px;
}

.prompt-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 12px;
  color: #333;
  font-size: 16px;
}

.prompt-section textarea {
  width: 100%;
  padding: 16px;
  border: 2px solid #e1e1e1;
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  overflow-y: scroll; /* 常にスクロールバーを表示 */
  transition: border-color 0.2s;
  min-height: 120px;
}

.prompt-section textarea:focus {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* プロンプト改善提案ボタン */
.improve-prompt-btn {
  margin-top: 12px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.improve-prompt-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.improve-prompt-btn:active {
  transform: translateY(0);
}

/* 参照画像セクション */
.reference-section {
  border-top: 1px solid #f0f0f0;
  padding-top: 32px;
}

.reference-section h3 {
  font-size: 18px;
  margin-bottom: 16px;
  color: #333;
}

.reference-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.reference-container {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
}

.reference-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 14px;
}

.reference-note {
  color: #666;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

/* ボタンスタイル */
.primary-btn {
  background: linear-gradient(135deg, #007aff, #5856d6);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}

.primary-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  background: white;
  color: #007aff;
  border: 2px solid #007aff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn:hover {
  background: #007aff;
  color: white;
}

.generate-btn {
  width: 100%;
  margin-top: 24px;
  font-size: 18px;
  padding: 20px;
}

/* 詳細設定アコーディオン */
.advanced-settings {
  margin-top: 16px;
  border: 2px solid #e1e1e1;
  border-radius: 12px;
  overflow: hidden;
  background: #fafafa;
}

.advanced-settings[open] {
  border-color: #6b4ce6;
}

.advanced-settings-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(135deg, #f5f5f5 0%, #fafafa 100%);
  transition: all 0.2s;
}

.advanced-settings-toggle:hover {
  background: linear-gradient(135deg, #eeeeee 0%, #f5f5f5 100%);
}

.advanced-settings[open] .advanced-settings-toggle {
  background: linear-gradient(135deg, #6b4ce6 0%, #8b5cf6 100%);
  color: white;
}

.toggle-icon {
  font-size: 16px;
}

.toggle-text {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.toggle-arrow {
  font-size: 12px;
  transition: transform 0.2s;
}

.advanced-settings[open] .toggle-arrow {
  transform: rotate(180deg);
}

.advanced-settings-content {
  padding: 16px;
  background: white;
}

/* 解像度セレクター（生成画面） */
.resolution-selector {
  background: linear-gradient(135deg, #f8f9ff 0%, #fff5f5 100%);
  border: 2px solid #e8e0ff;
  border-radius: 12px;
  padding: 16px;
}

.resolution-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #6b4ce6;
  margin-bottom: 12px;
}

.resolution-options {
  display: flex;
  gap: 8px;
}

.resolution-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: white;
  border: 2px solid #e1e1e1;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.resolution-btn:hover {
  border-color: #6b4ce6;
  background: #faf8ff;
}

.resolution-btn.active {
  border-color: #6b4ce6;
  background: linear-gradient(135deg, #6b4ce6 0%, #8b5cf6 100%);
  color: white;
}

.resolution-name {
  font-size: 16px;
  font-weight: 700;
}

.resolution-desc {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}

.resolution-btn.active .resolution-desc {
  opacity: 0.9;
}

/* アスペクト比セレクター（生成画面） */
.aspect-ratio-selector {
  background: linear-gradient(135deg, #f5fff5 0%, #f0f8ff 100%);
  border: 2px solid #c8e6c9;
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

.aspect-ratio-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #2e7d32;
  margin-bottom: 12px;
}

.aspect-ratio-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.aspect-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  min-width: 56px;
  background: white;
  border: 2px solid #e1e1e1;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.aspect-btn:hover {
  border-color: #2e7d32;
  background: #f5fff5;
}

.aspect-btn.active {
  border-color: #2e7d32;
  background: linear-gradient(135deg, #2e7d32 0%, #4caf50 100%);
  color: white;
}

.aspect-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2px;
  font-size: 16px;
}

/* アスペクト比アイコン（CSSで描画） */
.aspect-icon.aspect-square,
.aspect-icon.aspect-3-2,
.aspect-icon.aspect-2-3,
.aspect-icon.aspect-4-3,
.aspect-icon.aspect-3-4,
.aspect-icon.aspect-16-9,
.aspect-icon.aspect-9-16,
.aspect-icon.aspect-21-9,
.aspect-icon.aspect-4-5,
.aspect-icon.aspect-5-4 {
  border: 2px solid currentColor;
  border-radius: 2px;
}

.aspect-icon.aspect-square { width: 18px; height: 18px; }
.aspect-icon.aspect-3-2 { width: 21px; height: 14px; }
.aspect-icon.aspect-2-3 { width: 14px; height: 21px; }
.aspect-icon.aspect-4-3 { width: 20px; height: 15px; }
.aspect-icon.aspect-3-4 { width: 15px; height: 20px; }
.aspect-icon.aspect-16-9 { width: 24px; height: 13px; }
.aspect-icon.aspect-9-16 { width: 13px; height: 24px; }
.aspect-icon.aspect-21-9 { width: 26px; height: 11px; }
.aspect-icon.aspect-4-5 { width: 16px; height: 20px; }
.aspect-icon.aspect-5-4 { width: 20px; height: 16px; }

.aspect-name {
  font-size: 11px;
  font-weight: 600;
}

.aspect-ratio-note {
  margin-top: 10px;
  font-size: 12px;
  color: #666;
  text-align: center;
}

/* 編集セクションは削除済み */

/* アップロードエリアは削除済み */

/* アップロードコンテンツと編集コントロールは削除済み */

/* 編集プロンプトセクションは削除済み */

/* 結果セクション */
.result-section {
  background: white;
  border-radius: 16px;
  padding: 32px;
  margin-top: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.result-header h3 {
  font-size: 20px;
  color: #333;
}

.result-info {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: #666;
}

.result-image-container {
  text-align: center;
  margin-bottom: 24px;
}

.result-image {
  max-width: 100%;
  max-height: 500px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.2s;
}

.result-image:hover {
  transform: scale(1.02);
}

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.text-response-display {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.6;
  color: #495057;
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
}

.action-btn {
  background: #f8f9fa;
  color: #333;
  border: 1px solid #e1e1e1;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #e9ecef;
  transform: translateY(-1px);
}

/* ローディング */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-content {
  text-align: center;
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  max-width: 400px;
  margin: 20px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #007aff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-content h3 {
  margin-bottom: 20px;
  color: #333;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: #f3f3f3;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #007aff, #5856d6);
  animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

/* エラー表示 */
.error-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.error-content {
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  margin: 20px;
  text-align: center;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-content h3 {
  color: #dc3545;
  margin-bottom: 16px;
}

.error-content p {
  color: #666;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* モーダル */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid #f0f0f0;
}

.modal-header h2 {
  font-size: 20px;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 4px;
  line-height: 1;
}

.close-btn:hover {
  color: #333;
}

.modal-body {
  padding: 32px;
}

body.no-scroll {
  overflow: hidden;
}

/* プロンプト改善モーダル */
.prompt-improvement-modal-content {
  max-width: 900px;
  width: 100%;
}

.prompt-comparison {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: start;
}

.prompt-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prompt-column h3 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.prompt-display {
  background: #f8f9fa;
  border: 2px solid #e1e1e1;
  border-radius: 12px;
  padding: 16px;
  font-size: 15px;
  line-height: 1.6;
  color: #333;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 150px;
  max-height: 400px;
  overflow-y: auto;
}

.prompt-display.improved {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
  border-color: #667eea;
}

.prompt-arrow {
  font-size: 32px;
  color: #667eea;
  font-weight: bold;
  align-self: center;
  padding-top: 32px;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .prompt-improvement-modal-content {
    max-width: 100%;
  }

  .prompt-comparison {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .prompt-arrow {
    transform: rotate(90deg);
    padding-top: 0;
    justify-self: center;
  }
}

.history-preview-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 24px;
}

.history-preview-modal {
  background: rgba(20, 20, 24, 0.96);
  border-radius: 16px;
  max-width: min(90vw, 960px);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.history-preview-close {
  align-self: flex-end;
  background: none;
  border: none;
  color: #f5f5f7;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.history-preview-close:hover {
  color: #ffffff;
}

.history-preview-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}

.history-preview-image {
  max-width: 100%;
  max-height: 65vh;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  object-fit: contain;
  background: #1c1c1e;
}

.history-preview-details {
  margin-top: 16px;
  color: #f5f5f7;
}

.history-preview-prompt {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 12px;
  word-break: break-word;
}

.history-preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 14px;
  color: #d1d1d6;
}

.setting-group {
  margin-bottom: 24px;
}

.setting-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.setting-group input,
.setting-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e1e1e1;
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
}

.setting-group input:focus,
.setting-group textarea:focus {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.help-text {
  font-size: 13px;
  color: #666;
  margin-top: 6px;
}

.help-text a {
  color: #007aff;
  text-decoration: none;
}

.help-text a:hover {
  text-decoration: underline;
}

.modal-footer {
  padding: 24px 32px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* レスポンシブ */
@media (max-width: 768px) {
  .header-content {
    padding: 12px 16px;
  }

  .app-header h1 {
    font-size: 20px;
  }

  .main-app {
    padding: 16px;
  }

  .input-section,
  .result-section {
    padding: 24px;
  }

  .main-nav {
    margin-bottom: 16px;
  }

  /* タブボタンスタイルは削除済み */

  .reference-controls {
    flex-direction: column;
  }

  .result-actions {
    flex-direction: column;
  }

  .action-btn {
    width: 100%;
  }

  .modal-content {
    margin: 10px;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 20px;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .setup-content {
    padding: 24px;
  }

  .setup-content h2 {
    font-size: 24px;
  }

  /* アップロードエリアスタイルは削除済み */

  .result-info {
    flex-direction: column;
    gap: 8px;
  }
}

/* 参照画像編集機能の追加スタイル */
.reference-image-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.edit-btn, .remove-btn {
  border: none;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.edit-btn {
  background: #007aff;
  color: white;
}

.edit-btn:hover {
  background: #0056cc;
}

.remove-btn {
  background: #ff3b30;
  color: white;
}

.remove-btn:hover {
  background: #d70015;
}

/* 画像編集モーダル */
.editor-modal {
  max-width: 95vw;
  max-height: 95vh;
  width: 1000px;
  height: 700px;
}

.editor-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  flex-wrap: wrap;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
  min-width: 40px;
}

.tool-btn:hover {
  background: #f0f0f0;
  border-color: #007aff;
}

.tool-btn.active {
  background: #007aff;
  color: white;
  border-color: #007aff;
}

.tool-btn:disabled {
  background: #f8f9fa;
  color: #999;
  cursor: not-allowed;
}

.tool-label {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  white-space: nowrap;
}

.brush-slider {
  width: 80px;
}

.brush-value {
  font-size: 12px;
  color: #666;
  min-width: 35px;
  text-align: center;
}

.color-palette {
  display: flex;
  gap: 4px;
}

.color-btn {
  width: 24px;
  height: 24px;
  border: 2px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.color-btn:hover {
  border-color: #007aff;
  transform: scale(1.1);
}

.color-btn.active {
  border-color: #007aff;
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.3);
}

.canvas-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f0f0f0;
  position: relative;
}


.canvas-wrapper {
  flex: 1;
  position: relative;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  background: #f0f0f0;
  user-select: none;
}

.canvas-layer {
  position: relative;
  transform-origin: 0 0;
  border: 2px solid #ddd;
  box-sizing: content-box;
}

.editor-canvas {
  position: absolute;
  top: 0;
  left: 0;
  border: none;
  cursor: crosshair;
  transform-origin: top left;
}

#main-canvas {
  background: #fff;
}

#edit-canvas,
#overlay-canvas {
  background: transparent;
}

.canvas-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: white;
  border-top: 1px solid #e9ecef;
  font-size: 12px;
  color: #666;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-controls button {
  min-width: 36px;
  padding: 6px 10px;
}

#zoom-display {
  font-weight: 600;
  width: 60px;
  text-align: center;
}

/* ブラシカーソル */
.brush-cursor {
  position: absolute;
  border: 2px solid #007aff;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
  display: none;
  background: rgba(0, 122, 255, 0.1);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .editor-modal {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .editor-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px;
  }

  .tool-group {
    justify-content: center;
    flex-wrap: wrap;
  }

  .brush-slider {
    width: 120px;
  }

  .canvas-info {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

/* 履歴機能スタイル */

/* タブナビゲーション */
.nav-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #f2f2f7;
  margin-bottom: 20px;
}

.nav-tab {
  flex: 1;
  padding: 12px 16px;
  background: none;
  border: none;
  font-size: 16px;
  font-weight: 500;
  color: #8e8e93;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.nav-tab.active {
  color: #007aff;
}

.nav-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #007aff;
}

.nav-tab:hover:not(.active) {
  color: #007aff;
  background: rgba(0, 122, 255, 0.05);
}

/* 履歴コンテンツ */
.history-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 履歴コントロール */
.history-controls {
  margin-bottom: 20px;
}

.search-section {
  margin-bottom: 16px;
}

.search-input-group {
  position: relative;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding: 12px 40px 12px 16px;
  border: 2px solid #e5e5ea;
  border-radius: 10px;
  font-size: 16px;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: #007aff;
}

.clear-search-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  background: #8e8e93;
  color: white;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.clear-search-btn:hover {
  background: #666;
}

.filter-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 16px;
  border: 2px solid #e5e5ea;
  background: white;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  color: #8e8e93;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn.active {
  background: #007aff;
  border-color: #007aff;
  color: white;
}

.filter-btn:hover:not(.active) {
  border-color: #007aff;
  color: #007aff;
}

.action-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* 履歴統計 */
.history-stats {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #8e8e93;
}

#selected-count {
  color: #007aff;
  font-weight: 500;
}

/* 履歴グリッド */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

/* 履歴カード */
.history-item {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.history-item.selected {
  border: 2px solid #007aff;
  background: rgba(0, 122, 255, 0.05);
}

/* 履歴カード内のサムネイル */
.history-thumbnail {
  width: 100%;
  height: 220px;
  object-fit: cover;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  background: #f2f2f7;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* 履歴カード内容 */
.history-card-content {
  padding: 16px;
}

.history-prompt {
  font-size: 14px;
  color: #1d1d1f;
  line-height: 1.4;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}

.history-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #8e8e93;
  margin-bottom: 12px;
}

.history-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}

.history-date {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.history-basic-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
}

.history-basic-info span {
  white-space: nowrap;
}

.history-usage-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
}

.history-usage-info span {
  white-space: nowrap;
}

/* 履歴カードアクション */
.history-actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
}

.history-actions .action-group {
  display: flex;
  gap: 4px;
}

.history-btn {
  padding: 6px 12px;
  border: 1px solid #e5e5ea;
  background: white;
  border-radius: 6px;
  font-size: 12px;
  color: #007aff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-btn:hover {
  background: #f2f2f7;
}

.history-btn.danger {
  color: #ff3b30;
}

.history-btn.danger:hover {
  background: rgba(255, 59, 48, 0.1);
}

.favorite-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  transition: transform 0.2s ease;
}

.favorite-btn:hover {
  transform: scale(1.1);
}

.favorite-btn.active {
  color: #ff9500;
}

/* 選択チェックボックス */
.history-checkbox {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #e5e5ea;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.history-checkbox.checked {
  background: #007aff;
  border-color: #007aff;
  color: white;
}

.history-checkbox::after {
  content: '✓';
  font-size: 12px;
  display: none;
}

.history-checkbox.checked::after {
  display: block;
}

/* 履歴が空の場合 */
.history-empty {
  text-align: center;
  padding: 60px 20px;
  color: #8e8e93;
}

.empty-content {
  max-width: 300px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.history-empty h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1d1d1f;
}

.history-empty p {
  font-size: 16px;
  line-height: 1.4;
  margin-bottom: 24px;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .history-controls {
    margin-bottom: 16px;
  }

  .filter-section {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .filter-group,
  .action-group {
    justify-content: center;
  }

  .history-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    padding: 0 10px;
  }

  .history-item {
    border-radius: 8px;
  }

  .history-preview-modal {
    max-width: 100%;
    padding: 20px;
  }

  .history-preview-image {
    max-height: 55vh;
  }

  .history-preview-prompt {
    font-size: 15px;
  }

  .nav-tab {
    padding: 10px 12px;
    font-size: 14px;
  }

  .search-input-group {
    max-width: 100%;
  }

  .history-meta-row {
    font-size: 11px;
  }

  .history-date {
    font-size: 11px;
  }

  .history-basic-info,
  .history-usage-info {
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .history-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .filter-group,
  .action-group {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-btn,
  .secondary-btn {
    width: 100%;
    justify-content: center;
  }

  .history-stats {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .history-thumbnail {
    height: 180px;
  }

  .history-meta-row {
    font-size: 10px;
    gap: 6px;
  }

  .history-date {
    font-size: 10px;
  }

  .history-basic-info,
  .history-usage-info {
    font-size: 9px;
    gap: 6px;
  }

  .history-preview-overlay {
    padding: 16px;
  }

  .history-preview-modal {
    padding: 16px;
    border-radius: 12px;
  }

  .history-preview-image {
    max-height: 50vh;
  }

  .history-preview-meta {
    flex-direction: column;
    gap: 8px;
  }
}

/* フルスクリーン画像表示モーダル */
.fullscreen-image-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: zoom-out;
}

.fullscreen-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: white;
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10001;
  line-height: 1;
  padding: 0;
}

.fullscreen-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.fullscreen-close-btn:active {
  transform: scale(0.95);
}

.fullscreen-image-container {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px 20px;
  pointer-events: none;
}

.fullscreen-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* モバイル対応 */
@media (max-width: 768px) {
  .fullscreen-close-btn {
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    font-size: 24px;
  }

  .fullscreen-image-container {
    padding: 56px 12px 12px;
  }
}

/* ========================================
 * キャッシュ管理・バージョン更新UI
 * ======================================== */

/* キャッシュ管理セクション */
.setting-section {
  margin: 24px 0;
  padding: 20px;
  background: #f8f8f8;
  border-radius: 12px;
  border: 1px solid #e0e0e0;
}

.setting-section h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1d1d1f;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e0e0e0;
}

.setting-item:last-of-type {
  border-bottom: none;
}

.setting-item label {
  font-size: 14px;
  font-weight: 500;
  color: #666;
}

.setting-item span {
  font-size: 14px;
  color: #1d1d1f;
  font-weight: 500;
}

.version-info {
  display: flex;
  gap: 8px;
  align-items: center;
}

.update-badge {
  font-size: 11px;
  padding: 3px 8px;
  background: #ff3b30;
  color: white;
  border-radius: 12px;
  font-weight: 600;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.setting-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 4px;
}

.btn-secondary {
  flex: 1;
  padding: 12px 16px;
  background: #e0e0e0;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1d1d1f;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: #d0d0d0;
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

.btn-primary {
  flex: 1;
  padding: 12px 16px;
  background: #007aff;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: #0051d5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

/* 更新通知バナー */
.update-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 16px 20px;
  min-width: 320px;
  max-width: 90%;
  animation: slideDown 0.3s ease;
  border: 2px solid #007aff;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.update-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.update-content span {
  flex: 1;
  min-width: 180px;
  font-size: 14px;
  font-weight: 600;
  color: #1d1d1f;
}

.update-notification .btn-primary {
  flex: 0 0 auto;
  padding: 10px 20px;
  font-size: 13px;
  white-space: nowrap;
}

.btn-text {
  flex: 0 0 auto;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: #666;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
  white-space: nowrap;
}

.btn-text:hover {
  color: #007aff;
}

/* モバイル対応（キャッシュ管理） */
@media (max-width: 768px) {
  .setting-section {
    padding: 16px;
    margin: 16px 0;
  }

  .setting-section h3 {
    font-size: 15px;
  }

  .setting-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .setting-item label {
    font-size: 13px;
  }

  .setting-item span {
    font-size: 13px;
  }

  .setting-actions {
    flex-direction: column;
  }

  .btn-secondary,
  .btn-primary {
    width: 100%;
    padding: 14px;
  }

  .update-notification {
    min-width: auto;
    max-width: 95%;
    padding: 14px 16px;
  }

  .update-content {
    gap: 10px;
  }

  .update-content span {
    font-size: 13px;
    min-width: 100%;
  }

  .update-notification .btn-primary,
  .update-notification .btn-text {
    font-size: 12px;
    padding: 8px 16px;
  }
}

/* ========================================
   使用状況セクション (Usage Tracking)
   ======================================== */

.usage-content {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* 期間選択 */
.usage-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.period-selector {
  display: flex;
  gap: 8px;
}

.period-btn {
  padding: 10px 20px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.period-btn:hover {
  background: #f5f5f5;
  border-color: #007aff;
}

.period-btn.active {
  background: #007aff;
  color: white;
  border-color: #007aff;
}

/* サマリーカード */
.usage-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.summary-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.summary-card.highlight {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.summary-icon {
  font-size: 32px;
  line-height: 1;
}

.summary-content {
  flex: 1;
}

.summary-label {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.8;
  margin-bottom: 4px;
}

.summary-card.highlight .summary-label {
  opacity: 0.9;
}

.summary-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.summary-sub {
  font-size: 14px;
  font-weight: 500;
  opacity: 0.8;
  margin-top: 4px;
}

/* モデル別詳細 */
.usage-details {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 24px;
}

.usage-details h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #333;
}

.usage-table-container {
  overflow-x: auto;
}

.usage-table {
  width: 100%;
  border-collapse: collapse;
}

.usage-table thead {
  background: #f8f9fa;
}

.usage-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  border-bottom: 2px solid #e0e0e0;
  white-space: nowrap;
}

.usage-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid #f0f0f0;
}

.usage-table tbody tr:hover {
  background: #f8f9fa;
}

.usage-table .usage-empty {
  text-align: center;
  color: #999;
  font-style: italic;
}

/* データ管理 */
.usage-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.usage-actions .danger {
  background: #ff3b30;
  color: white;
}

.usage-actions .danger:hover {
  background: #e63329;
}

/* ========================================
   課金警告モーダル (Billing Warning)
   ======================================== */

.billing-warning {
  max-width: 600px;
}

.modal-header.warning {
  background: linear-gradient(135deg, #ff6b6b 0%, #ff8787 100%);
  color: white;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.modal-header.warning h2 {
  color: white;
}

.warning-content {
  padding: 0;
}

.warning-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e0e0e0;
}

.warning-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.warning-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #333;
}

.warning-list {
  list-style: none;
  padding: 0;
}

.warning-list li {
  padding: 8px 0;
  padding-left: 24px;
  position: relative;
  font-size: 14px;
  line-height: 1.6;
}

.warning-list li::before {
  content: '⚠️';
  position: absolute;
  left: 0;
}

.warning-list strong {
  color: #ff3b30;
  font-weight: 600;
}

.pricing-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.pricing-table td {
  padding: 8px 12px;
  font-size: 14px;
  border-bottom: 1px solid #f0f0f0;
}

.pricing-table td:first-child {
  font-weight: 500;
  color: #666;
}

.pricing-table td:last-child {
  text-align: right;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-weight: 600;
  color: #007aff;
}

.pricing-note {
  margin-top: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.6;
  color: #666;
}

.warning-section p {
  font-size: 14px;
  line-height: 1.6;
  color: #666;
  margin-bottom: 8px;
}

.warning-section a {
  color: #007aff;
  text-decoration: none;
  font-weight: 500;
}

.warning-section a:hover {
  text-decoration: underline;
}

.warning-checkbox {
  background: #f8f9fa;
  padding: 16px;
  border-radius: 8px;
  margin-top: 24px;
}

.warning-checkbox label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.warning-checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

#billing-warning-close:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========================================
   モバイル対応（使用状況セクション）
   ======================================== */

@media (max-width: 768px) {
  .usage-content {
    padding: 16px;
  }

  .usage-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .period-selector {
    width: 100%;
  }

  .period-btn {
    flex: 1;
    padding: 12px 16px;
  }

  .usage-summary {
    grid-template-columns: 1fr;
  }

  .summary-card {
    padding: 16px;
  }

  .summary-icon {
    font-size: 28px;
  }

  .summary-value {
    font-size: 24px;
  }

  .usage-details {
    padding: 16px;
  }

  .usage-table th,
  .usage-table td {
    padding: 10px 12px;
    font-size: 13px;
  }

  .usage-table th {
    font-size: 12px;
  }

  .usage-actions {
    flex-direction: column;
  }

  .usage-actions button {
    width: 100%;
  }

  .billing-warning {
    max-width: 95%;
  }

  .warning-section h3 {
    font-size: 15px;
  }

  .warning-list li {
    font-size: 13px;
  }

  .pricing-table td {
    font-size: 13px;
    padding: 6px 10px;
  }
}

/* ===================================
   Analytics同意ダイアログ（CSP対応）
   =================================== */
.analytics-consent-dialog {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 20px 24px;
  max-width: 500px;
  z-index: 10000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui;
}

.analytics-consent-dialog h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: #1d1d1f;
}

.analytics-consent-dialog p {
  margin: 0 0 16px 0;
  font-size: 14px;
  line-height: 1.6;
  color: #6e6e73;
}

.analytics-consent-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.analytics-consent-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.analytics-consent-btn.decline {
  border: 1px solid #d2d2d7;
  background: white;
  color: #1d1d1f;
}

.analytics-consent-btn.accept {
  border: none;
  background: #007aff;
  color: white;
}

/* ===================================
   ErrorBoundary フォールバックUI（CSP対応）
   =================================== */
.error-boundary-container {
  padding: 40px 24px;
  text-align: center;
}

.error-boundary-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-boundary-title {
  margin-bottom: 12px;
  font-size: 20px;
}

.error-boundary-message {
  margin-bottom: 24px;
}

.error-boundary-reload-btn {
  padding: 10px 20px;
  border-radius: 8px;
  background: #007aff;
  color: #fff;
  border: none;
  cursor: pointer;
}

.error-boundary-note {
  margin-top: 16px;
  color: #ff3b30;
  font-weight: 500;
}

.error-boundary-stack {
  margin-top: 16px;
  padding: 12px;
  background: #f5f5f7;
  border-radius: 8px;
  text-align: left;
  font-size: 12px;
  overflow-x: auto;
}

.error-boundary-meta {
  margin-top: 16px;
  text-align: left;
  list-style: none;
  padding: 0;
}

.error-boundary-meta li {
  margin-bottom: 8px;
  font-size: 14px;
}

.error-boundary-meta strong {
  font-weight: 600;
}

/* カラーパレット色定義（CSP対応） */
.color-btn.color-red {
  background: rgba(255, 0, 0, 0.3);
}

.color-btn.color-green {
  background: rgba(0, 255, 0, 0.3);
}

.color-btn.color-blue {
  background: rgba(0, 0, 255, 0.3);
}

.color-btn.color-yellow {
  background: rgba(255, 255, 0, 0.3);
}

/* hiddenユーティリティクラス */
.hidden {
  display: none;
}

/* インストール通知バナー（CSP対応） */
.install-notification {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
}

.install-message {
  flex: 1;
}

.install-btn {
  background: #007aff;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.install-btn:hover {
  background: #0051d5;
}

.install-close-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #666;
  padding: 4px 8px;
}

.install-close-btn:hover {
  color: #333;
}

/* 参照画像アニメーション（main.jsから移行） */
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

.reference-image-item {
  position: relative;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
  cursor: move;
}

.reference-image-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.reference-image-item img {
  width: 100%;
  height: 80px;
  object-fit: cover;
}

.reference-image-info {
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.filename {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #333;
}

.remove-btn {
  background: #ff4757;
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-btn:hover {
  background: #ff3742;
}

/* 更新通知ボタン（ui.jsから移行） */
.update-notification-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.update-notification-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* エクスポート/インポートボタン */
#export-history-btn,
#import-history-btn {
  font-weight: 500;
}

#export-history-btn:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

#import-history-btn:hover {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

/* =============================================
   テンプレート機能スタイル
   ============================================= */

/* テンプレートコンテンツ */
.templates-content {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

/* テンプレートコントロール */
.templates-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* テンプレートアクショングループ */
.template-actions-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* カテゴリフィルター */
.category-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.category-filter .filter-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid rgba(0, 122, 255, 0.3);
  background: white;
  color: #007aff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-filter .filter-btn:hover {
  background: rgba(0, 122, 255, 0.1);
  transform: translateY(-1px);
}

.category-filter .filter-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* テンプレートグリッド */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

/* テンプレートカード */
.template-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.template-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* テンプレートヘッダー */
.template-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.template-name {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* プリセットバッジ */
.preset-badge {
  display: inline-block;
  padding: 2px 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
}

/* プロンプト表示 */
.template-prompt {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* テンプレートアクション */
.template-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.template-use-btn,
.template-edit-btn,
.template-delete-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-use-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.template-use-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.template-edit-btn {
  background: rgba(0, 122, 255, 0.1);
  color: #007aff;
}

.template-edit-btn:hover {
  background: rgba(0, 122, 255, 0.2);
}

.template-delete-btn {
  background: rgba(255, 71, 87, 0.1);
  color: #ff4757;
}

.template-delete-btn:hover {
  background: rgba(255, 71, 87, 0.2);
}

/* テンプレート空状態 */
.templates-empty {
  text-align: center;
  padding: 60px 20px;
  grid-column: 1 / -1;
}

.templates-empty .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.templates-empty h3 {
  font-size: 20px;
  color: #333;
  margin-bottom: 8px;
}

.templates-empty p {
  font-size: 14px;
  color: #666;
}

/* テンプレートモーダル */
#template-modal .setting-group {
  margin-bottom: 20px;
}

#template-modal label {
  display: block;
  font-weight: 500;
  color: #333;
  margin-bottom: 8px;
  font-size: 14px;
}

#template-modal .required {
  color: #ff4757;
  margin-left: 4px;
}

#template-modal input[type="text"],
#template-modal textarea,
#template-modal select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

#template-modal input[type="text"]:focus,
#template-modal textarea:focus,
#template-modal select:focus {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

#template-modal textarea {
  resize: vertical;
  min-height: 120px;
}

#template-modal select {
  cursor: pointer;
  background: white;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .templates-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .category-filter {
    justify-content: center;
  }

  .templates-grid {
    grid-template-columns: 1fr;
  }

  .template-actions {
    flex-direction: column;
  }

  .template-use-btn,
  .template-edit-btn,
  .template-delete-btn {
    width: 100%;
  }
}

/* ========================================
   Gemini 3 Pro対応スタイル
   ======================================== */

/* モデル選択設定 */
.setting-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
}

.setting-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-badge.new-badge {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setting-label {
  display: block;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
  font-size: 14px;
}

.setting-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: white;
  transition: all 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  cursor: pointer;
}

.setting-select:focus {
  outline: none;
  border-color: #007aff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.setting-select:hover {
  border-color: #9ca3af;
}

.setting-description {
  font-size: 13px;
  color: #6b7280;
  margin-top: 8px;
  line-height: 1.5;
}

.setting-description strong {
  color: #374151;
  font-weight: 600;
}

.setting-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #f3f4f6;
  border-radius: 8px;
  font-size: 14px;
  color: #374151;
  margin-top: 16px;
}

.info-icon {
  font-size: 18px;
  flex-shrink: 0;
}

/* コスト推定表示 */
.cost-estimate {
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cost-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.cost-label {
  font-size: 14px;
  color: #6b7280;
  font-weight: 500;
}

.cost-value {
  font-size: 24px;
  font-weight: 700;
  color: #10b981;
  transition: color 0.3s ease;
}

.cost-detail {
  font-size: 13px;
  color: #9ca3af;
}

.model-info {
  display: flex;
  gap: 8px;
  align-items: center;
}

.model-chip {
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.3s ease;
}

.flash-chip {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.pro-chip {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* ローディング詳細メッセージ */
.loading-detail {
  margin-top: 12px;
  font-size: 14px;
  color: #6b7280;
  text-align: center;
  max-width: 300px;
  line-height: 1.5;
}

.loading-progress {
  width: 100%;
  max-width: 300px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin-top: 16px;
  overflow: hidden;
}

.progress-bar-animated {
  height: 100%;
  background: linear-gradient(90deg, #007aff, #5856d6);
  animation: progress-animation 2s ease-in-out infinite;
}

@keyframes progress-animation {
  0% {
    width: 0%;
    opacity: 1;
  }
  50% {
    width: 100%;
    opacity: 0.8;
  }
  100% {
    width: 100%;
    opacity: 0;
  }
}

/* トースト通知 */
.toast-notification {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  transition: transform 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

.toast-notification.show {
  transform: translateX(-50%) translateY(0);
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .cost-estimate {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .cost-info {
    width: 100%;
  }

  .cost-value {
    font-size: 20px;
  }

  .model-info {
    width: 100%;
    justify-content: flex-start;
  }

  .setting-section h3 {
    font-size: 15px;
  }

  .setting-select {
    font-size: 14px;
  }
}

/* アクセシビリティ対応 */
@media (prefers-reduced-motion: reduce) {
  .progress-bar-animated {
    animation: none;
  }

  .toast-notification {
    transition: none;
  }

  .model-chip {
    transition: none;
  }
}
