* { box-sizing: border-box; margin: 0; }
:root {
  --accent: #e0524d;
  --ink: #1f2937;
  --sub: #6b7280;
  --line: #e5e7eb;
  --bg: #fafaf7;
  /* モバイルでヘッダ上段だけスクロールアウトさせるための固定高 */
  --header-top-h: 54px;
  --gutter: 16px;
}
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 130px; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: rgba(224, 82, 77, .15);
  overflow-wrap: anywhere;
}
.wrap {
  max-width: 1080px; margin: 0 auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ── ヘッダ ───────────────────────────── */
.site-header {
  background: #fff; border-bottom: 1px solid var(--line);
  padding-top: 18px; position: sticky; top: 0; z-index: 10;
}
.header-top { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; row-gap: 2px; }
.logo { display: flex; align-items: baseline; gap: 8px; font-size: 22px; letter-spacing: .04em; }
.logo-mark { flex: none; align-self: center; }
.logo-name { flex: none; }
.logo-sub { font-size: 12.5px; font-weight: 400; color: var(--sub); letter-spacing: 0; }
.logo-sub::before { content: "／"; margin-right: 2px; color: var(--line); }
.tagline { color: var(--sub); font-size: 12.5px; }

.search-row { display: flex; gap: 8px; margin-top: 12px; }
#search {
  flex: 1; min-width: 0; font-size: 16px; /* 16px未満だと iOS で自動ズームする */
  padding: 10px 14px; border: 2px solid var(--line); border-radius: 10px;
  outline: none; background: #fff; color: var(--ink); -webkit-appearance: none; appearance: none;
}
#search:focus { border-color: var(--accent); }
#category {
  font-size: 16px; padding: 8px; border: 2px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); max-width: 220px; min-height: 44px;
}
.style-tabs {
  display: flex; gap: 4px; margin-top: 10px; padding-bottom: 10px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.style-tabs::-webkit-scrollbar { display: none; }
.style-tabs button {
  flex: none; font-size: 13px; padding: 8px 14px; min-height: 36px;
  border: none; background: none; border-radius: 999px; cursor: pointer; color: var(--sub);
}
.style-tabs button.active { background: var(--ink); color: #fff; }

/* ── 一覧 ─────────────────────────────── */
.status { color: var(--sub); font-size: 13px; padding: 14px 2px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; padding-bottom: 24px; }
.card {
  display: block; width: 100%; font: inherit; color: inherit;
  -webkit-appearance: none; appearance: none;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 6px 8px; text-align: center; cursor: pointer;
  transition: border-color .1s, transform .1s;
}
.card:focus-visible, #more:focus-visible, .style-tabs button:focus-visible,
.dl-buttons button:focus-visible, .close:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
@media (hover: hover) {
  .card:hover { border-color: var(--accent); transform: translateY(-2px); }
}
.card:active { border-color: var(--accent); }
.card svg { width: 40px; height: 40px; color: var(--ink); }
.card .nm { display: block; font-size: 10.5px; color: var(--sub); margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .badge { display: inline-block; font-size: 9px; color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-top: 4px; }
.more-row { text-align: center; padding-bottom: 40px; }
#more { font-size: 14px; padding: 12px 32px; min-height: 44px; border: 2px solid var(--ink); background: #fff; border-radius: 999px; cursor: pointer; }
@media (hover: hover) { #more:hover { background: var(--ink); color: #fff; } }
.noscript-note { font-size: 13px; color: var(--sub); line-height: 1.9; padding: 8px 0 32px; }

/* ── モーダル ─────────────────────────── */
/* 冒頭の `* { margin: 0 }` で UA の `dialog { margin: auto }` が消えるため明示的に戻す(中央寄せ) */
dialog#modal { margin: auto; border: none; border-radius: 16px; padding: 0; max-width: 560px; width: calc(100vw - 32px); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.close {
  position: absolute; top: 4px; right: 6px; width: 44px; height: 44px;
  font-size: 22px; line-height: 1; border: none; background: none; cursor: pointer; color: var(--sub);
}
.modal-body { display: flex; gap: 20px; padding: 24px; flex-wrap: wrap; }
.preview-col { flex: 0 0 220px; }
.preview {
  width: 220px; height: 220px; max-width: 100%;
  background: repeating-conic-gradient(#f3f4f6 0 25%, #fff 0 50%) 0 0 / 20px 20px;
  border: 1px solid var(--line); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.preview svg { width: 170px; height: 170px; }
.controls { display: flex; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--sub); align-items: center; flex-wrap: wrap; }
.controls label { display: flex; align-items: center; gap: 6px; }
.controls input[type="color"] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.controls select { font-size: 16px; padding: 6px; min-height: 36px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
.info-col { flex: 1; min-width: 200px; }
.info-col h2 { font-size: 18px; }
.tags { font-size: 12px; color: var(--sub); margin: 8px 0 16px; line-height: 1.8; }
.dl-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.dl-buttons button {
  flex: 1 1 auto; min-width: 72px; min-height: 44px;
  font-size: 14px; font-weight: 600; padding: 10px 20px;
  border: none; border-radius: 10px; background: var(--accent); color: #fff; cursor: pointer;
}
@media (hover: hover) { .dl-buttons button:hover { opacity: .85; } }
.dl-buttons button.ghost { flex-basis: 100%; background: #fff; color: var(--ink); border: 2px solid var(--line); font-weight: 400; }
.license-note { font-size: 11.5px; color: var(--sub); margin-top: 14px; }

/* ── フッタ ───────────────────────────── */
.site-footer {
  background: #fff; border-top: 1px solid var(--line); margin-top: 20px;
  padding: 28px 0 calc(48px + env(safe-area-inset-bottom));
}
.footer-sec { margin-bottom: 24px; }
.site-footer h2 { font-size: 15px; margin-bottom: 8px; }
.site-footer p { font-size: 12.5px; color: var(--sub); line-height: 1.9; margin-bottom: 8px; }
.site-footer a { color: var(--accent); }
.faq dt { font-size: 13px; font-weight: 600; margin-top: 12px; }
.faq dd { font-size: 12.5px; color: var(--sub); line-height: 1.9; margin: 4px 0 0; }
.copyright { font-size: 11.5px; color: var(--sub); border-top: 1px solid var(--line); padding-top: 16px; }

/* ── スマホ ───────────────────────────── */
@media (max-width: 640px) {
  :root { --gutter: 12px; }
  html { scroll-padding-top: 108px; }
  /* 上段(ロゴ+説明)はスクロールで隠し、検索とタブだけを画面上部に固定する */
  .site-header { top: calc(-1 * var(--header-top-h)); padding-top: 0; }
  .header-top { height: var(--header-top-h); align-content: center; overflow: hidden; }
  .logo { font-size: 19px; gap: 6px; }
  .logo-mark { width: 24px; height: 24px; }
  .logo-sub { font-size: 11px; }
  .tagline { font-size: 11px; flex-basis: 100%; }
  /* 固定領域を低く保つため、検索とカテゴリは1行に収める */
  .search-row { margin-top: 8px; gap: 6px; }
  #search { padding: 11px 12px; }
  #category { flex: 0 0 116px; width: 116px; max-width: none; font-size: 13px; padding: 6px 4px; }
  .style-tabs { margin-top: 8px; padding-bottom: 8px; }
  .status { padding: 10px 2px; font-size: 12.5px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
  .card { padding: 12px 4px 6px; border-radius: 10px; }
  .card svg { width: 34px; height: 34px; }
  .card .nm { font-size: 10px; }

  /* モーダルはボトムシート化(親指が届く位置にボタンを置く) */
  dialog#modal {
    width: 100%; max-width: none; margin: auto 0 0;
    max-height: 88dvh; border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-body { flex-direction: column; gap: 16px; padding: 20px 16px 24px; flex-wrap: nowrap; }
  .preview-col { flex: none; align-self: center; width: 100%; max-width: 260px; }
  .preview { width: 100%; aspect-ratio: 1; height: auto; }
  .preview svg { width: 62%; height: 62%; }
  .controls { justify-content: center; }
  .info-col { min-width: 0; }
  .info-col h2 { font-size: 16px; }
  /* line-height(1.8)の整数倍にして、行の途中で切れないようにする */
  .tags { margin-bottom: 12px; max-height: 5.4em; overflow-y: auto; }
  .site-footer { padding-top: 24px; }
}

@media (max-width: 360px) {
  :root { --header-top-h: 62px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .logo-sub { display: none; }
  .logo { font-size: 18px; }
  #category { flex-basis: 104px; width: 104px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ── 2言語表示 ────────────────────────────────
   同じ HTML に日英を持たせ、html[lang] で出し分ける。
   既定は日本語なので、英語ブロックは初期状態で隠す。 */
[data-l="en"] { display: none; }
html[lang="en"] [data-l="en"] { display: revert; }
html[lang="en"] [data-l="ja"] { display: none; }

.lang-toggle {
  margin-left: auto; flex: none; align-self: center;
  font-size: 12px; line-height: 1; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--sub); cursor: pointer;
}
.lang-toggle:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 640px) {
  /* ヘッダ上段は高さ固定でクリップされるので、切り替えボタンを1行目(ロゴの右)に置く。
     並びは ロゴ → 切り替え → キャッチコピー(flex-basis:100% で必ず改行)。 */
  .lang-toggle { font-size: 11px; padding: 5px 10px; order: 2; }
  .tagline { order: 3; }
}
