/* ==========================================================================
   Bookmark — スタイル
   方針: 箱で囲まない。区切りは余白と1本の罫線。階層は文字の大きさと色で作る。
   色は情報を持つものにだけ使う（カテゴリの点・危険な操作・警告）。
   ========================================================================== */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f6;
  --border: #e7e7ea;
  --border-strong: #c9c9d0;
  --text: #16161a;
  --muted: #6a6a75;
  --faint: #86868f;
  --invert-bg: #16161a;
  --invert-text: #ffffff;
  --danger: #b32941;
  --warn: #8a5a00;

  /* 文字 */
  --fs-nano: 10.5px;  /* バッジと件数バッジだけ。文章には使わない */
  --fs-micro: 12px;   /* 補助情報。これ以上小さくしない */
  --fs-meta: 13px;    /* 説明文・メタ情報。本文に次いでよく読まれる */
  --fs-body: 14px;
  --fs-title: 15px;
  --fs-head: 17px;

  /* 余白 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 64px;

  --header-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d;
    --surface: #101013;
    --surface-2: #17171b;
    --border: #26262c;
    --border-strong: #414149;
    --text: #ececef;
    --muted: #9494a0;
    --faint: #7b7b86;
    --invert-bg: #ececef;
    --invert-text: #0b0b0d;
    --danger: #e8798b;
    --warn: #d6a453;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP",
    "Yu Gothic UI", sans-serif;
  font-size: var(--fs-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
::selection { background: var(--invert-bg); color: var(--invert-text); }

/* 文中に置いたアイコンは既定でベースラインに「乗って」しまい、字より浮いて見える。
   少し下げて、文字の重心に合わせる。flex の中では vertical-align は無視されるので、
   全ての svg に当てて問題ない。 */
svg { flex: none; vertical-align: -0.15em; }

/*
 * text-box-trim: 行の上下に付く half-leading を削り、
 * 「指定した余白 = 目で見える余白」にする。
 *
 * これを入れないと、たとえば見出しの margin-bottom を 8px にしても
 * 実際の隙間は行送り分だけ広くなり、余白の数字が当てにならない。
 * 対応していないブラウザでは今までどおりの見え方になるよう @supports で囲う。
 */
@supports (text-box: trim-both cap alphabetic) {
  /* line-clamp で overflow:hidden している要素には当てない。
     trim で行箱が cap〜baseline まで縮み、g や y の下が切れる。 */
  .panel h2,
  .empty h2,
  .field label,
  .shot figcaption,
  .fgroup h4,
  .side h3 {
    text-box: trim-both cap alphabetic;
  }

  /* trim の分だけ隙間が詰まるので、狙いの余白に戻す */
  .panel h2 { margin-bottom: var(--s3); }
  .field label { margin-bottom: var(--s3); }
  .shot figcaption { margin-bottom: var(--s3); }
  .empty h2 { margin-bottom: var(--s3); }
  .fgroup h4 { margin-bottom: var(--s3); }
}

/* ------------------------------------------------------------- 絞り込み */
/*
 * details だと、ボタン（summary）とパネルが同じ要素の中にある。
 * ボタンをツールバーの中に置くとパネルもツールバーの中に入ってしまい、
 * 「下の要素を押し出す」形にできない。
 * そこで checkbox を先頭に置き、:checked で離れた場所のパネルを開く。
 * ツールバーの外に出せるので、開いたぶんだけ一覧が素直に下がる。
 */
.filter-state {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  margin: 0;
}

.filter-btn {
  position: relative;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--faint);
  cursor: pointer;
}
.filter-btn:hover { color: var(--text); }
.filter-btn svg { width: 15px; height: 15px; }
.filter-state:checked ~ .toolbar .filter-btn { background: var(--surface-2); color: var(--text); }
.filter-state:focus-visible ~ .toolbar .filter-btn { outline: 2px solid var(--text); outline-offset: 1px; }
.filter-btn .n {
  position: absolute;
  top: -2px; right: -4px;
  min-width: 14px; height: 14px; padding: 0 3px;
  display: grid; place-items: center;
  background: var(--invert-bg); color: var(--invert-text);
  font-size: var(--fs-nano); line-height: 1;
}

