:root {
  --bg: #f4f4f5;
  --panel: #fff;
  --border: #d4d4d8;
  --accent: #2563eb;
  --highlight: rgba(250, 204, 21, 0.55);
  --text: #18181b;
  --muted: #71717a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.toolbar .nav-link {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 600;
  align-self: center;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  padding: 0.65rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.toolbar label {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  color: var(--muted);
  gap: 0.2rem;
}

.toolbar label.grow {
  flex: 1;
  min-width: 12rem;
}

.toolbar input,
.toolbar select {
  font-size: 0.95rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.check-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.check-label input {
  width: 1rem;
  height: 1rem;
}

.toolbar button {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
}

.toolbar button:hover {
  background: var(--bg);
}

#btn-search {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pager {
  display: flex;
  align-items: end;
  gap: 0.25rem;
}

.pager #page-input {
  width: 4rem;
}

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 0.75rem;
}

.sidebar h2 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.hit-list,
.toc-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}

.hit-list li,
.toc-list li {
  margin-bottom: 0.35rem;
}

.hit-list button,
.toc-list button {
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1.35;
}

.hit-list button:hover,
.toc-list button:hover,
.hit-list button.active,
.toc-list button.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.hit-list .meta {
  display: block;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.75rem;
}

.hit-list .snip {
  color: var(--muted);
}

.viewer {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.aepp-viewer {
  overflow: hidden;
  padding: 0;
  align-items: stretch;
}

.aepp-page-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1rem;
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.aepp-pages.page-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  background: #fff;
  max-width: 100%;
}

.aepp-page-slot {
  position: relative;
  min-height: 120px;
  background: #fafafa;
}

.aepp-page-inner {
  position: relative;
  margin: 0 auto;
}

.aepp-page-slot .page-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  vertical-align: top;
}

.page-wrap {
  position: relative;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  background: #fff;
}

.highlight-layer {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.highlight-layer span {
  position: absolute;
  background: var(--highlight);
  border-radius: 2px;
}

.status {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
}
