:root {
  color-scheme: light;
  --bg: #e9e9e9;
  --bg-raised: #ffffff;
  --bg-hover: #eeeeee;
  --line: #dedede;
  --text: #303030;
  --muted: #737373;
  --accent: #1769aa;
  --accent-strong: #1769aa;
  --danger: #b42318;
  --sidebar-bg: #fafafa;
  --scroll-thumb: #c1c1c1;
  --page-gap: 12px;
  --toolbar-h: 40px;
  --sidebar-w: 272px;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
  font-size: 13px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #242424;
  --bg-raised: #303030;
  --bg-hover: #3d3d3d;
  --line: #484848;
  --text: #e4e4e4;
  --muted: #ababab;
  --accent: #91bce5;
  --accent-strong: #286ba3;
  --danger: #f3a69e;
  --sidebar-bg: #2b2b2b;
  --scroll-thumb: #626262;
  --shadow: 0 1px 5px rgb(0 0 0 / 28%);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Shared stroke icons for reader controls. */
.icon {
  width: 1em;
  height: 1em;
  display: block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toolbar {
  position: relative;
  z-index: 18;
  height: var(--toolbar-h);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, auto);
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
}

/* Permanent seats are grouped by spacing plus a hairline divider between clusters. */
.tb-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  min-width: 0;
}

.tb-divider {
  width: 1px;
  height: 16px;
  background: var(--line);
  flex: 0 0 auto;
}

#page-controls[hidden],
#page-divider[hidden] {
  display: none;
}

.toolbar-left {
  flex-shrink: 0;
}

.toolbar-right {
  justify-content: flex-end;
  min-width: 0;
}

.toolbar-center {
  min-width: 0;
  text-align: left;
  padding-left: 16px;
}

.doc-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
}

.btn {
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn.primary {
  background: var(--accent-strong);
  border-color: transparent;
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

/* After a PDF is open, 打开 steps down to a normal toolbar control. */
#btn-open.demoted {
  background: transparent;
  border-color: transparent;
}

#btn-open.demoted:hover:not(:disabled) {
  background: var(--bg-hover);
  filter: none;
}

.btn.active:not(.primary) {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.btn.icon {
  width: 32px;
  padding: 0;
}

.btn.has-icon {
  gap: 6px;
}

.btn .icon {
  font-size: 15px;
}

.btn.icon .icon {
  font-size: 16px;
}

.btn.tiny .icon {
  font-size: 13px;
}

.btn.tiny {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  height: 28px;
}

.btn.icon.tiny {
  width: 28px;
  padding: 0;
}

/* Author display:inline-flex beats the UA [hidden] rule; enforce it. */
.btn[hidden] {
  display: none !important;
}

/* Toolbar permanent seats stay visible but unframed; spacing groups them. */
.toolbar .btn.toolbar-ghost {
  border-color: transparent;
  background: transparent;
  height: 30px;
}

.toolbar .btn.toolbar-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
}

.toolbar .btn.toolbar-ghost.active:not(.primary) {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: transparent;
}

.page-box {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.page-box .page-input {
  width: 3.2em;
  min-width: 2.5em;
  text-align: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 6px;
  font: inherit;
  color: var(--text);
  -moz-appearance: textfield;
  appearance: textfield;
}

.page-box .page-input:hover {
  border-color: var(--line);
}

.page-box .page-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}

.page-box .page-input::-webkit-outer-spin-button,
.page-box .page-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.page-total {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.page-box {
  font-variant-numeric: tabular-nums;
}

#page-count {
  display: inline-block;
  width: 3.2em;
  text-align: center;
}

.zoom-picker {
  position: relative;
  flex: 0 0 auto;
}

#zoom-button {
  height: 30px;
  min-width: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

#zoom-button .chevron {
  font-size: 13px;
  color: var(--muted);
}

.zoom-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 25;
  min-width: 140px;
  max-height: calc(100dvh - var(--toolbar-h) - 16px);
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-raised);
}

