/* ますくやさん Web版 — 段階2の最小スタイル。
   段階6でテーマ（Default/Dark/Cute）に拡張。段階14でご意見箱モーダルの部品を追加。 */

:root {
  --bg: #f5f5f5;
  --bar-bg: #ffffff;
  --border: #d0d0d0;
  --text: #222222;
  --muted: #888888;
  --accent: #4a90d9;
  --danger: #d9534f;
  --stage-bg: #808080; /* キャンバス背景の既定グレー（デスクトップ版に合わせる） */
  --btn-bg: #ffffff;
  --btn-hover: #eef4fb;
  --font: "Segoe UI", "Yu Gothic UI", sans-serif;
}

/* ダークテーマ */
[data-theme="dark"] {
  --bg: #1f1f22;
  --bar-bg: #2a2a2e;
  --border: #45454c;
  --text: #e9e9ec;
  --muted: #9a9aa2;
  --accent: #5a9be0;
  --danger: #e2706b;
  --stage-bg: #2b2b30;
  --btn-bg: #34343a;
  --btn-hover: #3e3e46;
}

/* かわいいテーマ（丸ゴシック＋ピンク系） */
[data-theme="cute"] {
  --bg: #fff2f7;
  --bar-bg: #ffffff;
  --border: #ffc6dc;
  --text: #6b4453;
  --muted: #c789a0;
  --accent: #ff86b3;
  --danger: #f0617f;
  --stage-bg: #f3c9d9;
  --btn-bg: #ffffff;
  --btn-hover: #ffe6f0;
  --font: "Rounded Mplus 1c", "Segoe UI", "Yu Gothic UI", sans-serif;
}

/* かわいいテーマ用フォント（M PLUS Rounded 1c・OFL）。assets/fonts に同梱。 */
@font-face {
  font-family: "Rounded Mplus 1c";
  src: url("../assets/fonts/MPLUSRounded1c-Medium.ttf") format("truetype");
  font-weight: 400 600;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  /* UI操作のタップ遅延（300ms）を消す。アクセシビリティ用ズームは残す。 */
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* 上部バー */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 12px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.bar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-title {
  font-size: 17px;
  font-weight: 700;                 /* ロゴは少し目立たせる（Bold＋アクセント色） */
  letter-spacing: 0.04em;
  color: var(--accent);
  text-decoration: none;
}
.app-title:hover { color: var(--accent); }

/* ボタン内アイコン（アイコン＋文字ボタン用の整列） */
.btn .btn-ic { vertical-align: -3px; margin-right: 5px; }

.zoom-group { margin-left: auto; position: relative; }

/* 拡大縮小：虫眼鏡アイコンを押すと出るポップオーバー（スライダー＋−＋＋フィット）。 */
.zoom-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bar-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  z-index: 60;
  white-space: nowrap;
}
.zoom-pop[hidden] { display: none; }
.zoom-pop input[type="range"] { width: 130px; }

/* ボタン共通 */
.btn {
  font: inherit;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--btn-hover); border-color: var(--accent); }