.filterbody { display: none; }
.filter-state:checked ~ .filterbody {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s5) var(--s6);
  padding: var(--s5) 0;
  border-block: 1px solid var(--border);
  margin-bottom: var(--s4);
}

.fgroup { min-width: 0; max-width: 100%; }

/* ------------------------------------------------------------------ header */
.hdr {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s5);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: var(--s2); font-weight: 600; letter-spacing: -0.005em; flex: none; }
.brand svg { width: 17px; height: 17px; }
.brand span { display: none; }
@media (min-width: 600px) { .brand span { display: inline; } }

.spacer { flex: 1; }

.hdr-right { display: flex; align-items: center; gap: var(--s1); flex: none; }
.who { display: none; color: var(--faint); font-size: var(--fs-meta); margin-right: var(--s3); }
@media (min-width: 900px) { .who { display: block; } }

.iconbtn, .search > summary {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
.iconbtn:hover, .search > summary:hover { background: var(--surface-2); color: var(--text); }
.iconbtn svg, .search > summary svg { width: 17px; height: 17px; }
.search > summary::-webkit-details-marker { display: none; }
.search[open] > summary { background: var(--surface-2); color: var(--text); }

/* 検索は既定で畳み、開いたときだけヘッダ下にせり出す */
.search { position: relative; }
.search > form {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  width: min(360px, calc(100vw - 32px));
  background: var(--bg);
  border-bottom: 1px solid var(--text);
}
.search input {
  width: 100%;
  height: 38px;
  padding: 0 30px 0 2px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: var(--fs-body);
}
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; }
.search .clear { position: absolute; right: 2px; top: 50%; translate: 0 -50%; color: var(--faint); padding: 4px; line-height: 0; }
.search .clear:hover { color: var(--text); }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  --btn-px: var(--s5);
  height: 38px;
  padding: 0 var(--btn-px);
  border: 1px solid var(--border-strong);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-meta);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--invert-bg); border-color: var(--invert-bg); color: var(--invert-text); }
.btn-primary:hover { background: var(--invert-bg); opacity: 0.85; }
/*
 * 枠線の無いボタンは左右のパディングを持たない。
 * パディングがあると文字が列の基準線から右にずれ、負のマージンで引き戻すと
 * 今度はホバーの背景が列の外へはみ出す。どちらも起きないのが padding: 0。
 * 結果としてホバー範囲は文字ぴったりになるが、これらは文字リンク相当の操作なので問題ない。
 */
.btn-ghost, .btn-danger { --btn-px: 0; border-color: transparent; }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { background: none; color: var(--text); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: none; border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }

/* アイコンだけのボタンは文字が無く当たり判定が消えるので、枠の分だけ確保する */
.catrow .btn-danger, .btn-ghost:has(> svg:only-child) { --btn-px: var(--s2); }
.btn-sm { --btn-px: var(--s3); height: 30px; font-size: var(--fs-micro); }
.btn svg { width: 15px; height: 15px; }
.btn[disabled] { opacity: 0.35; cursor: default; }

/* ------------------------------------------------------------------ main */
.main { padding: var(--s5) var(--s5) var(--s8); min-width: 0; max-width: 1160px; margin: 0 auto; }

/* 絞り込みパネルの基準にするため relative */
.toolbar { position: relative; display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; margin-bottom: var(--s4); }

/* タブと件数はひとつの塊。baseline で揃えないと数字だけ下にずれる。 */

