/* ===========================================================================
   Manga Creative Studio - スタイル
   色・余白・角丸・影は、まずここの変数（デザイントークン）で管理する
   =========================================================================== */

:root {
  /* ベースカラー（背景と文字） */
  --bg: #f6f7fa;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --text: #16181d;
  --text-sub: #5a6172;
  --border: #e5e8ef;
  --border-strong: #d5dae4;

  /* メインカラー：企画アシスタント側。ボタンなど重要な操作にも使う */
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef0fe;

  /* アクセントカラー：漫画生成側 */
  --accent: #0b7d70;
  --accent-hover: #09695f;
  --accent-soft: #e6f5f3;

  /* 赤はエラー表示だけに使う */
  --danger: #c2372b;
  --danger-soft: #fdf3f2;
  --danger-border: #f3c9c4;

  /* 余白のスケール */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* 英字は system-ui（すっきり見える）、日本語は Hiragino / Noto を優先 */
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
               "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------------------
   ヘッダー
   --------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.brand-mark {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand), #7c6df2);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
}
.site-header h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.3;
}
.site-header .tagline {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-sub);
}

/* ---------------------------------------------------------------------------
   レイアウト
   --------------------------------------------------------------------------- */

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5) var(--sp-7);
}
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
  align-items: start;
}

/* ---------------------------------------------------------------------------
   カード（企画アシスタント / 漫画生成）
   --------------------------------------------------------------------------- */

.card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--sp-6) var(--sp-5) var(--sp-5);
}
/* カード上部の細い色帯で、2つの機能の違いを示す */
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.card--assist::before { background: var(--brand); }
.card--gen::before { background: var(--accent); }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: var(--sp-3);
}
.card--assist .badge { background: var(--brand-soft); color: var(--brand); }
.card--gen .badge { background: var(--accent-soft); color: var(--accent); }

.card h2 {
  margin: 0 0 var(--sp-2);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -.01em;
}
.card .lead {
  margin: 0 0 var(--sp-6);
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-sub);
}

/* ---------------------------------------------------------------------------
   フォーム
   --------------------------------------------------------------------------- */

.field { margin-bottom: var(--sp-5); }
.field label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: var(--sp-2);
}
.hint {
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-sub);
  margin: var(--sp-2) 0 0;
}

select,
textarea {
  width: 100%;
  padding: 13px 14px;
  font-size: 15px;
  font-family: inherit;
  line-height: 1.7;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  transition: border-color .15s ease, box-shadow .15s ease;
}
select {
  /* 標準の矢印を消して、統一したアイコンを描く */
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235a6172' 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;
  cursor: pointer;
}
textarea {
  resize: vertical;
  min-height: 120px;
}
select:hover,
textarea:hover { border-color: #c3cad6; }

select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .16);
}
.card--gen select:focus,
.card--gen textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 125, 112, .18);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

/* 画像アップロード欄 */
.upload {
  display: block;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.upload:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.upload .icon {
  display: block;
  margin: 0 auto var(--sp-2);
  color: var(--brand);
}
.upload .main {
  display: block;
  font-size: 14px;
  font-weight: 700;
}
.upload .sub {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-sub);
}
.upload input[type="file"] { display: none; }

/* ---------------------------------------------------------------------------
   ボタン
   --------------------------------------------------------------------------- */

.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: .01em;
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn--assist {
  background: var(--brand);
  box-shadow: 0 2px 8px rgba(79, 70, 229, .25);
}
.btn--assist:hover { background: var(--brand-hover); transform: translateY(-1px); }
.btn--gen {
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(11, 125, 112, .25);
}
.btn--gen:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible {
  outline: 3px solid rgba(79, 70, 229, .35);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: .55;
  cursor: progress;
  transform: none;
  box-shadow: none;
}

/* ---------------------------------------------------------------------------
   出力エリア
   --------------------------------------------------------------------------- */

.result {
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
}
.result h3 {
  margin: 0 0 var(--sp-3);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text-sub);
}
.result-body {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
  font-size: 14.5px;
  line-height: 1.9;
  white-space: pre-wrap;
}

/* ---------------------------------------------------------------------------
   案内・エラー表示
   --------------------------------------------------------------------------- */

.notice {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.8;
}
/* お知らせ：強い色を使わず、落ち着いたトーンにする */
.notice--info {
  background: var(--accent-soft);
  border: 1px solid #c9e8e3;
  color: #0a5c53;
}
/* エラー：赤はここだけで使う */
.notice--error {
  margin: 0 0 var(--sp-3);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  border-left: 3px solid var(--danger);
  color: var(--danger);
  font-weight: 500;
}
#gen-error { margin: var(--sp-4) 0 0; }

/* ---------------------------------------------------------------------------
   生成結果プレビュー
   --------------------------------------------------------------------------- */

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
}
.preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.preview-card .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
}
.preview-card .head span:last-child {
  font-weight: 500;
  font-size: 12px;
  color: var(--text-sub);
  white-space: nowrap;
}
.preview-card .thumb {
  aspect-ratio: 3 / 4;
  background: var(--surface-2);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* コマ割りのイメージが伝わるように、枠だけのダミーを並べる */
.panel-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
}
.panel-grid span {
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  background: #fff;
}
.thumb .caption { text-align: center; }
.thumb .label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-sub);
}
.thumb .note {
  display: block;
  font-size: 11.5px;
  line-height: 1.6;
  color: #6b7280;
}

/* ---------------------------------------------------------------------------
   フッター
   --------------------------------------------------------------------------- */

.site-footer {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-sub);
  padding: 0 var(--sp-5) var(--sp-6);
}

/* ---------------------------------------------------------------------------
   タブレット：1カラムにしつつ、横に間延びしないよう幅を抑える
   --------------------------------------------------------------------------- */

@media (max-width: 1023px) {
  .columns {
    grid-template-columns: 1fr;
    gap: var(--sp-5);
    max-width: 680px;
    margin: 0 auto;
  }
  .header-inner { max-width: 680px; }
}

/* ---------------------------------------------------------------------------
   スマホ
   --------------------------------------------------------------------------- */

@media (max-width: 640px) {
  body { line-height: 1.75; }
  .header-inner { padding: var(--sp-3) var(--sp-4); }
  .brand-mark { width: 34px; height: 34px; font-size: 14px; }
  .site-header h1 { font-size: 17px; }
  .site-header .tagline { font-size: 12px; }

  .container { padding: var(--sp-5) var(--sp-4) var(--sp-6); }
  .card { padding: var(--sp-5) var(--sp-4); border-radius: var(--radius-md); }
  .card h2 { font-size: 20px; }

  /* 横並びは無理に詰めず縦に並べる */
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .field-row .field { margin-bottom: var(--sp-5); }
  .preview-grid { grid-template-columns: 1fr; }
  .preview-card .thumb { aspect-ratio: 4 / 3; }

  /* iOS で入力時に自動ズームされないよう 16px を確保 */
  select, textarea { font-size: 16px; }
  .btn { min-height: 54px; }
  .result-body { padding: var(--sp-4); }
}

/* 動きを減らす設定の端末ではアニメーションを止める */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .btn:hover { transform: none; }
}