.btn:disabled { color: var(--muted); cursor: default; opacity: 0.6; }
.btn.icon { width: 34px; padding: 5px 0; text-align: center; }
.btn.icon.mini { width: 28px; font-size: 14px; }
.btn.danger { color: var(--danger); border-color: #e6b8b6; }
.btn.danger:hover:not(:disabled) { background: #fdecea; border-color: var(--danger); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent); opacity: 0.9; }
.btn.mini-text { padding: 3px 8px; font-size: 13px; }
.zoom-label { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }

/* トグル（道具のブラシ/消しゴム） */
.btn.toggle.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.toggle.active:hover { background: var(--accent); }

/* レイアウト：左パネル＋ステージ */
.layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.panel {
  flex: 0 0 var(--panel-w, 248px);   /* 幅は掴みバーのドラッグで調整（--panel-w）。カード化の余白ぶん広め */
  background: var(--bar-bg);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
}

/* パネル右端の掴みバー（PC・ドッキング時のみ）。ドラッグで幅を調整。 */
.panel-resizer {
  flex: 0 0 6px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 10;
}
.panel-resizer::before {
  content: "";
  position: absolute; top: 0; bottom: 0; left: 2px;
  width: 2px; background: var(--border);
}
.panel-resizer:hover::before, body.resizing .panel-resizer::before { background: var(--accent); }
body.resizing { cursor: col-resize; user-select: none; }
.panel-hint { color: var(--muted); font-size: 13px; line-height: 1.6; margin-top: 16px; }

/* パネル内のグループ */
.group { margin-bottom: 18px; }
/* 左パネルはカード式（枠で区切って構造を見やすく）。道具/自動マスク/設定/描き方/表示 の各まとまり。 */
.panel .group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.panel .group .group-title { margin-top: 0; }
/* 自動マスクカード内の余白（単体スタイルの外側マージンを打ち消す） */
.auto-group .detect-mode { margin: 0; }
.auto-group .automask-btn { margin: 10px 0 0; }
.auto-group .automask-batch-btn { margin: 8px 0 0; }
.group-title {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
}
.tool-row { display: flex; gap: 6px; }
.tool-row .btn { flex: 1; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.heart-btn { width: 100%; margin-bottom: 6px; }
.heart-btn.active { background: #ff5fa2; border-color: #ff5fa2; color: #fff; }
/* 消しゴム（上部バーのアイコンボタン）：SVGを中央に。トグルの active は .btn.toggle.active で白く。 */
#tool-eraser { display: inline-flex; align-items: center; justify-content: center; }
#tool-eraser svg { display: block; }

/* 自動マスキング：道具の直下に置く主役ボタン。やや目立たせる（アクセント色・太字・少し大きめ）。 */
.automask-btn {
  width: 100%;
  margin: 4px 0 18px;
  padding: 11px 12px;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  border-radius: 10px;
}
.automask-btn:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.automask-btn:disabled { opacity: 0.5; }
/* 一括ボタン：単体ボタンのすぐ下に寄せ、枠線タイプで「まとめて」を区別する。 */
.automask-batch-btn {
  width: 100%;
  margin: -12px 0 18px;
  padding: 9px 12px;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
}
.automask-batch-btn:hover:not(:disabled) { background: rgba(127, 127, 127, 0.12); }
.automask-batch-btn:disabled { opacity: 0.5; }
.automask-batch-btn[hidden] { display: none; }
/* 検出モード（イラスト用／実写用）のトグル。AUTOボタンの上に置く。 */
.detect-mode { margin: 4px 0 8px; }
.detect-mode-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.detect-mode-toggle { display: flex; gap: 6px; }
.detect-mode-toggle .btn { flex: 1 1 0; font-size: 13px; }

/* 自動マスクボタン内の補足ラベル（(表示中画像のみ) / (全画像・zip保存)）。 */
.automask-sub { font-weight: 600; font-size: 0.82em; opacity: 0.92; }

/* 一括処理の進捗パネル（ステータス下・中央）。処理中／完了で内容が変わる。 */
.batch-panel {
  position: absolute;
  top: 46px; left: 50%; transform: translateX(-50%);
  z-index: 22;
  width: min(420px, 86%);
  padding: 14px 16px;
  background: rgba(20, 16, 20, 0.88);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.batch-panel[hidden] { display: none; }
.stage.has-strip .batch-panel { top: 110px; } /* 帯が出ている時は帯の下へ */
.batch-text { font-size: 13.5px; font-weight: 700; line-height: 1.55; text-align: center; white-space: pre-line; }
.batch-remain { font-size: 12.5px; line-height: 1.5; text-align: center; color: rgba(255, 255, 255, 0.82); margin: 2px 0 10px; }
.batch-remain:empty { display: none; }
.batch-bar { height: 8px; background: rgba(255, 255, 255, 0.18); border-radius: 999px; overflow: hidden; }
.batch-bar-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width 0.25s ease; }
.batch-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.batch-actions .btn {
  font-size: 13px; color: #fff;
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.32);
}
.batch-actions .btn.primary { background: var(--accent); border-color: var(--accent); }
.batch-actions .btn:hover { filter: brightness(1.12); }
.batch-actions .btn[hidden] { display: none; }
.slider-label { display: block; font-size: 13px; margin-bottom: 6px; }

/* 表示：カラーテーマ */
.theme-field { margin-bottom: 12px; }
.theme-field select { width: 100%; }

/* 表示：背景色の行 */
.bg-row { display: flex; align-items: center; gap: 8px; }
.bg-row label { font-size: 13px; }
.bg-row input[type="color"] {
  width: 40px; height: 28px; padding: 0;
  border: 1px solid var(--border); border-radius: 6px;
  background: none; cursor: pointer;
}
.panel-hint.sub { margin-top: 8px; font-size: 12px; }
.slider-row { display: flex; align-items: center; gap: 6px; }
.slider-row input[type="range"] { flex: 1; min-width: 0; }
.tool-option[hidden] { display: none; }
.guide-note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.guide-note.warn { color: var(--danger); font-weight: 600; }

/* キャンバス領域 */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  background: var(--stage-bg);
  overflow: hidden;
  /* 指の操作（描画・パン・ピンチ）を自前で扱うため、ブラウザ標準のスクロール/ズームを無効化。 */
  touch-action: none;
}
#canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.stage.dragover { outline: 3px dashed var(--accent); outline-offset: -6px; }

/* ドロップ案内（画像未読込のとき表示） */
.drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: #fff;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  font-size: 18px;
  line-height: 1.6;
}
.stage.has-image .drop-hint { display: none; }

/* 加工サーバーの状態表示（送信中・エラー） */
.status-toast {
  position: absolute;
  left: 50%;
  top: 18px;             /* スマホでブラウザ下部が見切れるため上に表示 */
  transform: translateX(-50%);
  max-width: 80%;
  padding: 8px 16px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 14px;
  pointer-events: none;
  box-sizing: border-box;
  white-space: normal;          /* 長い文言は折り返す（はみ出し・見切れ防止） */
  overflow-wrap: anywhere;      /* 日本語・URL等も箱の中で折り返す */
  text-align: center;
  line-height: 1.5;
}
.status-toast.error { background: rgba(180, 40, 40, 0.9); }

/* 処理中（自動マスク）：スピナー付きで「動いている」ことを示す。
   ※検出AIはメインスレッドを止めるため回転が一瞬固まることはあるが、処理中である表示は残る。 */
.status-toast.busy { background: rgba(20, 20, 20, 0.88); padding-left: 40px; }
.status-toast.busy::before {
  content: "";
  position: absolute;
  left: 15px; top: 50%; margin-top: -8px;
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: toast-spin 0.8s linear infinite;
}
@keyframes toast-spin { to { transform: rotate(360deg); } }

/* 一括処理：画像の帯（サムネ＋前後ナビ＋カウンタ）。stage 上部にオーバーレイ。 */
.filmstrip {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 78px;
  display: grid;                                    /* ◀ | サムネ(可変) | ▶ | カウンタ */
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.55);
  z-index: 8;
  box-sizing: border-box;
}
.filmstrip[hidden] { display: none; }
/* 帯が出ている間はステータス表示を帯の下へ（隠れないように）。 */
.stage.has-strip .status-toast { top: 88px; }
.film-thumbs {
  flex: 1 1 0;           /* basis 0＋min-width:0 で残り幅に収め、内部で横スクロール */
  min-width: 0;          /* これが無いと帯が伸びて ▶/カウンタが画面外へ押し出される */
  display: flex;
  gap: 6px;
  height: 100%;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.film-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 62px; height: 62px;
  padding: 0; margin: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  background: #222;
  cursor: pointer;
  overflow: hidden;
}
.film-thumb img, .film-thumb canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.film-thumb.current { border-color: var(--accent); }
.film-thumb.saved { opacity: 0.85; }
.film-thumb .film-check {
  position: absolute; top: 2px; right: 2px;
  display: none;
  background: rgba(40, 160, 70, 0.95); color: #fff;
  font-size: 11px; line-height: 1; padding: 2px 4px; border-radius: 8px;
}
.film-thumb.saved .film-check { display: block; }
/* ◀▶：暗い帯の上で見やすいよう、白文字＋半透明の明るいボタンに（既定の .btn 配色を上書き）。 */
.film-nav {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.film-nav:hover:not(:disabled) { background: rgba(255, 255, 255, 0.3); }
.film-nav:disabled { opacity: 0.35; }
.film-counter { color: #fff; font-size: 13px; min-width: 46px; text-align: center; }

/* ブラシ円カーソル（マウス追従。クリックは透過） */
.brush-cursor {
  position: absolute;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 5;
}
.brush-cursor[hidden] { display: none; }

/* モーダル（ヘルプ／注意） */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--bar-bg);
  color: var(--text);
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 8px 18px 20px; line-height: 1.7; }
.modal-body h3 { font-size: 15px; margin: 18px 0 6px; color: var(--accent); }
.modal-body ul { margin: 6px 0; padding-left: 1.2em; }
.modal-body li { margin: 3px 0; }
.modal-body .muted { color: var(--muted); font-size: 13px; }