.count { color: var(--faint); font-size: var(--fs-micro); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ツールバー右側のアイコンは、間隔を詰めてひと続きに見せる */
.tools { display: inline-flex; align-items: center; gap: 2px; }
.viewtoggle { display: inline-flex; gap: 2px; }
.viewtoggle a { width: 28px; height: 28px; display: grid; place-items: center; color: var(--faint); }
.viewtoggle a:hover { color: var(--text); }
.viewtoggle a.on { background: var(--surface-2); color: var(--text); }
.viewtoggle svg { width: 15px; height: 15px; }

/* アイコンから開く小さなメニュー。中身はただのリンクなので状態を持たない。 */
.menu { position: relative; }
.menu > summary {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--faint);
  cursor: pointer;
  list-style: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { color: var(--text); }
.menu[open] > summary { background: var(--surface-2); color: var(--text); }
.menu > summary svg { width: 15px; height: 15px; }

.menu-list {
  position: absolute;
  z-index: 50;
  top: calc(100% + 6px);
  right: 0;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border-strong);
}
.menu-list a {
  padding: var(--s3) var(--s4);
  font-size: var(--fs-meta);
  color: var(--muted);
  white-space: nowrap;
}
.menu-list a + a { border-top: 1px solid var(--border); }
.menu-list a:hover { background: var(--surface-2); color: var(--text); }
.menu-list a.on { color: var(--text); font-weight: 600; }

.fgroup h4 { margin: 0 0 var(--s2); font-size: var(--fs-micro); font-weight: 400; color: var(--muted); }

.taglist { display: flex; flex-wrap: wrap; gap: var(--s1) 6px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px var(--s2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--fs-micro);
  max-width: 100%;
}
.tag:hover { border-color: var(--border-strong); color: var(--text); }
.tag.on { background: var(--invert-bg); border-color: var(--invert-bg); color: var(--invert-text); }
.tag .n { color: var(--faint); font-variant-numeric: tabular-nums; }
.tag.on .n { color: inherit; opacity: 0.6; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s4); }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 6px 2px var(--s2);
  border: 1px solid var(--border-strong);
  font-size: var(--fs-micro);
  color: var(--text);
}
.chip .x { color: var(--faint); line-height: 0; padding: 2px; }
.chip .x:hover { color: var(--text); }

.dot { width: 7px; height: 7px; flex: none; }

/* ------------------------------------------------------------- リスト */
.rows { display: flex; flex-direction: column; }

/* サムネイルを主役にする。狭い画面では縦積み、広い画面では横幅の約45%を画像に割く。 */
/* 狭い画面ではサムネイルを小さく横に置く。縦積みにすると1件で画面が埋まってしまう。 */
.item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  grid-template-areas: "thumb body";
  gap: var(--s3);
  padding: var(--s4) 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
  align-items: start;
}
@media (min-width: 720px) {
  .item {
    grid-template-columns: 45% minmax(0, 1fr);
    gap: var(--s5);
    padding: var(--s5) var(--s3);
    align-items: stretch;
  }
}
.item:hover { background: var(--surface-2); }
.ithumb { grid-area: thumb; }
.ibody { grid-area: body; }
/* タイトル行の右端。日付のとなりに置くと、視線の通り道に入って見つけやすい。 */
.itools { display: flex; align-items: center; gap: 2px; flex: none; margin-left: 2px; }

.ithumb { display: block; aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-2); }
.ithumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
/* 画像が無いときの頭文字。文章ではなく装飾なのでトークンを使わない。 */
.ithumb .ph { display: grid; place-items: center; width: 100%; height: 100%; color: var(--faint); font-size: 22px; }

