/* ===== ベース ===== */
/*
  このファイルで使う値は、次の決まった段階からだけ選ぶ。
  値がバラバラだと、余白が狭いこと以上に「素人っぽい画面」に見えるため。

  文字サイズ … 12 / 13 / 14 / 15 / 19 / 21 px
  余白       … 4 / 8 / 12 / 16 / 20 / 24 / 32 / 40 px（4の倍数）
  角丸       … var(--radius-sm) / var(--radius) / var(--radius-pill)
*/
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e6eaf2;

  /* 文字色は3段階。濃い＝本文、中間＝補足、薄い＝注記 */
  --text: #1a2233;
  --text-sub: #5c6b84;
  --text-muted: #66738a;

  /* STEP 1: 企画・アイデア出しアシスタント（青系） */
  --assistant: #2f6bff;
  --assistant-soft: #eef3ff;

  /* STEP 2: 漫画生成（オレンジ系） */
  --generate: #f2731c;
  --generate-soft: #fff2e8;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  /* カードは枠線ではなく影で浮かせる（枠線が多いと古く見えるため） */
  --shadow: 0 1px 2px rgba(26, 34, 51, .04), 0 8px 24px rgba(26, 34, 51, .08);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* 英字用フォントを先に置き、日本語だけ Noto Sans JP が当たるようにする */
  font-family: "Inter", "Noto Sans JP", -apple-system, BlinkMacSystemFont,
               "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.75;
  font-size: 15px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* キーボード操作時にどこを選んでいるか分かるようにする */
:focus-visible {
  outline: 2px solid var(--assistant);
  outline-offset: 2px;
}

/* ===== ヘッダー ===== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-logo {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--assistant), var(--generate));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-title {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.4;
}

.app-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ===== レイアウト（PC: 2カラム / スマホ: 縦） ===== */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

/* ===== カード ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* 上端の色が、その機能の担当色を示す */
.card--assistant { border-top: 4px solid var(--assistant); }
.card--generate  { border-top: 4px solid var(--generate); }

/* 見出し部分は背景色で区切る。枠線は引かない */
.card__head { padding: 24px; }

.card--assistant .card__head { background: var(--assistant-soft); }
.card--generate  .card__head { background: var(--generate-soft); }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  color: #fff;
  line-height: 1.6;
}

.badge--assistant { background: var(--assistant); }
.badge--generate  { background: var(--generate); }

.card__title {
  margin: 12px 0 8px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.5;
}

.card__desc {
  margin: 0;
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.8;
}

.card__body { padding: 24px; }

/* ===== フォーム ===== */
/* ラベルと入力欄は近づけ、項目どうしは離す。これだけで構造が伝わる */
.field { margin-bottom: 20px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.control {
  width: 100%;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}

textarea.control { resize: vertical; }

select.control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2712%27%20height%3D%278%27%20viewBox%3D%270%200%2012%208%27%3E%3Cpath%20fill%3D%27none%27%20stroke%3D%27%235c6b84%27%20stroke-width%3D%271.6%27%20d%3D%27M1%201.5L6%206.5L11%201.5%27%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.control::placeholder { color: var(--text-muted); }

/* 入力中の欄がはっきり分かるようにする */
.control:focus {
  outline: none;
  border-color: var(--assistant);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .15);
}

.card--generate .control:focus {
  border-color: var(--generate);
  box-shadow: 0 0 0 3px rgba(242, 115, 28, .18);
}

/* ===== 画像アップロード欄 ===== */
/* 破線は「ここに置ける」という意味を持つので、ここでは意図的に使う */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  text-align: center;
  border: 2px dashed #c3d0e8;
  border-radius: var(--radius-sm);
  background: #fafbfe;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.dropzone:hover {
  border-color: var(--assistant);
  background: var(--assistant-soft);
}

.dropzone__icon { font-size: 28px; line-height: 1.2; }
.dropzone__main { font-size: 14px; font-weight: 700; }
.dropzone__sub  { font-size: 12px; color: var(--text-muted); }

/* ===== ボタン ===== */
.btn {
  display: block;
  width: 100%;
  min-height: 48px;          /* 指で確実に押せる高さを確保する */
  padding: 12px 20px;
  margin-top: 4px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform .1s, box-shadow .15s, filter .15s;
}

