/* Manga Creative Studio — スタイル（コミック風ポップデザイン） */

:root {
  /* 色は黄・ピンク・水色の3色＋墨・クリーム。色の上に置く文字は必ず墨（黒）にする */
  --cream: #fff6d8;            /* 背景 */
  --cream-dot: #f3d56b;        /* 背景の網点 */
  --surface: #ffffff;
  --ink: #1a1a1a;              /* 文字・枠線・ベタ影 */
  --text-sub: #4a4a4a;         /* 補足文字（白地でコントラスト 9:1 以上） */

  --yellow: #ffd60a;           /* メイン：ヘッダー・生成ボタン・ラベル */
  --pink: #ff5da2;             /* STEP 1 */
  --pink-soft: #ffe3ef;        /* エラー背景 */
  --cyan: #2ec4f1;             /* STEP 2・フォーカス */

  --border: 3px solid var(--ink);
  --border-thin: 2.5px solid var(--ink);
  --radius: 22px;
  --radius-md: 16px;
  --radius-sm: 14px;
  --shadow: 8px 8px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --focus-ring: 0 0 0 4px rgba(46, 196, 241, .55);

  --font-pop: "M PLUS Rounded 1c", "Noto Sans JP", "Hiragino Maru Gothic ProN", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  font-family: "Inter", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.9;
  background-color: var(--cream);
  background-image: radial-gradient(var(--cream-dot) 1.3px, transparent 1.5px);
  background-size: 16px 16px;
}

.container {
  width: min(1120px, 100%);
  margin-inline: auto;
  padding-inline: 24px;
}

/* 見た目は隠すが、キーボード操作や読み上げでは使えるようにする */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
  padding-block: 14px;
}

.logo { display: flex; align-items: center; gap: 12px; }

.logo-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: var(--yellow);
  font-family: var(--font-pop);
  font-size: 22px;
  line-height: 1;
  transform: rotate(-6deg);
}

.app-title {
  margin: 0;
  font-family: var(--font-pop);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
}

.app-tagline {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
}

/* ---------- レイアウト ---------- */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  padding-block: 44px 72px;
  align-items: start;
}

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

.card-head {
  position: relative;
  padding: 28px 32px 24px;
  border-bottom: var(--border);
}

.card--assistant .card-head { background: var(--pink); }
.card--generate  .card-head { background: var(--cyan); }

/* 見出し帯にうっすら網点（スクリーントーン）を重ねる */
.card-head::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, .22) 1.6px, transparent 1.8px);
  background-size: 12px 12px;
}

.card-head > * { position: relative; z-index: 1; }

/* 吹き出し型のバッジ */
.badge {
  display: inline-block;
  position: relative;
  padding: 2px 14px;
  background: var(--surface);
  border: var(--border-thin);
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.8;
  letter-spacing: .04em;
}

.badge::after {
  content: "";
  position: absolute;
  left: 18px;
  bottom: -9px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border-right: var(--border-thin);
  border-bottom: var(--border-thin);
  transform: skewY(-35deg) rotate(35deg);
}

.card-title {
  margin: 16px 0 4px;
  font-family: var(--font-pop);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.4;
}

.card-desc {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.8;
}

.card-body {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---------- フォーム ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }

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