.zoom-menu button {
  display: block;
  position: relative;
  width: 100%;
  padding: 7px 12px 7px 28px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.zoom-menu button:hover,
.zoom-menu button:focus-visible {
  background: var(--line);
  outline: none;
}

.zoom-menu button[aria-checked="true"]::before {
  content: "✓";
  position: absolute;
  left: 8px;
  color: var(--accent);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 4px 0 8px;
  min-width: 0;
  width: 100%;
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-box .search-icon {
  font-size: 14px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 13px;
}

.search-box input::placeholder {
  color: var(--muted);
}

.search-box input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

.search-clear:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.search-clear[hidden] {
  display: none !important;
}

.search-count {
  color: var(--muted);
  font-size: 12px;
  min-width: 56px;
  text-align: right;
  flex: 0 0 auto;
}

.workspace {
  display: flex;
  height: calc(100% - var(--toolbar-h));
}

.sidebar {
  --sidebar-slide-ms: 0.18s;
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--sidebar-bg);
  border-radius: 0;
  box-shadow: none;
  border-right: 1px solid var(--line);
  transition:
    width var(--sidebar-slide-ms) ease,
    flex var(--sidebar-slide-ms) ease,
    border-color var(--sidebar-slide-ms) ease,
    border-width var(--sidebar-slide-ms) ease;
}

.sidebar-inner {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transform: translateX(0);
  transition: transform var(--sidebar-slide-ms) ease;
  will-change: transform;
}

.workspace.sidebar-collapsed .sidebar {
  width: 0;
  flex: 0 0 0;
  border-right-width: 0;
  border-right-color: transparent;
  pointer-events: none;
}

.workspace.sidebar-collapsed .sidebar-inner {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar-head {
  display: flex;
  align-items: center;
  height: 40px;
  flex: 0 0 40px;
  gap: 8px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
}

.sidebar-tabs {
  display: flex;
  align-self: stretch;
  flex: 0 0 144px;
  min-width: 0;
  gap: 2px;
  background: transparent;
  padding: 0;
}

.sidebar-tab {
  flex: 1 1 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
}

.sidebar-tab:hover {
  color: var(--text);
}

.sidebar-tab.active,
.sidebar-tab[aria-selected="true"] {
  background: transparent;
  box-shadow: inset 0 -2px var(--accent);
  color: var(--text);
}

.outline-tree-actions {
  display: inline-flex;
  align-items: center;
  gap: 0;
  flex: 0 0 auto;
}

.outline-tree-actions[hidden] {
  display: none;
}

#btn-sidebar-close {
  margin-left: auto;
}

.outline-tree-actions .btn.icon.tiny {
  width: 26px;
  height: 26px;
}

.outline-tree-actions .icon {
  font-size: 15px;
}

.search-pane-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.search-pane-bar .search-count {
  flex: 1 1 auto;
}

.search-pane-nav {
  display: flex;
  margin-left: auto;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.search-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}

.sidebar-pane {
  display: none;
  overflow: auto;
  overflow-x: hidden;
  padding: 4px 10px 16px;
  min-height: 0;
}

.sidebar-pane.active {
  display: block;
}

#search-pane.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.search-controls {
  flex: 0 0 auto;
  padding-top: 8px;
}

#search-list {
  overflow-y: auto;
  min-height: 0;
}

#search-list > * {
  flex-shrink: 0;
}

.outline-item,
.search-hit {
  width: 100%;
  min-width: 0;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 2px;
  padding: 6px 8px;
  cursor: pointer;
}

.outline-item:hover,
.search-hit:hover {
  background: var(--bg-hover);
}

/* Current hit: thin accent bar on a quiet wash, not a blue card. */
.search-hit {
  position: relative;
}

.search-hit + .search-hit {
  border-top: 1px solid var(--line);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.search-hit.active {
  background: var(--bg-hover);
  box-shadow: inset 2px 0 0 var(--accent);
}

.search-hit.active .meta {
  color: var(--accent);
}

.outline-item.active {
  background: var(--bg-hover);
  box-shadow: inset 2px 0 0 var(--accent);
  color: var(--text);
}

.outline-node {
  display: block;
}

.outline-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.outline-toggle {
  flex: 0 0 20px;
  width: 20px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  font-size: 10px;
  line-height: 1;
  padding: 0;
}

.outline-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Leaves keep a reserved (invisible) toggle so sibling titles align. */
.outline-toggle.is-leaf {
  visibility: hidden;
  pointer-events: none;
}

.outline-toggle[aria-expanded="false"]::before {
  content: "▸";
}

.outline-toggle[aria-expanded="true"]::before {
  content: "▾";
  color: var(--text);
}

.outline-branch {
  display: none;
}

.outline-branch.expanded {
  display: block;
}

.outline-item {
  display: block;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.45;
}

.outline-item:focus:not(:focus-visible) {
  outline: none;
}

.outline-item:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.search-hit {
  display: block;
  overflow: hidden;
}

.search-hit .meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-hit .snippet {
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.5;
}

.search-hit .snippet mark {
  background: #d7a13b;
  color: #111;
  border-radius: 2px;
}

.empty-side {
  color: var(--muted);
  font-size: 13px;
  padding: 16px 10px;
}

.viewer-wrap {
  position: relative;
  flex: 1;
  overflow: auto;
  /* Prefetch resizes placeholders manually; disable browser scroll anchoring to avoid double compensation. */
  overflow-anchor: none;
  background: var(--bg);
}

.pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 48px;
  gap: var(--page-gap);
}

