@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+JP:wght@400;500;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ============================================================
   awesome-design — design tokens (job colors 4 + neutrals only)
   ============================================================ */
:root {
  --ink: #212529;
  --muted: #64707C;
  --line: #DEE2E6;
  --line-strong: #CDD4DB;
  --paper: #FFFFFF;
  --paper-dim: #F6F8FA;
  --paper-dim2: #EEF1F4;
  --accent: #2563EB;
  --accent-soft: #EAF0FE;
  --ok: #16A34A;
  --ok-soft: #E7F5EC;
  --warn: #D97706;
  --warn-soft: #FBF0E1;
  --err: #DC2626;
  --err-soft: #FBEBEB;

  --font-sans: 'IBM Plex Sans JP', 'Hiragino Kaku Gothic ProN', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;

  --text-micro: 11.5px;
  --text-caption: 12.5px;
  --text-data: 13.5px;
  --text-body: 15px;
  --text-section: 18px;
  --text-title: 21px;
  --text-display: 27px;
  --text-stat: 34px;

  --leading-body: 1.9;
  --leading-data: 1.6;
  --leading-heading: 1.45;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow-1: 0 1px 2px rgba(33,37,41,.05);
  --shadow-2: 0 8px 24px rgba(33,37,41,.09);
  --shadow-3: 0 14px 36px rgba(33,37,41,.12);

  --header-h: 60px;
  --container: 1240px;

  /* terminal surface (achromatic) */
  --term-bg: #16191D;
  --term-bar: #1E232A;
  --term-line: #2A3038;
  --term-fg: #F1F3F5;
  --term-dim: #8A929B;
  --term-str: #C7CDD4;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--paper-dim);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: var(--text-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
button { font-family: inherit; }
img { display: block; max-width: 100%; }

/* full-bleed: use the whole page width, 32px side gutters */
.container { width: 100%; margin: 0; padding: 0 clamp(32px, 5vw, 96px); }

/* ============================================================
   Header / nav
   ============================================================ */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
}
.app-header .container {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
}
.wordmark {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.wordmark:hover { text-decoration: none; }
.wm-mark { width: 22px; height: 22px; flex: none; display: block; border-radius: 6px; }
.wm-text {
  font-weight: 700; font-size: 16.5px; letter-spacing: -.01em; line-height: 1;
}
.wm-v {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  color: var(--muted); letter-spacing: .04em; margin-left: 1px; align-self: flex-start; margin-top: 1px;
}
.app-nav { display: flex; align-items: center; gap: 4px; }
.app-nav a {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: var(--text-data); font-weight: 500;
  text-decoration: none; line-height: 1; white-space: nowrap;
  transition: background .13s, color .13s;
}
.app-nav a:hover { background: var(--paper-dim); color: var(--ink); text-decoration: none; }
.app-nav a.active { color: var(--ink); background: var(--paper-dim); }
.app-nav a.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px;
}
.app-nav a[hidden] { display: none; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: var(--text-data); font-weight: 600; line-height: 1;
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink);
  cursor: pointer; transition: background .13s, border-color .13s, transform .06s, box-shadow .13s;
  white-space: nowrap;
}
.btn:hover { background: var(--paper-dim); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-primary:hover { background: #101317; border-color: #101317; }
.btn-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-ok:hover { background: #128a3e; border-color: #128a3e; }
.btn-danger { background: var(--paper); color: var(--err); border-color: #F0C9C9; }
.btn-danger:hover { background: var(--err-soft); border-color: var(--err); }
.btn svg { width: 15px; height: 15px; }

/* ============================================================
   Toast
   ============================================================ */
.toast-host {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  min-width: 260px; max-width: 460px;
  background: var(--ink); color: var(--paper);
  border-radius: 10px; padding: 12px 16px 12px 14px;
  box-shadow: var(--shadow-3);
  font-size: var(--text-data); line-height: 1.5;
  opacity: 0; transform: translateY(10px) scale(.98);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast .t-ic {
  width: 22px; height: 22px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.toast.ok .t-ic { background: var(--ok); }
.toast.warn .t-ic { background: var(--warn); }
.toast.err .t-ic { background: var(--err); }
.toast .t-body code { font-family: var(--font-mono); font-size: 12px; opacity: .92; }
.toast .t-body b { font-weight: 600; }

/* ============================================================
   Quality / kind badges + chips
   ============================================================ */
.badge-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* call-count badge — 呼び出し回数 is the primary success signal */
.call-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 7px; border-radius: 20px;
  background: var(--paper-dim); border: 1px solid var(--line);
  color: var(--muted); white-space: nowrap; line-height: 1.4;
}
.call-badge .cb-ic { width: 12px; height: 12px; color: var(--muted); flex: none; display: flex; }
.call-badge .cb-ic svg { width: 12px; height: 12px; }
.call-badge b {
  font-family: var(--font-mono); font-size: var(--text-caption); font-weight: 600;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.call-badge .cb-u { font-size: var(--text-micro); color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 6px;
  font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 500;
  color: var(--muted); background: var(--paper); border: 1px solid var(--line);
  line-height: 1.5; white-space: nowrap;
}
.chip.tag { color: var(--ink); }
.chip.sealed { color: var(--ink); background: var(--paper-dim); }
.chip.sealed::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

/* ============================================================
   Catalog — dictionary header (center search + live counter)
   ============================================================ */
.cat-header { height: auto; min-height: var(--header-h); }
.cat-header .container {
  display: grid;
  grid-template-columns: auto minmax(240px, 560px) auto;
  align-items: center; gap: 20px;
  padding-top: 9px; padding-bottom: 9px;
}

.hdr-search { position: relative; display: flex; align-items: center; justify-self: center; width: 100%; }
.hdr-search .s-ic {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted); pointer-events: none;
}
.hdr-search input {
  width: 100%; height: 42px;
  padding: 0 44px 0 42px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--paper-dim); color: var(--ink);
  font-family: var(--font-sans); font-size: var(--text-data);
  transition: border-color .13s, box-shadow .13s, background .13s;
}
.hdr-search input::placeholder { color: var(--muted); }
.hdr-search input:focus { outline: none; background: var(--paper); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hdr-search input::-webkit-search-cancel-button, .hdr-search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.hdr-search .s-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: none; background: transparent; color: var(--muted);
  border-radius: 50%; cursor: pointer; display: none; align-items: center; justify-content: center;
}
.hdr-search .s-clear svg { width: 16px; height: 16px; }
.hdr-search .s-clear:hover { background: var(--paper-dim2); color: var(--ink); }
.hdr-search.has-value .s-clear { display: flex; }

.hdr-right { display: flex; align-items: center; gap: 16px; justify-self: end; }

/* tag-suggest combobox dropdown */
.search-suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-2); padding: 5px; overflow: hidden;
}
.search-suggest[hidden] { display: none; }
.search-suggest .ss-head {
  font-size: var(--text-micro); font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 6px 10px 7px;
}
.ss-opt {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: none; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; text-align: left; line-height: 1.3;
}
.ss-opt:hover, .ss-opt.active { background: var(--accent-soft); }
.ss-opt .ss-ic { width: 15px; height: 15px; color: var(--muted); flex: none; display: flex; }
.ss-opt .ss-ic svg { width: 15px; height: 15px; }
.ss-opt.active .ss-ic { color: var(--accent); }
.ss-opt .ss-t { flex: 1; font-family: var(--font-mono); font-size: var(--text-data); color: var(--ink); }
.ss-opt.active .ss-t { color: var(--accent); font-weight: 600; }
.ss-opt .ss-c {
  font-family: var(--font-mono); font-size: var(--text-caption); color: var(--muted);
  background: var(--paper-dim2); border-radius: 20px; padding: 1px 8px; font-variant-numeric: tabular-nums;
}

/* active-filter chip bar (below the search) */
.filter-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 20px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.filter-bar[hidden] { display: none; }
.filter-bar .fb-label {
  font-size: var(--text-micro); font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); flex: none;
}
.fb-chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.fchip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 6px 4px 10px; border-radius: 20px;
  border: 1px solid var(--line-strong); background: var(--paper-dim); cursor: pointer;
  color: var(--ink); line-height: 1.4; transition: background .12s, border-color .12s;
}
.fchip:hover { background: var(--err-soft); border-color: #F0C9C9; }
.fchip .fc-k { font-size: var(--text-micro); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.fchip .fc-v { font-family: var(--font-mono); font-size: var(--text-caption); font-weight: 500; }
.fchip .fc-x {
  width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--line); color: var(--muted); flex: none; transition: background .12s, color .12s;
}
.fchip .fc-x svg { width: 11px; height: 11px; }
.fchip:hover .fc-x { background: var(--err); color: #fff; }
.fb-clear {
  flex: none; padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink);
  font-size: var(--text-caption); font-weight: 600; cursor: pointer; transition: background .12s, border-color .12s;
}
.fb-clear:hover { background: var(--paper-dim); border-color: var(--muted); }

/* 絞り込み toggle — only shown on narrow widths where the sidebar collapses.
   Hidden on wide screens (the sidebar is a permanent column there). */
.side-toggle {
  display: none;
  align-items: center; gap: 10px; width: 100%;
  margin-bottom: 18px; padding: 11px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); cursor: pointer;
  box-shadow: var(--shadow-1); line-height: 1;
  transition: background .13s, border-color .13s;
}
.side-toggle:hover { background: var(--paper-dim); border-color: var(--muted); }
.side-toggle .st-ic { width: 17px; height: 17px; color: var(--muted); flex: none; display: flex; }
.side-toggle .st-ic svg { width: 17px; height: 17px; }
.side-toggle .st-label { font-size: var(--text-data); font-weight: 600; }
.side-toggle .st-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: #fff;
  font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.side-toggle .st-badge[hidden] { display: none; }
