:root {
  --bg: #fdfcf9;
  --bg-surface: #ffffff;
  --bg-muted: #f5f2eb;
  --border: #e5e0d5;
  --text: #2c2a26;
  --text-muted: #6b6862;

  --accent: #b8462e;
  --accent-hover: #9a3a25;
  --accent-bg: #faeae4;

  --cat-kekkon: #c77b8e;
  --cat-sogi: #6b7aa8;
  --cat-iwai: #c99740;

  --max-width: 860px;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1917;
    --bg-surface: #252320;
    --bg-muted: #2f2d2a;
    --border: #3d3b36;
    --text: #e8e5dd;
    --text-muted: #a8a49a;
    --accent: #d46a52;
    --accent-hover: #e0806a;
    --accent-bg: #3a2520;
  }
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Noto Sans JP",
               "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  margin: 0 0 0.6em;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; margin-top: 2.2em; }
h3 { font-size: 1.1rem; margin-top: 1.6em; }

p { margin: 0 0 1em; }

ul, ol {
  padding-left: 1.4em;
  margin: 0 0 1em;
}
li { margin-bottom: 0.4em; }

/* ===== ヘッダー ===== */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 1.05rem;
}
.site-logo:hover {
  text-decoration: none;
  color: var(--accent);
}
.site-logo svg {
  width: 28px;
  height: 28px;
}
.site-logo-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 2px;
}

.global-nav {
  display: flex;
  gap: 4px;
}
.global-nav a {
  color: var(--text);
  font-size: 0.9rem;
  padding: 6px 10px;
  border-radius: 6px;
}
.global-nav a:hover {
  background: var(--bg-muted);
  text-decoration: none;
}
.global-nav a.is-current {
  color: var(--accent);
  font-weight: 600;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .menu-toggle {
    display: inline-block;
  }
  .global-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    flex-direction: column;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
  }
  .global-nav.is-open {
    display: flex;
  }
  .global-nav a {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
  }
  .global-nav a:last-child { border-bottom: none; }
}

/* ===== パンくず ===== */
.breadcrumb {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 16px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.breadcrumb ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.breadcrumb li::after {
  content: "›";
  margin-left: 6px;
  color: var(--text-muted);
}
.breadcrumb li:last-child::after {
  content: "";
}
.breadcrumb a { color: var(--text-muted); }

/* ===== メイン ===== */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
}

.lead {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 1.5em;
}

.last-updated {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1em;
}

/* ===== 絞り込み ===== */
.filter-section {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.filter-item label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.filter-item select {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text);
  font-family: inherit;
}
.filter-item select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ===== 結果表 ===== */
.result-section { margin-bottom: 32px; }

.result-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.result-card .result-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.result-card .result-primary {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  margin-bottom: 4px;
}
.result-card .result-range {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.result-card .result-note {
  font-size: 0.9rem;
  color: var(--text);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.result-empty {
  background: var(--bg-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

/* 全件テーブル */
.result-table-wrap {
  margin-top: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.4;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.result-table th,
.result-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.result-table th {
  background: var(--bg-muted);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.result-table tr:last-child td { border-bottom: none; }
.result-table .cell-primary {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.result-table-toggle {
  margin-top: 16px;
  text-align: center;
}
.result-table-toggle button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}
.result-table-toggle button:hover {
  background: var(--bg-muted);
}

/* ===== 注意・FAQ・関連 ===== */
.notes-section ul {
  background: var(--bg-muted);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 14px 14px 14px 32px;
  list-style-type: disc;
}
.notes-section li {
  font-size: 0.92rem;
  color: var(--text);
}

.faq-section dl {
  margin: 0;
}
.faq-section dt {
  font-weight: 600;
  margin-top: 20px;
  padding: 10px 12px;
  background: var(--bg-muted);
  border-radius: 6px;
  position: relative;
  padding-left: 38px;
}
.faq-section dt::before {
  content: "Q.";
  position: absolute;
  left: 12px;
  top: 10px;
  color: var(--accent);
  font-weight: 700;
}
.faq-section dd {
  margin: 8px 0 0;
  padding: 8px 12px 8px 38px;
  position: relative;
  font-size: 0.95rem;
}
.faq-section dd::before {
  content: "A.";
  position: absolute;
  left: 12px;
  top: 8px;
  color: var(--text-muted);
  font-weight: 700;
}

.related-section ul {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.related-section li { margin: 0; }
.related-section a {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-weight: 500;
  transition: background 0.15s;
}
.related-section a:hover {
  background: var(--bg-muted);
  text-decoration: none;
  border-color: var(--accent);
}
.related-section a::after {
  content: " →";
  color: var(--accent);
}

/* ===== トップ・カテゴリハブ ===== */
.hero {
  text-align: center;
  padding: 32px 0 16px;
}
.hero h1 {
  font-size: 1.9rem;
  margin-bottom: 0.4em;
}
.hero p {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0 auto;
  max-width: 600px;
}

.category-block {
  margin-bottom: 36px;
}
.category-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  color: white;
}
.category-heading.cat-kekkon { background: var(--cat-kekkon); }
.category-heading.cat-sogi { background: var(--cat-sogi); }
.category-heading.cat-iwai { background: var(--cat-iwai); }
.category-heading h2 {
  margin: 0;
  font-size: 1.1rem;
  color: white;
}
.category-heading .cat-desc {
  font-size: 0.8rem;
  opacity: 0.95;
  margin-left: auto;
}

.genre-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  list-style: none;
  padding: 0;
}
.genre-grid li { margin: 0; }
.genre-card {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
  height: 100%;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, border-color 0.15s;
}
.genre-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-1px);
}
.genre-card .genre-card-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 4px;
}
.genre-card .genre-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

@media (max-width: 640px) {
  .category-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .category-heading .cat-desc {
    margin-left: 0;
  }
}

/* ===== 補助ページ（about, privacy 等） ===== */
.static-page h2 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.static-page section {
  margin-bottom: 24px;
}

/* ===== フッター ===== */
.site-footer {
  background: var(--bg-muted);
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 32px 0 24px;
}
.site-footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}
.footer-genres h3,
.footer-pages h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 10px;
  font-weight: 600;
}
.footer-genres ul,
.footer-pages ul {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}
.footer-genres a,
.footer-pages a {
  font-size: 0.88rem;
  color: var(--text);
}
.footer-copy {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}

/* ===== 404 ===== */
.notfound {
  text-align: center;
  padding: 48px 16px;
}
.notfound h1 {
  font-size: 4rem;
  color: var(--accent);
  margin-bottom: 0;
}
.notfound h2 {
  margin-top: 8px;
}