.ibody { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.ihead { display: flex; align-items: flex-start; gap: var(--s3); min-width: 0; }

/* 日付と操作は行の右下にまとめる。読む順（タイトル→タグ→要約）の最後に来る。 */
.ifoot { display: flex; align-items: center; justify-content: flex-end; gap: var(--s2); margin-top: auto; padding-top: var(--s3); }
.ihead .badge { flex: none; margin-top: 3px; white-space: nowrap; }
.ititle {
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.01em;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ititle:hover { text-decoration: underline; }
.iwhen { color: var(--faint); font-size: var(--fs-micro); white-space: nowrap; flex: none; }
.iwhen:hover { color: var(--text); }

@media (min-width: 720px) { .ititle { font-size: var(--fs-head); } }

.itags { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3); font-size: var(--fs-meta); min-width: 0; }
.itags:empty { display: none; }
.isite { color: var(--muted); max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icat { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.itag { color: var(--muted); }
.itag::before { content: "#"; opacity: 0.55; }
.icat:hover, .itag:hover { color: var(--text); }

.isum {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: var(--fs-meta);
  line-height: 1.8;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (min-width: 720px) { .isum { -webkit-line-clamp: 5; } }

.owner { display: inline-flex; align-items: center; gap: var(--s1); font-size: var(--fs-micro); color: var(--faint); }

.star {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 0; background: none;
  color: var(--muted);
  cursor: pointer;
}
.star:hover, .star.on { color: var(--text); }
.star:hover { background: var(--surface-2); }

/* 詳細（編集・再取得・削除ができる画面）への入口。
   サムネイルとタイトルはリンク先そのものを開くので、ここが唯一の入口になる。
   hover で出す方式だと存在に気づけないため、常に表示しておく。 */
.idetail {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  color: var(--muted);
}
.idetail:hover { background: var(--surface-2); color: var(--text); }
.idetail svg { width: 16px; height: 16px; }
.star.on { color: var(--text); }
.star svg { width: 15px; height: 15px; }

.item.pending .ithumb .ph, .card.pending .thumb .ph { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.85; } }

/* ------------------------------------------------------------ グリッド */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s6) var(--s5);
}
@media (min-width: 620px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 940px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card { display: flex; flex-direction: column; min-width: 0; }
.card .thumb { position: relative; aspect-ratio: 16 / 10; background: var(--surface-2); overflow: hidden; margin-bottom: var(--s3); }
.card .thumb > a { display: block; width: 100%; height: 100%; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.card .thumb .ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--faint); font-size: 22px; }
.card .star { position: absolute; top: var(--s2); right: var(--s2); background: var(--bg); }

/* スターが右上に居るので、状態の印は右下へ。 */
.badges { position: absolute; bottom: var(--s2); right: var(--s2); display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.badge { padding: 0 6px; font-size: var(--fs-nano); line-height: 18px; background: var(--surface-2); color: var(--muted); }
/* 公開範囲の印。囲まない。色を持たせる意味も無いので、本文と同じ濃さで置く。 */
.vis { display: inline-flex; align-items: center; flex: none; color: var(--text); }
.vis svg { width: 13px; height: 13px; }
.badge.warn { color: var(--warn); }
.badge.err { color: var(--danger); }

.card .body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.site { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: var(--fs-micro); min-width: 0; }
.site img { width: 13px; height: 13px; flex: none; }
.site .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card h2 {
  margin: 0;
  font-size: var(--fs-title);
  font-weight: 500;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card p.sum {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-meta);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .foot { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: var(--s1); }
.card .when { color: var(--faint); font-size: var(--fs-micro); margin-left: auto; flex: none; }
.card .foot .idetail { margin-left: 2px; }

/* -------------------------------------------------------------- 空・頁送り */
.empty { padding: var(--s7) var(--s5); text-align: center; color: var(--faint); }
/* 空状態の顔文字。細い記号の連なりなので、本文より大きめかつ濃いめにしないと沈む。
   .empty p / .gate p（詳細度 0,1,1）に勝つ必要があるのでクラス2つで書く。 */
.empty .emptyart, .gate .emptyart {
  margin: 0 0 var(--s6);
  font-size: clamp(44px, 8vw, 64px);
  line-height: 1.15;
  letter-spacing: 0.06em;
  color: var(--faint);
  user-select: none;
  white-space: nowrap;
}
.empty h2 { margin: 0 0 var(--s2); font-size: var(--fs-title); font-weight: 500; color: var(--text); }
.empty p { margin: 0 0 var(--s5); font-size: var(--fs-meta); color: var(--muted); }

.pager { display: flex; gap: var(--s3); justify-content: center; margin-top: var(--s6); align-items: center; }
/* 読み込み中は押せないことを見せる。文言は変えない（一瞬で戻るので読めない） */
.pager.loading { opacity: 0.4; pointer-events: none; }
.pager 
/* --------------------------------------------------------- 入口のページ */
/* サインインが必要・見つからない・エラー。文字だけで足りるので囲まない。 */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: var(--s6) var(--s5); }
.gate-box { max-width: 420px; }
.gate .brand { display: flex; }
.gate .emptyart { margin-bottom: var(--s5); }
.gate h1 { margin: 0 0 var(--s3); font-size: var(--fs-head); font-weight: 600; letter-spacing: -0.01em; }
.gate p { margin: 0; color: var(--muted); font-size: var(--fs-meta); line-height: 1.9; }
.gate .gate-detail { margin-top: var(--s4); color: var(--faint); font-size: var(--fs-micro); }
.gate .actions { margin-top: var(--s6); }

/* -------------------------------------------------------------- ページ */
.page { max-width: 720px; margin: 0 auto; padding: var(--s6) var(--s5) 120px; }
.page.wide { max-width: 1180px; }

/* 設定: 章タイトルと説明を左に置き、操作は右に集める */
.page.settings { max-width: 1000px; }
@media (min-width: 860px) {
  .settings .panel {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: var(--s7);
    align-items: start;
  }
}
.settings .phead .hint { margin-bottom: 0; }
.settings .pbody > .field:last-child { margin-bottom: 0; }

.crumb { display: inline-flex; align-items: center; gap: var(--s2); color: var(--faint); font-size: var(--fs-meta); margin-bottom: var(--s7); }
.crumb:hover { color: var(--text); }

.panel { border: 0; background: none; padding: 0; }
.panel + .panel { margin-top: var(--s8); padding-top: var(--s6); border-top: 1px solid var(--border); }
.panel h2 { margin: 0 0 var(--s2); font-size: var(--fs-title); font-weight: 600; letter-spacing: -0.005em; }
.panel h3 { font-size: var(--fs-body); font-weight: 600; }
.panel .hint { margin: 0 0 var(--s5); color: var(--muted); font-size: var(--fs-meta); line-height: 1.85; }

/* 入力は塗らない。1本の下線だけで示し、フォーカスで濃くする。 */
.field { margin-bottom: var(--s7); }
.field:last-child { margin-bottom: 0; }
.field label { display: block; margin-bottom: var(--s3); font-size: var(--fs-meta); color: var(--muted); }

.field input[type="text"],
.field input[type="url"],
.field textarea,
.field select {
  width: 100%;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--border-strong);
  background: none;
  color: inherit;
  font: inherit;
  font-size: var(--fs-body);
  border-radius: 0;
}
.field textarea { resize: vertical; min-height: 76px; line-height: 1.8; }
.field select { padding-right: var(--s5); cursor: pointer; }

/*
 * カスタマイズ可能な select（Chrome 135+）。
 * 対応ブラウザでは配色と角の無さを他の入力欄に揃え、
 * 未対応ブラウザ（Safari / Firefox）では OS 標準の select のまま動く。
 */
@supports (appearance: base-select) {
  .field select {
    appearance: base-select;
    border: 0;
    border-bottom: 1px solid var(--border-strong);
    background: none;
    padding: 10px 0;
  }
  .field select:hover { background: none; }
  .field select::picker-icon { color: var(--faint); transition: rotate 0.15s; }
  .field select:open::picker-icon { rotate: 180deg; }

  .field select::picker(select) {
    appearance: base-select;
    margin-top: 6px;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--bg);
    box-shadow: none;
    padding: 0;
  }
  .field select option {
    padding: var(--s3) var(--s4);
    font-size: var(--fs-meta);
    color: var(--muted);
    background: var(--bg);
  }
  .field select option:not(:first-child) { border-top: 1px solid var(--border); }
  .field select option:hover { background: var(--surface-2); color: var(--text); }
  .field select option:checked { color: var(--text); font-weight: 600; }
  .field select option::checkmark { display: none; }
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-bottom-color: var(--text); }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field .note { margin-top: var(--s2); font-size: var(--fs-meta); color: var(--muted); line-height: 1.8; }

