/* ===== 基本設定（色・角丸・影はここで一元管理） ===== */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2333;
  --text-sub: #2b3045;
  --muted: #5a5f73;      /* 補足文字（薄い背景上でもコントラスト 4.5:1 以上） */
  --border: #e6e8ef;
  --border-strong: #d5d8e2;

  /* アシスタント = 青紫系 */
  --assist: #5b5bd6;
  --assist-hover: #4d4dc9;
  --assist-ink: #4b4bc8;  /* 薄い背景の上に置く文字色 */
  --assist-soft: #eeeefc;
  --assist-tint: #f7f7fe;

  /* 漫画生成 = オレンジ系 */
  --gen: #f0672e;         /* ロゴ・アイコン・装飾用 */
  --gen-strong: #cc4a10;  /* ボタン背景（白文字でコントラスト 4.5:1 以上） */
  --gen-hover: #b8420e;
  --gen-ink: #c2410c;     /* 薄い背景の上に置く文字色 */
  --gen-soft: #fff1ea;
  --gen-tint: #fff8f4;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  /* 英字は Segoe UI、日本語はヒラギノ / Noto Sans JP / 游ゴシックで表示 */
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  /* 左上に青紫、右上にオレンジをごく薄く敷いて、2つの機能を背景でも示す */
  background:
    radial-gradient(900px 360px at 0% -5%, rgba(91, 91, 214, 0.08), transparent 70%),
    radial-gradient(900px 360px at 100% -5%, rgba(240, 103, 46, 0.07), transparent 70%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 画面上は隠すが、キーボード操作・読み上げでは使える */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ===== ヘッダー ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.logo-mark { width: 36px; height: 36px; display: block; }
/* アプリ名は1つのフォント・サイズ・太さで統一 */
.logo-text {
  font-family: "Plus Jakarta Sans", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
}
.badge-mock {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

/* ===== メイン：PCは2カラム ===== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

/* ===== パネル（カード） ===== */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.panel-head { margin-bottom: 28px; }
.panel-title {
  display: flex;
  align-items: center;
  gap: 16px;
}
.panel-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.panel-icon .icon { width: 24px; height: 24px; }
.panel-assistant .panel-icon { background: var(--assist-soft); color: var(--assist); }
.panel-generate  .panel-icon { background: var(--gen-soft);    color: var(--gen); }

.step {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.5;
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: 4px;
}
.panel-assistant .step { background: var(--assist-soft); color: var(--assist-ink); }
.panel-generate  .step { background: var(--gen-soft);    color: var(--gen-ink); }

.panel-head h2 {
  font-size: 1.375rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
}
.lead {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.8;
}

/* ===== 入力欄 ===== */
.field { margin-bottom: 24px; min-width: 0; }
.field-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 8px;
}
.input {
  width: 100%;
  min-height: 48px;
  font: inherit;
  font-size: 1rem;           /* 16px 以上：iOS の自動ズームを防ぐ */
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input::placeholder { color: #8a8fa3; }
.input:hover { border-color: #bfc3d0; }
textarea.input { resize: vertical; line-height: 1.7; }
.input:focus { outline: none; }
.panel-assistant .input:focus { border-color: var(--assist); box-shadow: 0 0 0 4px var(--assist-soft); }
.panel-generate  .input:focus { border-color: var(--gen);    box-shadow: 0 0 0 4px var(--gen-soft); }

/* セレクトボックス：標準の矢印を、デザインに合わせた矢印に置き換え */
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 44px;
  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='%235a5f73' 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: 18px;
}

/* アップロード欄 */
.upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 176px;
  padding: 24px;
  border: 1.5px dashed #c7c9ea;
  border-radius: var(--radius);
  background: var(--assist-tint);
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, border-color 0.2s;
}
.upload:hover { background: var(--assist-soft); border-color: var(--assist); }
.upload:focus-within { border-color: var(--assist); box-shadow: 0 0 0 4px var(--assist-soft); }
.upload-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--assist);
  box-shadow: 0 2px 8px rgba(91, 91, 214, 0.15);
}
.upload-icon[hidden] { display: none; }
.upload-text { font-size: 0.9375rem; font-weight: 700; color: var(--assist-ink); }
.upload-sub { font-size: 0.8125rem; color: var(--muted); line-height: 1.6; }
.upload-preview {
  max-height: 160px;
  max-width: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.1);
}