/* 同意ゲートは最前面（他のモーダルより上） */
.modal-backdrop.consent { z-index: 300; }

/* 確認ダイアログのボタン列 */
.modal.confirm { width: min(420px, 92vw); }
.confirm-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.confirm-actions .btn { width: 100%; padding: 9px 12px; }

/* ご意見箱（feedback.js が生成するモーダルの中身） */
.feedback-text {
  width: 100%; box-sizing: border-box; resize: vertical; margin: 8px 0;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font: inherit;
}
.feedback-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.feedback-err { margin-top: 4px; }

/* 画像未読み込み時のキャンバスはクリックで開けるので、それが分かるカーソルに。 */
.stage:not(.has-image) { cursor: pointer; }

/* ===== レスポンシブ（適応型）：レイアウトは画面幅で決める ===== */
/* 道具パネルの開閉トグルと背景は、広い画面では出さない。 */
.btn-panel { display: none; }
.panel-backdrop { display: none; }
/* 開くボタンのラベル：広い画面＝長い表記／狭い画面＝「開く」 */
.label-short { display: none; }
/* AUTOボタンの短い補足（(1枚)/(全部)）はスマホ下部バー内でだけ表示 */
.automask-sub-s { display: none; }
/* スマホ用の下部アクションバー・2段目（広い画面では出さない） */
.mobile-bar { display: none; }
.mobile-row2 { display: none; }

