/* Stable viewports with explicit page controls; native zoom keeps a scroll fallback. */
.paged-view {
  display: grid !important;
  grid-template-rows: minmax(0, 1fr) 48px;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: visible !important;
}
.page-window {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 10px;
  position: relative;
  touch-action: pan-y pinch-zoom;
  overscroll-behavior-x: contain;
}
.paged-view[data-dragging="true"] .page-track {
  user-select: none;
  -webkit-user-select: none;
  cursor: grabbing;
}
.page-window input,
.page-window textarea,
.page-window select,
.page-window [contenteditable="true"] {
  touch-action: auto;
}
.page-window [data-swipe-card]:active {
  /* A card is the drag surface; shrinking it on touch-down breaks its grip. */
  transform: none !important;
}
.page-track {
  display: flex;
  width: 100%;
  height: 100%;
}
.paged-view[data-dragging="true"] .page-track,
.paged-view[data-page-moving="true"] .page-track { will-change: transform; }
.view-sheet {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--page-columns, 1), minmax(0, 1fr));
  gap: 14px;
  align-content: stretch;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y pinch-zoom;
  overflow-anchor: none;
  padding: 2px;
}
/* Offscreen pages remain rendered so dragging and interrupted returns reveal
   a continuous rail. `inert` still excludes them from focus and interaction. */
.paged-view[data-page-layout="flow"] .view-sheet {
  display: flex;
  flex-direction: column;
  align-content: initial;
  gap: 12px;
}
.paged-view[data-page-layout="flow"] .view-sheet > * {
  flex-shrink: 0;
  margin-top: 0;
  margin-bottom: 0;
}
.page-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  height: 48px;
  min-width: 0;
}
.page-arrow {
  width: 48px;
  height: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel, #202720);
  font-size: 21px;
  color: var(--ink);
  touch-action: manipulation;
}
.page-arrow:disabled {
  opacity: 0.28;
}
.page-counter {
  font:
    500 12px/1 ui-monospace,
    monospace;
  font-variant-numeric: tabular-nums;
  min-width: 60px;
  text-align: center;
  color: var(--muted);
}
.page-navigation[data-single="true"] .page-arrow {
  visibility: hidden;
}
.view-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 48px;
}
.view-tabs button {
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.view-tabs button[aria-selected="true"] {
  background: var(--panel);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
.view-tab-panel {
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.view-sheet > * {
  min-width: 0;
  max-width: 100%;
}
@media (max-width: 760px) {
  .view-sheet {
    gap: 8px;
  }
  .view-tabs {
    gap: 3px;
  }
  .view-tabs button {
    padding: 8px 10px;
    font-size: 12px;
  }
  .paged-view {
    gap: 5px;
  }
  .page-navigation {
    gap: 15px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .page-track {
    will-change: auto;
  }
}
.paged-view {
  grid-template-columns: minmax(0, 1fr) !important;
  grid-auto-flow: row;
  align-content: stretch !important;
}
.paged-view[hidden],
.view-tab-panel[hidden] {
  display: none !important;
}
.page-window {
  container-type: size;
}
.view-tabs {
  height: 100%;
}
@media (min-width: 761px) and (max-height: 650px) {
  .paged-view {
    grid-template-columns: minmax(0, 1fr) 48px !important;
    grid-template-rows: minmax(0, 1fr);
    gap: 10px;
  }
  .page-navigation {
    height: 100%;
    flex-direction: column;
    gap: 12px;
  }
  .page-counter {
    min-width: 44px;
    font-size: 11px;
  }
  .page-arrow {
    width: 44px;
  }
}
@media (min-width: 761px) and (max-height: 650px) {
  .page-navigation {
    gap: 2px;
    justify-content: space-between;
  }
}
