/* =========================================================================
   Manga Creative Studio - モックアップ用スタイル
   シンプルでモダンなWebアプリ風。2つの役割を色で分けています。
   - 企画・アイデア出しアシスタント … インディゴ（紫）
   - 漫画生成                       … ピンク（ローズ）
   ========================================================================= */

:root {
  --bg: #f3f4fb;
  --card: #ffffff;
  --text: #1f2433;
  --text-muted: #5b6472;
  --border: #e6e8ef;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(30, 34, 51, 0.07);

  /* 役割ごとのアクセントカラー */
  --assistant: #6366f1;
  --assistant-soft: #eef0ff;
  --generate: #ec4899;
  --generate-soft: #fdecf6;

  --font: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic",
    "Meiryo", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
::selection { background: color-mix(in srgb, var(--assistant) 22%, transparent); }

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

/* ------------------------------------------------------------------ */
/* ヘッダー（アプリ名）                                                */
/* ------------------------------------------------------------------ */
.app-header {
  background: linear-gradient(120deg, #6366f1 0%, #a855f7 52%, #ec4899 100%);
  color: #fff;
  padding: 30px 20px;
}
.app-header__inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.app-header__logo {
  font-size: 40px;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
}
.app-header__title {
  margin: 0;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.app-header__subtitle {
  margin: 5px 0 0;
  font-size: 14px;
  opacity: 0.92;
}

/* ------------------------------------------------------------------ */
/* 全体レイアウト（PC＝2カラム / スマホ＝1カラム）                     */
/* ------------------------------------------------------------------ */
.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

/* ------------------------------------------------------------------ */
/* パネル（カード型UI）                                                */
/* ------------------------------------------------------------------ */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-top: 5px solid var(--accent);
  padding: 26px 24px 28px;
}
/* 役割ごとにアクセントカラーを切り替え */
.panel--assistant {
  --accent: var(--assistant);
  --accent-soft: var(--assistant-soft);
}
.panel--generate {
  --accent: var(--generate);
  --accent-soft: var(--generate-soft);
}

.panel__head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.panel__icon {
  width: 54px;
  height: 54px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 27px;
  border-radius: 14px;
  background: var(--accent-soft);
}
.panel__eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.panel__title {
  margin: 3px 0 0;
  font-size: 21px;
  font-weight: 800;
}
.panel__desc {
  margin: 14px 0 22px;
  font-size: 14px;
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ */
/* 入力フィールド                                                     */
/* ------------------------------------------------------------------ */
.field { margin-bottom: 18px; }
.field__label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 7px;
}
.input {
  width: 100%;
  font-family: inherit;
  font-size: 16px; /* 16px 以上でスマホの自動ズームを防ぎ、読みやすく */
  color: var(--text);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
textarea.input { resize: vertical; min-height: 104px; }

/* セレクトは標準の矢印を消し、統一感のあるモダンなドロップダウン矢印にする */
select.input {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6472' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 42px;
}

/* 2つのフィールドを横並び（枚数・コマ数など） */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ------------------------------------------------------------------ */
/* ラフ画像アップロード欄（見た目だけのダミー）                       */
/* ------------------------------------------------------------------ */
.upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 28px 16px;
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.upload:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, #fff);
}
.upload__icon { font-size: 30px; }
.upload__text { font-weight: 700; font-size: 14px; }
.upload__hint { font-size: 12px; color: var(--text-muted); }
.upload__filename {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* ボタン（押しやすく目立つデザイン）                                 */
/* ------------------------------------------------------------------ */
.btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 15px 18px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 24%, transparent);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}
.btn:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn:active { transform: translateY(0); }
/* キーボード操作でも「今どこを選んでいるか」が分かるようにする */
.btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* 結果・プレビュー共通の枠                                           */
/* ------------------------------------------------------------------ */
.result,
.preview {
  margin-top: 24px;
  padding: 18px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
}
.result__label,
.preview__label {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* アシスタントのサンプル回答 */
.result__body {
  background: #fff;
  border-radius: 10px;
  padding: 16px 18px;
}
.result__heading {
  margin: 0 0 8px;
  font-weight: 800;
  font-size: 15px;
}
.result__list {
  margin: 0;
  padding-left: 1.15em;
  font-size: 14px;
  color: #374151;
}
.result__list li { margin-bottom: 6px; }
.result__list li:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ */
/* 漫画生成プレビュー（カード形式）                                   */
/* PC＝横並び / スマホ＝縦並び                                        */
/* ------------------------------------------------------------------ */
.preview__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.preview-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.preview-card__thumb {
  aspect-ratio: 3 / 4;
  background:
    linear-gradient(135deg, #fafafe 0%, var(--accent-soft) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.preview-card__thumb-icon { font-size: 30px; opacity: 0.65; }
.preview-card__thumb-text { font-size: 12px; font-weight: 700; }
.preview-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 0;
}
.preview-card__title { margin: 0; font-weight: 800; font-size: 14px; }
.preview-card__badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--generate);
  background: var(--generate-soft);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.preview-card__note {
  margin: 7px 12px 12px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ------------------------------------------------------------------ */
/* フッター                                                           */
/* ------------------------------------------------------------------ */
.app-footer {
  text-align: center;
  padding: 8px 20px 40px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ */
/* レスポンシブ（タブレット・スマホ）                                 */
/* ------------------------------------------------------------------ */

/* タブレット縦・小さめPC：2カラム → 1カラム */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
}

/* スマホ：横並びの入力・プレビューを縦並びに */
@media (max-width: 640px) {
  .app-header { padding: 24px 16px; }
  .app-header__title { font-size: 22px; }
  .app-header__logo { font-size: 34px; }
  .layout { padding: 20px 16px 32px; gap: 20px; }
  .panel { padding: 22px 18px 24px; }
  .field-row { grid-template-columns: 1fr; }
  .preview__grid { grid-template-columns: 1fr; }
}

/* ================================================================== */
/* OpenAI API 連携で追加：読み込み中・エラー表示・回答・生成画像      */
/* ================================================================== */

/* お知らせ／エラーメッセージ */
.notice {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.6;
}
.notice--info {
  color: #3730a3;
  background: #eef0ff;
  border: 1px solid #c7d2fe;
}
.notice--error {
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecaca;
}

/* AIの回答（改行をそのまま表示） */
.assist-answer {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.8;
  color: #374151;
}

/* 実行中のボタン */
.btn:disabled {
  opacity: 0.7;
  cursor: progress;
  transform: none;
}

/* 生成された漫画画像 */
.preview-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 読み込み中スピナー */
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid color-mix(in srgb, var(--accent, #6366f1) 30%, #fff);
  border-top-color: var(--accent, #6366f1);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================== */
/* 追加機能：A. ストーリー作成ボタン / B. キャラクターラフ作成       */
/* ================================================================== */

/* 「漫画生成へ入れる」ボタン（アシスタント側） */
.btn--insert {
  margin-top: 12px;
  font-size: 14px;
  padding: 12px 16px;
}

/* B. キャラクターラフ作成：漫画生成パネル内の独立ブロック */
.subpanel {
  background: var(--generate-soft);
  border: 1px solid color-mix(in srgb, var(--generate) 22%, var(--border));
  border-radius: 14px;
  padding: 18px 16px 20px;
}
.subpanel__head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.subpanel__icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 22px;
  border-radius: 12px;
  background: #fff;
}
.subpanel__title { margin: 2px 0 0; font-size: 17px; font-weight: 800; }
.subpanel__desc { margin: 10px 0 16px; font-size: 13px; color: var(--text-muted); }

/* キャラクターラフのプレビューは白背景で、1枚だけ・大きすぎないように */
#character-preview { background: #fff; }
#character-grid { grid-template-columns: 1fr; max-width: 320px; }

/* 機能の境界をはっきりさせる仕切り線 */
.divider {
  border: none;
  border-top: 2px dashed color-mix(in srgb, var(--generate) 35%, var(--border));
  margin: 28px 0;
}

/* 漫画ページ生成ブロックの見出し（キャラ作成との境界を分かりやすく） */
.block-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.block-head__icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 22px;
  border-radius: 12px;
  background: var(--generate-soft);
}

/* 「キャラクターラフを主人公として使う」チェックボックス */
.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--generate);
  cursor: pointer;
}
.checkbox input:disabled { cursor: not-allowed; opacity: 0.6; }
.field-hint { margin: 6px 0 0; font-size: 12px; color: var(--text-muted); }

/* スマホでは仕切りの余白を少し詰める */
@media (max-width: 640px) {
  #character-grid { grid-template-columns: 1fr; }
  .divider { margin: 18px 0; }
}
