/* =========================================================
   Manga Creative Studio - スタイル
   色・余白・角丸・影は下のデザイントークン（CSS変数）で管理
   ========================================================= */
:root {
  /* ベース */
  --bg: #fdf6f9;
  --surface: #ffffff;
  --surface-soft: #fffafc;
  --text: #2a1f26;
  --muted: #6b5a64;          /* 背景とのコントラスト 5.9:1 */
  --border: #f0dfe7;
  --border-strong: #e6c9d6;

  /* STEP 1：アシスタント（ピンク） */
  --assist: #db2777;         /* 白文字とのコントラスト 4.6:1 */
  --assist-ink: #be185d;
  --assist-soft: #fdeaf2;

  /* STEP 2：生成（フューシャ） */
  --generate: #a21caf;       /* 白文字とのコントラスト 6.3:1 */
  --generate-ink: #86198f;
  --generate-soft: #f8e8fa;

  /* エラー */
  --danger: #b42318;
  --danger-soft: #fef1f1;
  --danger-border: #f5c2c2;

  /* 形 */
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(60, 20, 45, .04), 0 8px 24px rgba(60, 20, 45, .06);

  /* 余白（8px基準） */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font: "Inter", "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

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

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 64px;
}
.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--assist), var(--generate));
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.app-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.badge-mock {
  margin-left: auto;
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 12px;
  white-space: nowrap;
}

/* ---------- Intro ---------- */
.intro {
  padding-top: var(--space-7);
  padding-bottom: var(--space-5);
  text-align: center;
}
.intro-eyebrow {
  margin: 0 0 var(--space-2);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--assist-ink);
}
.intro-title {
  margin: 0 0 var(--space-3);
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  line-height: 1.35;
  font-weight: 800;
  letter-spacing: -.01em;
}
.intro-text {
  margin: 0 auto;
  max-width: 40em;
  color: var(--muted);
}

/* ---------- Layout ---------- */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  padding-top: var(--space-5);
  padding-bottom: var(--space-7);
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.panel { padding: var(--space-6); }

/* パネル見出し */
.panel-head {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  margin-bottom: var(--space-6);
}
.step-num {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
}
.panel-assist .step-num   { background: var(--assist); }
.panel-generate .step-num { background: var(--generate); }
.step {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .08em;
}
.panel-assist .step   { color: var(--assist-ink); }
.panel-generate .step { color: var(--generate-ink); }
.panel-head h2 {
  margin: 2px 0 var(--space-2);
  font-size: 1.35rem;
  line-height: 1.4;
  font-weight: 800;
}
.desc { margin: 0; color: var(--muted); font-size: .94rem; }