.label {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.input {
  width: 100%;
  padding: 12px 14px;
  border: var(--border-thin);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.7;
  transition: background .15s, box-shadow .15s;
}

.input::placeholder { color: #767676; }

/* 触れる場所だと分かるように、カーソルを乗せたら少し色を変える */
.input:hover:not(:focus) { background: #fffdf0; }

.input:focus {
  outline: none;
  box-shadow: var(--focus-ring);
}

.textarea { resize: vertical; min-height: 104px; }

.select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path fill='none' stroke='%231a1a1a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 13px;
  padding-right: 44px;
}

/* ---------- アップローダー ---------- */
.uploader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 24px 18px;
  border: 2.5px dashed var(--ink);
  border-radius: var(--radius-md);
  background-color: #fff9e0;
  background-image: radial-gradient(#f5dc85 1.2px, transparent 1.4px);
  background-size: 10px 10px;
  text-align: center;
  cursor: pointer;
  transition: background-color .15s, box-shadow .15s;
}

.uploader:hover { background-color: #fff0b3; }

.uploader:focus-within { box-shadow: var(--focus-ring); }

.uploader-icon {
  width: 30px;
  height: 30px;
  margin-bottom: 6px;
  color: var(--ink);
  stroke-width: 2;
}

.uploader-main { font-size: 15px; font-weight: 700; }
.uploader-sub  { font-size: 12px; color: var(--text-sub); }

.uploader-filename {
  margin: 0;
  font-size: 12px;
  color: var(--text-sub);
}

/* ---------- ボタン（ぷっくり） ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 12px 20px;
  border: var(--border);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-family: var(--font-pop);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: .04em;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--ink);
  transition: transform .12s ease, box-shadow .12s ease;
}

/* ホバーで少し浮き、押すと沈む */
.btn:hover  { transform: translateY(-3px); box-shadow: 0 9px 0 var(--ink); }
.btn:active { transform: translateY(5px);  box-shadow: 0 1px 0 var(--ink); }

.btn:focus-visible {
  outline: 4px solid var(--cyan);
  outline-offset: 4px;
}

.btn--assistant { background: var(--pink); }
.btn--generate  { background: var(--yellow); }

/* 処理中は沈んだ状態で止める */
.btn:disabled,
.btn:disabled:hover {
  cursor: progress;
  opacity: .7;
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--ink);
}

/* ---------- 出力エリア ---------- */
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.result-label { font-size: 14px; font-weight: 700; }

.chip {
  padding: 0 12px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.9;
  white-space: nowrap;
}

/* AIの回答は吹き出しにする */
.result .result-head { margin-bottom: 24px; }

.result-body {
  position: relative;
  margin-left: 4px;
  padding: 18px 22px;
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
}

.result-body::before {
  content: "";
  position: absolute;
  top: -15px;
  left: 34px;
  width: 22px;
  height: 22px;
  background: var(--surface);
  border-left: var(--border);
  border-top: var(--border);
  transform: rotate(45deg);
}

.result-lead { margin: 0 0 6px; font-weight: 700; }

.result-list {
  margin: 0;
  padding-left: 1.2em;
  font-size: 14px;
  line-height: 1.85;
}

.result-list li + li { margin-top: 6px; }

.placeholder {
  margin: 0;
  color: var(--text-sub);
  font-size: 14px;
}

/* ---------- エラー表示 ---------- */
.error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 10px 14px;
  background: var(--pink-soft);
  border: var(--border-thin);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.7;
}

.error::before {
  content: "!";
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  font-size: 14px;
  line-height: 1;
}

/* ---------- プレビューカード ---------- */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.page-card {
  padding: 10px;
  background: var(--surface);
  border: var(--border-thin);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.page-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding-inline: 4px;
}

.page-no {
  font-family: var(--font-pop);
  font-size: 16px;
  font-weight: 800;
}

.page-meta {
  padding: 0 10px;
  background: var(--cyan);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.8;
  white-space: nowrap;
}

/* 生成前の枠はスクリーントーン風の網点 */
.page-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  aspect-ratio: 3 / 4;
  padding: 10px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background-color: #fbfbfb;
  background-image: radial-gradient(#d4d4d4 1.4px, transparent 1.6px);
  background-size: 9px 9px;
  text-align: center;
}

/* 生成済みの画像を表示する状態（生成画像は 2:3 の縦長） */
.page-thumb--filled {
  aspect-ratio: 2 / 3;
  padding: 0;
  background: var(--surface);
  overflow: hidden;
}

.page-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.page-thumb-icon {
  width: 30px;
  height: 30px;
  margin-bottom: 4px;
  color: var(--ink);
  stroke-width: 2;
}

/* 網点の上でも読めるよう、文字に白い下地を敷く */
.page-thumb-title,
.page-thumb-text {
  padding: 0 6px;
  border-radius: 6px;
  background: var(--surface);
}

.page-thumb-title { font-size: 13px; font-weight: 700; line-height: 1.6; }
.page-thumb-text  { font-size: 12px; line-height: 1.6; }

/* ---------- フッター ---------- */
.app-footer {
  border-top: var(--border);
  background: var(--yellow);
  padding-block: 18px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
}

.app-footer p { margin: 0; }

/* ---------- 動きを減らす設定の人には、浮き沈みを止める ---------- */
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:hover { transform: none; box-shadow: 0 6px 0 var(--ink); }
}

/* ---------- タブレット ---------- */
@media (max-width: 1024px) {
  /* 1カラムにしつつ、横に伸びすぎないよう幅を抑える */
  .main-grid {
    grid-template-columns: 1fr;
    max-width: 720px;
    gap: 36px;
    padding-block: 40px 64px;
  }
}

/* ---------- スマホ ---------- */
@media (max-width: 600px) {
  body { font-size: 14px; }
  .container { padding-inline: 16px; }
  .header-inner { padding-block: 12px; }
  .logo-mark { width: 34px; height: 34px; font-size: 18px; border-radius: 9px; }
  .app-title { font-size: 19px; }
  .app-tagline { font-size: 12px; }

  .main-grid { padding-block: 28px 48px; gap: 28px; }

  /* 小さい画面では枠と影を少し控えめに */
  .card { border-radius: 18px; box-shadow: 5px 5px 0 var(--ink); }
  .card-head { padding: 24px 20px 20px; }
  .card-body { padding: 24px 20px 28px; gap: 24px; }
  /* 「企画・アイデア出しアシスタント」が375px幅でも途中で折り返さないサイズ */
  .card-title { font-size: 18px; }

  /* 入力欄は16px以上にして、iOSの自動ズームを防ぐ */
  .input { font-size: 16px; padding: 12px; }

  /* 横並びの選択欄は縦に。項目間隔は他の入力欄と揃える */
  .field-row { grid-template-columns: 1fr; gap: 24px; }

  .result-body { padding: 16px 18px; }

  /* プレビューは縦並び。生成前の枠は高さを抑える */
  .preview-grid { grid-template-columns: 1fr; gap: 16px; }
  .page-thumb:not(.page-thumb--filled) { aspect-ratio: 4 / 3; }

  .btn { font-size: 17px; }
}
