/* =========================================================
   Manga Creative Studio - スタイル定義
   デザイントークン（:root）→ 共通パーツ → 個別パーツ の順
   ========================================================= */

/* ===== デザイントークン ===== */
:root {
  /* 配色：ベース */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #fafbfe;
  --border: #e7eaf1;
  --text: #141a26;
  --text-sub: #5a6478;
  --placeholder: #97a1b3;

  /* 配色：アクセント（アシスタント＝青／生成＝紫） */
  --assistant: #2b5bd7;
  --assistant-hover: #2450c4;
  --assistant-soft: #eef2ff;
  --assistant-line: #dde4ff;
  --generate: #7442cf;
  --generate-hover: #663ab8;
  --generate-soft: #f4efff;
  --generate-line: #e4d9fa;

  /* 配色：状態 */
  --ok: #0b7047;
  --ok-soft: #e8f6ef;
  --warn: #7a5200;
  --warn-soft: #fff6e6;
  --warn-line: #f0dfba;
  --danger: #a32a1c;
  --danger-soft: #fef1ef;
  --danger-line: #f6cdc6;

  /* 角丸 */
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;

  /* 影 */
  --shadow-card: 0 1px 2px rgba(17, 24, 39, .04), 0 10px 30px rgba(17, 24, 39, .06);

  /* 余白（画面幅に応じて切り替え） */
  --pad-card: 20px;
  --gap-section: 24px;
  --gutter: 16px;
}
@media (min-width: 768px) {
  :root {
    --pad-card: 28px;
    --gap-section: 28px;
    --gutter: 24px;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* 英字はシステムのモダンなフォント、日本語は読みやすい明朝以外の書体を優先 */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
               "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.8;
  letter-spacing: .01em;
  font-feature-settings: "palt" 1; /* 日本語の字間を自然に詰める */
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* 見出しの改行位置を自然にする（未対応ブラウザでは無視される）。
   本文に使うと狭い幅で改行が不揃いになるため、見出しのみに適用する */
.app-title,
.card__title { word-break: auto-phrase; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ===== ヘッダー ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.app-header__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px var(--gutter);
  display: flex;
  align-items: center;
  gap: 14px;
}
.app-logo {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--assistant), var(--generate));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .06em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.35;
}
.app-subtitle {
  margin: 3px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-sub);
}
@media (min-width: 768px) {
  .app-title { font-size: 22px; }
  .app-subtitle { font-size: 13px; }
}

/* ===== レイアウト =====
   スマホ・タブレット：1カラム（読みやすい幅に制限）
   PC（1024px〜）：2カラム */
.layout {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px var(--gutter) 40px;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap-section);
}
@media (min-width: 768px) {
  .layout { padding: 32px var(--gutter) 56px; }
}
@media (min-width: 1024px) {
  .layout {
    max-width: 1180px;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

/* ===== カード ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
/* 上部にごく薄い色を敷いて、2つの役割を色で区別する */
.card--assistant { background-image: linear-gradient(180deg, rgba(43, 91, 215, .05), rgba(43, 91, 215, 0) 200px); }
.card--generate  { background-image: linear-gradient(180deg, rgba(116, 66, 207, .05), rgba(116, 66, 207, 0) 200px); }

.card__head { padding: var(--pad-card) var(--pad-card) 0; }
.card__body { padding: 22px var(--pad-card) var(--pad-card); }

.card__title {
  margin: 14px 0 8px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: -.01em;
}
.card__desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.85;
  color: var(--text-sub);
}
@media (min-width: 768px) {
  .card__title { font-size: 21px; }
}

/* ===== バッジ・タグ ===== */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 6px 12px;
  border-radius: 999px;
}
.badge--assistant { background: var(--assistant-soft); color: var(--assistant); }
.badge--generate  { background: var(--generate-soft);  color: var(--generate); }

.card__tag {
  margin: 14px 0 0;
  display: inline-flex;
  align-items: flex-start; /* 2行に折り返しても印が1行目に揃うように */
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
  padding: 7px 13px;
  border-radius: 999px;
}
/* 色だけに頼らず、丸い印で状態を示す */
.card__tag::before {
  content: "";
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  margin-top: .58em;
  border-radius: 50%;
  background: currentColor;
}
.card__tag--live    { color: var(--ok);   background: var(--ok-soft); }
.card__tag--planned { color: var(--warn); background: var(--warn-soft); }

/* ===== フォーム ===== */
.field { margin-bottom: 22px; }
.field__label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
  margin-bottom: 9px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 18px;
}
@media (min-width: 480px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}

