/* =========================================================
   Manga Creative Studio
   色・文字・余白はここのCSS変数で一元管理しています
   ========================================================= */
:root {
  /* ベース */
  --bg: #f4f6fb;
  --card: #ffffff;
  --surface: #f8f9fc;          /* 入力欄・ドロップゾーンの背景 */
  --text: #1a1f2c;
  --muted: #5b6170;            /* 補足テキスト（淡色背景でも 4.5:1 以上） */
  --border: #e2e6ef;

  /* 機能ごとのメインカラー（白文字とのコントラスト 5:1 以上） */
  --assistant: #2563eb;        /* 青：企画・アイデア出しアシスタント */
  --assistant-soft: #eef3ff;
  --generate: #c2410c;         /* オレンジ：漫画生成 */
  --generate-soft: #fff3eb;

  --danger: #b42318;
  --danger-soft: #fef1f0;

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

  /* 文字 */
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 400px at 0% 0%, rgba(37, 99, 235, .06), transparent 60%),
    radial-gradient(1200px 400px at 100% 0%, rgba(194, 65, 12, .05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-feature-settings: "palt"; letter-spacing: .02em; line-height: 1.4; }

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

/* キーボード操作時のフォーカス表示 */
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent, var(--assistant)) 45%, transparent);
  outline-offset: 2px;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--assistant), var(--generate));
  color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, .25);
}
.logo-text { font-weight: 800; font-size: 20px; letter-spacing: -.01em; }
.badge-mock {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px;
}

/* ---------- Layout ---------- */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  padding-top: 40px;
  padding-bottom: 56px;
  align-items: start;
}

.panel {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px 32px;
  box-shadow: var(--shadow-card);
}
/* 機能を色で区別する上部のアクセントライン */
.panel::before {
  content: "";
  position: absolute; inset: 0 0 auto 0;
  height: 4px;
  background: var(--accent);
}
.panel-assistant { --accent: var(--assistant); --accent-soft: var(--assistant-soft); }
.panel-generate  { --accent: var(--generate);  --accent-soft: var(--generate-soft); }

.panel-head { margin-bottom: 28px; }
.step {
  display: inline-block;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 12px;
}
.panel h2 { margin: 14px 0 8px; font-size: 24px; font-weight: 800; }
.lead { margin: 0; color: var(--muted); font-size: 15px; }

/* ---------- Form ---------- */
.field { margin-bottom: 22px; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
}
select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;               /* iOSで自動ズームしないよう16px以上 */
  line-height: 1.6;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
select {
  min-height: 50px;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 42px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235b6170' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}
textarea { resize: vertical; min-height: 120px; }
textarea::placeholder { color: #8a909e; }
select:hover, textarea:hover { border-color: #cdd3df; }
select:focus, textarea:focus {
  outline: none;
  background-color: var(--card);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ラフ画像アップロード（inputは見た目だけ隠し、キーボード操作は可能） */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 28px 16px;
  border: 1.5px dashed #cdd3df;
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.dropzone-icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card); color: var(--accent);
  box-shadow: 0 2px 6px rgba(16, 24, 40, .08);
  font-size: 20px; margin-bottom: 6px;
}
.dropzone-title { font-weight: 700; font-size: 15px; word-break: break-all; }
.dropzone-sub { font-size: 13px; color: var(--muted); }

/* ---------- Button ---------- */
.btn {
  width: 100%;
  min-height: 56px;
  margin-top: 6px;
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .04em;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 28%, transparent);
  transition: transform .12s, box-shadow .15s, filter .15s;
}
.btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 34%, transparent);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .7; cursor: wait; transform: none; }

