:root {
  --ink: #1f2523;
  --muted: #68716e;
  --line: #dce2dd;
  --paper: #f7f8f4;
  --white: #ffffff;
  --red: #b84b3f;
  --red-dark: #8f342e;
  --teal: #277c78;
  --teal-soft: #dcefeb;
  --gold: #b58a4c;
  --shadow: 0 12px 30px rgba(35, 44, 40, 0.08);
}

* { box-sizing: border-box; }

html { background: var(--paper); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.topbar { background: var(--ink); color: #f9fbf8; }
.topbar-inner { max-width: 1480px; margin: 0 auto; padding: 18px 32px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.55); color: #fff; font-size: 18px; }
.brand strong { display: block; font-size: 15px; letter-spacing: .02em; }
.brand small { display: block; margin-top: 3px; color: #bdc8c2; font-size: 11px; }
.header-status { display: inline-flex; align-items: center; gap: 8px; color: #bdc8c2; font-size: 12px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; background: #65b49c; border-radius: 50%; }
.logout-link { margin-left: 10px; color: #f0c3a9; text-decoration: none; font-size: 11px; }
.logout-link:hover { color: #fff; }

.page-shell { max-width: 1480px; margin: 0 auto; padding: 52px 32px 80px; }
.intro { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 56px; align-items: end; padding-bottom: 38px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 9px; color: var(--red); font-size: 10px; letter-spacing: .16em; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 790px; margin-bottom: 16px; font-family: Georgia, "Songti SC", "STSong", serif; font-size: clamp(32px, 4vw, 60px); line-height: 1.08; font-weight: 500; letter-spacing: 0; }
.intro-copy { max-width: 690px; margin-bottom: 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.intro-note { padding: 18px 18px 17px; border-left: 3px solid var(--gold); background: #eef1eb; }
.note-label { display: block; margin-bottom: 8px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.intro-note p { margin: 0; color: #4f5b54; font-size: 13px; line-height: 1.65; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 36px 0 56px; background: var(--line); border: 1px solid var(--line); }
.stat-card { min-height: 142px; padding: 20px 22px; background: var(--white); }
.stat-label { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin: 22px 0 8px; color: var(--ink); font-size: 30px; font-weight: 650; letter-spacing: 0; }
.stat-card small { color: #89938d; font-size: 11px; }

.period-section { margin-bottom: 60px; }
.section-heading, .results-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 18px; }
h2 { margin-bottom: 0; font-family: Georgia, "Songti SC", "STSong", serif; font-size: 26px; font-weight: 500; letter-spacing: 0; }
.text-button { border: 0; padding: 8px 0; background: transparent; color: var(--teal); cursor: pointer; font-size: 12px; }
.text-button:hover { color: var(--red); }
.period-chart { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px 18px; }
.period-bar { display: grid; grid-template-columns: 78px 1fr 48px; gap: 10px; align-items: center; min-width: 0; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; text-align: left; }
.period-bar-label { font-size: 12px; white-space: nowrap; }
.period-bar-track { height: 7px; overflow: hidden; background: #e7ebe6; }
.period-bar-track span { display: block; height: 100%; background: var(--teal); }
.period-bar strong { color: var(--muted); font-size: 11px; font-weight: 600; text-align: right; }
.period-bar.is-active .period-bar-label, .period-bar.is-active strong { color: var(--red); }
.period-bar.is-active .period-bar-track span { background: var(--red); }

.workspace { display: grid; grid-template-columns: 238px minmax(0, 1fr); gap: 34px; align-items: start; }
.filters { position: sticky; top: 18px; }
.filter-heading { padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.filter-heading h2 { font-size: 23px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 650; }
.field input, .field select { width: 100%; min-height: 39px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 0; outline: 0; background: var(--white); color: var(--ink); font-size: 12px; }
.field input:focus, .field select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(39,124,120,.12); }
.reset-button { width: 100%; min-height: 39px; margin-top: 4px; border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; font-size: 12px; }
.reset-button:hover { background: var(--red-dark); border-color: var(--red-dark); }
.filter-footnote { display: grid; grid-template-columns: 8px auto 8px auto; gap: 7px; align-items: center; margin-top: 24px; color: var(--muted); font-size: 10px; }
.legend-swatch { width: 8px; height: 8px; display: block; }
.legend-swatch.structured { background: var(--red); }
.legend-swatch.image-only { background: var(--teal); }

.results-panel { min-width: 0; }
.results-meta { color: var(--muted); font-size: 12px; }
.record-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; min-height: 500px; }
.record-card { min-width: 0; border: 1px solid var(--line); background: var(--white); transition: box-shadow .2s ease, transform .2s ease; }
.record-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.record-card.is-structured { border-top: 3px solid var(--red); }
.record-card.is-image-only { border-top: 3px solid var(--teal); }
.card-open { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; }
.card-image { position: relative; aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden; background: #eef1ed; }
.card-image img { width: 100%; height: 100%; object-fit: contain; }
.image-placeholder { color: #8e9991; font-size: 11px; }
.card-body { padding: 14px 14px 13px; }
.card-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.museum-label { min-width: 0; overflow: hidden; color: var(--teal); font-size: 10px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.period-label { flex: none; padding: 3px 5px; background: var(--teal-soft); color: var(--teal); font-size: 10px; }
.card-title { min-height: 39px; margin-bottom: 7px; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 14px; line-height: 1.4; font-weight: 650; }
.card-id { margin-bottom: 10px; color: #808c84; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-type { min-height: 33px; margin-bottom: 13px; display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: var(--muted); font-size: 11px; line-height: 1.5; }
.card-footer { display: flex; justify-content: flex-start; flex-wrap: wrap; gap: 8px; border-top: 1px solid #edf0ed; padding-top: 10px; color: #89938d; font-size: 10px; }
.asset-label { white-space: nowrap; }
.category-label { color: var(--teal); }
.category-label.is-uncertain { color: #a66a35; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 28px; color: var(--muted); font-size: 12px; }
.icon-button { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid var(--line); background: var(--white); color: var(--ink); cursor: pointer; font-size: 17px; line-height: 1; }
.icon-button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.icon-button:disabled { opacity: .35; cursor: default; }
.drawer-close { position: absolute; top: 16px; right: 16px; z-index: 2; font-size: 22px; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(18, 27, 23, .45); }
.drawer-backdrop[hidden] { display: none; }
.detail-drawer { position: fixed; inset: 0 0 0 auto; z-index: 11; width: min(590px, 100%); overflow-y: auto; padding: 44px 34px 54px; background: var(--paper); box-shadow: -18px 0 40px rgba(18, 27, 23, .18); transform: translateX(100%); transition: transform .25s ease; }
.detail-drawer.is-open { transform: translateX(0); }
.detail-header { padding-right: 48px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.detail-header h2 { margin-bottom: 10px; font-size: 31px; line-height: 1.22; }
.detail-id { margin: 0; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.detail-gallery { position: relative; min-height: 250px; margin: 24px 0 18px; padding: 12px; background: #e9ede9; }
.detail-gallery img { max-width: 100%; max-height: 440px; object-fit: contain; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.gallery-item { display: grid; gap: 5px; min-width: 0; color: var(--ink); text-decoration: none; }
.gallery-item img { width: 100%; height: 150px; background: #f7f8f6; object-fit: contain; }
.gallery-item span { overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.asset-count { margin-top: 10px; color: var(--muted); font-size: 11px; }
.detail-placeholder { color: #849087; font-size: 12px; }
.asset-count { position: absolute; right: 10px; bottom: 10px; padding: 5px 7px; background: rgba(31,37,35,.82); color: #fff; font-size: 10px; }
.detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 26px; }
.primary-link, .secondary-link { display: inline-block; padding: 10px 13px; text-decoration: none; font-size: 12px; }
.primary-link { background: var(--red); color: #fff; }
.primary-link:hover { background: var(--red-dark); }
.secondary-link { border: 1px solid var(--teal); color: var(--teal); }
.link-note { max-width: 250px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.review-panel { margin: 24px 0 26px; padding: 16px; border: 1px solid var(--line); background: var(--white); }
.review-panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 14px; }
.review-panel-heading h3 { margin-bottom: 0; font-size: 16px; }
.review-state { color: var(--muted); font-size: 10px; text-align: right; }
.review-field { display: block; margin-bottom: 12px; }
.review-field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.review-field select { width: 100%; min-height: 36px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 0; background: var(--paper); color: var(--ink); font-size: 12px; }
.review-field select:focus { border-color: var(--teal); outline: 0; box-shadow: 0 0 0 3px rgba(39,124,120,.12); }
.review-save-button { width: 100%; min-height: 37px; border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; font-size: 12px; }
.review-save-button:hover:not(:disabled) { border-color: var(--red-dark); background: var(--red-dark); }
.review-save-button:disabled { opacity: .55; cursor: default; }
.review-note, .review-message { margin: 10px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.review-message { color: var(--teal); min-height: 15px; }
.detail-fields, .raw-fields { margin: 0; }
.detail-fields > div, .raw-fields > div { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.detail-fields dt, .raw-fields dt { color: var(--muted); font-size: 11px; }
.detail-fields dd, .raw-fields dd { margin: 0; color: var(--ink); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.detail-section { margin-top: 28px; }
.detail-section h3 { margin-bottom: 11px; font-size: 14px; }
.detail-section p { color: var(--muted); font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.source-path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px !important; overflow-wrap: anywhere; }
.loading-state, .empty-state { grid-column: 1 / -1; min-height: 260px; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); font-size: 12px; text-align: center; }
.empty-state strong { color: var(--ink); font-size: 15px; }
.empty-state span { max-width: 320px; line-height: 1.6; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--paper); }
.login-shell { width: min(430px, 100%); padding: 38px; border: 1px solid var(--line); background: var(--white); box-shadow: var(--shadow); }
.login-mark { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 30px; border: 1px solid var(--ink); font-family: Georgia, serif; font-size: 22px; }
.login-shell h1 { margin-bottom: 12px; font-size: 34px; }
.login-copy { margin-bottom: 28px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.login-form label { display: block; margin-bottom: 16px; }
.login-form label span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 650; }
.login-form input { width: 100%; min-height: 42px; padding: 10px; border: 1px solid var(--line); outline: 0; background: var(--paper); color: var(--ink); }
.login-form input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(39,124,120,.12); }
.login-form button { width: 100%; min-height: 42px; margin-top: 8px; border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; font-size: 12px; }
.login-form button:hover { border-color: var(--red-dark); background: var(--red-dark); }
.login-error { min-height: 18px; margin: 12px 0 0; color: var(--red-dark); font-size: 11px; }

@media (max-width: 1180px) {
  .record-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .period-chart { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .topbar-inner, .page-shell { padding-left: 20px; padding-right: 20px; }
  .intro { grid-template-columns: 1fr; gap: 24px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .filters { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
  .filter-heading, .reset-button, .filter-footnote { grid-column: 1 / -1; }
  .field { margin-bottom: 12px; }
}
@media (max-width: 600px) {
  .page-shell { padding-top: 34px; }
  .topbar-inner { align-items: flex-start; }
  .header-status { display: none; }
  h1 { font-size: 34px; }
  .stats-grid { margin-top: 28px; margin-bottom: 42px; }
  .stat-card { min-height: 118px; padding: 16px; }
  .stat-card strong { margin-top: 15px; font-size: 25px; }
  .period-chart { grid-template-columns: 1fr; }
  .workspace { gap: 28px; }
  .filters { grid-template-columns: 1fr; }
  .filter-heading, .reset-button, .filter-footnote { grid-column: auto; }
  .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-body { padding: 11px; }
  .card-title { font-size: 12px; }
  .museum-label, .period-label, .card-id, .card-type, .card-footer { font-size: 9px; }
  .detail-drawer { padding-left: 22px; padding-right: 22px; }
}
