/* アイキャッチプロンプトジェネレーター */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1b2330;
  --ink-sub: #5e6a7a;
  --line: #e1e5eb;
  --accent: #2f6df0;
  --accent-ink: #ffffff;
  --code-bg: #f3f5f8;
  --placeholder: #b3bbc6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 28px rgba(16, 24, 40, .07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d;
    --card: #1a1f29;
    --ink: #e9edf3;
    --ink-sub: #9aa5b5;
    --line: #2a313c;
    --accent: #75a2ff;
    --accent-ink: #0e131a;
    --code-bg: #10151c;
    --placeholder: #545f6d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

/* display を持つ要素にも hidden を効かせる（画面の切り替えで使う） */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.wrap { width: min(1560px, 100% - 28px); margin-inline: auto; }

/* ---------------------------------------------------------------- ヘッダー */

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.site-header h1 { margin: 0; font-size: 1.15rem; }
.lead { margin: 2px 0 0; color: var(--ink-sub); font-size: .85rem; }
.header-actions { display: flex; gap: 8px; }

.site-footer { padding: 14px 0 28px; color: var(--ink-sub); font-size: .78rem; }

/* ---------------------------------------------------------------- レイアウト */

.layout {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  padding: 12px 0;
  align-items: start;
}

@media (min-width: 1040px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(380px, 420px); }
  .col-out { position: sticky; top: 12px; }
}

.col-out { display: grid; gap: 12px; min-width: 0; }

/* 選択側は段組にして、カードの高さの違いで空きが出ないよう上に詰める */
.col-pick {
  min-width: 0;
  columns: 330px;
  column-gap: 12px;
}

.col-pick > .card {
  /* カードが段をまたいで分割されないようにする */
  break-inside: avoid;
  page-break-inside: avoid;
  margin-bottom: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px 12px;
}

.card h2,
.card > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  padding: 0;
  font-size: .86rem;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.card h2 { cursor: auto; margin-bottom: 8px; }
.card > summary::-webkit-details-marker { display: none; }

/* 開閉の向きを示す三角 */
.card > summary .ttl::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 6px;
  vertical-align: 1px;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  opacity: .45;
  transition: transform .12s;
}

details[open] > summary .ttl::before { transform: rotate(90deg); }
details[open] > summary { margin-bottom: 8px; }

.sel {
  font-size: .72rem;
  font-weight: 400;
  color: var(--ink-sub);
}

/* ------------------------------------------------------------ 選択カード */

.grid { display: grid; gap: 6px; }
.grid-sm { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.grid-size { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }

.pick {
  display: grid;
  gap: 1px;
  padding: 4px 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}

.pick:hover { border-color: var(--accent); }

.pick.is-on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1.5px var(--accent) inset;
}

.pick-label { font-size: .72rem; font-weight: 600; line-height: 1.3; margin-top: 3px; }
.pick-note { font-size: .64rem; color: var(--ink-sub); line-height: 1.3; }

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 5px;
  overflow: hidden;
  background: var(--code-bg);
}

/* テイスト見本の図形 */
.thumb .tp { position: absolute; display: block; }

.thumb .sw {
  position: absolute;
  bottom: 8%;
  width: 20%;
  height: 26%;
  border-radius: 3px;
}
.thumb .sw:nth-child(1) { left: 8%; }
.thumb .sw:nth-child(2) { left: 32%; }
.thumb .sw:nth-child(3) { left: 56%; }

.thumb-glyph {
  position: absolute;
  inset: 8%;
  display: flex;
  justify-content: center;
}
.thumb-glyph svg { height: 100%; width: 100%; }

.thumb-ratio {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--code-bg);
}

.ratio-box {
  display: block;
  border: 2px solid var(--ink-sub);
  border-radius: 3px;
  opacity: .7;
}

.pick.is-on .ratio-box { border-color: var(--accent); opacity: 1; }

/* チップ */

.chips { display: flex; flex-wrap: wrap; gap: 5px; }

.chip {
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: .76rem;
  cursor: pointer;
}

