:root {
  color-scheme: dark;
  --bg: #151718;
  --surface: #1d2022;
  --surface-2: #24282b;
  --surface-hover: #282d31;
  --text: #e8e9ea;
  --muted: #a8adb3;
  --faint: #7f878e;
  --border: #343a3f;
  --link: #8db9ff;
  --accent: #9cc2ff;
  --id-normal: #a9c8ff;
  --id-mid: #ffd166;
  --id-high: #ff8b82;
  --reply: #91bcff;
  --focus: #b7d2ff;
  --shadow: 0 8px 30px rgba(0,0,0,.22);
  --body-width: 1120px;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f6;
  --surface: #ffffff;
  --surface-2: #eef1f3;
  --surface-hover: #f5f7f8;
  --text: #1d2329;
  --muted: #59636d;
  --faint: #747e87;
  --border: #d7dde2;
  --link: #245ea8;
  --accent: #245ea8;
  --id-normal: #285f9e;
  --id-mid: #825500;
  --id-high: #b42318;
  --reply: #245ea8;
  --focus: #164f94;
  --shadow: 0 8px 28px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
}
a { color: var(--link); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
.site-shell { width: min(var(--body-width), calc(100% - 28px)); margin: 0 auto; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
}
.topbar-inner { padding: 10px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.nav-link { color: var(--muted); text-decoration: none; font-size: .9rem; }
.nav-link:hover { color: var(--text); }
.spacer { flex: 1 1 auto; }
.control-btn, .seg-btn, .jump-btn, .clear-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 11px;
}
.control-btn:not(:disabled):hover, .seg-btn:not(:disabled):hover, .jump-btn:hover, .clear-btn:hover { background: var(--surface-hover); }
.hero { padding: 25px 0 14px; }
.hero h1 { margin: 0; font-size: clamp(1.3rem, 3vw, 2rem); line-height: 1.35; letter-spacing: .01em; }
.hero-meta { margin-top: 8px; color: var(--muted); font-size: .9rem; }
.toolbar {
  margin: 6px 0 18px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  display: grid;
  gap: 10px;
}
.toolbar-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-wrap { flex: 1 1 340px; }
.search-input, .jump-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
}
.search-input:focus, .jump-input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 20%, transparent);
}
.jump-wrap { display: flex; gap: 7px; flex: 0 1 240px; }
.jump-input { min-width: 0; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg-btn { border: 0; border-radius: 0; padding: 7px 12px; background: transparent; color: var(--muted); }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--surface-2); color: var(--text); font-weight: 650; }
.pager { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.range-label { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 126px; text-align: center; font-size: .9rem; }
.next-thread-guide {
  margin: 8px 0 48px;
  padding: 20px 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 44%, var(--border));
  border-radius: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 13%, var(--surface)), var(--surface));
  box-shadow: 0 16px 42px color-mix(in srgb, #000 18%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.next-thread-guide[hidden] { display: none; }
.next-thread-copy { display: grid; gap: 4px; }
.next-thread-copy strong { font-size: 1.18rem; color: var(--text); }
.next-thread-copy > span:last-child { color: var(--muted); font-size: .9rem; }
.next-thread-kicker { color: var(--accent); font-size: .78rem; font-weight: 700; letter-spacing: .08em; }
.next-thread-link {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 28%, transparent);
}
.next-thread-link:hover { filter: brightness(1.08); }
.next-thread-link:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 36%, transparent); outline-offset: 3px; }
.next-thread-link b { font-size: 1.2em; }
.filter-status { display: none; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.filter-status.show { display: flex; }
.thread { margin: 0; padding: 0; }
.post {
  margin: 0;
  padding: 17px 5px 19px;
  border-top: 1px solid var(--border);
  scroll-margin-top: 76px;
}
.post:last-child { border-bottom: 1px solid var(--border); }
.post:hover { background: color-mix(in srgb, var(--surface-hover) 46%, transparent); }
.post.flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  0% { background: color-mix(in srgb, var(--accent) 20%, transparent); }
  100% { background: transparent; }
}
.post-head { display: flex; gap: 6px 11px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.resno { color: var(--text); text-decoration: none; font-weight: 780; font-size: 1.04rem; font-variant-numeric: tabular-nums; }
.resno:hover { color: var(--link); }
.reply-count {
  border: 1px solid color-mix(in srgb, var(--reply) 42%, var(--border));
  background: color-mix(in srgb, var(--reply) 10%, var(--surface-2));
  color: var(--reply);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .80rem;
  font-weight: 780;
  white-space: nowrap;
}
.reply-count:hover { background: color-mix(in srgb, var(--reply) 17%, var(--surface-2)); }
.author { color: var(--muted); font-weight: 600; overflow-wrap: anywhere; }
.date { color: var(--faint); font-size: .87rem; font-variant-numeric: tabular-nums; }
.id-token {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: .88rem;
  font-weight: 720;
}
.id-token.repeat { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.id-normal { color: var(--id-normal); }
.id-mid { color: var(--id-mid); }
.id-high { color: var(--id-high); font-weight: 820; }
.post-body { margin: 0; padding: 0 8px 0 30px; color: var(--text); overflow-wrap: anywhere; }
.post-body a { text-decoration-thickness: 1px; text-underline-offset: 2px; }
.post-body img { max-width: 100%; height: auto; }
.post-body.long-collapsed { max-height: 24rem; overflow: hidden; position: relative; }
.post-body.long-collapsed::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7rem;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}
.post:hover .post-body.long-collapsed::after {
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--surface-hover) 46%, var(--bg)));
}
.long-toggle { margin: 9px 0 0 30px; border: 0; background: transparent; color: var(--link); padding: 3px 0; }
.reply-tree { margin: 14px 8px 0 30px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.reply-tree-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 8px; }
.tree-close { margin-left: auto; border: 0; background: transparent; color: var(--muted); padding: 2px 4px; }
.tree-node { margin: 7px 0 0; padding: 8px 10px; border-left: 2px solid var(--border); background: color-mix(in srgb, var(--surface-2) 58%, transparent); border-radius: 0 8px 8px 0; }
.tree-node .tree-meta { color: var(--muted); font-size: .84rem; }
.tree-node .tree-excerpt { margin-top: 3px; color: var(--text); font-size: .92rem; white-space: pre-wrap; }
.tree-jump { border: 0; background: transparent; color: var(--link); padding: 0; font-weight: 750; }
.tree-duplicate { color: var(--faint); font-size: .84rem; }
.empty-state { padding: 38px 0; text-align: center; color: var(--muted); }
.hover-preview {
  position: fixed;
  z-index: 80;
  display: none;
  width: min(420px, calc(100vw - 24px));
  max-height: 260px;
  overflow: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 11px 13px;
  pointer-events: none;
  font-size: .9rem;
}
.hover-preview.show { display: block; }
.hover-preview .hp-meta { color: var(--muted); margin-bottom: 5px; font-size: .82rem; }
.runtime-note { margin: 0 0 12px; color: var(--faint); font-size: .8rem; }
.footer { padding: 28px 0 55px; color: var(--faint); text-align: center; font-size: .82rem; }
@media (max-width: 760px) {
  .next-thread-guide { align-items: stretch; flex-direction: column; gap: 16px; padding: 18px; }
  .next-thread-link { justify-content: center; width: 100%; }
  body { font-size: 15px; line-height: 1.68; }
  .site-shell { width: min(100% - 20px, var(--body-width)); }
  .topbar-inner { gap: 8px; }
  .hero { padding-top: 18px; }
  .toolbar { padding: 10px; border-radius: 12px; }
  .pager { width: 100%; margin-left: 0; justify-content: space-between; }
  .range-label { flex: 1; min-width: 0; }
  .post { padding: 14px 1px 16px; }
  .post-head { gap: 5px 8px; }
  .post-body { padding-left: 12px; padding-right: 2px; }
  .long-toggle { margin-left: 12px; }
  .reply-tree { margin-left: 12px; margin-right: 2px; padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .post.flash { animation: none; }
}

.archive-thread-nav {display:flex;flex-wrap:wrap;gap:10px;justify-content:space-between;margin:16px 0;}
.archive-thread-nav a {text-decoration:none;}
.archive-thread-nav [aria-disabled="true"] {opacity:.55;}
