:root {
  --paper: #f3efe5;
  --paper-deep: #e9e0cf;
  --panel: #fffdf8;
  --ink: #20231f;
  --muted: #6f726a;
  --line: #cec4b3;
  --line-dark: #9d927f;
  --red: #b43a30;
  --green: #397356;
  --gold: #a47529;
  --shadow: 0 18px 44px rgba(72, 54, 31, .1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 90% 8%, rgba(180, 58, 48, .08), transparent 27rem),
    linear-gradient(90deg, transparent 49.96%, rgba(135, 112, 76, .05) 50%, transparent 50.04%),
    var(--paper);
  color: var(--ink);
  font-family: Manrope, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
}

a { color: inherit; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  transform: translateY(-150%);
  background: var(--ink);
  color: #fff;
}
.skip-link:focus { transform: none; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(18px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, .94);
  backdrop-filter: blur(12px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}
.seal {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--red);
  color: #fff;
  font: 22px "Noto Serif TC", "Songti TC", serif;
}
.brand b, .brand small { display: block; }
.brand b { font-size: 13px; letter-spacing: .18em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.site-header nav { display: flex; align-items: center; gap: 20px; }
.site-header nav a {
  color: var(--ink);
  font-size: 12px;
  text-decoration: none;
}
.site-header nav a:hover { color: var(--red); }
.connection {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .05em;
}
.connection i, .inventory-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #61a374;
  box-shadow: 0 0 0 3px #dbeade;
}

main { width: min(1220px, calc(100% - 40px)); margin: 0 auto; }
.hero {
  min-height: 520px;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr);
  gap: clamp(40px, 8vw, 110px);
  align-items: center;
  padding: clamp(70px, 10vw, 122px) clamp(0px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
}
.eyebrow, .snapshot > span {
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .22em;
}
.hero h1 {
  margin: 17px 0 24px;
  font: 700 clamp(42px, 6.5vw, 78px)/1.12 "Noto Serif TC", "Songti TC", serif;
  letter-spacing: .02em;
}
.hero h1 em { color: var(--red); font-style: normal; }
.hero-copy > p {
  max-width: 700px;
  margin: 0;
  color: var(--muted);
  font: 17px/1.85 Georgia, "Noto Serif TC", serif;
}
.hero-actions { display: flex; align-items: center; gap: 24px; margin-top: 34px; }
.primary-action {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 22px;
  padding: 0 20px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.primary-action:hover { background: var(--red); }
.primary-action span { font-size: 18px; }
.text-action { color: var(--green); font-size: 12px; text-underline-offset: 4px; }
.snapshot {
  padding: 36px 32px;
  border: 1px solid var(--line-dark);
  background: var(--panel);
  box-shadow: 14px 14px 0 var(--paper-deep);
}
.snapshot strong {
  display: block;
  margin-top: 20px;
  color: var(--green);
  font: 700 clamp(56px, 8vw, 88px)/1 Georgia, serif;
}
.snapshot b {
  display: block;
  margin-top: 5px;
  font: 20px "Noto Serif TC", serif;
}
.snapshot p { margin: 24px 0 0; color: var(--muted); font-size: 12px; line-height: 1.75; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--panel);
}
.metrics div { min-width: 0; padding: 24px 26px; border-right: 1px solid var(--line); }
.metrics div:last-child { border-right: 0; }
.metrics span, .metrics strong, .metrics small { display: block; }
.metrics span {
  color: var(--red);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .16em;
}
.metrics strong {
  margin: 10px 0 5px;
  overflow: hidden;
  font: 700 clamp(19px, 2vw, 28px)/1.15 Georgia, serif;
  text-overflow: ellipsis;
}
.metrics small { color: var(--muted); font-size: 10px; }

.catalog { padding: 94px 0 100px; }
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 30px;
  margin-bottom: 34px;
}
.section-heading > div { display: grid; grid-template-columns: 38px 1fr; }
.section-number { color: var(--red); font: 11px Georgia, serif; letter-spacing: .1em; }
.section-heading h2, .notation h2, .method h2 {
  margin: -5px 0 8px;
  font: 700 31px "Noto Serif TC", "Songti TC", serif;
}
.section-heading p { grid-column: 2; margin: 0; color: var(--muted); font-size: 13px; }
.inventory-state {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
}
.inventory-state.error { color: var(--red); }
.inventory-state.error i { background: var(--red); box-shadow: 0 0 0 3px #f0dad5; }

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
}
.search-field > span:first-child, .sort-field > span:first-child {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
}
.search-box { position: relative; display: block; }
.search-box svg {
  position: absolute;
  left: 16px;
  top: 50%;
  width: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
}
.search-box input, .sort-field select {
  width: 100%;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
  background: var(--panel);
  color: var(--ink);
}
.search-box input { padding: 0 48px 0 47px; }
.search-box input:focus, .sort-field select:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(57, 115, 86, .12); }
.search-box button {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 23px;
}
.sort-field select { padding: 0 14px; }