.cols { display: flex; gap: var(--s5); flex-wrap: wrap; }
.cols > * { flex: 1; min-width: 180px; }

.actions { display: flex; gap: var(--s3); align-items: center; margin-top: var(--s6); flex-wrap: wrap; }
/* flex:1 のスペーサーを挟むと、折り返し時に後続が丸ごと次の行へ落ちる。
   右寄せは margin-left:auto でやる。 */
.actions .push { margin-left: auto; }

.actions .sep { width: 1px; height: 20px; background: var(--border); margin: 0 var(--s2); }

/* ツールチップ。説明文を常時置かず、必要なときだけ出す。 */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  translate: -50% 0;
  width: max-content;
  max-width: 260px;
  padding: 7px 10px;
  background: var(--invert-bg);
  color: var(--invert-text);
  font-size: var(--fs-micro);
  line-height: 1.65;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.1s;
  z-index: 60;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after { opacity: 1; visibility: visible; }

/* 公開範囲: 3点スライダー。ドラッグ中は連続して追従し、離すと最寄りの段に吸着する。 */
.vis-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s4) var(--s6); }
.vis-slider { width: 340px; max-width: 100%; flex: none; }

.vis-range {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 30px;
  background: none;
  cursor: pointer;
  margin: 0;
  /* つまみが端で見切れないよう、トラックを内側に寄せる */
  padding: 0 1px;
}
.vis-range:focus { outline: none; }
.vis-range::-webkit-slider-runnable-track { height: 2px; background: var(--border-strong); }
.vis-range::-moz-range-track { height: 2px; background: var(--border-strong); }
/* つまみ: 掴める範囲を 28px 取りつつ、見た目は 14px のまま。
   透明な border で外側を広げ、background-clip: content-box で
   中身の 14px だけを塗る。 */
