:root {
  --bg: #f7f7f5;
  --card: #fff;
  --text: #1d1d1f;
  --muted: #5f6368;
  --line: #e2e2de;
  --accent: #1f5fbf;
  --chip: #eef2f8;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151618; --card: #1f2023; --text: #ececec; --muted: #a3a6ab; --line: #34363a; --accent: #7fb0ff; --chip: #2a2f38; }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); overflow-wrap: anywhere; }
button, input, select { font: inherit; color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.site-header, main, .site-footer { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.site-header { padding-top: 24px; }
.site-header h1 { font-size: 1.4rem; margin: 0 0 4px; }
.lead { margin: 0 0 16px; color: var(--muted); font-size: .9rem; }

.controls { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0 12px; border-bottom: 1px solid var(--line); }
.search input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
  font-size: 16px; /* iOS のズーム防止 */
}
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-top: 8px; align-items: end; }
.filters label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 2px; min-width: 0; }
.filters select { width: 100%; max-width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 16px; min-width: 0; }
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--card); padding: 8px 12px; }
button.secondary { color: var(--muted); }
.toggle-filters { display: none; width: 100%; margin-top: 8px; }

.result-count { color: var(--muted); font-size: .9rem; margin: 12px 0 8px; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.card h3 { margin: 0; font-size: 1.05rem; }
.card h3 button { all: unset; cursor: pointer; color: var(--text); overflow-wrap: anywhere; }
.card h3 button:hover, .card h3 button:focus-visible { text-decoration: underline; color: var(--accent); }
.card .oneliner { margin: 0; font-size: .92rem; }
.meta { font-size: .78rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.badge { display: inline-block; padding: 0 8px; border-radius: 999px; background: var(--chip); font-size: .75rem; color: var(--text); }
.status-acquired { background: #fff3d6; color: #6b4b00; }
.status-inactive { background: #eee; color: #666; }
@media (prefers-color-scheme: dark) { .status-acquired { background: #4a3a10; color: #ffe2a3; } .status-inactive { background: #333; color: #bbb; } }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.chips button { padding: 0 8px; border-radius: 999px; border: 0; background: var(--chip); font-size: .75rem; }
.chips button:hover { text-decoration: underline; }
.more { text-align: center; margin: 16px 0 32px; }
.more button { padding: 10px 24px; }
.empty { color: var(--muted); padding: 24px 0; }

dialog {
  width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 48px); border: 1px solid var(--line);
  border-radius: 14px; padding: 0; background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog article { padding: 18px 20px 22px; }
.detail-header { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.detail-header h2 { margin: 0; font-size: 1.3rem; overflow-wrap: anywhere; }
.detail-meta { margin: 0; font-size: .8rem; color: var(--muted); }
.close { font-size: 1.4rem; line-height: 1; padding: 4px 12px; }
.detail-oneliner { font-weight: 600; margin: 12px 0 8px; }
.detail-desc { white-space: pre-line; font-size: .93rem; margin-bottom: 12px; }
.detail-desc.loading { color: var(--muted); }
.detail-fields { display: grid; grid-template-columns: 7.5em 1fr; gap: 6px 12px; margin: 0; font-size: .9rem; }
.detail-fields dt { color: var(--muted); }
.detail-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.site-footer { color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); padding-top: 12px; padding-bottom: 32px; }
.site-footer ul { padding-left: 1.2em; }

@media (max-width: 640px) {
  .site-header h1 { font-size: 1.15rem; }
  .toggle-filters { display: block; }
  .filters { display: none; grid-template-columns: 1fr 1fr; }
  .filters.open { display: grid; }
  .cards { grid-template-columns: 1fr; }
  .detail-fields { grid-template-columns: 1fr; }
  .detail-fields dt { margin-top: 6px; }
  dialog { max-height: calc(100vh - 24px); }
}