.category-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  margin-top: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.category-bar button {
  min-height: 48px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.category-bar button:last-child { border-right: 0; }
.category-bar button b {
  margin-left: 5px;
  color: var(--line-dark);
  font: 10px Georgia, serif;
}
.category-bar button:hover { color: var(--ink); }
.category-bar button.active { background: var(--ink); color: #fff; }
.category-bar button.active b { color: #cfd4cc; }
.results-meta {
  min-height: 49px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.results-meta p { margin: 0; color: var(--muted); font-size: 12px; }
.results-meta p b { color: var(--ink); }
.results-meta small { color: var(--muted); font-size: 9px; }

.table-shell { position: relative; min-height: 260px; background: var(--panel); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-dark);
  background: #e9e1d3;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .09em;
  text-align: left;
  white-space: nowrap;
}
th:nth-child(n+3):not(:last-child), td:nth-child(n+3):not(:last-child) { text-align: right; }
td {
  padding: 15px 14px;
  border-bottom: 1px solid #e3dccc;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
tbody tr:hover { background: #f8f4eb; }
.code-button {
  border: 0;
  border-bottom: 1px dotted var(--line-dark);
  background: transparent;
  color: var(--red);
  font: 700 14px "SFMono-Regular", Consolas, monospace;
  letter-spacing: .02em;
}
.material-cell { color: var(--ink); font: 15px "Noto Serif TC", "Songti TC", serif; }
.query-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
}
.query-link:hover { border-color: var(--green); background: #edf4ee; }
.empty-state, .load-error {
  min-height: 260px;
  display: grid;
  place-content: center;
  text-align: center;
}
.empty-state span, .load-error b { font: 21px "Noto Serif TC", serif; }
.empty-state p, .load-error p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.load-error button {
  width: max-content;
  margin: 18px auto 0;
  padding: 9px 15px;
  border: 1px solid var(--red);
  background: transparent;
  color: var(--red);
}
.load-more {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--panel);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}
.load-more:hover { background: #edf4ee; }

.notation {
  display: grid;
  grid-template-columns: .72fr 1.28fr;
  gap: clamp(40px, 8vw, 110px);
  padding: 92px clamp(0px, 4vw, 54px);
  border-top: 1px solid var(--line);
}
.notation > div:first-child { display: grid; grid-template-columns: 38px 1fr; align-content: start; }
.notation h2 { grid-column: 2; }
.notation > div:first-child p { grid-column: 2; margin: 10px 0 0; color: var(--muted); font: 15px/1.8 Georgia, "Noto Serif TC", serif; }
.notation code { color: var(--red); font-weight: 700; }
.notation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.piece-key { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); background: var(--panel); }
.piece-key span { padding: 15px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.piece-key span:nth-child(even) { border-right: 0; }
.piece-key span:nth-last-child(-n+2) { border-bottom: 0; }
.piece-key b { display: inline-grid; width: 23px; height: 23px; margin-right: 6px; place-items: center; background: var(--paper-deep); color: var(--red); font: 700 12px monospace; }
.code-example { padding: 24px; border: 1px solid var(--line-dark); background: var(--ink); color: #fff; }
.code-example > span { color: #beaa83; font-size: 9px; letter-spacing: .16em; }
.code-example strong { display: block; margin: 19px 0 10px; color: #e15b50; font: 700 34px monospace; }
.code-example p { margin: 0 0 16px; font: 17px "Noto Serif TC", serif; }
.code-example small { color: #aeb3ac; font-size: 10px; line-height: 1.6; }

.method {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) minmax(310px, .75fr);
  gap: 0;
  padding: 72px clamp(0px, 4vw, 54px) 100px;
  border-top: 1px solid var(--line);
}
.method > div { padding-right: clamp(30px, 6vw, 84px); }
.method p { margin: 12px 0 0; color: var(--muted); font: 14px/1.8 Georgia, "Noto Serif TC", serif; }
.method dl { margin: 0; border: 1px solid var(--line); background: var(--panel); }
.method dl div { display: grid; grid-template-columns: 105px 1fr; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.method dl div:last-child { border-bottom: 0; }
.method dt { color: var(--muted); font-size: 10px; }
.method dd { margin: 0; overflow: hidden; font: 700 11px monospace; text-align: right; text-overflow: ellipsis; white-space: nowrap; }

.toast {
  position: fixed;
  z-index: 30;
  right: 22px;
  bottom: 22px;
  padding: 12px 16px;
  transform: translateY(18px);
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
}
.toast.show { transform: none; opacity: 1; }
footer {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(18px, 5vw, 72px);
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 10px;
}
footer a { color: var(--ink); text-underline-offset: 3px; }
.noscript { margin: 0; padding: 18px; background: #f3dfda; color: #7d2c25; text-align: center; }

@media (max-width: 940px) {
  .connection { display: none; }
  .hero { grid-template-columns: 1fr .55fr; gap: 36px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics div:nth-child(2) { border-right: 0; }
  .metrics div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .category-bar { grid-template-columns: repeat(3, 1fr); }
  .category-bar button:nth-child(3) { border-right: 0; }
  .category-bar button:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .notation { grid-template-columns: 1fr; }
  .method { grid-template-columns: 38px 1fr; }
  .method dl { grid-column: 2; margin-top: 28px; }
}

@media (max-width: 720px) {
  .site-header { height: auto; min-height: 60px; padding: 9px 13px; }
  .seal { width: 35px; height: 35px; font-size: 19px; }
  .brand b { font-size: 11px; }
  .brand small { display: none; }
  .site-header nav { gap: 10px; }
  .site-header nav a { font-size: 10px; }
  .site-header nav a:nth-child(3) { display: none; }
  main { width: min(100% - 26px, 1220px); }
  .hero { min-height: 0; grid-template-columns: 1fr; padding: 58px 4px 70px; }
  .hero h1 { font-size: clamp(39px, 13vw, 60px); }
  .hero-copy > p { font-size: 15px; }
  .snapshot { margin-right: 10px; padding: 26px; box-shadow: 10px 10px 0 var(--paper-deep); }
  .snapshot strong { font-size: 61px; }
  .metrics div { padding: 19px 16px; }
  .catalog { padding: 70px 0 76px; }
  .section-heading { align-items: start; flex-direction: column; }
  .filters { grid-template-columns: 1fr; }
  .category-bar { grid-template-columns: 1fr 1fr; }
  .category-bar button { border-bottom: 1px solid var(--line); }
  .category-bar button:nth-child(odd) { border-right: 1px solid var(--line); }
  .category-bar button:nth-child(even) { border-right: 0; }
  .category-bar button:nth-last-child(-n+2) { border-bottom: 0; }
  .results-meta small { display: none; }
  .table-shell { background: transparent; box-shadow: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tbody tr { position: relative; padding: 15px 14px 48px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 8px 20px rgba(72, 54, 31, .06); }
  td {
    min-height: 30px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 0;
    border: 0;
    white-space: normal;
    text-align: right !important;
  }
  td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .06em;
  }
  td:first-child { padding-top: 0; }
  td:first-child .code-button { font-size: 18px; }
  .material-cell { font-size: 16px; }
  td:last-child {
    position: absolute;
    right: 14px;
    bottom: 11px;
    left: 14px;
    width: auto;
    padding: 0;
  }
  td:last-child::before { display: none; }
  .query-link { width: 100%; justify-content: center; }
  .notation { padding: 70px 4px; }
  .notation-grid { grid-template-columns: 1fr; }
  .method { padding: 62px 4px 80px; }
  .method > div { padding-right: 0; }
  .method dl { grid-column: 1 / 3; }
  footer { min-height: 88px; flex-wrap: wrap; padding-block: 18px; }
  footer span { order: 3; flex-basis: 100%; }
}

@media (max-width: 420px) {
  .site-header nav a:first-child { display: none; }
  .hero-actions { align-items: flex-start; flex-direction: column; gap: 16px; }
  .primary-action { width: 100%; justify-content: space-between; }
  .metrics strong { font-size: 19px; }
  .piece-key { grid-template-columns: 1fr; }
  .piece-key span, .piece-key span:nth-child(even) { border-right: 0; border-bottom: 1px solid var(--line); }
  .piece-key span:last-child { border-bottom: 0; }
  .method dl div { grid-template-columns: 90px 1fr; }
}