.vis-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 28px; height: 28px;
  margin-top: -13px;
  border: 7px solid transparent;
  background: var(--invert-bg);
  background-clip: content-box;
  cursor: grab;
  transition: scale 0.1s;
}
.vis-range::-moz-range-thumb {
  box-sizing: border-box;
  width: 28px; height: 28px;
  border: 7px solid transparent;
  border-radius: 0;
  background: var(--invert-bg);
  background-clip: content-box;
  cursor: grab;
}
.vis-range:active::-webkit-slider-thumb { scale: 1.2; cursor: grabbing; }
.vis-range:active::-moz-range-thumb { cursor: grabbing; }
.vis-range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--text); outline-offset: 2px; }

/* 目盛。位置がつまみの止まる3点と揃うよう、両端だけ寄せる。 */
.vis-ticks { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: -2px; }
.vis-ticks button {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--fs-micro);
  color: var(--faint);
  cursor: pointer;
}
.vis-ticks button:nth-child(2) { justify-content: center; }
.vis-ticks button:nth-child(3) { justify-content: flex-end; }
.vis-ticks button svg { width: 13px; height: 13px; }
.vis-ticks button:hover { color: var(--muted); }
[data-level="0"] .vis-ticks button:nth-child(1),
[data-level="1"] .vis-ticks button:nth-child(2),
[data-level="2"] .vis-ticks button:nth-child(3) { color: var(--text); }

/* 選んだ段階に応じて、結果を1文で出す。スライダーの右に置く。 */
.vis-desc {
  flex: 1;
  min-width: 200px;
  margin: 0;
  padding-top: 2px;
  font-size: var(--fs-meta);
  color: var(--muted);
  line-height: 1.8;
}
.vis-desc > span { display: none; }
[data-level="0"] .vis-desc .d-0,
[data-level="1"] .vis-desc .d-1,
[data-level="2"] .vis-desc .d-2 { display: inline; }

/* 選んだ段階に応じて、結果を1文で出す。切り替えは :has() だけで行い JS を使わない。 */
.vis-desc { margin: var(--s3) 0 0; font-size: var(--fs-micro); color: var(--faint); line-height: 1.7; }
.vis-desc > span { display: none; }

.msg {
  padding: 3px 0 3px var(--s3);
  border: 0;
  border-left: 2px solid var(--border-strong);
  font-size: var(--fs-meta);
  line-height: 1.75;
  margin-bottom: var(--s6);
  color: var(--muted);
}
.msg.err { color: var(--danger); border-left-color: currentColor; }
.msg.warn { color: var(--warn); border-left-color: currentColor; }

