/* =========================================================
   漫画風デザイン
   ・白黒ベース + 差し色 2 色（赤 = 生成・メイン操作 / 黄 = 強調・選択）
   ・太い枠線、ベタの影、スクリーントーン（網点）、集中線
   ========================================================= */
:root {
  --ink: #111;          /* 墨（線・文字） */
  --paper: #fff;        /* 紙 */
  --tone: #e6e6e6;      /* トーン（薄いグレー） */
  --muted: #555;
  --red: #e5231b;       /* 差し色 1 */
  --yellow: #ffd400;    /* 差し色 2 */

  --font-display: "Dela Gothic One", "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;

  --line: 3px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* display を指定した要素でも hidden で隠せるように */

body {
  margin: 0;
  /* 内容が少ない画面でも、フッターを画面の一番下に置く */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.7;
  /* スクリーントーン（網点）の背景 */
  background-color: #f4f4f4;
  background-image: radial-gradient(#cfcfcf 1.1px, transparent 1.4px);
  background-size: 9px 9px;
}

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 24px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.05rem; margin: 0 0 12px; }

/* ===== ヘッダー（ベタ + 集中線） ===== */
.app-header {
  color: var(--paper);
  background-color: var(--ink);
  background-image: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 255, 255, 0.07) 0 1.2deg, transparent 1.2deg 6deg);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.logo { display: flex; align-items: center; gap: 12px; }
.logo h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; letter-spacing: 0.03em; transform: skewX(-6deg); }
.logo-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 3px solid var(--paper);
  background: var(--red);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.2rem;
  transform: rotate(-6deg);
  box-shadow: 3px 3px 0 var(--yellow);
}
.header-right { display: flex; align-items: center; gap: 10px; }
.save-status { font-size: 0.78rem; color: #ccc; }
.btn-help { background: var(--yellow); box-shadow: 3px 3px 0 var(--red) !important; }

/* ===== タブ ===== */
.tabbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px 0;
  background: var(--ink);
  border-bottom: 5px solid var(--red);
}
.tabbar button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 26px 8px;
  border: 3px solid var(--ink);
  border-bottom: none;
  background: #333;
  color: #ddd;
  font-family: var(--font-display);
  font-size: 1rem;
  cursor: pointer;
}
.tabbar button[aria-selected="true"] { background: var(--red); color: var(--paper); }
.tabbar button:focus-visible { outline: 3px solid var(--yellow); outline-offset: -3px; }
.tab-icon { font-family: var(--font-body); }

main { flex: 1 0 auto; padding: 32px 24px 56px; }
.tab-panel { max-width: 860px; margin: 0 auto; }

/* ===== パネル（漫画のコマ風） ===== */
.panel {
  position: relative;
  background: var(--paper);
  border: var(--line);
  box-shadow: var(--shadow);
  padding: 32px;
  margin-bottom: 32px;
}
.big-title {
  margin: 0 0 24px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.7rem;
  line-height: 1.4;
}
.big-title span {
  display: inline-block;
  /* 蛍光ペン風のマーカー */
  background: linear-gradient(transparent 62%, var(--yellow) 62%, var(--yellow) 92%, transparent 92%);
}
.desc { margin: -8px 0 24px; color: var(--muted); font-size: 0.95rem; }

/* ===== 入力欄 ===== */
.field { margin: 0 0 24px; }
.label { display: block; font-weight: 700; font-size: 0.95rem; margin-bottom: 8px; }
.label::before { content: "■ "; color: var(--red); font-size: 0.7em; vertical-align: 2px; }
.hint { margin: 8px 0 0; font-size: 0.875rem; line-height: 1.6; color: var(--muted); }