.btn--assistant {
  background: var(--assistant);
  box-shadow: 0 4px 12px rgba(47, 107, 255, .24);
}

.btn--generate {
  background: var(--generate);
  box-shadow: 0 4px 12px rgba(242, 115, 28, .24);
}

.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}

/* ===== 出力エリア ===== */
.result {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.result__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.result__label { font-size: 13px; font-weight: 700; }

.tag {
  font-size: 12px;
  color: var(--text-muted);
  background: #f0f3f9;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  white-space: nowrap;
}

/* 背景色でまとまりを示すので、枠線は引かない */
.result__body {
  background: #f8fafd;
  border-radius: var(--radius-sm);
  padding: 20px;
}

.result__lead {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
}

.result__list {
  margin: 0;
  padding-left: 1.2em;
  font-size: 14px;
  color: var(--text-sub);
}

.result__list li + li { margin-top: 8px; }

.result__empty,
.result__loading {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.result__loading::after {
  content: "";
  display: inline-block;
  width: 1em;
  text-align: left;
  animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

/* ===== エラーメッセージ ===== */
/* 赤は「エラー」の意味を持たせたいので、ここ以外では使わない */
.error {
  margin: 16px 0 0;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: #96341c;
  background: #fdf0ec;
  border-left: 4px solid #d9482a;
  border-radius: var(--radius-sm);
}

/* ===== 生成プレビュー（PC: 横並び / スマホ: 縦並び） ===== */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
}

.preview__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  background: var(--generate-soft);
}

.preview__page { font-size: 13px; font-weight: 700; }
.preview__panels { font-size: 12px; color: var(--text-sub); }

.preview__frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 200px;
  padding: 24px 16px;
  text-align: center;
  background: repeating-linear-gradient(
    45deg, #fbfcfe, #fbfcfe 10px, #f5f7fb 10px, #f5f7fb 20px
  );
}

.preview__icon  { font-size: 32px; line-height: 1.2; }
.preview__title { font-size: 13px; font-weight: 700; color: var(--text-sub); }
.preview__note  { font-size: 12px; color: var(--text-muted); }

/* 生成中スピナー */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #dde3ee;
  border-top-color: var(--generate);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* アップロード済みラフ画像のプレビュー */
.dropzone--filled { padding: 12px; }

.dropzone__preview {
  max-width: 100%;
  max-height: 180px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* 生成された漫画ページ（画像）の表示 */
.preview__frame--filled {
  display: block;
  padding: 0;
  min-height: 0;
  background: #fff;
}

.preview__image {
  display: block;
  width: 100%;
  height: auto;          /* 縦横比を崩さない */
}

/* ===== フッター ===== */
.app-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  text-align: center;
}

.app-footer p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== タブレット ===== */
/* 余白だけを少し詰める。要素が間延びしないようにする */
@media (max-width: 1024px) {
  .layout { gap: 20px; padding: 24px 16px 8px; }
  .card__head { padding: 20px; }
  .card__body { padding: 20px; }
  .app-header__inner { padding: 16px; }
  .app-footer { padding: 24px 16px 40px; }
}

/* ===== スマホ（1カラム縦積み） ===== */
@media (max-width: 767px) {
  .layout {
    grid-template-columns: 1fr;   /* 2カラム → 縦並び */
    gap: 16px;
    padding: 20px 16px 4px;
  }

  .field-row  { grid-template-columns: 1fr; gap: 0; }
  .field-row .field { margin-bottom: 20px; }

  .preview-grid { grid-template-columns: 1fr; }  /* プレビューも縦並び */

  .app-header__inner { padding: 12px 16px; gap: 12px; }
  .app-logo { width: 40px; height: 40px; font-size: 14px; }
  .app-title { font-size: 19px; }

  .card__head { padding: 20px 16px; }
  .card__body { padding: 20px 16px; }

  /* 入力欄は16px未満だと iOS で自動ズームが起きるため下げない */
  .control { font-size: 16px; }

  .preview__frame { min-height: 170px; }
}
