:root {
  --ink: #252724;
  --muted: #5f625c;
  --accent: #943e32;
  --accent-bg: #f9eeea;
  --line: #e6e3db;
  --paper: #fffefa;
  --background: #f7f6f2;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--background);
  line-height: 1.6;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: 8px; transform: translateY(-150%); background: white; padding: 8px; z-index: 5; }
.skip:focus { transform: none; }
.shell { max-width: 1120px; padding-inline: 32px; margin-inline: auto; }

.masthead { border-bottom: 1px solid var(--line); background: var(--paper); }
.masthead-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.22rem; font-weight: 750; text-decoration: none; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); }
.brand-mark i { position: relative; width: 19px; height: 19px; border: 1.5px solid #fff3eb; border-radius: 50%; }
.brand-mark i::before { content: ""; position: absolute; inset: 4px; border: 1.5px solid #fff3eb; border-radius: 50%; }
.brand-mark i::after { content: ""; position: absolute; top: 2px; right: 1px; width: 5px; height: 5px; border-radius: 50%; background: #ffccaa; }
nav { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.nav-item, .text-button { background: transparent; border: 0; color: var(--muted); border-radius: 6px; padding: 9px 10px; min-height: 44px; }
.nav-item[aria-pressed="true"] { color: var(--accent); background: var(--accent-bg); font-weight: 700; }
.nav-item:hover, .text-button:hover { color: var(--accent); }
#saved-count:not(:empty) { margin-left: 3px; font-size: .82rem; font-variant-numeric: tabular-nums; }

.intro { padding: 35px 0 20px; }
h1 { font-size: clamp(1.8rem, 3.8vw, 2.55rem); line-height: 1.25; font-weight: 750; letter-spacing: -.02em; }
.intro p { color: var(--muted); margin-top: 8px; }
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 248px);
  grid-template-areas: "search rail" "results rail";
  grid-template-rows: auto 1fr;
  gap: 18px 28px;
  align-items: start;
}
.search { grid-area: search; min-width: 0; }
.search-controls {
  display: flex; align-items: center; gap: 10px; padding: 5px 5px 5px 15px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
}
.search-controls input {
  flex: 1; min-width: 0; min-height: 42px; padding: 6px 2px; border: 0; background: transparent;
}
.search-controls input:focus-visible { outline-offset: -2px; }
.search-mark { width: 16px; height: 16px; flex: 0 0 16px; border: 1.6px solid var(--muted); border-radius: 50%; position: relative; margin-right: 3px; }
.search-mark::after { content: ""; position: absolute; right: -5px; bottom: -2px; width: 7px; height: 1.5px; background: var(--muted); transform: rotate(45deg); }
.primary, .secondary { min-height: 42px; padding: 7px 13px; border-radius: 7px; white-space: nowrap; }
.primary { color: #fff; background: var(--accent); border: 1px solid var(--accent); }
.primary:hover { background: #7e3229; }
.secondary { color: var(--ink); background: var(--paper); border: 1px solid var(--line); }
.secondary:hover:not(:disabled) { border-color: #c9aea5; color: var(--accent); }

.rail { grid-area: rail; min-width: 0; position: sticky; top: 16px; }
.filters, .data-panel { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 13px 15px; }
.filters summary { font-weight: 720; cursor: pointer; color: var(--ink); }
.filters form { display: grid; gap: 10px; margin-top: 10px; }
.filters label { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: .9rem; }
.filters select {
  width: 100%; min-width: 0; min-height: 40px; padding: 6px 27px 6px 9px;
  appearance: none; border-radius: 6px; border: 1px solid var(--line); color: var(--ink);
  background: #faf9f5 linear-gradient(45deg, transparent 50%, var(--muted) 50%) no-repeat calc(100% - 14px) 52% / 4px 4px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 10px) 52%;
  background-size: 4px 4px;
}
.filters .check { display: flex; align-items: center; gap: 8px; min-height: 32px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.filters .text-button { min-height: 34px; justify-self: start; padding: 3px 0; color: var(--accent); font-size: .875rem; }
.data-panel { margin-top: 12px; }
.data-panel h2 { font-size: .95rem; font-weight: 720; margin-bottom: 5px; }
.data-status { display: grid; gap: 4px; color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.data-mode { color: var(--accent); font-weight: 650; }

.results { grid-area: results; min-width: 0; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.results-head h2 { font-size: 1.23rem; font-weight: 730; }
.results-head p, .meta { color: var(--muted); font-size: .875rem; }
.results-head p { margin-top: 3px; }
.date-group { margin: 0 0 16px; }
.date-heading {
  display: flex; align-items: center; gap: 11px; padding: 5px 0; margin-bottom: 6px;
  color: #53544e; font-size: .875rem; font-weight: 650; font-variant-numeric: tabular-nums;
}
.date-heading::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.date-entries { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.notice { padding: 15px 18px 16px; }
.notice + .notice { border-top: 1px solid var(--line); }
.notice:hover { background: #fbfaf6; }
.notice h4 { margin: 0 0 5px; font-size: 1.075rem; line-height: 1.55; }
.notice h4 button { border: 0; padding: 0; background: transparent; text-align: left; font-weight: 720; overflow-wrap: anywhere; }
.notice h4 button:hover { color: var(--accent); }
.badges, .row-meta, .detail-actions, .pager { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; }
.badge { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.badge-stage { padding: 2px 7px; background: var(--accent-bg); color: var(--accent); border-radius: 5px; font-weight: 660; }
.badge-muted { color: #715a2b; background: #f5efdf; }
.purchaser { margin: 5px 0; color: #4f524c; font-size: .94rem; overflow-wrap: anywhere; }
.row-meta { margin-top: 9px; justify-content: space-between; overflow-wrap: anywhere; }
.deadline { color: #6b4b25; }
.empty { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 36px 16px; text-align: center; color: var(--muted); }
.message { margin-bottom: 12px; padding: 10px 13px; border-radius: 8px; }
.error { color: #862f22; background: #fceeea; }
.pager { justify-content: center; margin-top: 12px; }
footer { padding-block: 24px; font-size: .875rem; color: var(--muted); }

dialog { width: min(752px, calc(100% - 24px)); max-height: 88vh; border: 1px solid var(--line); border-radius: 13px; padding: 0; color: var(--ink); background: var(--paper); }
dialog::backdrop { background: #241c1aa3; }
.dialog-head { position: sticky; top: 0; z-index: 1; background: var(--paper); padding: 17px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.dialog-head h2 { font-size: 1.25rem; line-height: 1.5; overflow-wrap: anywhere; }
#dialog-content { padding: 18px 22px 26px; overflow-wrap: anywhere; }
#dialog-content h3 { margin: 18px 0 7px; }
.facts { display: grid; grid-template-columns: 96px minmax(0,1fr); gap: 8px 14px; }
.facts dt { font-size: .9rem; color: var(--muted); }
.facts dd { margin: 0; }
.detail-actions a { display: inline-flex; align-items: center; text-decoration: none; white-space: normal; }
.detail-actions a:hover { text-decoration: underline; }
.detail-body { white-space: pre-wrap; line-height: 1.8; }
.related { padding-left: 20px; }
.related .text-button { text-align: left; }
.source-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.source-row:last-child { border-bottom: 0; }
.source-row .meta { margin: 3px 0 7px; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--ink); color: white; border-radius: 8px; padding: 10px 14px; z-index: 5; }

@media (max-width: 720px) {
  .shell { padding-inline: 14px; }
  .masthead-inner { gap: 8px; }
  .brand { gap: 7px; font-size: 1.07rem; }
  .brand-mark { width: 29px; height: 29px; }
  nav { gap: 0; }
  .nav-item { padding-inline: 8px; font-size: .92rem; }
  .intro { padding: 21px 0 14px; }
  .workspace { grid-template-columns: minmax(0,1fr); grid-template-areas: "search" "rail" "results"; gap: 10px; }
  .rail { position: static; }
  .filters { padding: 9px 12px; }
  .filters form { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px 10px; }
  .filters .check { grid-column: 1 / -1; }
  .data-panel { background: transparent; border: 0; border-radius: 0; margin: 7px 0 0; padding: 0 1px; }
  .data-panel h2 { display: none; }
  .data-status { display: flex; flex-wrap: wrap; gap: 2px 8px; }
  .notice { padding: 13px 14px; }
  .dialog-head, #dialog-content { padding-inline: 14px; }
}
