.txt-mode-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.txt-mode-toolbar > :first-child {
  justify-self: start;
}

.txt-mode-toolbar > :nth-child(2) {
  justify-self: center;
}

.txt-mode-toolbar > :last-child {
  justify-self: end;
}

.txt-mode-help {
  margin: 0;
  color: #4a5568;
  max-width: 760px;
}

.txt-mode-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#txt-mode-load-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#txt-mode-load-btn .txt-load-icon {
  width: 14px;
  text-align: center;
}

#txt-mode-load-btn.is-success {
  border-color: #6bbf7a;
  background: #edf9ef;
}

#txt-mode-load-btn.is-success .txt-load-icon,
#txt-mode-load-btn.is-success .txt-load-label {
  color: #1f7f36;
}

.txt-mode-controls select {
  min-width: 260px;
  margin-bottom: 0;
}

.txt-mode-status {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #dbe6f3;
  border-radius: 6px;
  background: #f6f9fd;
  color: #2b4460;
  font-size: 14px;
}

.txt-mode-status.is-error {
  border-color: #f1b5b0;
  background: #fff1f0;
  color: #842a23;
}

.txt-mode-status.is-success {
  border-color: #b7dfbf;
  background: #edf9ef;
  color: #1f5f29;
}

.txt-mode-page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

#txt-page-indicator {
  min-width: 170px;
  text-align: center;
  font-weight: 600;
  color: #2b4460;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#txt-page-input {
  min-width: 28px;
  padding: 0;
  margin: 0;
  height: 30px;
  text-align: center;
}

.txt-mode-pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid #dde6f2;
  border-radius: 6px;
  background: #f8fbff;
  font-size: 13px;
}

.txt-mode-pipeline label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.txt-tool-range {
  border-left: 1px solid #dbe6f3;
  padding-left: 10px;
}

.txt-tool-range input[type="range"] {
  width: 120px;
}

.txt-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 60vh;
}

.txt-mode-panel {
  border: 1px solid #d9e3ef;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.txt-mode-panel h4 {
  margin: 0 0 8px;
  color: var(--dark-blue);
}

.txt-mode-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.txt-mode-panel-header h4 {
  margin: 0;
}

.txt-preview-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.txt-icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.txt-icon-btn i {
  font-size: 12px;
}

.txt-icon-btn.is-active {
  border-color: #7fa9d3;
  background: var(--dark-blue);
}

.txt-mode-content {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.45;
  background: #f8fbff;
  border: 1px solid #e5edf7;
  border-radius: 6px;
  padding: 10px;
  min-height: 50vh;
  max-height: 72vh;
  overflow: auto;
}

.txt-panel-spinner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #436180;
  font-family: "Google Sans", sans-serif;
  font-size: 13px;
}

.txt-panel-spinner i {
  font-size: 14px;
}

#txt-mode-left {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.txt-mode-page-fit {
  display: block;
  position: relative;
  margin: 0 auto;
}

#txt-mode-right {
  font-family: Georgia, "Times New Roman", Times, serif;
  font-size: 14px;
  line-height: 1.4;
  color: #17212b;
  background: #fdfefe;
  display: flex;
}

.txt-semantic-root {
  margin: 0 auto;
  max-width: 780px;
  width: 100%;
}

