:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --panel: #ffffff;
  --line: #d9d6cf;
  --line-soft: #ece9e2;
  --text: #070707;
  --muted: #68645f;
  --accent: #d71920;
  --accent-dark: #a70f15;
  --accent-soft: #fff0f0;
  --danger: #a33a3a;
  --shadow: 0 18px 44px rgba(7, 7, 7, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 56px 0 auto;
  height: 1px;
  background: #0a0a0a;
  pointer-events: none;
  z-index: 20;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

.brand-strip {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid #0a0a0a;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(14px);
}

.masthead-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 4vw, 72px);
  min-height: 56px;
  padding: 0 18px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-lockup:hover {
  text-decoration: none;
}

.brand-symbol {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  background: transparent;
}

.brand-symbol img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.brand-word {
  color: #050505;
  font-size: clamp(24px, 2vw, 34px);
  font-weight: 950;
  line-height: 0.9;
  letter-spacing: -0.05em;
  white-space: nowrap;
}

.app-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  width: min(1760px, calc(100% - 28px));
  min-height: calc(100vh - 56px);
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 57px;
  align-self: start;
  max-height: calc(100vh - 57px);
  overflow: hidden;
  border-right: 1px solid #0a0a0a;
  background: rgba(255, 255, 255, 0.72);
  padding: 36px 22px;
}

