:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #18212f;
  --muted: #647184;
  --line: #d8dee8;
  --teal: #0f766e;
  --blue: #2563eb;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  padding: 18px 24px 16px;
}

.brand-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  max-width: 1500px;
  margin: 0 auto 14px;
}

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

.build-summary {
  color: var(--muted);
  font-size: 13px;
}

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

.top-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-links a,
.clear-button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 13px;
  text-decoration: none;
}

.top-links a:hover,
.clear-button:hover,
.link-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.result-total {
  min-width: 92px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
  padding: 8px 11px;
  text-align: center;
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr);
  gap: 12px;
  max-width: 1500px;
  margin: 0 auto;
}

.search-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.search-field > label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 0 12px;
}

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.clear-button {
  min-height: 42px;
  padding: 0 14px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1500px;
  margin: 18px auto 0;
  padding: 0 24px 24px;
}

.results-pane,
.detail-pane {
  min-width: 0;
}

.results-pane {
  align-self: start;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.manual-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 186px);
  overflow: auto;
  padding-right: 4px;
}

.manual-card {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  padding: 10px;
  text-align: left;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.manual-card:hover,
.manual-card:focus-within,
.manual-card.is-active {
  border-color: var(--teal);
  box-shadow: 0 8px 22px rgba(15, 118, 110, 0.12);
}

.manual-card-main {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
  width: 100%;
  min-height: 110px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.manual-card-main:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 3px;
}

.manual-card img {
  display: block;
  align-self: stretch;
  width: 80px;
  height: 100%;
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef2f7;
  object-fit: cover;
}

.manual-card-content {
  min-width: 0;
  padding-bottom: 36px;
}

.manual-title {
  display: -webkit-box;
  margin: 0 0 7px;
  overflow: hidden;
  font-weight: 750;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.manual-meta,
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  background: #eef2f7;
  color: #334155;
  padding: 2px 8px;
  white-space: nowrap;
}

.tag.category {
  background: #ecfdf5;
  color: #047857;
}

.manual-card-actions {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.manual-card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 0 10px;
  text-decoration: none;
}

.manual-card-action:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.mobile-pdf-bar {
  display: none;
}

.detail-header {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.detail-header img {
  width: 96px;
  height: 126px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
}

.detail-header h2 {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.28;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  padding: 0 14px;
  text-decoration: none;
}

.primary-action:hover {
  background: #115e59;
}

.detail-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.snippet {
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background: #eef2ff;
  color: #312e81;
  line-height: 1.65;
  padding: 12px;
}

.pdf-frame {
  width: 100%;
  height: min(72vh, 760px);
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f7;
}

.detail-empty,
.empty-list {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .manual-list {
    max-height: none;
  }

  .manual-card {
    min-height: 154px;
  }

  .manual-card-main {
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 14px;
    min-height: 132px;
  }

  .manual-card img {
    width: 108px;
    min-height: 132px;
  }

  .manual-card-content {
    padding-bottom: 40px;
  }

  .detail-pane {
    display: none;
  }

  body.mobile-detail-open {
    overflow: hidden;
  }

  body.mobile-detail-open .detail-pane {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    overflow: auto;
    background: var(--surface);
  }

  body.mobile-detail-open .detail-card {
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
  }

  .mobile-pdf-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 48px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    padding: 7px 10px 7px 12px;
  }

  .mobile-pdf-title {
    display: -webkit-box;
    min-width: 0;
    overflow: hidden;
    font-weight: 750;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .mobile-back {
    flex: 0 0 auto;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--teal);
    font-weight: 750;
    padding: 0 10px;
  }

  body.mobile-detail-open .detail-header,
  body.mobile-detail-open .detail-actions,
  body.mobile-detail-open .snippet {
    display: none;
  }

  body.mobile-detail-open .detail-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
    padding: 0;
  }

  body.mobile-detail-open .pdf-frame {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    border: 0;
    border-radius: 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 14px;
  }

  .brand-row {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-actions,
  .top-links {
    justify-content: flex-start;
  }

  h1 {
    font-size: 21px;
  }

  .workspace {
    margin-top: 14px;
    padding: 0 14px 18px;
  }

  .detail-header {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .detail-header img {
    width: 72px;
    height: 96px;
  }

  .detail-header h2 {
    font-size: 18px;
  }

  .pdf-frame {
    height: 64vh;
    min-height: 320px;
  }
}