.chip:hover { border-color: var(--accent); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ------------------------------------------------------------- プレビュー */

.stage {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background:
    repeating-conic-gradient(var(--code-bg) 0 25%, transparent 0 50%) 0 0 / 16px 16px,
    var(--card);
  border: 1px solid var(--line);
  /* サイズを選び直しても箱の大きさは変えない */
  height: 320px;
}

.preview {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
}

.pv-box { position: absolute; }

.pv-subject { display: flex; align-items: flex-end; justify-content: center; border-radius: calc(var(--u) * .6); }
.pv-subject svg { height: 100%; width: auto; max-width: 100%; }

.pv-plate { border-radius: calc(var(--u) * .8); }
.pv-logo { border-radius: calc(var(--u) * .4); }

.pv-bar { display: flex; flex-direction: column; justify-content: center; gap: calc(var(--u) * .8); }
.pv-bar::before,
.pv-bar::after {
  content: "";
  display: block;
  height: var(--bar-h, 50%);
  border-radius: calc(var(--u) * .4);
  background: var(--bar);
}
.pv-bar::after { width: 68%; }

.pv-text {
  display: flex;
  align-items: center;
  overflow: hidden;
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: .01em;
}

.pv-t {
  display: block;
  width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
  line-break: strict;
}

/* どうしても入りきらないときだけ行数で切る */
.pv-t.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pv-head { font-size: calc(var(--u) * 6.2); }
.pv-sub { font-size: calc(var(--u) * 3); font-weight: 600; }
.pv-meta { font-size: calc(var(--u) * 2.2); font-weight: 500; }

.preview-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}



/* ------------------------------------------------------------------ 入力 */

.fields { display: grid; gap: 6px; }
.field label { display: block; font-size: .74rem; font-weight: 600; margin-bottom: 2px; }

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: .86rem;
}

input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.custom-size {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: .8rem;
}
.custom-size label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.custom-size input { width: 90px; }
.custom-size .unit, .custom-size .x { color: var(--ink-sub); }
.ratio-note { margin-left: auto; color: var(--ink-sub); }
.custom-size[hidden] { display: none; }

.checks { display: grid; gap: 2px; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: .78rem;
  line-height: 1.45;
  cursor: pointer;
  padding: 1px 0;
}
.check input { accent-color: var(--accent); margin-top: 4px; }
.check small { display: block; color: var(--ink-sub); font-size: .68rem; line-height: 1.35; }
.check-inline { align-items: center; }
.check-inline input { margin-top: 0; }



/* ------------------------------------------------------------------ 出力 */

.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.tabs .btn-copy { margin-left: auto; margin-bottom: 4px; }

.tab {
  padding: 6px 12px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-sub);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
}
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }



.prompt-box {
  margin: 0;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code-bg);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: .74rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow: auto;
}

/* ---------------------------------------------------------------- ボタン */

.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.btn {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn-sub { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-copy { padding: 5px 12px; font-size: .76rem; }

/* ------------------------------------------------------------------ 履歴 */

.history { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.history-empty { padding: 11px 13px; color: var(--ink-sub); font-size: .8rem; }
.history-item { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: none; }

.history-load {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 13px;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.history-load:hover { background: var(--code-bg); }
.history-label { font-size: .83rem; font-weight: 600; }
.history-note { font-size: .7rem; color: var(--ink-sub); }

.history-del {
  padding: 5px 11px;
  margin-right: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  color: var(--ink-sub);
  font: inherit;
  font-size: .73rem;
  cursor: pointer;
}
.history-del:hover { color: var(--ink); }

/* ---------------------------------------------------------------- トースト */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 8px);
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: .8rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------- カスタム配色 */

.palette-editor {
  margin-top: 10px;
  padding: 9px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code-bg);
}

.palette-editor[hidden] { display: none; }

.editor-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 7px; }
.editor-title { font-size: .74rem; font-weight: 700; }
.editor-hint { font-size: .66rem; color: var(--ink-sub); }

.color-rows { display: grid; gap: 5px; }

.color-row {
  display: grid;
  grid-template-columns: 4.6em 26px 6.4em minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.color-label { font-size: .72rem; font-weight: 600; }

.color-swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
.color-swatch::-webkit-color-swatch-wrapper { padding: 2px; }
.color-swatch::-webkit-color-swatch { border: none; border-radius: 4px; }

.color-hex,
.color-name {
  padding: 4px 7px;
  font-size: .74rem;
}
.color-hex { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.editor-import { margin-top: 9px; }
.import-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }

.import-chip {
  display: flex;
  padding: 2px;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
  cursor: pointer;
}
.import-chip:hover { border-color: var(--accent); }
.import-chip span { width: 9px; height: 16px; border-radius: 2px; }

/* テキストエリア */

textarea {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: .86rem;
  line-height: 1.5;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.field .hint { margin-left: .4em; font-weight: 400; color: var(--ink-sub); font-size: .66rem; }

/* ------------------------------------------------------------ 書体・出力 */

.sub-label {
  margin: 10px 0 4px;
  font-size: .7rem;
  font-weight: 700;
  color: var(--ink-sub);
}
.sub-label:first-of-type { margin-top: 0; }

.thumb-font {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--u) * 17);
  font-weight: 700;
  line-height: 1;
  letter-spacing: .02em;
  white-space: nowrap;
}

/* 出力データ（説明付きの単一選択） */

.opt-list { display: grid; gap: 4px; }

.opt {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .8rem;
  line-height: 1.45;
  cursor: pointer;
}

.opt:hover { border-color: var(--accent); }
.opt.is-on { border-color: var(--accent); box-shadow: 0 0 0 1.5px var(--accent) inset; }
.opt input { accent-color: var(--accent); margin-top: 4px; }
.opt small { display: block; color: var(--ink-sub); font-size: .68rem; line-height: 1.35; }

/* -------------------------------------------------------- バリエーション */

/* 見出しの「振る」ボタン */
.vary-toggle {
  margin-left: auto;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-sub);
  font: inherit;
  font-size: .68rem;
  font-weight: 600;
  cursor: pointer;
}
.vary-toggle:hover { border-color: var(--accent); color: var(--ink); }
.vary-toggle.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* 振り分け中のカード */
.pick.is-vary { opacity: .55; }
.pick.is-vary.is-picked { opacity: 1; border-color: var(--accent); }
.pick.is-vary.is-picked .thumb::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--card);
}