.history-section {
  display: grid;
  max-height: calc(100vh - 129px);
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-title h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.section-title button {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
}

.history-list {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.history-item {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 14px 12px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.history-item:hover,
.history-item.active {
  background: #ffffff;
  box-shadow: inset 3px 0 0 #0a0a0a;
}

.history-query {
  display: block;
  margin-bottom: 7px;
  font-size: 16px;
  font-weight: 700;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.main-panel {
  min-width: 0;
  padding: 36px clamp(22px, 4vw, 58px) 44px;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: clamp(18px, 2.2vw, 34px);
  min-height: 56px;
  margin: 0;
}

.top-actions button {
  position: relative;
  min-height: 56px;
  padding: 0;
  border: 0;
  color: #111111;
  background: transparent;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  transition: color 140ms ease;
}

.top-actions button:hover {
  color: var(--accent);
}

.search-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.search-hero h1 {
  max-width: 760px;
  margin: 0 0 8px;
  font-size: clamp(34px, 3.2vw, 54px);
  line-height: 0.98;
  font-weight: 950;
  letter-spacing: -0.055em;
}

.search-hero p {
  margin: 0;
  color: #272727;
  font-size: clamp(14px, 1.05vw, 17px);
  font-weight: 650;
}

.search-dock {
  position: sticky;
  top: 57px;
  z-index: 18;
  padding: 12px 0 14px;
  background: rgba(245, 245, 242, 0.96);
  backdrop-filter: blur(14px);
}

.search-bar {
  display: grid;
  grid-template-columns: 1fr 120px;
  overflow: hidden;
  border: 1px solid #0a0a0a;
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
}

.search-bar input {
  min-width: 0;
  height: 62px;
  border: 0;
  padding: 0 24px;
  color: var(--text);
  background: #ffffff;
  font-size: 22px;
  font-weight: 720;
  outline: none;
}

.search-bar button {
  border: 0;
  color: #ffffff;
  background: #050505;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.search-bar button:hover {
  background: var(--accent);
}

.keyword-panel {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #ffffff;
}

.keyword-title {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
  line-height: 30px;
  font-weight: 700;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  color: #111111;
  background: var(--accent-soft);
  font-size: 14px;
  font-weight: 700;
}

.keyword-chip span {
  margin-left: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.keyword-empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 30px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.filters label {
  display: flex;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0 12px;
  background: var(--panel);
}

.filters span {
  flex: 0 0 auto;
  color: #2c3841;
  font-size: 15px;
}

.filters select {
  min-width: 0;
  width: 100%;
  border: 0;
  color: #2c3841;
  background: transparent;
  font-size: 15px;
  outline: none;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  color: var(--muted);
  font-size: 16px;
}

#status.error {
  color: var(--danger);
}

.results-list {
  display: grid;
  border-top: 1px solid #0a0a0a;
}

.empty-results {
  padding: 28px 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.paper-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 22px;
  padding: 26px 0;
  border-bottom: 1px solid #d4d0c8;
}

.paper-index {
  color: #1c2931;
  font-size: 17px;
  line-height: 1.5;
}

.paper-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.42;
  font-weight: 880;
  letter-spacing: -0.018em;
}

.paper-title a {
  color: var(--text);
  text-decoration: none;
}

.paper-title a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.title-zh {
  margin: 10px 0 0;
  color: #21343d;
  font-size: 18px;
  line-height: 1.55;
  font-weight: 650;
}

.title-zh.loading {
  color: var(--muted);
  font-weight: 600;
}

.relation-summary {
  margin-top: 10px;
  border-left: 3px solid #0a0a0a;
  padding: 10px 12px;
  color: #222222;
  background: #ffffff;
  font-size: 15px;
  line-height: 1.65;
  font-weight: 560;
  white-space: pre-line;
}

.relation-summary.loading {
  color: var(--muted);
  border-left-color: var(--line);
  background: #fbfdfe;
}

.meta-line {
  margin-top: 9px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.match-line {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.match-line b {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  color: #111111;
  background: var(--accent-soft);
  font-size: 13px;
}

.id-line {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 8px;
  color: #51616b;
  font-size: 14px;
}

.id-line a {
  color: #0067a8;
  text-decoration: none;
}

.id-line a:hover {
  text-decoration: underline;
}

.paper-actions {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 12px;
  min-width: 170px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  color: #111111;
  background: var(--accent-soft);
  font-size: 14px;
  font-weight: 700;
}

.action-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
}

.action-links a {
  color: #0067a8;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.action-links a:hover {
  text-decoration: underline;
}

.download-link {
  color: var(--accent-dark) !important;
}

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding-top: 22px;
}

.pager button {
  min-width: 42px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  color: #27333b;
  font-size: 14px;
}

.page-numbers {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.pager .page-number {
  justify-content: center;
  padding: 0 12px;
}

.pager .page-number.active {
  border-color: var(--accent);
  color: #111111;
  font-weight: 760;
}

.pager button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

@media (max-width: 980px) {
  body::before {
    top: auto;
  }

  .masthead-row {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 8px 14px 0;
  }

  .brand-lockup {
    min-height: 44px;
  }

  .brand-symbol {
    width: 38px;
    height: 38px;
  }

  .brand-symbol img {
    width: 38px;
    height: 38px;
  }

  .brand-word {
    font-size: 26px;
  }

  .app-layout {
    grid-template-columns: 1fr;
    width: min(100% - 22px, 1760px);
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    order: 2;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .history-section,
  .history-list {
    max-height: none;
    overflow: visible;
  }

  .main-panel {
    order: 1;
    padding: 16px 14px 28px;
  }

  .top-actions {
    min-height: 42px;
    gap: 12px;
    justify-content: flex-start;
    margin: 0;
    overflow-x: auto;
  }

  .top-actions button {
    min-height: 42px;
    flex: 0 0 auto;
    font-size: 11px;
  }

  .search-bar,
  .filters,
  .paper-row {
    grid-template-columns: 1fr;
  }

  .search-dock {
    top: 95px;
    padding-top: 10px;
  }

  .keyword-panel {
    display: grid;
  }

  .search-bar button {
    min-height: 48px;
  }

  .search-hero {
    margin-bottom: 16px;
  }

  .search-hero h1 {
    font-size: 31px;
  }

  .filters {
    gap: 10px;
    margin-top: 16px;
  }

  .result-meta {
    display: grid;
    min-height: 64px;
    font-size: 14px;
  }

  .paper-row {
    gap: 10px;
    padding: 18px 0;
  }

  .paper-actions {
    justify-items: start;
    min-width: 0;
  }

  .action-links {
    justify-content: flex-start;
  }
}
