/* 夜ふかしガイド｜同人 — 深夜の読書灯をモチーフにしたライブラリUI */
:root {
  --bg: #12141f;
  --panel: #1a1d2c;
  --panel2: #242839;
  --line: #333852;
  --text: #f2f3f9;
  --mut: #b0b6cd;
  --lamp: #f6cf85;
  --lamp-ink: #2a1f06;
  --lamp-soft: rgba(246, 207, 133, .16);
  --shadow: 0 8px 24px rgba(0, 0, 0, .28);
  --radius: 14px;
  --side: 232px;
  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f1f3f8;
  --panel: #ffffff;
  --panel2: #e9ecf4;
  --line: #d6dbe8;
  --text: #1b1e2b;
  --mut: #566078;
  --lamp: #9a5a06;
  --lamp-ink: #ffffff;
  --lamp-soft: rgba(154, 90, 6, .10);
  --shadow: 0 6px 20px rgba(40, 48, 80, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); gap: 20px; padding: 16px; max-width: 1760px; margin: 0 auto; }
.side {
  position: sticky; top: 16px; align-self: start; height: calc(100vh - 32px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px 12px 12px; display: flex; flex-direction: column; overflow: hidden;
}
.side-scroll { overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px 8px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; font-weight: 700; letter-spacing: .02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 50%; background: var(--lamp); box-shadow: inset -9px -3px 0 0 var(--panel), 0 0 18px var(--lamp-soft); flex: none; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--mut); letter-spacing: .06em; line-height: 1.3; }
.nav a, .nav-sub a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: 10px; color: var(--mut); font-size: 15px; line-height: 1.4;
}
.nav a:hover, .nav-sub a:hover { background: var(--panel2); color: var(--text); }
.nav a[aria-current="page"], .nav-sub a[aria-current="page"] { background: var(--lamp-soft); color: var(--lamp); font-weight: 700; }
.nav-title { margin: 18px 10px 4px; font-size: 13px; color: var(--mut); font-weight: 700; }
.nav-sub a { font-size: 14px; padding: 7px 10px; }
.nav-sub .n { font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }
.side-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-foot a { font-size: 12px; color: var(--mut); padding: 6px 8px; border-radius: 8px; }
.side-foot a:hover { color: var(--text); background: var(--panel2); }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--mut); border: 1px solid var(--line); background: var(--panel); }
.icon-btn:hover { color: var(--text); background: var(--panel2); }
.icon-btn svg { width: 18px; height: 18px; }

.main { min-width: 0; }
.scrim { display: none; }
.topbar { display: flex; gap: 10px; align-items: center; position: sticky; top: 16px; z-index: 20; margin-bottom: 18px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.search:focus-within { border-color: var(--lamp); }
.search svg { width: 18px; height: 18px; color: var(--mut); flex: none; }
.search input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: 0; color: var(--text); font: inherit; font-size: 15px; }
.search input::placeholder { color: var(--mut); }
.search kbd { font: 11px/1 var(--font); color: var(--mut); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
#menu { display: none; }
.pr-note { font-size: 13px; color: var(--mut); margin: 0 0 14px; }
.sample-ribbon { background: var(--lamp-soft); color: var(--lamp); border: 1px dashed var(--lamp); border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 14px; }

/* ---------- list page ---------- */
.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 900; letter-spacing: .01em; }
.page-head .count { color: var(--mut); font-size: 13px; font-variant-numeric: tabular-nums; }
.notice { font-size: 13px; color: var(--mut); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 0 0 14px; }

