/* ---------- base ---------- */
:root {
  --bg: #fbf6ee;
  --bg-2: #f3ebda;
  --ink: #2a2622;
  --muted: #6e655c;
  --line: #e6dcc6;
  --accent: #d94f5c;
  --accent-2: #f6c544;
  --accent-3: #4ea3a8;
  --shadow: 0 6px 20px rgba(70, 50, 20, 0.10);
  --shadow-lg: 0 18px 50px rgba(70, 50, 20, 0.20);
  --radius: 14px;
  --serif: "Source Han Serif SC", "Songti SC", "Noto Serif CJK SC", "PingFang SC", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ---------- header ---------- */
.site-header {
  background: linear-gradient(180deg, #fff6e0 0%, #fbf6ee 100%);
  border-bottom: 2px solid var(--line);
  padding: 36px 20px 28px;
  text-align: center;
}
.header-inner { max-width: 1100px; margin: 0 auto; }
.site-header h1 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.2;
}
.site-header h1 .zh { color: var(--accent); }
.site-header h1 .en {
  display: block;
  font-size: 0.55em;
  letter-spacing: 0.18em;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 600;
}
.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- toolbar ---------- */
.toolbar {
  max-width: 1100px;
  margin: 24px auto 12px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#search-input {
  width: 100%;
  padding: 14px 18px;
  font-size: 17px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(217, 79, 92, 0.12);
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 6px 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.stats { color: var(--muted); font-size: 14px; }

/* ---------- grid ---------- */
.grid {
  max-width: 1100px;
  margin: 8px auto 60px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 24px;
}
.card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  flex-direction: column;
  border: 1.5px solid transparent;
  text-align: left;
  padding: 0;
  width: 100%;
  font: inherit;
  color: inherit;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-2);
}
.card-cover {
  aspect-ratio: 2 / 3;
  background: var(--bg-2);
  overflow: hidden;
  position: relative;
}
.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 16px;
  font-family: var(--serif);
}
.card-cover.placeholder .ph-emoji {
  font-size: 48px;
  margin-bottom: 10px;
}
.card-cover.placeholder .ph-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #3a2f24;
  line-height: 1.2;
}
.card-cover.placeholder .ph-series {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: #5a4a36;
  font-weight: 800;
}
.card-meta {
  padding: 12px 14px 16px;
  border-top: 1px solid var(--line);
}
.card-name-en {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
  margin: 0 0 2px;
}
.card-name-zh {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 6px;
}
.card-cat {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-2);
  color: #6a5a3a;
}

/* ---------- modal ---------- */
.modal[hidden] { display: none !important; }
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(40, 30, 20, 0.55);
  backdrop-filter: blur(2px);
}
.modal-content {
  position: relative;
  background: var(--bg);
  border-radius: 20px;
  width: min(960px, 100%);
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  border: none;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 2;
  transition: transform 0.15s;
}
.modal-close:hover { transform: scale(1.08); background: #fff; }

.modal-body {
  overflow-y: auto;
  padding: 0;
}

.detail {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
}
.detail-cover {
  background: var(--bg-2);
  padding: 32px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-cover img {
  width: 100%;
  max-width: 240px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}
.detail-cover.placeholder {
  aspect-ratio: auto;
}
.detail-cover.placeholder .ph-card {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
  padding: 16px;
  font-family: var(--serif);
}
.detail-cover.placeholder .ph-emoji { font-size: 64px; margin-bottom: 14px; }
.detail-cover.placeholder .ph-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.2;
}
.detail-cover.placeholder .ph-series {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #5a4a36;
}

.detail-main { padding: 32px 36px 36px; }

.detail-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.detail-cat {
  display: inline-block;
  background: var(--accent-2);
  color: #4a3500;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  text-transform: uppercase;
}
.detail-cat.specific {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--line);
  font-weight: 600;
}
.detail-name-en {
  font-size: 32px;
  font-weight: 700;
  margin: 12px 0 4px;
  line-height: 1.1;
}
.detail-name-zh {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}
.detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 18px;
}
.detail-meta-row span strong {
  color: var(--ink);
  font-weight: 700;
}
.status-alive { color: #2a7a3a; font-weight: 700; }
.status-deceased { color: var(--muted); }

.tagline {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.4;
  background: #fff;
  border-left: 4px solid var(--accent);
  padding: 14px 18px;
  border-radius: 6px;
  margin: 0 0 22px;
}
.tagline p { margin: 0; }
.tagline .zh { display: block; margin-top: 6px; color: var(--muted); font-size: 16px; }

.story-blocks {
  display: grid;
  gap: 22px;
}
@media (min-width: 760px) {
  .story-blocks { grid-template-columns: 1fr 1fr; gap: 28px; }
}
.story-block h3 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px dashed var(--line);
  padding-bottom: 6px;
}
.story-block.zh h3 { color: var(--accent-3); }
.story-block p {
  margin: 0;
  font-size: 16px;
  line-height: 1.8;
}
.story-block.zh p {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.85;
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
  .detail { grid-template-columns: 1fr; }
  .detail-cover { padding: 24px 16px 8px; }
  .detail-cover img, .detail-cover.placeholder .ph-card { max-width: 200px; }
  .detail-main { padding: 24px 22px 28px; }
  .detail-name-en { font-size: 26px; }
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 2px solid var(--line);
  text-align: center;
  padding: 24px 16px;
  color: var(--muted);
  font-size: 13px;
  background: var(--bg-2);
}
.site-footer p { margin: 0; line-height: 1.7; }

/* ---------- a11y ---------- */
:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
}

body.modal-open { overflow: hidden; }