/* -------------------------------------------------------------- 詳細 */
.detail { display: grid; grid-template-columns: 1fr; gap: var(--s6); }
@media (min-width: 960px) {
  .detail { grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: var(--s7); align-items: start; }
}
.dcol { min-width: 0; }
.dcol > * + * { margin-top: var(--s6); }
/* 見出しが直前の画像にくっついて見えないよう、図の前だけ広く取る */
.dcol > .shot + .shot, .dcol > .shot + .panel { margin-top: var(--s7); }
.dcol .panel + .panel { margin-top: var(--s6); }

.shot { margin: 0; }
.shot figcaption {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  font-size: var(--fs-meta); color: var(--muted); margin-bottom: var(--s3);
}

/* 選ばれていないほうは沈める。押せることは伝えたいので消しはしない。 */
.thumbpick { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--faint); }
.thumbpick span { font-size: var(--fs-micro); }
.thumbpick:hover { color: var(--muted); }
.thumbpick:has(input:checked) { color: var(--text); }
.thumbpick input { margin: 0; accent-color: var(--text); }
.dhero { display: block; background: var(--surface-2); overflow: hidden; }
.dhero img { width: 100%; }
/* 画像と同じ比率で場所を取り、有無でレイアウトがずれないようにする */
/* ページ全体のキャプチャ。左右のカラムの下に、全幅で置く。
   畳まないので、見たい人はそのままスクロールすればよい。 */
.fullshot { margin: var(--s8) 0 0; }
.fullshot figcaption { font-size: var(--fs-meta); color: var(--muted); margin-bottom: var(--s3); }
.fullshot img { display: block; width: 100%; background: var(--surface-2); }

.noshot {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  padding: var(--s4);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-meta);
  line-height: 1.8;
  text-align: center;
}

.durl { color: var(--muted); font-size: var(--fs-meta); word-break: break-all; }
.durl:hover { color: var(--text); text-decoration: underline; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s4) var(--s6); font-size: var(--fs-meta); margin: 0; line-height: 1.8; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; color: var(--muted); word-break: break-word; }

/* 行ごとに項目数が違う（新規行にはカウントと削除が無い）ので、
   flex ではなく固定カラムのグリッドにして列位置を揃える。 */
.catrow {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 2.5rem 84px 28px;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) 0;
}
.catrow .btn { width: 100%; }
.catrow .count { text-align: right; }
.catrow + .catrow { border-top: 1px solid var(--border); }
.catrow input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  color: inherit;
  font: inherit;
  font-size: var(--fs-body);
  border-radius: 0;
}
.catrow input[type="text"]:focus { outline: none; border-bottom-color: var(--text); }
.catrow input[type="text"]::placeholder { color: var(--faint); }
/* カテゴリの色: 決め打ちのパレットから選ぶ */
.swatch { position: relative; flex: none; }
.swatch > summary {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  cursor: pointer;
  list-style: none;
}
.swatch > summary::-webkit-details-marker { display: none; }
.swatch > summary:hover, .swatch[open] > summary { background: var(--surface-2); }
.chip-dot { display: block; width: 14px; height: 14px; }

.swatch-grid {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  display: grid;
  grid-template-columns: repeat(6, 22px);
  gap: 4px;
  padding: var(--s2);
  background: var(--bg);
  border: 1px solid var(--border-strong);
}
.swatch-grid label { display: block; cursor: pointer; margin: 0; }
.swatch-grid input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatch-grid span {
  display: block;
  width: 22px; height: 22px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.swatch-grid label:hover span { outline: 1px solid var(--border-strong); outline-offset: 2px; }
.swatch-grid input:checked + span,
.swatch-grid input:checked ~ span { outline: 2px solid var(--text); outline-offset: 2px; }

/* 任意の色。色見本と同じ大きさの枠に、OS のカラー入力を重ねて隠している。 */
.swatch-custom { position: relative; }
.swatch-custom input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.swatch-custom > span {
  background:
    conic-gradient(from 0deg,
      #db6c66, #d27830, #b88a01, #889e2a, #37ab6b,
      #18a7a1, #00a1cb, #5d91e7, #997fde, #c170bb, #db6c66);
}

code, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: var(--fs-micro); }
.codebox { color: var(--muted); }
.codebox {
  background: var(--surface-2);
  border: 0;
  padding: var(--s4) var(--s5);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--muted);
  line-height: 1.75;
}

