:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #e9ebef;
  --text: #1b1d22;
  --text-2: #5c626c;
  --text-3: #8b9099;
  --line: #dcdfe4;
  --line-2: #c5c9d0;
  --like: #b8323f;
  --like-bg: #fbeaec;
  --high: #8a5a0a;
  --high-bg: #fbeed3;
  --solo: #275f8f;
  --solo-bg: #e2eef9;
  --focus: #2f6fd6;
  --radius: 10px;
  --nav-h: 56px;
  --sidebar-w: 240px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15171b;
  --surface: #1f2227;
  --surface-2: #2a2e35;
  --text: #e8e9ec;
  --text-2: #a4a9b2;
  --text-3: #767b85;
  --line: #2f333a;
  --line-2: #40454e;
  --like: #e46a75;
  --like-bg: #3a2226;
  --high: #f0c06a;
  --high-bg: #3b2f14;
  --solo: #8fc1ee;
  --solo-bg: #1f3244;
  --focus: #7aa7f0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-weight: 500; line-height: 1.35; margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }

/* ---- nav ---- */
.nav {
  position: sticky; top: 0; z-index: 20;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 4px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; text-decoration: none; margin-right: 16px; letter-spacing: .02em; }
.menu { display: flex; gap: 2px; }
.menu a {
  text-decoration: none; font-size: 14px; color: var(--text-2);
  padding: 7px 12px; border-radius: 8px;
}
.menu a:hover { background: var(--surface-2); color: var(--text); }
.menu a[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 500; }
.countdown { font-size: 12px; color: var(--text-3); padding: 7px 4px 7px 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.countdown b { font-weight: 500; color: var(--text-2); }
.nav-right { margin-left: auto; display: flex; gap: 4px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#filterToggle { display: none; }
:root[data-theme="dark"] .ic-sun { display: block; }
:root[data-theme="dark"] .ic-moon { display: none; }
:root[data-theme="light"] .ic-sun { display: none; }
:root[data-theme="light"] .ic-moon { display: block; }

/* ---- layout ---- */
.layout { display: flex; min-height: calc(100vh - var(--nav-h)); }
.sidebar {
  width: var(--sidebar-w); flex: none;
  padding: 18px 18px 28px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
}
.sidebar-head { display: none; }
.main { flex: 1; min-width: 0; padding: 20px 24px 40px; }
.scrim { display: none; }

/* ---- sidebar controls ---- */
.search {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; height: 38px;
  background: var(--bg); margin-bottom: 18px;
}
.search:focus-within { border-color: var(--focus); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--text-3); stroke-width: 2; stroke-linecap: round; }
.search input { border: 0; background: transparent; flex: 1; min-width: 0; font: inherit; color: inherit; outline: none; }
.fs { border: 0; padding: 0; margin: 0 0 16px; }
.fs legend { font-size: 12px; color: var(--text-3); padding: 0; margin-bottom: 6px; }
.fs label { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 3px 0; cursor: pointer; }
.fs input[type="checkbox"], .fs input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--text); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills label { padding: 0; }
.pills input { position: absolute; opacity: 0; width: 0; height: 0; }
.pills span {
  display: inline-block; min-width: 36px; text-align: center; font-size: 13px;
  padding: 4px 8px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--text-2);
}
.pills input:checked + span { background: var(--text); color: var(--surface); border-color: var(--text); }
.pills input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-text { border: 0; background: transparent; color: var(--text-2); font-size: 13px; padding: 4px 0; cursor: pointer; text-decoration: underline; }

/* ---- list header ---- */
.list-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.count { font-size: 14px; color: var(--text-2); }
.sort { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.sort select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 6px 10px;
}

/* ---- cards ---- */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
@media (max-width: 1500px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1150px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px)  { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }

