
/* Styles for the new (non-iframe) catalog item viewer. */

div.newViewer {
  position: fixed;
  width: 100%;
  height: 96%;
  top: 130px;
  overflow: hidden;
}

div.newViewerArea {
  position: relative;
  width: 100%;
  height: 100%;
  margin-top: 30px;
  box-sizing: border-box;
  padding: 8px;
  overflow: auto;
  display: flex;
  gap: 8px;
}

/* Default: panes stacked vertically. JS adds .row for side-by-side. */
div.newViewerArea {
  flex-direction: column;
}

div.newViewerArea.row {
  flex-direction: row;
}

div.newViewerArea > .viewerPane:not(.viewerPaneCollapsed) {
  flex-grow: 1 !important;
  flex-shrink: 1 !important;
}

div.newViewerArea:not(.row) > .viewerPane:not(.viewerPaneCollapsed) {
  min-height: 30px;
}

.viewerPane {
  flex: 1 1 0;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  background-color: white;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  transition: min-height 300ms ease, flex 300ms ease;
}

.viewerPaneResizeHandle {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 16px;
  cursor: ns-resize;
  touch-action: none;
  z-index: 10;
  background: linear-gradient(
    to bottom,
    transparent calc(100% - 2px),
    #a5a5a5 calc(100% - 2px)
  );
}
.viewerPaneResizeHandle:hover {
  background: linear-gradient(
    to bottom,
    transparent calc(100% - 2px),
    #656565 calc(100% - 2px)
  );
}

div.newViewerArea.row > .viewerPane > .viewerPaneResizeHandle {
  top: 0;
  right: 0;
  bottom: auto;
  left: auto;
  width: 16px;
  height: 100%;
  cursor: ew-resize;
  background: linear-gradient(
    to right,
    transparent calc(100% - 2px),
    #a5a5a5 calc(100% - 2px)
  );
}

div.newViewerArea.row > .viewerPane > .viewerPaneResizeHandle:hover {
  background: linear-gradient(
    to right,
    transparent calc(100% - 2px),
    #656565 calc(100% - 2px)
  );
}

div.newViewerArea > .viewerPane:last-child > .viewerPaneResizeHandle {
  display: none;
}

.viewerPane.viewerPaneResizing,
.viewerPane.viewerPaneResizing * {
  transition: none !important;
  user-select: none;
}

.viewerPane.viewerPaneCollapsed {
  min-height: 0;
  flex: 0 0 30px;
}

.viewerPane.viewerPaneCollapsed .viewerPaneContent {
  display: none;
}

.viewerPane.viewerPaneCollapsed .viewerPaneResizeHandle {
  display: none;
}

.viewerPaneMenuBar {
  height: 30px;
  background-color: #e5e5e5;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: background-color 150ms;
}

.viewerPane.viewerPaneFocused > .viewerPaneMenuBar {
  background-color: #e6ebf1;
}

.viewerPaneMenuBar:active {
  cursor: grabbing;
}

.viewerPaneDragHandle {
  flex: 1 1 0;
  min-width: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #aaa;
  letter-spacing: 2px;
  user-select: none;
}

.viewerPaneMenuBar:hover .viewerPaneDragHandle {
  color: #777;
}

.viewerPane.viewerPaneDragging {
  opacity: 0.4;
}

/* Pane lifts slightly after the 1-second hold, before drag is released. */
.viewerPane.viewerPaneLiftReady {
  transform: translate(-4px, -4px);
  box-shadow: 6px 6px 14px rgba(0,0,0,0.22);
  z-index: 100;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

/* Drop insertion indicator lines between panes */
.viewerDropIndicator {
  position: absolute;
  z-index: 200;
  pointer-events: none;
  /* Default: horizontal line for column layout */
  width: 100%;
  height: 3px;
  background: #0d3673;
  border-radius: 2px;
  transform: translateY(-50%);
  opacity: 0.35;
  transition: opacity 120ms ease;
}
.viewerDropIndicator.viewerDropIndicatorActive {
  opacity: 1;
}
.viewerDropIndicator.viewerDropIndicatorRow {
  /* Vertical line for row layout */
  width: 3px;
  height: 100%;
  transform: translateX(-50%) translateY(0);
}

.viewerPaneChevron {
  padding: 0 8px;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}

.viewerPaneHeader {
  padding: 0 4px;
  font-size: 14pt;
  font-weight: bold;
  cursor: pointer;
}

/* Edition button(s) hoisted into the pane title bar */
.viewerPaneMenuBar .textEdnButton {
  margin-left: 10px;
  height: 22px;
  padding: 0 6px;
  font-size: 12px;
  background-color: #a5a5a5;
  color: #000;
  border-color: #a5a5a5;
  cursor: pointer;
}

.viewerPaneMenuBar .textEdnButton:hover {
  background-color: #656565;
  color: #fff;
  border-color: #656565;
}

.viewerPaneMenuBar .textEdnButton.selected {
  background-color: #94b1d4;
  color: #000;
  border-color: #94b1d4;
}

.viewerPaneMenuBar .textEdnButton.selected:hover {
  background-color: #0d3673;
  color: #fff;
  border-color: #0d3673;
}

.viewerPanePropsBtn {
  padding: 0 8px;
  font-size: 14px;
  line-height: 30px;
  cursor: pointer;
  flex-shrink: 0;
}

.viewerPanePropsBtn:hover {
  opacity: 0.7;
}

.viewerPane.viewerPropsPanelOpen .viewerPaneContent {
  margin-right: 250px;
}

.viewerPanePropsPanel {
  position: absolute;
  top: 30px; /* below the menu bar */
  right: 0;
  width: 250px;
  bottom: 0;
  background: #f5f5f5;
  border-left: 1px solid #ccc;
  box-sizing: border-box;
  overflow-y: auto;
  padding: 10px;
  z-index: 10;
}

.viewerPropsMiniCanvas {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  border: 1px solid #ccc;
}

.viewerPropsSegId {
  display: none;
  text-align: center;
  font-size: 10pt;
  color: #444;
  margin-top: 4px;
}

.viewerPropsTranscription {
  font-size: 13pt;
  font-weight: 600;
  color: #222;
  word-break: break-word;
  font-style: italic;
}

.viewerPropsReadings {
  margin-top: 6px;
  text-align: center;
  font-size: 13pt;
  line-height: 1.6;
}
.viewerPropsDelBtn {
  display: block;
  width: 100%;
  padding: 4px 8px;
  margin-top: 8px;
  font-size: 10pt;
  cursor: pointer;
  background: #a03030;
  color: #fff;
  border: none;
  border-radius: 3px;
}
.viewerPropsDelBtn:hover:not(:disabled) {
  background: #882020;
}
.viewerPropsDelBtn:disabled {
  opacity: 0.35;
  cursor: default;
}

.viewerPropsReading {
  display: inline;
}

.viewerPropsRotControls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0px auto 8px auto;
  justify-content: center;
}

.viewerPropsRotBtn {
  font-size: 13px;
  line-height: 1;
  height: 26px;
  min-width: 26px;
  padding: 0 5px;
  cursor: pointer;
  background: #e8e8e8;
  border: 1px solid #bbb;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.viewerPropsRotBtn:hover {
  background: #d0d0d0;
}

.viewerPropsTokenEdit {
  margin: 8px 0;
  padding: 8px;
  background-color: ;
  border: 1px solid ;
  border-radius: 3px;
  text-align: center;
}

.viewerPropsTokenLabel {
  font-size: 12px;
  margin-bottom: 6px;
  color: #444;
}

