:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #edf4f1;
  --text: #17211f;
  --muted: #66736f;
  --line: #d9e2df;
  --accent: #007a65;
  --accent-2: #0f9b8e;
  --danger: #b42318;
  --warning: #b86e00;
  --shadow: 0 14px 30px rgba(25, 44, 39, 0.1);
  font-family: "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(20px, 2.2vw, 30px);
  line-height: 1.15;
  letter-spacing: 0;
}

.app-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  min-height: 38px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

.button {
  padding: 0 13px;
  white-space: nowrap;
}

.button-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 21px;
}

.icon-button.active {
  color: var(--warning);
  border-color: rgba(184, 110, 0, 0.45);
  background: #fff7e8;
}

.compact {
  width: 32px;
  min-height: 32px;
  font-size: 20px;
  flex: 0 0 32px;
}

.app-shell {
  height: calc(100vh - 76px);
  min-height: 520px;
  display: grid;
  grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
}

.search-pane {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-box {
  padding: 16px 16px 10px;
}

.search-box label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 7px;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.search-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 101, 0.12);
}

.search-input-wrap span {
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}

#searchInput {
  min-width: 0;
  width: 100%;
  height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
}

.quick-filters {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding: 0 16px 12px;
}

.quick-filters button {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: #24413b;
  padding: 0 11px;
  cursor: pointer;
}

.online-search {
  margin: 0 16px 14px;
  padding: 12px;
  background: #f7fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
}

.online-search strong {
  display: block;
  font-size: 14px;
  margin-bottom: 3px;
}

.online-search span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.online-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.online-actions a {
  min-width: 0;
  min-height: 32px;
  border-radius: 6px;
  border: 1px solid rgba(0, 122, 101, 0.22);
  background: #fff;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.result-bar {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-bar strong {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

#sortMode {
  width: 112px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 8px;
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
}

.result-item {
  border-bottom: 1px solid var(--line);
}

.result-button {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 13px 16px;
  cursor: pointer;
  color: var(--text);
  display: grid;
  gap: 7px;
}

.result-button:hover,
.result-button:focus-visible {
  background: #f4faf8;
  outline: 0;
}

.result-button.selected {
  background: #e7f5f1;
  box-shadow: inset 4px 0 0 var(--accent);
}

.result-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.result-title {
  font-weight: 700;
  line-height: 1.35;
  min-width: 0;
  overflow-wrap: anywhere;
}

.favorite-dot {
  color: var(--warning);
  flex: 0 0 auto;
}

.result-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.result-summary {
  color: #3e4b48;
  font-size: 13px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

mark {
  background: #fff0b8;
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

.empty-state {
  padding: 24px 16px;
  color: var(--muted);
}

.reader-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #eef3f1;
}

.detail-panel {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(360px, 1.6fr);
  gap: 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.detail-panel h2 {
  margin: 0;
  font-size: clamp(19px, 2vw, 28px);
  line-height: 1.18;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.meta-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 14px;
}

.meta-grid div {
  min-width: 0;
}

.meta-grid dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 2px;
}

.meta-grid dd {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.summary-text {
  grid-column: 1 / -1;
  margin: 0;
  color: #3b4946;
  font-size: 14px;
  line-height: 1.55;
}

#docFrame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
    position: static;
  }

  .app-shell {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .search-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 52vh;
  }

  .reader-pane {
    min-height: 74vh;
  }

  .detail-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-header {
    padding: 12px;
    gap: 10px;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .button {
    min-height: 36px;
    padding: 0 10px;
  }

  .search-box,
  .quick-filters,
  .online-search,
  .result-bar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .online-search {
    margin-left: 12px;
    margin-right: 12px;
  }

  .result-button {
    padding-left: 12px;
    padding-right: 12px;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }
}
