:root {
  color-scheme: light;
  --paper: #fffdf9;
  --canvas: #f7f1e8;
  --canvas-deep: #eee4d6;
  --ink: #292723;
  --muted: #716c64;
  --line: #ded4c7;
  --brand: #9b573a;
  --brand-dark: #73402b;
  --brand-soft: #f2dfd2;
  --priority-one: #a44338;
  --priority-one-soft: #f7e2de;
  --priority-two: #a66322;
  --priority-two-soft: #f8ead8;
  --priority-three: #55715e;
  --priority-three-soft: #e4eee7;
  --normal: #4d725d;
  --normal-soft: #e7f0e9;
  --unknown: #777168;
  --unknown-soft: #eeeae4;
  --shadow-sm: 0 2px 12px rgb(74 54 38 / 7%);
  --shadow-lg: 0 18px 50px rgb(74 54 38 / 11%);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --page: 1180px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 10% 2%, rgb(255 255 255 / 70%), transparent 25rem),
    var(--canvas);
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  min-height: 44px;
}

button {
  color: inherit;
}

img,
svg {
  display: block;
}

a {
  color: var(--brand-dark);
}

.page-shell {
  width: min(calc(100% - 40px), var(--page));
  margin-inline: auto;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid #2e6fa3;
  outline-offset: 3px;
}

.site-header {
  position: relative;
  overflow: hidden;
  padding: 54px 0 46px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(118deg, rgb(255 253 249 / 96%), rgb(242 223 210 / 72%)),
    var(--paper);
}

.site-header::after {
  position: absolute;
  right: -90px;
  bottom: -180px;
  width: 410px;
  height: 410px;
  border: 1px solid rgb(155 87 58 / 15%);
  border-radius: 50%;
  box-shadow: 0 0 0 42px rgb(155 87 58 / 4%), 0 0 0 88px rgb(155 87 58 / 3%);
  content: "";
}

.hero {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 78px minmax(0, 720px);
  gap: 28px;
  align-items: start;
}

.hero-mark {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border: 1px solid rgb(155 87 58 / 20%);
  border-radius: 22px;
  background: rgb(255 253 249 / 80%);
  box-shadow: var(--shadow-sm);
}

