/* ===== デザインの土台（色・文字・余白・角丸・影） ===== */
:root {
  /* ベースカラー */
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-sub: #f8f9fc;
  --border: #e3e6ee;

  /* テキストカラー */
  --text: #1c2030;
  --text-sub: #5b6274;     /* 補足文（白背景でコントラスト比 約6:1） */

  /* エリアごとの色：アシスタント＝ティール、生成＝パープル */
  --assist: #0b8f80;
  --assist-strong: #097a6d;
  --assist-soft: #e7f5f3;
  --generate: #6d45f0;
  --generate-strong: #5a34d6;
  --generate-soft: #f0ecff;

  /* 状態の色 */
  --danger: #c62f2f;
  --danger-soft: #fdeeee;

  /* 角丸・影 */
  --radius-card: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(20, 30, 60, 0.04), 0 8px 24px rgba(20, 30, 60, 0.06);

  /* フォント（英字は Inter、日本語は Noto Sans JP） */
  --font: "Inter", "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}

/* パネルごとに使う色を切り替える（中の部品は --accent を使う） */
.panel-assistant { --accent: var(--assist); --accent-strong: var(--assist-strong); --accent-soft: var(--assist-soft); }
.panel-generate  { --accent: var(--generate); --accent-strong: var(--generate-strong); --accent-soft: var(--generate-soft); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
}

/* SVGアイコン共通（線の太さ・色を統一） */
svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== ヘッダー ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
}
.logo-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--assist), var(--generate));
  color: #fff;
  font-size: 20px;
}
.app-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-sub);
  background: var(--surface-sub);
  border: 1px solid var(--border);
  padding: 0 10px;
  border-radius: 999px;
}

/* ===== 2カラムレイアウト（PC） ===== */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  padding-top: 40px;
  padding-bottom: 40px;
  align-items: start;
}

/* ===== カード（パネル） ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius-card);
  padding: 32px;
  box-shadow: var(--shadow-card);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.panel-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 24px;
}
.panel-head h2 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.4;
}
.step {
  display: inline-block;
  font-family: "Inter", sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.lead {
  margin: 0 0 28px;
  color: var(--text-sub);
  font-size: 0.9375rem;
}

/* ===== 入力欄 ===== */
.field { margin-bottom: 20px; min-width: 0; }
.field > label:not(.upload-box),
.field-label {
  display: block;
  font-weight: 700;
  font-size: 0.875rem;
  margin-bottom: 8px;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;            /* 16px以上にしてスマホでの自動拡大を防ぐ */
  line-height: 1.6;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sub);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
select {
  min-height: 48px;
  appearance: none;
  padding-right: 40px;
  cursor: pointer;
  /* 下向き矢印 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6274' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
}
textarea { resize: vertical; min-height: 120px; }
textarea::placeholder { color: #8a91a2; }
select:hover, textarea:hover { border-color: #cfd4df; }
select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background-color: var(--surface);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* アップロード欄 */
.upload-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 28px 16px;
  border: 2px dashed #c4d9d6;
  border-radius: var(--radius-md);
  background: var(--surface-sub);
  color: var(--text-sub);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-box:hover,
.upload-box.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 22px;
  box-shadow: 0 2px 8px rgba(20, 30, 60, 0.08);
}
.upload-text { font-weight: 500; color: var(--text); font-size: 0.9375rem; }
.upload-box small { font-size: 0.8125rem; }
.file-name {
  margin: 8px 0 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent-strong);
}
.file-name:empty { display: none; }

/* ===== ボタン ===== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  margin-top: 8px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px -6px var(--accent);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }

/* 処理中（disabled）はスピナーを表示 */
.btn:disabled { opacity: 0.75; cursor: wait; transform: none; }
.btn:disabled::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* エラー表示 */
.error-msg {
  margin: 12px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9375rem;
  font-weight: 500;
}

/* ===== 出力エリア ===== */
.result-box, .preview-area {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.result-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-sub);
}
.result-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
#assistant-result {
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  font-size: 0.9375rem;
}
.result-title { margin: 0 0 4px; font-weight: 700; }
#assistant-result ul { margin: 0; padding-left: 1.2em; }
#assistant-result li { margin-bottom: 6px; }
.ai-text { white-space: pre-wrap; margin: 0; }

/* プレビューカード：PCでは横並び */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--surface);
  transition: box-shadow 0.15s;
}
.preview-card:hover { box-shadow: var(--shadow-card); }
.preview-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  margin-bottom: 10px;
}
.preview-card-head strong { font-family: "Inter", sans-serif; color: var(--accent); }
.preview-card-head span {
  color: var(--text-sub);
  background: var(--surface-sub);
  padding: 0 8px;
  border-radius: 999px;
}
.preview-image {
  aspect-ratio: 2 / 3;          /* 生成画像（1024x1536）と同じ縦横比 */
  border-radius: var(--radius-sm);
  background: var(--surface-sub);
  border: 1.5px dashed #d3cbf5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--text-sub);
  overflow: hidden;
}
.preview-image b { color: var(--accent); font-size: 0.875rem; margin-bottom: 4px; }
.preview-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}
.preview-image.has-image { border: none; padding: 0; background: var(--surface); }
.preview-image.loading { background: var(--accent-soft); animation: pulse 1.4s ease-in-out infinite; }
.preview-image.failed { color: var(--danger); border-color: #f2c4c4; background: var(--danger-soft); }
.preview-image.failed b { color: var(--danger); }
@keyframes pulse { 50% { opacity: 0.55; } }

/* ===== フッター ===== */
.app-footer {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-sub);
  padding: 0 16px 40px;
}
.app-footer p { margin: 0; }

/* ===== タブレット（〜960px）：1カラム、横に伸びすぎないよう幅を制限 ===== */
@media (max-width: 960px) {
  .main-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    max-width: 760px;
  }
}

/* ===== スマホ（〜600px） ===== */
@media (max-width: 600px) {
  .container { padding: 0 16px; }
  .header-inner { height: 56px; }
  .app-title { font-size: 1.0625rem; }
  .logo-mark { width: 32px; height: 32px; font-size: 18px; }
  .main-grid { padding-top: 20px; padding-bottom: 24px; gap: 20px; }
  .panel { padding: 24px 20px; border-radius: 16px; }
  .panel-icon { width: 44px; height: 44px; font-size: 22px; }
  .panel-head h2 { font-size: 1.1875rem; }
  .lead { margin-bottom: 24px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }  /* 選択欄は縦並び */
  .preview-grid { grid-template-columns: 1fr; }        /* プレビューは縦並び */
  #assistant-result { padding: 16px 18px; }
}