.chips.is-dim { opacity: .45; }
.chip:disabled { opacity: .35; cursor: not-allowed; }

.vary-summary { display: flex; flex-wrap: wrap; gap: 5px; }
.vary-empty { color: var(--ink-sub); font-size: .74rem; }

.vary-chip {
  padding: 3px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--accent);
}

.count-bar {
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--code-bg);
  font-size: .76rem;
}
.count-bar .is-over { color: #d64545; }

.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }

/* ------------------------------------------------------------- 比較ビュー */

body.is-compare { overflow: hidden; }

.compare {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.compare[hidden] { display: none; }

.compare-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.compare-title { display: flex; align-items: baseline; gap: 8px; font-size: .95rem; }
.compare-tabs { border-bottom: none; margin: 0; }
.compare-actions { display: flex; gap: 8px; margin-left: auto; }

.compare-body { flex: 1; overflow: auto; padding: 14px 16px 28px; }

.vgrid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.vcard {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.vcard-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.vcard-no { font-size: .72rem; font-weight: 700; color: var(--accent); }
.vcard-label { font-size: .72rem; color: var(--ink-sub); line-height: 1.35; }

.vcard-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  background:
    repeating-conic-gradient(var(--code-bg) 0 25%, transparent 0 50%) 0 0 / 14px 14px,
    var(--card);
}

.vcard-actions { display: flex; gap: 6px; padding: 8px 10px 0; }

.vcard-prompt {
  margin: 8px 10px 10px;
  padding: 8px 9px;
  border-radius: 6px;
  background: var(--code-bg);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: .66rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 150px;
  overflow: auto;
}



/* ------------------------------------------- 入力欄（例文と入力済みの差） */

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

/* 入力済みははっきり、未入力（例文表示中）は控えめに見せる */
input:not(:placeholder-shown),
textarea:not(:placeholder-shown) {
  color: var(--ink);
  font-weight: 600;
}

input:placeholder-shown,
textarea:placeholder-shown {
  font-weight: 400;
}

kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--card);
  font-family: inherit;
  font-size: .92em;
  line-height: 1.5;
}

/* 発想の切り口 */

.seed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
}

.seed-list li {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--code-bg);
  font-size: .76rem;
  line-height: 1.4;
}

.seed-no {
  flex: none;
  font-size: .68rem;
  font-weight: 700;
  color: var(--accent);
}

#seedArea[hidden], #axisArea[hidden] { display: none; }

/* ------------------------------------------------------------ 補足テキスト */

/*
 * 常に読ませたい補足。印は付けず、本文より一段落とした地味な文字で置く。
 * 一度読めば足りる説明は .tip のツールチップに寄せているので、ここには残さない。
 */
.caution,
.hint-line,
.preview-note,
.out-note {
  display: block;
  margin: 7px 0 0;
  padding: 0;
  background: none;
  border: 0;
  color: var(--ink-sub);
  font-size: .7rem;
  line-height: 1.65;
}

/* プレビュー下はチェックボックスと横並びなので、行に馴染ませる */
.preview-note { margin: 0; flex: 1 1 200px; }

/* プロンプトの見出し直下に付くものは詰める */
.out-note { margin: 0 0 6px; }

/* ------------------------------------------------- 必要なときだけ開く補足 */

.tip {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 5px;
}

.tip-btn {
  width: 14px;
  height: 14px;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: none;
  color: var(--ink-sub);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 9px;
  font-style: italic;
  font-weight: 700;
  line-height: 12px;
  text-align: center;
  cursor: help;
  opacity: .55;
}

.tip-btn:hover,
.tip-btn:focus-visible,
.tip.is-open .tip-btn {
  opacity: 1;
  color: var(--accent);
}

