/* ===== Manga Creative Studio - styles ===== */
:root {
  --bg: #f4f5fa;
  --bg-tint: #eef0fb;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --text: #1b1d24;
  --text-sub: #5c6273;
  --border: #e7e9f2;
  --border-soft: #eef0f6;
  --assist: #4f6ef7;
  --assist-soft: #eef2ff;
  --gen: #e8552c;
  --gen-soft: #fff1ec;
  --danger: #b42318;
  --danger-soft: #fff5f4;

  --radius: 20px;      /* カード */
  --radius-md: 14px;   /* パネル・ボタン */
  --radius-sm: 10px;   /* 入力欄 */
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 10px 30px rgba(20, 24, 40, .06);
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: linear-gradient(180deg, var(--bg-tint) 0%, var(--bg) 320px);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* キーボード操作時のフォーカスを分かりやすくする */
:focus-visible {
  outline: 2px solid var(--assist);
  outline-offset: 2px;
}

/* ---- header ---- */
.app-header {
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 46px; height: 46px;
  flex: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--assist), var(--gen));
  box-shadow: 0 6px 16px rgba(79, 110, 247, .25);
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  display: grid;
  place-items: center;
}
.brand-text h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: .01em;
}
.brand-text p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text-sub); }
.badge {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-sub);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  white-space: nowrap;
}

/* ---- layout ---- */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 32px 56px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

/* ---- card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* カード上部にテーマ色をうっすら敷いて、2つの機能を見分けやすくする */
.card-head {
  padding: 32px 32px 4px;
  background: linear-gradient(180deg, var(--assist-soft), rgba(255, 255, 255, 0));
}
.card--gen .card-head { background: linear-gradient(180deg, var(--gen-soft), rgba(255, 255, 255, 0)); }
.card-head h2 {
  margin: 14px 0 8px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: .01em;
}
.lead { margin: 0; color: var(--text-sub); font-size: 15px; }

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.6;
  border-radius: 999px;
  padding: 4px 14px;
}
.tag--assist { background: #e3e9ff; color: #3550d8; }
.tag--gen { background: #ffe4da; color: #c2431f; }

.card-body { padding: 24px 32px 36px; }

/* ---- form ---- */
.field { margin-bottom: 26px; }
.label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
  margin-bottom: 8px;
}
.input {
  width: 100%;
  padding: 13px 16px;
  font: inherit;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:hover { border-color: #d6dae8; }
textarea.input { resize: vertical; min-height: 120px; }
.input:focus {
  border-color: var(--assist);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, .16);
  background: var(--surface);
}
.card--gen .input:focus {
  border-color: var(--gen);
  box-shadow: 0 0 0 3px rgba(232, 85, 44, .16);
}
/* select は OS 標準の矢印をやめて、画面全体と同じトーンに揃える */
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 44px;
  min-height: 50px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none' stroke='%235c6273' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M5 8l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ---- dropzone ---- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 32px 20px;
  text-align: center;
  border: 2px dashed #ccd4ec;
  border-radius: var(--radius-md);
  background: #fafbff;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--assist); background: var(--assist-soft); }
.dropzone-icon { font-size: 30px; line-height: 1.2; }
.dropzone-title { font-size: 15px; font-weight: 700; }
.dropzone-sub { font-size: 13px; line-height: 1.6; color: var(--text-sub); }
.dropzone-file { font-size: 13px; color: var(--text-sub); margin-top: 8px; }

/* ---- buttons ---- */
.btn {
  width: 100%;
  min-height: 54px;
  padding: 15px 20px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform .08s, box-shadow .15s, filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn--assist { background: var(--assist); box-shadow: 0 6px 18px rgba(79, 110, 247, .28); }
.btn--gen { background: var(--gen); box-shadow: 0 6px 18px rgba(232, 85, 44, .28); }
.btn:disabled { opacity: .6; cursor: default; filter: none; transform: none; box-shadow: none; }

/* ---- result ---- */
.result { margin-top: 28px; }
.result-head { margin-bottom: 10px; }
.result-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text-sub);
}
.card--assist .result-label { color: #3550d8; }
.result-body {
  margin: 0;
  padding: 20px 22px;
  font-size: 15px;
  line-height: 1.85;
  white-space: pre-wrap;
  min-height: 96px;
  background: var(--surface-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
}
.result-body.is-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f3c0bb;
}

/* ---- 補足テキスト・案内 ---- */
.hint {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-sub);
}
.notice {
  margin: 18px 0 0;
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.7;
  color: #8a4b20;
  background: var(--gen-soft);
  border: 1px solid #f6c9b6;
  border-radius: var(--radius-md);
}
.notice.is-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f3c0bb;
}

/* ---- preview ---- */
.preview-head { margin-top: 30px; margin-bottom: 10px; }
.preview-head .result-label { color: #c2431f; }
.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}
/* 1枚だけのときは大きく見せる */
.preview-grid:has(.preview-card:only-child) { grid-template-columns: 1fr; }
.preview-card {
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}
.preview-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.page-no { font-size: 14px; font-weight: 700; white-space: nowrap; }
.panel-chip {
  font-size: 12px;
  line-height: 1.6;
  color: #c2431f;
  background: var(--gen-soft);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}
.preview-frame {
  aspect-ratio: 3 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed #dfe3ee;
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(45deg, #fafbfd, #fafbfd 10px, #f3f5fa 10px, #f3f5fa 20px);
  color: var(--text-sub);
  text-align: center;
  padding: 12px;
}
.preview-frame:has(.preview-image) {
  border-style: solid;
  border-color: var(--border);
  background: #fff;
  padding: 0;
  overflow: hidden;
}
.preview-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.frame-icon { font-size: 28px; line-height: 1.2; }
.frame-title { font-size: 13px; font-weight: 700; line-height: 1.5; }
.preview-note {
  margin: 12px 0 2px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-sub);
  text-align: center;
}

/* ---- footer ---- */
.app-footer {
  padding: 8px 24px 40px;
  text-align: center;
  font-size: 13px;
  color: var(--text-sub);
}
.app-footer p { margin: 0; }

/* ---- タブレット：1カラムにして読みやすい幅に収める ---- */
@media (max-width: 1023px) {
  .layout {
    grid-template-columns: 1fr;
    max-width: 760px;
    padding: 32px 24px 48px;
    gap: 24px;
  }
  /* カードと同じ幅にそろえる */
  .header-inner { max-width: 760px; padding: 16px 24px; }
  .card-head { padding: 28px 24px 4px; }
  .card-body { padding: 20px 24px 32px; }
}

/* ---- スマホ：縦並び・タップしやすい大きさ ---- */
@media (max-width: 640px) {
  body { background-image: linear-gradient(180deg, var(--bg-tint) 0%, var(--bg) 220px); }
  .layout { padding: 20px 16px 36px; gap: 20px; }
  .header-inner { padding: 12px 16px; }
  .brand { gap: 12px; }
  .brand-mark { width: 40px; height: 40px; font-size: 20px; border-radius: 12px; }
  .brand-text h1 { font-size: 17px; }
  .brand-text p { display: none; }
  .card-head { padding: 24px 18px 4px; }
  .card-head h2 { font-size: 20px; }
  .card-body { padding: 18px 18px 28px; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .preview-grid { grid-template-columns: 1fr; padding: 14px; }
  .input { font-size: 16px; } /* iOS の自動ズーム防止 */
  .result-body { padding: 18px 16px; }
}

/* ---- アニメーションを減らす設定への配慮 ---- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
