:root {
  --paper: #f2eee5;
  --ink: #171713;
  --muted: #716d63;
  --line: rgba(23, 23, 19, 0.18);
  --accent: #d7ff3f;
  --rust: #b84b2a;
  --panel: rgba(255, 255, 255, 0.46);
  --shadow: 0 24px 80px rgba(41, 35, 23, 0.14);
}

html[data-theme="dark"] {
  --paper: #191a16;
  --ink: #eeeadd;
  --muted: #a9a69c;
  --line: rgba(238, 234, 221, 0.17);
  --panel: rgba(255, 255, 255, 0.045);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Mono", "Microsoft YaHei", monospace;
  min-height: 100vh;
  transition: background .3s ease, color .3s ease;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: .12;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.25'/%3E%3C/svg%3E");
}

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: 72px;
  border-right: 1px solid var(--line);
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 24px 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}
.monogram { color: var(--ink); text-decoration: none; font-weight: 500; letter-spacing: -.08em; font-size: 20px; }
.rail-line { height: 58px; width: 1px; background: var(--line); margin: 18px 0; }
.rail-label { writing-mode: vertical-rl; font-size: 9px; letter-spacing: .25em; color: var(--muted); }
.rail-spacer { flex: 1; }
.rail-button { width: 36px; height: 36px; border: 1px solid var(--line); background: transparent; border-radius: 50%; }