/* ---------- Form ---------- */
.field { margin-bottom: var(--space-5); }
.field-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: .92rem;
  margin-bottom: var(--space-2);
}
.tag {
  font-size: .7rem;
  font-weight: 700;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
}
.tag-required { color: #fff; background: var(--text); }
.tag-optional { color: var(--muted); background: #f3eaee; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

select, textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;           /* iOSでのズーム防止 */
  color: var(--text);
  background-color: var(--surface-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
select {
  min-height: 48px;
  appearance: none;
  -webkit-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='%236b5a64' 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;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.7; }
textarea::placeholder { color: #9a8a93; }
select:hover, textarea:hover { border-color: #d9b3c4; }
select:focus, textarea:focus { outline: none; background-color: var(--surface); }
.panel-assist select:focus,   .panel-assist textarea:focus   { border-color: var(--assist);   box-shadow: 0 0 0 4px var(--assist-soft); }
.panel-generate select:focus, .panel-generate textarea:focus { border-color: var(--generate); box-shadow: 0 0 0 4px var(--generate-soft); }

/* アップロード */
.upload-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-6) var(--space-4);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-box:hover { border-color: var(--assist); background: var(--assist-soft); }
.upload-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--assist-soft);
  color: var(--assist-ink);
  display: grid;
  place-items: center;
  margin-bottom: var(--space-2);
}
.upload-box:hover .upload-icon { background: var(--surface); }
.upload-main { font-weight: 700; font-size: .94rem; }
.upload-sub  { color: var(--muted); font-size: .82rem; }
.upload-file { color: var(--assist-ink); font-size: .86rem; font-weight: 700; }
.upload-thumb {
  max-width: 100%;
  max-height: 180px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  box-shadow: var(--shadow-card);
}
.upload-thumb:not([hidden]) ~ .upload-icon { display: none; }
.link-btn {
  margin-top: var(--space-2);
  min-height: 36px;
  background: none;
  border: none;
  color: var(--assist-ink);
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px 0;
}

/* ---------- Buttons ---------- */
.btn {
  width: 100%;
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, filter .15s;
}
.btn:hover  { filter: brightness(1.07); transform: translateY(-1px); }
.btn:active { transform: translateY(0); filter: brightness(.97); }
.btn:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.btn:disabled { opacity: .65; cursor: wait; transform: none; filter: none; }
.btn-assist   { background: var(--assist);   box-shadow: 0 8px 20px rgba(219, 39, 119, .28); }
.btn-generate { background: var(--generate); box-shadow: 0 8px 20px rgba(162, 28, 175, .26); }

/* ---------- Output ---------- */
.output, .preview {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}
.output-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-weight: 700;
  font-size: .94rem;
  margin-bottom: var(--space-3);
}
.panel-assist .output-head .icon   { color: var(--assist-ink); }
.panel-generate .output-head .icon { color: var(--generate-ink); }
.output-body {
  background: var(--assist-soft);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  font-size: .95rem;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.status-text { font-weight: 500; color: var(--muted); font-size: .85rem; }

.error-msg {
  margin: var(--space-3) 0 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: .92rem;
  font-weight: 600;
}

/* ---------- Preview ---------- */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}
.preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  transition: box-shadow .15s, transform .15s;
}
.preview-card:hover { box-shadow: var(--shadow-card); transform: translateY(-2px); }
.preview-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  padding: 10px 12px;
  font-size: .88rem;
}
.preview-meta > * { white-space: nowrap; }
.preview-meta span {
  color: var(--generate-ink);
  background: var(--generate-soft);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: .75rem;
  font-weight: 700;
}
.preview-image {
  aspect-ratio: 2 / 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  text-align: center;
  font-size: .82rem;
  color: var(--muted);
  background: repeating-linear-gradient(45deg, #faf0fb 0 10px, #fdf8fd 10px 20px);
}
.preview-label { font-weight: 700; color: var(--generate-ink); font-size: .9rem; }
.preview-image:has(img) { padding: 0; background: var(--surface); }
.preview-image a { display: block; width: 100%; height: 100%; }
.preview-image img { width: 100%; height: 100%; object-fit: contain; display: block; }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--generate-soft);
  border-top-color: var(--generate);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
  padding: 0 0 var(--space-6);
}

/* ---------- Responsive ---------- */
/* タブレット：2つのパネルは横並びのまま、余白を詰める */
@media (max-width: 1024px) {
  .container { padding: 0 var(--space-4); }
  .main-grid { gap: var(--space-4); }
  .intro { padding-top: var(--space-6); }
  .panel { padding: var(--space-5); }
  .panel-head { gap: var(--space-3); }
  .step-num { width: 40px; height: 40px; }
  .panel-head h2 { font-size: 1.2rem; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .preview-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); }
}

/* 狭い画面：パネルを縦に並べる */
@media (max-width: 720px) {
  .main-grid { grid-template-columns: 1fr; max-width: 600px; }
  .field-row { grid-template-columns: 1fr 1fr; gap: var(--space-4); }
}

/* スマホ */
@media (max-width: 640px) {
  .container { padding: 0 var(--space-4); }
  .header-inner { height: 56px; }
  .app-header h1 { font-size: 1.02rem; }
  .intro { padding-top: var(--space-5); padding-bottom: var(--space-4); }
  .intro-text { font-size: .94rem; }
  .main-grid { padding-top: var(--space-2); gap: var(--space-4); }
  .panel { padding: var(--space-5) var(--space-4); }
  .panel-head { gap: var(--space-3); margin-bottom: var(--space-5); }
  .step-num { width: 40px; height: 40px; }
  .panel-head h2 { font-size: 1.2rem; }
  .output-body { padding: var(--space-4); }
  .preview-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .badge-mock { display: none; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
}
