/* Editor redesign layer: design tokens, sticky item bar, calmer fields, dark theme.
   Loaded last, so it refines the older stylesheets without rewriting them. */
:root {
  --bg: #f4efe5;
  --surface: #fffefb;
  --surface-2: #faf7ef;
  --ink: #2a2620;
  --ink-2: #756e62;
  --line: #e4dccb;
  --accent: #2f6b4c;
  --accent-ink: #fff;
  --accent-soft: #ebefe0;
  --en-bg: #f8f4ea;
  --en-line: #e7dfce;
  --ua-bg: #fffefb;
  --ua-line: #c3d0b3;
  --warn: #b57a12;
  --warn-soft: #fbefcf;
  --danger-soft: #f8e4da;
  --shadow: 0 1px 2px #3a2f1a12, 0 6px 18px #3a2f1a0e;
  --radius: 12px;
  color: var(--ink);
  background: var(--bg);
  color-scheme: light;
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #111214;
  --surface: #1e2023;
  --surface-2: #292c31;
  --ink: #f4f5f7;
  --ink-2: #bcc2c9;
  --line: #3b4046;
  --accent: #8fd6ac;
  --accent-ink: #102016;
  --accent-soft: #2a3430;
  --en-bg: #17181b;
  --en-line: #2f3338;
  --ua-bg: #25292e;
  --ua-line: #4a6455;
  --warn: #e0b04f;
  --warn-soft: #3a2f16;
  --danger-soft: #3d221d;
  --shadow: 0 1px 2px #0006, 0 8px 24px #0006;
}
body {
  background: var(--bg);
  color: var(--ink);
}
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px 3%;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar nav button[aria-current='page'] {
  background: var(--accent-soft);
  color: var(--accent);
}
button {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--line);
  border-radius: 8px;
  transition:
    background 0.12s,
    border-color 0.12s;
}
button:hover {
  background: var(--accent-soft);
}
.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.primary:hover {
  background: var(--accent);
  filter: brightness(1.1);
}
input[type='search'],
textarea,
input[type='text'],
input[type='password'],
select {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.muted {
  color: var(--ink-2);
}
.card,
.row,
.field,
.panel,
.group {
  background: var(--surface);
  border-color: var(--line);
}

/* --- Item bar: navigation and progress stay in view while reading --- */
.item-toolbar {
  position: sticky;
  top: 52px;
  z-index: 10;
  margin: 0 0 12px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.item-toolbar button {
  padding: 7px 11px;
}
.item-header {
  align-items: center;
  margin: 18px 0 4px;
}
.item-header h1 {
  margin: 0 auto 0 0;
  font-size: 30px;
  line-height: 1.15;
}
.item-status,
.status {
  border-radius: 999px;
  padding: 4px 11px;
}
.item-status {
  color: var(--accent);
  background: var(--accent-soft);
}
.tag {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 2px 9px;
}
.ai-comment {
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
}

/* --- Field card --- */
.field {
  padding: 0;
  margin: 18px 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.field-header {
  align-items: center;
  margin: 0;
  padding: 10px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.field-header strong {
  font: 600 12px/1.4 ui-monospace, Consolas, monospace;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 3px 8px;
}
.field-header .muted {
  margin-left: auto;
}
.field-layout {
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 0;
}
.field-body {
  padding: 16px 18px 18px;
}
.field-side {
  border-left: 1px solid var(--line);
  background: var(--surface-2);
  padding: 16px;
}
.field.unsaved {
  padding-left: 0;
  box-shadow:
    inset 4px 0 var(--warn),
    var(--shadow);
}
.unsaved-badge {
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 999px;
  padding: 3px 10px;
}

/* EN is a quiet reference, UA is the working text. */
.clean-columns:not([hidden]) {
  gap: 12px;
}
.reading-column {
  padding: 16px 18px;
  border-radius: 10px;
  background: var(--en-bg);
  border: 1px solid var(--en-line);
}
.reading-column.target,
.clean-columns .target {
  background: var(--ua-bg);
  border: 1px solid var(--ua-line);
}
.clean-columns .reading-column {
  background: var(--en-bg);
  border-color: var(--en-line);
}
.clean-columns .reading-column.target {
  background: var(--ua-bg);
  border-color: var(--ua-line);
}
.field-column-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 11px;
}
.reader {
  font: 17px/1.7 Georgia, 'Times New Roman', serif;
  color: var(--ink);
}
.reader ::selection {
  background: #f3d98a;
  color: #1f2a24;
}

/* Editing: a calm, large writing surface. */
.inline-editor {
  margin-top: 14px;
}
.inline-editor > summary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--accent);
  border-radius: 8px;
}
.inline-editor textarea {
  min-height: 170px;
  margin-top: 10px;
  padding: 14px;
  border-radius: 10px;
  font: 15px/1.65 ui-monospace, Consolas, monospace;
  resize: vertical;
}
.inline-editor textarea:focus {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}

/* Side panel */
.field-side h3 {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.term-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 8px;
}
.field-note {
  background: var(--warn-soft);
  border-left-color: var(--warn);
  border-radius: 0 8px 8px 0;
}
.glossary-highlight {
  background: #f6e3a0;
  color: #1f2a24;
}

/* History cards */
.field-history-card {
  background: var(--surface);
  border-color: var(--line);
  border-radius: 10px;
}
.field-history-summary {
  background: var(--surface-2);
}
.aligned-diff {
  border-color: var(--line);
}
.diff-heading {
  background: var(--surface-2);
  color: var(--ink-2);
  border-color: var(--line);
}
.diff-paragraph.diff-before {
  background: var(--danger-soft);
  border-color: var(--line);
}
.diff-paragraph.diff-after {
  background: var(--ua-bg);
}
.clean-preview .diff-paragraph.diff-after {
  background: var(--surface);
}
.history {
  border-radius: var(--radius);
}

/* Action bar: floating, always reachable */
.actions {
  bottom: 12px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border-color: var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  align-items: center;
}
.actions .primary {
  padding: 10px 18px;
}
kbd {
  font: 600 11px/1 ui-monospace, Consolas, monospace;
  padding: 2px 5px;
  border: 1px solid currentColor;
  border-radius: 4px;
  opacity: 0.7;
  margin-left: 6px;
}
.session-item-progress {
  margin-bottom: 8px;
}

/* Dark theme: the older rules hard-code light colours, so restate them with tokens. */
:root[data-theme='dark'] :is(.sessionbar, .warning, .draft-conflict, .proposal, .session-item-progress) {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}
:root[data-theme='dark'] .stat-card {
  background: var(--surface);
  border-color: var(--line);
}
:root[data-theme='dark'] .stat-card strong {
  color: var(--accent);
}
:root[data-theme='dark'] :is(.stat-card span, .session-progress, .tag-filter-clear) {
  color: var(--ink-2);
}
:root[data-theme='dark'] .file-group > summary {
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme='dark'] :is(.tag-select, select, .tag-filter-chip) {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme='dark'] .draft-conflict pre,
:root[data-theme='dark'] .raw-diff pre {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme='dark'] .status {
  background: var(--surface-2);
  color: var(--ink-2);
}
:root[data-theme='dark'] :is(.status-findings, .status-returned) {
  background: #4a2622;
  color: #f0a49b;
}
:root[data-theme='dark'] :is(.status-source_updated, .status-awaiting_review.flag-unsure) {
  background: var(--warn-soft);
  color: var(--warn);
}
:root[data-theme='dark'] .status-untranslated {
  background: #2f2742;
  color: #c4b3ea;
}
:root[data-theme='dark'] :is(.status-awaiting_review, .status-in_ai) {
  background: #1f3047;
  color: #9fc3ec;
}
:root[data-theme='dark'] .status-confirmed {
  background: #1f4a30;
  color: #9fe0b5;
}
:root[data-theme='dark'] .item-status {
  background: var(--accent-soft);
  color: var(--accent);
}
:root[data-theme='dark'] :is(.diff-delete, del) {
  background: #4a2622;
  color: #f0a49b;
}
:root[data-theme='dark'] :is(.diff-insert, ins) {
  background: #1f4a30;
  color: #9fe0b5;
}
:root[data-theme='dark'] .reader .foundry-ref {
  background: #1d3447;
  color: #9fcdea;
  border-color: #35566f;
}
:root[data-theme='dark'] .reader .foundry-mechanic {
  background: var(--surface-2);
  color: var(--ink-2);
  border-color: var(--line);
}
:root[data-theme='dark'] .dialog {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme='dark'] .bar nav button {
  background: transparent;
}

/* Theme switch in the top bar */
#theme {
  padding: 6px 10px;
  font-size: 15px;
  line-height: 1;
}