.hero-mark svg {
  width: 43px;
  fill: none;
  stroke: var(--brand);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.section-kicker {
  margin: 0 0 5px;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-story {
  margin: 0 0 2px;
  color: #b46a54;
  font-family: "Xingkai SC", "Kaiti SC", "STKaiti", "KaiTi", cursive;
  font-size: clamp(1rem, 2vw, 1.3rem);
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.35;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: clamp(2.1rem, 5vw, 3.65rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.12;
}

.hero h1 {
  position: relative;
  display: inline-block;
  margin-bottom: 18px;
  color: #713f34;
  font-family: "Yuanti SC", "STYuanti-SC-Regular", "STYuanti", "PingFang SC", sans-serif;
  font-size: clamp(2.8rem, 6.5vw, 5rem);
  font-weight: 600;
  letter-spacing: 0.035em;
  text-shadow: 0 3px 0 rgb(255 255 255 / 68%);
}

.hero h1::after {
  position: absolute;
  right: 4%;
  bottom: -5px;
  left: 3%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d99a7c, #e9bd79 48%, #b9cfae);
  content: "";
  opacity: 0.75;
  transform: rotate(-1deg);
}

h2 {
  margin-bottom: 0;
  font-size: 1.38rem;
  line-height: 1.25;
}

.hero-copy {
  max-width: 680px;
  margin-bottom: 16px;
  color: #57514a;
  font-size: 1.04rem;
}

.archive-meta {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

main.page-shell {
  padding-block: 34px 64px;
}

.app-status {
  margin-bottom: 20px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--muted);
}

.app-status:empty,
.app-status[data-state="ready"] {
  display: none;
}

.app-status[data-state="error"] {
  border-color: #d5a59d;
  background: var(--priority-one-soft);
  color: #71332c;
}

.search-panel {
  margin-top: 0;
  margin-bottom: 34px;
  padding: 18px;
  border: 1px solid rgb(222 212 199 / 80%);
  border-radius: var(--radius-md);
  background: rgb(255 253 249 / 96%);
  box-shadow: var(--shadow-lg);
}

.search-label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.82rem;
  font-weight: 700;
}

.search-field {
  position: relative;
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 15px;
  width: 21px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 1.8;
  transform: translateY(-50%);
}

.search-field input {
  width: 100%;
  min-height: 52px;
  padding: 10px 16px 10px 47px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
}

.search-field input::placeholder {
  color: #918a81;
}

.search-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgb(155 87 58 / 10%);
}

.section-heading,
.results-heading {
  display: flex;
  gap: 24px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-heading > p,
.results-heading > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

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

.quick-filters {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 9px;
}

.quick-filter {
  position: relative;
  display: flex;
  min-height: 82px;
  padding: 12px 10px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgb(255 253 249 / 74%);
  cursor: pointer;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.quick-filter:hover {
  border-color: #c5aa97;
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.quick-filter[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.quick-filter strong {
  font-size: 1.28rem;
  line-height: 1;
}

.quick-filter span {
  color: #5e5851;
  font-size: 0.78rem;
  line-height: 1.25;
}

.advanced-panel {
  margin-bottom: 35px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgb(255 253 249 / 72%);
  box-shadow: var(--shadow-sm);
}

.advanced-panel summary {
  display: flex;
  min-height: 52px;
  padding: 13px 18px;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 700;
}

.advanced-panel summary::marker {
  color: var(--brand);
}

.filter-summary {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.filter-grid {
  display: grid;
  padding: 18px;
  grid-template-columns: repeat(6, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  border-top: 1px solid var(--line);
}

.filter-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.filter-grid select {
  width: 100%;
  padding: 8px 31px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}

.button {
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 700;
}

.button-secondary {
  border-color: var(--line);
  background: var(--paper);
}

.button-secondary:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.results-section {
  min-height: 300px;
}

.cat-results {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.cat-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.cat-table th {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #f3ece3;
  color: #625b53;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-align: left;
}

.cat-row {
  position: relative;
  cursor: pointer;
  transition: background 140ms ease;
}

.cat-row:hover,
.cat-row:focus-within {
  background: #faf6f0;
}

.cat-row td {
  padding: 15px 12px;
  border-bottom: 1px solid #ebe4da;
  vertical-align: top;
}

.cat-row:last-child td {
  border-bottom: 0;
}

.cat-row td:first-child {
  border-left: 4px solid transparent;
}

.cat-row.priority-1 td:first-child {
  border-left-color: var(--priority-one);
}

.cat-row.priority-2 td:first-child {
  border-left-color: var(--priority-two);
}

.cat-row.priority-3 td:first-child {
  border-left-color: var(--priority-three);
}

.cat-identity {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
}

.cat-photo {
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--canvas);
  object-fit: cover;
}

.cat-name-button,
.relation-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
  text-align: left;
  text-decoration: none;
}

.cat-name-button:hover,
.relation-link:hover {
  color: var(--brand-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cat-subline,
.cell-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.birth-estimate {
  flex-basis: 100%;
  margin-top: 2px;
}

.badge {
  display: inline-flex;
  min-height: 25px;
  padding: 3px 8px;
  align-items: center;
  border-radius: 999px;
  background: var(--unknown-soft);
  color: #5f5a52;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.15;
}

.badge-alert {
  background: var(--priority-one-soft);
  color: #7d332c;
}

.badge-warn {
  background: var(--priority-two-soft);
  color: #784818;
}

.badge-care {
  background: var(--priority-three-soft);
  color: #3e5e47;
}

.badge-normal {
  background: var(--normal-soft);
  color: #3d654e;
}

.latest-update {
  color: #4e4943;
  font-size: 0.8rem;
  line-height: 1.55;
}

.empty-state,
.not-found {
  padding: 64px 24px;
  text-align: center;
}

.empty-state h3,
.not-found h2 {
  margin-bottom: 8px;
}

.empty-state p,
.not-found p {
  color: var(--muted);
}

.detail-view {
  max-width: 980px;
  margin-inline: auto;
}

.back-link {
  display: inline-flex;
  margin-bottom: 20px;
  padding: 8px 0;
  gap: 8px;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  cursor: pointer;
  font-weight: 700;
}

.detail-hero {
  display: grid;
  margin-bottom: 20px;
  padding: 24px;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-lg);
}

.detail-photo-wrap {
  position: relative;
}

.detail-photo {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--canvas);
  object-fit: cover;
}

.photo-caption {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgb(41 39 35 / 76%);
  color: white;
  font-size: 0.68rem;
}

.detail-title-row {
  display: flex;
  gap: 15px;
  align-items: start;
  justify-content: space-between;
}

.detail-title-row h1 {
  margin-bottom: 4px;
  font-size: clamp(2rem, 4vw, 3rem);
}

.detail-color {
  margin-bottom: 18px;
  color: var(--muted);
}

.detail-priority {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 750;
}

.detail-priority.priority-1 {
  background: var(--priority-one-soft);
  color: var(--priority-one);
}

.detail-priority.priority-2 {
  background: var(--priority-two-soft);
  color: var(--priority-two);
}

.detail-priority.priority-3 {
  background: var(--priority-three-soft);
  color: var(--priority-three);
}

.status-cards {
  display: grid;
  margin: 20px 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.status-card {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #faf6f0;
}

.status-card span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.69rem;
}

.status-card strong {
  font-size: 0.9rem;
}

.latest-callout {
  margin: 0;
  padding: 13px 15px;
  border-left: 3px solid var(--brand);
  border-radius: 0 9px 9px 0;
  background: var(--brand-soft);
  color: #4f3d34;
  font-size: 0.86rem;
}

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

.detail-card {
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.detail-card-wide {
  grid-column: 1 / -1;
}

.detail-card h2 {
  margin-bottom: 15px;
  font-size: 1.06rem;
}

.fact-list {
  display: grid;
  margin: 0;
  grid-template-columns: minmax(90px, 0.55fr) 1.45fr;
  gap: 9px 16px;
  font-size: 0.86rem;
}

.fact-list dt {
  color: var(--muted);
}

.fact-list dd {
  margin: 0;
  font-weight: 600;
}

.plain-list,
.relation-list,
.missing-list,
.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain-list li,
.relation-list li,
.missing-list li {
  padding: 8px 0;
  border-bottom: 1px solid #eee7de;
  font-size: 0.86rem;
}

.plain-list li:last-child,
.relation-list li:last-child,
.missing-list li:last-child {
  border-bottom: 0;
}

.behavior-tag,
.event-outcome {
  display: inline-flex;
  margin: 3px 6px 3px 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1ebe2;
  color: var(--ink);
  font-size: 0.78rem;
}

.relation-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  font-weight: 700;
}

.relation-separator {
  color: var(--muted);
}

.relation-preferred {
  color: var(--brand-dark);
}

.relation-observation {
  margin: 7px 0 4px;
  line-height: 1.65;
}

.relation-behaviors {
  margin-top: 2px;
}

.event-outcome {
  background: #f6dfd8;
}

.event-hero {
  grid-template-columns: 1fr;
}

.affected-cat-list li {
  align-items: center;
  flex-wrap: wrap;
}

.relation-group + .relation-group {
  margin-top: 16px;
}

.relation-group h3 {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
}

.certainty {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.7rem;
}

.timeline {
  position: relative;
}

.timeline::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 7px;
  width: 1px;
  background: var(--line);
  content: "";
}

.timeline li {
  position: relative;
  padding: 0 0 20px 30px;
}

.timeline li:last-child {
  padding-bottom: 0;
}

.timeline li::before {
  position: absolute;
  top: 7px;
  left: 2px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
  content: "";
}

.timeline time {
  color: var(--muted);
  font-size: 0.72rem;
}

.timeline strong {
  display: block;
  margin: 1px 0 2px;
  font-size: 0.86rem;
}

.timeline p {
  margin: 0;
  color: #555049;
  font-size: 0.82rem;
}

.missing-card {
  border-color: #dbc9b8;
  background: #fdf8f1;
}

.site-footer {
  padding: 28px 0;
  border-top: 1px solid var(--line);
  background: #eee5da;
}

.footer-inner {
  display: flex;
  gap: 30px;
  justify-content: space-between;
}

.footer-inner p {
  max-width: 560px;
  margin: 0;
  color: #625c54;
  font-size: 0.76rem;
}

@media (max-width: 1040px) {
  .status-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cat-table th:nth-child(4),
  .cat-table td:nth-child(4) {
    display: none;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(calc(100% - 28px), var(--page));
  }

  .site-header {
    padding: 38px 0 66px;
  }

  .hero {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 16px;
  }

  .hero-mark {
    width: 52px;
    height: 52px;
    border-radius: 16px;
  }

  .hero-mark svg {
    width: 33px;
  }

  h1 {
    font-size: clamp(1.9rem, 9vw, 2.7rem);
  }

  .hero-copy {
    font-size: 0.9rem;
  }

  main.page-shell {
    padding-top: 20px;
  }

  .search-panel {
    margin-top: 0;
    margin-bottom: 28px;
    padding: 13px;
  }

  .section-heading > p,
  .filter-summary {
    display: none;
  }

  .quick-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-filter:first-child {
    grid-column: 1 / -1;
    min-height: 62px;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-grid .button {
    grid-column: 1 / -1;
  }

  .cat-results {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .cat-table,
  .cat-table tbody,
  .cat-table tr,
  .cat-table td {
    display: block;
    width: 100%;
  }

  .cat-table th:nth-child(4),
  .cat-table td:nth-child(4) {
    display: block;
  }

  .cat-table thead {
    display: none;
  }

  .cat-row {
    display: grid !important;
    margin-bottom: 12px;
    padding: 15px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    border: 1px solid var(--line);
    border-left: 4px solid transparent;
    border-radius: var(--radius-md);
    background: var(--paper);
    box-shadow: var(--shadow-sm);
  }

  .cat-row.priority-1 {
    border-left-color: var(--priority-one);
  }

  .cat-row.priority-2 {
    border-left-color: var(--priority-two);
  }

  .cat-row.priority-3 {
    border-left-color: var(--priority-three);
  }

  .cat-row td,
  .cat-row td:first-child {
    padding: 0;
    border: 0;
  }

  .cat-row td::before {
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.66rem;
    font-weight: 700;
  }

  .cat-row td:first-child {
    grid-column: 1 / -1;
  }

  .cat-row td:first-child::before {
    display: none;
  }

  .cat-row td:last-child {
    grid-column: 1 / -1;
    padding-top: 9px;
    border-top: 1px solid #eee7de;
  }

  .cat-photo,
  .cat-identity {
    width: 64px;
  }

  .cat-identity {
    width: auto;
    grid-template-columns: 64px 1fr;
  }

  .detail-hero {
    padding: 17px;
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 16px;
  }

  .detail-title-row {
    display: block;
  }

  .detail-title-row h1 {
    font-size: 1.9rem;
  }

  .detail-priority {
    display: inline-block;
    margin-bottom: 8px;
  }

  .status-cards {
    grid-column: 1 / -1;
  }

  .latest-callout {
    grid-column: 1 / -1;
  }

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

  .detail-card-wide {
    grid-column: auto;
  }

  .footer-inner {
    display: grid;
    gap: 12px;
  }
}

@media (max-width: 430px) {
  .status-cards {
    grid-template-columns: 1fr;
  }

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

  .filter-grid .button {
    grid-column: auto;
  }

  .detail-hero {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .status-cards {
    grid-template-columns: 1fr;
  }

  .fact-list {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .fact-list dd {
    margin-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
