.error {
  background: #eeeeee;
  padding: 0.8em;
}

pre.error {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

a {
  text-decoration: none;
}

/* highlight links that have title starting or ending with a space. */
body:has(footer span[style='']) a.spaced {
  text-decoration: wavy underline crimson;
}

a img {
  border: 0;
}

body {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  position: absolute;
  background: #eeeeee url('/images/crosses.png');
  overflow: hidden;
  padding: 0;
  margin: 0;
  font-family: 'Helvetica Neue', Verdana, helvetica, Arial, Sans;
  line-height: 1.3;
  color: #333333;
}

/* Better align sortable items. */
.ui-sortable-helper > p {
  margin: 0px;
}


/* Fallback helper: Sortable locks height from getRect / placeholder styles.
   .image img { height:100% } then fills the box and captions get clipped.
   Keep width from JS; let height follow content like stock jQuery UI. */
body > .ui-sortable-helper.item {
  overflow: visible;
  height: auto !important;
  max-height: none;
}
body > .ui-sortable-helper.item :is(img.thumbnail, img.wide) {
  height: auto;
}

.main {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /*  position: absolute;*/
  bottom: 60px;
  margin: 0;
  /*  width: 10000%; */
  display: flex;
  overflow-x: auto;
  height: calc(100vh - 40px);
}

footer {
  border-top: 1px solid #3d3c43;
  box-shadow: inset 0px 0px 7px rgba(0, 0, 0, 0.8);
  background: #eeeeee url('/images/noise.png');
  position: fixed;
  left: 0;
  right: 0;
  height: 20px;
  padding: 10px;
  font-size: 80%;
  z-index: 1000;
  color: #ccdcd2;
}

footer form,
.footer-item {
  display: inline;
}

.item-placeholder {
  border: 2px dotted #bbb;
  background: #eee;
  box-sizing: border-box;
  overflow: hidden;
}
.item-placeholder > * {
  display: none;
}

.footer-item {
  margin-left: 8px;
}

.no-results {
  font-style: italic;
}

.omitted-results {
  font-style: italic;
}

.incremental-search {
  position: absolute;
  background-color: white;
  color: black;
  display: inline-block;
  max-height: 300px;
  max-width: 430px;
  padding-top: 5px;
  padding-bottom: 5px;
  padding-right: 10px;
  padding-left: 10px;
  box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.4);
  outline: none;
  overflow-y: auto;
  overflow-x: hidden;
}

.search-term {
  background-color: yellow;
}

.neighbor {
  float: right;
  padding-left: 8px;
  width: 16px;
}

img.remote,
.neighbor img {
  width: 16px;
  height: 16px;
  background-color: #cccccc;
}

.neighbor .wait {
  -webkit-animation: rotatecw 2s linear infinite;
  -moz-animation: rotatecw 2s linear infinite;
  animation: rotatecw 2s linear infinite;
}
.neighbor .fetch {
  -webkit-animation: rotatecw 0.5s linear infinite;
  -moz-animation: rotatecw 0.5s linear infinite;
  animation: rotatecw 0.5s linear infinite;
}
.neighbor .fail {
  -webkit-transform: rotate(15deg);
  -moz-transform: rotate(15deg);
  transform: rotate(15deg);
}