@media (max-width: 760px) {
  /* 上部バー1段目（ロゴ＋開く＋閉じる＋↶↷＋?）。消しゴム/クリア/保存は2段目へ移設される。 */
  .topbar { flex-wrap: nowrap; gap: 6px; padding: 6px 8px; }
  .topbar .btn { padding: 7px 8px; font-size: 13px; white-space: nowrap; }
  .label-long { display: none; }
  .label-short { display: inline; }
  .zoom-group { display: none; }         /* ズームはピンチ操作で代替（ボタン省略） */
  .topbar .bar-group:empty { display: none; } /* ボタンが移設された後の空グループを畳む */
  .brand-group { flex-direction: row; align-items: center; gap: 6px; }
  .app-title { font-size: 14px; padding: 4px 10px; white-space: nowrap; }
  .btn { white-space: nowrap; }          /* ボタン内で文字を縦折れさせない */

  /* 2段目：☰ツール／すべてクリア／消しゴム（＋右端に保存）。 */
  .mobile-row2 {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding: 6px 10px;
    background: var(--bar-bg);
    border-bottom: 1px solid var(--border);
  }
  .mobile-row2[hidden] { display: none; }
  .mobile-row2 #btn-save { margin-left: auto; } /* 保存は右端（主要導線・アクセント色のまま） */

  /* 下部アクションバー：自動マスキング（親指ゾーン）＝[イラスト用/実写用][AUTO(1枚)][AUTO(全部)]。 */
  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 120;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    background: var(--bar-bg);
    border-top: 1px solid var(--border);
  }
  .mobile-bar[hidden] { display: none; }
  .mobile-bar-label {
    flex: 0 0 auto;
    font-size: 10.5px;
    line-height: 1.25;
    font-weight: 700;
    color: var(--muted);
    text-align: center;
  }
  .mobile-bar .detect-mode-toggle { display: flex; gap: 4px; flex: 0 1 auto; }
  .mobile-bar .detect-mode-toggle .btn { font-size: 12px; padding: 8px 8px; }
  .mobile-bar .mode-suffix { display: none; }  /* [イラスト][実写] 表記（「用」省略） */
  .mobile-bar .automask-btn,
  .mobile-bar .automask-batch-btn { width: auto; margin: 0; padding: 8px 10px; font-size: 13px; border-radius: 10px; }
  .mobile-bar .automask-sub { display: none; }     /* 長い補足は隠し… */
  .mobile-bar .automask-sub-s { display: inline; } /* …(1枚)/(全部) の短い表記に切替 */

  /* 自動マスク系は下部バーへ移設されるので、パネル内の空カードは畳む */
  .auto-group { display: none; }
  /* 下部バーの高さぶんキャンバス領域を上げる（バーに隠れないように） */
  .layout { padding-bottom: calc(52px + env(safe-area-inset-bottom)); }

  .btn-panel {
    display: inline-flex; align-items: center; gap: 6px;
    font-weight: 700; color: #fff;
    background: var(--accent); border-color: var(--accent);
  }
  .btn-panel:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
  .panel-resizer { display: none; } /* ドロワー時は幅調整バーを出さない */
  .panel {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 264px; max-width: 82vw;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.28);
  }
  .panel.open { transform: translateX(0); }

  /* ドロワーを開いた時の背景（タップで閉じる）。 */
  .panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 150;
  }
  .panel-backdrop[hidden] { display: none; }
}