ol.steps { margin: 0; padding-left: var(--s5); font-size: var(--fs-meta); color: var(--muted); line-height: 1.9; }
ol.steps li { margin-bottom: var(--s4); }
ol.steps li strong { color: var(--text); font-weight: 500; }

/* 設定ページ: 長い手順は畳んでおく */
.sub { border-top: 1px solid var(--border); }
.sub > summary {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s4) 0;
  font-size: var(--fs-body);
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
.sub > summary::-webkit-details-marker { display: none; }
.sub > summary::before { content: "›"; display: inline-block; transition: rotate 0.12s; }
.sub[open] > summary::before { rotate: 90deg; }
.sub > summary:hover { color: var(--text); }
.sub .body { padding: 0 0 var(--s5); }

.meter { height: 4px; background: var(--surface-2); overflow: hidden; margin: var(--s2) 0 var(--s1); }
.meter i { display: block; height: 100%; background: var(--muted); }
.meter i.hot { background: var(--warn); }

/* -------------------------------------------------------------- Tagify */
.tagify {
  --tags-border-color: transparent;
  --tags-hover-border-color: transparent;
  --tags-focus-border-color: transparent;
  --tag-bg: var(--surface-2);
  --tag-hover: var(--surface-2);
  --tag-text-color: var(--text);
  --tag-remove-bg: var(--surface-2);
  --tag-remove-btn-color: var(--muted);
  --tag-border-radius: 0;
  --tag-pad: 0 6px;
  --placeholder-color: var(--faint);
  --placeholder-color-focus: var(--faint);
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border-strong);
  border-radius: 0;
  background: none;
  padding: 2px 0;
  font-size: var(--fs-body);
}
.tagify--focus { border-bottom-color: var(--text); }
.tagify__tag > div { border-radius: 0; }
.tagify__input { color: var(--text); margin: 4px; }
/* Tagify の演出を全部止める。候補は「出る／出ない」だけでいい。
   スライドインもタグ追加時の bump も、この UI では邪魔にしかならない。 */
.tagify { --tag-hide-transition: 0s; --tagify-dd-item--hidden-duration: 0s; transition: none; }
.tagify__tag,
.tagify__tag > div,
.tagify__tag > div > *,
.tagify__tag__removeBtn,
.tagify__input:last-child:focus::before,
.tagify--empty .tagify__input::before { transition: none; }
.tagify__tag > div::before { animation: none; transition: none; }

/* ドロップダウンは body 直下に出るので、.tagify に書いた変数が届かない。
   ここで直接指定する（既定のままだと青い線が出る）。 */
.tagify__dropdown {
  --tagify-dd-bg-color: var(--bg);
  --tagify-dd-color-primary: var(--border-strong);
  --tagify-dd-text-color: var(--text);
  --tagify-dd-item-pad: 0;
  border-radius: 0;
  box-shadow: none;
  border-top: 0;
}
.tagify__dropdown__wrapper {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  box-shadow: none;
  transition: none;
  animation: none;
  overflow-y: auto;
}
/* 開いた直後の「たたまれた状態」を無くし、最初から実寸で出す */
.tagify__dropdown--initial .tagify__dropdown__wrapper,
.tagify__dropdown--initial[placement="top"] .tagify__dropdown__wrapper {
  max-height: var(--tagify-dd-max-height);
  transform: none;
}
.tagify__dropdown__item {
  border-radius: 0;
  color: var(--text);
  font-size: var(--fs-meta);
  padding: var(--s3) var(--s4);
  margin: 0;
  max-height: none;
  box-shadow: none;
}
.tagify__dropdown__item + .tagify__dropdown__item { border-top: 1px solid var(--border); }
.tagify__dropdown__item--active { background: var(--surface-2); color: var(--text); }
/* 絞り込みで隠れた項目は罫線も消す */
.tagify__dropdown__item--hidden { border-top: 0; }