/* ---------- Output ---------- */
.output, .preview {
  margin-top: 32px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  padding: 20px;
}
.output-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--accent);
  margin-bottom: 12px;
}
.output-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.output-body {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  font-size: 15px;
  line-height: 1.8;
}
.output-title { margin: 0 0 6px; font-weight: 700; }
.output-body ul { margin: 0; padding-left: 1.2em; }
.output-body li + li { margin-top: 6px; }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.page-card {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.page-card-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; margin-bottom: 10px;
}
.page-card-head strong { font-size: 15px; }
.page-card-head span {
  color: var(--accent); font-size: 12px; font-weight: 700;
  background: var(--accent-soft); border-radius: 999px; padding: 1px 10px;
}
.page-frame {
  aspect-ratio: 1 / 1.414;       /* 漫画原稿のような縦長 */
  border: 2px solid var(--text);
  border-radius: 4px;
  padding: 5px;
  display: grid;
  gap: 5px;
  position: relative;
  background: var(--card);
}
.koma { background: #eef0f5; border-radius: 2px; }
.page-frame-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 10px;
  pointer-events: none;
}
.page-frame-label b {
  font-size: 12px; background: rgba(255,255,255,.95);
  padding: 3px 8px; border-radius: 6px; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
.page-frame-label small {
  margin-top: 6px; font-size: 11px; color: var(--muted);
  background: rgba(255,255,255,.95); padding: 2px 6px; border-radius: 6px; line-height: 1.5;
}

/* ---------- 状態表示（アップロード・エラー・生成中など） ---------- */
.upload-thumb { max-height: 140px; max-width: 100%; object-fit: contain; border-radius: var(--radius-sm); margin-bottom: 6px; }
.link-btn {
  margin-top: 6px; background: none; border: 0; padding: 6px 2px;
  color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer;
}
.link-btn:hover { color: var(--text); }
.hint { margin: 12px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.error-box {
  margin: 16px 0 0; padding: 12px 16px; border-radius: var(--radius-md);
  background: var(--danger-soft); color: var(--danger); border: 1px solid #f8cfcb;
  font-size: 14px; font-weight: 600;
}
.ai-text { white-space: pre-wrap; margin: 0; }
.page-frame.has-image { padding: 0; border-width: 1px; border-color: var(--border); overflow: hidden; display: block; }
.page-frame.has-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.page-frame.is-loading .koma { animation: pulse 1.2s ease-in-out infinite; }
.page-frame.is-error { border-color: var(--danger); }
.page-frame-label small:empty { display: none; }
@keyframes pulse { 50% { opacity: .45; } }
.page-card-actions { margin-top: 8px; text-align: right; font-size: 13px; }
.page-card-actions:empty { display: none; }
.page-card-actions a { color: var(--accent); font-weight: 700; text-decoration: none; }
.page-card-actions a:hover { text-decoration: underline; }

.app-footer {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 0 0 40px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Tablet（〜960px）：1列にし、横に伸びすぎないよう幅を制限 ---------- */
@media (max-width: 960px) {
  .main-grid {
    grid-template-columns: 1fr;
    gap: 28px;
    max-width: 720px;
  }
}

/* ---------- Smartphone（〜600px） ---------- */
@media (max-width: 600px) {
  .container { padding: 0 16px; }
  .header-inner { height: 56px; }
  .logo-mark { width: 32px; height: 32px; font-size: 16px; }
  .logo-text { font-size: 17px; white-space: nowrap; }
  .badge-mock { display: none; }
  .main-grid { padding-top: 20px; padding-bottom: 40px; gap: 20px; }
  .panel { padding: 28px 18px 22px; border-radius: 16px; }
  .panel-head { margin-bottom: 22px; }
  .panel h2 { font-size: 21px; }
  .lead { font-size: 14px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .output, .preview { padding: 16px; margin-top: 24px; }
  .output-body { padding: 16px; }
  /* プレビューは2列（縦に長くなりすぎないように） */
  .preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .page-card { padding: 10px; }
  .page-card-head { flex-direction: column; align-items: flex-start; gap: 2px; margin-bottom: 8px; }
  .page-card-head strong { font-size: 14px; white-space: nowrap; }
  .page-card-head span { font-size: 11px; padding: 0 8px; white-space: nowrap; }
  .page-frame { padding: 4px; gap: 4px; }
  .page-frame-label b { font-size: 11px; padding: 2px 6px; }
  .page-frame-label small { display: none; }   /* 狭い枠では補足文を省略 */
}