.circle-row { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 10px; scrollbar-width: none; }
.circle-row::-webkit-scrollbar { display: none; }
.cir { flex: none; width: 66px; text-align: center; }
.cir .av {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 4px; display: grid; place-items: center;
  font-weight: 900; font-size: 20px; color: #fff; border: 2px solid transparent;
  background: linear-gradient(150deg, hsl(var(--h) 50% 42%), hsl(calc(var(--h) + 40) 55% 26%));
}
.cir span { display: block; font-size: 12px; color: var(--mut); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cir[aria-pressed="true"] .av { border-color: var(--lamp); box-shadow: 0 0 0 3px var(--lamp-soft); }
.cir[aria-pressed="true"] span { color: var(--lamp); font-weight: 700; }

.filters { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 999px;
  background: var(--panel2); color: var(--text); font-size: 14px; border: 1px solid transparent; white-space: nowrap;
}
.chip:hover { color: var(--text); }
.chip .n { font-size: 12px; color: var(--mut); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--lamp); color: var(--lamp-ink); font-weight: 700; }
.chips.more-hidden .chip.extra { display: none; }
.chip.more { background: transparent; border-color: var(--line); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.toolbar .grow { flex: 1; }
.seg { display: inline-flex; background: var(--panel2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { height: 28px; padding: 0 10px; border-radius: 8px; font-size: 13px; color: var(--mut); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--text); font-weight: 700; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.sort { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--mut); }
.sort select { height: 32px; border-radius: 9px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); padding: 0 8px; font: inherit; font-size: 13px; }

.grid { display: grid; gap: 18px 14px; grid-template-columns: repeat(auto-fill, minmax(var(--card, 170px), 1fr)); }
.grid[data-size="s"] { --card: 132px; }
.grid[data-size="m"] { --card: 170px; }
.grid[data-size="l"] { --card: 230px; }
.card { position: relative; min-width: 0; }
.cover { position: relative; display: block; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: var(--panel2); box-shadow: var(--shadow); transition: transform .18s ease; }
.cover:hover { transform: translateY(-3px); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.ph {
  width: 100%; height: 100%; display: flex; align-items: flex-end; padding: 12px;
  background: linear-gradient(160deg, hsl(var(--h) 46% 34%), hsl(calc(var(--h) + 45) 52% 17%));
}
.ph span { font-weight: 900; font-size: 15px; line-height: 1.35; color: rgba(255, 255, 255, .92); text-shadow: 0 1px 8px rgba(0, 0, 0, .4); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.badge {
  position: absolute; left: 8px; top: 8px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 8px;
  background: var(--lamp); color: var(--lamp-ink); font-weight: 900; font-size: 14px; display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.fav { position: absolute; right: 8px; top: 8px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(10, 11, 20, .62); color: #fff; backdrop-filter: blur(6px); }
.fav svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; }
.fav[aria-pressed="true"] { color: var(--lamp); }
.fav[aria-pressed="true"] svg { fill: currentColor; }
.meta { padding: 8px 2px 0; }
.meta .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 700; font-size: 15px; line-height: 1.45; }
.meta .t:hover { color: var(--lamp); }
.meta .c { display: block; max-width: 100%; text-align: left; margin-top: 2px; font-size: 13px; color: var(--mut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .c:hover { color: var(--text); }
.meta .sub { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; font-size: 13px; color: var(--mut); font-variant-numeric: tabular-nums; }
.meta .sub b { color: var(--text); font-weight: 700; }
.empty { grid-column: 1 / -1; text-align: center; padding: 56px 16px; color: var(--mut); }
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.more-btn { display: block; margin: 26px auto 8px; padding: 0 28px; height: 44px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font-weight: 700; }
.more-btn:hover { border-color: var(--lamp); color: var(--lamp); }

/* ---------- detail page ---------- */
.crumb { font-size: 13px; color: var(--mut); margin-bottom: 14px; }
.crumb a:hover { color: var(--lamp); }
.detail { display: grid; grid-template-columns: minmax(220px, 340px) minmax(0, 1fr); gap: 28px; align-items: start; }
.detail .cover-lg { aspect-ratio: 3 / 4; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); background: var(--panel2); }
.detail .cover-lg img { width: 100%; height: 100%; object-fit: cover; }
.detail h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.35; font-weight: 900; }
.by { color: var(--mut); margin: 0 0 14px; }
.by a { color: var(--text); border-bottom: 1px solid var(--line); }
.by a:hover { color: var(--lamp); border-color: var(--lamp); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 16px 0; }
.facts div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.facts dt { font-size: 12px; color: var(--mut); }
.facts dd { margin: 0; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.cta {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 10px 22px;
  border-radius: 14px; background: var(--lamp); color: var(--lamp-ink); font-weight: 900; font-size: 16px; box-shadow: 0 10px 28px var(--lamp-soft);
}
.cta:hover { filter: brightness(1.06); }
.cta-note { font-size: 12px; color: var(--mut); margin: 8px 0 0; }
.sec { margin: 34px 0 12px; font-size: 18px; font-weight: 900; }
.samples { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.samples button { aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; background: var(--panel2); border: 1px solid var(--line); }
.samples img { width: 100%; height: 100%; object-fit: cover; }
dialog.lightbox { border: 0; padding: 0; background: transparent; max-width: 94vw; max-height: 94vh; }
dialog.lightbox::backdrop { background: rgba(5, 6, 12, .86); }
dialog.lightbox img { max-height: 90vh; border-radius: 10px; }

/* ---------- age gate ---------- */
.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(6, 7, 14, .94); backdrop-filter: blur(10px); }
.gate-box { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px; text-align: center; }
.gate-box h2 { margin: 0 0 8px; font-size: 22px; }
.gate-box p { margin: 0 0 20px; color: var(--mut); font-size: 14px; }
.gate-box .row { display: grid; gap: 8px; }
.gate-box .yes { height: 48px; border-radius: 12px; background: var(--lamp); color: var(--lamp-ink); font-weight: 900; }
.gate-box .no { height: 44px; border-radius: 12px; border: 1px solid var(--line); color: var(--mut); }

.foot { margin: 48px 0 12px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--mut); font-size: 12px; line-height: 1.8; }

/* ---------- mobile ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; padding: 12px; gap: 0; }
  .side { position: fixed; z-index: 60; left: 10px; top: 10px; bottom: 10px; width: min(300px, calc(100vw - 20px)); height: auto; transform: translateX(-110%); transition: transform .22s ease; box-shadow: var(--shadow); }
  body.drawer .side { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(5, 6, 12, .6); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.drawer .scrim { opacity: 1; pointer-events: auto; }
  #menu { display: inline-grid; }
  .topbar { top: 10px; }
  .search kbd { display: none; }
  .page-head h1 { font-size: 23px; }
  .detail { grid-template-columns: 1fr; gap: 18px; }
  .detail .cover-lg { max-width: 300px; }
  .grid[data-size="m"] { --card: 144px; }
  .grid[data-size="l"] { --card: 200px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- 好み診断 ---------- */
.diag-cta { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--lamp); border: 1px solid var(--lamp); border-radius: 999px; padding: 4px 14px; }
.diag-cta:hover { background: var(--lamp-soft); }
.diag { max-width: 820px; }
.diag-title { margin: 0 0 6px; font-size: 28px; font-weight: 900; line-height: 1.2; }
.diag-progress { height: 6px; border-radius: 99px; background: var(--panel2); overflow: hidden; margin: 18px 0 14px; }
.diag-progress span { display: block; height: 100%; background: var(--lamp); border-radius: 99px; transition: width .25s ease; }
.diag-step { margin: 0; font-size: 13px; color: var(--mut); }
.diag-q { margin: 4px 0 16px; font-size: 22px; line-height: 1.4; font-weight: 900; }
.diag-opts { display: grid; gap: 10px; }
.diag-opt {
  text-align: left; padding: 14px 18px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line);
  font-size: 16px; font-weight: 700; transition: border-color .15s, background .15s;
}
.diag-opt:hover { border-color: var(--lamp); background: var(--lamp-soft); }
.diag-opt.skip { color: var(--mut); font-weight: 500; background: transparent; }
.diag-back { margin-top: 16px; color: var(--mut); font-size: 14px; }
.diag-back:hover { color: var(--text); }
.diag-actions { display: grid; gap: 10px; margin-top: 24px; max-width: 420px; }
.diag-btn { display: flex; justify-content: center; align-items: center; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-weight: 700; }
.diag-btn:hover { border-color: var(--lamp); color: var(--lamp); }
.why { margin: 4px 0 0; font-size: 12px; color: var(--lamp); }
.diag .grid { margin-top: 6px; }

/* ---------- ホーム(入口) ---------- */
.hero2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; margin: 4px 0 8px; }
.pick { display: flex; gap: 16px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.pick:hover { border-color: var(--lamp); }
.pick-cover { width: 110px; aspect-ratio: 3 / 4; flex: none; border-radius: 10px; overflow: hidden; background: var(--panel2); }
.pick-cover img { width: 100%; height: 100%; object-fit: cover; }
.pick-body { min-width: 0; display: grid; gap: 2px; }
.pick-label { font-size: 13px; font-weight: 700; color: var(--lamp); }
.pick-body strong { font-size: 18px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pick-body span { font-size: 13px; color: var(--mut); }
.pick-body .pick-label { color: var(--lamp); }
.pick-go { margin-top: 6px; font-weight: 700; color: var(--lamp) !important; }
.hero-side { display: grid; gap: 10px; align-content: stretch; }
.diag-big { display: flex; flex-direction: column; justify-content: center; gap: 4px; background: var(--lamp); color: var(--lamp-ink); border-radius: 18px; padding: 18px 20px; box-shadow: 0 8px 24px var(--lamp-soft); }
.diag-big:hover { filter: brightness(1.06); }
.diag-big strong { font-size: 20px; line-height: 1.3; }
.diag-big span { font-size: 14px; opacity: .85; }
.updated { margin: 0; font-size: 13px; color: var(--mut); }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 0 8px; }
.sec-head h2 { margin: 0; font-size: 19px; font-weight: 900; }
.sec-head a { font-size: 14px; color: var(--lamp); font-weight: 700; }
.rail { display: flex; gap: 14px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.rcard { flex: 0 0 148px; scroll-snap-align: start; min-width: 0; }
.rc-cover { position: relative; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: var(--panel2); box-shadow: var(--shadow); }
.rc-cover img { width: 100%; height: 100%; object-fit: cover; }
.rcard:hover .rc-cover { outline: 2px solid var(--lamp); }
.rc-t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 6px; font-size: 14px; font-weight: 700; line-height: 1.45; }
.rc-sub { display: block; font-size: 13px; color: var(--mut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-badge { position: absolute; left: 8px; top: 8px; background: #e5484d; color: #fff; font-size: 11px; font-weight: 900; padding: 2px 8px; border-radius: 6px; letter-spacing: .04em; }
.rank-no { position: absolute; left: 8px; top: 8px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 8px; background: var(--lamp); color: var(--lamp-ink); font-weight: 900; font-size: 13px; display: grid; place-items: center; }
.follow-hint { font-size: 14px; color: var(--mut); background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; }
.lib-head { margin-top: 28px; }
.x-link { display: block; margin: 14px 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; text-align: center; color: var(--text); }
.x-link:hover { border-color: var(--lamp); color: var(--lamp); }
@media (max-width: 960px) {
  .hero2 { grid-template-columns: 1fr; }
  .pick-cover { width: 92px; }
  .rcard { flex-basis: 132px; }
}