.viewerPropsTokenLabel strong {
  font-weight: bold;
}

.viewerPropsAnnotateBtn,
.viewerPropsToggleCaseBtn,
.viewerPropsEditTokBtn,
.viewerPropsAddTokBtn,
.viewerPropsEditLineLabelBtn,
.viewerPropsNewLineBtn,
.viewerPropsJoinBtn,
.viewerPropsExpandCmpBtn,
.viewerPropsLexBtn,
.viewerPropsCopySQL {
  display: block;
  width: 100%;
  padding: 4px 8px;
  margin-top: 4px;
  font-size: 11pt;
  cursor: pointer;
  background: #2a6aa0;
  color: #fff;
  border: none;
  border-radius: 3px;
}
.viewerPropsAnnotateBtn:hover,
.viewerPropsToggleCaseBtn:hover,
.viewerPropsEditTokBtn:hover,
.viewerPropsAddTokBtn:hover,
.viewerPropsEditLineLabelBtn:hover,
.viewerPropsNewLineBtn:hover,
.viewerPropsJoinBtn:hover,
.viewerPropsExpandCmpBtn:hover,
.viewerPropsLexBtn:hover,
.viewerPropsCopySQL:hover {
  background: #1d5080;
}
.viewerPropsAnnotateBtn:disabled,
.viewerPropsToggleCaseBtn:disabled,
.viewerPropsEditTokBtn:disabled,
.viewerPropsAddTokBtn:disabled,
.viewerPropsEditLineLabelBtn:disabled,
.viewerPropsNewLineBtn:disabled,
.viewerPropsJoinBtn:disabled,
.viewerPropsExpandCmpBtn:disabled,
.viewerPropsLexBtn:disabled,
.viewerPropsCopySQL:disabled {
  background: #aaa;
  cursor: default;
}

.viewerPropsDeleteLineBtn {
  display: block;
  width: 100%;
  padding: 4px 8px;
  margin-top: 4px;
  font-size: 11pt;
  cursor: pointer;
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 3px;
}
.viewerPropsDeleteLineBtn:hover {
  background: #962d22;
}
.viewerPropsDeleteLineBtn.active {
  background: #7f8c8d;
}
.viewerPropsDeleteLineBtn.active:hover {
  background: #5f6b6c;
}

.viewerPropsLineOperation.hide {
  display: none;
}

.lineDeleteBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #c0392b;
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-right: 4px;
  flex-shrink: 0;
}
.lineDeleteBtn:hover {
  background: #e74c3c;
}
.lineDeleteBtn:disabled {
  background: #aaa;
  cursor: default;
}

.textLine.newLinePlaceholder {
  background: #fffbe6;
  border: 1px dashed #c9a825;
  border-radius: 3px;
  padding: 2px 4px;
  cursor: grab;
}
.textLine.newLinePlaceholder.dragging {
  opacity: 0.4;
}
.textLine.newLinePlaceholder .lineText {
  color: #888;
  font-style: italic;
  cursor: pointer;
}
.textLine.newLinePlaceholder:not(.nlpEditing):hover {
  background: #fff3c4;
}
.textLine.newLinePlaceholder.nlpEditing {
  cursor: default;
}
.textLine.newLinePlaceholder.nlpEditing .lineText {
  font-style: normal;
  color: inherit;
}
.nlpInput {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: inherit;
  padding: 2px 4px;
  border: 1px solid #2a6aa0;
  border-radius: 2px;
  outline: none;
}
.nlpInput:focus {
  border-color: #1d5080;
  box-shadow: 0 0 0 2px rgba(42, 106, 160, 0.25);
}
.nlpLabelInput {
  width: 3.5em;
  font: inherit;
  font-size: inherit;
  font-weight: bold;
  text-align: right;
  padding: 1px 2px;
  border: 1px solid #2a6aa0;
  border-radius: 2px;
  outline: none;
}
.nlpLabelInput:focus {
  border-color: #1d5080;
  box-shadow: 0 0 0 2px rgba(42, 106, 160, 0.25);
}
.textLine.newLinePlaceholder .lineLabel {
  cursor: pointer;
}
.newLineDropIndicator {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: #2a6aa0;
  border-radius: 2px;
  pointer-events: none;
  z-index: 10;
}
.newLineDragActive .textLine:not(.dragging),
.newLineDragActive .viewerStructLabel {
  transition: transform 0.1s;
}

.viewerAddTokDialog {
  min-width: 420px;
}
.viewerAddTokPosRow,
.viewerAddTokValRow {
  margin: 10px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.viewerAddTokPosToggle {
  padding: 4px 12px;
  cursor: pointer;
  background: #2a6aa0;
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 10pt;
}
.viewerAddTokPosToggle:hover {
  background: #1d5080;
}
.viewerAddTokValInput {
  width: 80px;
  padding: 3px 6px;
  font-size: 11pt;
  border: 1px solid #a5a5a5;
  border-radius: 3px;
}
.viewerAddTokBtnRow {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.viewerAddTokPreviewRow {
  margin: 10px 0;
}
.viewerAddTokPreviewLabel {
  font-size: 9pt;
  color: #656565;
  margin-bottom: 4px;
}
.viewerAddTokPreviewContent {
  max-height: 180px;
  overflow-y: auto;
}
.viewerAddTokPreviewEmpty {
  color: #a5a5a5;
  font-style: italic;
  font-size: 9pt;
}
.viewerAddTokPreviewTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 9pt;
}
.viewerAddTokPreviewTable th {
  text-align: left;
  padding: 2px 6px;
  border-bottom: 1px solid #a5a5a5;
  font-weight: 600;
  color: #656565;
}
.viewerAddTokPreviewTable td {
  padding: 2px 6px;
  border-bottom: 1px solid #d5d5d5;
}
.viewerAddTokPreviewError td {
  color: #c00;
  background: #fff0f0;
}
.viewerAddTokPreviewErrMsg {
  margin-top: 4px;
  font-size: 9pt;
  color: #c00;
}
.viewerAddTokPreviewSummary {
  margin-top: 4px;
  font-size: 9pt;
  color: #656565;
}
.viewerAddTokPreviewSclLabel {
  font-weight: 600;
  vertical-align: top;
  border-right: 1px solid #a5a5a5;
  white-space: nowrap;
}
.viewerAddTokPreviewAlt td {
  background: #d5d5d5;
}
.viewerAddTokPreviewImplicit {
  color: #a5a5a5;
  font-style: italic;
}
.viewerModalBtn.viewerAddTokBtnInvalid,
.viewerModalBtn.viewerAddTokBtnInvalid:hover {
  background: #fdd9b5;
  color: #333;
  border-color: #e8a850;
  cursor: default;
}

.viewerAnnotationDialog {
  min-width: 400px;
}
.viewerAnnotationText {
  width: 100%;
  min-height: 80px;
  resize: vertical;
}

.viewerPropsRotRow {
  display: none;
  justify-content: center;
  margin: 2px 0 0;
}

.viewerPropsRotLabel {
  font-size: 11px;
  font-weight: bold;
  color: #444;
  text-align: center;
}

.viewerPropsLoading {
  color: #999;
  font-style: italic;
}

/* Mode dropdown row — at the bottom of the props panel content. */
.viewerCreateSegRow {
  margin-top: 16px;
  padding: 6px 0 2px;
  border-top: 1px solid #d0d0d0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.viewerCreateSegLabel {
  font-size: 11px;
  color: #444;
  display: flex;
  align-items: center;
  cursor: default;
  user-select: none;
}

.viewerModeSelect {
  font-size: 11px;
  padding: 2px 4px;
  border: 1px solid #bbb;
  border-radius: 3px;
  cursor: pointer;
}

/* Surface-picker modal */
.viewerModalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewerModalDialog {
  position: relative;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  padding: 20px 24px 16px;
  min-width: 280px;
  max-width: 840px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.viewerModalTitle {
  font-size: 14px;
  font-weight: bold;
  color: #222;
}

.viewerModalLabel {
  font-size: 12px;
  color: #444;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.viewerModalSelect {
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid #bbb;
  border-radius: 4px;
}

.viewerModalInput {
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid #bbb;
  border-radius: 4px;
}

.viewerModalBtnRow {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.viewerModalBtn {
  font-size: 12px;
  padding: 5px 14px;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #f5f5f5;
  cursor: pointer;
}

.viewerModalBtn:hover {
  background: #e8e8e8;
}

.viewerModalBtnPrimary {
  background: #4a7cc9;
  border-color: #3a6ab8;
  color: #fff;
}

.viewerModalBtnPrimary:hover {
  background: #3a6ab8;
}

.viewerPropsNone {
  color: #999;
  font-size: 10pt;
}

.viewerPaneContent {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  padding: 8px 12px 9em 12px;
  box-sizing: border-box;
}

.viewerPaneContent.viewerImageContent {
  position: relative;
  padding: 0;
  overflow: hidden;
}

.viewerImageAttribution {
  position: absolute;
  bottom: 6px;
  left: 8px;
  font-size: 10pt;
  font-weight: normal;
  color: #000;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff;
  user-select: none;
  z-index: 1;
  cursor: default;
}

.viewerImageAttribution a {
  cursor: pointer;
}

#viewerBibPopup {
  position: fixed;
  z-index: 9999;
  max-width: 420px;
  padding: 6px 10px;
  font-size: 10pt;
  font-weight: 400;
  background-color: #e6ebf1;
  color: black;
  box-shadow: 4px 3px 10px #888888;
  pointer-events: auto;
}

#viewerAnoPopup {
  position: fixed;
  z-index: 9999;
  max-width: 420px;
  padding: 6px 10px;
  font-size: 10pt;
  font-weight: 400;
  background-color: #e6ebf1;
  color: black;
  box-shadow: 4px 3px 10px #888888;
  pointer-events: auto;
}

#viewerAnoPopup.viewerAnoPopupEditor {
  pointer-events: auto;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
  padding: 20px 24px 16px;
  min-width: 280px;
  max-width: 840px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 12px;
  color: #222;
}