main { margin-left: 72px; }
.hero { min-height: 68vh; padding: 44px clamp(28px, 5vw, 84px) 54px; border-bottom: 1px solid var(--line); position: relative; overflow: hidden; }
.hero::after {
  content: "904";
  position: absolute;
  right: -2vw;
  bottom: -12vw;
  font-family: "Noto Serif SC", serif;
  font-size: clamp(220px, 31vw, 520px);
  line-height: .75;
  color: transparent;
  -webkit-text-stroke: 1px var(--line);
  pointer-events: none;
}
.eyebrow { display: flex; align-items: center; gap: 10px; font-size: 10px; letter-spacing: .16em; color: var(--muted); }
.signal { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent), transparent 72%); }
.hero-grid { display: grid; grid-template-columns: 1.7fr .75fr; gap: 8vw; align-items: end; min-height: 52vh; position: relative; z-index: 1; }
.kicker { margin: 0 0 14px; font-size: 11px; letter-spacing: .28em; color: var(--rust); }
h1 { font-family: "Noto Serif SC", serif; font-size: clamp(62px, 8.2vw, 138px); line-height: .95; letter-spacing: -.08em; margin: 0; font-weight: 600; }
h1 em { font-style: normal; color: var(--rust); }
.hero-meta { margin-bottom: 8px; }
.hero-meta > p { font-family: "Noto Serif SC", serif; font-size: 15px; line-height: 1.9; margin: 0 0 34px; max-width: 420px; }
.sync-card { border-left: 4px solid var(--accent); padding: 4px 0 4px 18px; display: grid; gap: 5px; }
.sync-card span, .sync-card small { font-size: 10px; color: var(--muted); }
.sync-card strong { font-family: "Noto Serif SC", serif; font-size: 18px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.metrics article { min-height: 170px; padding: 28px clamp(20px, 3vw, 46px); border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; }
.metrics article:last-child { border: 0; }
.metrics span { font-family: "Noto Serif SC", serif; font-size: 14px; }
.metrics strong { font-size: clamp(42px, 5vw, 78px); line-height: 1; letter-spacing: -.08em; font-weight: 300; }
.metrics small { font-size: 9px; color: var(--muted); letter-spacing: .18em; }

.workspace { padding: 44px clamp(24px, 4vw, 68px) 100px; }
.toolbar { display: flex; gap: 16px; justify-content: space-between; align-items: stretch; }
.search { min-width: min(540px, 50vw); border-bottom: 1px solid var(--ink); display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-family: "Noto Serif SC", serif; font-size: 18px; }
.search kbd { border: 1px solid var(--line); border-radius: 3px; padding: 4px 7px; font-size: 9px; color: var(--muted); }
.toolbar-actions { display: flex; gap: 10px; }
select, .outline-button { border: 1px solid var(--line); background: var(--panel); padding: 0 16px; min-height: 44px; }
.outline-button:hover { background: var(--ink); color: var(--paper); }
.section-heading { margin: 56px 0 20px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.section-heading p { margin: 0; font-size: 10px; letter-spacing: .16em; }
.view-toggle { display: flex; gap: 3px; }
.view-toggle button { border: 0; background: transparent; color: var(--muted); font-size: 18px; }
.view-toggle button.active { color: var(--rust); }

.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 26px; row-gap: 58px; }
.product-card { min-width: 0; animation: reveal .55s both; }
.image-frame { width: 100%; aspect-ratio: 4 / 3; border: 0; padding: 0; overflow: hidden; position: relative; background: #d9d2c4; box-shadow: var(--shadow); }
.image-frame img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .7s cubic-bezier(.2,.7,.2,1); }
.image-frame:hover img { transform: scale(1.045); }
.image-placeholder { position: absolute; inset: 0; display: grid; place-items: center; background: repeating-linear-gradient(135deg, #d9d2c4, #d9d2c4 8px, #cec5b6 8px, #cec5b6 16px); color: #6e665a; }
.image-placeholder span { border: 1px solid currentColor; padding: 8px 12px; font-size: 9px; letter-spacing: .2em; }
.image-badge { position: absolute; right: 12px; bottom: 12px; background: var(--accent); color: #111; padding: 5px 8px; font-size: 9px; }
.card-copy { padding-top: 16px; position: relative; }
.card-index { color: var(--rust); font-size: 10px; margin-bottom: 11px; }
.card-copy h2 { margin: 0; font-family: "Noto Serif SC", serif; font-size: 20px; line-height: 1.45; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.card-description { color: var(--muted); font-size: 11px; line-height: 1.7; height: 38px; overflow: hidden; }
.card-footer { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 10px; display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; }
.status-pill.active { color: #43742b; }
.status-pill.inactive { color: var(--rust); }
.product-grid.list { display: block; }
.product-grid.list .product-card { display: grid; grid-template-columns: 180px 1fr; gap: 26px; border-bottom: 1px solid var(--line); padding: 18px 0; }
.product-grid.list .image-frame { box-shadow: none; }
.product-grid.table { display: block; overflow-x: auto; }
.catalog-table { width: 100%; border-collapse: collapse; min-width: 1050px; }
.catalog-table th { text-align: left; color: var(--muted); font-size: 9px; letter-spacing: .12em; padding: 12px 10px; border-bottom: 1px solid var(--ink); font-weight: 400; }
.catalog-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 11px; vertical-align: middle; }
.catalog-table tr { transition: background .2s ease; }
.catalog-table tbody tr:hover { background: color-mix(in srgb, var(--accent), transparent 88%); }
.catalog-cover { width: 58px; height: 58px; object-fit: cover; background: #d9d2c4; display: block; }
.catalog-title { max-width: 420px; font-family: "Noto Serif SC", serif; font-size: 14px; line-height: 1.55; }
.catalog-id { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.row-detail-button, .copy-json { border: 1px solid var(--line); background: transparent; padding: 8px 12px; }
.row-detail-button:hover, .copy-json:hover { background: var(--ink); color: var(--paper); }

.empty-state { min-height: 430px; border: 1px dashed var(--line); text-align: center; padding: 80px 20px; position: relative; overflow: hidden; }
.empty-mark { position: absolute; inset: -60px 0 auto; font-size: 240px; line-height: 1; color: transparent; -webkit-text-stroke: 1px var(--line); z-index: -1; }
.empty-state h2 { font-family: "Noto Serif SC", serif; margin: 70px 0 12px; font-size: 34px; }
.empty-state p { color: var(--muted); font-size: 12px; }

dialog { width: min(980px, 92vw); max-height: 90vh; border: 0; padding: 0; background: var(--paper); color: var(--ink); box-shadow: 0 40px 160px #0008; }
dialog::backdrop { background: rgba(10, 10, 8, .74); backdrop-filter: blur(8px); }
.dialog-close { position: sticky; float: right; top: 16px; right: 16px; z-index: 2; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); font-size: 24px; }
.detail { padding: 52px; }
.detail-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.detail-gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #ddd4c6; }
.detail-gallery > .image-placeholder { position: relative; inset: auto; aspect-ratio: 3 / 1; grid-column: 1 / -1; }
.detail h2 { font-family: "Noto Serif SC", serif; font-size: 42px; line-height: 1.2; margin: 36px 0 14px; }
.detail-description { white-space: pre-wrap; font-family: "Noto Serif SC", serif; line-height: 1.9; }
.detail-meta { margin-top: 34px; border-top: 1px solid var(--line); }
.detail-row { display: grid; grid-template-columns: 160px 1fr; gap: 20px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.detail-row span:first-child { color: var(--muted); }
.detail-row a { color: var(--rust); word-break: break-all; }
.detail-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.detail-header h2 { margin-right: auto; }
.raw-panel { margin-top: 44px; }
.raw-panel > h3 { font-family: "Noto Serif SC", serif; font-size: 24px; margin: 0 0 16px; }
.raw-tree { border-top: 1px solid var(--ink); }
.raw-node { border-bottom: 1px solid var(--line); }
.raw-node summary { display: grid; grid-template-columns: minmax(130px, 220px) 1fr; gap: 20px; padding: 10px 0; cursor: pointer; list-style: none; font-size: 11px; }
.raw-node summary::-webkit-details-marker { display: none; }
.raw-node summary::before { content: "+"; color: var(--rust); margin-right: 8px; }
.raw-node[open] > summary::before { content: "−"; }
.raw-key { color: var(--muted); word-break: break-all; }
.raw-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.raw-children { margin-left: 24px; border-left: 1px solid var(--line); padding-left: 18px; }
.raw-leaf { display: grid; grid-template-columns: minmax(130px, 220px) 1fr; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 11px; }
.raw-value { white-space: pre-wrap; word-break: break-all; }
.raw-value a { color: var(--rust); }
.field-count { color: var(--rust); }

@keyframes reveal { from { opacity: 0; transform: translateY(22px); } }
@media (max-width: 920px) {
  .hero-grid { grid-template-columns: 1fr; align-items: center; padding-top: 70px; gap: 42px; }
  .hero { min-height: auto; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search { width: 100%; min-width: 0; }
}
@media (max-width: 620px) {
  .rail { display: none; }
  main { margin: 0; }
  .hero { padding: 28px 20px 46px; }
  h1 { font-size: 58px; }
  .metrics article { min-height: 130px; padding: 18px; }
  .metrics strong { font-size: 44px; }
  .workspace { padding: 30px 16px 80px; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .product-grid { grid-template-columns: 1fr; }
  .detail { padding: 52px 20px 28px; }
  .detail-gallery { grid-template-columns: repeat(2, 1fr); }
}
