:root {
  --bg: #f6f4ef;
  --surface: #fff;
  --text: #24222e;
  --muted: #6d6a7a;
  --line: #e2ded4;
  --accent: #3d3a8c;
  --accent-text: #fff;
  --accent-soft: #ecebf8;
  --gold: #c8922b;
  --danger: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(30 25 60 / 6%), 0 2px 8px rgb(30 25 60 / 5%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15141c;
    --surface: #1f1e29;
    --text: #e9e7f0;
    --muted: #a09db0;
    --line: #34323f;
    --accent: #a9a5ff;
    --accent-text: #15141c;
    --accent-soft: #2a2942;
    --gold: #e0b252;
    --danger: #ff8a80;
    --shadow: none;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 12px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.75 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  overflow-wrap: anywhere;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 1.4rem; line-height: 1.4; margin: 18px 0 10px; }
h2 { font-size: 1.1rem; line-height: 1.4; margin: 28px 0 10px; }
h1 small, h2 small { font-size: .8em; font-weight: 500; color: var(--muted); margin-left: .25em; }
small { font-size: .82em; }
.wrap { width: min(100% - 32px, 820px); margin-inline: auto; }
.muted, .lead { color: var(--muted); }
.lead { margin: 0 0 16px; }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.inline { display: inline; }
.empty { color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 22px 16px; text-align: center; }

/* ヘッダー */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; }
.logo { font-weight: 700; font-size: clamp(.9rem, 4.2vw, 1.1rem); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 6px; }
.logo-mark { color: var(--gold); font-size: 1.3em; line-height: 1; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 8px 12px; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 3px solid transparent; font-weight: 600; font-size: .92rem; }
.nav a:hover { color: var(--accent); border-color: var(--accent); }
.site-footer { margin-top: 48px; border-top: 1px solid var(--line); padding: 20px 0 32px; color: var(--muted); font-size: .85rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-footer p { margin: 8px 0 0; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 18px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.12); color: var(--accent-text); }
.btn-danger { color: var(--danger); }
.btn-sm { min-height: 36px; padding: 4px 14px; font-size: .88rem; white-space: nowrap; flex: none; }

/* トップ */
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 18px; margin-top: 18px; }
.hero h1 { margin: 0 0 6px; font-size: 1.35rem; }
.hero p { margin: 0 0 14px; color: var(--muted); }
.search-form { display: flex; gap: 8px; }
.search-form input { flex: 1; min-width: 0; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 10px; }
.list-head h2 { margin: 0; }
.tabs, .sorts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.tabs a { padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: .9rem; font-weight: 600; }
.tabs a[aria-current], .tabs a:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.sorts { font-size: .88rem; gap: 14px; }
.sorts a { color: var(--muted); text-decoration: none; }
.sorts a[aria-current] { color: var(--text); font-weight: 700; text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; }