.viewerAnoEditorText {
  width: 100%;
  resize: vertical;
}

.viewerAnoEditorSelect {
  width: 100%;
}

sup.viewerAnoMarker {
  cursor: help;
  font-size: 0.65em;
  color: ;
  margin-left: 1px;
}

#viewerDictPopup {
  position: fixed;
  z-index: 9998;
  max-width: min(460px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  min-width: 180px;
  padding: 6px 10px;
  font-size: 16px;
  font-weight: 400;
  text-align: left;
  background-color: rgba(229,229,229,0.92);
  box-shadow: 3px 3px 12px #888888;
  pointer-events: auto;
  cursor: default;
  box-sizing: border-box;
  overflow: auto;
}

#viewerDictPopup .popupwrapperdiv {
  max-width: 100%;
  text-align: left;
  display: block;
  font-size: 16px;
}

#viewerDictPopup .viewerDictLemRow {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 2px;
  max-width: 100%;
}

#viewerDictPopup .lemma {
  font-size: 18pt;
  line-height: 18pt;
  font-weight: normal;
  font-style: normal;
  cursor: pointer;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}

#viewerDictPopup .kharShow {
  font-family: "Segoe UI Historic", "Kharosthi Unicode", "Noto Sans Kharoshthi";
  font-style: normal;
  font-weight: normal;
  font-size: 18pt;
  overflow-wrap: anywhere;
  max-width: 100%;
}

#viewerDictPopup .lemsuper {
  font-size: 0.8em;
  vertical-align: super;
}

#viewerDictPopup .lemetym {
  padding-right: 5px;
}

#viewerDictPopup .lemphonetic {
  padding-right: 5px;
}

#viewerDictPopup .lemPos {
  padding-right: 5px;
}

#viewerDictPopup .lemgloss {
  padding-right: 5px;
  word-wrap: break-word;
}

#viewerDictPopup .morphology {
  font-size: 13px;
  font-style: italic;
}

#viewerDictPopup .viewerDictClose {
  float: right;
  cursor: pointer;
  font-size: 13pt;
  font-style: normal;
  font-family: sans-serif;
  line-height: 1;
  color: #a5a5a5;
  margin-left: 8px;
}

#viewerDictPopup .viewerDictClose:hover {
  color: black;
}

@media only screen and (max-device-width: 480px) {
  #viewerDictPopup {
    left: 0 !important;
    right: 0 !important;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }

  #viewerDictPopup .popupwrapperdiv {
    max-width: 100%;
  }
}

.viewerImageCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.viewerImageFallback {
  display: block;
  max-width: 100%;
  height: auto;
}

.viewerImageLoading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: black;
  font-size: 0.9em;
  pointer-events: none;
  z-index: 2;
}

.viewerImageLoading::before {
  content: '';
  display: block;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(0,0,0,0.15);
  border-top-color: black;
  border-radius: 50%;
  animation: viewerSpinAnim 0.8s linear infinite;
}

.viewerImageLoadingText {
  min-width: 140px;
  text-align: center;
}

.viewerImageLoadingProgress {
  width: 140px;
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.15);
}

.viewerImageLoadingFill {
  width: 0;
  height: 100%;
  background: black;
  transition: width 150ms ease;
}

@keyframes viewerSpinAnim {
  to { transform: rotate(360deg); }
}

/* ── Text viewer ──────────────────────────────────────── */

.viewerTextMenuBar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 6px;
  border-bottom: 1px solid #888888;
}

.viewerTextContent {
  padding: 8px 6px;
  overflow-y: auto;
  cursor: pointer;
  font-size: 12pt;
  user-select: none;
  -webkit-user-select: none;
}

.viewerTextContent * {
  user-select: none;
  -webkit-user-select: none;
}

.viewerTextContent.viewerKhar {
  direction: rtl;
  font-size: 15.6pt;
  letter-spacing: 0.1em;
  font-family: "Segoe UI Historic", "Kharosthi Unicode", "Noto Sans Kharoshthi";
}

.viewerPaneContent.viewerKhar {
  direction: rtl;
  font-size: 15.6pt;
  letter-spacing: 0.1em;
}

.viewerTextLoading {
  color: #999;
  font-style: italic;
  font-size: 0.9em;
  padding: 4px 0;
}

.viewerTextTitleLabel {
  font-size: 16pt;
  font-weight: 600;
  color: #000;
  margin: 0.6em 0 0.1em 0;
  padding: 0;
}

.viewerStructLabel {
  font-size: 13pt;
  font-weight: 600;
  color: #656565;
  margin: 0.2em 0 0.1em 0;
  padding: 0;
}

.textLine {
  display: flex;
  align-items: baseline;
  gap: 1em;
  margin-bottom: 0.25em;
}

.lineLabel {
  display: inline-block;
  min-width: 4em;
  flex-shrink: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: bold;
  direction: ltr;
  cursor: pointer;
  border-radius: 2px;
}

.lineLabel:hover,
.lineLabel:focus-visible {
  background: #e5edf4;
  outline: none;
}

