/* =========================================================
   Manga Creative Studio - スタイル
   色・角丸・影は :root の変数で一元管理しています
   ========================================================= */
:root {
  /* ベース */
  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1a1d29;
  --text-sub: #4a5063;   /* 補足文（背景とのコントラストを確保） */
  --muted: #6a7084;
  --border: #e4e7ef;

  /* エリアごとのアクセント */
  --assistant: #0d8f82;       /* 企画・アイデア出し：ティール */
  --assistant-strong: #0a7369;
  --assistant-soft: #e8f6f4;
  --generate: #6d4ae8;        /* 漫画生成：バイオレット */
  --generate-strong: #5836d1;
  --generate-soft: #f0ecfe;

  /* 状態 */
  --info: #2f55c7;
  --info-soft: #eef3ff;
  --danger: #c02626;
  --danger-soft: #fdeeee;

  --radius-lg: 20px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.04), 0 8px 24px rgba(20, 24, 40, 0.06);
  --font: "Inter", "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  background:
    radial-gradient(1200px 400px at 10% -10%, #e9f5f3 0%, transparent 60%),
    radial-gradient(1000px 400px at 100% 0%, #efeafd 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.icon { width: 20px; height: 20px; flex-shrink: 0; }

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

/* ===== ヘッダー ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--assistant) 0%, var(--generate) 100%);
  box-shadow: 0 4px 12px rgba(109, 74, 232, 0.25);
}
.app-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.app-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22a565; }

/* ===== 2カラムレイアウト ===== */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  padding-top: 40px;
  padding-bottom: 40px;
  align-items: start;
}

/* ===== パネル（カード） ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}
.panel-head { margin-bottom: 28px; }
.panel-title-row { display: flex; align-items: center; gap: 14px; }
.panel-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  flex-shrink: 0;
}
.panel-icon .icon { width: 24px; height: 24px; }
.panel-assistant .panel-icon { background: var(--assistant-soft); color: var(--assistant); }
.panel-generate  .panel-icon { background: var(--generate-soft);  color: var(--generate); }

.step-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.4;
}
.panel-assistant .step-label { color: var(--assistant); }
.panel-generate  .step-label { color: var(--generate); }

.panel-head h2 {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.panel-desc {
  margin: 16px 0 0;
  color: var(--text-sub);
  font-size: 14px;
}

/* ===== 入力欄 ===== */
.field { margin-bottom: 22px; }
.field-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 16px; /* スマホでの自動ズーム防止 */
  line-height: 1.6;
  color: var(--text);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 120px; }
textarea::placeholder { color: #9a9fb0; }
select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 48px;
  padding-right: 42px;
  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='%236a7084' 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;
}
select:hover, textarea:hover { border-color: #cdd2de; }
.panel-assistant select:focus, .panel-assistant textarea:focus {
  outline: none;
  border-color: var(--assistant);
  box-shadow: 0 0 0 4px var(--assistant-soft);
}
.panel-generate select:focus, .panel-generate textarea:focus {
  outline: none;
  border-color: var(--generate);
  box-shadow: 0 0 0 4px var(--generate-soft);
}

/* アップロード欄 */
.upload-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 28px 16px;
  border: 1.5px dashed #c9cfdc;
  border-radius: var(--radius);
  background: #fafbfd;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.upload-box:hover { border-color: var(--assistant); background: var(--assistant-soft); }
.upload-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--assistant-soft);
  color: var(--assistant);
}
.upload-text { font-weight: 600; color: var(--assistant-strong); }
.upload-hint { font-size: 13px; color: var(--muted); }

.note { margin: 10px 0 0; font-size: 13px; color: var(--muted); line-height: 1.6; }

