* { box-sizing: border-box; }
:root {
  --blue: #08739a;
  --blue-dark: #07516d;
  --bg: #eef3f5;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #66788a;
  --shadow: 0 6px 24px rgba(17, 24, 39, .12);
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: linear-gradient(90deg, var(--blue-dark), var(--blue));
  color: white;
  box-shadow: var(--shadow);
}
.title { font-size: 22px; font-weight: 700; letter-spacing: .2px; }
.subtitle { font-size: 12px; opacity: .88; margin-top: 3px; }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
button {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: white;
  color: var(--blue-dark);
  font-weight: 700;
  cursor: pointer;
}
button:hover { filter: brightness(.94); }
.pageLabel { white-space: nowrap; font-size: 14px; }
#pageInput {
  width: 66px;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  text-align: center;
  color: var(--text);
}
.layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: calc(100vh - 67px);
}
.sidebar {
  border-right: 1px solid #d7e0e5;
  background: #f7fafb;
  overflow: auto;
  max-height: calc(100vh - 67px);
  padding: 14px;
}
.panel {
  background: var(--panel);
  border: 1px solid #e1e8ec;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(17, 24, 39, .06);
}
h2 {
  margin: 0 0 10px;
  color: var(--blue-dark);
  font-size: 15px;
}
.tocItem {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  margin: 3px 0;
  border-radius: 8px;
  background: #edf7fa;
  color: var(--blue-dark);
  font-weight: 600;
}
.tocItem small { color: var(--muted); font-weight: 400; float: right; }
#searchBox {
  width: 100%;
  border: 1px solid #ccd8df;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 14px;
}
.searchResults {
  margin-top: 10px;
  max-height: 240px;
  overflow: auto;
}
.searchResult {
  display: block;
  text-align: left;
  width: 100%;
  margin: 5px 0;
  padding: 8px;
  background: #f0f4f6;
  color: var(--text);
  font-weight: 400;
  border-radius: 8px;
}
.searchResult strong { color: var(--blue-dark); }
.searchResult span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.25; }
.thumbs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.thumb {
  padding: 5px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #f3f6f8;
  cursor: pointer;
}
.thumb.active { border-color: var(--blue); background: #e4f5fa; }
.thumb img { width: 100%; display: block; border-radius: 6px; }
.thumb span { display: block; text-align: center; color: var(--muted); font-size: 12px; margin-top: 4px; }
.viewerWrap {
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 67px);
}
.viewer {
  flex: 1;
  overflow: auto;
  padding: 22px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.pageStage {
  position: relative;
  width: min(100%, 1134px);
  background: white;
  box-shadow: var(--shadow);
  transform-origin: top center;
}
.pageStage img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}
.linkLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pdfLink {
  position: absolute;
  display: block;
  pointer-events: auto;
  border: 2px solid rgba(8, 115, 154, .0);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0);
}
.pdfLink:hover,
.pdfLink:focus {
  background: rgba(8, 115, 154, .14);
  border-color: rgba(8, 115, 154, .55);
  outline: none;
}
.hint {
  padding: 10px 18px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid #d7e0e5;
  background: #f7fafb;
}
mark { background: #fff3a3; padding: 0 .1em; }
@media (max-width: 850px) {
  .topbar { position: static; align-items: flex-start; flex-direction: column; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: none; border-right: 0; border-bottom: 1px solid #d7e0e5; }
  .viewerWrap { height: auto; min-height: 70vh; }
  .viewer { padding: 12px; }
  .thumbs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