.side-toggle .st-chev {
  margin-left: auto; width: 10px; height: 10px; flex: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .2s ease;
}
.side-toggle.open .st-chev { transform: rotate(-135deg); }

/* ============================================================
   Catalog — dictionary body
   ============================================================ */
.dict-wrap { padding-top: 24px; padding-bottom: 80px; }
.dict-body { display: grid; grid-template-columns: 224px 1fr; gap: 32px; align-items: start; }

/* --- sidebar --- */
.dict-side { position: sticky; top: calc(var(--header-h) + 24px); }
.side-scroll { max-height: calc(100vh - var(--header-h) - 48px); overflow-y: auto; padding-right: 4px; }
.side-scroll::-webkit-scrollbar { width: 8px; }
.side-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 2px solid var(--paper-dim); }

/* kind nav — the only category axis (3 rows) */
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-kind-link {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  border: none; background: transparent; cursor: pointer;
  color: var(--ink); text-align: left; line-height: 1.3;
  transition: background .15s ease, color .15s ease;
}
.side-kind-link:hover { background: var(--paper-dim2); }
.side-kind-link .skl-label { font-size: var(--text-data); font-weight: 500; }
.side-kind-link .skl-count {
  font-family: var(--font-mono); font-size: var(--text-caption); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.side-kind-link.active { background: var(--accent-soft); }
.side-kind-link.active::before {
  content: ""; position: absolute; left: 3px; top: 9px; bottom: 9px; width: 3px;
  background: var(--accent); border-radius: 2px;
}
.side-kind-link.active .skl-label { font-weight: 700; color: var(--accent); }
.side-kind-link.active .skl-count { color: var(--accent); }

/* tag cloud — the primary fine-grained search device */
.side-tags { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.side-tags h4 {
  display: flex; align-items: center; gap: 7px;
  font-size: var(--text-micro); font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 12px; padding-left: 2px;
}
.side-tags h4 .side-tags-total {
  font-family: var(--font-mono); font-size: var(--text-micro); font-weight: 600; letter-spacing: 0;
  color: var(--muted); background: var(--paper-dim2); border-radius: 20px; padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tagtog {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 9px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--paper); cursor: pointer;
  font-family: var(--font-mono); font-size: var(--text-caption); color: var(--ink);
  line-height: 1.4; transition: background .12s, border-color .12s, color .12s;
}
.tagtog:hover { background: var(--paper-dim); border-color: var(--line-strong); }
.tagtog .tt-count {
  font-size: var(--text-micro); color: var(--muted); background: var(--paper-dim2);
  border-radius: 20px; padding: 0 6px; font-variant-numeric: tabular-nums; line-height: 1.6;
}
.tagtog.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tagtog.active .tt-count { background: rgba(255,255,255,.22); color: #fff; }
.tag-more {
  margin-top: 12px; padding: 4px 2px; font-size: var(--text-caption); color: var(--accent);
  background: none; border: none; cursor: pointer; font-weight: 500;
}
.tag-more:hover { text-decoration: underline; text-underline-offset: 2px; }
.side-reset {
  display: block; width: 100%; text-align: left;
  margin-top: 20px; padding: 16px 2px 0; border-top: 1px solid var(--line);
  font-size: var(--text-caption); color: var(--muted);
  background: none; cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.side-reset:hover { color: var(--ink); }
.side-reset[hidden] { display: none; }

/* --- main sections (one per kind) --- */
.dict-main { min-width: 0; }

/* 件数はカウンタ UI でなく文章 1 行 (「N / M packets」表示は持たない) */
.result-line {
  font-family: var(--font-mono); font-size: var(--text-caption); color: var(--muted);
  margin: 2px 2px 20px; font-variant-numeric: tabular-nums;
}
.result-line:empty { display: none; }
.kind-section { margin-bottom: 48px; scroll-margin-top: calc(var(--header-h) + 24px); }
.kind-section:last-child { margin-bottom: 8px; }
.kind-section[hidden] { display: none; }
.kind-head {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 24px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.kind-name { font-size: var(--text-title); font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.kind-count {
  font-family: var(--font-mono); font-size: var(--text-caption); color: var(--muted);
  padding: 3px 10px; background: var(--paper-dim2); border-radius: 20px; line-height: 1.4;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.kind-count b { color: var(--ink); font-weight: 600; }
.kind-count .kc-u { color: var(--muted); }

/* wide screens (1600px+) land 4–5 columns; narrows down naturally */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }

.dcard {
  position: relative; display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-1);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.dcard[hidden] { display: none; }
.dcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-strong); text-decoration: none; }
.dcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dc-preview {
  position: relative; height: 176px; overflow: hidden;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.dc-preview.img {
  padding: 16px; background: var(--paper-dim);
  background-image: linear-gradient(45deg, #eef1f4 25%, transparent 25%, transparent 75%, #eef1f4 75%),
                    linear-gradient(45deg, #eef1f4 25%, transparent 25%, transparent 75%, #eef1f4 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.dc-preview.img img {
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain; border-radius: 4px; box-shadow: 0 2px 10px rgba(33,37,41,.12);
  background: var(--paper);
}
.dc-preview.demo { background: var(--paper-dim); }
.dc-demo {
  position: absolute; top: 50%; left: 50%;
  border: 0; transform-origin: center center; pointer-events: none;
  background: var(--paper); box-shadow: 0 1px 6px rgba(33,37,41,.08);
}

.dcard .take-btn {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 7px;
  background: rgba(22,25,29,.9); color: #fff; border: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500; line-height: 1;
  opacity: 0; transform: translateY(-4px); transition: opacity .15s, transform .15s, background .12s;
  backdrop-filter: blur(4px);
}
.dcard .take-btn:hover { background: var(--ink); }
.dcard .take-btn svg { width: 13px; height: 13px; }
.dcard:hover .take-btn, .dcard:focus-within .take-btn { opacity: 1; transform: translateY(0); }

.dc-meta { padding: 14px 15px 15px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.dc-name { font-size: var(--text-body); font-weight: 700; line-height: 1.35; letter-spacing: -.01em; color: var(--ink); }
.dc-title {
  font-size: var(--text-caption); color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.dc-intent {
  font-size: var(--text-caption); color: var(--muted); line-height: 1.55; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dc-foot { display: flex; align-items: center; gap: 7px; margin-top: auto; padding-top: 10px; flex-wrap: wrap; }
.dc-tags { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-right: auto; }
/* タグはチップ装飾を持たない — #tag のプレーンな mono リンク */
.dc-tag {
  font-family: var(--font-mono); font-size: var(--text-micro); color: var(--muted);
  padding: 0; background: none; border: none;
  line-height: 1.6; cursor: pointer;
  transition: color .13s ease;
}
.dc-tag:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.dc-tag:active { transform: translateY(1px); }

.empty {
  text-align: center; padding: 88px 24px; color: var(--muted);
}
.empty[hidden] { display: none; }
.empty .e-ic { width: 46px; height: 46px; margin: 0 auto 16px; color: var(--line-strong); }
.empty h3 { font-size: var(--text-section); font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.empty p { font-size: var(--text-data); margin-bottom: 20px; }
.empty p b { color: var(--ink); font-weight: 600; }

/* ============================================================
   Detail
   ============================================================ */
.detail-wrap { padding-top: 20px; padding-bottom: 80px; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: var(--text-caption); color: var(--muted); margin-bottom: 18px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); font-family: var(--font-mono); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--line-strong); }
.breadcrumb .cur { color: var(--ink); font-family: var(--font-mono); }

.detail-ref { font-family: var(--font-mono); font-size: var(--text-data); color: var(--accent); word-break: break-all; margin-bottom: 8px; }
.detail-title { font-size: var(--text-display); font-weight: 700; line-height: var(--leading-heading); letter-spacing: -.01em; margin-bottom: 14px; max-width: 900px; }
.detail-badges { margin-bottom: 26px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 34px; align-items: start; }
.detail-main { min-width: 0; }
/* keep long-form reading blocks within a comfortable measure on wide screens;
   the preview frame is free to use the full column */
.detail-main .section,
.detail-main .tabs { max-width: 1040px; }

.preview-frame { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); box-shadow: var(--shadow-1); margin-bottom: 30px; }
.preview-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--paper-dim);
}
.preview-dots { display: flex; gap: 6px; }
.preview-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.preview-name { font-family: var(--font-mono); font-size: var(--text-caption); color: var(--muted); }
.preview-name b { color: var(--ink); font-weight: 500; }
.preview-open { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-caption); font-weight: 600; color: var(--accent); }
.preview-open svg { width: 13px; height: 13px; }
.preview-stage {
  position: relative; overflow: hidden; padding: 26px;
  background: var(--paper-dim);
  background-image: linear-gradient(45deg, #eef1f4 25%, transparent 25%, transparent 75%, #eef1f4 75%),
                    linear-gradient(45deg, #eef1f4 25%, transparent 25%, transparent 75%, #eef1f4 75%);
  background-size: 18px 18px; background-position: 0 0, 9px 9px;
  min-height: 260px;
}
.preview-demo {
  position: absolute; top: 50%; left: 50%;
  border: 0; transform-origin: center center; pointer-events: none;
  background: var(--paper); box-shadow: var(--shadow-2); border-radius: 4px;
}

.section { margin-bottom: 30px; }
.section-label { font-size: var(--text-micro); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.section .lead { font-size: var(--text-section); font-weight: 500; line-height: var(--leading-heading); color: var(--ink); }
.guardrails { display: flex; flex-direction: column; gap: 10px; }
.guardrail {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper);
}
.guardrail .g-mark { font-family: var(--font-mono); color: var(--muted); flex: none; font-size: var(--text-data); }
.guardrail span.g-text { font-size: var(--text-data); line-height: var(--leading-data); }
.guardrail b { font-family: var(--font-mono); font-weight: 600; }

/* tabs */
.tabs { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.tab-strip { display: flex; border-bottom: 1px solid var(--line); background: var(--paper-dim); overflow-x: auto; }
.tab-btn {
  padding: 12px 18px; border: none; background: transparent; cursor: pointer;
  font-size: var(--text-data); font-weight: 600; color: var(--muted); position: relative; white-space: nowrap;
  transition: color .12s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--ink); background: var(--paper); }
.tab-btn.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.tab-panel { padding: 22px 22px 24px; display: none; }
.tab-panel.active { display: block; }

/* DESIGN.md source panel */
.md-source { border: 1px solid var(--term-line); border-radius: var(--radius-sm); overflow: hidden; background: var(--term-bg); }
.md-source-head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px; border-bottom: 1px solid var(--term-line); background: var(--term-bar);
}
.md-source-head svg { width: 15px; height: 15px; color: var(--term-dim); flex: none; }
.md-source-head .ms-name { font-family: var(--font-mono); font-size: var(--text-caption); color: var(--term-fg); font-weight: 500; }
.md-source-head .ms-open { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-caption); font-weight: 600; color: #8AB4F8; }
.md-source-head .ms-open:hover { text-decoration: none; opacity: .85; }
.md-source-head .ms-open svg { width: 13px; height: 13px; color: inherit; }
.md-pre {
  margin: 0; padding: 18px 18px 20px; max-height: 460px; overflow: auto;
  font-family: var(--font-mono); font-size: var(--text-caption); line-height: 1.75;
  color: var(--term-str); white-space: pre; tab-size: 2;
}
.md-pre::-webkit-scrollbar { width: 10px; height: 10px; }
.md-pre::-webkit-scrollbar-thumb { background: #333B44; border-radius: 6px; border: 2px solid var(--term-bg); }

.usage-col + .usage-col { margin-top: 20px; }
.usage-col h5 { font-size: var(--text-caption); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 10px; display: flex; align-items: center; gap: 7px; }
.usage-col.do h5 { color: var(--ok); }
.usage-col.dont h5 { color: var(--err); }
.usage-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.usage-list li { display: flex; gap: 10px; align-items: flex-start; font-size: var(--text-data); line-height: var(--leading-data); }
.usage-list li .u-ic { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.usage-col.do .u-ic { color: var(--ok); }
.usage-col.dont .u-ic { color: var(--err); }

.kv-list { display: flex; flex-direction: column; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: none; }
.kv .k { font-family: var(--font-mono); font-size: var(--text-caption); color: var(--muted); letter-spacing: .02em; }
.kv .v { font-family: var(--font-mono); font-size: var(--text-data); color: var(--ink); text-align: right; }
.kv .v.ok { color: var(--ok); }

.file-list { display: flex; flex-direction: column; gap: 2px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; font-family: var(--font-mono); font-size: var(--text-data); }
.file-row:hover { background: var(--paper-dim); }
.file-row svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.file-row .f-tag { margin-left: auto; font-size: var(--text-micro); color: var(--muted); padding: 2px 7px; background: var(--paper-dim); border-radius: 5px; }

.proof-checks { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.check-row { display: flex; gap: 11px; align-items: flex-start; font-size: var(--text-data); line-height: 1.5; }
.check-row .c-ic { flex: none; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.check-row .c-ic.pass { background: var(--ok-soft); color: var(--ok); }
.check-row .c-ic svg { width: 12px; height: 12px; }
.check-row .c-txt b { font-weight: 600; }
.check-row .c-txt .c-meta { color: var(--muted); font-family: var(--font-mono); font-size: var(--text-caption); }

.lineage { display: flex; flex-direction: column; gap: 0; }
.lineage-node { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); }
.lineage-node.current { border-color: var(--accent); background: var(--accent-soft); }
.lineage-node .ln-ref { font-family: var(--font-mono); font-size: var(--text-data); }
.lineage-node .ln-tag { margin-left: auto; font-size: var(--text-micro); font-weight: 600; padding: 2px 8px; border-radius: 12px; }
.lineage-node.current .ln-tag { background: var(--accent); color: #fff; }
.lineage-node.old .ln-tag { background: var(--paper-dim); color: var(--muted); }
.lineage-arrow { display: flex; align-items: center; gap: 8px; padding: 8px 0 8px 18px; color: var(--muted); font-size: var(--text-caption); font-family: var(--font-mono); }
.lineage-arrow svg { width: 16px; height: 16px; }

/* detail rail */
.rail { display: flex; flex-direction: column; gap: 18px; position: sticky; top: calc(var(--header-h) + 20px); min-width: 0; }
.rail-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); overflow: hidden; box-shadow: var(--shadow-1); }

/* call-count hero — the primary signal for a packet */
.rail-hero {
  position: relative; padding: 22px 22px 20px;
  display: flex; flex-direction: column; align-items: flex-start;
  background: var(--ink); border-color: var(--ink); color: var(--paper);
}
.rail-hero .rh-ic { width: 22px; height: 22px; color: rgba(255,255,255,.55); margin-bottom: 10px; }
.rail-hero .rh-ic svg { width: 22px; height: 22px; }
.rail-hero .rh-num {
  font-family: var(--font-mono); font-size: 46px; font-weight: 600; line-height: 1;
  color: var(--paper); font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.rail-hero .rh-lab {
  margin-top: 8px; font-size: var(--text-caption); font-weight: 500;
  letter-spacing: .06em; color: rgba(255,255,255,.7);
}
.rail-card-head { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rail-card-head .rc-title { font-size: var(--text-caption); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.take-card { background: var(--term-bg); border-color: var(--term-line); }
.take-card .rail-card-head { border-color: var(--term-line); }
.take-card .rc-title { color: var(--term-dim); }
.take-card-body { padding: 16px; }
.take-cmd { font-family: var(--font-mono); font-size: var(--text-data); line-height: 1.7; color: var(--term-fg); white-space: pre-wrap; word-break: normal; overflow-wrap: anywhere; }
.take-cmd .cmd { color: #8AB4F8; }
.take-cmd .flag { color: var(--term-dim); }
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 7px; cursor: pointer;
  background: rgba(255,255,255,.08); color: var(--term-fg); border: 1px solid rgba(255,255,255,.14);
  font-family: var(--font-mono); font-size: 12px; font-weight: 500; line-height: 1; transition: background .12s;
}
.copy-btn:hover { background: rgba(255,255,255,.16); }
.copy-btn svg { width: 13px; height: 13px; }

.rail-stats { padding: 6px 16px 10px; }
.rail-stat { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rail-stat:last-child { border-bottom: none; }
.rail-stat .rs-k { font-size: var(--text-caption); color: var(--muted); }
.rail-stat .rs-v { font-family: var(--font-mono); font-size: var(--text-data); color: var(--ink); font-weight: 500; text-align: right; }
.rail-stat .rs-v.big { font-size: var(--text-title); font-weight: 600; }
.rail-states { display: flex; flex-wrap: wrap; gap: 6px; }

/* ============================================================
   CLI terminal
   ============================================================ */
.cli-wrap { padding-top: 26px; padding-bottom: 80px; }
.cli-head { margin-bottom: 20px; }
.cli-kicker { font-family: var(--font-mono); font-size: var(--text-micro); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.cli-head h1 { font-size: var(--text-display); font-weight: 700; letter-spacing: -.01em; line-height: var(--leading-heading); }
.cli-head h1 .arrow { color: var(--muted); font-weight: 400; margin: 0 6px; }

.terminal {
  background: var(--term-bg); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3); overflow: hidden; cursor: text;
  border: 1px solid var(--term-line);
}
.term-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: var(--term-bar); border-bottom: 1px solid var(--term-line); }
.term-dots { display: flex; gap: 7px; }
.term-dots i { width: 11px; height: 11px; border-radius: 50%; background: #3A424C; }
.term-title { font-family: var(--font-mono); font-size: var(--text-caption); color: var(--term-dim); margin-left: 8px; }
.term-title .blink-tag { color: var(--term-dim); }
.term-body {
  padding: 22px 24px 26px; height: 560px; overflow-y: auto;
  font-family: var(--font-mono); font-size: var(--text-data); line-height: 1.75; color: var(--term-fg);
}
.term-body::-webkit-scrollbar { width: 10px; }
.term-body::-webkit-scrollbar-thumb { background: #333B44; border-radius: 6px; border: 2px solid var(--term-bg); }
.term-line { white-space: pre-wrap; word-break: break-word; }
.term-cmd-line { color: var(--term-fg); }
.term-prompt { color: var(--ok); font-weight: 600; }
.term-prompt .host { color: var(--accent); }
.term-cmd { color: var(--term-fg); }
.term-cmd .verb { color: #8AB4F8; }
.term-cmd .arg-str { color: var(--warn); }
.term-cmd .flag { color: var(--term-dim); }
.term-out { color: var(--term-str); }
.j-key { color: #8AB4F8; }
.j-str { color: var(--term-str); }
.j-num { color: #E9ECEF; }
.j-bool-t { color: #56C271; }
.j-bool-f { color: #E06C6C; }
.j-punc { color: var(--term-dim); }
.j-pass { color: #56C271; }
.j-warn { color: #E0A458; }
.j-ref { color: #8AB4F8; }
.cursor { display: inline-block; width: 9px; height: 1.05em; background: var(--term-fg); vertical-align: text-bottom; margin-left: 2px; animation: blink 1.05s steps(1) infinite; border-radius: 1px; }
.cursor.idle { background: var(--ok); }
@keyframes blink { 0%,50%{opacity:1} 50.01%,100%{opacity:0} }
.term-hint-cursor { color: var(--term-dim); }

/* ============================================================
   Responsive — verified at 390 / 768 / 1024 / 1440 / 1920
   Layout ladder:
     ≥1025  sidebar column + detail rail beside content (widest)
     ≤1024  detail rail drops below · catalog sidebar → collapsible panel
     ≤900   header search wraps to row 2
     ≤560   compact nav
     ≤430   phone (390): 1-column cards, tightened terminal / titles
   ============================================================ */

/* let the search flex before things get tight */
@media (max-width: 1120px) {
  .cat-header .container { grid-template-columns: auto minmax(220px, 1fr) auto; }
}

/* ≤1024 — detail rail below content; catalog sidebar becomes a toggle panel */
@media (max-width: 1024px) {
  .container { padding: 0 24px; }

  /* detail: right rail wraps under the main column, full width */
  .detail-grid { grid-template-columns: 1fr; gap: 28px; }
  .rail { position: static; }

  /* catalog: single-column body; sidebar collapses behind 絞り込み toggle */
  .dict-body { grid-template-columns: 1fr; gap: 20px; }
  .dict-side { position: static; display: none; }
  .dict-body.side-open .dict-side { display: block; margin-bottom: 4px; }
  .side-scroll { max-height: none; overflow: visible; padding-right: 0; }
  .side-toggle { display: flex; }
}

/* ≤900 — header search on its own row */
@media (max-width: 900px) {
  .cat-header .container {
    grid-template-columns: auto auto;
    grid-template-areas: "brand right" "search search";
    row-gap: 10px;
  }
  .cat-header .wordmark { grid-area: brand; }
  .cat-header .hdr-right { grid-area: right; }
  .cat-header .hdr-search { grid-area: search; max-width: 100%; }

  .app-nav a { padding: 8px 11px; }
  .detail-title { font-size: var(--text-title); }
  .cli-head h1 { font-size: var(--text-title); }
  .term-body { height: 460px; font-size: 12.5px; }
}

/* ≤560 — phone landscape / tall portrait */
@media (max-width: 560px) {
  .wm-v { display: none; }
  .app-nav { gap: 2px; }
  .app-nav a { padding: 8px 9px; font-size: var(--text-caption); }
  .toast { max-width: calc(100vw - 32px); }
}

/* ≤430 — small phone (390 target) */
@media (max-width: 430px) {
  .container { padding: 0 16px; }
  .card-grid { grid-template-columns: 1fr; }
  .cat-header .container { column-gap: 12px; }
  .cat-header .hdr-search input { height: 40px; }
  .hdr-right { gap: 8px; }
  .app-nav a { padding: 7px 7px; }
  .side-toggle { padding: 10px 14px; }
  .detail-title { font-size: var(--text-section); }
  .cli-head h1 { font-size: var(--text-section); }
  .cli-head h1 .arrow { margin: 0 3px; }
  .term-body { height: 380px; font-size: 11.5px; padding: 16px 14px 18px; }
  .toast { min-width: 0; }
}

/* ============================================================
   API 接続版の追加 (v6 tokens 準拠 — 見た目の発明なし)
   ============================================================ */

/* token gate — 最小の入力画面 (入力 1 つ + 決定。説明文なし) */
.token-gate {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper-dim);
}
.token-gate .token-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
/* 再認証など理由がある時だけ 1 行添える (token 失効) */
.token-gate .token-msg {
  flex-basis: 100%;
  margin: 0;
  font-size: var(--text-caption);
  color: var(--warn);
}
.token-gate input {
  width: 280px; height: 40px;
  padding: 0 14px;
  font-family: var(--font-mono);
  font-size: var(--text-data);
  color: var(--ink);
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.token-gate input::placeholder { color: var(--muted); font-family: var(--font-mono); }
.token-gate input:focus {
  outline: none;
  background: var(--paper);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.token-gate .btn { height: 40px; }

/* 取得件数 < total のときの控えめな残数表示 (fixes.md §C #8/#11) */
.trunc-note {
  margin: 18px 0 0;
  font-size: var(--text-caption);
  color: var(--muted);
  text-align: center;
}
