/* =========================================================
   Manga Creative Studio
   デザインルール：色・角丸・影・余白はここの変数を使い回す
   ========================================================= */
:root {
  /* ベース */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-sub: #f9fafc;
  --text: #1c2030;
  --text-sub: #4a5068;
  --muted: #646a80;          /* 白背景で 5:1 以上 */
  --border: #e4e7ef;
  --border-strong: #cfd4e0;

  /* 機能ごとのテーマ色（白文字で 4.5:1 以上） */
  --assistant: #5b4bdb;       /* 企画アシスタント：インディゴ */
  --assistant-hover: #4a3bc6;
  --assistant-soft: #f1efff;
  --assistant-line: #d8d2fb;
  --generate: #d9480f;        /* 漫画生成：オレンジ */
  --generate-hover: #c03f0c;
  --generate-soft: #fff3ec;
  --generate-line: #fcd5c2;

  --danger: #c62828;
  --danger-soft: #fdecec;

  /* 形・影 */
  --radius-lg: 20px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(28, 32, 48, 0.04), 0 8px 24px rgba(28, 32, 48, 0.06);
  --ring: 0 0 0 4px rgba(91, 75, 219, 0.18);

  --font: "Inter", "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background:
    radial-gradient(1200px 400px at 10% -10%, #ece9ff 0%, transparent 60%),
    radial-gradient(1000px 400px at 100% 0%, #fff0e6 0%, transparent 55%),
    var(--bg);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
}

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

.icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ===== ヘッダー ===== */
.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;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--assistant), var(--generate));
  color: #fff;
}
.brand-mark .icon { width: 22px; height: 22px; }
.app-title { margin: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.app-subtitle { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.4; }

.step-nav { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-sub); }
.step-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}
.step-nav a:hover { background: var(--surface-sub); }
.step-nav .arrow { color: var(--border-strong); }

/* ===== メインレイアウト（PC: 2カラム） ===== */
.intro { padding: 48px 0 8px; }
.intro h2 { margin: 0 0 8px; font-size: 1.75rem; line-height: 1.4; letter-spacing: -0.01em; }
.intro p { margin: 0; color: var(--text-sub); }

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  padding-top: 32px;
  padding-bottom: 48px;
  align-items: start;
}
.column { display: flex; flex-direction: column; gap: 32px; min-width: 0; }

/* ===== カード ===== */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  scroll-margin-top: 96px;
}

.card-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 28px; }
.step-num {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1.1rem;
}
.card-assistant .step-num { background: var(--assistant-soft); color: var(--assistant); }
.card-generate .step-num,
.preview-section .step-num { background: var(--generate-soft); color: var(--generate); }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.4;
}
.badge-assistant { color: var(--assistant); }
.badge-generate { color: var(--generate); }

.card h2 { margin: 2px 0 6px; font-size: 1.35rem; line-height: 1.45; letter-spacing: -0.01em; }
.description { margin: 0; color: var(--text-sub); font-size: 0.93rem; line-height: 1.7; }

