:root {
  --bg: #e8eaed;
  --bar: #ffffff;
  --bar-border: #d7dae0;
  --text: #1f2328;
  --muted: #6a7280;
  --btn-hover: #eef0f3;
  --accent: #2563eb;
  --page-shadow: 0 1px 3px rgba(0, 0, 0, .18), 0 4px 14px rgba(0, 0, 0, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1f23;
    --bar: #2a2d33;
    --bar-border: #3a3e46;
    --text: #e6e8eb;
    --muted: #9aa1ad;
    --btn-hover: #363a42;
    --accent: #60a5fa;
    --page-shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 14px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
}

/* toolbar */
.toolbar {
  flex: none; height: 48px; padding: 0 12px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  background: var(--bar); border-bottom: 1px solid var(--bar-border);
  position: relative; z-index: 2;
}
.tb-group { display: flex; align-items: center; gap: 4px; min-width: 0; }
.tb-right { justify-content: flex-end; }
.doc-title { margin-left: 8px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

button { font: inherit; color: inherit; }
.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
}
.btn { padding: 0 10px; }
.icon-btn { width: 32px; }
.btn:hover:not(:disabled), .icon-btn:hover:not(:disabled) { background: var(--btn-hover); }
.btn:disabled, .icon-btn:disabled { opacity: .4; cursor: default; }
.btn svg, .icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.page-input {
  width: 48px; height: 30px; text-align: center; font: inherit; color: inherit;
  background: var(--bg); border: 1px solid var(--bar-border); border-radius: 6px;
}
.page-total { color: var(--muted); padding: 0 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.zoom-select, .mode-select {
  height: 30px; padding: 0 6px; font: inherit; color: inherit; min-width: 120px;
  background: var(--bg); border: 1px solid var(--bar-border); border-radius: 6px; cursor: pointer;
}
.mode-select { min-width: 0; flex: none; margin-left: 4px; }

/* viewer */
.viewer { flex: 1; overflow: auto; position: relative; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; width: max-content; min-width: 100%; }
.page {
  position: relative; background: #fff; box-shadow: var(--page-shadow); flex: none;
}
.page canvas, .page svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.page svg { overflow: hidden; }
.page .page-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #9aa1ad; font-size: 13px;
}
.page .page-error { position: absolute; left: 8px; bottom: 8px; color: #b42318; font-size: 12px; }

.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); text-align: center; padding: 16px; pointer-events: none;
}
.empty svg { width: 56px; height: 56px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; margin-bottom: 8px; }
.empty p { margin: 2px 0; }
.empty strong { color: var(--text); font-weight: 600; }
.viewer.dragover { outline: 3px dashed var(--accent); outline-offset: -10px; }

.status {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%);
  background: var(--bar); border: 1px solid var(--bar-border); border-radius: 8px; padding: 8px 14px;
  box-shadow: var(--page-shadow); max-width: calc(100% - 32px);
}
.status.error { color: #b42318; }

@media (max-width: 640px) {
  .toolbar { grid-template-columns: auto 1fr auto; gap: 6px; padding: 0 8px; }
  .btn span, .doc-title { display: none; }
  .tb-center { justify-content: center; }
  .zoom-select { min-width: 0; width: 92px; }
  .pages { padding: 12px 8px; }
}