/* スレッド一覧 */
.thread-list, .hit-list, .company-grid { list-style: none; margin: 0; padding: 0; }
.thread-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.thread-list li + li { border-top: 1px solid var(--line); }
.thread-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--text); text-decoration: none; }
.thread-item:hover { background: var(--accent-soft); }
.thread-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.thread-title { font-weight: 700; line-height: 1.5; }
.thread-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; color: var(--muted); font-size: .82rem; }
.thread-count { text-align: center; line-height: 1.2; min-width: 3em; }
.thread-count b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.thread-count small { color: var(--muted); font-size: .7rem; }
.rank { flex: none; width: 2em; height: 2em; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); font-weight: 700; font-variant-numeric: tabular-nums; }
.thread-list li:nth-child(-n+3) .rank { background: var(--gold); color: #fff; }
.badge { display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 4px; font-size: .72rem; font-weight: 700; vertical-align: 2px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge-company { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); }
.badge-talk { background: var(--line); color: var(--muted); }
.badge-st-open { background: color-mix(in srgb, #2e7d32 16%, transparent); color: #2e7d32; }
.badge-st-locked { background: var(--line); color: var(--muted); }
.badge-st-hidden { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.alert-notice { font-weight: 600; }
.badge-lock { margin-left: 6px; background: var(--line); color: var(--muted); }

/* 星 */
.stars { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.stars-none { color: var(--muted); font-size: .82rem; }
.stars-bar { position: relative; display: inline-block; font-size: .95em; line-height: 1; letter-spacing: 1px; }
.stars-bar::before { content: "★★★★★"; color: var(--line); }
.stars-bar span { position: absolute; inset: 0 auto 0 0; overflow: hidden; white-space: nowrap; }
.stars-bar span::before { content: "★★★★★"; color: var(--gold); }
.s0 span { width: 0 } .s1 span { width: 10% } .s2 span { width: 20% } .s3 span { width: 30% } .s4 span { width: 40% } .s5 span { width: 50% }
.s6 span { width: 60% } .s7 span { width: 70% } .s8 span { width: 80% } .s9 span { width: 90% } .s10 span { width: 100% }

/* ページ送り */
.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 16px 0; }
.pager a, .pager-cur, .pager-gap { min-width: 40px; min-height: 40px; display: grid; place-items: center; padding: 0 10px; border-radius: 8px; text-decoration: none; font-variant-numeric: tabular-nums; }
.pager a { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager-cur { background: var(--accent); color: var(--accent-text); font-weight: 700; }

/* スレッド */
.crumb { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 14px; font-size: .82rem; color: var(--muted); }
.thread-head h1 { margin-bottom: 4px; }
.thread-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 0 0 8px; color: var(--muted); font-size: .9rem; }
.posts { display: grid; gap: 10px; margin: 12px 0; }
.post { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; scroll-margin-top: 12px; }
.post:target { border-color: var(--gold); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 35%, transparent); }
.post-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; font-size: .82rem; color: var(--muted); }
.post-no { font-weight: 700; font-size: .95rem; color: var(--accent); text-decoration: none; font-variant-numeric: tabular-nums; }
.post-name { color: var(--text); }
.post-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; }
.post-rating { margin: 6px 0 0; }
.post-body { margin-top: 8px; font-size: 1rem; line-height: 1.8; }
.post-body.pre { white-space: pre-wrap; }
.post-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: .82rem; }
.post-foot a { color: var(--muted); padding: 4px 0; }
.post-deleted { background: transparent; border-style: dashed; color: var(--muted); }
.anchor { font-weight: 600; }
.popup { position: absolute; z-index: 20; width: min(92vw, 560px); max-height: 60vh; overflow: auto; box-shadow: 0 8px 30px rgb(0 0 0 / 25%); border-radius: var(--radius); }
.popup .post { border-color: var(--accent); }

/* フォーム */
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 20px 0; }
.form-card h2 { margin-top: 0; }
.post-form { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > label, .field > legend { font-weight: 700; font-size: .92rem; padding: 0; }
.field small { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="search"], input[type="email"], input[type="url"], input[type="password"], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
textarea { resize: vertical; line-height: 1.7; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.field-note { display: flex; justify-content: space-between; gap: 12px; margin: 0; color: var(--muted); font-size: .8rem; }
.counter { white-space: nowrap; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); font-weight: 700; }
.choice { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.choice label { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.choice label:has(:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice span { display: grid; }
.rating-input { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; }
.rating-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rating-input label { font-size: 2rem; line-height: 1; padding: 2px 3px; color: var(--line); cursor: pointer; }
.rating-input input:checked ~ label, .rating-input label:hover, .rating-input label:hover ~ label { color: var(--gold); }
.rating-input input:focus-visible + label { outline: 3px solid var(--gold); border-radius: 4px; }
.rating-clear { font-size: .85rem; color: var(--muted); }
.alert { margin: 0 0 12px; padding: 10px 14px; border-radius: 8px; border: 1px solid; }
.alert-error { color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.alert-notice { color: var(--text); border-color: var(--line); background: var(--accent-soft); }
[hidden] { display: none !important; }

/* 占い会社・検索・文章ページ・管理 */
.company-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.company-grid a { display: grid; gap: 2px; height: 100%; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.company-grid a:hover { border-color: var(--accent); }
.company-grid small { color: var(--muted); }
.hit-list { display: grid; gap: 8px; }
.hit-list a { display: grid; gap: 2px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.hit-list span { color: var(--muted); font-size: .9rem; }
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 18px 18px; margin-top: 14px; }
.prose li { margin-block: 4px; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .9rem; }
.table-wrap { overflow-x: auto; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; }
.table th, .table td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; }

@media (min-width: 640px) {
  h1 { font-size: 1.6rem; }
  .hero { padding: 28px; }
  .hero h1 { font-size: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