@-webkit-keyframes rotatecw {
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@-moz-keyframes rotatecw {
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@keyframes rotatecw {
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

header {
  top: 0;
}

.page-handle {
  cursor: grab;
}

.page.ui-sortable-placeholder {
  visibility: hidden;
}

footer {
  bottom: 0;
}

.twins,
.journal,
.footer {
  min-height: 1em;
  opacity: 1;
}
.twins:hover,
.journal:hover,
.footer:hover {
  opacity: 1;
}

.story {
  padding-bottom: 5px;
}

.story .item {
  min-width: 40px;
}

/* jQuery UI sortable prevented text selection on item mousedown; SortableJS does not.
   Without this, double-click to edit briefly highlights a word before the textarea opens. */
.story .item:not(.textEditing) {
  -webkit-user-select: none;
  user-select: none;
}
.story .item.textEditing textarea {
  -webkit-user-select: text;
  user-select: text;
}

.story blockquote {
  margin-left: 0;
  padding: 0 10px;
  color: #777;
  border-left: 4px solid #ddd;
}

.data,
.chart,
.image {
  overflow: auto; /* clearfix hack */
  float: right;
  margin-left: 1.4px;
  margin-bottom: 0.4em;
  background: #eeeeee;
  padding: 11.2px;
  width: 183px;
}

.image.wide {
  width: 100%;
  margin-left: 0em;
  padding: 0em;
  padding-bottom: 0.8em;
  float: none;
}

.image.left {
  float: left;
  margin-left: 0em;
  margin-right: 2.8px;
}

.image :is(.thumbnail, .wide) {
  width: 100%;
  height: 100%;
}

/* image overlay */

div.image {
  position: relative;
}

.image img.overlay {
  width: 16px;
  height: 16px;
  position: relative;
  bottom: 22px;
  right: 2px; /* or -2px without float */
  float: right;
  opacity: 0;
  transition: 0.7s ease;
}

.image:hover img.overlay {
  opacity: 1;
}

/* image plugin editor */

.imageEditing #image-options {
  margin-left: 4px;
}

/* end image plugin editor */

.backlinks {
  /*width: 420px;*/
  margin-top: 2px;
  clear: both;
  background-color: #eeeeee;
  padding: 1px;
  color: grey;
  font-size: 80%;
}

.backlinks summary {
  margin-top: 5px;
  margin-left: 5px;
  margin-bottom: 3px;
}

.backlinks div {
  margin-left: 5px;
  margin-right: 2px;
}

.backlinks a {
  color: steelblue;
}

.journal {
  /*width: 420px;*/
  overflow-x: hidden;
  /*  margin-top: 2px; */
  clear: both;
  background-color: #eeeeee;
  padding: 1px;
}

.journal.ui-draggable {
  /*width: 420px;*/
}


.journal.ui-draggable,
.journal.ui-draggable * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  user-drag: none;
  touch-action: none;
}
.journal.ui-state-hover {
  /* Inset shadow avoids border layout shift on journal merge hover. */
  background: #ededed;
  box-shadow: inset 0 0 0 1px #ccc;
}
.main > .journal.ui-draggable-dragging,
.main > .journal.ui-draggable-dragging * {
  pointer-events: none;
}

.action.fork {
  color: black;
}

.action {
  font-size: 0.9em;
  background-color: #cccccc;
  background-size: 24px 24px;
  color: #666666;
  text-align: center;
  text-decoration: none;
  padding: 0.2em;
  margin: 3px;
  float: left;
  width: 18px;
}

.action.separator {
  background-color: #eeeeee;
}

.control-buttons {
  float: right;
  position: relative;
  right: 5px;
  overflow-x: visible;
  white-space: nowrap;
}

.button {
  /*from bootstrap*/
  background-color: #f5f5f5;
  background-image: -ms-linear-gradient(top, #ffffff, #e6e6e6);
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
  background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
  background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
  background-image: linear-gradient(top, #ffffff, #e6e6e6);
  background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
  background-repeat: repeat-x;
  border: 1px solid #cccccc;
  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
  border-color: #e6e6e6 #e6e6e6 #bfbfbf;
  border-bottom-color: #b3b3b3;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
  -webkit-box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.05);
  -moz-box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.05);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.05);

  /*custom*/
  display: inline-block;
  white-space: normal;
  position: relative;
  top: 2px;
  left: 3px;
  font-size: 0.9em;
  text-align: center;
  text-decoration: none;
  padding: 0.2em;
  margin-bottom: 2px;
  color: #2c3f39;
  width: 18px;
}

.button:hover {
  color: #d9a513;
  text-shadow: 0 0 1px #2c3f39;
  box-shadow: 0 0 7px #3d3c43;
}

.button:active {
  box-shadow: inset 0 0 7px #3d3c43;
}

.output-item {
  background-color: #eee;
  padding: 15px;
  margin-block-start: 1em;
  margin-block-end: 1em;
}

.target {
  background-color: #ffffcc !important;
}

.consumed {
  outline: solid 2px orange !important;
}

.highlight {
  outline: solid 2px red;
}

.report p,
.factory p,
.data p,
.chart p,
.footer a,
.image p,
p.caption {
  text-align: center;
  margin-bottom: 0;
  color: gray;
  font-size: 70%;
}

.twins p {
  color: gray;
}

image.remote {
  width: 16px;
  height: 16px;
}

p.readout {
  text-align: center;
  font-size: 300%;
  color: black;
  font-weight: bold;
  margin: 0;
}

.footer {
  clear: both;
  margin-bottom: 1em;
  padding-bottom: 500px;
}