.lineLabel.selected {
  color: #fff;
  background: #2a6aa0;
}

.viewerLineLabelInput {
  box-sizing: border-box;
  width: 4em;
  padding: 1px 3px;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.lineText {
  flex: 1;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
}

.structLabel {
  color: #a5a5a5;
  font-size: 0.85em;
  margin-right: 2px;
  margin-left: 0.4em;
}

.lineText > .structLabel:first-child,
.cmpGroup:first-child > .structLabel:first-child {
  margin-left: 0;
}

.structLabelPart {
  cursor: default;
}

.structLabelPart:hover {
  color: #333;
}

.tok.structHover {
  background-color: rgba(100, 149, 237, 0.18);
}

/* ── Structure text display mode ─────────────────────────────────────── */

.structTextSection {
  margin: 10px 0 14px;
}

.structTextDivision {
  margin: 6px 0;
  padding-left: 3em;
}

.structTextLabel {
  display: inline-block;
  color: black;
  font-weight: 600;
  vertical-align: top;
  margin: 0 0.3em;
}

.structTextLabel::before {
  content: '(';
}

.structTextLabel::after {
  content: ')';
}

.structTextStanza {
  margin: 8px 0;
  padding-left: 0;
}

.structTextPada {
  line-height: 1.6;
}

.structTextProse {
  margin: 4px 0;
  line-height: 1.6;
  padding-left: 3em;
}

.structTextProse > .structTextLabel {
  display: inline;
  margin-left: 0.5em;
  width: auto;
  margin-right: 0.5em;
}

.structTextBlock {
  margin: 4px 0;
}

.structTextSentence > .structTextLabel {
  <!-- color: black; -->
  margin-right: 0.4em;
}



.structTextLineNum {
  color: #a5a5a5;
  margin: 0 0.3em;
  font-size: 0.9em;
}

.viewerTextAttrib {
  font-size: 10pt;
  color: #656565;
  letter-spacing: normal;
}

.viewerTranslationContent {
  padding: 0;
}

.viewerTranslationPara {
  margin: 0.3em 0;
  line-height: 1.5;
}

/* Image picker — button in the menu bar */
/* Image picker button inherits .textEdnButton base styles; no extra overrides needed */

/* Image picker — floating dropdown panel */
.viewerImgPickerPanel {
  position: fixed;
  z-index: 9000;
  background: #fff;
  border: 1px solid #a5a5a5;
  border-radius: 4px;
  padding: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.viewerImgPickerPanel.hide {
  display: none;
}

/* Individual image cell */
.viewerImgPickerCell {
  position: relative;
  width: 90px;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 3px;
  overflow: hidden;
  text-align: center;
}

/* Text-linked images — blue border */
.viewerImgPickerCell.textimage {
  border-color: #94b1d4;
}
.viewerImgPickerCell.textimage:hover {
  border-color: #0d3673;
}
.viewerImgPickerCell.textimage.selected {
  border-color: #0d3673;
  box-shadow: 0 0 0 1px #0d3673;
}

/* Baseline images — red border */
.viewerImgPickerCell.baseline {
  border-color: #c00;
}
.viewerImgPickerCell.baseline:hover {
  border-color: #ff3333;
}
.viewerImgPickerCell.baseline.selected {
  border-color: #8b0000;
  box-shadow: 0 0 0 1px #8b0000;
}

/* Thumbnail image */
.viewerImgPickerThumb {
  width: 100%;
  height: 60px;
  object-fit: cover;
  display: block;
  background: #e5e5e5;
}

/* Baseline badge (⛋) in top-right corner of cell */
.viewerImgPickerBadge {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 13px;
  line-height: 1;
  color: #0d3673;
  text-shadow: 0 0 3px #fff;
  pointer-events: none;
}

/* Title label overlaid at bottom of thumbnail */
.viewerImgPickerLabel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 9pt;
  line-height: 1.2;
  color: #fff;
  background: rgba(0,0,0,0.55);
  padding: 1px 3px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
}

.scl {
  display: inline;
}

.highlightScl .scl:hover {
  background-color: #e5e5e5;
  border-radius: 2px;
}

.highlightTok .tok:hover {
  background-color: #e5e5e5;
  border-radius: 2px;
}

/* Token highlighted from image-side hover (token highlight mode) */
.highlightTok .tok.imgHover {
  background-color: #e5e5e5;
  border-radius: 2px;
}

/* Syllable highlighted from image-side hover (syllable highlight mode) */
.highlightScl .scl.imgHover {
  background-color: #e5e5e5;
  border-radius: 2px;
}

/* Token selected (from image or text click, token highlight mode) */
.highlightTok .tok.selected {
  background-color: #90ee90;
  border-radius: 2px;
}
.highlightTok .tok.selected.noLemma {
  color: #999;
}

/* Syllable selected (from image or text click, syllable highlight mode) */
.highlightScl .scl.selected {
  background-color: #90ee90;
  border-radius: 2px;
}

.tok {
  display: inline-block;
}

.tok + .tok {
  margin-left: 0.4em;
}

.tok.noGapBefore {
  margin-left: 0;
}

/* Space after a footnote marker before the next token or compound group */
.viewerAnoMarker + .tok,
.viewerAnoMarker + .cmpGroup {
  margin-left: 0.4em;
}

.viewerAnoMarker + .tok.noGapBefore {
  margin-left: 0;
}

/* Compound token group wrapper */
.cmpGroup {
  display: inline-block;
}

/* No space between tokens within a non-digit compound */
.cmpGroup .tok + .tok {
  margin-left: 0;
}

/* Space between tokens within a digit compound */
.cmpGroup.digitsCompound .tok + .tok {
  margin-left: 0.4em;
}

/* Space between a compound group and its neighbours */
.tok + .cmpGroup,
.cmpGroup + .tok,
.cmpGroup + .cmpGroup {
  margin-left: 0.4em;
}

/* Explicit token joins override all normal and compound spacing. */
/* 'Show compounds' toggle (editor-only) — highlight compound groups in red. */
.showCompounds .cmpGroup {
  background: rgba(200, 0, 0, 0.15);
  border-radius: 2px;
}

/* Props-panel label for the 'Show compounds' checkbox. */
.viewerPropsShowCmpLabel {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11pt;
  cursor: pointer;
  margin-bottom: 8px;
}

.viewerPropsDisplayLabel {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11pt;
  cursor: pointer;
  margin-bottom: 8px;
}

.viewerPropsViewLabel {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11pt;
  margin-bottom: 8px;
}

.viewerPropsViewSelect {
  font-size: 10pt;
}

/* 'Start/Stop linking' button in the text-pane props panel. */
.viewerPropsLinkBtn {
  display: block;
  width: 100%;
  padding: 4px 8px;
  margin-bottom: 8px;
  font-size: 11pt;
  cursor: pointer;
  background: #1a6a3a;
  color: #fff;
  border: none;
  border-radius: 3px;
}
.viewerPropsLinkBtn:disabled {
  background: #aaa;
  color: #eee;
  cursor: default;
}
.viewerPropsLinkNav {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.viewerPropsLinkNav.hide { display: none; }
.viewerPropsLinkNavBtn {
  flex: 1;
  padding: 4px 8px;
  font-size: 10pt;
  cursor: pointer;
  background: #1a6a3a;
  color: #fff;
  border: none;
  border-radius: 3px;
}
.viewerPropsLinkNavBtn:hover {
  background: #145a30;
}
.viewerPropsUnlinkBtn {
  display: block;
  width: 100%;
  padding: 4px 8px;
  margin-bottom: 8px;
  font-size: 10pt;
  cursor: pointer;
  background: #a03030;
  color: #fff;
  border: none;
  border-radius: 3px;
}
.viewerPropsUnlinkBtn:hover {
  background: #882020;
}
.viewerPropsUnlinkBtn:disabled {
  opacity: 0.5;
  cursor: default;
}
.viewerPropsUnlinkBtn.hide { display: none; }

/* Floating cursor label shown while linking mode is active. */
#viewerLinkingLabel {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: rgba(26, 106, 58, 0.9);
  color: #fff;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 22pt;
  white-space: nowrap;
}
#viewerLinkingLabel.hide {
  display: none;
}