/* =====================================================================
   サイト（TOP / ギャラリー）— ツールとは別の、スクロールする通常ページ。
   配色トークン（--accent 等・テーマ）は共有、レイアウトはページ個別。
   ===================================================================== */
body.site {
  display: block;
  height: auto;
  min-height: 100vh;
  overflow: auto;
}

/* サイト共通の軽いヘッダー（ツールバーではない） */
.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--border);
}
.site-logo { font-size: 18px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: 0.04em; }
.site-nav { display: flex; gap: 14px; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.site-nav a:hover { color: var(--accent); }

/* ---- TOP（ランディング） ---- */
.landing { max-width: 940px; margin: 0 auto; padding: 28px 20px 48px; }
.hero { text-align: center; padding: 28px 8px 12px; }
.hero-title { font-size: 30px; margin: 0 0 14px; line-height: 1.35; }
.hero-lead { color: var(--text); font-size: 15px; line-height: 1.9; margin: 0 0 22px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.cta {
  display: inline-block; padding: 12px 22px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--btn-bg); color: var(--text);
  text-decoration: none; font-weight: 700;
}
.cta:hover { border-color: var(--accent); background: var(--btn-hover); }
.cta.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.cta.primary:hover { filter: brightness(1.08); background: var(--accent); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 34px; }
.card {
  display: block; padding: 22px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--bar-bg); color: var(--text);
  text-decoration: none; transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 8px 22px rgba(0,0,0,0.08); }
.card-emoji { font-size: 30px; }
.card h2 { font-size: 18px; margin: 10px 0 8px; }
.card p { color: var(--muted); font-size: 14px; line-height: 1.75; margin: 0 0 12px; }
.card-go { color: var(--accent); font-weight: 700; font-size: 14px; }

.site-note { color: var(--muted); font-size: 13px; line-height: 1.8; text-align: center; margin-top: 34px; }
.site-foot { text-align: center; color: var(--muted); font-size: 12px; padding: 22px; border-top: 1px solid var(--border); }

/* ---- ギャラリー ---- */
.gallery { max-width: 1040px; margin: 0 auto; padding: 24px 20px 48px; }
.gallery-title { font-size: 24px; margin: 6px 0 8px; }
.gallery-lead { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.g-item { margin: 0; }
.g-thumb {
  width: 100%; aspect-ratio: 1 / 1; border-radius: 12px; object-fit: cover; display: block;
  background: var(--btn-hover); border: 1px solid var(--border);
}
.g-placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; border-style: dashed;
}
.g-item figcaption { margin-top: 8px; font-size: 13px; color: var(--muted); text-align: center; }

@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
  .hero-title { font-size: 24px; }
  /* スマホ：ギャラリーは小さめサムネを多く並べて一覧性を上げる（クリックで拡大は従来どおり）。 */
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .g-item figcaption { font-size: 11px; margin-top: 4px; }
}

/* コラム記事ページ（mosaic-guide.html 等） */
.article { max-width: 720px; margin: 0 auto; padding: 24px 20px 48px; line-height: 1.9; }
.article h1 { font-size: 26px; line-height: 1.5; margin: 8px 0 4px; }
.article-sub { font-size: 17px; color: var(--muted); font-weight: normal; }
.article-date { color: var(--muted); font-size: 12.5px; margin-bottom: 20px; }
.article h2 { font-size: 19px; margin: 32px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.article ul { padding-left: 1.4em; }
.article li { margin: 6px 0; }
.article a { color: var(--accent); }
.article-caution {
  border-left: 3px solid var(--accent);
  background: rgba(127, 127, 127, 0.07);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--muted);
}
.article-cta { text-align: center; margin: 28px 0; }
/* TOPのコラムへのテキストリンク */
.column-link { text-align: center; margin-top: 18px; font-size: 14px; }
.column-link a { color: var(--accent); }

/* ロゴを「TOPへのリンク」と分かるよう少し目立つボタンに（全ページ共通・Bold＋アクセント枠） */
.logo-btn {
  display: inline-block;
  padding: 5px 12px;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  background: var(--btn-bg);
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  line-height: 1.2;
}
.logo-btn:hover { border-color: var(--accent); background: var(--btn-hover); color: var(--accent); }

