/* =========================================================
   Manga Creative Studio
   コンセプト：漫画原稿のような、モノクロ基調のミニマルデザイン
   色：墨（黒）・原稿用紙（白）・グレー ＋ アクセント1色（赤入れの朱色）
   ========================================================= */
:root {
  --ink: #161616;        /* 墨：文字・枠線・ボタン */
  --ink-soft: #3a3a3a;
  --muted: #767676;      /* 補足テキスト */
  --line: #d9d9d6;       /* 細い区切り線 */
  --paper: #ffffff;      /* 原稿用紙 */
  --bg: #f3f3f1;         /* 背景 */
  --tone: #dcdcd8;       /* スクリーントーンの点 */
  --accent: #d6402e;     /* アクセント（1色のみ） */
  --accent-soft: #fbefed;

  /* 文字サイズ（見出し → 本文 → 補足 の差をはっきり） */
  --fs-title: 1.5rem;    /* 24px 見出し */
  --fs-body: 0.9375rem;  /* 15px 本文 */
  --fs-label: 0.8125rem; /* 13px ラベル */
  --fs-note: 0.75rem;    /* 12px 補足 */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: var(--fs-body);
  line-height: 1.8;
  color: var(--ink);
  background-color: var(--bg);
  /* スクリーントーン風のドット背景 */
  background-image: radial-gradient(var(--tone) 1px, transparent 1.3px);
  background-size: 16px 16px;
  -webkit-font-smoothing: antialiased;
}

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

svg { display: block; }

/* ===== ヘッダー ===== */
.app-header {
  background: var(--paper);
  border-bottom: 1.5px solid var(--ink);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--paper);
  font-weight: 900;
  font-size: 1rem;
}
.logo-text {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.mock-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-note);
  font-weight: 600;
  color: var(--ink-soft);
  padding: 3px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.mock-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.lead {
  margin: 36px 0 24px;
  font-size: var(--fs-label);
  color: var(--muted);
}

/* ===== 2カラムレイアウト ===== */
.main-grid {
  display: grid;
  grid-template-columns: 1fr;   /* スマホ・タブレット：縦並び */
  gap: 28px;
  margin-bottom: 56px;
}
@media (min-width: 1024px) {
  .main-grid { grid-template-columns: 1fr 1fr; align-items: start; }  /* PC：2カラム */
}

/* ===== パネル（コマ枠のような細い墨線のみ。影なし） ===== */
.panel {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  padding: 36px;
}

.panel-head {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.step-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-note);
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--accent);
}
.step-label::before {
  content: "";
  width: 20px;
  height: 2px;
  background: currentColor;
}
.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 10px;
  font-size: var(--fs-title);
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0.02em;
}
.title-icon { width: 26px; height: 26px; flex-shrink: 0; }
.panel-desc {
  margin: 0;
  font-size: var(--fs-label);
  color: var(--muted);
}

/* ===== フォーム ===== */
.form { display: flex; flex-direction: column; gap: 22px; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.label {
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: 0.04em;
}

select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;  /* iOSで入力時に拡大されないように */
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px 14px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 116px; }
textarea::placeholder { color: #a6a6a6; }
select {
  appearance: none;
  padding-right: 40px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23161616' 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;
  background-size: 16px;
}
select:hover, textarea:hover { border-color: #b3b3b0; }
select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(22, 22, 22, 0.08);
}

/* アップロード欄 */
.upload {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 160px;
  padding: 24px;
  border: 1.5px dashed #bdbdb9;
  border-radius: 4px;
  background: var(--paper);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.upload:hover {
  border-color: var(--ink);
  background-image: radial-gradient(var(--tone) 1px, transparent 1.3px);
  background-size: 8px 8px;
}
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-icon { width: 30px; height: 30px; color: var(--ink-soft); }
.upload-text { font-size: var(--fs-label); font-weight: 700; }
.upload-hint { max-width: 28em; font-size: var(--fs-note); line-height: 1.7; color: var(--muted); }
.upload-preview { max-height: 160px; max-width: 100%; margin-top: 10px; border: 1px solid var(--line); }

/* ボタン：墨ベタ。押すと沈む、控えめな立体感 */
.btn {
  width: 100%;
  min-height: 54px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--tone);
  transition: transform .12s, box-shadow .12s, background-color .15s;
}
.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--accent);
}
.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--accent);
}
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn:disabled {
  background: var(--ink-soft);
  cursor: wait;
  transform: none;
  box-shadow: 4px 4px 0 var(--tone);
}