.input {
  width: 100%;
  padding: 13px 15px;
  font-size: 16px; /* 16px未満にするとiOSで入力時に拡大されるため */
  line-height: 1.7;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.input::placeholder { color: var(--placeholder); }
.input:hover { border-color: #d5dbe7; }
.input:focus {
  background: var(--surface);
  border-color: var(--assistant);
  box-shadow: 0 0 0 3px rgba(43, 91, 215, .16);
}
.card--generate .input:focus {
  border-color: var(--generate);
  box-shadow: 0 0 0 3px rgba(116, 66, 207, .16);
}
.input--area {
  resize: vertical;
  min-height: 108px;
  line-height: 1.85;
}
select.input {
  appearance: none;
  cursor: pointer;
  padding-right: 42px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' stroke='%235a6478' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 15px center;
}

/* ===== 画像アップロード欄 ===== */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 30px 18px;
  text-align: center;
  border: 1.5px dashed #c6cfe0;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.dropzone:hover,
.dropzone:focus-within {
  border-color: var(--assistant);
  background: var(--assistant-soft);
}
.dropzone__icon {
  display: flex;
  color: var(--assistant);
}
.dropzone__icon svg { width: 26px; height: 26px; }
.dropzone__main {
  font-size: 14px;
  font-weight: 700;
  color: var(--assistant);
}
.dropzone__sub {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-sub);
}
.file-name {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--text-sub);
}

/* ===== ボタン ===== */
.btn {
  width: 100%;
  min-height: 54px;
  padding: 15px 22px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: .02em;
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, background-color .2s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid rgba(43, 91, 215, .4); outline-offset: 2px; }

.btn--assistant {
  background: var(--assistant);
  box-shadow: 0 6px 18px rgba(43, 91, 215, .26);
}
.btn--assistant:hover:not(:disabled) {
  background: var(--assistant-hover);
  box-shadow: 0 10px 24px rgba(43, 91, 215, .3);
}
.btn--generate {
  background: var(--generate);
  box-shadow: 0 6px 18px rgba(116, 66, 207, .24);
}
.btn--generate:hover:not(:disabled) {
  background: var(--generate-hover);
  box-shadow: 0 10px 24px rgba(116, 66, 207, .28);
}
.btn--generate:focus-visible { outline-color: rgba(116, 66, 207, .4); }

/* ===== 出力結果・プレビュー ===== */
.result,
.preview {
  margin-top: 26px;
  scroll-margin-top: 90px; /* 固定ヘッダーに隠れないように */
}
.result__head,
.preview__head { margin-bottom: 12px; }
.result__label {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--text-sub);
}
.result__body {
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.95;
  background: var(--assistant-soft);
  border: 1px solid var(--assistant-line);
  border-radius: var(--radius-md);
  padding: 20px;
}
.result__body--error {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger);
}

/* カード一覧：スマホ1列 → タブレット・PC 2列 */
.preview__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 520px) {
  .preview__grid { grid-template-columns: repeat(2, 1fr); }
}

.page-card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color .2s, box-shadow .2s;
}
.page-card:hover {
  border-color: var(--generate-line);
  box-shadow: 0 6px 18px rgba(116, 66, 207, .08);
}
.page-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.page-card__no {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .01em;
}
.page-card__meta {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--generate);
  background: var(--generate-soft);
  padding: 4px 10px;
  border-radius: 999px;
}
.page-card__thumb {
  aspect-ratio: 3 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, #faf8ff, #f4f0fd);
  border: 1px dashed var(--generate-line);
  border-radius: var(--radius-sm);
  color: var(--text-sub);
  font-size: 12.5px;
}
.page-card__thumb-icon {
  display: flex;
  color: #a290d6;
}
.page-card__thumb-icon svg { width: 28px; height: 28px; }
.page-card__note {
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-sub);
  text-align: center;
}

/* ===== 補足テキスト ===== */
.note {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-sub);
}

/* ===== 案内・エラーの枠 ===== */
.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-md);
  scroll-margin-top: 90px;
}
/* hidden属性を付けたときは display:flex より優先して隠す */
.notice[hidden] { display: none; }
.notice__icon {
  flex: 0 0 20px;
  display: flex;
  margin-top: 2px;
  color: var(--warn);
}
.notice__icon svg { width: 20px; height: 20px; }
.notice__text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--warn);
}
/* 通常時は「案内」、エラー時は「注意」のアイコンに切り替える */
.notice__icon .icon-warn { display: none; }
.notice--error .notice__icon .icon-info { display: none; }
.notice--error .notice__icon .icon-warn { display: block; }
.notice--error {
  background: var(--danger-soft);
  border-color: var(--danger-line);
}
.notice--error .notice__icon,
.notice--error .notice__text { color: var(--danger); }

/* ===== フッター ===== */
.app-footer {
  text-align: center;
  padding: 0 var(--gutter) 44px;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--text-sub);
}
.app-footer p { margin: 0; }