select,
textarea,
input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 16px; /* iOSでズームされないサイズ */
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 12px 14px;
}
textarea { resize: vertical; min-height: 96px; }
#story-text { font-size: 17px; min-height: 120px; }
select:focus,
textarea:focus,
input[type="text"]:focus { outline: none; box-shadow: 0 0 0 4px var(--yellow); }
::placeholder { color: #767676; } /* 白背景でも読める濃さ（コントラスト 4.5:1） */

/* キーボード操作時に、どのボタンを選んでいるか分かるように */
.btn:focus-visible,
.btn-sub:focus-visible,
.btn-link:focus-visible,
.icon-btn:focus-visible,
.idea:focus-visible,
.photo-add:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* 選択チップ */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 16px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
}
.chip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 2px solid var(--ink); margin-left: -8px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 var(--red); }
.chip:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--yellow); }
.chip-add { border-style: dashed; background: #fffbe0; }

/* ネタ出し */
.idea-btn { display: inline-flex; align-items: center; min-height: 44px; margin-top: 4px; }
.idea-list { display: grid; gap: 8px; margin-top: 8px; }
.idea-list:empty { display: none; }
.idea {
  text-align: left;
  padding: 12px 16px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: #fffbe0;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.idea strong { display: block; font-family: var(--font-display); font-weight: 400; }
.idea:hover { background: var(--yellow); }

/* 詳細設定 */
.more { margin: 0 0 24px; padding: 2px 16px; border: 2px dashed var(--ink); }
.more summary { padding: 10px 0; font-weight: 700; cursor: pointer; } /* 押しやすい高さ（約 44px） */
.more[open] { padding-bottom: 16px; }
.more[open] summary { margin-bottom: 8px; }
.more .field:last-of-type { margin-bottom: 16px; }

/* 料金の目安（トーン貼り） */
.cost {
  border: 2px solid var(--ink);
  padding: 12px 16px;
  font-size: 0.9rem;
  background-color: var(--paper);
  background-image: radial-gradient(#ddd 1px, transparent 1.3px);
  background-size: 6px 6px;
}
.cost table { width: 100%; border-collapse: collapse; background: var(--paper); }
.cost td { padding: 3px 6px; }
.cost td:last-child { text-align: right; font-weight: 700; }
.cost tr.total td { border-top: 2px solid var(--ink); font-weight: 700; }
.cost tr.total td:last-child { color: var(--red); }
.cost p { margin: 8px 0 0; padding: 6px 8px; font-size: 0.85rem; line-height: 1.6; color: var(--muted); background: var(--paper); }

/* ===== ボタン（ベタ影で押し込める） ===== */
.btn {
  width: 100%;
  min-height: 56px;
  border: var(--line);
  border-radius: 6px;
  background: var(--red);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled {
  cursor: not-allowed;
  transform: none;
  box-shadow: 2px 2px 0 var(--ink);
  color: var(--ink);
  background-color: var(--tone);
  background-image: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(0, 0, 0, 0.08) 6px 8px);
}
.btn-make { min-height: 68px; font-size: 1.45rem; }
.make-note { margin: 12px 0 0; text-align: center; font-size: 0.875rem; font-weight: 700; color: var(--muted); }

.btn-sub {
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn-sub:hover { background: #fffbe0; }
.btn-sub:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn-sub:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-danger:hover { background: var(--red); color: var(--paper); }

.btn-link {
  border: none;
  background: none;
  padding: 10px 0; /* 文字だけのボタンも押しやすい高さに */
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-underline-offset: 3px;
  cursor: pointer;
}
.btn-link:disabled { opacity: 0.45; cursor: not-allowed; }

.icon-btn {
  width: 44px;
  min-height: 44px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--paper);
  font-weight: 700;
  cursor: pointer;
}
.icon-btn:hover { background: var(--red); color: var(--paper); }

/* エラーメッセージ（叫び風） */
.error-box {
  position: relative;
  margin: 16px 0 0;
  padding: 12px 14px 12px 46px;
  background: var(--paper);
  border: 3px solid var(--red);
  color: var(--red);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 4px 4px 0 var(--red);
}
.error-box::before {
  content: "！";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%) rotate(-8deg);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  background: var(--red);
  color: var(--paper);
  font-family: var(--font-display);
}

/* ===== 生成中の演出 ===== */
.progress-card { text-align: center; }
.stages { display: flex; justify-content: center; gap: 6px; list-style: none; padding: 0; margin: 0 0 18px; flex-wrap: wrap; }
.stages li {
  padding: 4px 14px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: #767676;
  font-weight: 700;
  font-size: 0.875rem;
}
.stages li.doing { background: var(--yellow); color: var(--ink); animation: bounce 0.8s ease-in-out infinite; }
.stages li.done { background: var(--ink); color: var(--paper); }
.stages li.done::before { content: "✓ "; }
@keyframes bounce { 50% { transform: translateY(-3px); } }
.bar { height: 18px; border: 2px solid var(--ink); background: var(--paper); overflow: hidden; }
.bar span {
  display: block;
  height: 100%;
  width: 0;
  background-color: var(--red);
  background-image: repeating-linear-gradient(-45deg, transparent 0 8px, rgba(255, 255, 255, 0.35) 8px 16px);
  background-size: 22px 22px;
  animation: stripe 0.6s linear infinite;
  transition: width 0.4s;
}
@keyframes stripe { to { background-position: 22px 0; } }
.quip {
  position: relative;
  display: inline-block;
  margin: 22px 0 4px;
  padding: 10px 20px;
  border: 2px solid var(--ink);
  border-radius: 22px;
  background: var(--paper);
  font-weight: 700;
}
.quip::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  border: 6px solid transparent;
  border-bottom: 10px solid var(--ink);
  transform: translateX(-50%);
}

/* ===== できあがった漫画 ===== */
.result-head { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.result-head input { font-family: var(--font-display); font-size: 1.2rem; box-shadow: 4px 4px 0 var(--ink); }
.result-head .btn-sub { white-space: nowrap; }

/* ページが 1 枚だけのときは中央に、複数なら並べる */
.preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); justify-items: center; gap: 24px; }
.preview-card {
  width: 100%;
  max-width: 520px;
  background: var(--paper);
  border: var(--line);
  box-shadow: 5px 5px 0 var(--ink);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.preview-top { display: flex; justify-content: space-between; align-items: baseline; }
.preview-page { font-family: var(--font-display); font-size: 1.05rem; }
.preview-panels { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.preview-label { font-weight: 700; font-size: 0.85rem; color: var(--red); }
.preview-note { font-size: 0.875rem; color: var(--muted); line-height: 1.6; }

/* 生成前の漫画ページ風の枠（以前の形式の作品用） */
.manga-page { aspect-ratio: 2 / 3; display: grid; gap: 5px; padding: 7px; background: var(--paper); border: var(--line); }
.manga-page[data-panels="1"] { grid-template: 1fr / 1fr; }
.manga-page[data-panels="2"] { grid-template: 1fr 1fr / 1fr; }
.manga-page[data-panels="4"] { grid-template: repeat(4, 1fr) / 1fr; }
.manga-page[data-panels="6"] { grid-template: repeat(3, 1fr) / 1fr 1fr; }
.koma {
  border: 2px solid var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(#cfcfcf 1.2px, transparent 1.5px);
  background-size: 8px 8px;
}

.page-canvas { width: 100%; height: auto; border: 2px solid var(--ink); touch-action: none; }
.preview-card.loading .page-canvas { opacity: 0.35; }

.card-section { border-top: 2px dashed #bbb; padding-top: 12px; }
.card-section .label { font-size: 0.875rem; margin-bottom: 8px; }
.card-section summary { padding: 10px 0; font-weight: 700; font-size: 0.9rem; cursor: pointer; }
.card-section[open] summary { margin-bottom: 8px; }
.bubble-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-bottom: 6px; }
.bubble-row textarea { min-height: 44px; padding: 8px 12px; font-size: 15px; border-radius: 18px; }
.bubble-row.selected textarea { box-shadow: 0 0 0 4px var(--yellow); }
.card-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.card-buttons .btn-sub { flex: 1; min-width: 0; }
.revise-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 8px; }
.revise-row input { padding: 8px 10px; font-size: 15px; }

.export-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 24px 0;
  padding: 12px 16px;
  border: 2px solid var(--ink);
  background: var(--yellow);
}
.export-bar .label { margin: 0 8px 0 0; }
.export-bar .label::before { color: var(--ink); }

/* 台本（ネーム） */
.name-details summary { padding: 10px 0; font-family: var(--font-display); cursor: pointer; }
.name-details[open] summary { margin-bottom: 8px; }
.name-details .btn { margin-top: 24px; }
.name-editor { margin-top: 16px; display: grid; gap: 16px; }
.empty { margin: 0; color: var(--muted); font-size: 0.95rem; }
/* 一覧が空のとき：グリッドの 1 マスに押し込めず、横いっぱいの案内にする */
.char-list > .empty,
.works-grid > .empty { grid-column: 1 / -1; padding: 32px 16px; border: 2px dashed var(--ink); background: #fffef5; text-align: center; }
.name-page { border: var(--line); padding: 14px; background: var(--paper); }
.name-page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.name-page-head h4 {
  margin: 0;
  padding: 0 12px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.9rem;
}
.name-page-head select { width: auto; max-width: 100%; padding: 6px 10px; font-size: 14px; }
.name-panel { display: grid; grid-template-columns: 60px 1fr; gap: 8px 12px; padding: 12px 0; border-top: 2px dashed #bbb; }
.name-panel-no { font-family: var(--font-display); font-size: 0.85rem; padding-top: 10px; }
.name-panel textarea { min-height: 64px; font-size: 15px; }
.dialogue-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; margin-top: 8px; }
.dialogue-row input { padding: 8px 10px; font-size: 15px; }
.dialogue-row input:nth-child(2) { border-radius: 16px; } /* セリフ欄は吹き出しっぽく */
.add-dialogue { margin-top: 8px; }

/* ===== キャラ帳 ===== */
.char-editor { margin: 24px 0 0; padding: 24px; border: 2px dashed var(--ink); background: #fffef5; }
.char-editor .btn { margin-top: 8px; }
.char-editor #char-close { display: block; margin: 8px auto 0; }
.person-photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 420px; }
.person-photo { position: relative; aspect-ratio: 1; }
.person-photo img { width: 100%; height: 100%; object-fit: cover; border: 2px solid var(--ink); display: block; }
.photo-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 30px;
  height: 30px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.photo-remove:hover { background: var(--red); color: var(--paper); }
.photo-add {
  aspect-ratio: 1;
  border: 2px dashed var(--ink);
  background: #fffbe0;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: pre-line;
  cursor: pointer;
}
.photo-add:hover { background: var(--yellow); }
.consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  background: var(--yellow);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.consent input { flex: none; width: 20px; height: 20px; margin-top: 3px; accent-color: var(--ink); }
.char-preview { margin: 0 0 16px; border: var(--line); background: var(--paper); }
.char-preview img { display: block; width: 100%; }
.features { margin: 0 0 16px; padding: 2px 12px; border: 2px dashed var(--ink); background: var(--paper); font-size: 0.875rem; }
.features summary { padding: 10px 0; font-weight: 700; cursor: pointer; }
.features[open] { padding-bottom: 12px; }
.features p { margin: 8px 0 0; white-space: pre-wrap; color: var(--muted); }
#char-revise { margin-top: 16px; }

.char-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 24px; margin-top: 24px; }
.char-card { border: var(--line); background: var(--paper); box-shadow: 4px 4px 0 var(--ink); display: flex; flex-direction: column; }
.char-card img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-bottom: var(--line); }
.char-card-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.char-card-body strong { font-family: var(--font-display); font-weight: 400; font-size: 1.05rem; }
.char-card-body .desc-text {
  font-size: 0.85rem;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.char-card-body .card-buttons { margin-top: auto; }

/* ===== 作品 ===== */
.works-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 24px; }
.work-card { border: var(--line); background: var(--paper); box-shadow: 4px 4px 0 var(--ink); display: flex; flex-direction: column; }
.work-card.current { box-shadow: 4px 4px 0 var(--red); }
.work-thumb { aspect-ratio: 2 / 3; border-bottom: var(--line); background: #f1f1f1; display: grid; place-items: center; overflow: hidden; }
.work-thumb canvas,
.work-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.work-thumb span { color: #767676; font-weight: 700; font-size: 0.85rem; }
.work-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 4px; }
.work-body strong { font-family: var(--font-display); font-weight: 400; overflow-wrap: anywhere; }
.work-body small { color: var(--muted); }
.work-body .card-buttons { margin-top: 8px; }
.work-body .card-buttons .btn-sub { padding: 8px 6px; white-space: nowrap; } /* 細いカードでもボタンの文字を折り返さない */

/* ===== フッター ===== */
.app-footer { padding: 24px 0; background: var(--ink); color: #ddd; font-size: 0.85rem; text-align: center; border-top: 5px solid var(--red); }

/* ===== チュートリアル ===== */
.tour { position: fixed; inset: 0; z-index: 100; }
.tour-backdrop { position: absolute; inset: 0; }
.tour.center .tour-backdrop { background: rgba(0, 0, 0, 0.7); }
.tour-spot {
  position: fixed;
  border: 4px solid var(--yellow);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  transition: top 0.25s, left 0.25s, width 0.25s, height 0.25s;
}
.tour.center .tour-spot { display: none; }
.tour-card {
  position: fixed;
  left: 50%;
  bottom: 24px;
  width: min(460px, calc(100% - 32px));
  transform: translateX(-50%);
  background: var(--paper);
  border: var(--line);
  border-radius: 24px;
  box-shadow: 8px 8px 0 var(--ink);
  padding: 22px 24px 18px;
}
.tour.center .tour-card { top: 50%; bottom: auto; transform: translate(-50%, -50%); }
.tour.card-top .tour-card { top: 16px; bottom: auto; }
.tour-badge {
  display: inline-block;
  margin-bottom: 8px;
  padding: 2px 12px;
  background: var(--red);
  color: var(--paper);
  border: 2px solid var(--ink);
  font-family: var(--font-display);
  font-size: 0.75rem;
  transform: skewX(-10deg);
}
.tour-card h2 { margin: 0 0 8px; font-family: var(--font-display); font-weight: 400; font-size: 1.35rem; line-height: 1.4; }
.tour-text { margin: 0 0 14px; font-size: 0.95rem; white-space: pre-line; }
.tour-dots { display: flex; gap: 6px; margin-bottom: 14px; }
.tour-dots span { width: 10px; height: 10px; border: 2px solid var(--ink); border-radius: 50%; }
.tour-dots span.on { background: var(--ink); }
.tour-check { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 700; margin-bottom: 14px; }
.tour-check input { width: 18px; height: 18px; accent-color: var(--ink); }
.tour-buttons { display: flex; align-items: center; gap: 8px; }
.tour-buttons .spacer { flex: 1; }
.tour-buttons .btn { width: auto; min-height: 44px; padding: 0 22px; font-size: 1rem; }

/* ===== PDF 保存（印刷） ===== */
#print-area { display: none; }
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  #print-area img { display: block; width: 100%; height: 277mm; object-fit: contain; break-after: page; }
}

/* ===== スマホ ===== */
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); } /* 下に固定したタブバーで、フッターが隠れないように */
  main { padding: 24px 16px 40px; }
  .header-inner { min-height: 56px; }
  .logo { gap: 8px; min-width: 0; }
  .logo h1 { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .logo-mark { width: 30px; height: 30px; font-size: 0.95rem; }
  /* 狭い画面では「？」だけにして、ロゴを省略せずに表示する */
  .btn-help { width: 44px; min-height: 44px; padding: 0; font-size: 1rem; }
  .help-label { display: none; }
  .save-status { display: none; }

  /* タブは画面下に固定 */
  .tabbar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    gap: 0;
    padding: 0 0 env(safe-area-inset-bottom);
    border-bottom: none;
    border-top: 4px solid var(--red);
  }
  .tabbar button {
    flex: 1;
    flex-direction: column;
    gap: 0;
    padding: 8px 0 6px;
    border: none;
    font-size: 0.8rem;
  }
  .tab-icon { font-size: 1.2rem; line-height: 1.2; }

  .panel { padding: 24px 16px; margin-bottom: 24px; box-shadow: 4px 4px 0 var(--ink); }
  .big-title { font-size: 1.35rem; }
  .char-editor { padding: 16px; }
  .preview-grid { grid-template-columns: 1fr; }
  .result-head { flex-wrap: wrap; }
  .name-panel { grid-template-columns: 1fr; }
  .name-panel-no { padding-top: 0; }
  .dialogue-row { grid-template-columns: 84px 1fr auto; }
  .export-bar .btn-sub { flex: 1 1 100%; }
  .works-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .work-body { padding: 10px 10px 12px; }
  .char-list { grid-template-columns: 1fr; }
  .tour-card { bottom: 84px; padding: 18px 18px 14px; }
  .tour-card h2 { font-size: 1.15rem; }
}