.tip-body {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  z-index: 30;
  width: max-content;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-size: .7rem;
  font-weight: 400;
  line-height: 1.65;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, -3px);
  transition: opacity .12s ease, transform .12s ease;
}

.tip-body::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-bottom-color: var(--ink);
}

.tip-btn:hover + .tip-body,
.tip-btn:focus-visible + .tip-body,
.tip.is-open .tip-body {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* 段組の中で吹き出しが切れないようにする */
.col-pick > .card:has(.tip.is-open) { overflow: visible; }

/* ============================================================ 作例一覧 */

/* ------------------------------------------------------- 画面の切り替え */

.views {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  margin-bottom: -13px;
}

.view-tab {
  appearance: none;
  border: 1px solid var(--line);
  border-bottom: none;
  background: transparent;
  color: var(--ink-sub);
  font: inherit;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
}

.view-tab:hover { color: var(--ink); }

.view-tab.is-active {
  background: var(--bg);
  border-color: var(--line);
  color: var(--accent);
  /* 下辺の線を背景色で隠して、タブが本文とつながって見えるようにする */
  box-shadow: 0 1px 0 0 var(--bg);
}

.view-count { color: var(--ink-sub); font-weight: 400; font-size: .8em; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------- 絞り込み */

.gallery { display: grid; gap: 12px; padding: 12px 0; align-items: start; }

.filter-card { display: grid; gap: 8px; }

.filter-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filter-search { flex: 1; min-width: 220px; }

.filter-search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}

.filter-search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.filter-count { color: var(--ink-sub); font-size: .82rem; font-variant-numeric: tabular-nums; }

.filter-row {
  display: grid;
  grid-template-columns: 5.5em minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.filter-label { color: var(--ink-sub); font-size: .8rem; padding-top: 4px; }

.filter-more { border-top: 1px solid var(--line); padding-top: 8px; }
.filter-more > summary { cursor: pointer; color: var(--ink-sub); font-size: .82rem; }
.filter-more > summary:hover { color: var(--ink); }
.filter-more[open] { display: grid; gap: 8px; }
.filter-more[open] > summary { margin-bottom: 2px; }

/* ------------------------------------------------------------- 作例カード */

.gal-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.gal-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  /* 30件を縦に並べると描画が重いので、画面外のカードは描画を省く */
  content-visibility: auto;
  contain-intrinsic-size: auto 360px;
}

.gal-thumb {
  appearance: none;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 0;
  background: var(--code-bg);
  cursor: zoom-in;
  display: block;
}

.gal-thumb img { display: block; width: 100%; height: auto; }
.gal-thumb:hover img { opacity: .9; }
.gal-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.gal-body { display: grid; gap: 7px; padding: 10px 12px 12px; }

.gal-head { display: flex; align-items: baseline; gap: 7px; }
.gal-head h3 { margin: 0; font-size: .95rem; }

.gal-no {
  color: var(--ink-sub);
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.gal-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.gal-tag {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  color: var(--ink-sub);
  font-size: .72rem;
}

.gal-copy { margin: 0; color: var(--ink-sub); font-size: .82rem; }
.gal-actions { display: flex; gap: 6px; margin-top: 2px; }
.gal-empty { color: var(--ink-sub); text-align: center; padding: 32px 0; }

/* --------------------------------------------------------------- 詳細 */

body.is-detail { overflow: hidden; }

.detail {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.detail[hidden] { display: none; }

.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.detail-title { display: flex; align-items: baseline; gap: 8px; font-size: .95rem; }
.detail-no { color: var(--ink-sub); font-size: .78rem; font-variant-numeric: tabular-nums; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

.detail-body {
  flex: 1;
  overflow: auto;
  display: grid;
  gap: 12px;
  align-items: start;
  padding: 14px 16px 28px;
  grid-template-columns: 1fr;
}

@media (min-width: 1040px) {
  .detail-body { grid-template-columns: minmax(0, 1fr) minmax(360px, 460px); }
}

.detail-visual { display: grid; gap: 8px; min-width: 0; }

.detail-visual img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--code-bg);
}

.detail-note { margin: 0; color: var(--ink-sub); font-size: .8rem; }
.detail-side { display: grid; gap: 12px; min-width: 0; }

/* 条件・内容の一覧 */

.detail-list {
  display: grid;
  grid-template-columns: 6.5em minmax(0, 1fr);
  gap: 3px 10px;
  margin: 0;
  font-size: .84rem;
}

.detail-list dt { color: var(--ink-sub); }
.detail-list dd { margin: 0; }
.detail-list ul { margin: 0; padding-left: 1.1em; }
/* おすすめセットの説明は選択肢と同じカード内に収める。 */
.preset-hint { margin: 10px 0; font-size: 12px; line-height: 1.7; color: var(--ink-sub); }