/* ===== ボタン ===== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 14px 20px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn:hover  { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: -5px; }
.btn-assistant { background: var(--assistant); box-shadow: 0 6px 16px rgba(13, 143, 130, 0.25); }
.btn-assistant:hover { background: var(--assistant-strong); box-shadow: 0 10px 22px rgba(13, 143, 130, 0.3); }
.btn-generate  { background: var(--generate);  box-shadow: 0 6px 16px rgba(109, 74, 232, 0.25); }
.btn-generate:hover  { background: var(--generate-strong); box-shadow: 0 10px 22px rgba(109, 74, 232, 0.3); }
.btn:disabled { opacity: 0.7; cursor: wait; transform: none; box-shadow: none; }
.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.btn.is-loading .btn-spinner { display: block; }
.btn.is-loading .icon { display: none; }

/* ===== お知らせ・エラー ===== */
.info-box, .error-box {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
}
.info-box::before, .error-box::before {
  content: "";
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  background: currentColor;
  -webkit-mask: var(--mask) no-repeat center / contain;
  mask: var(--mask) no-repeat center / contain;
}
.info-box {
  background: var(--info-soft);
  color: var(--info);
  --mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E");
}
.error-box {
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
  --mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E");
}
.panel-head .info-box { margin-top: 16px; }

/* ===== 回答エリア ===== */
.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-sub);
}
.section-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.result-box {
  margin-top: 28px;
  padding: 22px 24px;
  border-radius: 14px;
  background: var(--assistant-soft);
  border: 1px solid #cfeae6;
}
.result-box .section-label { color: var(--assistant-strong); }
.result-title { margin: 0 0 6px; font-weight: 700; }
.result-list { margin: 0; padding-left: 1.2em; }
.result-list li { margin-bottom: 6px; }
.result-answer { white-space: pre-wrap; font-size: 15px; line-height: 1.85; }

/* ===== プレビュー ===== */
.preview-area { margin-top: 28px; }
.preview-area .section-label { color: var(--generate-strong); }
.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* PC・タブレットは2列（枚数は1/2/4/8なので端数が出ない） */
  gap: 16px;
}
.preview-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
}
.preview-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.preview-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.preview-meta strong { color: var(--generate-strong); font-weight: 700; }
.preview-meta span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  background: #f2f3f7;
  padding: 2px 10px;
  border-radius: 999px;
}
.preview-image {
  position: relative;
  aspect-ratio: 3 / 4; /* 漫画ページ風の縦長 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  text-align: center;
  background: #fafafc;
}
/* コマ割りの下書き線（選択したコマ数に合わせて表示） */
.panel-skeleton {
  position: absolute;
  inset: 12px;
  display: grid;
  gap: 6px;
}
.panel-skeleton i {
  border: 1.5px solid #dcdfe8;
  border-radius: 4px;
  background: #fff;
}
.skeleton-1 { grid-template: 1fr / 1fr; }
.skeleton-2 { grid-template: 1fr 1fr / 1fr; }
.skeleton-4 { grid-template: repeat(4, 1fr) / 1fr; }
.skeleton-6 { grid-template: repeat(3, 1fr) / 1fr 1fr; }
.preview-overlay {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 10px rgba(20, 24, 40, 0.06);
}
.preview-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--generate);
  background: var(--generate-soft);
  padding: 2px 10px;
  border-radius: 999px;
}
.preview-image p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-sub);
}
.preview-image.has-image { padding: 0; aspect-ratio: 2 / 3; background: #fff; }
.preview-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.preview-image a { display: block; width: 100%; height: 100%; }
.preview-error { color: var(--danger) !important; font-weight: 700; }
.spinner {
  width: 32px; height: 32px;
  border: 4px solid var(--generate-soft);
  border-top-color: var(--generate);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== フッター ===== */
.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 0 16px 40px;
}
.app-footer p { margin: 0; }

/* ===== タブレット（1カラム・横に伸びすぎない幅） ===== */
@media (max-width: 960px) {
  .main-grid {
    grid-template-columns: 1fr;
    max-width: 760px;
    gap: 24px;
    padding-top: 28px;
  }
  .container { padding: 0 24px; }
}

/* ===== スマホ ===== */
@media (max-width: 600px) {
  body { font-size: 15px; }
  .container { padding: 0 16px; }
  .header-inner { min-height: 64px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
  .brand { gap: 10px; }
  .app-title { font-size: 16px; white-space: nowrap; }
  .app-subtitle { display: none; }
  .status-pill { padding: 4px 10px; font-size: 12px; gap: 6px; }
  .main-grid { padding-top: 20px; gap: 20px; }
  .panel { padding: 22px 18px; border-radius: 16px; }
  .panel-icon { width: 42px; height: 42px; border-radius: 12px; }
  .panel-head h2 { font-size: 20px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .result-box { padding: 18px; }
  .preview-grid { grid-template-columns: 1fr; } /* プレビューは縦並び */
}
