* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1rem;
  color: #222;
  background: #fafafa;
}

header {
  margin-bottom: 2rem;
}

h1 {
  margin-bottom: 1rem;
}

nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter {
  padding: 0.4rem 0.8rem;
  border: 1px solid #ccc;
  background: white;
  border-radius: 4px;
  cursor: pointer;
}

.filter.active {
  background: #222;
  color: white;
  border-color: #222;
}

.theme-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.theme-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.6rem;
  border: 1px solid transparent;
  border-left: 4px solid var(--chip, #999);
  background: #fff;
  border-radius: 3px;
  font-size: 0.78rem;
  cursor: pointer;
  color: #333;
}

.theme-chip:hover {
  background: #f0f0f0;
}

.theme-chip.active {
  background: #222;
  color: #fff;
}

.theme-chip.small {
  cursor: default;
  padding: 0.1rem 0.45rem;
  font-size: 0.72rem;
}

.chip-count {
  color: #999;
  font-size: 0.7rem;
}

.count {
  color: #666;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.card-head h2 {
  font-size: 1.05rem;
  line-height: 1.3;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}

.badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 3px;
  white-space: nowrap;
}

.badge.bm { background: #ffe8cc; color: #a04a00; }
.badge.biz { background: #d4edda; color: #155724; }
.badge.biz-maybe { background: #e2e3e5; color: #383d41; }

.summary {
  font-size: 0.9rem;
  line-height: 1.45;
  color: #333;
  white-space: pre-wrap;
}

.summary a {
  color: #1a6ec0;
  word-break: break-all;
}

.themes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: #666;
  border-top: 1px solid #f0f0f0;
  padding-top: 0.5rem;
}

.meta-status { font-weight: 500; color: #444; }

/* --- cards with a write-up --- */
.card.has-detail {
  cursor: pointer;
  transition: box-shadow 0.12s, border-color 0.12s;
}

.card.has-detail:hover,
.card.has-detail:focus-visible {
  border-color: #999;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  outline: none;
}

.read-more {
  margin-top: auto;
  font-size: 0.8rem;
  font-weight: 600;
  color: #1a6ec0;
}

/* --- modal --- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
  padding: 2rem 1rem;
  overflow-y: auto;
}

.modal.open {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.modal-panel {
  position: relative;
  background: #fff;
  max-width: 760px;
  width: 100%;
  border-radius: 8px;
  padding: 2rem 2rem 2.5rem;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

.modal-close {
  position: sticky;
  float: right;
  top: 0;
  border: none;
  background: none;
  font-size: 1.8rem;
  line-height: 1;
  color: #888;
  cursor: pointer;
}

.modal-close:hover { color: #222; }

.modal-title {
  font-size: 1.4rem;
  margin-bottom: 1rem;
  padding-right: 1.5rem;
}

.doc-text p {
  font-size: 0.95rem;
  line-height: 1.55;
  margin-bottom: 0.9rem;
}

.doc-list {
  list-style: none;
  margin: 0 0 0.9rem;
}

.doc-list li {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 0.35rem;
  padding-left: 1.4rem;
  text-indent: -1.4rem;
}

.doc-list li.lvl-1 {
  padding-left: 3rem;
  text-indent: -1.4rem;
  color: #444;
}

.doc-list .marker {
  font-weight: 600;
  color: #1a6ec0;
  margin-right: 0.3rem;
}

.doc-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.6rem;
  margin-top: 1.2rem;
  border-top: 1px solid #eee;
  padding-top: 1.2rem;
}

.doc-img {
  display: block;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #eee;
}

.doc-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 1 / 1;
}