.page {
  float: left; /* inline-block preferred? */
  margin: 8px;
  /* padding: 0 31px; */
  width: 490px;
  flex: 0 0 490px;
  background-color: white;
  /*  height: 100%;  */
  overflow: auto;
  box-shadow: 2px 1px 4px rgba(0, 0, 0, 0.2);
  outline: none;
}
.page.active {
  box-shadow: 2px 1px 24px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.page.plugin > .paper {
  box-shadow: inset 0px 0px 40px 0px rgba(0, 220, 0, 0.5);
}

.page.local > .paper {
  box-shadow: inset 0px 0px 40px 0px rgba(220, 180, 0, 0.7);
}

.page.remote > .paper {
  box-shadow: inset 0px 0px 40px 0px rgba(0, 180, 220, 0.5);
}

.page.recycler > .paper {
  box-shadow: inset 0px 0px 40px 0px rgba(220, 0, 0, 0.5);
}

.paper {
  /*width: 430px;*/
  padding: 30px;
  min-height: 100%;
}

.handle-parent {
  z-index: 0;
  position: relative;
}

.page-handle {
  z-index: 1;
  width: 100%;
  position: absolute;
  left: 0px;
  top: 0px;
}

/* Page drag: .page-handle covers chrome above the story. Title and twins
   content stay interactive; without pointer-events:none on their block
   ancestors, empty header/twins row space steals hits and only a thin
   grab strip remains (classic intent: exceptions are the spans only). */
.header,
.header h1,
.header h2,
.twins,
.twins p {
  pointer-events: none;
}

/* make more specific than ghost style. */
div.pending-remove.page {
  opacity: 0.2;
  transition-property: opacity;
  transition-duration: 300ms;
}

.twins span {
  z-index: 2;
  position: relative;
  pointer-events: auto;
}

.header span {
  z-index: 2;
  position: relative;
  pointer-events: auto;
}

.factory {
  font-size: inherit;
  width: 100%;
  min-height: 150px;
}

textarea {
  font-size: inherit;
  margin-left: 2px;
  resize: vertical;
  width: calc(100% - 12px);
  min-height: 150px;
}

.clickable:hover {
  cursor: pointer;
}

@media all and (max-width: 490px) {
  .page {
    width: 1%;
    margin: 8px;
    padding: 0;
    flex: 0 0 100vw;
    font-size: 0.87rem;
    overflow-x: unset;
  }
}

* {
  scrollbar-width: thin;
  scrollbar-color: #ccc #eee;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
  margin-right: 10px;
}

::-webkit-scrollbar-button:start:decrement,
::-webkit-scrollbar-button:end:increment {
  height: 30px;
  display: block;
  background-color: transparent;
}

::-webkit-scrollbar-track-piece {
  background-color: #eeeeee;
  -webkit-border-radius: 6px;
}

::-webkit-scrollbar-thumb:vertical {
  height: 50px;
  background-color: #cccccc;
  border: 1px solid #eeeeee;
  -webkit-border-radius: 6px;
}

.factory {
  clear: both;
  margin-top: 5px;
  margin-bottom: 5px;
  background-color: #eeeeee;
}
.factory p {
  padding: 10px;
}

.bytebeat .play {
  display: inline-block;
  height: 14px;
  width: 11px;
  padding-left: 3px;
  font-size: 70%;
  color: #999999;
  border: 1px solid #999999;
  border-radius: 8px;
}
.bytebeat .symbol {
  color: #990000;
}

.video {
  margin-top: 16px;
  margin-bottom: 5px;
}

.revision {
  position: relative;
  font-size: 24px;
  color: rgba(128, 32, 16, 0.7); /* #7b2106 */
  font-weight: bold;
}

.revision span {
  background: rgba(255, 255, 255, 0.8);
  padding: 10px;
  position: absolute;
  display: block;
  text-align: center;
  top: -40px;
  right: 10px;
  transform: rotate(-15deg);
  -webkit-transform: rotate(-15deg);
  -moz-transform: rotate(-15deg);
}

.favicon {
  position: relative;
  margin-bottom: -6px;
}

.ghost {
  opacity: 0.6;
  border-color: #eef2fe;
}

/* === Parity mobile / SortableJS item+page controls (append-only; stock above untouched) === */

.wiki-item-drag > p,
.sortable-drag > p,
.item-placeholder > p {
  margin: 0px;
}

/* Mobile item helpers keep a grabbing hand; desktop items use body move/copy/no-drop. */
/* Insert slot: item-sized (JS locks width/height on touch + desktop). */
.item-placeholder {
  border: none !important;
  background: #eee !important;
  box-shadow: none !important;
  outline: 1px dotted #bbb !important;
  outline-offset: -1px;
  opacity: 1 !important;
  box-sizing: border-box;
  overflow: hidden !important;
}
.item-placeholder .item-toolbar,
.item-placeholder .item-drag-handle,
.item-placeholder .item-edit-button,
.item.wiki-item-chosen .item-toolbar,
.item.wiki-item-chosen .item-drag-handle,
.item.wiki-item-chosen .item-edit-button,
.item.wiki-item-drag-sizing .item-toolbar,
.item.wiki-item-drag-sizing .item-drag-handle,
.item.wiki-item-drag-sizing .item-edit-button {
  display: none !important;
}

/* Hide all content in the insert slot — only the dotted box should show.
   visibility:hidden is not enough: nested `visibility:visible` (plugin imgs,
   etc.) paints the original item in place during a move. display:none on
   children + a JS-locked height keeps the grey slot without showing the item.
   Origin item content is the .shadow-copy, visible only while Shift-copying. */
.item-placeholder,
.item-placeholder * {
  color: transparent !important;
  caret-color: transparent !important;
}
.item-placeholder > * {
  display: none !important;
}
.item-placeholder::before,
.item-placeholder::after {
  content: none !important;
  display: none !important;
}

.wiki-item-chosen {
  cursor: auto;
}

/* Chosen (mousedown) is still the real item until drag distance is met.
   Do not clip captions the way the grey insert slot does. */
.wiki-item-chosen:not(.item-placeholder) {
  overflow: visible;
}

/* Helper inherits body cursor (move / copy / no-drop) — classic FedWiki.
   Desktop: full item clone, transparent page background showing through. */
.wiki-item-drag.sortable-fallback,
.sortable-fallback.wiki-item-drag,
.wiki-item-drag {
  opacity: 1 !important;
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  border: none !important;
  z-index: 10000;
}

.wiki-item-drag.sortable-fallback,
.sortable-fallback.wiki-item-drag {
  cursor: inherit !important;
  /* Slot lock is cloneNode'd onto the helper; unlock so captions match stock. */
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
}

/* Desktop item drag: header/journal/handle controls must not override move/copy/no-drop. */
body.wiki-item-story-dragging .page,
body.wiki-item-story-dragging .page * {
  cursor: inherit !important;
}

.wiki-item-drag.sortable-fallback :is(img.thumbnail, img.wide),
.sortable-fallback.wiki-item-drag :is(img.thumbnail, img.wide),
.wiki-item-lineup-helper :is(img.thumbnail, img.wide) {
  max-width: 100% !important;
  height: auto !important;
}


/* Mobile handle-reorder: full-size clone, faded so the item-sized insert slot
   (where the item will land) stays readable underneath. */
body.wiki-item-handle-drag .sortable-fallback.item,
body.wiki-item-handle-drag .wiki-item-drag.sortable-fallback {
  opacity: 0.4 !important;
  visibility: visible !important;
  pointer-events: none !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Handle / long-press helpers are on body — match mobile .page text size
   (clone loses .page ancestor; without this the finger preview reflows taller). */
body.wiki-item-lineup-dragging .wiki-item-lineup-helper {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media all and (max-width: 490px) {
  body.wiki-item-handle-drag .sortable-fallback.item,
  body.wiki-item-handle-drag .wiki-item-drag.sortable-fallback,
  body.wiki-item-lineup-dragging .wiki-item-lineup-helper {
    font-size: 0.87rem;
  }
}


.sortable-fallback.item .item-toolbar,
.sortable-fallback.item .item-drag-handle,
.sortable-fallback.item .item-edit-button {
  display: none !important;
}

/* Source preview while Shift-copying only — never visible during a normal move.
   Visibility is driven by jQuery hide/show (inline display) like classic FedWiki;
   these rules are a backup if inline styles are cleared. */
.shadow-copy {
  pointer-events: none !important;
}

.shadow-copy:not(.is-copy-preview) {
  display: none !important;
}

.shadow-copy.is-copy-preview {
  display: block !important;
}

/* Desktop classic page drag:
   - Drag helper = the page under the cursor
   - Ghost = empty reserved column (invisible slot, same as .ui-sortable-placeholder) */
.wiki-page-ghost {
  opacity: 0.45;
}

body:not(.wiki-page-lineup-shrunk) .main > .page.wiki-page-ghost {
  /* visibility:hidden keeps layout space without painting a grey placeholder box.
     Pointer capture lives on body during drag, not the ghost handle. */
  visibility: hidden !important;
}

.wiki-page-drag,
.sortable-fallback.page {
  cursor: grabbing !important;
  z-index: 10000;
  pointer-events: none;
}

/* Desktop helper is a 1:1 copy of the lineup page — full opacity, same page controls.
   SortableJS sets inline opacity: 0.8 on fallback clones; beat that until remove. */
body:not(.wiki-page-lineup-shrunk) .sortable-fallback.page,
body:not(.wiki-page-lineup-shrunk) .wiki-page-drag.page {
  overflow: visible !important;
  visibility: visible !important;
  opacity: 1 !important;
  background: #fff !important;
  box-shadow: 2px 1px 24px rgba(0, 0, 0, 0.4);
}

body:not(.wiki-page-lineup-shrunk) .sortable-fallback.page > *,
body:not(.wiki-page-lineup-shrunk) .wiki-page-drag.page > * {
  visibility: visible !important;
  opacity: 1 !important;
}

/* Classic desktop: fade to 20% when the page will be removed (drag above the window).
   SortableJS fallback clones set inline opacity: 0.8, so this must beat that. */
div.pending-remove.page,
.wiki-page-drag.pending-remove,
.sortable-fallback.page.pending-remove {
  opacity: 0.2 !important;
  transition-property: opacity;
  transition-duration: 300ms;
  box-shadow: none !important;
}

/* Mobile page drag: half-size lineup, dashed insert slot, mini label under finger.
   Kill overscroll while shrunk so a flick through the page header stays a dismiss,
   not an iOS pointer-cancel. */
body.wiki-page-lineup-shrunk {
  overscroll-behavior: none;
  touch-action: none;
}

body.wiki-page-lineup-shrunk .main {
  scroll-snap-type: none;
  scroll-padding-inline: 55vw;
}

body.wiki-page-lineup-shrunk .main > .page:not(.wiki-page-ghost) {
  zoom: 0.5;
  transition: none;
  /* Beat mobile overflow-x:hidden / min-width:0 which otherwise clip zoomed pages. */
  overflow: visible !important;
  min-width: 100vw !important;
  max-width: none !important;
}

@supports not (zoom: 1) {
  body.wiki-page-lineup-shrunk .main > .page:not(.wiki-page-ghost) {
    transform: scale(0.5);
    transform-origin: top left;
    margin-right: -50%;
    margin-bottom: -50%;
    overflow: visible !important;
    min-width: 100vw !important;
    max-width: none !important;
  }
}

body.wiki-page-lineup-shrunk .wiki-page-ghost,
body.wiki-page-lineup-shrunk .main > .page.wiki-page-ghost {
  zoom: 1 !important;
  transform: none !important;
  margin: 8px 4px !important;
  margin-right: 4px !important;
  margin-bottom: 8px !important;
  flex: 0 0 13px !important;
  width: 13px !important;
  min-width: 13px !important;
  max-width: 13px !important;
  align-self: stretch !important;
  height: auto !important;
  min-height: 0 !important;
  opacity: 1 !important;
  background-color: var(--wiki-ghost-bg, #e8e8e8) !important;
  border: 2px dashed #666 !important;
  box-shadow: none !important;
  overflow: hidden !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

body.wiki-page-lineup-shrunk .wiki-page-ghost > * {
  display: none !important;
}

/* Pending remove-from-lineup: soft dismiss, not delete-red. */
body.wiki-page-lineup-shrunk .main > .page.pending-remove.wiki-page-ghost {
  border-color: #666 !important;
  background: #ddd !important;
}

/* Mobile remove-from-lineup: 20px full-width top strip. Keep next to label styles
   so partial client deploys ship JS + page header strip together (sortablePages.js). */
.page-drag-targets {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  z-index: 100000;
  pointer-events: none;
  justify-content: stretch;
  align-items: stretch;
  gap: 0;
  box-sizing: border-box;
}

.page-drag-targets.is-active {
  display: flex;
}

.page-drag-targets-trash-only .page-drag-target-trash {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
}

.page-drag-target {
  pointer-events: none;
  height: 20px;
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  border: 2px dashed #8a8a8a;
  background: rgba(255, 255, 255, 0.28);
  color: #333;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
  transition: background-color 120ms, border-color 120ms, color 120ms;
}

.page-drag-target.is-unavailable {
  visibility: hidden;
}

.page-drag-target-icon {
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-drag-target-icon svg {
  width: 16px;
  height: 16px;
}

.page-drag-target-trash .page-drag-target-icon {
  color: #555;
}

.page-drag-target.is-hot {
  border-style: solid;
  border-color: #333;
  background: rgba(255, 255, 255, 0.45);
}

.page-drag-target-trash.is-hot {
  border-color: #c62828;
  background: rgba(255, 235, 238, 0.4);
  color: #c62828;
  box-shadow: 0 2px 10px rgba(198, 40, 40, 0.2);
}

.page-drag-target-trash.is-hot .page-drag-target-icon {
  color: #c62828;
}

/* Invisible pin at original lineup slot — only anchors the red origin string. */
.wiki-page-drag-origin-pin {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  max-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  align-self: stretch;
  height: auto;
  min-height: 0;
  pointer-events: none;
  opacity: 0;
  overflow: visible;
  position: relative;
}

/* Red “string” from original slot center to the drag label. */
.wiki-page-drag-string {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100000;
  pointer-events: none;
  overflow: visible;
}

.wiki-page-drag-string.is-active {
  display: block;
}

.wiki-page-drag-string-line {
  stroke: #c62828;
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
  opacity: 0.9;
}

/* Extra inline room so first/last pages can center while dragging. */
.wiki-page-drag-spacer {
  flex: 0 0 auto;
  align-self: stretch;
  height: 1px;
  pointer-events: none;
  opacity: 0;
}

/* Mobile: hide Sortable's full-page fallback — label follows the finger instead. */
body.wiki-page-lineup-shrunk .wiki-page-drag,
body.wiki-page-lineup-shrunk .sortable-fallback.page {
  opacity: 0 !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: none !important;
  box-shadow: none !important;
  pointer-events: none !important;
  z-index: 10000;
}

.wiki-page-drag-label {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100001;
  pointer-events: none;
  will-change: transform;
}

.wiki-page-drag-label.is-active {
  display: block;
}

.wiki-page-drag-label-page {
  width: 84px;
  height: 117px;
  box-sizing: border-box;
  padding: 8px 9px;
  background: #fff;
  border: 1px solid #888;
  border-radius: 5px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.wiki-page-drag-label-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  color: #222;
  word-break: break-word;
  overflow: hidden;
  max-height: 100%;
}

.wiki-page-drag-label.is-pending-remove .wiki-page-drag-label-page {
  background: #ececec;
  border-color: #666;
  opacity: 0.85;
}

/* Mobile: selected item — suppress native text long-press; body long-press = cross-page;
   ⋮⋮ handle = same-page Sortable reorder. Allow pan-y so the first scroll
   gesture on the selected item still moves the page (touch-action:none ate it). */
.item.handle-selected {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
  /* Plugin boards may set overflow; keep the pinned overlay paintable. */
  overflow: visible;
}

/* While a long-press hold is armed, lock pan so the browser cannot steal the
   gesture as scroll (pan-y on .handle-selected otherwise cancels the hold). */
.item.handle-selected.wiki-longpress-pending {
  touch-action: none;
}

.item.handle-selected .item-drag-handle {
  cursor: grab;
  touch-action: none;
}

body.wiki-item-lineup-dragging {
  /* Do not set overflow:hidden here — toggling it mid-touch cancels the pointer on Android. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

body.wiki-item-lineup-dragging .main {
  touch-action: none;
}

/* Item/journal long-press: restore Y scroll on shrunk pages (page drag uses
   overflow:visible). Match shrunk-page specificity so overflow-y beats that
   shorthand — otherwise tall pages stay unscrolled and off-screen journals
   are unreachable (R-027 mobile). */
body.wiki-item-lineup-dragging.wiki-page-lineup-shrunk .main > .page:not(.wiki-page-ghost),
body.wiki-journal-merging.wiki-page-lineup-shrunk .main > .page:not(.wiki-page-ghost) {
  overflow-y: auto !important;
}

.wiki-item-lineup-origin {
  /* Keep layout for insert math until hidden for move. */
  outline: none;
}

/* Move: hide origin (desktop shadow-copy stays hidden). Copy: show it. */
.wiki-item-lineup-origin-hidden {
  display: none !important;
}

.wiki-item-lineup-origin-copy {
  display: block !important;
  opacity: 1 !important;
  outline: 2px dashed #888;
}

/* Floating drag preview — full-size like desktop; JS scales to 0.5 with lineup shrink. */
.wiki-item-lineup-helper {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100060;
  pointer-events: none;
  box-sizing: border-box;
  transform-origin: top left;
  will-change: transform;
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  border: none !important;
  opacity: 1 !important;
  margin: 0 !important;
  overflow: visible;
}

.wiki-item-lineup-helper.is-active {
  display: block;
  overflow: visible !important;
}

.wiki-item-lineup-helper.is-active > .item,
.wiki-item-lineup-helper.is-active > .item.wiki-item-lineup-drag-sizing {
  box-sizing: border-box !important;
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
}

.wiki-item-lineup-helper .item-toolbar,
.wiki-item-lineup-helper .item-drag-handle,
.wiki-item-lineup-helper .item-edit-button {
  display: none !important;
}

/* Insert slot — JS sets item-sized dimensions during long-press drag. */
.wiki-item-lineup-placeholder.item-placeholder {
  display: block;
  width: auto;
  margin: 2px 0;
  pointer-events: none;
  position: relative;
  z-index: 5;
  box-sizing: border-box;
  border: 1px dotted rgba(140, 140, 140, 0.7) !important;
  background: rgba(238, 238, 238, 0.55) !important;
  outline: none !important;
}

.wiki-item-lineup-overlay {
  display: none;
  position: fixed;
  z-index: 100040;
  pointer-events: none;
  box-sizing: border-box;
  overflow: visible;
}

.wiki-item-lineup-overlay.is-active {
  display: flex;
  /* Halves abut — no gap. Hot half draws a thin per-edge inset frame; only the
     active half owns the center divider so the split stays a single hairline. */
  gap: 0;
  padding: 0;
}

.wiki-item-lineup-half {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  /* No border/margin: dashed borders + margin/gap left a blank gray center. */
  border: 0;
  margin: 0;
  background: transparent;
  color: #333;
  opacity: 0.45;
  transition: opacity 100ms, background 100ms, box-shadow 100ms, color 80ms;
  padding: 10px 4px;
}

/* Source page: move only (no same-page copy) — full width. */
.wiki-item-lineup-overlay.move-only .wiki-item-lineup-half-copy {
  display: none;
}

.wiki-item-lineup-overlay.move-only .wiki-item-lineup-half-move {
  flex: 1 1 100%;
}

.wiki-item-lineup-overlay.labels-above .wiki-item-lineup-half {
  justify-content: flex-start;
  padding-top: 14px;
  padding-bottom: 48px;
}

.wiki-item-lineup-overlay.labels-below .wiki-item-lineup-half {
  justify-content: flex-end;
  padding-top: 48px;
  padding-bottom: 14px;
}

.wiki-item-lineup-half-move.is-hot {
  opacity: 1;
  background: rgba(70, 150, 230, 0.18);
  color: #063a75;
  /* Outer left + top/bottom; center/right edge only on the active half. */
  box-shadow:
    inset 1.5px 0 0 rgba(26, 111, 208, 0.9),
    inset 0 1.5px 0 rgba(26, 111, 208, 0.9),
    inset 0 -1.5px 0 rgba(26, 111, 208, 0.9),
    inset -1.5px 0 0 rgba(26, 111, 208, 0.9);
}

.wiki-item-lineup-half-copy.is-hot {
  opacity: 1;
  background: rgba(50, 190, 100, 0.18);
  color: #0a4a24;
  box-shadow:
    inset -1.5px 0 0 rgba(20, 150, 74, 0.9),
    inset 0 1.5px 0 rgba(20, 150, 74, 0.9),
    inset 0 -1.5px 0 rgba(20, 150, 74, 0.9),
    inset 1.5px 0 0 rgba(20, 150, 74, 0.9);
}

/* Long-press drag: illegal drop — red frame only; mirrors desktop cursor:no-drop / cancel.
   Hide floating Move/Copy icons — a hot move button on a red box reads as allowed. */
.wiki-item-lineup-overlay.is-no-drop {
  box-shadow: inset 0 0 0 2px rgba(200, 45, 45, 0.92);
}

.wiki-item-lineup-overlay.is-no-drop .wiki-item-lineup-half-icon,
.wiki-item-lineup-overlay.is-no-drop .wiki-item-lineup-half-label {
  display: none;
}

.wiki-item-lineup-overlay.is-no-drop .wiki-item-lineup-half {
  opacity: 0;
  background: transparent;
  box-shadow: none;
}

.wiki-item-lineup-placeholder.item-placeholder.is-no-drop {
  border: 1px dotted rgba(190, 45, 45, 0.9) !important;
  background: rgba(255, 220, 220, 0.55) !important;
}

.wiki-item-lineup-half-icon {
  display: flex;
  line-height: 0;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.wiki-item-lineup-half-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.88);
  padding: 2px 8px;
  border-radius: 6px;
}

/* Mobile cross-page item drag: Move | Copy strip on the destination page. */
.wiki-item-drop-chooser {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10050;
  display: none;
  box-sizing: border-box;
  pointer-events: none;
  gap: 6px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.18);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.wiki-item-drop-chooser.is-active {
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.wiki-item-drop-choice {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 6px 8px;
  border-radius: 8px;
  color: #444;
  background: #f3f3f3;
  border: 2px solid transparent;
  opacity: 0.72;
  transition: opacity 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.wiki-item-drop-choice.is-hot {
  opacity: 1;
  background: #fff;
  border-color: #3d6ea5;
  color: #1a3a5c;
  box-shadow: inset 0 0 0 1px rgba(61, 110, 165, 0.25);
}

.wiki-item-drop-choice.is-unavailable {
  opacity: 0.28;
  filter: grayscale(1);
}

.wiki-item-drop-choice-icon {
  display: flex;
  line-height: 0;
}

.wiki-item-drop-choice-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.wiki-item-drop-choice-move.is-hot {
  border-color: #2a7a4b;
  color: #1a4d2e;
  box-shadow: inset 0 0 0 1px rgba(42, 122, 75, 0.25);
}

.wiki-item-drop-choice-copy.is-hot {
  border-color: #3d6ea5;
  color: #1a3a5c;
}

/* Parity: keep vertical scroll on .page; lineup pans horizontally only. */
.main {
  overflow-y: hidden;
}


.main {
  margin: 0;
  display: flex;
  overflow-x: auto;
  /* Hidden, not visible: overflow-x:auto otherwise computes overflow-y to auto
     (CSS overflow pairing), so one gesture pans the lineup and the page at once
     and a column can be thrown completely off-screen. Vertical scroll belongs
     on .page (desktop overflow:auto; mobile sets it in the 490px block). */
  overflow-y: hidden;
  height: calc(100vh - 40px);
}

.item-placeholder {
  outline: 1px dotted #bbb;
  outline-offset: -1px;
  background: #eee;
}

body:not(.fedwiki-edit-mode) .item-toolbar,
body:not(.fedwiki-edit-mode) .item-drag-handle {
  display: none !important;
}

/* Overlay wrapper: JS pins `top` to the visible slice of tall items so handle
   + pencil stay on screen after the item's own top has scrolled away (tap the
   bottom of chess/activity and the buttons must still be in the viewport).
   Height 0 so it never reflows story text. */

.item-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  z-index: 6;
  pointer-events: none;
}

.item-toolbar .item-drag-handle,
.item-toolbar .item-edit-button {
  pointer-events: auto;
}

/* Desktop: no handles — whole-item drag. Touch/coarse: overlay grab targets (no reflow). */

.item-drag-handle {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  z-index: 6;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  color: #555;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -1px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.item.textEditing .item-toolbar,
.item.textEditing .item-drag-handle,
.item.textEditing .item-edit-button,
.item.textEditing .item-action-toolbar {
  display: none !important;
}

.item-edit-button {
  display: none;
  position: absolute;
  top: 48px;
  right: 2px;
  z-index: 6;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  color: #555;
  font-size: 22px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.item-action-toolbar {
  display: none;
}

.item.handle-selected {
  outline: 1px dashed #999;
}

.item.toolbar-active {
  outline: 1px solid #666;
}

/* Mobile: tap-selected journal (no handle/pencil — long-press to merge-drag). */

.journal.journal-selected {
  outline: 1px dashed #999;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.journal-merge-source {
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.journal-merge-source .action,
.journal-merge-clone,
.journal-merge-clone .action {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.journal-merge-source.is-dragging {
  touch-action: none;
  cursor: grabbing;
}

.journal .action {
  cursor: pointer;
  position: relative;
  z-index: 1;
  -webkit-user-select: none;
  user-select: none;
}

.journal.wiki-merge-hover,
.journal.ui-state-hover {
  /* Match stock jQuery UI hover look; inset shadow avoids border layout shift
     that reflows floated .action icons onto the next row. */
  background: #ededed;
  outline: none;
  box-shadow: inset 0 0 0 1px #ccc;
}

.journal-merge-clone {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

body.wiki-journal-merging,
body.wiki-journal-merging * {
  -webkit-user-select: none !important;
  user-select: none !important;
  caret-color: transparent;
}

/* Stock FedWiki rules restored (accidentally dropped in parity CSS rewrite). */

/* Stock page column sizing restored — required for lineup flex + mobile 100vw. */

@media (hover: none), (pointer: coarse) {
  /* Overlay the item corner — never change paper/item width (that reflows text). */
  body.fedwiki-edit-mode .item-drag-handle {
    display: flex;
    top: 2px;
    right: 2px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 26px;
    touch-action: none;
  }

  body.fedwiki-edit-mode .item-edit-button {
    display: flex;
    top: 50px;
    right: 2px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 22px;
    touch-action: manipulation;
  }

  .item-action-toolbar button {
    min-width: 44px;
    min-height: 44px;
  }

  .desktop-only-controls {
    display: none !important;
  }
}
@media all and (max-width: 490px) {
  .page { scroll-snap-align: center; }
  .main { scroll-snap-type: x mandatory; }
}
