:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --panel: #fffdf8;
  --panel-strong: #ffffff;
  --ink: #1f2328;
  --muted: #68707a;
  --line: #d9d3c7;
  --accent: #0f766e;
  --accent-dark: #0b4f4a;
  --warm: #a15c21;
  --mark: #eef7f4;
  --shadow: 0 18px 40px rgba(31, 35, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Sans", Meiryo, sans-serif;
  line-height: 1.5;
}

/* ─── Header ─── */

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px) 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-strong);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 800;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.source-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  background: #faf7ef;
  font-size: 13px;
  white-space: nowrap;
}

.source-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--accent-dark);
  background: #eef7f4;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.source-link:hover {
  background: var(--accent);
  color: #ffffff;
}

/* ─── Layout ─── */

.app-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 32px) 48px;
}

/* ─── Summary strip ─── */

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-strip div {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--panel);
}

.summary-strip strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.summary-strip span {
  color: var(--muted);
  font-size: 13px;
}

/* ─── Search hint ─── */

.search-hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

/* ─── Score list ─── */

.score-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

details.score-item {
  border-bottom: 1px solid var(--line);
}

details.score-item:last-child {
  border-bottom: none;
}

details.score-item > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

details.score-item > summary::-webkit-details-marker {
  display: none;
}

details.score-item > summary::after {
  content: "▶";
  flex-shrink: 0;
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s;
}

details.score-item[open] > summary::after {
  transform: rotate(90deg);
}

details.score-item > summary:hover {
  background: var(--mark);
}

details.score-item[open] > summary {
  background: var(--mark);
  border-bottom: 1px solid var(--line);
}

.summary-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.summary-main strong {
  font-size: 15px;
  overflow-wrap: anywhere;
}

.summary-main span,
.summary-meta {
  color: var(--muted);
  font-size: 12px;
}

/* ─── Badges ─── */

.badge-row {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid #c8ded9;
  border-radius: 999px;
  padding: 2px 8px;
  background: #f3fbf8;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.warm {
  border-color: #e2c6a9;
  background: #fff7ed;
  color: var(--warm);
}

/* ─── Detail body ─── */

.detail-body {
  padding: 18px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 7px 11px;
  color: #ffffff;
  background: var(--accent);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}

.action-link:hover {
  opacity: 0.85;
}

.action-link.secondary {
  color: var(--accent-dark);
  background: var(--panel-strong);
}

/* ─── Detail grid ─── */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.field {
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field strong {
  display: block;
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

/* ─── Text blocks ─── */

.text-block {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.text-block h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.text-block p {
  margin: 0;
  color: #3a4048;
  overflow-wrap: anywhere;
}

/* ─── Link section ─── */

.link-section {
  margin-top: 28px;
}

.link-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}

.link-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 10px;
  overflow: hidden;
}

.link-group > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  font-size: 15px;
  user-select: none;
}

.link-group > summary::-webkit-details-marker {
  display: none;
}

.link-group > summary::after {
  content: "▶";
  flex-shrink: 0;
  font-size: 10px;
  color: var(--muted);
  margin-left: auto;
  transition: transform 0.15s;
}

.link-group[open] > summary::after {
  transform: rotate(90deg);
}

.link-group > summary:hover {
  background: var(--mark);
}

.link-group[open] > summary {
  background: var(--mark);
  border-bottom: 1px solid var(--line);
}

.link-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
  background: #eef7f4;
  border: 1px solid #c8ded9;
  border-radius: 999px;
  padding: 1px 8px;
}

.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.link-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.link-item:last-child {
  border-bottom: none;
}

.link-category {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding-top: 3px;
  line-height: 1.4;
}

.link-content a {
  font-weight: 700;
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 14px;
}

.link-content a:hover {
  text-decoration: underline;
  color: var(--accent);
}

.link-content p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.link-disclaimer {
  margin: 14px 0 0;
  padding: 12px 16px;
  background: #faf7ef;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* ─── Intro box & 目次 ─── */

.intro-box {
  border: 1px solid #c8ded9;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--mark);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.intro-box > strong {
  display: block;
  font-size: 16px;
  color: var(--accent-dark);
  margin-bottom: 8px;
}

.intro-box ul {
  margin: 0 0 12px;
  padding-left: 20px;
}

.intro-box li {
  margin: 4px 0;
  color: #3a4048;
  font-size: 14px;
  line-height: 1.6;
}

.intro-box b {
  color: var(--warm);
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}

.toc a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.toc a:hover {
  background: var(--accent);
  color: #fff;
}

/* ─── Genre nav ─── */

.genre-nav {
  margin-bottom: 16px;
}

.genre-nav h2,
.score-section > h2 {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 800;
}

.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.genre-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.genre-chip span {
  font-size: 11px;
  color: var(--muted);
  background: #faf7ef;
  border-radius: 999px;
  padding: 1px 7px;
}

.genre-chip:hover {
  border-color: var(--accent);
}

.genre-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.genre-chip.is-active span {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* ─── Toolbar (検索・絞り込み) ─── */

.score-section {
  margin-bottom: 28px;
}

.toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  margin-bottom: 12px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.toolbar-row.filters {
  margin-top: 10px;
}

.tb-search {
  flex: 1 1 100%;
}

.tb-search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 15px;
  background: var(--panel-strong);
}

.tb-search input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.filters select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  background: var(--panel-strong);
  color: var(--ink);
}

.tb-clear {
  min-height: 38px;
  align-self: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  background: var(--panel-strong);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.tb-clear:hover {
  border-color: var(--accent);
  background: var(--mark);
}

.tb-status {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.tb-status strong {
  color: var(--accent-dark);
  font-size: 15px;
}

.filter-empty {
  margin: 12px 0 0;
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ─── FAQ ─── */

.faq-section {
  margin-top: 28px;
}

.faq-section h2,
.glossary-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 800;
}

.faq-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 8px;
  overflow: hidden;
}

.faq-item > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  font-size: 15px;
  user-select: none;
}

.faq-item > summary::-webkit-details-marker {
  display: none;
}

.faq-item > summary::before {
  content: "Q";
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.faq-item > summary::after {
  content: "＋";
  margin-left: auto;
  color: var(--muted);
}

.faq-item[open] > summary::after {
  content: "−";
}

.faq-item[open] > summary {
  background: var(--mark);
  border-bottom: 1px solid var(--line);
}

.faq-answer {
  padding: 14px 16px;
}

.faq-answer p {
  margin: 0;
  color: #3a4048;
  line-height: 1.7;
}

/* ─── Glossary ─── */

.glossary-section {
  margin-top: 28px;
}

.glossary {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.glossary .term {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px 14px;
}

.glossary dt {
  font-weight: 800;
  font-size: 14px;
  color: var(--accent-dark);
}

.glossary dd {
  margin: 4px 0 0;
  font-size: 13px;
  color: #3a4048;
  line-height: 1.6;
}

/* ─── Responsive ─── */

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .summary-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .badge-row {
    display: none;
  }

  details.score-item[open] > summary .badge-row {
    display: flex;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .link-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .filters label {
    flex: 1 1 calc(50% - 5px);
  }

  .filters select {
    width: 100%;
  }

  .glossary {
    grid-template-columns: 1fr;
  }
}