.card {
  display: block; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.card:hover { border-color: var(--line-2); }
.card:hover .thumb img { transform: scale(1.03); }
.thumb {
  position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.thumb .noimg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 12px; }
.badge-high {
  position: absolute; top: 8px; left: 8px;
  font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 999px;
  background: var(--high-bg); color: var(--high);
}
.card-body { padding: 10px 12px 12px; }
.card-title {
  font-size: 14px; font-weight: 500; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.8em;
}
.card-author { font-size: 12px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.stars { color: var(--text); letter-spacing: -.02em; }
.stars .off { color: var(--line-2); }
.scale { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.scale i { display: block; width: 4px; background: var(--line-2); border-radius: 1px; }
.scale i.on { background: var(--text); }
.card-tags { display: flex; gap: 6px; align-items: center; margin-top: 8px; font-size: 12px; }
.tag { padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.tag-solo { background: var(--solo-bg); color: var(--solo); }
.likes { margin-left: auto; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }
.likes svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.likes.on { color: var(--like); }
.likes.on svg { fill: currentColor; }

.empty { padding: 60px 0; text-align: center; color: var(--text-2); }
.empty button { margin-top: 12px; }

/* ---- detail ---- */
.detail { max-width: 960px; }
.back {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; margin-bottom: 18px;
  font-size: 14px; text-decoration: none;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px;
}
.back:hover { background: var(--surface-2); border-color: var(--text-3); }
.back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); gap: 28px; align-items: start; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr; gap: 20px; } }
.detail .thumb { border-radius: var(--radius); border: 1px solid var(--line); }
.detail h1 { font-size: 22px; overflow-wrap: anywhere; }
.detail .author { color: var(--text-2); margin-top: 4px; font-size: 14px; }
.comment {
  margin: 16px 0 0; padding: 10px 14px 12px; font-size: 14px; line-height: 1.7;
  background: var(--surface-2); border-radius: 8px; border-left: 3px solid var(--line-2);
}
.comment-label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.comment p { margin: 0; }
.spec { margin-top: 20px; border-top: 1px solid var(--line); }
.spec div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.spec dt { color: var(--text-2); margin: 0; }
.spec dd { margin: 0; text-align: right; }
.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.btn-primary, .btn-like {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--text); color: var(--surface); border: 1px solid var(--text); }
.btn-primary:hover { opacity: .9; }
.btn-primary svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-like { background: var(--surface); border: 1.5px solid var(--like); color: var(--like); }
.btn-like:hover { background: var(--like-bg); }
.btn-like svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.btn-like.on { background: var(--like); border-color: var(--like); color: #fff; }
.btn-like.on:hover { opacity: .9; }
.btn-like.on svg { fill: currentColor; }
.btn-like.on.pop svg { animation: heart-pop .32s ease-out; }
:root[data-theme="dark"] .btn-like.on { color: #1b1d22; }
.btn-like:disabled { cursor: default; opacity: .6; }
@keyframes heart-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  70% { transform: scale(.92); }
  100% { transform: scale(1); }
}
.note { font-size: 12px; color: var(--text-3); margin-top: 10px; }

/* ---- prose pages ---- */
.prose { max-width: 720px; font-size: 15px; }
.prose h1 { font-size: 24px; margin-bottom: 16px; }
.prose h2 { font-size: 17px; margin: 24px 0 8px; }
.prose p { margin: 8px 0; }
.prose ul { padding-left: 20px; margin: 8px 0; }
.prose li { margin: 4px 0; }
.prose strong { font-weight: 500; }

/* ---- footer ---- */
.foot {
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between;
  padding: 16px 24px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3);
}
.foot a { color: var(--text-2); }

/* ---- intro overlay ---- */
.intro {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.intro-box {
  background: var(--surface); border-radius: 14px; padding: 32px 36px 28px;
  max-width: 1080px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.intro-box h1 { font-size: 22px; margin-bottom: 12px; }
.intro-box h2 { font-size: 16px; margin: 20px 0 6px; }
.intro-box p, .intro-box li { font-size: 14px; line-height: 1.75; }
.intro-box p { margin: 6px 0; }
.intro-box ul { padding-left: 20px; margin: 6px 0; }
.intro-box strong { font-weight: 500; }
.intro-box .btn-primary { margin-top: 20px; }

/* ---- mobile ---- */
@media (max-width: 860px) {
  /* ナビ：1行目タイトル（中央）、2行目メニュー（中央）。テーマ切替は右上に固定 */
  .nav {
    height: auto; flex-wrap: wrap; justify-content: center; gap: 4px;
    padding: 10px 52px 8px; position: sticky;
  }
  .brand { width: 100%; text-align: center; margin: 0; font-size: 16px; line-height: 1.3; }
  .menu { width: 100%; justify-content: center; }
  .menu a { padding: 6px 10px; font-size: 13px; }
  .countdown { display: none; }
  .nav-right { position: absolute; top: 6px; right: 8px; margin: 0; }
  /* 絞り込みボタン：一覧ページでのみ左下に固定表示 */
  #filterToggle {
    display: none;
    position: fixed; left: 14px; bottom: 14px; z-index: 25;
    width: 52px; height: 52px; border-radius: 999px;
    background: var(--text); color: var(--surface);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  }
  #filterToggle:hover { background: var(--text); color: var(--surface); }
  #filterToggle svg { width: 22px; height: 22px; }
  body.is-home #filterToggle { display: inline-flex; }
  .main { padding: 16px 14px 90px; }
  .intro { padding: 12px; }
  .intro-box { padding: 22px 18px 20px; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 40;
    transform: translateX(-100%); transition: transform .2s ease;
    width: min(320px, 88vw); padding-top: 14px;
  }
  .sidebar.open { transform: none; }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; font-weight: 500; margin-bottom: 12px; }
  .scrim { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.4); }
  .scrim.show { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .thumb img, .sidebar { transition: none; }
  .btn-like.on.pop svg { animation: none; }
}