/* TOP：入口セクション（大ボタン＋注意書き） */
.entry { text-align: center; margin-top: 30px; }
.cta.big { padding: 15px 34px; font-size: 17px; border-radius: 14px; }
.entry-note { margin: 14px auto 30px; max-width: 580px; }
.entry-note .feature { font-weight: 700; color: var(--text); margin: 0 0 8px; font-size: 15px; }
.entry-note .fine { color: var(--muted); font-size: 12.5px; line-height: 1.7; margin: 4px 0; }
.entry-note.prep { color: var(--accent); font-weight: 700; margin-top: 8px; }
.r18 { color: var(--accent); font-weight: 700; }

/* ---- ギャラリー：サムネはボタン（クリックで拡大） ---- */
.g-thumb-btn {
  display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer;
  border-radius: 12px;
}
.g-thumb-btn:hover .g-thumb { border-color: var(--accent); }

/* ---- ギャラリー1階層目：カテゴリ一覧（重ね写真風サムネ＋名前＋枚数） ---- */
.cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 22px;
}
.cat-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 10px 16px; border: 0; background: none; cursor: pointer;
  border-radius: 14px; transition: transform 0.15s ease;
}
.cat-card:hover { transform: translateY(-3px); }
/* 重ね写真：最大3枚を少しずつ回転・オフセットして重ねる。1〜2枚でも成立するよう正方形の箱を確保。 */
.cat-stack {
  position: relative; width: 100%; aspect-ratio: 1 / 1; margin-bottom: 4px;
}
.cat-stack-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--border); background: var(--btn-hover);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
}
.cat-stack-img-0 { z-index: 3; transform: rotate(0deg); }
.cat-stack-img-1 { z-index: 2; transform: rotate(-6deg) translate(-6%, 3%); }
.cat-stack-img-2 { z-index: 1; transform: rotate(6deg) translate(6%, 4%); }
.cat-card:hover .cat-stack-img-0 { transform: rotate(-2deg) translate(-1%, -2%); }
.cat-card:hover .cat-stack-img-1 { transform: rotate(-9deg) translate(-8%, 4%); }
.cat-card:hover .cat-stack-img-2 { transform: rotate(9deg) translate(8%, 5%); }
.cat-name { font-weight: 700; font-size: 15px; color: var(--text); }
.cat-count { font-size: 12px; color: var(--muted); }

@media (max-width: 640px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .cat-name { font-size: 13px; }
}

/* ---- ギャラリー2階層目：カテゴリ一覧へ戻る導線 ---- */
.cat-back-row { margin: 0 0 6px; }
.cat-back { color: var(--accent); font-size: 14px; text-decoration: none; }
.cat-back:hover { text-decoration: underline; }

/* ---- 年齢認証ゲート（R18・OKまで本文非表示） ---- */
.age-gate {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55); padding: 20px;
}
.age-gate[hidden] { display: none; }
.age-box {
  background: var(--bar-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 26px 24px; max-width: 420px; width: 100%; text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}
.age-box h2 { margin: 0 0 10px; font-size: 20px; }
.age-note { color: var(--muted); font-size: 13px; margin: 0 0 18px; line-height: 1.7; }
.age-actions { display: flex; flex-direction: column; gap: 10px; }
.age-actions .cta { width: 100%; }

/* ---- 拡大表示（ライトボックス）：小さめのウィンドウ ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 320;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6); padding: 20px;
}
.lightbox[hidden] { display: none; }
.lightbox-inner {
  position: relative; background: var(--bar-bg); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; max-width: min(92vw, 640px); max-height: 88vh;
  overflow: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.lightbox-body img { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; border-radius: 8px; }
.lightbox-placeholder {
  width: min(80vw, 320px); height: min(80vw, 320px);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); border: 1px dashed var(--border); border-radius: 10px; background: var(--btn-hover);
}
.lightbox-cap { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; }
.lightbox-close {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px;
  border: 1px solid var(--border); border-radius: 50%; background: var(--btn-bg);
  color: var(--text); font-size: 18px; line-height: 1; cursor: pointer;
}
.lightbox-close:hover { border-color: var(--accent); background: var(--btn-hover); }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 1;
  width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 50%;
  background: var(--btn-bg); color: var(--text); font-size: 22px; line-height: 1; cursor: pointer;
}
.lightbox-nav:hover { border-color: var(--accent); background: var(--btn-hover); }
.lightbox-nav[hidden] { display: none; }
.lightbox-prev { left: 8px; }
.lightbox-next { right: 8px; }
@media (max-width: 640px) {
  .lightbox-nav { width: 34px; height: 34px; font-size: 18px; }
}