.pdfViewer .page {
  /* This viewer sizes the page itself; PDF.js default borders would shrink
     the percentage-sized canvas but leave the text viewport unchanged. */
  border: 0;
}

.page {
  /* Only the official text layer participates in native text selection. */
  -webkit-user-select: none;
  user-select: none;
  position: relative;
  background: #fff;
  box-shadow: var(--shadow);
  line-height: 0;
}

.page canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.page .textLayer,
.page .linkLayer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
}

.page .textLayer {
  opacity: 1;
  z-index: 2;
  -webkit-user-select: text;
  user-select: text;
}

.page .linkLayer {
  z-index: 3;
  pointer-events: none;
}

.page .textLayer span {
  color: transparent;
  position: absolute;
  white-space: pre;
  transform-origin: 0% 0%;
  cursor: text;
}

.page .textLayer ::selection {
  background: rgb(0 120 215 / 0.45);
  color: transparent;
}

.page .textLayer br::selection {
  background: transparent;
  color: transparent;
}

.page .linkLayer a {
  position: absolute;
  cursor: pointer;
  pointer-events: auto;
}

.page .hlLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.page .hl {
  position: absolute;
  background: rgba(255, 196, 0, 0.38);
  pointer-events: none;
}

.page .hl.current {
  background: rgba(80, 160, 255, 0.45);
}

.drop-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: var(--muted);
}

.drop-hint h1 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 18px;
  font-weight: 400;
}

.drop-hint p {
  margin: 0 0 16px;
  font-size: 13px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: auto;
  padding: 24px;
}

#btn-open-empty {
  margin: 0 0 16px;
}

.empty-state .empty-shortcut {
  font-size: 12px;
  margin: 0;
}

.drop-hint.hidden {
  display: none;
}

.viewer-wrap.dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -12px;
}

.translate-bubble {
  position: fixed;
  z-index: 20;
  width: min(420px, 100%);
  max-width: 420px;
  max-height: min(70vh, 480px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 3px 14px rgb(0 0 0 / 14%);
}

.bubble-body {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
}

.bubble-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* Actions stay legible: hierarchy comes from type size and muted source,
   never from fading interactive controls. */
.bubble-close {
  color: var(--muted);
}

.bubble-close:hover {
  color: var(--text);
}

.bubble-actions-spacer {
  flex: 1 1 auto;
  min-width: 4px;
}

.translate-chip {
  position: fixed;
  z-index: 19;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.translate-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.translate-chip[hidden] {
  display: none !important;
}

.modal-card label.setting-checkbox {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--text);
  cursor: pointer;
}

.modal-card label.setting-checkbox input[type="checkbox"] {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
}

.modal-card label.setting-checkbox .setting-checkbox-label {
  flex: 1 1 auto;
  line-height: 1.4;
}

.bubble-source,
.bubble-result {
  margin-top: 0;
  line-height: 1.5;
}

/* Source stays quieter than the translation: smaller, dimmer, no titles. */
.bubble-source {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.bubble-result {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.bubble-source.bubble-term,
.bubble-result.bubble-term,
.bubble-result.streaming {
  white-space: pre-wrap;
}

.bubble-source.bubble-passage,
.bubble-result.bubble-passage {
  white-space: normal;
}

.bubble-source.collapsed {
  max-height: 72px;
  overflow: hidden;
}

.source-toggle {
  margin: 4px 0 0;
  font-size: 12px;
}

.settings-advanced {
  margin: 4px 0 12px;
  border-top: 1px solid var(--line);
  padding: 12px 0 0;
}

.settings-advanced summary {
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}

.settings-advanced .hint.compact {
  margin: 8px 0;
}

.settings-advanced label:last-child {
  margin-bottom: 0;
}

.viewer-status {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: var(--bg);
}

.viewer-status[hidden] {
  display: none !important;
}

.viewer-status-text {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 420px;
  overflow-wrap: anywhere;
}

.bubble-passage p {
  margin: 0 0 0.65em;
}

.bubble-passage p:last-child {
  margin-bottom: 0;
}

.bubble-status {
  font-size: 12px;
  color: var(--muted);
  margin-right: auto;
}

.bubble-result.error {
  color: var(--danger);
}

.bubble-result.streaming {
  min-height: 1.5em;
}

.translate-caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: translate-caret-blink 1s step-end infinite;
}

@keyframes translate-caret-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.22);
  display: grid;
  place-items: center;
  z-index: 30;
}

