/* =========================================================
   Manga Creative Studio — スタイル
   色・角丸・影・余白は :root の変数にまとめ、画面全体で使い回します。
   ========================================================= */
:root {
  /* ベースカラー */
  --bg: #f4f5f9;
  --card: #ffffff;
  --surface: #f8f9fc;      /* 入力欄・サブエリアの背景 */
  --text: #1c2030;
  --muted: #5f6478;        /* 補足文字（白背景でコントラスト 5.5:1 程度） */
  --border: #e4e6ef;
  --border-strong: #cfd3e0;

  /* メインカラー（エリアごとに色分け） */
  --assist: #6d45f0;       /* 企画アシスタント：紫 */
  --assist-strong: #5a34d6;
  --assist-soft: #f1ecff;
  --gen: #f0602e;          /* 漫画生成：オレンジ */
  --gen-strong: #d84d1d;
  --gen-soft: #fff0ea;

  /* エラー */
  --danger: #b42318;
  --danger-soft: #fef0ef;

  /* 角丸・影 */
  --radius-lg: 20px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(20, 24, 40, .04), 0 8px 24px rgba(20, 24, 40, .06);

  /* フォント（英字は Apple / Segoe、日本語はヒラギノ・Noto・游ゴシック） */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 400px at 0% -10%, rgba(109, 69, 240, .07), transparent 60%),
    radial-gradient(1000px 400px at 100% -10%, rgba(240, 96, 46, .06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

/* ===== ヘッダー（スクロールしても上に残る） ===== */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.header-inner { display: flex; align-items: center; gap: 14px; }
.logo {
  display: grid; place-items: center; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: 12px; font-size: 22px;
  background: linear-gradient(135deg, var(--assist-soft), var(--gen-soft));
  border: 1px solid var(--border);
}
.app-header h1 { margin: 0; font-size: 1.25rem; line-height: 1.3; letter-spacing: .01em; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: .85rem; line-height: 1.4; }
.badge-mock {
  margin-left: auto; font-size: .75rem; font-weight: 700; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px;
}

/* ===== レイアウト：PC は 2カラム ===== */
.main-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 32px; padding-top: 40px; padding-bottom: 40px; align-items: start;
}

/* ===== パネル（カード） ===== */
.panel {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px; box-shadow: var(--shadow-card);
}
/* カード上部の細いアクセントライン */
.panel::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; }
.panel-assist::before { background: linear-gradient(90deg, var(--assist), #9b7bff); }
.panel-generate::before { background: linear-gradient(90deg, var(--gen), #ff9a62); }

.panel-head { margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.step {
  display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .12em;
  padding: 4px 12px; border-radius: 999px; line-height: 1.4;
}
.panel-assist .step { background: var(--assist-soft); color: var(--assist-strong); }
.panel-generate .step { background: var(--gen-soft); color: var(--gen-strong); }
.panel h2 { margin: 12px 0 8px; font-size: 1.4rem; line-height: 1.4; letter-spacing: .01em; }
.desc { margin: 0; color: var(--muted); font-size: .95rem; }

/* ===== フォーム ===== */
.field { margin-bottom: 24px; flex: 1; min-width: 0; }
/* アップロード欄（.upload）も label なので、見出し用ラベルのスタイルから除外する */
.field > label:not(.upload) { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 8px; }
.field-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.field-row .field > label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px: iOSでズームされない */
  color: var(--text); background-color: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; line-height: 1.6;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
textarea { resize: vertical; min-height: 120px; }
textarea::placeholder { color: #8a8fa3; }
select {
  min-height: 48px; padding-right: 40px; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  /* 下向き矢印アイコン（SVG） */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235f6478' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
select:hover, textarea:hover { border-color: var(--border-strong); }
select:focus, textarea:focus { outline: none; background-color: #fff; }
.panel-assist select:focus, .panel-assist textarea:focus { border-color: var(--assist); box-shadow: 0 0 0 4px var(--assist-soft); }
.panel-generate select:focus, .panel-generate textarea:focus { border-color: var(--gen); box-shadow: 0 0 0 4px var(--gen-soft); }

/* ラフ画像アップロード欄 */
.upload {
  display: flex; align-items: center; gap: 16px; padding: 20px; cursor: pointer;
  border: 1.5px dashed #c6b8f7; border-radius: var(--radius); background: #faf8ff;
  transition: background .2s, border-color .2s;
}
.upload:hover { background: var(--assist-soft); border-color: var(--assist); }
.upload:focus-within { outline: 3px solid var(--assist-soft); outline-offset: 2px; }
.upload-icon {
  display: grid; place-items: center; flex-shrink: 0;
  width: 52px; height: 52px; border-radius: 12px; font-size: 26px;
  background: #fff; box-shadow: 0 1px 3px rgba(20, 24, 40, .08);
}
.upload-text { font-size: .95rem; line-height: 1.5; color: var(--assist-strong); font-weight: 700; word-break: break-all; }
.upload-text small { color: var(--muted); font-weight: 400; font-size: .8rem; }
.hint { margin: 10px 0 0; font-size: .85rem; line-height: 1.6; color: var(--muted); }

/* ===== ボタン ===== */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 56px; padding: 0 24px; border: none; border-radius: var(--radius); cursor: pointer;
  font: inherit; font-size: 1.05rem; font-weight: 700; color: #fff; letter-spacing: .04em;
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); filter: brightness(.97); }
.btn:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.btn:disabled { opacity: .65; cursor: wait; transform: none; filter: none; }
.btn-assist { background: linear-gradient(135deg, #8a66ff, var(--assist-strong)); box-shadow: 0 8px 20px rgba(109, 69, 240, .28); }
.btn-generate { background: linear-gradient(135deg, #ff8a4c, var(--gen-strong)); box-shadow: 0 8px 20px rgba(240, 96, 46, .28); }
.btn-assist:hover { box-shadow: 0 10px 24px rgba(109, 69, 240, .34); }
.btn-generate:hover { box-shadow: 0 10px 24px rgba(240, 96, 46, .34); }

/* ===== アシスタントの回答 ===== */
.output { margin-top: 28px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.output-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--assist-soft); color: var(--assist-strong); font-weight: 700; font-size: .9rem; padding: 12px 18px;
}
.output-status {
  flex-shrink: 0; font-size: .72rem; font-weight: 700; background: #fff; color: var(--assist-strong);
  border-radius: 999px; padding: 3px 10px;
}
.output-body { padding: 18px 20px; font-size: .95rem; line-height: 1.8; }
.output-body p { margin: 0 0 8px; }
.output-body h4 { margin: 16px 0 6px; font-size: 1rem; }
.output-body h4:first-child { margin-top: 0; }
.output-body ul { margin: 0 0 8px; padding-left: 1.3em; }
.output-body li { margin-bottom: 6px; }
.output-body li::marker { color: var(--assist); }
.output-body.loading { color: var(--muted); }
.output-body .error {
  color: var(--danger); background: var(--danger-soft); border: 1px solid #f9d0cc;
  border-radius: var(--radius-sm); padding: 12px 14px; margin: 0;
}

/* ===== 画像生成の案内 ===== */
.notice {
  margin-top: 16px; padding: 16px 18px; border-radius: var(--radius);
  background: var(--gen-soft); border: 1px solid #ffd2c0; font-size: .9rem; line-height: 1.7;
}
.notice strong { display: block; color: var(--gen-strong); margin-bottom: 4px; }

/* ===== 生成結果プレビュー ===== */
.preview-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 32px 0 14px; font-weight: 700; font-size: 1rem;
}
.soon {
  font-size: .72rem; font-weight: 700; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px;
}
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.page-card {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow .2s, transform .2s;
}
.page-card:hover { box-shadow: var(--shadow-card); transform: translateY(-2px); }
.page-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; font-size: .82rem; }
.page-meta strong { font-size: .9rem; }
.koma-tag { background: var(--gen-soft); color: var(--gen-strong); font-weight: 700; border-radius: 999px; padding: 2px 10px; font-size: .72rem; white-space: nowrap; }
.page-canvas {
  aspect-ratio: 1 / 1.414; /* 漫画原稿の縦長比率 */
  margin: 0 14px; background: #fff; border: 2px solid #2b2f40; border-radius: 4px;
  display: grid; gap: 5px; padding: 5px;
}
.page-canvas span { background: #fafbfd; border: 1.5px solid #2b2f40; border-radius: 1px; }
.page-note { padding: 12px 14px 16px; text-align: center; font-size: .78rem; line-height: 1.6; color: var(--muted); }
.page-note b { display: block; color: var(--text); font-size: .85rem; }

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

/* ===== タブレット（〜960px）：1カラムに ===== */
@media (max-width: 960px) {
  .container { padding: 0 24px; }
  .main-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-top: 28px; max-width: 760px; }
}

/* ===== スマホ（〜600px） ===== */
@media (max-width: 600px) {
  .container { padding: 0 16px; }
  .app-header { padding: 10px 0; }
  .logo { width: 38px; height: 38px; font-size: 19px; border-radius: 10px; }
  .app-header h1 { font-size: 1.05rem; }
  .tagline { font-size: .75rem; }
  .badge-mock { display: none; }
  .main-grid { gap: 20px; padding-top: 20px; padding-bottom: 24px; }
  .panel { padding: 24px 20px; border-radius: 16px; }
  .panel-head { margin-bottom: 22px; padding-bottom: 18px; }
  .panel h2 { font-size: 1.2rem; }
  .desc { font-size: .9rem; }
  .field { margin-bottom: 20px; }
  .field-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .field-row .field > label { white-space: normal; }
  .upload { padding: 16px; }
  .output-body { padding: 16px; }
  .preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .page-meta { flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 12px; }
  .page-canvas { margin: 0 10px; }
  .page-note { padding: 10px 10px 14px; }
}