/* ── Item alignment pane (editor-only) ───────────────────────────── */

.viewerItemMsg {
  padding: 12px;
  color: #656565;
  font-size: 11pt;
}

table.viewerItemTable {
  border-collapse: collapse;
  font-size: 10pt;
  width: 100%;
}

table.viewerItemTable th {
  background-color: #e6ebf1;
  border: 1px solid #d5d5d5;
  padding: 4px 8px;
  text-align: left;
  font-weight: bold;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

table.viewerItemTable td {
  border: 1px solid #d5d5d5;
  padding: 3px 8px;
  vertical-align: top;
  white-space: nowrap;
}

table.viewerItemTable tr:nth-child(even) td {
  background-color: #f5f5f5;
}

table.viewerItemTable tr:hover td {
  background-color: #e6ebf1;
}

/* ── Item pane inline editing ── */

td.itemEditable {
  cursor: pointer;
}

td.itemEditable:hover {
  outline: 1px dashed #94b1d4;
}

input.itemEditInput {
  font-size: inherit;
  font-family: inherit;
  padding: 1px 4px;
  border: 1px solid #94b1d4;
  border-radius: 2px;
  width: calc(100% - 50px);
  box-sizing: border-box;
}

button.itemEditBtn {
  font-size: inherit;
  padding: 0 5px;
  margin-left: 2px;
  cursor: pointer;
  border: 1px solid #d5d5d5;
  border-radius: 2px;
  background: #e6ebf1;
  vertical-align: middle;
  line-height: 1.4;
}

button.itemEditOk {
  color: green;
}

button.itemEditCancel {
  color: red;
}

.viewerEditionMsg {
  padding: 12px;
  color: #656565;
  font-size: 11pt;
}

table.viewerEditionTable {
  border-collapse: collapse;
  font-size: 10pt;
  width: 100%;
}

table.viewerEditionTable th {
  background-color: #e6ebf1;
  border: 1px solid #d5d5d5;
  padding: 4px 8px;
  text-align: left;
  font-weight: bold;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

table.viewerEditionTable td {
  border: 1px solid #d5d5d5;
  padding: 3px 8px;
  vertical-align: top;
  white-space: nowrap;
}

table.viewerEditionTable tr:nth-child(even) td {
  background-color: #f5f5f5;
}

table.viewerEditionTable tr:hover td {
  background-color: #e6ebf1;
}

h4.viewerEditionSubhead {
  margin: 12px 0 4px 0;
  padding: 0 8px;
  font-size: 10pt;
  color: #656565;
}

div.viewerEdnLineGroup {
  overflow-x: auto;
  padding-bottom: 40px;
}

table.viewerEditionLinesTable {
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 10pt;
  width: max-content;
  margin-bottom: 0;
}

table.viewerEditionLinesTable th {
  background-color: #e6ebf1;
  border: 1px solid #d5d5d5;
  padding: 4px 8px;
  text-align: left;
  font-weight: bold;
  white-space: nowrap;
  vertical-align: middle;
  width: 5em;
  min-width: 5em;
  max-width: 5em;
}

td.viewerEdnSegCell {
  background-color: #e6ebf1;
  border: 1px solid #d5d5d5;
  padding: 3px 6px;
  text-align: center;
  white-space: nowrap;
  font-size: 9pt;
  width: 4em;
  min-width: 4em;
  max-width: 4em;
}

td.viewerEdnRowLabel {
  background-color: #e6ebf1;
  border: 1px solid #d5d5d5;
  padding: 3px 6px;
  text-align: left;
  white-space: nowrap;
  font-size: 9pt;
  font-style: italic;
  width: 5em;
  min-width: 5em;
  max-width: 5em;
}

table.viewerEditionLinesTable td {
  border: 1px solid #d5d5d5;
  padding: 3px 6px;
  vertical-align: top;
  text-align: center;
  white-space: nowrap;
  font-size: 9pt;
  user-select: none;
  -webkit-user-select: none;
}

tr.viewerEdnTokRow td {
  background-color: #f5f5f5;
  font-weight: bold;
}

tr.viewerEdnTokRow td.viewerEdnUnmappedGra {
  color: red;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

tr.viewerEdnTokRow td.viewerEdnUnmappedGra:hover {
  background-color: #ffe0e0;
}

tr.viewerEdnTokRow td.viewerEdnUnmappedGra.selected {
  background-color: #ffcccc;
  outline: 2px solid red;
}

.viewerEdnFixOverlay {
  z-index: 9001;
}

.viewerEdnFixInfo {
  color: #c00;
  font-size: 12px;
  font-weight: bold;
}

.viewerEdnFixHint {
  color: #656565;
  font-size: 11px;
  font-style: italic;
}

.viewerEdnFixSelect {
  width: 100%;
  margin-top: 4px;
}

/* Mapped token cells — clickable for editing */
tr.viewerEdnTokRow td.viewerEdnMappedTok {
  position: relative;
  padding-right: 1.8em;
  cursor: pointer;
}

tr.viewerEdnTokRow td.viewerEdnMappedTok:hover {
  background-color: #e8eef8;
}

tr.viewerEdnTokRow td.viewerEdnMappedTok.selected {
  background-color: #d0e0f8;
  outline: 2px solid #4a7cc9;
  outline-offset: -2px;
}

tr.viewerEdnTokRow td.viewerEdnMappedTok .viewerEdnTokEditBtn {
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
  width: 1.25em;
  height: 1.25em;
  padding: 0;
  border: 1px solid #1f6fb2;
  border-radius: 50%;
  background: rgba(30, 100, 165, 0.95);
  color: #fff;
  font-size: 10px;
  line-height: 1.1em;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
}

tr.viewerEdnTokRow td.viewerEdnMappedTok:hover .viewerEdnTokEditBtn,
tr.viewerEdnTokRow td.viewerEdnMappedTok:focus-within .viewerEdnTokEditBtn,
tr.viewerEdnTokRow td.viewerEdnMappedTok.selected .viewerEdnTokEditBtn {
  opacity: 1;
  pointer-events: auto;
}

tr.viewerEdnTokRow td.viewerEdnMappedTok .viewerEdnTokEditBtn:hover {
  background: rgba(25, 85, 140, 0.98);
}

tr.viewerEdnTokRow td.viewerEdnMappedTokHasEdit {
  padding-right: 1.8em;
}

/* Add-token buttons — appear on left/right outside a selected token cell */
.viewerEdnAddTokBtn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 1.1em;
  height: 1.1em;
  padding: 0;
  border: 1px solid #0d3673;
  border-radius: 50%;
  background: #0d3673;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  line-height: 1em;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewerEdnAddTokBtn:hover {
  filter: brightness(1.2);
}
.viewerEdnAddTokBtn.viewerEdnAddTokBtnLeft {
  left: -0.65em;
}
.viewerEdnAddTokBtn.viewerEdnAddTokBtnRight {
  right: -0.65em;
}

/* Syllable cells — clickable for selection, edit via hover button */
tr.viewerEdnSclRow td.viewerEdnMappedScl {
  position: relative;
  cursor: pointer;
}

tr.viewerEdnSclRow td.viewerEdnMappedScl:hover {
  background-color: #eef3fb;
}

tr.viewerEdnSclRow td.viewerEdnMappedScl.selected {
  background-color: #dceef8;
  outline: 2px solid #4a9cc9;
  outline-offset: -2px;
}

tr.viewerEdnSclRow td.viewerEdnMappedSclHasEdit {
  padding-right: 1.8em;
}

tr.viewerEdnSclRow td.viewerEdnMappedScl .viewerEdnSclEditBtn {
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
  width: 1.25em;
  height: 1.25em;
  padding: 0;
  border: 1px solid #1f6fb2;
  border-radius: 50%;
  background: rgba(30, 100, 165, 0.95);
  color: #fff;
  font-size: 10px;
  line-height: 1.1em;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
}

tr.viewerEdnSclRow td.viewerEdnMappedScl:hover .viewerEdnSclEditBtn,
tr.viewerEdnSclRow td.viewerEdnMappedScl:focus-within .viewerEdnSclEditBtn,
tr.viewerEdnSclRow td.viewerEdnMappedScl.selected .viewerEdnSclEditBtn {
  opacity: 1;
  pointer-events: auto;
}

tr.viewerEdnSclRow td.viewerEdnMappedScl .viewerEdnSclEditBtn:hover {
  background: rgba(25, 85, 140, 0.98);
}

/* Token edit modal */
.viewerTokEditValue {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  padding: 4px 0;
}

.viewerTokEditLoadingOverlay {
  cursor: wait;
}

.viewerTokEditLoadingDialog {
  min-width: 240px;
}

.viewerTokEditLoadingText {
  color: #656565;
  font-size: 12px;
}

.viewerTokEditGraGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.viewerTokEditGraCell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 4px 10px 4px 10px;
  min-width: 48px;
  min-height: 52px;
  background: #fafafa;
  cursor: default;
}

.viewerTokEditGraCell:hover {
  border-color: #e44;
}

/* In split-token mode, grapheme cells are clickable split targets */
.viewerTokEditGraGridSplitMode .viewerTokEditGraCell {
  cursor: crosshair;
}
.viewerTokEditGraGridSplitMode .viewerTokEditGraCell:hover {
  border-color: #e8a850;
  background: #fff3e0;
}

.viewerTokEditGraId {
  font-size: 9px;
  color: #ccc;
  align-self: center;
  margin-bottom: auto;
}

.viewerTokEditGraChar {
  font-size: 16px;
  color: #000;
}

.viewerTokEditGraType {
  font-size: 8px;
  color: #ccc;
  align-self: flex-end;
  margin-top: auto;
}

.viewerTokEditUnlink {
  display: none;
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-size: 11px;
  color: #fff;
  background: #d44;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.viewerTokEditGraCell:hover .viewerTokEditUnlink {
  display: block;
}

.viewerTokEditGraRemoved {
  opacity: 0.35;
  border-color: #d44;
  background: #fee;
  text-decoration: line-through;
}

.viewerTokEditGraRemoved .viewerTokEditUnlink {
  display: block;
  background: #888;
}

.viewerTokEditGraSelected {
  border-color: #4a7cc9;
  background: #eef3fb;
  box-shadow: 0 0 0 2px rgba(74, 124, 201, 0.35);
  cursor: pointer;
}

.viewerTokEditGraEditing {
  border-color: #4a7cc9;
  background: #fff;
}

.viewerTokEditGraInput {
  width: calc(100% - 4px);
  max-width: 3em;
  min-width: 1.5em;
  font-size: 16px;
  text-align: center;
  border: none;
  border-bottom: 1px solid #4a7cc9;
  outline: none;
  background: transparent;
  padding: 0;
  color: #000;
}

.viewerTokEditGraAdd {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  align-self: center;
  font-size: 14px;
  font-weight: bold;
  color: #4a7cc9;
  border: 1px dashed #4a7cc9;
  border-radius: 3px;
  cursor: pointer;
  background: #eef3fb;
  flex-shrink: 0;
}
.viewerTokEditGraAdd:hover {
  background: #d0dffa;
  border-color: #2a5a9a;
  color: #2a5a9a;
}

.viewerTokEditGraNew {
  border-color: #4a7cc9;
  border-style: dashed;
  background: #eef3fb;
}

/* ── TCM badge on grapheme cells ── */
.viewerTokEditGraTcmBadge {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  line-height: 1;
  padding: 1px 3px;
  background: #ffefc0;
  border: 1px solid #dab300;
  border-radius: 3px;
  color: #7a5e00;
  white-space: nowrap;
}

/* ── TCM button row in token edit modal ── */
.viewerTokEditTcmRow {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 8px 0 4px 0;
  flex-wrap: wrap;
}

.viewerTokEditTcmLabel {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  margin-right: 4px;
}

.viewerTokEditTcmBtn {
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #f8f8f8;
  cursor: pointer;
  color: #333;
}
.viewerTokEditTcmBtn:hover {
  background: #e8e8e8;
  border-color: #999;
}
.viewerTokEditTcmBtn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* ── Token operation buttons (Add syllable / Add grapheme / Split token) ── */
.viewerTokEditOpsRow {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.viewerTokEditOpsBtn {
  padding: 4px 10px;
  font-size: 10pt;
  border: 1px solid #999;
  border-radius: 3px;
  background: #f5f5f5;
  color: #333;
  cursor: pointer;
}
.viewerTokEditOpsBtn:hover {
  background: #e8e8e8;
}
.viewerTokEditOpsBtn.active {
  background: #2a6aa0;
  color: #fff;
  border-color: #2a6aa0;
}

/* Insert targets shown between grapheme cells */
.viewerTokEditInsertTarget {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 8px;
  min-height: 52px;
  border-radius: 4px;
  background: #d0dffa;
  border: 2px dashed #4a7cc9;
  cursor: pointer;
  transition: background 0.15s;
}
.viewerTokEditInsertTarget:hover {
  background: #4a7cc9;
}

/* Visual gap shown at the split point after the user clicks a split target */
.viewerTokEditSplitGap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  min-height: 52px;
  border-radius: 4px;
  background: #fff3e0;
  border: 2px solid #e8a850;
  cursor: pointer;
  font-size: 14px;
  color: #c77600;
}
.viewerTokEditSplitGap::after {
  content: '\2702'; /* scissors */
}
.viewerTokEditSplitGap:hover {
  background: #fdd9b5;
}

/* Shared grapheme cell (belongs to both halves of a within-grapheme split) */
.viewerTokEditGraShared {
  border-color: #e8a850;
  background: #fff3e0;
  box-shadow: 0 0 0 2px #e8a850;
}

/* Split-within overlay shown under V-type cells */
.viewerTokEditSplitOverlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: #d0dffa;
  border-top: 2px dashed #4a7cc9;
  cursor: pointer;
  border-radius: 0 0 4px 4px;
  transition: background 0.15s;
}
.viewerTokEditSplitOverlay:hover {
  background: #4a7cc9;
}