@media (max-width: 900px) {
  .field-layout {
    grid-template-columns: 1fr;
  }
  .field-side {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .item-toolbar {
    top: 0;
    position: static;
  }
  .item-header h1 {
    font-size: 24px;
  }
}
@media (max-width: 650px) {
  .clean-columns:not([hidden]) {
    grid-template-columns: 1fr;
  }
}

.field-header strong:empty {
  display: none;
}

.history summary,
.raw-diff summary,
.group > summary {
  color: var(--accent);
}

/* --- Field header switch: clean text or the changes of this field --- */
.field-header {
  flex-wrap: wrap;
  gap: 8px;
}
.view-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.view-switch .seg {
  border: 0;
  border-radius: 0;
  padding: 4px 11px;
  font-size: 12px;
  background: transparent;
}
.view-switch .seg + .seg {
  border-left: 1px solid var(--line);
}
.view-switch .seg.active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* --- Editing: opened by the header button, double click or E --- */
.inline-editor > summary {
  display: none;
}
.inline-editor {
  margin-top: 12px;
}
.edit-toggle {
  padding: 4px 10px;
  font-size: 12px;
}
.field {
  scroll-margin-top: 130px;
}

/* --- Terms heading only when there are terms --- */
.field-side h3:has(+ .field-terms:empty) {
  display: none;
}

/* --- Menus (the bar's «Ще», the glossary's «⋯») --- */
.menu {
  position: relative;
  display: inline-block;
}
.menu > summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}
.menu > summary::-webkit-details-marker {
  display: none;
}
.menu > summary:hover,
.menu[open] > summary {
  background: var(--accent-soft);
}
.menu-list {
  position: absolute;
  right: 0;
  z-index: 30;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.menu-list button {
  border: 0;
  text-align: left;
  background: transparent;
}
.actions .menu-list {
  bottom: calc(100% + 8px);
}
.actions .more {
  margin-left: 0;
}
.unsaved-count:not(:empty) {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 650;
}
.hint {
  margin: 4px 0 10px;
}

/* --- Field rail: where I am in a long item --- */
.item-layout {
  display: block;
}
.field-rail {
  display: none;
}
@media (min-width: 1100px) {
  .item-layout:not(.single-field) {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
  }
  .field-rail {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: sticky;
    top: 130px;
    max-height: calc(100vh - 230px);
    overflow: auto;
    padding: 10px 6px;
    margin-top: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
}
.field-rail-title {
  padding: 2px 8px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.rail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}
.rail-item.is-current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}
.rail-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--line);
}
.rail-item.has-note .rail-dot {
  background: #d9645a;
  border-color: #d9645a;
}
.rail-item.is-unsaved .rail-dot {
  background: var(--warn);
  border-color: var(--warn);
}