.modal[hidden],
.translate-bubble[hidden] {
  display: none !important;
}

.modal-card {
  width: min(460px, calc(100vw - 24px));
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  box-shadow: 0 8px 32px rgb(0 0 0 / 14%);
}

.modal-card h2 {
  margin: 0 0 20px;
  font-size: 17px;
  font-weight: 600;
}

.modal-card .hint.error {
  color: var(--danger);
}

.modal-card .hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
}

.modal-card label {
  display: block;
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--muted);
}

.modal-card input,
.modal-card select {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.model-picker {
  position: relative;
}

.model-picker-status {
  font-size: 12px;
  margin-top: 4px;
  color: var(--muted);
}

.model-picker-status.error {
  color: var(--danger);
}

.model-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  overflow: auto;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  z-index: 20;
  margin: 0;
  padding: 4px;
  list-style: none;
}

.model-menu[hidden] {
  display: none;
}

.model-menu li button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.model-menu li button:hover,
.model-menu li button:focus-visible {
  background: var(--bg-hover);
}

.model-menu .model-id {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 6px;
}

/* Page box reads as an editable control; — / — when no document is open. */
.page-box .page-input:disabled {
  opacity: 0.7;
  border-color: transparent;
  background: transparent;
  cursor: default;
}

.bubble-actions .btn,
.sidebar-head .btn,
.search-pane-nav .btn {
  background: transparent;
  border-color: transparent;
}

.bubble-actions .btn:hover:not(:disabled),
.sidebar-head .btn:hover:not(:disabled),
.search-pane-nav .btn:hover:not(:disabled) {
  background: var(--bg-hover);
}

.sidebar-head .btn.icon.tiny,
.search-pane-nav .btn.icon.tiny {
  width: 28px;
  height: 28px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page-total b {
  font-weight: 400;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-inner {
    transition: none;
  }
  .translate-caret {
    animation: none;
  }
}

/* ---- Tight chrome: keep toolbar on one row, sidebar becomes overlay ---- */
.workspace {
  position: relative;
}

@media (max-width: 1020px) {
  .toolbar-center {
    display: none;
  }
  .toolbar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    padding: 0 10px;
  }
  .toolbar-left,
  .toolbar-right {
    gap: 8px;
  }
}

@media (max-width: 900px) {
  /* Overlay panel: never squeezes the page to 90px. */
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 15;
    box-shadow: var(--shadow);
  }
  .workspace.sidebar-collapsed .sidebar {
    visibility: hidden;
  }
  #btn-forward {
    display: none;
  }
}

@media (max-width: 360px) {
  /* 320–360px: keep one-row toolbar; icon-only 打开/目录 if labels still overflow. */
  #btn-open span,
  #btn-sidebar span {
    display: none;
  }
  #btn-open,
  #btn-sidebar {
    width: 36px;
    padding: 0;
    justify-content: center;
  }
  .toolbar {
    gap: 4px;
    padding: 0 6px;
  }
  .toolbar-left,
  .toolbar-right {
    gap: 4px;
  }
  #zoom-button span:not(.icon):not(.chevron) {
    max-width: 4.5em;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 620px) {
  /* Tightest chrome: drop one-shot controls, keep one path per job. */
  #btn-back {
    display: none;
  }
  #btn-zoom-in,
  #btn-zoom-out {
    display: none;
  }
  .toolbar .tb-divider {
    display: none;
  }
  .toolbar .btn {
    padding-left: 8px;
    padding-right: 8px;
  }
  .toolbar-left,
  .toolbar-right {
    gap: 4px;
  }
  .toolbar > * {
    min-width: 0;
  }
  #zoom-button {
    min-width: 0;
  }
  #zoom-button .chevron {
    display: none;
  }
  .page-box .page-input,
  #page-count {
    width: 2.6em;
  }
}

@media (max-width: 360px) {
  .toolbar .btn.icon,
  #btn-open,
  #btn-sidebar {
    width: 28px;
  }
  #zoom-button {
    max-width: 76px;
    padding-inline: 4px;
  }
}