/* Cell marked as having a decomposition split */
.viewerTokEditGraSplit {
  border-color: #e67e22;
  background: #fef5e7;
  box-shadow: 0 0 0 2px rgba(230, 126, 34, 0.3);
}

/* Decomposed vowel display within a grapheme cell */
.viewerTokEditGraDecomp {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: #e67e22;
  margin-top: 2px;
  cursor: pointer;
}
.viewerTokEditGraDecomp:hover {
  text-decoration: underline;
}
.viewerTokEditDecompLeft,
.viewerTokEditDecompRight {
  font-weight: bold;
}
.viewerTokEditDecompSep {
  font-size: 9px;
  color: #999;
}

/* ── Compound membership section ──────────────────────────────── */
.viewerTokEditCompoundSection {
  margin: 8px 0 4px;
  padding: 6px 8px;
  border: 1px solid #c4d4e8;
  border-radius: 4px;
  background: #f2f6fc;
}
.viewerTokEditCompoundMembers {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.viewerTokEditCompoundMember {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #aab;
  border-radius: 3px;
  background: #fff;
  font-size: 12px;
  cursor: default;
}
.viewerTokEditCompoundMemberCurrent {
  border-color: #4a7cc9;
  background: #d0dffa;
  font-weight: bold;
}
.viewerTokEditMergeBtn {
  margin-top: 6px;
}
.viewerTokEditCompoundMergePending {
  border-color: #e67e22;
  background: #fef5e7;
}
.viewerTokEditCompoundStatus {
  margin-top: 4px;
  font-size: 11px;
  color: #e67e22;
  font-style: italic;
}

/* ── Vowel split picker dialog (floating, like the keyboard) ────── */
.viewerVowelSplitPicker {
  position: absolute;
  z-index: 9200;
  padding: 10px 12px;
  border: 1px solid #aaa;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  max-width: 420px;
}
.viewerVowelSplitTitle {
  font-weight: bold;
  font-size: 11pt;
  margin-bottom: 10px;
}
.viewerVowelSplitLabel {
  font-size: 9pt;
  color: #555;
  margin: 8px 0 4px;
}
.viewerVowelSplitRow {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.viewerVowelSplitKey {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  font-size: 14px;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #f5f5f5;
  cursor: pointer;
  user-select: none;
}
.viewerVowelSplitKey:hover {
  background: #e0e0e0;
}
.viewerVowelSplitKey.selected {
  background: #2a6aa0;
  color: #fff;
  border-color: #2a6aa0;
}
.viewerVowelSplitSep {
  font-size: 10px;
  min-width: auto;
  padding: 0 10px;
}
.viewerVowelSplitBtnRow {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: flex-end;
}
.viewerVowelSplitRemoveBtn {
  color: #c0392b;
  border-color: #c0392b;
}
.viewerVowelSplitRemoveBtn:hover {
  background: #c0392b;
  color: #fff;
}

/* ── Floating grapheme virtual keyboard ─────────────────────────── */
.viewerGraKeyboard {
  position: absolute;
  z-index: 9200;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  width: 810px;
  background: #fff;
  border: 1px solid #aaa;
  border-radius: 5px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

.viewerGraKey {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 39px;
  height: 39px;
  padding: 0 6px;
  font-size: 20px;
  font-family: inherit;
  border: 1px solid #aaa;
  border-radius: 4px;
  background: #f5f5f5;
  color: #000;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.viewerGraKey:hover {
  background: #ddeeff;
  border-color: #4a7cc9;
}

.viewerGraKey:active {
  background: #4a7cc9;
  color: #fff;
}

.viewerGraKeySecondary {
  background: #e0e0e0;
  border-color: #ccc;
  color: #333;
}

.viewerGraKeySecondary:hover {
  background: #c8ddf0;
  border-color: #4a7cc9;
}

.viewerGraKeysWrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.viewerGraKeyBreak {
  flex-basis: 100%;
  height: 0;
}

.viewerGraKeySpacer {
  height: 39px;
}

.viewerGraTypeSwitchBar {
  display: flex;
  gap: 5px;
  margin-top: 8px;
  border-top: 1px solid #ddd;
  padding-top: 8px;
}

.viewerGraTypeSwitch {
  flex: 1;
  min-width: 0;
  height: 36px;
  font-size: 17px;
  font-family: inherit;
  border: 1px solid #aaa;
  border-radius: 4px;
  background: #f0f0f0;
  color: #333;
  cursor: pointer;
  padding: 0 3px;
  user-select: none;
  -webkit-user-select: none;
}

.viewerGraTypeSwitch:hover {
  background: #ddeeff;
  border-color: #4a7cc9;
}

.viewerGraTypeSwitchActive {
  background: #4a7cc9;
  color: #fff;
  border-color: #3a6ab9;
  font-weight: bold;
}

.viewerGraTypeSwitchActive:hover {
  background: #3a6ab9;
}

/* On-demand token edit button (shown after pen tap on selected token). */
.viewerTokQuickEditBtn {
  position: fixed;
  z-index: 9100;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid #1f6fb2;
  background: rgba(30, 100, 165, 0.95);
  color: #fff;
  font-size: 14px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 2px 7px rgba(0,0,0,0.35);
  padding: 0;
}

.viewerTokQuickEditBtn:hover {
  background: rgba(25, 85, 140, 0.98);
}

.viewerTokQuickEditBtn.hide {
  display: none;
}

.viewerPropsCiteToken {
  margin-top: 8px;
}

.viewerPropsCiteTokenWrap {
  position: relative;
  display: block;
}

.viewerPropsCiteBtn {
  display: block;
  width: 100%;
  padding: 4px 8px;
  font-size: 11pt;
  cursor: pointer;
  background: #2a6aa0;
  color: #fff;
  border: none;
  border-radius: 3px;
}

.viewerPropsCiteBtn:hover {
  background: #1d5080;
}

.viewerPropsCiteTooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.88);
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.viewerPropsCiteTokenWrap:hover .viewerPropsCiteTooltip {
  display: block;
}

tr.viewerEdnTokRow td.viewerEdnSharedGra {
  background: linear-gradient(to right, #f5f5f5 0%, #f5f5f5 45%, #d5d5d5 49%, #d5d5d5 51%, #f5f5f5 55%, #f5f5f5 100%);
  font-weight: normal;
  font-size: 8pt;
  color: #656565;
}

tr.viewerEdnSclRow td {
  background-color: #fff;
}

tr.viewerEdnGraRow td {
  background-color: #fff;
  font-size: 8pt;
  color: #656565;
  width: 3em;
  min-width: 3em;
  max-width: 3em;
}

tr.viewerEdnGraRow td.viewerEdnGraCell {
  cursor: pointer;
}

tr.viewerEdnGraRow td.viewerEdnGraCell:hover {
  background-color: #f0f4fa;
}

tr.viewerEdnGraRow td.viewerEdnGraCell.selected {
  background-color: #d0e0f8;
  outline: 2px solid #4a7cc9;
  outline-offset: -2px;
}

.viewerEdnGraTcmBtn {
  position: absolute;
  transform: translateX(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #4a7cc9;
  background: #fff;
  color: #4a7cc9;
  font-size: 8pt;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  line-height: 32px;
  text-align: center;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.viewerEdnGraTcmBtn:hover {
  background: #4a7cc9;
  color: #fff;
}

.viewerEdnTokJoinBtn {
  position: absolute;
  transform: translateX(-50%);
  padding: 2px 10px;
  border-radius: 4px;
  border: 2px solid #4a7cc9;
  background: #fff;
  color: #4a7cc9;
  font-size: 9pt;
  font-weight: 600;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.viewerEdnTokJoinBtn:hover {
  background: #4a7cc9;
  color: #fff;
}

.viewerEdnGraTcmMenu {
  position: absolute;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 20;
  padding: 2px 4px;
  gap: 2px;
}

.viewerEdnGraTcmMenuItem {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 9pt;
  font-weight: 600;
  color: #4a7cc9;
  border-radius: 12px;
}

.viewerEdnGraTcmMenuItem:hover {
  background: #4a7cc9;
  color: #fff;
}

span.viewerEdnGraId {
  font-size: 8pt;
  color: #656565;
}

span.viewerEdnGraChar {
  font-size: 11pt;
  color: #000;
}

.viewerEdnPagination {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid #d5d5d5;
  margin-top: 8px;
}

.viewerEdnPageBtn {
  padding: 5px 8px;
  font-size: 9pt;
  cursor: pointer;
  border: 1px solid #a5a5a5;
  border-radius: 3px;
  background: #d5d5d5;
  color: #333;
  text-align: center;
}

.viewerEdnPageBtn:hover {
  background: #a5a5a5;
}

.viewerEdnPageInfo {
  font-size: 9pt;
  color: #656565;
  padding: 2px 0;
  text-align: center;
}

/* ── Structure viewer ─────────────────────────────────────── */

.viewerStructureTree {
  padding: 6px 8px;
}

.viewerStructureLabel {
  font-size: 9pt;
  font-weight: 600;
  color: #656565;
  margin-bottom: 4px;
}

.viewerStructureMsg {
  font-size: 9pt;
  color: #656565;
  padding: 4px 8px;
}

ul.viewerStructureLevel {
  list-style: none;
  margin: 0 0 0 14px;
  padding: 2px 0 2px 10px;
  border-left: 1px solid #d5d5d5;
}

li.viewerStructureSeq {
  margin: 2px 0;
}

.viewerStructureSeqToggle {
  display: inline-block;
  width: 12px;
  font-size: 8pt;
  color: #a5a5a5;
  cursor: pointer;
  user-select: none;
  text-align: center;
}

li.viewerStructureSeq.collapsed > .viewerStructureSeqToggle {
  transform: rotate(-90deg);
}

li.viewerStructureSeq.collapsed > ul.viewerStructureLevel,
li.viewerStructureSeq.collapsed > table.viewerStructureTokTable {
  display: none;
}

.viewerStructureSeqId {
  display: block;
  font-size: 7pt;
  color: #a5a5a5;
}

.viewerStructureSeqLabel {
  font-size: 9pt;
  font-weight: 600;
  color: #444;
}

.viewerStructureSeqSublabel {
  font-weight: 400;
  color: #a5a5a5;
}

li.viewerStructureTokGroup {
  margin: 2px 0;
}

table.viewerStructureTokTable {
  border-collapse: collapse;
  display: inline-table;
  vertical-align: middle;
  margin-left: 6px;
}

tr.viewerStructureTokIdRow td {
  font-size: 7pt;
  color: #a5a5a5;
  text-align: center;
  padding: 0 4px;
}

tr.viewerStructureTokValueRow td {
  font-size: 9pt;
  text-align: center;
  padding: 0 4px;
}

@media only screen and (max-device-width: 480px) {
  div.newViewer {
    top: 58px;
    height: auto;
    bottom: 0;
  }
  div.newViewerArea {
    margin-top: 0;
  }
}

/* ── Text Tree View ──────────────────────────────────────────────────── */

.viewerTextTree {
  padding: 8px 4px;
  font-size: 9pt;
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.treeNode {
  margin-left: 16px;
}

.treeNode[data-tree-type="item"] {
  margin-left: 0;
}

.treeNodeRow {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: default;
}

.treeNodeRow:hover {
  background-color: #d5d5d5;
}

.treeNodeToggle {
  width: 14px;
  text-align: center;
  font-size: 8pt;
  cursor: pointer;
  user-select: none;
  color: #656565;
  flex-shrink: 0;
}

.treeNodeToggle.treeNodeLeaf {
  cursor: default;
  color: #a5a5a5;
}

.treeNodeType {
  font-size: 7.5pt;
  font-weight: 600;
  color: #fff;
  background-color: #a5a5a5;
  border-radius: 3px;
  padding: 0 4px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.treeNode[data-tree-type="item"] > .treeNodeRow .treeNodeType { background-color: #5b7fa6; }
.treeNode[data-tree-type="prt"]  > .treeNodeRow .treeNodeType { background-color: #7a9a5b; }
.treeNode[data-tree-type="frg"]  > .treeNodeRow .treeNodeType { background-color: #a67b5b; }
.treeNode[data-tree-type="srf"]  > .treeNodeRow .treeNodeType { background-color: #8b6fad; }
.treeNode[data-tree-type="txt"]  > .treeNodeRow .treeNodeType { background-color: #5b99a6; }
.treeNode[data-tree-type="edn"]  > .treeNodeRow .treeNodeType { background-color: #a65b7f; }

.treeNodeId {
  font-size: 7.5pt;
  color: #a5a5a5;
  flex-shrink: 0;
}

.treeNodeLabel {
  font-size: 9pt;
  color: #333;
}

.treeNodeChildren {
  border-left: 1px solid #d5d5d5;
  margin-left: 7px;
  padding-left: 0;
}

.treeNodeChildren.treeNodeCollapsed {
  display: none;
}

.treeNodeEditable {
  cursor: pointer;
  border-bottom: 1px dashed transparent;
}

.treeNodeEditable:hover {
  border-bottom-color: #a5a5a5;
}

.treeNodeEditInput {
  font-size: 9pt;
  padding: 0 3px;
  border: 1px solid #a5a5a5;
  border-radius: 2px;
  outline: none;
  width: 140px;
}

.treeAddBtn {
  margin-left: 16px;
  padding: 2px 8px;
  font-size: 8pt;
  color: #a5a5a5;
  cursor: pointer;
  border-radius: 3px;
  display: inline-block;
  margin-top: 2px;
}

.treeAddBtn:hover {
  color: #333;
  background-color: #d5d5d5;
}

/* ── Edition lines in tree view ──────────────────────────────────────── */

.treeLineLoading {
  font-size: 8pt;
  color: #a5a5a5;
  padding: 2px 8px;
  font-style: italic;
}

.treeLineGroup {
  margin: 4px 0;
  border: 1px solid #d5d5d5;
  border-radius: 4px;
  padding: 2px;
}

.treeLineGroup.treeLineGroupDragOver {
  border-color: #5b99a6;
  background-color: rgba(91, 153, 166, 0.06);
}

.treeLineGroupHeader {
  font-size: 8pt;
  font-weight: 600;
  color: #656565;
  padding: 2px 6px;
  background-color: #d5d5d5;
  border-radius: 2px;
  margin-bottom: 2px;
}

.treeLineList {
  min-height: 20px;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 1px;
}

.treeLineList.treeLineListDragOver {
  border-color: #5b99a6;
  background-color: rgba(91, 153, 166, 0.06);
}

.treeNode.treeNodeDropTarget > .treeNodeRow {
  outline: 2px dashed #5b99a6;
  background-color: rgba(91, 153, 166, 0.08);
}

.treeLineItem {
  font-size: 8.5pt;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 2px;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.treeLineItem:hover {
  background-color: #d5d5d5;
}

.treeLineItem.treeLineSelected {
  background-color: #cde4f0;
}

.treeLineItem.treeLineSelected:hover {
  background-color: #b8d8ea;
}

.treeLineItem[draggable="true"] {
  cursor: grab;
}

.treeLineItem[draggable="true"]:active {
  cursor: grabbing;
}