.txt-semantic-page {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.txt-semantic-body {
  flex: 0 0 auto;
}

.txt-semantic-body.is-editable {
  outline: 1px dashed #8bb1d7;
  outline-offset: 4px;
  border-radius: 4px;
  cursor: text;
}

.txt-semantic-body.is-editable:focus {
  outline-color: #2f6ea8;
}

.txt-semantic-page-label {
  margin: 0 0 1em;
  font-size: 12px;
  font-family: "Google Sans", sans-serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #5f7995;
}

.txt-semantic-root h1,
.txt-semantic-root h2,
.txt-semantic-root h3 {
  color: #0f1f2d;
  line-height: 1.25;
}

.txt-semantic-root h1 {
  font-size: 1.4em;
  margin: 1.3em 0 0.65em;
}

.txt-semantic-root h2 {
  font-size: 1.2em;
  margin: 1.2em 0 0.6em;
}

.txt-semantic-root h3 {
  font-size: 1.15em;
  margin: 1em 0 0.45em;
}

.txt-semantic-root p {
  margin: 0.9em 0;
  text-wrap: pretty;
}

.txt-semantic-body .txt-change-modified {
  background: rgba(221, 170, 66, 0.05);
  border-left: 3px solid rgba(221, 170, 66, 0.5);
  padding-left: 8px;
}

.txt-footnotes {
  margin-top: 1.6em;
  padding-top: 0.1em;
}

.txt-footnotes hr {
  border: 0;
  border-top: 1px solid #d4e1ef;
  margin: 0 0 0.8em;
}

.txt-footnotes small {
  display: block;
  color: #2a3d50;
}

.txt-footnotes small ol {
  margin: 0;
  padding-left: 1.4em;
}

.txt-footnotes small li {
  margin: 0.45em 0;
}

.txt-footnote-ref {
  text-decoration: none;
  color: #1f5f9f;
}

.txt-footnote-ref:hover {
  text-decoration: underline;
}

.txt-footnote-ref.is-missing {
  color: inherit;
  text-decoration: none;
  pointer-events: none;
}

.txt-semantic-root .txt-index-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  margin: 0.35em 0;
  padding-bottom: 0.15em;
  border-bottom: 1px dotted #9eb3c7;
}

.txt-semantic-root .txt-index-label {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.txt-semantic-root .txt-index-page {
  color: #1f5f9f;
  font-weight: 600;
  text-decoration: none;
}

.txt-semantic-root .txt-index-page:hover {
  text-decoration: underline;
}

.txt-semantic-root .txt-index-page.is-disabled {
  color: #7f8ea0;
  pointer-events: none;
}

.txt-semantic-root .page-number {
  display: block;
  margin-top: auto;
  font-family: "Google Sans", sans-serif;
  font-size: 12px;
  color: #6c8198;
  text-align: right;
  margin-right: 0.4em;
  margin-bottom: 0.35em;
}

.txt-semantic-root .txt-page-break {
  margin: 1.8em 0;
  border: 0;
  border-top: 1px dashed #c6d6e8;
}

.txt-semantic-root .txt-page-break-label {
  margin-top: -1.2em;
  margin-bottom: 1.1em;
  font-size: 12px;
  color: #6a7f96;
  text-align: center;
}

.txt-mode-page {
  position: relative;
  margin: 0 auto 12px;
  border: 1px solid #d7e2ef;
  border-radius: 4px;
  background: #fff;
  overflow: hidden;
  transform-origin: top left;
  flex: none;
}

.txt-mode-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.txt-mode-text-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.textLayer {
  position: absolute;
  text-align: initial;
  inset: 0;
  overflow: clip;
  opacity: 1;
  line-height: 1;
  -webkit-text-size-adjust: none;
  -moz-text-size-adjust: none;
  text-size-adjust: none;
  transform-origin: 0 0;
  caret-color: CanvasText;
}

.textLayer span,
.textLayer br {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0 0;
}

.textLayer ::selection {
  background: color-mix(in srgb, AccentColor, transparent 75%);
}

@media screen and (max-width: 812px) {
  .txt-mode-toolbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .txt-mode-toolbar > :first-child,
  .txt-mode-toolbar > :nth-child(2),
  .txt-mode-toolbar > :last-child {
    justify-self: stretch;
  }

  .txt-mode-page-nav {
    flex-wrap: wrap;
  }

  #txt-page-indicator {
    order: -1;
    width: 100%;
  }

  .txt-mode-controls {
    width: 100%;
  }

  .txt-mode-controls select {
    min-width: 0;
    width: 100%;
  }

  .txt-mode-grid {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .txt-mode-content {
    min-height: 35vh;
    max-height: 45vh;
  }

  .txt-tool-range {
    border-left: 0;
    padding-left: 0;
  }
}