/* ===== 出力エリア ===== */
.result, .preview { margin-top: 36px; }
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.result-title {
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.result-tag {
  font-size: var(--fs-note);
  color: var(--muted);
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

/* AIの回答：漫画の吹き出し風 */
.result-body {
  position: relative;
  margin-top: 18px;
  padding: 20px 22px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 16px;
  font-size: var(--fs-body);
  line-height: 1.9;
  white-space: pre-wrap;       /* AIの回答の改行をそのまま表示 */
  overflow-wrap: anywhere;
}
.result-body::before {        /* 吹き出しのしっぽ */
  content: "";
  position: absolute;
  top: -8.5px;
  left: 32px;
  width: 15px;
  height: 15px;
  background: inherit;
  border-top: 1.5px solid;
  border-left: 1.5px solid;
  border-color: inherit;
  transform: rotate(45deg);
}
.result-body.is-empty { color: var(--muted); border-color: var(--line); font-size: var(--fs-label); }
.result-body.is-loading { color: var(--muted); animation: pulse 1.2s ease-in-out infinite; }
.result-body.is-error {
  color: #a93323;
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 600;
}

/* 入力が空のときのエラー表示 */
.form-error {
  margin: 20px 0 0;
  padding: 14px 18px;
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  color: #a93323;
  font-size: var(--fs-label);
  font-weight: 600;
}
.form-error[hidden] { display: none; }

/* ===== 画像生成の案内（猫のイラスト付き） ===== */
.notice {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 28px;
  padding: 18px 22px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
}
.notice[hidden] { display: none; }
.notice-image { width: 84px; height: auto; flex-shrink: 0; }
.notice-text { margin: 0; font-size: var(--fs-label); line-height: 1.9; }

/* ===== プレビューカード：原稿用紙とコマ枠 ===== */
.preview-grid {
  display: grid;
  grid-template-columns: 1fr;   /* スマホ：縦並び */
  gap: 16px;
}
@media (min-width: 600px) {
  .preview-grid { grid-template-columns: repeat(2, 1fr); }  /* タブレット・PC：横並び */
}

.page-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.page-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-note);
}
.page-no { font-weight: 800; letter-spacing: 0.08em; }
.page-info { color: var(--muted); }

.page-sheet {
  margin: 14px;
  aspect-ratio: 1 / 1.414;      /* 原稿用紙の縦横比 */
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px dashed #cfcfcb;   /* 仕上がり線のイメージ */
}
.koma {
  border: 2px solid var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(#cfcfcb 1px, transparent 1.3px);  /* スクリーントーン */
  background-size: 7px 7px;
}
.page-caption {
  padding: 0 14px 16px;
  text-align: center;
}
.page-caption strong { display: block; font-size: var(--fs-label); font-weight: 700; }
.page-caption span { display: block; font-size: var(--fs-note); color: var(--muted); }

@keyframes pulse { 50% { opacity: .45; } }

/* ===== フッター ===== */
.app-footer {
  padding: 22px 0;
  background: var(--paper);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--fs-note);
  text-align: center;
}

/* ===== タブレット ===== */
@media (max-width: 1023px) {
  .container { padding: 0 24px; }
  .panel { padding: 30px; }
}

/* ===== スマホ ===== */
@media (max-width: 599px) {
  :root { --fs-title: 1.3rem; }
  .container { padding: 0 16px; }
  .header-inner { height: 56px; }
  .logo-text { font-size: 1rem; }
  .lead { margin: 24px 0 18px; }
  .main-grid { gap: 20px; }
  .panel { padding: 24px 18px; }
  .field-row { grid-template-columns: 1fr; }
  .notice { flex-direction: column; text-align: center; gap: 12px; }
  .page-sheet { max-width: 300px; margin: 14px auto; }
}
