:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #182026;
  --muted: #66737f;
  --line: #d8e0e6;
  --accent: #176b5b;
  --accent-strong: #0f4e43;
  --mark: #fff0a6;
  --shadow: 0 12px 36px rgba(24, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
}

.search-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.status {
  min-width: 74px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
}

.search-box {
  display: grid;
  gap: 8px;
}

.search-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.keyword-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 12px 13px;
  color: var(--text);
  background: transparent;
}

.keyword-input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

button {
  min-width: 42px;
  height: 42px;
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--accent-strong);
  background: #eef7f4;
  cursor: pointer;
}

button:hover {
  background: #dff0eb;
}

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

.results {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 4px;
}

.result {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(24, 32, 38, 0.03);
  cursor: pointer;
}

.result:hover {
  border-color: #9fc6bd;
}

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.page-badge {
  color: var(--accent-strong);
  font-weight: 800;
}

.score {
  color: var(--muted);
  font-size: 12px;
}

.snippet {
  margin: 0;
  color: #39454f;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}

mark {
  padding: 0 2px;
  border-radius: 3px;
  background: var(--mark);
  color: inherit;
}

.message {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfc;
  line-height: 1.6;
}

.viewer-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.toolbar button {
  width: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.page-jump {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.page-jump input {
  width: 68px;
  padding: 0;
  text-align: center;
}

.separator {
  width: 1px;
  height: 28px;
  background: var(--line);
}

.open-link {
  margin-left: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  background: #fff;
  text-decoration: none;
  font-size: 14px;
}

.page-surface {
  position: relative;
  display: none;
  margin: 0 auto;
}

.viewer {
  position: relative;
  min-height: 0;
  overflow: auto;
  padding: 22px;
  background: #e8edf0;
}

#pdfCanvas {
  display: block;
  background: #fff;
  box-shadow: var(--shadow);
}

.highlight-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.keyword-highlight {
  position: absolute;
  min-width: 14px;
  min-height: 8px;
  border: 2px solid rgba(220, 38, 38, 0.88);
  border-radius: 2px;
  background: rgba(255, 214, 102, 0.28);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.75);
}

.keyword-highlight::after {
  content: none;
}

.empty-state {
  max-width: 460px;
  display: grid;
  gap: 8px;
  margin: 16vh auto 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  line-height: 1.6;
}

.empty-state strong {
  color: var(--text);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 54vh) minmax(100vh, auto);
  }

  .search-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .search-panel,
  .viewer {
    padding: 14px;
  }

  .header {
    display: grid;
  }

  h1 {
    font-size: 21px;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .open-link {
    margin-left: 0;
  }
}