/* ===== 入力欄 ===== */
.field { margin-bottom: 24px; }
.field > label:not(.upload-box) {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.field > label .optional { margin-left: 6px; font-weight: 500; color: var(--muted); font-size: 0.8rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

select,
textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;           /* 16px: スマホでの自動ズームを防ぐ */
  font-family: inherit;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
select {
  min-height: 48px;
  appearance: none;
  padding-right: 44px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23646a80' 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;
}
textarea { resize: vertical; min-height: 120px; }
textarea::placeholder { color: #8a8fa3; }
select:hover,
textarea:hover { border-color: #b9bfce; }
select:focus,
textarea:focus { outline: none; border-color: var(--assistant); box-shadow: var(--ring); }
.card-generate select:focus,
.card-generate textarea:focus { border-color: var(--generate); box-shadow: 0 0 0 4px rgba(217, 72, 15, 0.16); }

.upload-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 20px;
  text-align: center;
  border: 1.5px dashed var(--assistant-line);
  border-radius: var(--radius);
  background: var(--surface-sub);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.15s, border-color 0.15s;
}
.upload-box:hover { background: var(--assistant-soft); border-color: var(--assistant); }
.upload-box:focus-within { box-shadow: var(--ring); border-color: var(--assistant); }
.upload-box small { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.upload-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--assistant-soft);
  color: var(--assistant);
}
.upload-icon .icon { width: 24px; height: 24px; }
.upload-thumb { max-width: 100%; max-height: 200px; margin-top: 10px; border-radius: var(--radius-sm); box-shadow: var(--shadow); }

/* ===== ボタン ===== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 14px 24px;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: 0.65; cursor: wait; transform: none; }
.btn-assistant { background: var(--assistant); box-shadow: 0 6px 16px rgba(91, 75, 219, 0.25); }
.btn-assistant:hover:not(:disabled) { background: var(--assistant-hover); }
.btn-generate { background: var(--generate); box-shadow: 0 6px 16px rgba(217, 72, 15, 0.22); }
.btn-generate:hover:not(:disabled) { background: var(--generate-hover); }
.btn-generate:focus-visible { box-shadow: 0 0 0 4px rgba(217, 72, 15, 0.22); }

/* ===== アシスタントの出力 ===== */
.output-box {
  margin-top: 28px;
  padding: 24px;
  background: var(--surface-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.output-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--assistant);
  font-weight: 700;
}
.output-label .icon { width: 18px; height: 18px; }
.answer { font-size: 0.95rem; color: var(--text); }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer h3 { margin: 20px 0 6px; font-size: 1.05rem; line-height: 1.5; }
.answer h4 { margin: 16px 0 4px; font-size: 0.95rem; }
.answer p { margin: 0 0 10px; }
.answer ul { margin: 0 0 10px; padding-left: 1.3em; }
.answer li { margin-bottom: 6px; }
.answer li::marker { color: var(--assistant); }
.output-title { font-weight: 700; }

/* ===== エラー・ステータス ===== */
.error-box {
  margin: 16px 0 0;
  padding: 12px 16px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.6;
}
.status-text { margin: 0; color: var(--muted); font-size: 0.85rem; }

/* ===== 生成結果プレビュー ===== */
.preview-head-row { margin-bottom: 20px; }
.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.preview-head span {
  color: var(--muted);
  font-size: 0.75rem;
  background: var(--surface-sub);
  padding: 2px 8px;
  border-radius: 999px;
}
.preview-image {
  aspect-ratio: 2 / 3;       /* 生成画像（1024×1536）と同じ縦長比率 */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background-color: var(--surface-sub);
  background-image: radial-gradient(#dfe3ec 1px, transparent 1px);
  background-size: 14px 14px;
  color: var(--muted);
}
.preview-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--generate);
  background: var(--generate-soft);
  padding: 2px 10px;
  border-radius: 999px;
}
.preview-image p { margin: 0; font-size: 0.8rem; line-height: 1.6; }
.preview-image.has-image { padding: 0; background: #fff; }
.preview-image img { width: 100%; height: 100%; object-fit: contain; display: block; }
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--generate-line);
  border-top-color: var(--generate);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ===== タブレット（1列。横に伸びすぎないよう幅を制限） ===== */
@media (max-width: 960px) {
  .main-grid { grid-template-columns: minmax(0, 1fr); max-width: 720px; }
  .intro { max-width: 720px; }
  .preview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ===== スマホ・タブレット縦 ===== */
@media (max-width: 768px) {
  .container { padding: 0 20px; }
  .step-nav { display: none; }
  .intro { padding-top: 32px; }
  .intro h2 { font-size: 1.4rem; }
  .main-grid { gap: 24px; padding-top: 24px; }
  .column { gap: 24px; }
  .card { padding: 24px 20px; border-radius: 16px; }
  .card-head { margin-bottom: 24px; gap: 12px; }
  .step-num { width: 40px; height: 40px; }
  .card h2 { font-size: 1.2rem; }
  .preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .app-subtitle { display: none; }
  .step-num { display: none; }   /* 狭い画面では STEP ラベルだけで十分 */
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .preview-grid { grid-template-columns: 1fr; }
  .output-box { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .spinner { animation-duration: 2s; }
}