/* ===== ボタン ===== */
.btn {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.99); }
.btn:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.btn-assistant { background: var(--assist); box-shadow: 0 8px 20px -6px rgba(91, 91, 214, 0.55); }
.btn-assistant:hover { background: var(--assist-hover); }
.btn-generate  { background: var(--gen-strong); box-shadow: 0 8px 20px -6px rgba(204, 74, 16, 0.5); }
.btn-generate:hover { background: var(--gen-hover); }
.btn.loading { opacity: 0.75; cursor: progress; pointer-events: none; }

/* ===== 出力エリア ===== */
.result { margin-top: 32px; }
.result-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 12px;
}
.result-head::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.panel-assistant .result-head::before { background: var(--assist); }
.panel-generate  .result-head::before { background: var(--gen); }

.result-body {
  background: var(--assist-tint);
  border: 1px solid #e4e4f8;
  border-radius: var(--radius);
  padding: 20px 22px;
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.result-placeholder { color: var(--muted); font-size: 0.9375rem; }

/* エラー表示（赤はエラーのときだけ使う） */
.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  font-size: 0.9375rem;
}

/* 案内表示（漫画生成エリア） */
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--gen-tint);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text-sub);
}
.notice-icon { color: var(--gen-ink); margin-top: 2px; }
.notice strong { color: var(--gen-ink); }
.notice-strong {
  margin: 16px 0 0;
  background: var(--gen-soft);
  border: 1px solid #fdd5bf;
  font-weight: 600;
}
.notice[hidden], .error-box[hidden], .field[hidden] { display: none; }

/* ===== 生成プレビュー：PCは横並び ===== */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  transition: box-shadow 0.2s, transform 0.2s;
}
.preview-card:hover { box-shadow: var(--shadow-card); transform: translateY(-2px); }
.preview-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 14px 0;
}
.preview-page { font-size: 0.8125rem; font-weight: 800; color: var(--gen-ink); }
.preview-panels { font-size: 0.75rem; color: var(--muted); }

/* 漫画ページ風の枠 */
.preview-image {
  aspect-ratio: 3 / 4;
  margin: 10px 14px 12px;
  padding: 6px;
  border: 2px solid var(--text-sub);
  border-radius: 4px;
  display: grid;
  gap: 5px;
  background: var(--card);
}
.preview-image .koma {
  border: 1.5px solid #b9bccb;
  border-radius: 2px;
  background: repeating-linear-gradient(45deg, #f8f9fb 0 6px, #f0f1f5 6px 12px);
}
.preview-caption { padding: 0 14px 16px; text-align: center; line-height: 1.6; }
.preview-caption strong { display: block; font-size: 0.8125rem; color: var(--text-sub); }
.preview-caption span { font-size: 0.75rem; color: var(--muted); }
.preview-caption .preview-tag {
  display: block;
  width: fit-content;
  margin: 8px auto 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gen-ink);
  background: var(--gen-soft);
  border-radius: 999px;
  padding: 2px 10px;
}

.footer {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  font-size: 0.8125rem;
  line-height: 1.8;
  color: var(--muted);
  padding: 0 16px 48px;
}

/* ===== タブレット横（2カラムのままパネルが狭くなる幅） ===== */
@media (max-width: 1024px) {
  .main { gap: 24px; }
  .panel { padding: 28px; }
  .field-row { grid-template-columns: 1fr 1fr; }
}

/* ===== タブレット縦・スマホ：1カラム ===== */
@media (max-width: 860px) {
  /* 1カラムでは横に伸びすぎないよう、読みやすい幅に収める */
  .main { grid-template-columns: 1fr; max-width: 720px; padding: 32px 24px; }
  .field-row { grid-template-columns: repeat(3, 1fr); }
}

/* ===== スマホ ===== */
@media (max-width: 600px) {
  .header-inner { padding: 12px 16px; }
  .logo-mark { width: 32px; height: 32px; }
  .logo-text { font-size: 1rem; }
  .main { padding: 20px 16px; gap: 20px; }
  .panel { padding: 24px 20px; border-radius: 16px; }
  .panel-head { margin-bottom: 24px; }
  .panel-title { gap: 12px; }
  .panel-icon { width: 44px; height: 44px; border-radius: 12px; }
  .panel-head h2 { font-size: 1.25rem; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .btn { min-height: 52px; }
  .preview-grid { grid-template-columns: 1fr; } /* プレビューは縦並び */
  .preview-image { max-width: 260px; margin: 10px auto 12px; }
}

/* 小さいスマホでは、アプリ名を1行で収めるためバッジを隠す */
@media (max-width: 360px) {
  .badge-mock { display: none; }
}