/* --- Glossary: dense rows --- */
.term-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 6px 0;
  padding: 10px 14px;
}
.term-row:hover {
  border-color: var(--accent);
}
.term-main {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(160px, 1.4fr) minmax(100px, 0.7fr) auto;
  gap: 14px;
  align-items: center;
}
.term-en {
  overflow-wrap: anywhere;
}
.term-ua {
  color: var(--ink);
  overflow-wrap: anywhere;
}
.term-cats {
  text-align: right;
}
.term-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.12s;
}
.term-row:hover .term-actions,
.term-row:focus-within .term-actions,
.term-actions:has(.menu[open]) {
  opacity: 1;
}
@media (hover: none) {
  .term-actions {
    opacity: 1;
  }
}
.term-actions button,
.term-actions .menu > summary {
  padding: 5px 10px;
  font-size: 12px;
}
.term-actions .menu-list {
  bottom: auto;
  top: calc(100% + 4px);
}
.term-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
  font-size: 12px;
}
.term-inactive {
  opacity: 0.6;
}
.term-history {
  margin: 4px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.term-history > summary {
  margin-top: 6px;
  font-size: 12px;
}
@media (max-width: 800px) {
  .term-main {
    grid-template-columns: 1fr auto;
  }
  .term-ua,
  .term-cats {
    grid-column: 1 / -1;
    text-align: left;
  }
}

/* --- Section separation: header, body and side panel read as three layers --- */
.field-header {
  background: color-mix(in srgb, var(--surface-2) 70%, var(--line));
}
.field-side {
  background: var(--surface-2);
}
.reading-column.target {
  box-shadow: inset 3px 0 var(--accent);
}

/* --- Action bar: a compact pill that fits its content --- */
.actions {
  width: fit-content;
  max-width: 100%;
  margin: 14px auto 0;
  gap: 6px;
}
.actions .primary {
  margin-left: 6px;
}
@media (max-width: 700px) {
  .actions {
    width: 100%;
    padding: 8px;
  }
  .actions kbd {
    display: none;
  }
  .actions button,
  .actions .menu > summary {
    padding: 9px 10px;
  }
  .actions .primary {
    flex: 1;
    margin-left: 0;
  }
  .unsaved-count:not(:empty) {
    flex-basis: 100%;
    text-align: center;
  }
}

.field-history-when {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
  text-align: right;
}
.field-history-when .field-history-actor {
  color: var(--ink);
  font-weight: 600;
}

/* --- Field history: text edits and status changes look different --- */
.field-history-card {
  border-left: 4px solid var(--line);
}
.field-history-card.kind-edit {
  border-left-color: var(--accent);
}
.field-history-card.kind-status {
  border-left-color: var(--ink-2);
  opacity: 0.92;
}
.field-history-card.kind-status > .field-history-summary {
  padding: 9px 14px;
}
.history-kind {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.kind-edit .history-kind {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* --- Home: statistics per editor --- */
.team-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.team-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.3fr) minmax(160px, 2fr) repeat(4, minmax(64px, 0.6fr));
  gap: 14px;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.team-row:first-child {
  border-top: 0;
}
.team-head {
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.team-row > span:nth-child(n + 3) {
  text-align: right;
}
.team-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.team-me {
  background: var(--accent-soft);
}
.team-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.team-bar strong {
  min-width: 2.5em;
  text-align: right;
}
.team-bar progress {
  flex: 1;
  height: 8px;
  accent-color: var(--accent);
}
@media (max-width: 700px) {
  .team-row {
    grid-template-columns: repeat(4, 1fr);
  }
  .team-row > .team-name,
  .team-row > .team-bar {
    grid-column: 1 / -1;
  }
  .team-head {
    display: none;
  }
}

/* --- Glossary: list on the left, the term's card on the right --- */
.gloss-layout {
  display: grid;
  grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.gloss-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  max-height: calc(100vh - 230px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.gloss-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 8px 12px;
  font-weight: 500;
}
.gloss-item-en {
  color: var(--ink);
  font-size: 14px;
}
.gloss-item-ua {
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gloss-item:hover {
  background: var(--surface-2);
}
.gloss-item.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 var(--accent);
}
.gloss-detail {
  position: sticky;
  top: 70px;
  min-height: 220px;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.gloss-empty {
  margin: 40px 0;
  text-align: center;
}
.gloss-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.gloss-head h2 {
  margin: 0;
  font-size: 26px;
  overflow-wrap: anywhere;
}
.gloss-cats {
  margin-top: 4px;
}
.gloss-ua {
  margin: 16px 0;
  padding: 14px 16px;
  background: var(--ua-bg);
  border: 1px solid var(--ua-line);
  box-shadow: inset 3px 0 var(--accent);
  border-radius: 10px;
}
.gloss-variant {
  font: 19px/1.5 Georgia, 'Times New Roman', serif;
}
.gloss-variant + .gloss-variant {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}
.gloss-block h3 {
  margin: 14px 0 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.gloss-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gloss-chips .tag {
  margin: 0;
  font-size: 13px;
  padding: 3px 10px;
}
.gloss-forbidden {
  background: var(--danger-soft);
  border-color: transparent;
  color: #a4443a;
  text-decoration: line-through;
}
.gloss-actions {
  display: flex;
  gap: 8px;
  margin: 20px 0 6px;
}
.gloss-history {
  margin-top: 14px;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}
.gloss-back {
  display: none;
  margin-bottom: 12px;
}
@media (max-width: 899px) {
  .gloss-layout {
    grid-template-columns: 1fr;
  }
  .gloss-layout.has-term .gloss-list-col {
    display: none;
  }
  .gloss-layout:not(.has-term) .gloss-detail {
    display: none;
  }
  .gloss-back {
    display: inline-block;
  }
  .gloss-detail {
    position: static;
  }
  .gloss-list {
    max-height: none;
  }
}

/* --- Quick-action menu (Ctrl + right click): remarks are told apart from a glossary action --- */
.annotation-menu {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
  border-radius: 10px;
  min-width: 240px;
}
.annotation-menu button {
  color: var(--ink);
  border-radius: 7px;
  font-weight: 500;
}
.annotation-menu button:hover {
  background: var(--surface-2);
}
.annotation-menu-title {
  padding: 6px 9px 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.annotation-menu-split {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.annotation-menu .annotation-flag {
  box-shadow: inset 3px 0 #d9645a;
}
.annotation-menu .annotation-flag:hover {
  background: var(--danger-soft);
}
.annotation-menu .annotation-term {
  color: var(--accent);
  font-weight: 650;
  box-shadow: inset 3px 0 var(--accent);
}
.annotation-menu .annotation-term:hover {
  background: var(--accent-soft);
}

/* --- A term lights up together with its words in the text --- */
.glossary-highlight[data-term],
.term-chip[data-term] {
  transition:
    background 0.12s,
    box-shadow 0.12s;
}
.glossary-highlight[data-term] {
  cursor: help;
}
.glossary-highlight.is-active {
  background: #f0c84a;
  box-shadow:
    0 0 0 2px #f0c84a,
    0 0 0 3px #a8820f;
}
.term-chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 3px 0 var(--accent);
  color: var(--ink);
}

/* --- View settings (⚙ in the top bar) --- */
#prefs > summary {
  padding: 6px 10px;
  font-size: 15px;
  line-height: 1;
}
#prefs .menu-list {
  right: 0;
  top: calc(100% + 8px);
  min-width: 250px;
  padding: 10px 12px;
  gap: 8px;
}
.prefs-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.prefs-list label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.prefs-list input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  margin: 0;
}
.bar {
  gap: 12px;
}
#identity {
  margin-right: 0;
}

/* --- Switched off: terms in the text lose their marking (hover on a chip still shows them) --- */
:root.no-terms .reader .glossary-highlight:not(.is-active) {
  background: transparent;
  box-shadow: none;
  color: inherit;
  cursor: auto;
}
/* --- Switched off: the text shows no fills or strike-through for what changed --- */
:root.no-diff.no-diff :is(ins, del, .diff-insert, .diff-delete) {
  background: transparent;
  color: inherit;
  text-decoration: none;
}
:root.no-diff.no-diff .diff-paragraph.diff-before {
  background: var(--surface);
}

/* --- Shortcut list (? in the top bar) --- */
#help {
  padding: 6px 11px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  border-radius: 999px;
}
.dialog.help {
  width: min(620px, calc(100% - 30px));
  max-height: calc(100vh - 40px);
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.help h2 {
  margin: 0 0 6px;
}
.help-section h3 {
  margin: 18px 0 6px;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.help-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.help-keys {
  white-space: nowrap;
}
.help-keys kbd {
  margin: 0;
  opacity: 1;
  padding: 3px 7px;
  font-size: 12px;
  border-color: var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--ink);
}
.help > div > button {
  margin-top: 16px;
}
@media (max-width: 560px) {
  .help-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* --- Previous / next: one group on the right of the item bar --- */
.item-toolbar {
  align-items: center;
}
.nav-group {
  margin-left: auto;
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.nav-group .seg {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 7px 14px;
  color: var(--accent);
}
.nav-group .seg:hover:not(:disabled) {
  background: var(--accent-soft);
}
.nav-group .seg:disabled {
  color: var(--ink-2);
  opacity: 0.45;
  cursor: default;
}
.nav-position {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--surface-2);
}
@media (max-width: 560px) {
  .nav-group {
    width: 100%;
    margin-left: 0;
  }
  .nav-group .seg {
    flex: 1;
  }
}
