main {
  padding-top: calc(var(--toolbar-h) + 12px); /* wysokość headera + margines */
}

/* ===============================
   BACKGROUND THEMES
================================ */

body.bg-white {
  background: #ffffff;
}

body.bg-paper {
  background-color: #efe6d6;
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(120, 102, 78, 0.04) 0,
      rgba(120, 102, 78, 0.04) 1px,
      transparent 1px,
      transparent 16px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(120, 102, 78, 0.04) 0,
      rgba(120, 102, 78, 0.04) 1px,
      transparent 1px,
      transparent 16px
    );
  background-attachment: fixed;
}

.background-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 10px;
  padding: 3px;
  border: 1px solid #d9dee7;
  border-radius: 999px;
  background: #f8fafc;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.bg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #475569;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.bg-btn:hover {
  background: #eef2f7;
  color: #334155;
}

.bg-btn.active {
  background: #ffffff;
  color: #1d4ed8;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

html, body {
  scroll-padding-bottom: calc(var(--annotation-footer-h) + 6px);
}

/* Odstęp z lewej strony dla listy segmentów */
#qaPairsPanel,
#qaPairsOutput {
  padding-left: 6px;   /* możesz zmienić np. na 24px */
  box-sizing: border-box;
  padding-bottom: calc(var(--annotation-footer-h));
}



/* QA potrzebuje układu pionowego (a nie globalnego flex-row) */
.tab-content[data-tab="qa"].active {
  display: flex;
  flex-direction: column;    /* kluczowe */
  align-items: stretch;
  overflow: visible;         /* ważne dla sticky */
}

/* Pasek narzędzi QA doklejony pod #toolbar */
.qa-toolbar-inner {
  position: sticky;
  top: var(--global-header-h);  /* ustawiasz JS-em */
  z-index: 1100;                /* nad treścią, nad #toolbar=1000 */
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  width: 100%;
}

.annotation-toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.7em;
  align-items: flex-end;
  background: linear-gradient(to right, #f0f4ff, #f5f7ff);
  padding: 0.5em 0.5em;
  border: 1px solid #d0d8ea;
  border-radius: 12px;
  margin-top: 0.4em;
  margin-bottom: 1em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  border-bottom: 2px solid #cdd8f0;

}

.qa-toolbar-container,
.tab-content[data-tab="qa"] { overflow: visible; }


.annotation-group {
  display: flex;
  flex-direction: row;  /* ⬅️ zamiast column */
  align-items: center;  /* ⬅️ żeby input był wyśrodkowany pionowo */
  gap: 0.5em;           /* ⬅️ trochę większy odstęp między elementami */
}



.annotation-toolbar input[type="text"],
.annotation-toolbar select {
  padding: 0.4em 0.6em;
  border-radius: 4px;
  border: 1px solid #bbb;
  font-size: 1em;
  width: 100%;
  max-width: 100%;
}

.annotation-toolbar button {
  padding: 0.6em 1em;
  background-color: #0057b7;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1em;
  cursor: pointer;
}

.annotation-toolbar button:disabled {
  background-color: #aaa;
  cursor: not-allowed;
}




.qa-ann.selected {
  outline: 2px dashed #007bff;
  background-color: #eaf2ff;
  box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.1);
  border-radius: 6px;
  transition: all 0.25s ease-in-out;
}

.qa-segment-row {
  display: flex;
  border-bottom: 1px solid #ddd;
  padding: 0.5em 0;
}

body.bg-paper .qa-segment-row {
  border-bottom-color: #cfbea3;
}

.qa-segment-row:last-child {
  border-bottom: none;
}

.qa-ann {
  margin-bottom: 0.7em;
  padding-bottom: 1.8em; /* zwiększamy padding na dole */
  border-bottom: 1px solid #eee;
  position: relative; /* potrzebne, jeśli będziemy używać float */
}

body.bg-paper .qa-ann {
  border-bottom-color: #d8cab1;
}

.qa-ann:last-child {
  border-bottom: none;
}

#qaPairsPanel {
  position: relative;
}

#qaPairsOutput {
  position: relative;
  z-index: 2;
}

.qa-relation-arrows-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 4;
}

.qa-rel-arrow-path {
  fill: none;
  stroke: #8ea1b8;
  color: #8ea1b8;
  stroke-width: 3.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-opacity: 0.96;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  transition:
    stroke 0.14s ease,
    stroke-width 0.14s ease,
    stroke-opacity 0.14s ease,
    filter 0.14s ease;
}

body.bg-paper .qa-rel-arrow-path {
  stroke: #9f8c6a;
  color: #9f8c6a;
}

.qa-rel-arrow-path.is-rel-hovered {
  stroke: #4f7fb8;
  color: #4f7fb8;
  stroke-width: 3.7;
  stroke-opacity: 1;
  filter: drop-shadow(0 1px 2px rgba(79, 127, 184, 0.12));
}

body.bg-paper .qa-rel-arrow-path.is-rel-hovered {
  stroke: #8b7048;
  color: #8b7048;
  filter: drop-shadow(0 1px 2px rgba(139, 112, 72, 0.12));
}

.qa-rel-arrow-path.is-rel-selected {
  stroke: #2563eb;
  color: #2563eb;
  stroke-width: 4.1;
  stroke-opacity: 1;
}

body.bg-paper .qa-rel-arrow-path.is-rel-selected {
  stroke: #7c5b2c;
  color: #7c5b2c;
}

.qa-rel-arrow-hitbox {
  fill: none;
  stroke: transparent;
  stroke-width: 15;
  pointer-events: stroke;
  cursor: pointer;
}

.qa-rel-arrow-label-group {
  pointer-events: auto;
  cursor: pointer;
  opacity: .50;
  transition: opacity .11s ease;
}

.qa-rel-arrow-group.is-rel-emphasized .qa-rel-arrow-label-group,
.qa-rel-arrow-label-group.is-rel-hovered,
.qa-rel-arrow-label-group.is-rel-selected {
  opacity: 1;
}

.qa-rel-arrow-label-bg {
  fill: rgba(255,255,255,0.98);
  stroke: #cbd5e1;
  stroke-width: 1.1;
  transition:
    fill 0.14s ease,
    stroke 0.14s ease;
}

body.bg-paper .qa-rel-arrow-label-bg {
  fill: rgba(251, 243, 228, 0.98);
  stroke: #d3c2a3;
}

.qa-rel-arrow-label {
  font-size: 12.5px;
  font-weight: 700;
  fill: #334155;
  letter-spacing: 0.01em;
  pointer-events: none;
}

.qa-rel-arrow-label-id {
  fill: #475569;
  font-weight: 700;
}

.qa-rel-arrow-label-sep {
  fill: #94a3b8;
  font-weight: 700;
}

.qa-rel-arrow-label-main {
  fill: #334155;
  font-weight: 700;
}

.qa-rel-arrow-label-group.is-rel-hovered .qa-rel-arrow-label-bg {
  fill: #eef4ff;
  stroke: #9bb8e8;
}

body.bg-paper .qa-rel-arrow-label-group.is-rel-hovered .qa-rel-arrow-label-bg {
  fill: #f4ead9;
  stroke: #cdb58a;
}

.qa-rel-arrow-label-group.is-rel-hovered .qa-rel-arrow-label,
.qa-rel-arrow-label-group.is-rel-hovered .qa-rel-arrow-label-id,
.qa-rel-arrow-label-group.is-rel-hovered .qa-rel-arrow-label-main {
  fill: #365d92;
}

body.bg-paper .qa-rel-arrow-label-group.is-rel-hovered .qa-rel-arrow-label,
body.bg-paper .qa-rel-arrow-label-group.is-rel-hovered .qa-rel-arrow-label-id,
body.bg-paper .qa-rel-arrow-label-group.is-rel-hovered .qa-rel-arrow-label-main {
  fill: #7a5d2e;
}

.qa-rel-arrow-label-group.is-rel-selected .qa-rel-arrow-label-bg {
  fill: #dbeafe;
  stroke: #60a5fa;
}

body.bg-paper .qa-rel-arrow-label-group.is-rel-selected .qa-rel-arrow-label-bg {
  fill: #eadcc7;
  stroke: #c7ad7c;
}

.qa-rel-arrow-label-group.is-rel-selected .qa-rel-arrow-label,
.qa-rel-arrow-label-group.is-rel-selected .qa-rel-arrow-label-id,
.qa-rel-arrow-label-group.is-rel-selected .qa-rel-arrow-label-main {
  fill: #1e40af;
}

body.bg-paper .qa-rel-arrow-label-group.is-rel-selected .qa-rel-arrow-label,
body.bg-paper .qa-rel-arrow-label-group.is-rel-selected .qa-rel-arrow-label-id,
body.bg-paper .qa-rel-arrow-label-group.is-rel-selected .qa-rel-arrow-label-main {
  fill: #6d4c1c;
}

.qa-ann-port {
  position: relative;
  display: inline-flex;
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  margin: 0 0.12em 0 0.02em;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid #94a3b8;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.96);
  z-index: 3;
  pointer-events: none;
  vertical-align: middle;
  transform: translateY(1px);
}

body.bg-paper .qa-ann-port {
  background: #fbf5ea;
  box-shadow: 0 0 0 2px rgba(248, 240, 225, 0.98);
}

.qa-ann-port.is-rel-selected {
  border-color: #1d4ed8;
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.98),
    0 0 0 5px rgba(37,99,235,0.18);
}

body.bg-paper .qa-ann-port.is-rel-selected {
  border-color: #7c5b2c;
  box-shadow:
    0 0 0 2px rgba(248, 240, 225, 0.98),
    0 0 0 5px rgba(124,91,44,0.16);
}

.relation-arrows-toggle-wrap {
  display: inline-flex;
  align-items: center;
}

.relation-display-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid #cfe0f5;
  background: #f8fbff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.relation-display-toggle-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #48627d;
  min-height: 40px;
  padding: 0 13px;
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.relation-display-toggle-btn + .relation-display-toggle-btn {
  border-left: 1px solid #d9e6f6;
}

.relation-display-toggle-btn:hover {
  background: #eef6ff;
}

.relation-display-toggle-btn.is-active {
  background: #eaf3ff;
  color: #1f4b7a;
}

.relation-arrows-toggle-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid #cfe0f5;
  background: #f8fbff;
  color: #2c4a6b;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease,
    color 0.15s ease;
}

.relation-arrows-toggle-btn:hover {
  background: #eef6ff;
  border-color: #b8d0ee;
}

.relation-arrows-toggle-btn:active {
  transform: translateY(1px);
}

.relation-arrows-toggle-btn.is-active {
  background: #eaf3ff;
  border-color: #9fc1ea;
  color: #1f4b7a;
}

.qa-ann .relation-chip {
  float: right;
  margin-left: 0.5em;
}

.qa-ann.highlighted {
  box-shadow: 0 0 0 3px #007bff55;
  border-radius: 6px;
}

.relation-label {
  font-size: 0.8em;
  color: #666;
  margin-top: 0.2em;
  margin-left: 0.4em;
  font-style: italic;
}

.relation-chip.active {
  background-color: #e1f0ff;
  border: 2px solid #007bff;
}

.relation-chip {
  background-color: #f0f0f0;
  color: #333;
  padding: 0.3em 0.6em;
  border-radius: 1em;
  font-size: 0.9em;
  font-weight: 500;
  display: inline-block;
  margin-top: 0.2em;
}

/* Plakietka z ID relacji (R1, R2, ...) */
.rel-id-badge{
  display: inline-block;
  font-size: 0.75em;
  line-height: 1.2;
  padding: 0.05em 0.55em;
  margin-right: 0.45em;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  vertical-align: middle;
}

/* Subtelne ID anotacji */
.annotation-tag-row {
  display: flex;
  align-items: center;
  gap: 0.38em;
  flex-wrap: wrap;
  margin-bottom: 0.12em;
}

.annotation-rationale-toggle {
  appearance: none;
  border: 0;
  background: transparent;
  color: #94a3b8;
  padding: 0;
  margin-left: 0.12em;
  font-size: 1.02em;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  transition:
    color 0.15s ease,
    opacity 0.15s ease,
    transform 0.05s ease,
    text-shadow 0.15s ease;
  opacity: 0.72;
}

.annotation-rationale-toggle:hover {
  color: #475569;
  opacity: 1;
}

.annotation-rationale-toggle:active {
  transform: translateY(1px);
}

.annotation-rationale-toggle.has-rationale {
  color: #c58a16;
  opacity: 1;
  text-shadow: 0 0 0.01px #c58a16;
}

.annotation-rationale-toggle.has-rationale:hover {
  color: #a76d08;
}

.ann-id-badge {
  display: inline-block;
  font-size: 0.68em;
  line-height: 1;
  padding: 0;
  margin-right: 0.0em;
  border: 0;
  background: transparent;
  color: #8795a8;
  vertical-align: middle;
  letter-spacing: 0.02em;
  font-weight: 500;
}

.relation-selection-popup {
  position: absolute;
  background: #f9fbff;
  border: 2px solid #007bff;
  padding: 1em;
  border-radius: 10px;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  min-width: 220px;
}

.relation-selection-popup {
  max-width: 260px;
  word-break: break-word;
}

.relation-selection-popup {
  background: #eaf4ff;
  border: 2px solid #007bff;
  padding: 0.5em;
  border-radius: 8px;
  box-shadow: 0px 2px 6px rgba(0,0,0,0.2);
}

.timestamp-input {
  font-size: 0.9em;
  padding: 2px 4px;
  width: 60px;
  border: 1px solid #aaa;
  border-radius: 4px;
}

.timestamp-pill {
  display: inline-block;
  background-color: #e6f4ea;
  color: #065f46;
  font-size: 0.8em;
  border-radius: 12px;
  padding: 2px 8px;
  margin-left: 6px;
  font-weight: 500;
  box-shadow: 0 0 0.5px #aaa;
  white-space: nowrap;
}

.segment-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-top: 0.5em;
  align-items: center;
}

.segment-flags label {
  background-color: #eef3f8;
  padding: 0.4em 0.7em;
  border-radius: 5px;
  border: 1px solid #ccc;
  font-size: 0.9em;
  cursor: pointer;
  user-select: none;
}

.segment-flags input[type="checkbox"] {
  margin-right: 0.3em;
  transform: scale(1.1);
}

.annotation-features {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.85em;
  color: #444;
}

.annotation-features > * {
  white-space: nowrap;
}

.annotation-features {
  font-size: 0.85em;
  color: #444;
  margin-top: 0.3em;
  padding-left: 0.5em;
  border-left: 2px solid #ddd;
}

.logic-structure-sentence {
  margin-top: 0.5em;
  display: flex;
  gap: 0.5em;
  align-items: center;
}

.segment-logic-display {
  font-size: 0.9em;
  color: #555;
  margin-top: 0.3em;
  background: #f4f4f4;
  padding: 0.4em;
  border-radius: 4px;
}

/* === Tag filter dropdown === */
.tag-filter { display:inline-block; position:relative; }
.tag-filter-btn {
  height:32px; padding:0 .75rem; border:1px solid #cbd5e1; border-radius:8px;
  background:#f8fafc; cursor:pointer;
}

.tag-filter-header { display:flex; gap:.5rem; padding:.25rem .25rem .5rem; border-bottom:1px solid #eef2f7; }
.tag-filter-header input { flex:1; height:30px; padding:.25rem .5rem; border:1px solid #cbd5e1; border-radius:6px; }
.tag-filter-groups { max-height:320px; overflow:auto; padding:.5rem .25rem; }
.tag-filter-group { margin-bottom:.5rem; }
.tag-filter-group h4 { margin:.25rem 0 .25rem; font-size:.85rem; color:#475569; font-weight:600; }
.tag-filter-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: .32rem 0;
}

.tag-filter-item {
  display: flex;
  align-items: flex-start;
  gap: .45rem;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
}

.tag-filter-item input {
  margin-top: .15rem;
  flex: 0 0 auto;
}

.tag-filter-item input { margin-right:.35rem; }
.tag-filter-footer { display:flex; justify-content:flex-end; padding:.5rem .25rem 0; border-top:1px solid #eef2f7; }

.relation-form {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  background: #f9fbff; /* jaśniejszy niebieski zamiast żółtego */
  padding: 2em;
  border: 2px solid #0057b7;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 10000;
  width: 700px;
  max-width: 95vw;
  font-size: 1.15em;
  font-family: "Segoe UI", sans-serif;
  transition: all 0.2s ease;
}


.relation-form label {
  display: block;
  margin-top: 0.5em;
}

.relation-form select,
.relation-form button {
  margin-top: 0.3em;
  width: 100%;
}

.relation-form button {
  background-color: #e7f0ff;
  color: #004499;
  text-align: center;
  justify-content: center;
  border: 1px solid #bcd3f2;
  border-radius: 4px;
  padding: 0.3em 0.8em;
  font-size: 0.9em;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  transition: background-color 0.2s ease;
}

.relation-form button:hover {
  background-color: #d4e7ff;
}

.annotate-btn {
  padding: 0.3em 0.6em;
  font-size: 0.9em;
  cursor: pointer;
  background: #007bff;
  border: none;
  border-radius: 4px;
  color: white;
  margin-top: 0.5em;
}

.annotation-menu {
  margin-top: 0.3em;
  display: flex;
  gap: 0.3em;
}

.annotation-tag {
  padding: 0.5em;
  border-radius: 4px;
  font-size: 0.85em;
}

.annotation-tag strong {
  display: block;
  margin-bottom: 0.25em;
}

.annotation-text {
  color: #111;
  font-size: 1.1em;
  line-height: 1.6;
  font-weight: 400;
  padding: 0.2em 0.3em;
  font-family: Palatino, "Palatino Linotype", serif;
}

.collapsed-summary {
  font-size: 1.25em;
  line-height: 1.6;
  font-weight: 400;
  font-family: Palatino, "Palatino Linotype", serif;
}

.annotation-tag.collapsed .collapsed-summary {
  display: inline;
}

.annotation-tag:not(.collapsed) .collapsed-summary {
  display: none;
}

.annotation-tag.collapsed .annotation-details {
  display: none;
}

.toggle-annotation-btn {
  margin-left: 0.5em;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1em;
  padding: 0;
}

.annotation-comment {
  margin-top: 0.3em;
  font-size: 0.9em;
  background-color: #f6f6f6;
  padding: 4px 8px;
  border-left: 3px solid #ccc;
  border-radius: 3px;
}

.comment-editor {
  position: fixed;
  top: 20%;
  left: 30%;
  background: white;
  border: 1px solid #aaa;
  padding: 1em;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
  z-index: 10000;
}

.annotation-interactions {
  margin-top: 0.4em;
  font-size: 0.85em;
  color: #333;
}

.interaction-chip-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  margin-top: 0.2em;
}

.interaction-chip {
  background: #e0f7fa;
  border-radius: 1em;
  padding: 0.4em 1em;
  font-size: 0.95em;
  font-weight: 500;
  border: 1px solid #00acc1;
  color: #004d40;
  white-space: nowrap;
}

.relation-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 1.1em;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.relation-table thead {
  background-color: #f0f4ff;
}

.relation-table th {
  text-align: left;
  padding: 10px;
  font-weight: 600;
  font-size: 0.95em;
  color: #1a1a1a;
  border-bottom: 1px solid #ccc;
}

.relation-table td {
  padding: 10px;
  vertical-align: top;
  border-top: 1px solid #eee;
}

.relation-table tr:hover {
  background-color: #f9fbff;
}

.relation-table td:nth-child(1) {
  text-align: center;
  font-weight: bold;
  color: #555;
}

.relation-table td:nth-child(2),
.relation-table td:nth-child(3),
 {
  white-space: normal;
  word-break: break-word;
}


.relation-table td:nth-child(5) {
  font-weight: 500;
  color: #333;
  font-size: 0.9em;
}

.relation-table td:last-child {
  display: flex;
  gap: 0.4em;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
}

.relation-table button {
  padding: 0.35em 0.6em;
  border-radius: 4px;
  border: none;
  font-size: 0.85em;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.relation-table button:nth-child(1) {
  background-color: #6c757d;
  color: white;
}
.relation-table button:nth-child(2) {
  background-color: #007bff;
  color: white;
}
.relation-table button:nth-child(3) {
  background-color: #dc3545;
  color: white;
}

.relation-table button:hover {
  opacity: 0.85;
}

.relation-table td:last-child {
  padding-left: 12px;

}

.relation-table button {
  min-width: 80px;
}

.relation-table td:nth-child(4) {
}

.relation-table td:nth-child(1) {
  text-align: center;
  font-weight: bold;
  color: #555;
}

.relation-table td:nth-child(2),
.relation-table td:nth-child(3),
 {
  white-space: normal;
  word-break: break-word;
}

.relation-table td:nth-child(5) {
  font-size: 1.20em !important;
  font-family: Palatino, "Palatino Linotype", serif;
  font-weight: 500;
  color: #333;
  line-height: 1.5;
}

.gold-controls {
  margin-top: 1em;
  padding: 0.5em;
  background: #f8f8f8;
  border-left: 4px solid #ccc;
  border-radius: 4px;
  font-size: 0.9em;
}

.gold-controls input {
  margin-right: 6px;
  padding: 2px 4px;
}

.gold-controls button {
  margin-right: 6px;
}

.gold-annotations-display ul {
  margin-top: 0.3em;
  margin-bottom: 0.5em;
  padding-left: 1.2em;
}

.gold-annotations-display li {
  margin-bottom: 0.3em;
}

.gold-collapsible-content.collapsed {
  display: none;
}

.collapsed-gold-preview {
  font-style: italic;
  color: #555;
  margin-left: 0.5em;
}

.gold-block-container {
  margin-top: 1em;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.5em;
  background: #fafafa;
}

.toggle-full-gold-btn {
  font-weight: bold;
  margin-bottom: 0.5em;
  background: #f0f0f0;
  border: none;
  cursor: pointer;
  padding: 0.3em 0.6em;
  border-radius: 4px;
}

.sentence-features-wrapper {
  background: #f3f3f3;
  padding: 0.5em;
  margin-top: 0.5em;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.bool-flags-container {
  margin-top: 0.5em;
}

.bool-flags-container label {
  margin-right: 1em;
  font-weight: 500;
}

.marker-wrapper {
  margin-top: 0.5em;
  padding: 0.3em;
}

.marker-list {
  margin-top: 0.3em;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
}

.marker-chip {
  background: #e0f0ff;
  border-radius: 1em;
  padding: 0.3em 0.8em;
  font-size: 0.9em;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  border: 1px solid #ccc;
}

.marker-chip button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1em;
}

.graph-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.graph-popup-content {
  background: white;
  padding: 1em;
  border-radius: 8px;
  width: 80%;
  height: 80%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  position: relative;
  display: flex;
  flex-direction: column;
}

.graph-popup-close {
  position: absolute;
  top: 0.5em;
  right: 0.8em;
  background: none;
  border: none;
  font-size: 1.4em;
  cursor: pointer;
  color: #333;
  z-index: 10;
}

.extended-metadata {
  position: fixed;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 1.5em;
  border: 1px solid #ccc;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
  z-index: 2000;
  max-width: 90vw;
  width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 8px;
  font-size: 1em;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.extended-metadata label {
  display: block;
  margin-bottom: 0.8em;
  font-size: 1em;
}

.extended-metadata .checkbox-wrapper {
  margin-bottom: 0.5em;
}

.segment-annotations {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  margin-bottom: 0.5em;
}

/* placeholder tylko na czas prac – można usunąć gdy włożysz paski */
.qa-toolbar-placeholder {
  font-size: .95rem;
  color: #475569;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: .6rem .75rem;
}

#annotationTypeResults {
  margin-top: 1.5em;
  padding: 1em;
  background-color: #f9f9f9;
  border-left: 4px solid #0073aa;
  border-radius: 6px;
}

#annotationTypeResults h3 {
  margin-top: 0;
  font-size: 1.2em;
  color: #0073aa;
}

/* FORMULARZ CECH Z ZDANIA W ZAKŁADCE ANOTACJA */

.features-panel {
  background-color: #f5f7fa;
  border: 1px solid #ccd6e0;
  border-radius: 8px;
  padding: 1em;
  margin-top: 0.5em;
  font-family: sans-serif;
  font-size: 0.95em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.features-panel label {
  display: block;
  margin: 0.5em 0 0.2em;
  font-weight: 500;
  color: #003366;
}

.features-panel input[type="text"],
.features-panel textarea {
  width: 20%;
  padding: 0.3em;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95em;
  box-sizing: border-box;
}

.features-panel textarea {
  resize: vertical;
}

.features-panel input[type="checkbox"],
.features-panel input[type="radio"] {
  margin-right: 0.3em;
}

.features-panel button {
  margin: 1em auto 0 auto; /* góra: 1em, poziomo: auto (wyśrodkowanie), dół: 0 */
  padding: 0.4em 1.2em;
  background-color: #337ab7;
  color: white;
  border: none;
  border-radius: 4px;
  font-weight: bold;
  display: block;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}


.features-panel button:hover {
  background-color: #286090;
}

.segment-id-tag {
  background-color: #eaf4ff;
  border: 1px solid #b3d7ff;
  border-radius: 12px;
  padding: 0.2em 0.6em;
  font-size: 0.85em;
  color: #003366;
  flex-shrink: 0;
  line-height: 1.4; /* dodane */
}

.segment-text {
  flex: 1;
  font-weight: normal;
  line-height: 1.4; /* dodane */
}

.segment-speaker {
  font-weight: bold !important;
  margin-right: 0.3em;
}

.segment {
  position: relative;
  z-index: 0;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 1em;
  margin-bottom: 1em;
  background: #fff;
}

.segment.selected {
  border-color: #007bff;
  background: #eaf4ff;
}

.segment-meta {
  font-size: 0.9em;
  color: #555;
  margin-bottom: 0.5em;
}

.segment-text {
  margin-bottom: 0.5em;
  font-size: 1em;
  font-weight: normal;
}

.relation-structure-block::before {
  content: attr(id);
  display: block;
  font-size: 1.40em;
  color: #888;
  margin-bottom: 0.25em;
}

.relation-structure-block {
  background: #fdfdfd;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 1em;
  margin-bottom: 1.2em;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.05);
}

.relation-structure-block ul {
  padding-left: 1.2em;
  margin: 0.5em 0;
}

.relation-structure-block {
  max-width: 100%;
  overflow-x: auto;
}

/* FORMULARZ CECH Z ZDANIA W ZAKŁADCE ANOTACJA */

.note-icon {
  position: absolute;
  right: 10px;
  bottom: 6px;
  font-size: 1.2em;
  cursor: pointer;
  opacity: 0.6;
}

.note-icon .custom-tooltip {
  position: absolute;;
  top: 50%;
  color: #111;
  left: -30px;
  transform: translate(-100%, -50%);  /* przesuwa cały dymek w lewo i centruje w pionie */
  background: #f9f9f9;
  border: 1px solid #ccc;
  padding: 0.4em 0.7em;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  font-size: 0.85em;
  white-space: pre-wrap;
  white-space: normal;         /* <-- pozwala na zawijanie */
  max-width: 600px;
  min-width: 350px;
  opacity: 0;
  transition: opacity 0.15s ease-in-out;
  pointer-events: none;
}

.note-icon:hover .custom-tooltip {
  opacity: 1;
}

.clickable-segment.selected {
  background-color: #eaf4ff;
  border: 1px;
  border-radius: 6px;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.hidden {
  display: none !important;
}

.relation-select-button {
  background-color: #e0efff;
  border: 1px solid #99c2ff;
  color: #004080;
  padding: 0.4em 0.8em;
  font-size: 0.95em;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s ease;
  width: 100%;
  text-align: center;
}

.relation-select-button:hover {
  background-color: #cce5ff;
}

.remove-rel {
  color: #888;
  font-size: 0.9em;
  margin-left: 0.4em;
  cursor: pointer;
}
.remove-rel:hover {
  color: red;
}

.segment-id-tag {
  display: inline-block;
  background-color: #e6f0ff;
  color: #003366;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.9em;
  margin-right: -0.4em;
  margin-bottom: 1em;
  border: 1px solid #ccc;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.segment-id-tag:hover {
  background-color: #cce0ff;
}


.flags {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.flag-chip {
  background-color: #f0f0f0;
  color: #333;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.75em;
  font-weight: 500;
}

.sentence-features-toggle-btn {
  font-size: 0.85em;             /* mniejsze emoji, dopasowane do tekstu */
  vertical-align: text-top;      /* lepsze wyrównanie względem tekstu */
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-left: 0.4em;
  color: #666;
  line-height: 1;
}

.sentence-features-toggle-btn:hover {
  background-color: #d4e7ff;
}

.argumentative-flag {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 0; /* niżej niż panel formularza */
  background: #d8f1f0;
  color: #007b8f;
  font-size: 0.75em;
  padding: 0.2em 0.6em;
  border-radius: 1em;
  border: 1px solid #b2ebf2;
  pointer-events: none; /* nie koliduje z kliknięciami */
}

.argumentative-flag.true {
  background-color: #e0f5e9;  /* pastelowa zieleń tła */
  color: #2e7d32;             /* spokojny, ciemniejszy zielony */
  border-color: #b2dfdb;      /* lekki zielono-miętowy odcień */
}


.argumentative-flag.false {
  background-color: #f0f0f0;
  color: #555;
}

.argumentative-flag.true::before {
  content: "💡 ";
}

.argumentative-flag.false::before {
  content: "✖️ ";
}

.radio-toggle input[type="radio"] {
  display: none;
}

.radio-toggle:has(input[type="radio"]:checked) {
  background-color: #337ab7;
  color: white;
  border-color: #337ab7;
}


.radio-toggle input[type="radio"]:checked + span {
  font-weight: bold;
}

.radio-toggle:has(input[type="radio"]:checked) {
  background-color: #337ab7;
  color: white;
  border-color: #337ab7;
}

.relation-details-box {
  background: #eef6ff;
  font-family: Palatino, "Palatino Linotype", serif;
  border: 1px solid #b3d1f2;
  border-left: 4px solid #007bff;
  padding: 0.75em 1em;
  margin-top: 0.5em;
  border-radius: 6px;
  font-size: 0.92em;
  color: #1a1a1a;
  transition: all 0.3s ease;
}

.relation-details-entry {
  margin-bottom: 0.4em;
}

.relation-details-box.hidden {
  display: none;
}

.relation-details-box div {
  margin-bottom: 0.3em;
}

.relation-details-text {
  font-family: Palatino, "Palatino Linotype", serif;
  font-size: 1.05em;
  margin-bottom: 1.5em !important; /* <-- tutaj zwiększ odstęp */
}

.relation-details-segment {
  display: flex;
  align-items: flex-start; /* <- to przywraca właściwe wyrównanie */
  gap: 1.1em;
  font-family: Arial, sans-serif;
  font-size: 0.95em;
  color: #444;
  line-height: 1.4;
}

.logic-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1em;
  margin-bottom: 1em;
}

.logic-row label {
  white-space: nowrap;
}

.logic-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.3em;
}

.radio-label {
  margin-right: 1em;
  display: flex;
  align-items: center;
  gap: 0.3em;
}

.radio-toggle-group {
  display: flex;
  gap: 1em;
  margin-top: 0.3em;
}

.radio-toggle {
  position: relative;
  display: inline-block;
  padding: 0.4em 1em;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  background-color: #f9f9f9;
  transition: all 0.2s ease-in-out;
  user-select: none;
}

.filtered-annotation-block {
  padding: 0.5em 1em;
  margin-bottom: 1em;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.03);
}

.filtered-annotation-block p {
  margin: 0.4em 0;
  font-size: 0.95em;
}

.filtered-annotation-block strong {
  color: #333;
}

.logic-structure-input {
  width: 40ch;
  max-width: 100%;
  padding: 0.3em 0.6em;
  font-size: 0.95em;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.logic-flags-display {
  font-size: 0.85em;
  color: #444;
  margin: 0.25em 0 0.5em;
  padding: 2px 6px;
  background: #f7f7f7;
  border-left: 3px solid #ccc;
}

:root { --annotation-footer-h: 88px; } /* wysokość „rezerwowa” na dół */

/* Stały footer tylko dla zakładki QA */
#annotation-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1300;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -6px 16px rgba(0,0,0,.06);
  padding: .5rem .75rem;
  min-height: var(--annotation-footer-h);
}

/* W środku używamy Twojego istniejącego stylu paska, ale bez ramek/tła */
#annotation-footer .annotation-toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: .6rem;
  align-items: center;
  background: none;
  border: 0;
  border-radius: 0;
  margin: 0;
  padding: 0;
  box-shadow: none;
}

/* Żeby treść QA nie chowała się pod stopką – rezerwujemy miejsce na dole */
.tab-content[data-tab="qa"].active {
  padding-bottom: var(--annotation-footer-h);
}

/* Lepsze zachowanie na małych szerokościach */
@media (max-width: 900px) {
  #annotation-footer .annotation-toolbar { gap: .5rem; }
  #annotation-footer { min-height: 104px; } /* trochę więcej miejsca na zawijanie */
}

.data-import-tools {
  margin-top: 0.5em;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  align-items: center;
}

.annotation-footer {
  padding: 0.75em 1em;
  border-top: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}
.annotation-footer .data-import-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  align-items: center;
}

/* === Stopka QA: kompakt i wyrównanie === */

/* ======= Annotation Footer (elegancki pasek) ======= */
.af{
  --af-h: 72px;
  position: sticky;           /* trzyma się dołu widoku */
  bottom: 0;
  z-index: 1000;
  background: color-mix(in oklab, var(--panel) 92%, white 8%);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 22px rgba(0,0,0,.06);
  backdrop-filter: saturate(120%) blur(6px);
}
.af__inner{
  height: var(--af-h);
  display: grid;
  grid-template-columns: 1fr 2fr 1fr; /* lewo / środek / prawo */
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
}

/* Zabezpieczenie, żeby treść nie wpadała pod stopkę */
/*.tab-content[data-tab="qa"]{
  padding-bottom: calc(var(--af-h) + 14px);
}

/* Kolumny */
.af__left, .af__center, .af__right{
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.af__left{ justify-content: flex-start; }
.af__center{
  justify-content: center;
  flex-wrap: wrap;
}
.af__right{ justify-content: flex-end; }

.af__group{ display: flex; align-items: center; gap: 8px; }
.af__grow{ flex: 1; min-width: 180px; }
.af__label{ color: var(--muted); font-weight: 600; }

/* Pola i selecty spójne z resztą */
.af select,
.af input[type="text"]{
  height: 36px;
  padding: 0 .75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  width: 100%;
}

/* Przyciski – korzystają z global .toolbar-button */
.toolbar-button.btn-primary{
  background: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 70%, white 30%);
  color: #fff;
}
.toolbar-button.btn-primary:hover{
  filter: brightness(1.05);
}

/* File inputs – ukryte, klikamy w label */
.af__file{ display: none; }

/* Warstwy */
.layer-tabs{
  display: flex; gap: .4rem; flex-wrap: wrap;
}
.layer-tab{
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: .35rem .7rem;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: border-color .15s ease, background .15s ease;
}
.layer-tab:hover{ border-color:#cbd5e1; background:#f8fafc; }
.layer-tab.active{ color: var(--accent); border-color:#bfd3ff; }

/* Tag filter – tylko kosmetyka przycisku, resztę masz już w CSS-ie */
#qaTagFilter{ position: relative; }

/* Responsywność – zwijamy w jedną kolumnę */
@media (max-width: 1100px){
  .af__inner{ grid-template-columns: 1fr; height: auto; padding: 12px 14px; gap: 10px; }
  .af__left, .af__center, .af__right{ justify-content: stretch; flex-wrap: wrap; }
  .tab-content[data-tab="qa"]{ padding-bottom: 18px; }
}

/* Poprawka: filtr etykiet otwiera się NAD przyciskiem */
#annotation-footer { overflow: visible; }            /* nie obcinaj popovera */
#qaTagFilter { position: relative; overflow: visible; }

#tagFilterMenu{
  position: absolute;
  top: auto;
  bottom: calc(100% + 8px);
  left: auto;
  right: 0;
  z-index: 2001;

  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: 820px;
  max-width: calc(100vw - 24px);
  min-width: 320px;
  max-height: 60vh;
  overflow: auto;
  padding: 10px;
  box-sizing: border-box;
}

#tagFilterMenu[hidden]{ display: none !important; }

/* Mały „dzióbek” wskazujący przycisk */
#tagFilterMenu::after{
  content: "";
  position: absolute;
  bottom: -8px;
  right: 16px;
  border: 8px solid transparent;
  border-top-color: #fff;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.06));
}

/* Gdy ekran niski – ogranicz wysokość, by zawsze się mieściło */
@media (max-height: 620px){
  #tagFilterMenu{ max-height: calc(100vh - 140px); }
}

.annotation-group.type-select  {
  flex: 0 0 320px;
  max-width: 320px;
  min-width: 320px;
}

.annotation-group.type-select #typeSelect,
.annotation-group.type-select .select2-container {
  width: 100% !important;
  min-width: 0 !important;
}

.annotation-group.type-select .select2-selection--single {
  width: 100% !important;
  box-sizing: border-box;
}

.annotation-group.custom-tag  {
  flex: 0 0 180px;
  max-width: 200px;
}

.annotation-group.flex-grow   {
  flex: 1 1 auto;
  min-width: 300px;
}

.annotation-group.add-button  {
  flex: 0 0 60px;
  max-width: 120px;
}


/* Annotation UX 3.3 — compact edit state in the annotation footer */
.annotation-edit-mode-pill {
  flex: 0 1 310px;
  min-width: 0;
  max-width: 340px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.32rem 0.4rem 0.32rem 0.72rem;
  border: 1px solid #9fc1ea;
  border-radius: 12px;
  background: #eef6ff;
  color: #294f77;
  box-sizing: border-box;
}

.annotation-edit-mode-pill[hidden] {
  display: none !important;
}

.annotation-edit-mode-label {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  min-width: 0;
  font-size: 0.86rem;
  line-height: 1.15;
  white-space: nowrap;
}

#annotationEditModeIdentity {
  min-width: 0;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #183c63;
}

#annotation-footer .annotation-edit-cancel-btn,
#annotation-footer .annotation-toolbar .annotation-edit-cancel-btn {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 0.65rem;
  border: 1px solid #bed2ea;
  border-radius: 9px;
  background: #fff;
  color: #355a7f;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

#annotation-footer .annotation-edit-cancel-btn:hover,
#annotation-footer .annotation-toolbar .annotation-edit-cancel-btn:hover {
  background: #f7fbff;
  border-color: #8eb5df;
}

#annotation-footer.is-editing-annotation #addAnnotationToSegmentBtn {
  min-width: 138px;
  background: #1769c2;
  color: #ffffff;
  border-color: #1769c2;
  font-weight: 700;
  box-shadow: 0 2px 7px rgba(23, 105, 194, 0.22);
}

#annotation-footer.is-editing-annotation #addAnnotationToSegmentBtn:hover:not(:disabled) {
  background: #1257a4;
  color: #ffffff;
  border-color: #1257a4;
  box-shadow: 0 3px 9px rgba(18, 87, 164, 0.26);
}

body.bg-paper .annotation-edit-mode-pill {
  border-color: #d8bd91;
  background: #f7efdf;
  color: #6d512d;
}

body.bg-paper #annotationEditModeIdentity {
  color: #533b20;
}

@media (max-width: 1180px) {
  .annotation-edit-mode-pill {
    flex-basis: 220px;
    max-width: 240px;
  }

  #annotationEditModeIdentity {
    max-width: 110px;
  }
}


/* Styl lekki, zgodny z tagmemaybe.org */
input[type="file"].file-input {
  padding: 0.3em 0.8em;
  font-size: 0.95em;
  color: #333;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Styl przycisku w input[type=file] */
input[type="file"]::file-selector-button {
  background-color: #f5f7fb;
  color: #333;
  border: 1px solid #ccc;
  padding: 0.3em 0.8em;
  margin-right: 0.6em;
  border-radius: 6px;
  font-size: 0.95em;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

input[type="file"].file-input {
  max-width: 250px;
  width: 100%;
}



/* Hover: delikatna zmiana tła i ramki */
input[type="file"]::file-selector-button:hover {
  background-color: #e8eef9;
  border-color: #999;
}

#addAnnotationToSegmentBtn {
  height: 36px;
  padding: 0 1em;
  font-size: 1em;
  font-weight: 500;
  background-color: #f4f4f4;
  color: #4b5563;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em; /* odstęp między ikoną a tekstem */
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

#addAnnotationToSegmentBtn:hover:not(:disabled) {
  background-color: #d4dafe;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

#addAnnotationToSegmentBtn:disabled {
  background-color: #f0f0f0;
  color: #aaa;
  border: 1px solid #ddd;
  cursor: not-allowed;
  box-shadow: none;
}

#addAnnotationToSegmentBtn {
  font-size: 1em;
  line-height: 1;
}

/* 🟦 Styl pola Select2 */
.select2-container--default .select2-selection--single {
  height: 36px;
  padding: 6px 12px;
  border: 1px solid #bbb;
  border-radius: 8px;
  background-color: #fff;
  font-size: 1em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
}

/* szerokość Select2 kontrolujemy lokalnie, nie globalnie */

/* 🔽 Styl ikonki rozwijania */
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 100%;
  right: 10px;
}

/* ✏️ Styl tekstu wybranego */
.select2-container--default .select2-selection--single .select2-selection__rendered {
  padding-left: 0;
  font-size: 1em;
  color: #222;
}

/* 🔍 Styl listy rozwijanej */
.select2-container--default .select2-results > .select2-results__options {
  font-size: 0.95em;
}

/* 💡 Hover i zaznaczenie */
.select2-results__option--highlighted {
  background-color: #dbeafe !important;
  color: #111 !important;
}

.select2-results__option--selected {
  background-color: #bfdbfe !important;
  color: #111 !important;
}

/* Nadpisz selektora z większą siłą */
.annotation-toolbar .select2-container--default .select2-selection--single {
  height: 36px !important;
  padding: 6px 12px !important;
  border: 1px solid #bbb !important;
  border-radius: 8px !important;
  background-color: #fff !important;
  font-size: 1em !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
  display: flex !important;
  align-items: center !important;
}

.annotation-toolbar .select2-selection__rendered {
  font-size: 1em !important;
  color: #222 !important;
  padding-left: 0 !important;
}

.annotation-toolbar .select2-selection__arrow {
  height: 100% !important;
  right: 10px !important;
}

.btn-export-json {
  background: linear-gradient(to right, #0057b7, #007bff);
  color: white;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  padding: 0.6em 1.2em;
  font-size: 1em;
  box-shadow: 0 4px 12px rgba(0, 87, 183, 0.3);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.btn-export-json:hover {
  background: linear-gradient(to right, #004a9f, #0066e0);
  box-shadow: 0 6px 16px rgba(0, 87, 183, 0.45);
  cursor: pointer;
}

.copy-segment-button button {
  font-size: 1.2em;
  padding: 0.4em 0.7em;
  background: #e0f2fe;           /* jasny błękit zamiast szarości */
  border: 1px solid #38bdf8;     /* niebieska ramka */
  border-radius: 8px;
  color: #0369a1;                /* ikona/tekst też niebieski */
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.copy-segment-button button:hover {
  background: #bae6fd;           /* mocniejszy błękit przy hoverze */
  transform: translateY(-1px);   /* lekkie uniesienie */
  box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* delikatny cień */
}

.copy-segment-button button:active {
  transform: translateY(0);      /* wrażenie „kliknięcia” */
  background: #7dd3fc;
}

/* Select2: dropdown zawsze ponad stopką i z lekkim odstępem */
.select2-container .select2-dropdown{
  z-index: 4000 !important;          /* #annotation-footer ma ~1300 */
}
.select2-container--open.select2-container--below .select2-dropdown{
  margin-top: 6px;                   /* odstęp od pola */
}
.select2-container--open.select2-container--above .select2-dropdown{
  margin-bottom: 6px;                /* gdy otworzy się w górę */
}

/* Pozwól przeciągać róg listy Select2 */
.select2-container .select2-dropdown{
  resize: both;                /* łapka w prawym-dolnym rogu */
  overflow: auto;              /* pokaż scroll, gdy trzeba */
  width: 320px;
  min-width: 320px;
  min-height: 160px;
  max-width: min(90vw, 720px);
  max-height: 70vh;
  box-sizing: border-box;
}

/* Domyślnie Select2 ogranicza wysokość opcji – zdejmujemy limit */
.select2-results,
.select2-results > .select2-results__options{
  max-height: none !important;
}

/* Stylowanie listy Select2 */
.select2-container .select2-dropdown {
  border-radius: 8px;
  border: 1px solid #ddd;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 4px 0;
  font-size: 14px;
}

/* Nagłówki grup (np. "Speech Acts", "Argument Mining") */
.select2-results__group {
  font-weight: 600;
  font-size: 13px;
  color: #444;
  background: #f7f7f9;
  padding: 6px 10px;
  margin-top: 4px;
  border-radius: 4px;
}

/* Opcje */
.select2-results__option {
  padding: 6px 12px;
  border-radius: 4px;
  margin: 2px 4px;
}


/* 🌳 Ikona drzewka w rogu segmentu (obok 📎) */
.tree-icon {
  position: absolute;
  right: 36px;              /* 📎 ma right:10px – ustawiamy obok */
  bottom: 6px;
  font-size: 1.2em;
  cursor: pointer;
  opacity: 0.65;
}
.tree-icon:hover { opacity: 0.95; }


/* Stopka modala */
.hierarchy-actions {
  display: flex; justify-content: flex-end; gap: .5em; margin-top: .8em;
}
.hierarchy-actions .btn {
  border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; padding: .5em .9em; cursor: pointer;
}
.hierarchy-actions .btn.primary { background: #2563eb; color: white; border-color: #2563eb; }
.hierarchy-actions .btn.primary:hover { filter: brightness(1.05); }

.hierarchy-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 40px 1fr; /* kolumna na strzałki + reszta */
}

.hierarchy-item {
  display: contents; /* pozwala gridowi używać dzieci jako wierszy */
}

.hierarchy-item .order-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2em;
}

.hierarchy-item .content {
  display: flex;
  align-items: center;
  gap: .5em;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: .3em .5em;
  margin-bottom: .35em;
  background: #f8fafc;
}

/* 🌳 Hierarchia tagów – zawijanie długich tytułów, bez zmiany układu */
.hierarchy-item .title{
  flex: 1 1 auto;
  min-width: 0;              /* kluczowe dla zawijania w flex w Chrome */
  white-space: normal;       /* pozwól zawijać */
  overflow-wrap: anywhere;   /* nowoczesny wrap */
  word-break: break-word;    /* fallback */
  text-overflow: clip;       /* bez wielokropka */
}

.hierarchy-item .lvl   { width: 48px; text-align: right; color: #64748b; font-size: .85em; }
.hierarchy-item .indent-controls { display: flex; gap: .3em; margin-left: .5em; }

.content[data-level="0"] { margin-left: 0; }
.content[data-level="1"] { margin-left: 24px; }
.content[data-level="2"] { margin-left: 48px; }
.content[data-level="3"] { margin-left: 72px; }

/* === Wizualizacja hierarchii w QA: strzałki przy dzieciach === */
.qa-ann[data-id] {
  position: relative;
}

.qa-ann[data-id][style*="margin-left"]::before {
  content: "↳";
  position: absolute;
  left: -18px;       /* odległość od treści */
  top: 0.25em;       /* pionowe wyrównanie */
  font-size: 1.1em;
  color: #64748b;    /* neutralny szary */
  pointer-events: none;
}



.toolbar-button.btn-primary{
  background: #2563eb; color:#fff; border: 1px solid #1d4ed8;
}
.toolbar-button.btn-primary:hover{ filter: brightness(1.05); }

/* === Tryb super-anotacji === */
.gold-mode-btn {
  background: #fff8db;
  border: 1px solid #facc15;
  color: #7c6300;
  font-weight: 600;
  border-radius: 10px;
  transition: all .2s ease;
}
.gold-mode-btn:hover {
  background: #fef3c7;
}
.gold-mode-btn.active {
  background: #fde68a;
  border-color: #eab308;
  color: #633c00;
}

.segment-text {
  margin-top: 0.2em;
}

.segment-translations {
  margin-top: 0.5em;
  padding-left: 0.6em;
  border-left: 2px solid #e5e7eb;
  color: #4b5563;
  font-size: 0.95em;
}

.segment-translation {
  margin-top: 0.25em;
  display: flex;
  gap: 0.5em;
  align-items: flex-start;
}

.lang-pill {
  display: inline-block;
  padding: 0.05em 0.45em;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  font-size: 0.75em;
  line-height: 1.4;
  color: #374151;
  background: #f9fafb;
  flex: 0 0 auto;
}

.translation-text {
  flex: 1 1 auto;
}

.translations-toggle-wrap {
  margin-right: 0.75em;
}

.translations-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: 0.9em;
  color: #374151;
  user-select: none;
}

/* ===============================
   TRANSLATIONS VISIBILITY
================================ */

.hide-translations .segment-translation {
  display: none;
}

/* ─── Search (Stats) ───────────────────────────── */
.search-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem .8rem;
  align-items: center;
  margin: .8rem 0 1rem;
}

.search-controls label {
  font-weight: 600;
  color: #374151;
  margin-right: .2rem;
}

.search-controls select {
  min-width: 160px;
  padding: .45rem .55rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: white;
}

.search-results .search-result {
  background: #fdfdfd;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: .85rem 1rem;
  margin-bottom: .8rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.search-result .search-meta {
  font-size: .95rem;
  color: #111827;
  margin-bottom: .35rem;
}

.search-result .search-text {
  color: #374151;
  margin: .25rem 0 .35rem;
}

.search-result .search-ann {
  color: #6b7280;
  font-size: .92rem;
}

.search-result .search-rel {
  color: #374151;
  margin: .25rem 0;
}

/* Manage Tag modal */
#manageTagModal textarea {
  resize: vertical;
}

/* Manage Tag modal – dopasowanie szerokości (korzysta ze stylu .config-content) */
.manage-tag-content{
  width: min(820px, 94vw);
}

/* ===============================
   TAG I18N + ANN TEXT I18N
================================ */

.tag-i18n-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-left: 0.45em;
  padding: 0.22em 0.6em;
  border-radius: 999px;
  border: 1px solid #bcd3f2;
  background: #eef5ff;
  color: #355070;
  font-size: 0.8em;
  line-height: 1.3;
  vertical-align: middle;
}

.tag-i18n-lang {
  display: inline-block;
  padding: 0.02em 0.4em;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 0.78em;
  font-weight: 600;
}

.annotation-text-i18n {
  margin-top: 0.45em;
  display: flex;
  gap: 0.5em;
  align-items: flex-start;
  padding-left: 0.2em;
  color: #4b5563;
  font-size: 0.95em;
}

.hierarchy-main-text {
  margin-left: 0.25em;
}

.relation-details-type .tag-i18n-chip {
  margin-left: 0.45em;
}

.rel-arrow {
  font-weight: 600;
  margin-left: 4px;
  margin-right: 0.18em;
}

.rel-arrow-out {
  color: #2e7d32;   /* zielony */
}

.rel-arrow-in {
  color: #1565c0;   /* niebieski */
}

.rel-peer-id {
  display: inline-block;
  font-size: 0.78em;
  line-height: 1;
  color: #8795a8;
  font-weight: 600;
  letter-spacing: 0.01em;
  vertical-align: middle;
}

.show-rel-neighborhood {
  display: inline-block;
  line-height: 1;
}

.show-rel-neighborhood:hover {
  transform: scale(1.08);
}

/* ===============================
   KOMENTARZ EKSPERCKI SEGMENTU
================================ */

.expert-fields {
  margin-top: 0.9em;
  padding-top: 0.8em;
  border-top: 1px solid #dbe3ef;
}

.expert-fields-header {
  font-weight: 700;
  color: #234;
  margin-bottom: 0.4em;
}

.difficulty-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  margin-top: 0.35em;
}

.difficulty-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.45em 0.8em;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease-in-out;
}

.difficulty-chip input[type="radio"] {
  display: none;
}

.difficulty-chip:has(input[type="radio"]:checked) {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #0f3b78;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.difficulty-clear-btn {
  margin-top: 0.6em;
  padding: 0.35em 0.75em;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #475569;
  cursor: pointer;
}

.difficulty-clear-btn:hover {
  background: #f8fafc;
}

/* 📝 Ikona notatki eksperckiej */
.expert-note-icon {
  position: absolute;
  right: 62px;   /* przed 🌳 i 📎 */
  bottom: 6px;
  font-size: 1.18em;
  cursor: pointer;
  opacity: 0.72;
  z-index: 2;
}

.expert-note-icon:hover {
  opacity: 1;
}

/* 🧾 Ikona uzasadnienia anotacji */
.expert-rationale-icon {
  position: absolute;
  right: 88px;   /* na lewo od 📝 */
  bottom: 6px;
  font-size: 1.18em;
  cursor: default;
  opacity: 0.82;
  z-index: 2;
}

/* 🙂🧐😵 Ikona trudności */
.expert-difficulty-icon {
  position: absolute;
  right: 114px;   /* na lewo od 🧾 */
  bottom: 6px;
  font-size: 1.18em;
  cursor: default;
  opacity: 0.82;
  z-index: 2;
}

/* Modal komentarza eksperckiego */
.expert-comment-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 16000;
  padding: 24px;
}

.expert-comment-modal.open {
  display: flex;
}

.expert-comment-modal__dialog {
  width: min(2300px, 99vw);
  max-height: min(99vh, 1200px);
  overflow: hidden;
  background: #fff;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.22);
  display: flex;
  flex-direction: column;
}

.expert-comment-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid #e5edf7;
  background: #f8fbff;
}

.expert-comment-modal__title {
  font-size: 1.06em;
  font-weight: 700;
  color: #1f3552;
}

.expert-comment-modal__meta {
  margin-top: 0.2em;
  color: #64748b;
  font-size: 0.92em;
}

.expert-comment-modal__close {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #334155;
  border-radius: 10px;
  padding: 0.2em 0.65em;
  font-size: 1.2em;
  cursor: pointer;
  line-height: 1;
}

.expert-comment-modal__close:hover {
  background: #f8fafc;
}

.expert-comment-modal__body {
  padding: 18px;
  overflow-y: auto;
  font-size: 0.98em;
  line-height: 1.55;
  color: #111827;
}

.expert-comment-row + .expert-comment-row {
  margin-top: 1.15em;
}

.expert-comment-label {
  font-weight: 700;
  color: #334155;
  margin-bottom: 0.45em;
}

.expert-comment-lang-grid {
  display: grid;
  gap: 0.7em;
}

.expert-comment-lang-card {
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  padding: 0.8em 0.95em;
  background: #ffffff;
}

.expert-comment-lang-card--pl {
  background: #f8fbff;
}

.expert-comment-lang-card--en {
  background: #fbfcfe;
}

.expert-comment-lang-head {
  display: flex;
  align-items: center;
  gap: 0.45em;
  margin-bottom: 0.45em;
}

.expert-comment-value {
  color: #111827;
  white-space: pre-wrap;
  line-height: 1.6;
}

.expert-comment-empty {
  color: #64748b;
  font-style: italic;
}

@media (min-width: 860px) {
  .expert-comment-lang-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Kontekst segmentu w modalu komentarza eksperckiego */
.expert-context-box {
  margin-bottom: 0.7em;
  padding: 0.8em 1em 0.75em;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #f8fbff;
}

.expert-context-box--compact {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
}

.expert-context-headline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35em;
  font-size: 1.02em;
  line-height: 1.2;
  margin-bottom: 0.08em;
}

.expert-context-segid {
  font-weight: 700;
  color: #1f3552;
}

.expert-context-speaker {
  font-weight: 600;
  color: #334155;
}

.expert-context-text {
  white-space: pre-wrap;
  line-height: 1.32;
  margin: 0;
}

.expert-context-text--compact {
  font-size: 1.01em;
  color: #111827;
  margin-bottom: 0.18em;
}

.expert-context-meta {
  margin-top: 0.4em;
}

.expert-context-subtitle {
  font-size: 0.88em;
  font-weight: 700;
  color: #52657a;
  margin-bottom: 0.45em;
}

.expert-context-annotations {
  margin-top: 0.75em;
}

.expert-context-ann-list {
  display: flex;
  flex-direction: column;
  gap: 0.55em;
}

.expert-context-ann {
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #ffffff;
  padding: 0.7em 0.85em;
}

.expert-context-ann-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45em;
  margin-bottom: 0.3em;
}

.expert-context-ann-id {
  display: inline-block;
  font-size: 0.78em;
  line-height: 1;
  color: #8795a8;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.expert-context-ann-tag .annotation-tag {
  vertical-align: middle;
}

.expert-context-ann-text {
  color: #111827;
  white-space: pre-wrap;
  line-height: 1.5;
}

.expert-context-ann-rationale {
  margin-top: 0.65em;
  padding-top: 0.65em;
  border-top: 1px solid #e8eef7;
}

.expert-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45em;
}

.expert-mini-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.28em 0.7em;
  border-radius: 999px;
  font-size: 0.88em;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #334155;
}

.expert-mini-chip--tag {
  background: #eef5ff;
  border-color: #bfd3f2;
  color: #274c77;
}

.expert-mini-chip--rel {
  background: #f6f8fb;
  border-color: #d7dee8;
  color: #475569;
}

.expert-comment-section {
  margin-top: 0.2em;
}

/* ===== Filtr etykiet — estetyka przycisków i panelu ===== */

#tagFilterMenu .tag-filter-actions-top,
#tagFilterMenu .tag-filter-actions-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
}

#tagFilterMenu .tag-filter-actions-top {
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #fff;
  padding: 4px 0 10px 0;
  z-index: 2;
}

#tagFilterMenu .tag-filter-actions-bottom {
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: #fff;
  padding: 10px 0 2px 0;
  z-index: 2;
  border-top: 1px solid #eef2f7;
}

#tagFilterMenu button {
  appearance: none;
  border: 1px solid #cfe0f5;
  background: #f8fbff;
  color: #2c4a6b;
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

#tagFilterMenu button:hover {
  background: #eef6ff;
  border-color: #b8d0ee;
}

#tagFilterMenu button:active {
  transform: translateY(1px);
}

#tagFilterMenu button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.22);
}

#tagFilterClear {
  color: #49627f;
  background: #f8fbff;
}

#tagFilterClose {
  color: #26415f;
  background: #f4f8fd;
}

#tagFilterSearch {
  width: 100%;
  border: 1px solid #cfe0f5;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  background: #fcfdff;
  color: #24364b;
  box-sizing: border-box;
}

#tagFilterSearch::placeholder {
  color: #8aa0b8;
}

#tagFilterSearch:focus {
  outline: none;
  border-color: #9fc1ea;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.16);
  background: #fff;
}

#tagFilterMenu {
  background: #ffffff;
}

#tagFilterGroups {
  border-top: 1px solid #eef2f7;
  border-bottom: 1px solid #eef2f7;
  padding: 10px 2px;
  margin-top: 6px;
  margin-bottom: 8px;
}

.tag-filter-item {
  padding: 4px 6px;
  border-radius: 10px;
  transition: background 0.12s ease;
}

.tag-filter-item:hover {
  background: #f8fbff;
}

/* ===============================
   MENU TŁUMACZEŃ W STOPCE
================================ */

.translations-menu {
  position: relative;
  display: inline-block;
}

.translations-menu-btn {
  appearance: none;
  border: 1px solid #cfe0f5;
  background: #f8fbff;
  color: #2c4a6b;
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  white-space: nowrap;
}

.translations-menu-btn:hover {
  background: #eef6ff;
  border-color: #b8d0ee;
}

.translations-menu-btn:active {
  transform: translateY(1px);
}

.translations-menu-btn.is-active {
  background: #eaf3ff;
  border-color: #9fc1ea;
  color: #1f4b7a;
}

.translations-menu-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 2100;
  min-width: 290px;
  max-width: min(360px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid #dbe7f3;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
  padding: 10px;
  box-sizing: border-box;
}

.translations-menu-panel[hidden] {
  display: none !important;
}

.translations-menu-header {
  font-size: 0.86rem;
  font-weight: 700;
  color: #52657a;
  padding: 2px 4px 8px 4px;
  border-bottom: 1px solid #eef2f7;
  margin-bottom: 8px;
}

.translations-menu-item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 8px 10px;
  border-radius: 10px;
  color: #24364b;
  font-size: 0.95rem;
  line-height: 1.25;
  cursor: pointer;
  transition: background 0.12s ease;
}

.translations-menu-item:hover {
  background: #f8fbff;
}

.translations-menu-item input {
  margin-top: 0.15rem;
  flex: 0 0 auto;
}

/* ===============================
   FILTR RELACJI
================================ */

.relation-filter {
  position: relative;
  display: inline-block;
  overflow: visible;
}

.relation-filter-btn {
  appearance: none;
  border: 1px solid #cfe0f5;
  background: #f8fbff;
  color: #2c4a6b;
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  white-space: nowrap;
}

.relation-filter-btn:hover {
  background: #eef6ff;
  border-color: #b8d0ee;
}

.relation-filter-btn:active {
  transform: translateY(1px);
}

.relation-filter-btn.is-active {
  background: #eaf3ff;
  border-color: #9fc1ea;
  color: #1f4b7a;
}

.relation-filter-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 2100;
  width: 420px;
  max-width: calc(100vw - 24px);
  min-width: 280px;
  max-height: 60vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #dbe7f3;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
  padding: 10px;
  box-sizing: border-box;
}

.relation-filter-menu[hidden] {
  display: none !important;
}

.relation-filter-menu::after {
  content: "";
  position: absolute;
  bottom: -8px;
  right: 16px;
  border: 8px solid transparent;
  border-top-color: #fff;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.06));
}

.relation-filter-header,
.relation-filter-footer {
  display: flex;
  align-items: center;
  gap: 10px;
}

.relation-filter-header {
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #fff;
  padding: 4px 0 10px 0;
  z-index: 2;
}

.relation-filter-footer {
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  background: #fff;
  padding: 10px 0 2px 0;
  z-index: 2;
  border-top: 1px solid #eef2f7;
}

.relation-filter-menu button {
  appearance: none;
  border: 1px solid #cfe0f5;
  background: #f8fbff;
  color: #2c4a6b;
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.relation-filter-menu button:hover {
  background: #eef6ff;
  border-color: #b8d0ee;
}

#relationFilterSearch {
  width: 100%;
  border: 1px solid #cfe0f5;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  background: #fcfdff;
  color: #24364b;
  box-sizing: border-box;
}

#relationFilterSearch::placeholder {
  color: #8aa0b8;
}

#relationFilterSearch:focus {
  outline: none;
  border-color: #9fc1ea;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.16);
  background: #fff;
}

#relationFilterGroups {
  border-top: 1px solid #eef2f7;
  border-bottom: 1px solid #eef2f7;
  padding: 10px 2px;
  margin-top: 6px;
  margin-bottom: 8px;
}

.relation-filter-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: .32rem 0;
}

.relation-filter-item {
  display: flex;
  align-items: flex-start;
  gap: .45rem;
  padding: 5px 8px;
  border-radius: 10px;
  transition: background 0.12s ease;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
}

.relation-filter-item:hover {
  background: #f8fbff;
}

.relation-filter-item input {
  margin-top: .15rem;
  flex: 0 0 auto;
}

.relation-select-button--add {
  background-color: #f8fbff;
  border: 1px dashed #99c2ff;
  color: #0f4c81;
  font-weight: 600;
}

.relation-select-button--add:hover {
  background-color: #eaf4ff;
}

.relation-add-inline-input {
  border: 1px solid #cfe0f5;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.95rem;
  background: #fcfdff;
  color: #24364b;
}

.relation-add-inline-input:focus {
  outline: none;
  border-color: #9fc1ea;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.16);
  background: #fff;
}

/* ===============================
   UJEDNOLICENIE PRZYCISKÓW W FOOTERZE
================================ */

#annotation-footer #downloadAutosaveBtn,
#annotation-footer #showTranscriptBtn,
#annotation-footer .tag-filter-btn,
#annotation-footer .relation-filter-btn,
#annotation-footer .translations-menu-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid #cfe0f5;
  background: #f8fbff;
  color: #2c4a6b;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease,
    color 0.15s ease;
}

#annotation-footer #downloadAutosaveBtn:hover,
#annotation-footer #showTranscriptBtn:hover,
#annotation-footer .tag-filter-btn:hover,
#annotation-footer .relation-filter-btn:hover,
#annotation-footer .translations-menu-btn:hover {
  background: #eef6ff;
  border-color: #b8d0ee;
}

#annotation-footer #downloadAutosaveBtn:active,
#annotation-footer #showTranscriptBtn:active,
#annotation-footer .tag-filter-btn:active,
#annotation-footer .relation-filter-btn:active,
#annotation-footer .translations-menu-btn:active {
  transform: translateY(1px);
}

#annotation-footer #downloadAutosaveBtn:focus-visible,
#annotation-footer #showTranscriptBtn:focus-visible,
#annotation-footer .tag-filter-btn:focus-visible,
#annotation-footer .relation-filter-btn:focus-visible,
#annotation-footer .translations-menu-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.22);
}

#annotation-footer .tag-filter-btn.is-active,
#annotation-footer .relation-filter-btn.is-active,
#annotation-footer .translations-menu-btn.is-active {
  background: #eaf3ff;
  border-color: #9fc1ea;
  color: #1f4b7a;
}

/* lekka kosmetyka exportu, żeby siedział w tej samej rodzinie gabarytowo */
#annotation-footer #exportJsonBtn {
  min-height: 40px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===============================
   MANAGE TAG MODAL
================================ */

.config-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 15000;
  padding: 24px;
}

.config-content {
  width: min(880px, 94vw);
  max-height: 88vh;
  overflow: hidden;
  background: #fff;
  border: 1px solid #dbe3ef;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.22);
  display: flex;
  flex-direction: column;
}

.manage-tag-content {
  width: min(820px, 94vw);
}

.config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid #e5edf7;
  background: #f8fbff;
}

.config-header h2 {
  margin: 0;
  font-size: 1.06em;
  font-weight: 700;
  color: #1f3552;
}

.config-close {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #334155;
  border-radius: 10px;
  padding: 0.2em 0.65em;
  font-size: 1.2em;
  cursor: pointer;
  line-height: 1;
}

.config-close:hover {
  background: #f8fafc;
}

.config-body {
  padding: 18px;
  overflow-y: auto;
}

.config-section {
  margin-top: 0.6em;
}

.config-table-wrap {
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #fff;
}

.config-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 18px;
  border-top: 1px solid #e5edf7;
  background: #fcfdff;
}

.config-footer-left,
.config-footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.annotation-rationale-meta {
  margin-bottom: 1em;
  padding: 0.9em 1em;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #f8fbff;
}

.annotation-rationale-meta-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45em;
  margin-bottom: 0.45em;
}

.annotation-rationale-meta-text {
  color: #111827;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* =========================================
   ANNOTATION — PAPER MODE EXTENSION
   wklej na sam koniec pliku
========================================= */

:root {
  --ann-surface: #ffffff;
  --ann-surface-soft: #f8fafc;
  --ann-surface-elevated: rgba(255, 255, 255, 0.96);
  --ann-border: #d9dee7;
  --ann-border-strong: #cbd5e1;
  --ann-text: #111827;
  --ann-muted: #475569;

  --ann-toolbar-bg: rgba(255, 255, 255, 0.96);
  --ann-footer-bg: rgba(255, 255, 255, 0.96);

  --ann-switch-bg: #f8fafc;
  --ann-btn-bg: #ffffff;
  --ann-btn-hover-bg: #eef2f7;
  --ann-btn-active-bg: #ffffff;
  --ann-btn-active-text: #1d4ed8;

  --ann-menu-bg: #ffffff;
  --ann-menu-border: #dbe7f3;

  --ann-chip-bg: #f8fbff;
  --ann-chip-border: #cfe0f5;
  --ann-chip-border-strong: #b8d0ee;

  --ann-panel-soft: #f8fbff;
  --ann-panel-border: #dbe3ef;

  --ann-rel-chip-bg: #f6f8fb;
  --ann-rel-chip-border: #d7dee8;

  --ann-shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.04);
  --ann-shadow-panel: 0 2px 12px rgba(15, 23, 42, 0.05);
}

body.bg-white {
  --ann-surface: #ffffff;
  --ann-surface-soft: #f8fafc;
  --ann-surface-elevated: rgba(255, 255, 255, 0.96);
  --ann-border: #d9dee7;
  --ann-border-strong: #cbd5e1;
  --ann-text: #111827;
  --ann-muted: #475569;

  --ann-toolbar-bg: rgba(255, 255, 255, 0.96);
  --ann-footer-bg: rgba(255, 255, 255, 0.96);

  --ann-switch-bg: #f8fafc;
  --ann-btn-bg: #ffffff;
  --ann-btn-hover-bg: #eef2f7;
  --ann-btn-active-bg: #ffffff;
  --ann-btn-active-text: #1d4ed8;

  --ann-menu-bg: #ffffff;
  --ann-menu-border: #dbe7f3;

  --ann-chip-bg: #f8fbff;
  --ann-chip-border: #cfe0f5;
  --ann-chip-border-strong: #b8d0ee;

  --ann-panel-soft: #f8fbff;
  --ann-panel-border: #dbe3ef;

  --ann-rel-chip-bg: #f6f8fb;
  --ann-rel-chip-border: #d7dee8;
}

body.bg-paper {
  --ann-surface: #fbf5ea;
  --ann-surface-soft: #f7efdf;
  --ann-surface-elevated: rgba(248, 240, 225, 0.96);
  --ann-border: #dccfb8;
  --ann-border-strong: #cdbd9f;
  --ann-text: #2e2a24;
  --ann-muted: #6f6557;

  --ann-toolbar-bg: rgba(245, 236, 220, 0.94);
  --ann-footer-bg: rgba(245, 236, 220, 0.94);

  --ann-switch-bg: #f8efdf;
  --ann-btn-bg: #f9f1e3;
  --ann-btn-hover-bg: #f4ead9;
  --ann-btn-active-bg: #e8ddc7;
  --ann-btn-active-text: #6b4e17;

  --ann-menu-bg: #fbf5ea;
  --ann-menu-border: #dccfb8;

  --ann-chip-bg: #fcf4e6;
  --ann-chip-border: #ddcfb6;
  --ann-chip-border-strong: #ccb993;

  --ann-panel-soft: #f7efdf;
  --ann-panel-border: #ddcfb6;

  --ann-rel-chip-bg: #f4ecdc;
  --ann-rel-chip-border: #d5c4a5;
}

/* ===== header ===== */

#toolbar {
  background: var(--ann-toolbar-bg);
  border-bottom: 1px solid var(--ann-border);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(10px);
}

#toolbar .file-indicator,
#toolbar #annotatorName,
#toolbar .toolbar-button.btn-ghost {
  background: var(--ann-surface-elevated);
  border: 1px solid var(--ann-border);
  color: var(--ann-muted);
  box-shadow: var(--ann-shadow-soft);
}

#toolbar #annotatorName {
  color: var(--ann-text);
}

#toolbar .nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#toolbar .user-switch-btn {
  width: 40px;
  min-width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  flex: 0 0 40px;
}

#toolbar #annotatorName.annotator-name-compact {
  width: 72px;
  min-width: 72px;
  max-width: 72px;
  text-align: center;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
}

#toolbar #loadedFileName.file-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 260px;
  padding-left: 12px;
  padding-right: 12px;
  white-space: nowrap;
  overflow: hidden;
}

#toolbar #loadedFileName .file-indicator-icon {
  flex: 0 0 auto;
}

#toolbar #loadedFileName .file-indicator-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1500px) {
  #toolbar #annotatorName.annotator-name-compact {
    width: 64px;
    min-width: 64px;
    max-width: 64px;
  }

  #toolbar .user-switch-btn {
    width: 36px;
    min-width: 36px;
    flex-basis: 36px;
  }

  #toolbar #loadedFileName.file-indicator {
    max-width: 180px;
  }
}

@media (max-width: 1280px) {
  #toolbar #loadedFileName.file-indicator {
    max-width: 140px;
  }
}

body.bg-paper #toolbar .tab-button.active {
  background: #f7eddb;
  border-color: #d7c7ab;
  box-shadow: none;
}

/* ===== background switcher ===== */

.background-switcher {
  border-color: var(--ann-border);
  background: var(--ann-switch-bg);
  box-shadow: var(--ann-shadow-soft);
}

.bg-btn {
  color: var(--ann-muted);
}

.bg-btn:hover {
  background: var(--ann-btn-hover-bg);
  color: var(--ann-text);
}

.bg-btn.active {
  background: var(--ann-btn-active-bg);
  color: var(--ann-btn-active-text);
  box-shadow: var(--ann-shadow-soft);
}

/* ===== footer ===== */

#annotation-footer {
  background: var(--ann-footer-bg);
  border-top: 1px solid var(--ann-border);
  box-shadow: 0 -6px 16px rgba(0,0,0,.06);
  backdrop-filter: blur(10px);
}

#annotation-footer .annotation-toolbar {
  background: none;
}

/* wspólna baza przycisków / inputów w stopce */
#annotation-footer .toolbar-button,
#annotation-footer .tag-filter-btn,
#annotation-footer .relation-filter-btn,
#annotation-footer .translations-menu-btn,
#annotation-footer input[type="file"].file-input,
#annotation-footer select,
#annotation-footer input[type="text"] {
  background: var(--ann-btn-bg);
  border: 1px solid var(--ann-border);
  color: var(--ann-text);
  box-shadow: var(--ann-shadow-soft);
}

#annotation-footer .toolbar-button:hover,
#annotation-footer .tag-filter-btn:hover,
#annotation-footer .relation-filter-btn:hover,
#annotation-footer .translations-menu-btn:hover,
#annotation-footer input[type="file"].file-input:hover,
#annotation-footer select:hover,
#annotation-footer input[type="text"]:hover {
  background: var(--ann-btn-hover-bg);
  border-color: var(--ann-border-strong);
}

#annotation-footer .tag-filter-btn.is-active,
#annotation-footer .relation-filter-btn.is-active,
#annotation-footer .translations-menu-btn.is-active {
  background: var(--ann-btn-active-bg);
  border-color: var(--ann-chip-border-strong);
  color: var(--ann-btn-active-text);
}

/* ===== popupy / menu ===== */

#tagFilterMenu,
.relation-filter-menu,
.translations-menu-panel {
  background: var(--ann-menu-bg);
  border: 1px solid var(--ann-menu-border);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
}

#tagFilterMenu .tag-filter-actions-top,
#tagFilterMenu .tag-filter-actions-bottom,
.relation-filter-header,
.relation-filter-footer,
.translations-menu-header {
  background: var(--ann-menu-bg);
}

#tagFilterSearch,
#relationFilterSearch {
  background: var(--ann-btn-bg);
  border: 1px solid var(--ann-border);
  color: var(--ann-text);
}

#tagFilterSearch:focus,
#relationFilterSearch:focus,
.relation-add-inline-input:focus {
  border-color: var(--ann-chip-border-strong);
  background: var(--ann-surface);
}

/* ===== treść anotacji / chipy ===== */

body.bg-paper .qa-ann.selected {
  background-color: #f3ead8;
  box-shadow: 0 0 0 4px rgba(139, 111, 71, 0.10);
}

body.bg-paper .clickable-segment.selected {
  background-color: #f3ead8;
  box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.14);
}

.relation-chip {
  background-color: var(--ann-rel-chip-bg);
  border: 1px solid var(--ann-rel-chip-border);
  color: #334155;
}

.relation-summary-toggle,
.relation-summary-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.relation-summary-toggle {
  appearance: none;
  border: 1px solid var(--ann-chip-border);
  background: color-mix(in oklab, var(--ann-surface) 84%, #eef6ff 16%);
  color: var(--ann-text-soft);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.relation-summary-toggle:hover,
.relation-summary-toggle.is-expanded {
  background: color-mix(in oklab, var(--ann-btn-active-bg) 78%, white 22%);
  border-color: #9fc1ea;
  color: #284a6b;
}

.relation-summary-badge {
  border: 1px solid var(--ann-chip-border);
  background: color-mix(in oklab, var(--ann-surface) 92%, white 8%);
  color: var(--ann-text-soft);
}

.qa-ann-rel-list {
  display: none;
  flex-wrap: wrap;
  gap: 0.45em 0.55em;
  margin-top: 0.5em;
}

#qaPairsOutput[data-relation-display-mode="full"] .qa-ann-rel-list,
#qaPairsOutput[data-relation-display-mode="minimal"] .qa-ann-rel-list.is-expanded {
  display: flex;
}

.qa-ann-rel-list .relation-wrapper {
  display: inline-flex;
  flex-direction: column;
}

.qa-ann-rel-list .relation-chip {
  float: none;
  margin-left: 0;
}

.relation-chip.active {
  background-color: color-mix(in oklab, var(--ann-btn-active-bg) 78%, white 22%);
  border: 2px solid #60a5fa;
}

.rel-id-badge {
  background: var(--ann-surface);
  border-color: var(--ann-border);
  color: #475569;
}

.tag-i18n-chip {
  background: color-mix(in oklab, var(--ann-btn-bg) 88%, white 12%);
  border-color: var(--ann-chip-border);
  color: #355070;
}

.tag-i18n-lang,
.lang-pill {
  background: var(--ann-surface);
  border-color: var(--ann-border);
  color: #475569;
}

.segment-translations {
  border-left-color: var(--ann-border);
  color: var(--ann-muted);
}

.annotation-text-i18n {
  color: var(--ann-muted);
}

/* ===== panele, formularze, modale ===== */

.features-panel,
.relation-form,
.relation-selection-popup,
.relation-table,
.gold-block-container,
.sentence-features-wrapper,
.segment-logic-display,
.logic-flags-display,
.relation-details-box,
.graph-popup-content,
.extended-metadata,
.comment-editor,
.expert-comment-modal__dialog,
.expert-comment-lang-card,
.expert-context-box,
.expert-context-ann {
  background: var(--ann-surface);
  border-color: var(--ann-panel-border);
}

.expert-comment-modal__header,
.expert-context-box,
.features-panel,
.segment-logic-display,
.logic-flags-display {
  background: var(--ann-panel-soft);
}

.expert-comment-modal__header {
  border-bottom-color: var(--ann-border);
}

.expert-comment-modal__close {
  background: var(--ann-btn-bg);
  border-color: var(--ann-border);
  color: var(--ann-muted);
}

.expert-comment-modal__close:hover {
  background: var(--ann-btn-hover-bg);
}

/* ===== delikatne ocieplenie w paper mode dla ikon i detali ===== */

body.bg-paper .annotation-rationale-toggle.has-rationale {
  color: #a76d08;
}

body.bg-paper .note-icon,
body.bg-paper .tree-icon,
body.bg-paper .expert-note-icon,
body.bg-paper .expert-rationale-icon,
body.bg-paper .expert-difficulty-icon {
  opacity: 0.78;
}

body.bg-paper .segment-id-tag {
  background-color: #f1e6d2;
  border-color: #d7c7ab;
  color: #6b4e17;
}

body.bg-paper .segment-id-tag:hover {
  background-color: #eadcc3;
}

/* =========================================
   PAPER MODE — ANNOTATION RATIONALE MODAL
   wklej na sam koniec pliku
========================================= */

body.bg-paper #annotationRationaleModal .config-content {
  background: #fbf5ea;
  border-color: #dccfb8;
}

body.bg-paper #annotationRationaleModal .config-header {
  background: #f7efdf;
  border-bottom-color: #dccfb8;
}

body.bg-paper #annotationRationaleModal .config-header h2 {
  color: #4b3a20;
}

body.bg-paper #annotationRationaleModal .config-close {
  background: #f9f1e3;
  border-color: #d6c5a7;
  color: #5b4a2f;
}

body.bg-paper #annotationRationaleModal .config-close:hover {
  background: #f2e7d2;
}

body.bg-paper #annotationRationaleModal .config-footer {
  background: #f8efdf;
  border-top-color: #dccfb8;
}

body.bg-paper #annotationRationaleModal .annotation-rationale-meta {
  background: #f7efdf;
  border-color: #dccfb8;
}

body.bg-paper #annotationRationaleModal .annotation-rationale-meta-text {
  color: #2e2a24;
}

body.bg-paper #annotationRationaleModal label {
  color: #5f5344 !important;
}

body.bg-paper #annotationRationaleModal textarea {
  background: #fcf6eb;
  border: 1px solid #d6c5a7;
  color: #2e2a24;
}

body.bg-paper #annotationRationaleModal textarea::placeholder {
  color: #8a7c68;
}

body.bg-paper #annotationRationaleModal textarea:focus {
  outline: none;
  border-color: #c7b18a;
  box-shadow: 0 0 0 3px rgba(199, 177, 138, 0.18);
}

body.bg-paper #annotationRationaleModal .toolbar-button.btn-ghost {
  background: #f9f1e3;
  border-color: #d6c5a7;
  color: #5b4a2f;
}

body.bg-paper #annotationRationaleModal .toolbar-button.btn-ghost:hover {
  background: #f2e7d2;
}

body.bg-paper #annotationRationaleModal .toolbar-button.btn-primary {
  background: #d8c19a;
  border-color: #c7ae84;
  color: #3f2d12;
}

body.bg-paper #annotationRationaleModal .toolbar-button.btn-primary:hover {
  background: #cfb487;
}

/* === Header tabs: kliknięcie nie zmienia wyglądu nieaktywnej pastylki === */
#toolbar .tabs .tab-button:not(.active):visited,
#toolbar .tabs .tab-button:not(.active):focus,
#toolbar .tabs .tab-button:not(.active):focus-visible,
#toolbar .tabs .tab-button:not(.active):active {
  color: #334155 !important;
  text-decoration: none !important;
  outline: none !important;
  box-shadow: none !important;
  transform: none !important;
}

body.bg-paper #toolbar .tabs .tab-button:not(.active):visited,
body.bg-paper #toolbar .tabs .tab-button:not(.active):focus,
body.bg-paper #toolbar .tabs .tab-button:not(.active):focus-visible,
body.bg-paper #toolbar .tabs .tab-button:not(.active):active {
  color: #5b4a2f !important;
  text-decoration: none !important;
  outline: none !important;
  box-shadow: none !important;
  transform: none !important;
}

/* =========================================
   HEADER TABS — aktywna jasna, reszta piaskowa
========================================= */

#toolbar .tabs .tab-button {
  background: #efe6d6 !important;
  border: 1px solid #d6c5a7 !important;
  color: #5b4a2f !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
}

#toolbar .tabs .tab-button:hover {
  background: #f4ecde !important;
  border-color: #ccb894 !important;
  color: #4e3d24 !important;
}

#toolbar .tabs .tab-button.active,
#toolbar .tabs .tab-button[aria-current="page"] {
  background: #ffffff !important;
  border: 1px solid #d9dee7 !important;
  color: #1f2937 !important;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06) !important;
}

#toolbar .tabs .tab-button.active:hover,
#toolbar .tabs .tab-button[aria-current="page"]:hover {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #111827 !important;
}

/* zachowaj neutralny wygląd nieaktywnych także po visited/focus */
#toolbar .tabs .tab-button:not(.active):visited,
#toolbar .tabs .tab-button:not(.active):focus,
#toolbar .tabs .tab-button:not(.active):focus-visible,
#toolbar .tabs .tab-button:not(.active):active {
  background: #efe6d6 !important;
  border-color: #d6c5a7 !important;
  color: #5b4a2f !important;
  text-decoration: none !important;
  outline: none !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  transform: none !important;
}

/* =========================================
   HEADER TABS — bez ukrytego suwaka na mniejszych ekranach
========================================= */

@media (max-width: 1500px) {
  #toolbar {
    flex-wrap: wrap;
    align-items: flex-start;
    row-gap: 10px;
  }

  #toolbar .nav-left {
    order: 1;
    flex: 0 0 auto;
  }

  #toolbar .tab-bar {
    order: 2;
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    overflow: visible !important;
  }

  #toolbar .tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
    width: 100%;
    padding: 0;
    overflow: visible !important;
  }

  #toolbar .nav-right {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    padding-left: 0;
  }

  #toolbar .tabs .tab-button {
    padding: 9px 14px !important;
    font-size: 0.96rem !important;
  }

  #toolbar #loadedFileName {
    max-width: 100%;
  }
}

@media (max-width: 1200px) {
  #toolbar .tabs {
    gap: 6px;
  }

  #toolbar .tabs .tab-button {
    padding: 8px 12px !important;
    font-size: 0.92rem !important;
  }

  #toolbar .nav-right {
    gap: 6px;
  }
}

/* =========================================
   HEADER TABS — restore white mode look
========================================= */

body.bg-white #toolbar .tabs .tab-button {
  background: #ffffff !important;
  border: 1px solid #d9dee7 !important;
  color: #334155 !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
}

body.bg-white #toolbar .tabs .tab-button:hover {
  background: #f8fbff !important;
  border-color: #cbd5e1 !important;
  color: #1f2937 !important;
}

body.bg-white #toolbar .tabs .tab-button.active,
body.bg-white #toolbar .tabs .tab-button[aria-current="page"] {
  background: #eef5ff !important;
  border: 1px solid #bfd3f2 !important;
  color: #1f3552 !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05) !important;
}

body.bg-white #toolbar .tabs .tab-button.active:hover,
body.bg-white #toolbar .tabs .tab-button[aria-current="page"]:hover {
  background: #eef5ff !important;
  border-color: #bfd3f2 !important;
  color: #1f3552 !important;
}

body.bg-white #toolbar .tabs .tab-button:not(.active):visited,
body.bg-white #toolbar .tabs .tab-button:not(.active):focus,
body.bg-white #toolbar .tabs .tab-button:not(.active):focus-visible,
body.bg-white #toolbar .tabs .tab-button:not(.active):active {
  background: #ffffff !important;
  border-color: #d9dee7 !important;
  color: #334155 !important;
  text-decoration: none !important;
  outline: none !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  transform: none !important;
}

body.bg-white #toolbar .tabs .tab-button.active:visited,
body.bg-white #toolbar .tabs .tab-button.active:focus,
body.bg-white #toolbar .tabs .tab-button.active:focus-visible,
body.bg-white #toolbar .tabs .tab-button.active:active {
  background: #eef5ff !important;
  border-color: #bfd3f2 !important;
  color: #1f3552 !important;
  text-decoration: none !important;
  outline: none !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05) !important;
  transform: none !important;
}

/* =========================================
   EXPORT JSON — ma się wyróżniać w obu trybach
========================================= */

#annotation-footer #exportJsonBtn,
#annotation-footer #exportJsonBtn.toolbar-button,
#annotation-footer #exportJsonBtn.btn-export-json {
  appearance: none;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid #1d4ed8 !important;
  background: linear-gradient(to right, #0057b7, #007bff) !important;
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 87, 183, 0.30) !important;
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.05s ease,
    filter 0.2s ease;
}

#annotation-footer #exportJsonBtn:hover,
#annotation-footer #exportJsonBtn.toolbar-button:hover,
#annotation-footer #exportJsonBtn.btn-export-json:hover {
  background: linear-gradient(to right, #004a9f, #0066e0) !important;
  color: #ffffff !important;
  box-shadow: 0 6px 16px rgba(0, 87, 183, 0.45) !important;
}

#annotation-footer #exportJsonBtn:active,
#annotation-footer #exportJsonBtn.toolbar-button:active,
#annotation-footer #exportJsonBtn.btn-export-json:active {
  transform: translateY(1px);
}

#annotation-footer #exportJsonBtn:focus-visible,
#annotation-footer #exportJsonBtn.toolbar-button:focus-visible,
#annotation-footer #exportJsonBtn.btn-export-json:focus-visible {
  outline: none;
  box-shadow:
    0 6px 16px rgba(0, 87, 183, 0.38),
    0 0 0 3px rgba(96, 165, 250, 0.24) !important;
}

/* paper mode — ciut cieplejszy cień, ale ten sam niebieski priorytet */
body.bg-paper #annotation-footer #exportJsonBtn,
body.bg-paper #annotation-footer #exportJsonBtn.toolbar-button,
body.bg-paper #annotation-footer #exportJsonBtn.btn-export-json {
  box-shadow: 0 4px 12px rgba(0, 87, 183, 0.24), 0 1px 0 rgba(120, 102, 78, 0.10) !important;
}

body.bg-paper #annotation-footer #exportJsonBtn:hover,
body.bg-paper #annotation-footer #exportJsonBtn.toolbar-button:hover,
body.bg-paper #annotation-footer #exportJsonBtn.btn-export-json:hover {
  box-shadow: 0 6px 16px rgba(0, 87, 183, 0.34), 0 1px 0 rgba(120, 102, 78, 0.12) !important;
}

/* =========================================
   GENERAL TAGS 1.0B — global taxonomy panel
========================================= */
.taxonomy-toolbar-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
}

.taxonomy-unclassified-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff1d6;
  color: #8a4b08;
  border: 1px solid #efc57f;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
}

.taxonomy-unclassified-badge[hidden] { display: none !important; }
.taxonomy-toolbar-btn.has-unclassified { border-color: #d6b46b !important; }

.taxonomy-modal-content {
  width: min(1180px, calc(100vw - 48px));
  max-width: 1180px;
  height: min(86vh, 900px);
  max-height: 900px;
}

.taxonomy-modal-content .config-header {
  align-items: flex-start;
}

.taxonomy-modal-subtitle {
  margin-top: 5px;
  max-width: 820px;
  color: #64748b;
  font-size: 0.9rem;
  line-height: 1.45;
  font-weight: 400;
}

.taxonomy-modal-body {
  overflow: auto;
  padding-top: 16px;
}

.taxonomy-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.taxonomy-kpi {
  padding: 12px 14px;
  border: 1px solid #dce4ee;
  border-radius: 12px;
  background: #f8fafc;
}

.taxonomy-kpi--warning {
  background: #fffaf0;
  border-color: #efd49a;
}

.taxonomy-kpi-value {
  font-size: 1.25rem;
  line-height: 1.1;
  font-weight: 800;
  color: #172033;
}

.taxonomy-kpi-label {
  margin-top: 5px;
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.3;
}

.taxonomy-controls {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 10px;
  position: sticky;
  top: -1px;
  z-index: 4;
  padding: 8px 0 12px;
  background: inherit;
}

.taxonomy-controls input,
.taxonomy-controls select,
.taxonomy-parent-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: #1f2937;
}

.taxonomy-controls input:focus,
.taxonomy-controls select:focus,
.taxonomy-parent-input:focus {
  outline: none;
  border-color: #8bb0dc;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

.taxonomy-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 8px;
}

.taxonomy-group {
  border: 1px solid #dce4ee;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.taxonomy-group--unclassified {
  border-color: #ead09a;
}

.taxonomy-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 14px;
  background: #f7f9fc;
  border-bottom: 1px solid #e6ebf1;
}

.taxonomy-group--unclassified .taxonomy-group-head {
  background: #fffaf0;
  border-bottom-color: #f0ddb6;
}

.taxonomy-group-title {
  font-weight: 800;
  color: #1f2937;
  overflow-wrap: anywhere;
}

.taxonomy-group-meta {
  margin-top: 3px;
  color: #64748b;
  font-size: 0.79rem;
}

.taxonomy-general-pill,
.taxonomy-status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid #cddcec;
  background: #edf5ff;
  color: #365476;
}

.taxonomy-status-pill.is-warning {
  border-color: #efcf91;
  background: #fff2d9;
  color: #8a4b08;
}

.taxonomy-status-pill.is-ok {
  border-color: #b9dfc8;
  background: #eefbf3;
  color: #2d6b45;
}

.taxonomy-group-body {
  display: flex;
  flex-direction: column;
}

.taxonomy-tag-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(420px, 1.2fr);
  gap: 16px;
  align-items: center;
  padding: 9px 12px 9px 16px;
  border-bottom: 1px solid #edf1f5;
}

.taxonomy-tag-row:last-child { border-bottom: 0; }
.taxonomy-tag-row:hover { background: #fbfcfe; }

.taxonomy-tag-main {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.taxonomy-tag-name {
  min-width: 0;
  font-weight: 650;
  color: #283548;
  overflow-wrap: anywhere;
}

.taxonomy-tag-count {
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: #8491a2;
}

.taxonomy-parent-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 7px;
  align-items: center;
}

.taxonomy-parent-editor .toolbar-button {
  min-height: 38px;
  padding: 0 12px;
}

.taxonomy-row-clear {
  width: 38px;
  min-width: 38px;
  padding: 0 !important;
  font-size: 1.2rem;
}

.taxonomy-empty {
  padding: 15px;
  color: #718096;
  font-size: 0.88rem;
}

.taxonomy-empty--large {
  border: 1px dashed #d5dde7;
  border-radius: 12px;
  text-align: center;
  padding: 28px 16px;
}

.taxonomy-footer-help {
  color: #6b7788;
  font-size: 0.8rem;
  line-height: 1.35;
  max-width: 720px;
}

@media (max-width: 900px) {
  .taxonomy-modal-content {
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
  }
  .taxonomy-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .taxonomy-controls { grid-template-columns: 1fr; }
  .taxonomy-tag-row { grid-template-columns: 1fr; gap: 7px; }
  .taxonomy-parent-editor { grid-template-columns: minmax(0, 1fr) auto auto; }
}

/* =========================================================
   GENERAL TAGS 1.0C — annotation display level
   ========================================================= */
.tag-view-mode {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 36px;
  padding: 3px;
  border: 1px solid var(--ann-border, #d7dee8);
  border-radius: 10px;
  background: var(--ann-btn-bg, #fff);
  box-shadow: var(--ann-shadow-soft, 0 1px 2px rgba(15, 23, 42, 0.04));
  white-space: nowrap;
}

.tag-view-mode-label {
  padding: 0 7px 0 6px;
  color: var(--ann-muted, #64748b);
  font-size: 0.78rem;
  font-weight: 650;
}

#annotation-footer .tag-view-mode-btn,
#annotation-footer .annotation-toolbar .tag-view-mode-btn {
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ann-muted, #64748b);
  box-shadow: none;
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1;
}

#annotation-footer .tag-view-mode-btn:hover,
#annotation-footer .annotation-toolbar .tag-view-mode-btn:hover {
  background: var(--ann-btn-hover-bg, #f4f7fb);
  border-color: var(--ann-border, #d7dee8);
  color: var(--ann-text, #1f2937);
}

#annotation-footer .tag-view-mode-btn.active,
#annotation-footer .annotation-toolbar .tag-view-mode-btn.active {
  background: var(--ann-btn-active-bg, #eaf3ff);
  border-color: var(--ann-chip-border-strong, #afc8e6);
  color: var(--ann-btn-active-text, #244b77);
}

/* General tags are deliberately secondary to the fine-grained tag.
   Keep the semantic hue from the inline background colour, but wash it
   towards the current Annotation surface so the fine tag reads first. */
.annotation-tag--general,
.annotation-tag--fine-general {
  border: 1px solid color-mix(in srgb, var(--ann-border, #d7dee8) 82%, transparent);
  box-shadow: none;
  background-image: linear-gradient(
    color-mix(in srgb, var(--ann-surface, #fff) 72%, transparent),
    color-mix(in srgb, var(--ann-surface, #fff) 72%, transparent)
  );
  color: var(--ann-text-soft, #475569);
  font-size: 0.80em;
  font-weight: 400;
  padding: 0.38em 0.52em;
}

.annotation-tag--general .tag-level-marker,
.annotation-tag--fine-general .tag-level-marker {
  background: color-mix(in srgb, var(--ann-surface, #fff) 82%, transparent);
  border-color: color-mix(in srgb, var(--ann-border, #d7dee8) 80%, transparent);
  color: var(--ann-muted, #64748b);
  font-size: 0.66em;
  font-weight: 600;
}

.tag-level-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.28em;
  height: 1.28em;
  padding: 0 0.28em;
  margin-right: 0.4em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(31, 41, 55, 0.18);
  color: rgba(31, 41, 55, 0.76);
  font-size: 0.68em;
  font-weight: 800;
  line-height: 1;
  vertical-align: 0.08em;
}

.annotation-tag--general-missing {
  border: 1px dashed #d39a3a;
  background: #fff7e6 !important;
  color: #82510d;
  cursor: pointer;
}

.tag-level-separator {
  display: inline-block;
  color: #94a3b8;
  font-size: 0.82em;
  line-height: 1;
  margin: 0 -0.08em;
}

body.bg-paper .tag-view-mode {
  background: var(--ann-btn-bg, #fbf5e8);
}

body.bg-paper .annotation-tag--general-missing {
  background: #f7ecd5 !important;
  border-color: #c9984c;
  color: #76501c;
}

@media (max-width: 860px) {
  .tag-view-mode-label { display: none; }
  #annotation-footer .tag-view-mode-btn,
  #annotation-footer .annotation-toolbar .tag-view-mode-btn {
    padding-left: 6px;
    padding-right: 6px;
  }
}

/* ===== GENERAL TAGS 1.0D — filtering by fine/general taxonomy level ===== */
#tagFilterGroups .tag-filter-group {
  margin: 0;
  padding: 8px 4px 10px;
}

#tagFilterGroups .tag-filter-group + .tag-filter-group {
  border-top: 1px solid #e8eef6;
  margin-top: 4px;
  padding-top: 12px;
}

#tagFilterGroups .tag-filter-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 6px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #64748b;
}

#tagFilterGroups .tag-filter-item {
  align-items: center;
  min-height: 30px;
}

#tagFilterGroups .tag-filter-item-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

#tagFilterGroups .tag-filter-level-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  border: 1px solid #cbd5e1;
  color: #52657d;
  background: #f8fafc;
}

#tagFilterGroups .tag-filter-level-badge--general {
  border-style: dashed;
  background: #fffaf0;
  border-color: #d8bb7a;
  color: #7a5b1c;
}

#tagFilterGroups .tag-filter-item--general:hover {
  background: #fffaf2;
}

#tagFilterGroups .tag-filter-item-count {
  flex: 0 0 auto;
  min-width: 28px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

#tagFilterGroups .tag-filter-empty {
  padding: 5px 8px 7px 38px;
  color: #94a3b8;
  font-size: 0.86rem;
  line-height: 1.35;
}

/* General-tag English labels */
.taxonomy-group-heading-main {
  min-width: 0;
  flex: 1 1 auto;
}

.taxonomy-group-title-en {
  margin-top: 2px;
  color: #7b8797;
  font-size: .78rem;
  line-height: 1.3;
}

.taxonomy-general-tools {
  flex: 0 1 520px;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  gap: 7px;
  align-items: end;
}

.taxonomy-general-en-editor {
  min-width: 0;
}

.taxonomy-general-en-editor > span {
  display: block;
  margin: 0 0 3px 2px;
  color: #7b8797;
  font-size: .66rem;
  font-weight: 750;
  letter-spacing: .04em;
}

.taxonomy-general-en-input {
  width: 100%;
  min-height: 36px;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  padding: 7px 9px;
  color: #1f2937;
  font: inherit;
  font-size: .8rem;
}

.taxonomy-general-en-input:focus {
  outline: 0;
  border-color: #8bb0dc;
  box-shadow: 0 0 0 3px rgba(96,165,250,.13);
}

.taxonomy-general-en-save {
  min-height: 36px;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .taxonomy-group-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .taxonomy-general-tools {
    width: 100%;
    flex-basis: auto;
  }
}

@media (max-width: 620px) {
  .taxonomy-general-tools {
    grid-template-columns: 1fr auto;
  }
  .taxonomy-general-pill {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

/* =========================================================
   ANNOTATION UX 1 — span hover/focus
   Hierarchy indentation deliberately remains controlled by the legacy
   renderer (`margin-left` + ↳ marker), so UX focus cannot flatten the tree.
   ========================================================= */

.qa-ann {
  transition: background-color .13s ease, box-shadow .13s ease, opacity .13s ease;
}

.qa-ann > .qa-ann-inner {
  position: relative;
  z-index: 1;
  border-radius: 7px;
  transition: background-color .13s ease, box-shadow .13s ease;
}

.qa-ann.is-ann-hovered > .qa-ann-inner,
.qa-ann.is-ann-span-hovered > .qa-ann-inner {
  background: rgba(245, 158, 11, 0.075);
  box-shadow: inset 3px 0 0 rgba(217, 119, 6, 0.32);
}

.qa-ann.is-ann-focused > .qa-ann-inner {
  background: rgba(59, 130, 246, 0.085);
  box-shadow:
    inset 3px 0 0 rgba(37, 99, 235, 0.58),
    0 0 0 1px rgba(59, 130, 246, 0.14);
}

.qa-ann.is-ann-relation-peer > .qa-ann-inner {
  background: rgba(14, 165, 233, 0.045);
  box-shadow: inset 2px 0 0 rgba(14, 165, 233, 0.20);
}

.qa-ann.is-ann-hierarchy-parent > .qa-ann-inner,
.qa-ann.is-ann-hierarchy-child > .qa-ann-inner {
  background: rgba(124, 58, 237, 0.045);
  box-shadow: inset 2px 0 0 rgba(124, 58, 237, 0.22);
}

.qa-ann.is-ann-focused.is-ann-hierarchy-parent > .qa-ann-inner,
.qa-ann.is-ann-focused.is-ann-hierarchy-child > .qa-ann-inner {
  box-shadow:
    inset 3px 0 0 rgba(37, 99, 235, 0.58),
    0 0 0 1px rgba(59, 130, 246, 0.14);
}

body.bg-paper .qa-ann.is-ann-hovered > .qa-ann-inner,
body.bg-paper .qa-ann.is-ann-span-hovered > .qa-ann-inner {
  background: rgba(194, 132, 32, 0.085);
  box-shadow: inset 3px 0 0 rgba(153, 99, 21, 0.34);
}

body.bg-paper .qa-ann.is-ann-focused > .qa-ann-inner {
  background: rgba(118, 88, 51, 0.09);
  box-shadow:
    inset 3px 0 0 rgba(110, 78, 38, 0.55),
    0 0 0 1px rgba(110, 78, 38, 0.15);
}

.annotation-tag--focusable {
  cursor: pointer;
  transition: transform .09s ease, box-shadow .12s ease, filter .12s ease;
}

.annotation-tag--focusable:hover {
  filter: saturate(1.08);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}

.qa-text-fragment {
  border-radius: 3px;
  transition: background-color .10s ease, box-shadow .10s ease;
}

.qa-text-fragment.is-ann-hovered-span {
  background: rgba(250, 204, 21, 0.30);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.08);
}

.qa-text-fragment.is-ann-focused-span {
  background: rgba(96, 165, 250, 0.22);
  box-shadow: inset 0 -2px 0 rgba(37, 99, 235, 0.36);
}

.qa-text-fragment.is-ann-focused-span.is-ann-hovered-span {
  background: rgba(251, 191, 36, 0.30);
  box-shadow: inset 0 -2px 0 rgba(37, 99, 235, 0.42);
}

body.bg-paper .qa-text-fragment.is-ann-hovered-span {
  background: rgba(216, 167, 73, 0.30);
}

body.bg-paper .qa-text-fragment.is-ann-focused-span {
  background: rgba(153, 119, 74, 0.22);
  box-shadow: inset 0 -2px 0 rgba(111, 78, 38, 0.38);
}

/* The old selected style remains as a fallback for deployments without
   annotationFocus.js, but UX 1 uses the explicit focus classes above. */
.qa-ann.selected:not(.is-ann-focused) {
  outline: none;
  box-shadow: none;
}

/* =========================================================
   ANNOTATION UX 2 — discourse-map relation renderer
   Relation geometry is intentionally isolated from hierarchy indentation:
   hierarchy stays on the left, discourse relations use a dedicated rail
   on the right of the annotation column.
   ========================================================= */

#qaPairsPanel {
  --qa-relation-corridor-width: 152px;
}

#qaPairsPanel.qa-relations-visible .qa-annotations-column {
  padding-right: var(--qa-relation-corridor-width);
  box-sizing: border-box;
  overflow: visible;
  /*
   * Annotation UX 2.2 — relation corridor.
   * The right-hand strip belongs to discourse relations only. Annotation text,
   * tags and relation chips end before it, while SVG routes stay inside it.
   */
  background-image: linear-gradient(
    to right,
    transparent 0,
    transparent calc(100% - var(--qa-relation-corridor-width)),
    rgba(100, 116, 139, 0.018) calc(100% - var(--qa-relation-corridor-width)),
    rgba(100, 116, 139, 0.018) 100%
  );
}

body.bg-paper #qaPairsPanel.qa-relations-visible .qa-annotations-column {
  background-image: linear-gradient(
    to right,
    transparent 0,
    transparent calc(100% - var(--qa-relation-corridor-width)),
    rgba(128, 96, 52, 0.018) calc(100% - var(--qa-relation-corridor-width)),
    rgba(128, 96, 52, 0.018) 100%
  );
}

.qa-annotations-column {
  position: relative;
  min-width: 0;
  /* Relation rail must settle before geometry is measured; do not animate this padding. */
  transition: none;
}

#qaPairsPanel.qa-relations-visible .qa-annotations-column::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: var(--qa-relation-corridor-width);
  width: 1px;
  background: rgba(100, 116, 139, 0.13);
  pointer-events: none;
  z-index: 0;
}

body.bg-paper #qaPairsPanel.qa-relations-visible .qa-annotations-column::after {
  background: rgba(126, 99, 62, 0.13);
}

.qa-annotations-column .annotation-tag-row {
  position: relative;
  padding-right: 21px;
}

.qa-annotations-column .qa-ann-port {
  position: absolute;
  right: 2px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin: 0;
  transform: translateY(-50%);
  border-width: 1.5px;
  opacity: .70;
  pointer-events: auto;
  cursor: default;
  transition: opacity .12s ease, transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

#qaPairsPanel.qa-relations-visible .qa-ann:hover .qa-ann-port,
#qaPairsPanel.qa-relations-visible .qa-ann.is-ann-focused .qa-ann-port,
#qaPairsPanel.qa-relations-visible .qa-ann-port.is-rel-selected,
#qaPairsPanel.qa-relations-visible .qa-ann-port.is-rel-hovered {
  opacity: 1;
}

#qaPairsPanel.qa-relations-visible .qa-ann-port {
  border-color: #7890ad;
}

body.bg-paper #qaPairsPanel.qa-relations-visible .qa-ann-port {
  border-color: #967d58;
}

.qa-ann-port.is-rel-hovered {
  border-color: #277c78;
  box-shadow:
    0 0 0 2px rgba(255,255,255,.98),
    0 0 0 4px rgba(39,124,120,.14);
}

body.bg-paper .qa-ann-port.is-rel-hovered {
  box-shadow:
    0 0 0 2px rgba(248,240,225,.98),
    0 0 0 4px rgba(124,91,44,.13);
}

.qa-relation-arrows-layer {
  overflow: visible;
  z-index: 8;
}

.qa-rel-arrow-group {
  opacity: .62;
  transition: opacity .12s ease;
}

.qa-rel-arrow-group.is-rel-emphasized {
  opacity: 1;
}

.qa-rel-arrow-group.is-rel-dimmed {
  opacity: .075;
}

.qa-rel-arrow-path {
  stroke-width: 1.5;
  stroke-opacity: .68;
  vector-effect: non-scaling-stroke;
  filter: none;
  transition: stroke-width .11s ease, stroke-opacity .11s ease;
}

body.bg-paper .qa-rel-arrow-path {
  /* Per-relation inline stroke remains authoritative in UX 2. */
  stroke-opacity: .64;
}

.qa-rel-arrow-group.is-rel-emphasized .qa-rel-arrow-path,
.qa-rel-arrow-path.is-rel-hovered {
  stroke-width: 2.25;
  stroke-opacity: .96;
}

.qa-rel-arrow-path.is-rel-selected {
  stroke-width: 2.55;
  stroke-opacity: 1;
}

.qa-rel-arrow-hitbox {
  stroke-width: 13;
  pointer-events: stroke;
  cursor: pointer;
}

.qa-rel-source-dot {
  pointer-events: none;
}

.qa-rel-arrow-label-group {
  pointer-events: auto;
  cursor: pointer;
  opacity: .50;
  transition: opacity .11s ease;
}

.qa-rel-arrow-group.is-rel-emphasized .qa-rel-arrow-label-group,
.qa-rel-arrow-label-group.is-rel-hovered,
.qa-rel-arrow-label-group.is-rel-selected {
  opacity: 1;
}

.qa-rel-arrow-label-bg {
  fill: rgba(255,255,255,.70);
  stroke: rgba(148,163,184,.20);
  stroke-width: .65;
}

body.bg-paper .qa-rel-arrow-label-bg {
  fill: rgba(248,240,225,.72);
  stroke: rgba(143,119,81,.20);
}

.qa-rel-arrow-label {
  font-size: 10px;
  font-weight: 730;
  dominant-baseline: alphabetic;
  paint-order: stroke;
  stroke: rgba(255,255,255,.74);
  stroke-width: 1.25px;
  stroke-linejoin: round;
}

body.bg-paper .qa-rel-arrow-label {
  stroke: rgba(248,240,225,.78);
}

.qa-rel-arrow-group.is-rel-dimmed .qa-rel-arrow-label-group {
  opacity: .18;
}

.qa-rel-arrow-label-group.is-rel-hovered .qa-rel-arrow-label-bg,
.qa-rel-arrow-label-group.is-rel-selected .qa-rel-arrow-label-bg {
  stroke-width: 1.2;
  fill: rgba(255,255,255,.99);
}

body.bg-paper .qa-rel-arrow-label-group.is-rel-hovered .qa-rel-arrow-label-bg,
body.bg-paper .qa-rel-arrow-label-group.is-rel-selected .qa-rel-arrow-label-bg {
  fill: rgba(248,240,225,.99);
}

.qa-relation-tooltip {
  position: fixed;
  z-index: 3000;
  display: grid;
  gap: 3px;
  max-width: min(360px, calc(100vw - 28px));
  padding: 9px 11px;
  border: 1px solid rgba(51,65,85,.28);
  border-radius: 9px;
  background: rgba(30,41,59,.96);
  color: #f8fafc;
  box-shadow: 0 8px 24px rgba(15,23,42,.16);
  font-size: .78rem;
  line-height: 1.3;
  pointer-events: none;
}

.qa-relation-tooltip[hidden] { display: none; }
.qa-relation-tooltip strong { font-weight: 760; }
.qa-relation-tooltip span { color: #dbe5f0; }

body.bg-paper .qa-relation-tooltip {
  background: rgba(61,49,35,.96);
  border-color: rgba(151,122,79,.34);
}

/* Annotation UX 2.4 — relation actions live on the arrow, not in the reading flow. */
.qa-rel-arrow-label-group {
  cursor: pointer;
}

.qa-relation-actions-popover {
  position: fixed;
  z-index: 3250;
  width: min(430px, calc(100vw - 24px));
  padding: 12px;
  border: 1px solid var(--ann-panel-border, #d6dee8);
  border-radius: 14px;
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #172033);
  box-shadow: 0 18px 46px rgba(15,23,42,.18);
  font-family: Arial, sans-serif;
}

.qa-relation-actions-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ann-border, #e2e8f0);
}

.qa-relation-actions-head > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.qa-relation-actions-head strong {
  font-size: .92rem;
  overflow-wrap: anywhere;
}

.qa-relation-actions-head span {
  color: var(--ann-muted, #64748b);
  font-size: .8rem;
}

.qa-relation-actions-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ann-muted, #64748b);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.qa-relation-actions-close:hover {
  background: var(--ann-panel-soft, #f1f5f9);
  color: var(--ann-text, #172033);
}

.qa-relation-actions-endpoints {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.qa-relation-actions-endpoint {
  appearance: none;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 7px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--ann-chip-border, #d9e2ec);
  border-radius: 10px;
  background: var(--ann-panel-soft, #f8fafc);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.qa-relation-actions-endpoint:hover {
  border-color: #a9c4e4;
  background: color-mix(in oklab, var(--ann-panel-soft, #f8fafc) 76%, #eaf3ff 24%);
}

.qa-relation-actions-endpoint-role {
  grid-column: 1 / -1;
  color: var(--ann-muted, #64748b);
  font-size: .68rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.qa-relation-actions-endpoint strong {
  font-size: .82rem;
}

.qa-relation-actions-endpoint > span:not(.qa-relation-actions-endpoint-role) {
  min-width: 0;
  overflow: hidden;
  color: #334155;
  font-size: .78rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qa-relation-actions-endpoint small {
  grid-column: 1 / -1;
  color: var(--ann-muted, #64748b);
  font-size: .7rem;
}

.qa-relation-actions-endpoint em {
  grid-column: 1 / -1;
  display: -webkit-box;
  overflow: hidden;
  color: var(--ann-text-soft, #475569);
  font-family: Palatino, "Palatino Linotype", serif;
  font-size: .78rem;
  font-style: normal;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.qa-relation-actions-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.qa-relation-actions-toolbar button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--ann-chip-border, #d9e2ec);
  border-radius: 9px;
  background: var(--ann-surface, #fff);
  color: #334155;
  font-size: .75rem;
  font-weight: 650;
  cursor: pointer;
}

.qa-relation-actions-toolbar button:hover {
  background: var(--ann-panel-soft, #f8fafc);
  border-color: #a9c4e4;
}

.qa-relation-actions-toolbar button.is-danger:hover {
  border-color: #efb0b0;
  background: #fff4f4;
  color: #9f2f2f;
}

.qa-relation-actions-details {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--ann-border, #e2e8f0);
  border-radius: 10px;
  background: color-mix(in oklab, var(--ann-panel-soft, #f8fafc) 82%, white 18%);
  font-size: .78rem;
  line-height: 1.4;
}

.qa-relation-actions-details[hidden] {
  display: none;
}

.qa-relation-actions-details p {
  margin: 4px 0 9px;
  font-family: Palatino, "Palatino Linotype", serif;
  font-size: .92rem;
}

body.bg-paper .qa-relation-actions-popover {
  box-shadow: 0 18px 46px rgba(78,57,31,.18);
}

body.bg-paper .qa-relation-actions-toolbar button.is-danger:hover {
  background: #f9e9e6;
}

@media (max-width: 640px) {
  .qa-relation-actions-endpoints {
    grid-template-columns: 1fr;
  }
  .qa-relation-actions-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.qa-ann.is-rel-endpoint > .qa-ann-inner {
  background: rgba(13,148,136,.055);
  box-shadow: inset 2px 0 0 rgba(13,148,136,.28);
}

.qa-ann.is-rel-source > .qa-ann-inner {
  box-shadow: inset 3px 0 0 rgba(39,124,120,.48);
}

.qa-ann.is-rel-target > .qa-ann-inner {
  box-shadow: inset 3px 0 0 rgba(80,106,159,.48);
}

.qa-text-fragment.is-rel-endpoint-span {
  background: rgba(45,212,191,.15);
  box-shadow: inset 0 -2px 0 rgba(13,148,136,.30);
}

body.bg-paper .qa-ann.is-rel-endpoint > .qa-ann-inner {
  background: rgba(130,95,48,.065);
}

body.bg-paper .qa-text-fragment.is-rel-endpoint-span {
  background: rgba(180,134,64,.16);
  box-shadow: inset 0 -2px 0 rgba(123,87,39,.28);
}

@media (max-width: 1180px) {
  #qaPairsPanel {
    --qa-relation-corridor-width: 122px;
  }
}

@media (max-width: 860px) {
  #qaPairsPanel {
    --qa-relation-corridor-width: 0px;
  }
  #qaPairsPanel.qa-relations-visible .qa-annotations-column {
    padding-right: 0;
    background-image: none;
  }
  #qaPairsPanel.qa-relations-visible .qa-annotations-column::after {
    display: none;
  }
  .qa-relation-arrows-layer { display: none; }
  .qa-annotations-column .qa-ann-port { display: none; }
}


/* =========================================================
   Annotation UX 3.2 — Hierarchy Editor v2
   Duży modal pozostaje bez zmian; przebudowany jest jego środek.
   ========================================================= */
.hierarchy-editor-v2 {
  gap: 0;
  overflow: hidden;
}

.hierarchy-editor-v2 .hierarchy-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 0.15rem 2.6rem 0.9rem 0;
  border-bottom: 1px solid var(--ann-border, #d8dee8);
}

.hierarchy-editor-v2 .hierarchy-editor-head h3 {
  margin: 0 0 0.35rem;
  font-size: 1.22rem;
  color: var(--ann-text, #172033);
}

.hierarchy-editor-v2 .hierarchy-editor-head p {
  margin: 0;
  max-width: 72rem;
  color: var(--ann-muted, #64748b);
  line-height: 1.45;
  font-size: 0.93rem;
}

.hierarchy-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 0 0 auto;
}

.hierarchy-editor-v2 .btn {
  appearance: none;
  border: 1px solid var(--ann-border, #cbd5e1);
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #243043);
  border-radius: 9px;
  padding: 0.48rem 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.hierarchy-editor-v2 .btn:hover:not(:disabled) {
  background: var(--ann-panel-soft, #f5f8fc);
  border-color: #aab8cb;
}

.hierarchy-editor-v2 .btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.hierarchy-view-toggle {
  display: inline-flex;
  border: 1px solid var(--ann-border, #cbd5e1);
  background: var(--ann-panel-soft, #f8fafc);
  border-radius: 10px;
  overflow: hidden;
}

.hierarchy-view-toggle button {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--ann-border, #cbd5e1);
  background: transparent;
  color: var(--ann-muted, #64748b);
  padding: 0.5rem 0.72rem;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.hierarchy-view-toggle button:last-child { border-right: 0; }
.hierarchy-view-toggle button.is-active {
  background: #eaf3ff;
  color: #24527d;
}

body.bg-paper .hierarchy-view-toggle button.is-active {
  background: #efe3ca;
  color: #6c4c22;
}

.hierarchy-parent-pick-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.75rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid #9fc1ea;
  background: #eef6ff;
  border-radius: 10px;
  color: #264b70;
}

.hierarchy-parent-pick-banner[hidden] { display: none; }
.hierarchy-parent-pick-banner > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.hierarchy-parent-pick-banner span { font-size: 0.87rem; color: #58708a; }

body.bg-paper .hierarchy-parent-pick-banner {
  border-color: #d4b77f;
  background: #f7edd9;
  color: #6d4c20;
}
body.bg-paper .hierarchy-parent-pick-banner span { color: #846a47; }

.hierarchy-editor-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(285px, 330px);
  gap: 1rem;
  margin-top: 0.8rem;
  overflow: hidden;
}

.hierarchy-tree-panel,
.hierarchy-inspector {
  min-height: 0;
  border: 1px solid var(--ann-panel-border, #d9e1ec);
  background: var(--ann-surface, #fff);
  border-radius: 12px;
}

.hierarchy-tree-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hierarchy-tree-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--ann-border, #e1e7ef);
  background: var(--ann-panel-soft, #f8fafc);
  font-size: 0.86rem;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.035em;
}

.hierarchy-change-status {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 700;
  color: #94a3b8;
}
.hierarchy-change-status.is-dirty { color: #b46816; }

.hierarchy-tree-list {
  list-style: none;
  display: block;
  margin: 0;
  padding: 0.6rem 0.7rem 1rem;
  overflow: auto;
}

.hierarchy-tree-node {
  display: block;
  position: relative;
  margin: 0 0 0.35rem calc(var(--hierarchy-depth, 0) * 28px);
  padding: 0;
}

.hierarchy-tree-node[style*="--hierarchy-depth: 0"] { margin-left: 0; }

.hierarchy-tree-node:not([style*="--hierarchy-depth: 0"])::before {
  content: "";
  position: absolute;
  left: -16px;
  top: -0.55rem;
  width: 14px;
  height: calc(50% + 0.55rem);
  border-left: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  border-bottom-left-radius: 5px;
  pointer-events: none;
}

.hierarchy-tree-row {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 0.45rem;
  align-items: flex-start;
  border: 1px solid #d9e2ee;
  background: #fbfcfe;
  color: inherit;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.hierarchy-tree-row:hover {
  background: #f4f8fd;
  border-color: #b9cadf;
}

.hierarchy-tree-node.is-selected > .hierarchy-tree-row {
  border-color: #75a7df;
  background: #edf5ff;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.13);
}

body.bg-paper .hierarchy-tree-row { background: #fffaf0; border-color: #e3d4b7; }
body.bg-paper .hierarchy-tree-row:hover { background: #f8efdc; border-color: #cfb98e; }
body.bg-paper .hierarchy-tree-node.is-selected > .hierarchy-tree-row {
  background: #f5e8cf;
  border-color: #c7a66f;
  box-shadow: 0 0 0 2px rgba(153, 111, 50, 0.10);
}

.hierarchy-tree-node.is-parent-candidate > .hierarchy-tree-row {
  border-color: #5ea77a;
  background: #effaf3;
}
.hierarchy-tree-node.is-parent-candidate > .hierarchy-tree-row:hover {
  background: #e3f6ea;
  box-shadow: 0 0 0 2px rgba(74, 151, 105, 0.12);
}
.hierarchy-tree-node.is-parent-disabled > .hierarchy-tree-row { opacity: 0.38; cursor: not-allowed; }
.hierarchy-tree-node.is-parent-source > .hierarchy-tree-row {
  border-style: dashed;
  border-color: #bf7a30;
  background: #fff7e9;
}

.hierarchy-branch-mark {
  min-height: 20px;
  color: #9aa8ba;
  font-size: 0.65rem;
  padding-top: 0.42rem;
  text-align: center;
}

.hierarchy-node-main { min-width: 0; }
.hierarchy-node-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  min-width: 0;
}

.hierarchy-node-id {
  font-size: 0.81rem;
  font-weight: 800;
  color: #64748b;
  min-width: 2.2rem;
}

.hierarchy-tag-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 100%;
  padding: 0.25rem 0.52rem;
  border-radius: 6px;
  background: color-mix(in oklab, var(--hier-tag-color, #dbeafe) 78%, white 22%);
  border: 1px solid color-mix(in oklab, var(--hier-tag-color, #dbeafe) 48%, #cbd5e1 52%);
  color: #29415d;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.2;
}

.hierarchy-tag-en,
.hierarchy-node-text-en,
.hierarchy-inspector-text-en {
  color: #718096;
  font-size: 0.84rem;
}

.hierarchy-tag-en {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-style: italic;
}
.hierarchy-tag-en > span,
.hierarchy-node-text-en > span,
.hierarchy-inspector-text-en > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 0.05rem 0.25rem;
  margin-right: 0.32rem;
  border: 1px solid #d8e0e9;
  border-radius: 999px;
  background: #fff;
  color: #607086;
  font-style: normal;
  font-size: 0.67rem;
  font-weight: 800;
}

.hierarchy-root-badge,
.hierarchy-children-count {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 0.42rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
}
.hierarchy-root-badge { background: #eef2f7; color: #69788d; }
.hierarchy-children-count { background: #edf7f0; color: #4c765a; }

.hierarchy-node-text {
  display: block;
  margin-top: 0.38rem;
  color: #2f3949;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.hierarchy-node-text-en { margin-top: 0.3rem; line-height: 1.4; overflow-wrap: anywhere; }

.hierarchy-inspector {
  overflow: auto;
  padding: 0.75rem;
  background: var(--ann-panel-soft, #f8fafc);
}

.hierarchy-inspector-card,
.hierarchy-inspector-section {
  border: 1px solid var(--ann-border, #dbe2eb);
  background: var(--ann-surface, #fff);
  border-radius: 10px;
  padding: 0.72rem;
  margin-bottom: 0.65rem;
}

.hierarchy-inspector-kicker {
  margin-bottom: 0.45rem;
  color: #7b8797;
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.055em;
}

.hierarchy-inspector-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.hierarchy-inspector-title > strong { color: #5f6f82; font-size: 0.83rem; }
.hierarchy-inspector-tag-en { margin-top: 0.4rem; color: #738195; font-size: 0.82rem; font-style: italic; }
.hierarchy-inspector-text { margin-top: 0.6rem; line-height: 1.42; color: #30394a; overflow-wrap: anywhere; }
.hierarchy-inspector-text-en { margin-top: 0.42rem; line-height: 1.4; overflow-wrap: anywhere; }

.hierarchy-inspector-section h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.55rem;
  color: #435168;
  font-size: 0.85rem;
}
.hierarchy-inspector-section h4 > span { color: #8190a4; font-weight: 700; }

.hierarchy-inspector-value,
.hierarchy-related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.hierarchy-related-chip {
  appearance: none;
  border: 1px solid #d5dfeb;
  background: #f7fafe;
  color: #3f5b78;
  border-radius: 999px;
  padding: 0.3rem 0.5rem;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.hierarchy-related-chip:hover { background: #eaf3ff; border-color: #a9c7e8; }
.hierarchy-empty-value { color: #8a96a7; font-size: 0.83rem; font-style: italic; }

.hierarchy-inspector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin-top: 0.62rem;
}

.hierarchy-order-meta { color: #7c899b; font-size: 0.8rem; }

.hierarchy-editor-v2 .hierarchy-actions {
  flex: 0 0 auto;
  border-top: 1px solid var(--ann-border, #d8dee8);
  padding-top: 0.75rem;
  margin-top: 0.8rem;
}

.hierarchy-editor-v2 .hierarchy-actions .btn.primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

body.bg-paper .hierarchy-tree-panel,
body.bg-paper .hierarchy-inspector,
body.bg-paper .hierarchy-inspector-card,
body.bg-paper .hierarchy-inspector-section {
  border-color: #dfcfb0;
}
body.bg-paper .hierarchy-tree-heading,
body.bg-paper .hierarchy-inspector { background: #f8f0e1; }
body.bg-paper .hierarchy-inspector-card,
body.bg-paper .hierarchy-inspector-section { background: #fffaf0; }
body.bg-paper .hierarchy-related-chip { background: #fbf2df; border-color: #dfc99f; color: #75562f; }
body.bg-paper .hierarchy-related-chip:hover { background: #f3e4c7; }

@media (max-width: 980px) {
  .hierarchy-editor-body { grid-template-columns: 1fr; overflow: auto; }
  .hierarchy-tree-panel { min-height: 360px; }
  .hierarchy-inspector { max-height: none; overflow: visible; }
  .hierarchy-editor-v2 .hierarchy-editor-head { flex-direction: column; }
}

/* =========================================================
   ANNOTATION UX 5.1 — compact theme picker + Mist
   ========================================================= */

.annotation-theme-control {
  position: relative;
  flex: 0 0 auto;
}

#toolbar .annotation-theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 11px;
  border-radius: 11px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}

.annotation-theme-btn-icon {
  font-size: 1rem;
  line-height: 1;
}

.annotation-theme-popover[hidden] {
  display: none !important;
}

.annotation-theme-popover {
  position: absolute;
  z-index: 13500;
  top: calc(100% + 9px);
  right: 0;
  width: 280px;
  padding: 13px;
  border: 1px solid var(--ann-menu-border, #dbe7f3);
  border-radius: 15px;
  background: var(--ann-menu-bg, #fff);
  color: var(--ann-text, #111827);
  box-shadow: 0 18px 46px rgba(15,23,42,.18);
}

.annotation-theme-title {
  margin: 1px 2px 10px;
  color: var(--ann-muted, #475569);
  font-size: .72rem;
  font-weight: 780;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.annotation-theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.annotation-theme-option {
  appearance: none;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 69px;
  padding: 8px 7px;
  border: 1px solid var(--ann-border, #d9dee7);
  border-radius: 11px;
  background: var(--ann-btn-bg, #fff);
  color: var(--ann-text, #111827);
  font: inherit;
  font-size: .76rem;
  font-weight: 680;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--ann-shadow-soft, 0 1px 2px rgba(15,23,42,.04));
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease;
}

.annotation-theme-option:hover {
  background: var(--ann-btn-hover-bg, #eef2f7);
  border-color: var(--ann-border-strong, #cbd5e1);
}

.annotation-theme-option.is-active,
.annotation-theme-option.active {
  border-color: var(--ann-chip-border-strong, #b8d0ee);
  background: var(--ann-btn-active-bg, #fff);
  color: var(--ann-btn-active-text, #1d4ed8);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, currentColor 18%, transparent);
}

.annotation-theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: 0 0 28px;
  border: 1px solid rgba(15,23,42,.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}

.annotation-theme-swatch--white {
  background: linear-gradient(135deg, #fff 0 58%, #eef5ff 58% 100%);
}

.annotation-theme-swatch--paper {
  background:
    linear-gradient(rgba(120,102,78,.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,102,78,.10) 1px, transparent 1px),
    #efe6d6;
  background-size: 7px 7px;
}

.annotation-theme-swatch--mist {
  background:
    linear-gradient(rgba(52,88,98,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(52,88,98,.08) 1px, transparent 1px),
    linear-gradient(135deg, #f8fbfc 0 52%, #e6eef1 52% 100%);
  background-size: 7px 7px, 7px 7px, 100% 100%;
}

/* Mist is deliberately light: Annotation contains many semantic colours and
   long text blocks, so the theme cools the workspace without fighting them. */
body.bg-mist {
  --ann-surface: #f7fafb;
  --ann-surface-soft: #eef4f5;
  --ann-surface-elevated: rgba(248, 251, 252, .965);
  --ann-border: #cbd9dd;
  --ann-border-strong: #b7cbd0;
  --ann-text: #17323a;
  --ann-text-soft: #405f68;
  --ann-muted: #637a81;

  --ann-toolbar-bg: rgba(232, 240, 242, .965);
  --ann-footer-bg: rgba(235, 242, 244, .965);

  --ann-switch-bg: #edf3f5;
  --ann-btn-bg: #f8fbfc;
  --ann-btn-hover-bg: #e8f0f2;
  --ann-btn-active-bg: #e0ecef;
  --ann-btn-active-text: #285966;

  --ann-menu-bg: #f7fafb;
  --ann-menu-border: #c9d9dd;

  --ann-chip-bg: #edf5f6;
  --ann-chip-border: #cadcdf;
  --ann-chip-border-strong: #a5c3c9;

  --ann-panel-soft: #eef4f5;
  --ann-panel-border: #cfdee1;

  --ann-rel-chip-bg: #edf3f5;
  --ann-rel-chip-border: #c9d7db;

  --ann-shadow-soft: 0 1px 2px rgba(35,66,76,.045);
  --ann-shadow-panel: 0 8px 24px rgba(35,66,76,.065);

  background-color: #e9eff1;
  background-image:
    radial-gradient(900px 520px at 10% -8%, rgba(255,255,255,.58), transparent 65%),
    radial-gradient(780px 520px at 94% 2%, rgba(191,215,220,.20), transparent 68%),
    linear-gradient(rgba(52,88,98,.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(52,88,98,.026) 1px, transparent 1px);
  background-size: auto, auto, 20px 20px, 20px 20px;
  background-attachment: fixed;
  color: var(--ann-text);
}

/* Header tabs: cool, quiet and close to the white theme rather than a dark UI. */
body.bg-mist #toolbar .tabs .tab-button,
body.bg-mist #toolbar .tabs .tab-button:not(.active):visited,
body.bg-mist #toolbar .tabs .tab-button:not(.active):focus,
body.bg-mist #toolbar .tabs .tab-button:not(.active):focus-visible,
body.bg-mist #toolbar .tabs .tab-button:not(.active):active {
  background: #f4f8f9 !important;
  border-color: #cbd9dd !important;
  color: #405d66 !important;
  box-shadow: 0 1px 2px rgba(35,66,76,.035) !important;
  text-decoration: none !important;
  outline: none !important;
  transform: none !important;
}

body.bg-mist #toolbar .tabs .tab-button:hover {
  background: #ebf2f4 !important;
  border-color: #b7cbd0 !important;
  color: #244851 !important;
}

body.bg-mist #toolbar .tabs .tab-button.active,
body.bg-mist #toolbar .tabs .tab-button[aria-current="page"],
body.bg-mist #toolbar .tabs .tab-button.active:visited,
body.bg-mist #toolbar .tabs .tab-button.active:focus,
body.bg-mist #toolbar .tabs .tab-button.active:focus-visible,
body.bg-mist #toolbar .tabs .tab-button.active:active {
  background: #e1edf0 !important;
  border-color: #abc5cb !important;
  color: #214e59 !important;
  box-shadow: 0 1px 2px rgba(35,66,76,.055) !important;
  text-decoration: none !important;
  outline: none !important;
  transform: none !important;
}

/* Reading surface and bilingual text. */
body.bg-mist .qa-segment-row,
body.bg-mist .qa-ann {
  border-bottom-color: rgba(88,119,127,.20);
}

body.bg-mist .segment-text,
body.bg-mist .segment-speaker,
body.bg-mist .translation-text {
  color: var(--ann-text);
}

body.bg-mist .segment-translations,
body.bg-mist .annotation-text-i18n {
  color: var(--ann-muted);
  border-left-color: #bfd0d4;
}

body.bg-mist .lang-pill,
body.bg-mist .tag-i18n-lang,
body.bg-mist .tag-i18n-chip,
body.bg-mist .segment-id-tag,
body.bg-mist .relation-chip,
body.bg-mist .rel-id-badge {
  border-color: var(--ann-chip-border);
  color: var(--ann-text-soft);
}

body.bg-mist .lang-pill,
body.bg-mist .tag-i18n-lang,
body.bg-mist .segment-id-tag,
body.bg-mist .rel-id-badge {
  background: rgba(248,251,252,.84);
}

body.bg-mist .tag-i18n-chip,
body.bg-mist .relation-chip {
  background: rgba(237,245,246,.90);
}

/* Functional Annotation focus stays visible but calm. */
body.bg-mist .qa-ann.is-ann-hovered > .qa-ann-inner,
body.bg-mist .qa-ann.is-ann-span-hovered > .qa-ann-inner {
  background: rgba(78,125,137,.070);
  box-shadow: inset 3px 0 0 rgba(78,125,137,.34);
}

body.bg-mist .qa-ann.is-ann-focused > .qa-ann-inner {
  background: rgba(63,111,124,.085);
  box-shadow: inset 3px 0 0 rgba(63,111,124,.47), 0 0 0 1px rgba(63,111,124,.10);
}

body.bg-mist .qa-text-fragment.is-ann-hovered-span {
  background: rgba(84,128,139,.13);
}

body.bg-mist .qa-text-fragment.is-ann-focused-span {
  background: rgba(66,115,128,.16);
}

/* Forms, popovers and hierarchy surfaces follow the cool neutral palette. */
body.bg-mist input:not([type="color"]):not([type="checkbox"]):not([type="radio"]),
body.bg-mist textarea,
body.bg-mist select,
body.bg-mist .select2-container--default .select2-selection--single,
body.bg-mist .hierarchy-tree-row,
body.bg-mist .hierarchy-related-chip {
  background: var(--ann-btn-bg);
  border-color: var(--ann-border);
  color: var(--ann-text);
}

body.bg-mist input::placeholder,
body.bg-mist textarea::placeholder {
  color: #7b8f95;
}

body.bg-mist .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--ann-text);
}

body.bg-mist .select2-dropdown,
body.bg-mist .select2-results {
  background: var(--ann-menu-bg) !important;
  border-color: var(--ann-border) !important;
  color: var(--ann-text) !important;
}

body.bg-mist .select2-results__option {
  color: var(--ann-text-soft);
}

body.bg-mist .select2-results__option--highlighted {
  background: var(--ann-btn-hover-bg) !important;
  color: var(--ann-text) !important;
}

body.bg-mist .hierarchy-tree-row:hover,
body.bg-mist .hierarchy-related-chip:hover {
  background: var(--ann-btn-hover-bg);
  border-color: var(--ann-border-strong);
}

body.bg-mist .annotation-theme-popover {
  box-shadow: 0 18px 42px rgba(35,66,76,.16);
}

@media (max-width: 720px) {
  .annotation-theme-popover {
    right: auto;
    left: 0;
    width: min(280px, calc(100vw - 28px));
  }

  .annotation-theme-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}



/* =========================================================
   ANNOTATION UX 5.2 — Sage / Stone / Lavender
   Three light alternatives that preserve semantic tag colours.
   ========================================================= */

.annotation-theme-swatch--sage {
  background:
    linear-gradient(rgba(74,102,82,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74,102,82,.07) 1px, transparent 1px),
    linear-gradient(135deg, #fbfcf8 0 52%, #e5ebe1 52% 100%);
  background-size: 7px 7px, 7px 7px, 100% 100%;
}

.annotation-theme-swatch--stone {
  background: linear-gradient(135deg, #fbf9f5 0 50%, #e5e0d8 50% 100%);
}

.annotation-theme-swatch--lavender {
  background:
    radial-gradient(circle at 28% 30%, rgba(255,255,255,.72) 0 18%, transparent 19%),
    linear-gradient(135deg, #fcfbff 0 52%, #e9e5f2 52% 100%);
}

body.bg-sage {
  --ann-surface: #fbfcf8;
  --ann-surface-soft: #f0f4ed;
  --ann-surface-elevated: rgba(251,252,248,.968);
  --ann-border: #ccd7c9;
  --ann-border-strong: #b8c8b5;
  --ann-text: #25352c;
  --ann-text-soft: #4d6154;
  --ann-muted: #6c7b70;
  --ann-toolbar-bg: rgba(234,240,230,.965);
  --ann-footer-bg: rgba(237,242,234,.965);
  --ann-switch-bg: #eff4ec;
  --ann-btn-bg: #fafcf8;
  --ann-btn-hover-bg: #e9f0e6;
  --ann-btn-active-bg: #e3ece0;
  --ann-btn-active-text: #486151;
  --ann-menu-bg: #fbfcf8;
  --ann-menu-border: #c9d5c6;
  --ann-chip-bg: #eef4eb;
  --ann-chip-border: #c9d7c6;
  --ann-chip-border-strong: #a9c0a5;
  --ann-panel-soft: #f0f4ed;
  --ann-panel-border: #d0dbcd;
  --ann-rel-chip-bg: #eef2ec;
  --ann-rel-chip-border: #cbd5c8;
  --ann-shadow-soft: 0 1px 2px rgba(43,64,49,.045);
  --ann-shadow-panel: 0 8px 24px rgba(43,64,49,.06);
  background-color: #edf1e9;
  background-image:
    radial-gradient(900px 520px at 8% -8%, rgba(255,255,255,.62), transparent 65%),
    radial-gradient(820px 520px at 96% 0%, rgba(189,207,184,.20), transparent 68%);
  background-attachment: fixed;
  color: var(--ann-text);
}

body.bg-stone {
  --ann-surface: #faf8f4;
  --ann-surface-soft: #f1ede7;
  --ann-surface-elevated: rgba(250,248,244,.97);
  --ann-border: #d5cec4;
  --ann-border-strong: #c2b8aa;
  --ann-text: #312f2b;
  --ann-text-soft: #5b5750;
  --ann-muted: #716c64;
  --ann-toolbar-bg: rgba(234,230,223,.968);
  --ann-footer-bg: rgba(237,233,226,.968);
  --ann-switch-bg: #f0ece6;
  --ann-btn-bg: #faf8f4;
  --ann-btn-hover-bg: #eee9e2;
  --ann-btn-active-bg: #e8e2d9;
  --ann-btn-active-text: #665e52;
  --ann-menu-bg: #faf8f4;
  --ann-menu-border: #d4cdc3;
  --ann-chip-bg: #f2eee8;
  --ann-chip-border: #d7cfc5;
  --ann-chip-border-strong: #beb2a3;
  --ann-panel-soft: #f1ede7;
  --ann-panel-border: #d8d0c6;
  --ann-rel-chip-bg: #f0ece6;
  --ann-rel-chip-border: #d4ccc1;
  --ann-shadow-soft: 0 1px 2px rgba(58,52,44,.045);
  --ann-shadow-panel: 0 8px 24px rgba(58,52,44,.06);
  background-color: #ece8e1;
  background-image:
    radial-gradient(880px 520px at 10% -8%, rgba(255,255,255,.60), transparent 65%),
    radial-gradient(780px 520px at 95% 1%, rgba(211,202,188,.18), transparent 68%);
  background-attachment: fixed;
  color: var(--ann-text);
}

body.bg-lavender {
  --ann-surface: #fbfaff;
  --ann-surface-soft: #f1eff7;
  --ann-surface-elevated: rgba(251,250,255,.97);
  --ann-border: #d4d0df;
  --ann-border-strong: #bfb8d0;
  --ann-text: #302f45;
  --ann-text-soft: #57546e;
  --ann-muted: #726e84;
  --ann-toolbar-bg: rgba(237,235,244,.968);
  --ann-footer-bg: rgba(240,238,246,.968);
  --ann-switch-bg: #f1eff7;
  --ann-btn-bg: #fbfaff;
  --ann-btn-hover-bg: #ece9f4;
  --ann-btn-active-bg: #e6e2f0;
  --ann-btn-active-text: #62577d;
  --ann-menu-bg: #fbfaff;
  --ann-menu-border: #d2cedd;
  --ann-chip-bg: #f1eef8;
  --ann-chip-border: #d6d0e3;
  --ann-chip-border-strong: #b9aecf;
  --ann-panel-soft: #f1eff7;
  --ann-panel-border: #d8d3e2;
  --ann-rel-chip-bg: #f0eef5;
  --ann-rel-chip-border: #d4cfdd;
  --ann-shadow-soft: 0 1px 2px rgba(53,48,75,.045);
  --ann-shadow-panel: 0 8px 24px rgba(53,48,75,.06);
  background-color: #efedf5;
  background-image:
    radial-gradient(900px 520px at 9% -8%, rgba(255,255,255,.65), transparent 65%),
    radial-gradient(800px 520px at 95% 1%, rgba(204,197,222,.20), transparent 68%);
  background-attachment: fixed;
  color: var(--ann-text);
}

/* Shared reading surface / controls for the three light themes. */
body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button,
body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button:not(.active):visited,
body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button:not(.active):focus,
body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button:not(.active):focus-visible,
body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button:not(.active):active {
  background: var(--ann-btn-bg) !important;
  border-color: var(--ann-border) !important;
  color: var(--ann-text-soft) !important;
  box-shadow: var(--ann-shadow-soft) !important;
  text-decoration: none !important;
  outline: none !important;
  transform: none !important;
}

body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button:hover {
  background: var(--ann-btn-hover-bg) !important;
  border-color: var(--ann-border-strong) !important;
  color: var(--ann-text) !important;
}

body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button.active,
body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button[aria-current="page"],
body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button.active:visited,
body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button.active:focus,
body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button.active:focus-visible,
body:is(.bg-sage,.bg-stone,.bg-lavender) #toolbar .tabs .tab-button.active:active {
  background: var(--ann-btn-active-bg) !important;
  border-color: var(--ann-chip-border-strong) !important;
  color: var(--ann-btn-active-text) !important;
  box-shadow: var(--ann-shadow-soft) !important;
  text-decoration: none !important;
  outline: none !important;
  transform: none !important;
}

body:is(.bg-sage,.bg-stone,.bg-lavender) .qa-segment-row,
body:is(.bg-sage,.bg-stone,.bg-lavender) .qa-ann {
  border-bottom-color: color-mix(in oklab, var(--ann-border) 76%, transparent);
}

body:is(.bg-sage,.bg-stone,.bg-lavender) .segment-text,
body:is(.bg-sage,.bg-stone,.bg-lavender) .segment-speaker,
body:is(.bg-sage,.bg-stone,.bg-lavender) .translation-text {
  color: var(--ann-text);
}

body:is(.bg-sage,.bg-stone,.bg-lavender) .segment-translations,
body:is(.bg-sage,.bg-stone,.bg-lavender) .annotation-text-i18n {
  color: var(--ann-muted);
  border-left-color: var(--ann-border-strong);
}

body:is(.bg-sage,.bg-stone,.bg-lavender) .lang-pill,
body:is(.bg-sage,.bg-stone,.bg-lavender) .tag-i18n-lang,
body:is(.bg-sage,.bg-stone,.bg-lavender) .tag-i18n-chip,
body:is(.bg-sage,.bg-stone,.bg-lavender) .segment-id-tag,
body:is(.bg-sage,.bg-stone,.bg-lavender) .relation-chip,
body:is(.bg-sage,.bg-stone,.bg-lavender) .rel-id-badge {
  border-color: var(--ann-chip-border);
  color: var(--ann-text-soft);
}

body:is(.bg-sage,.bg-stone,.bg-lavender) .lang-pill,
body:is(.bg-sage,.bg-stone,.bg-lavender) .tag-i18n-lang,
body:is(.bg-sage,.bg-stone,.bg-lavender) .segment-id-tag,
body:is(.bg-sage,.bg-stone,.bg-lavender) .rel-id-badge {
  background: color-mix(in oklab, var(--ann-surface) 90%, transparent);
}

body:is(.bg-sage,.bg-stone,.bg-lavender) .tag-i18n-chip,
body:is(.bg-sage,.bg-stone,.bg-lavender) .relation-chip {
  background: var(--ann-chip-bg);
}

/* Functional focus only; semantic colours of tags/relations stay untouched. */
body.bg-sage .qa-ann.is-ann-hovered > .qa-ann-inner,
body.bg-sage .qa-ann.is-ann-span-hovered > .qa-ann-inner { background: rgba(90,119,96,.065); box-shadow: inset 3px 0 0 rgba(90,119,96,.30); }
body.bg-sage .qa-ann.is-ann-focused > .qa-ann-inner { background: rgba(78,108,85,.085); box-shadow: inset 3px 0 0 rgba(78,108,85,.46), 0 0 0 1px rgba(78,108,85,.09); }
body.bg-sage .qa-text-fragment.is-ann-hovered-span { background: rgba(93,121,99,.12); }
body.bg-sage .qa-text-fragment.is-ann-focused-span { background: rgba(78,108,85,.16); }

body.bg-stone .qa-ann.is-ann-hovered > .qa-ann-inner,
body.bg-stone .qa-ann.is-ann-span-hovered > .qa-ann-inner { background: rgba(120,109,94,.060); box-shadow: inset 3px 0 0 rgba(120,109,94,.28); }
body.bg-stone .qa-ann.is-ann-focused > .qa-ann-inner { background: rgba(101,91,78,.080); box-shadow: inset 3px 0 0 rgba(101,91,78,.44), 0 0 0 1px rgba(101,91,78,.09); }
body.bg-stone .qa-text-fragment.is-ann-hovered-span { background: rgba(126,113,96,.115); }
body.bg-stone .qa-text-fragment.is-ann-focused-span { background: rgba(105,94,80,.15); }

body.bg-lavender .qa-ann.is-ann-hovered > .qa-ann-inner,
body.bg-lavender .qa-ann.is-ann-span-hovered > .qa-ann-inner { background: rgba(105,94,139,.058); box-shadow: inset 3px 0 0 rgba(105,94,139,.28); }
body.bg-lavender .qa-ann.is-ann-focused > .qa-ann-inner { background: rgba(91,79,126,.078); box-shadow: inset 3px 0 0 rgba(91,79,126,.43), 0 0 0 1px rgba(91,79,126,.09); }
body.bg-lavender .qa-text-fragment.is-ann-hovered-span { background: rgba(108,96,143,.11); }
body.bg-lavender .qa-text-fragment.is-ann-focused-span { background: rgba(92,80,128,.15); }

body:is(.bg-sage,.bg-stone,.bg-lavender) input:not([type="color"]):not([type="checkbox"]):not([type="radio"]),
body:is(.bg-sage,.bg-stone,.bg-lavender) textarea,
body:is(.bg-sage,.bg-stone,.bg-lavender) select,
body:is(.bg-sage,.bg-stone,.bg-lavender) .select2-container--default .select2-selection--single,
body:is(.bg-sage,.bg-stone,.bg-lavender) .hierarchy-tree-row,
body:is(.bg-sage,.bg-stone,.bg-lavender) .hierarchy-related-chip {
  background: var(--ann-btn-bg);
  border-color: var(--ann-border);
  color: var(--ann-text);
}

body:is(.bg-sage,.bg-stone,.bg-lavender) input::placeholder,
body:is(.bg-sage,.bg-stone,.bg-lavender) textarea::placeholder { color: var(--ann-muted); }

body:is(.bg-sage,.bg-stone,.bg-lavender) .select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--ann-text); }
body:is(.bg-sage,.bg-stone,.bg-lavender) .select2-dropdown,
body:is(.bg-sage,.bg-stone,.bg-lavender) .select2-results {
  background: var(--ann-menu-bg) !important;
  border-color: var(--ann-border) !important;
  color: var(--ann-text) !important;
}
body:is(.bg-sage,.bg-stone,.bg-lavender) .select2-results__option { color: var(--ann-text-soft); }
body:is(.bg-sage,.bg-stone,.bg-lavender) .select2-results__option--highlighted {
  background: var(--ann-btn-hover-bg) !important;
  color: var(--ann-text) !important;
}
body:is(.bg-sage,.bg-stone,.bg-lavender) .hierarchy-tree-row:hover,
body:is(.bg-sage,.bg-stone,.bg-lavender) .hierarchy-related-chip:hover {
  background: var(--ann-btn-hover-bg);
  border-color: var(--ann-border-strong);
}

@media (max-width: 720px) {
  .annotation-theme-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =========================================================
   ANNOTATION UX 5.3 — Theme consistency pass
   All six light themes share a subtle grid and theme-aware
   selection/highlight states so the workspace feels coherent.
   ========================================================= */

body.bg-white {
  --ann-selection-fill: #edf5ff;
  --ann-selection-ring: rgba(59, 130, 246, 0.18);
  --ann-selection-outline: #b9d6fb;
  --ann-selection-annotation-fill: rgba(59, 130, 246, 0.08);
  --ann-grid-line: rgba(148, 163, 184, 0.10);
  background-color: #f9fbfe;
  background-image:
    radial-gradient(920px 560px at 10% -10%, rgba(255,255,255,.96), transparent 68%),
    radial-gradient(760px 520px at 96% 2%, rgba(219,234,254,.38), transparent 70%),
    repeating-linear-gradient(0deg, var(--ann-grid-line) 0, var(--ann-grid-line) 1px, transparent 1px, transparent 16px),
    repeating-linear-gradient(90deg, var(--ann-grid-line) 0, var(--ann-grid-line) 1px, transparent 1px, transparent 16px);
  background-attachment: fixed;
}

body.bg-paper {
  --ann-selection-fill: #f3ead8;
  --ann-selection-ring: rgba(139, 111, 71, 0.14);
  --ann-selection-outline: #d7c5a4;
  --ann-selection-annotation-fill: rgba(139, 111, 71, 0.08);
}

body.bg-mist {
  --ann-selection-fill: #e6f0f3;
  --ann-selection-ring: rgba(79, 123, 134, 0.16);
  --ann-selection-outline: #bfd3d8;
  --ann-selection-annotation-fill: rgba(79, 123, 134, 0.08);
}

body.bg-sage {
  --ann-selection-fill: #eef4ec;
  --ann-selection-ring: rgba(100, 127, 104, 0.14);
  --ann-selection-outline: #cbd8c7;
  --ann-selection-annotation-fill: rgba(100, 127, 104, 0.075);
  --ann-grid-line: rgba(90, 119, 96, 0.075);
  background-image:
    radial-gradient(900px 520px at 8% -8%, rgba(255,255,255,.62), transparent 65%),
    radial-gradient(820px 520px at 96% 0%, rgba(189,207,184,.20), transparent 68%),
    repeating-linear-gradient(0deg, var(--ann-grid-line) 0, var(--ann-grid-line) 1px, transparent 1px, transparent 16px),
    repeating-linear-gradient(90deg, var(--ann-grid-line) 0, var(--ann-grid-line) 1px, transparent 1px, transparent 16px);
  background-attachment: fixed;
}

body.bg-stone {
  --ann-selection-fill: #f2ede6;
  --ann-selection-ring: rgba(122, 112, 98, 0.14);
  --ann-selection-outline: #d6c9b9;
  --ann-selection-annotation-fill: rgba(122, 112, 98, 0.075);
  --ann-grid-line: rgba(120, 109, 94, 0.075);
  background-image:
    radial-gradient(880px 520px at 10% -8%, rgba(255,255,255,.60), transparent 65%),
    radial-gradient(780px 520px at 95% 1%, rgba(211,202,188,.18), transparent 68%),
    repeating-linear-gradient(0deg, var(--ann-grid-line) 0, var(--ann-grid-line) 1px, transparent 1px, transparent 16px),
    repeating-linear-gradient(90deg, var(--ann-grid-line) 0, var(--ann-grid-line) 1px, transparent 1px, transparent 16px);
  background-attachment: fixed;
}

body.bg-lavender {
  --ann-selection-fill: #f1eef8;
  --ann-selection-ring: rgba(115, 103, 143, 0.14);
  --ann-selection-outline: #d7d1e6;
  --ann-selection-annotation-fill: rgba(115, 103, 143, 0.075);
  --ann-grid-line: rgba(108, 96, 143, 0.070);
  background-image:
    radial-gradient(900px 520px at 9% -8%, rgba(255,255,255,.65), transparent 65%),
    radial-gradient(800px 520px at 95% 1%, rgba(204,197,222,.20), transparent 68%),
    repeating-linear-gradient(0deg, var(--ann-grid-line) 0, var(--ann-grid-line) 1px, transparent 1px, transparent 16px),
    repeating-linear-gradient(90deg, var(--ann-grid-line) 0, var(--ann-grid-line) 1px, transparent 1px, transparent 16px);
  background-attachment: fixed;
}

body:is(.bg-white,.bg-paper,.bg-mist,.bg-sage,.bg-stone,.bg-lavender) .clickable-segment.selected {
  background-color: var(--ann-selection-fill);
  border-radius: 8px;
  box-shadow: 0 0 0 3px var(--ann-selection-ring);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

body:is(.bg-white,.bg-paper,.bg-mist,.bg-sage,.bg-stone,.bg-lavender) .qa-ann.selected,
body:is(.bg-white,.bg-paper,.bg-mist,.bg-sage,.bg-stone,.bg-lavender) .qa-ann.is-ann-focused > .qa-ann-inner {
  background-color: var(--ann-selection-annotation-fill);
}

body:is(.bg-white,.bg-paper,.bg-mist,.bg-sage,.bg-stone,.bg-lavender) .qa-ann.is-ann-focused > .qa-ann-inner {
  box-shadow: inset 3px 0 0 color-mix(in oklab, var(--ann-selection-outline) 72%, transparent), 0 0 0 1px color-mix(in oklab, var(--ann-selection-outline) 50%, transparent);
}

body.bg-sage .qa-text-fragment.is-ann-focused-span,
body.bg-stone .qa-text-fragment.is-ann-focused-span,
body.bg-lavender .qa-text-fragment.is-ann-focused-span,
body.bg-mist .qa-text-fragment.is-ann-focused-span,
body.bg-white .qa-text-fragment.is-ann-focused-span,
body.bg-paper .qa-text-fragment.is-ann-focused-span {
  outline: none;
}

/* =========================================================
   ANNOTATION UX 5.4 — Quick UX / General Tags save control
   ========================================================= */
.taxonomy-parent-editor {
  grid-template-columns: minmax(0, 1fr) max-content max-content;
}

.taxonomy-parent-input {
  min-width: 0;
  box-sizing: border-box;
}

.taxonomy-row-save.toolbar-button {
  height: 38px;
  min-height: 38px;
  min-width: 82px;
  padding: 0 15px;
  justify-content: center;
  border-radius: 10px;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1;
  box-shadow: 0 2px 7px rgba(37, 99, 235, 0.18);
}

.taxonomy-row-save.toolbar-button:hover {
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.23);
}

.taxonomy-row-clear.toolbar-button {
  height: 38px;
  min-height: 38px;
  border-radius: 10px;
}

@media (max-width: 900px) {
  .taxonomy-parent-editor {
    grid-template-columns: minmax(0, 1fr) max-content max-content;
  }

  .taxonomy-row-save.toolbar-button {
    min-width: 74px;
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* =========================================================
   ANNOTATION UX 5.5 — Compact two-row footer
   ========================================================= */

:root {
  --annotation-footer-h: 108px;
}

#annotation-footer {
  min-height: 0;
  padding: 0.42rem 0.7rem 0.46rem;
}

#annotation-footer .footer-inner {
  display: flex;
  flex-direction: column;
  gap: 0.34rem;
  min-width: 0;
}

#annotation-footer .footer-section {
  min-width: 0;
}

#annotation-footer .annotation-toolbar {
  gap: 0.5rem;
}

#annotation-footer .footer-secondary-section {
  padding-top: 0.34rem;
  border-top: 1px solid color-mix(in srgb, var(--ann-border, #d7dee8) 72%, transparent);
}

#annotation-footer .footer-secondary-toolbar,
#annotation-footer .data-import-tools.footer-secondary-toolbar {
  margin-top: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.42rem;
  min-width: 0;
  width: 100%;
  overflow: visible;
}

#annotation-footer .footer-secondary-toolbar > * {
  flex: 0 0 auto;
}

#annotation-footer .footer-secondary-toolbar .tag-view-mode {
  margin-right: 0.08rem;
}

#annotation-footer .footer-popover-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  overflow: visible;
}

#annotation-footer .footer-popover-toggle {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 12px;
  white-space: nowrap;
}

#annotation-footer .footer-popover-toggle.is-open {
  background: var(--ann-btn-active-bg, #eaf3ff);
  border-color: var(--ann-chip-border-strong, #afc8e6);
  color: var(--ann-btn-active-text, #244b77);
}

#annotation-footer .footer-popover-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 2600;
  width: 290px;
  max-width: min(360px, calc(100vw - 24px));
  padding: 9px;
  box-sizing: border-box;
  background: var(--ann-menu-bg, #fff);
  border: 1px solid var(--ann-menu-border, #dbe7f3);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

#annotation-footer .footer-popover-panel[hidden] {
  display: none !important;
}

#annotation-footer .footer-relations-panel {
  width: 350px;
}

#annotation-footer .footer-tools-panel {
  width: 270px;
}

#annotation-footer .footer-popover-heading {
  padding: 2px 4px 8px;
  margin-bottom: 7px;
  border-bottom: 1px solid color-mix(in srgb, var(--ann-menu-border, #dbe7f3) 72%, transparent);
  color: var(--ann-muted, #64748b);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

#annotation-footer .footer-popover-action,
#annotation-footer .footer-popover-panel .toolbar-button.footer-popover-action,
#annotation-footer .footer-popover-panel .relation-filter-btn.footer-popover-action,
#annotation-footer .footer-popover-panel .relation-arrows-toggle-btn.footer-popover-action {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 38px;
  margin: 0;
  padding: 7px 10px;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ann-text, #1f2937);
  box-shadow: none;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

#annotation-footer .footer-popover-action:hover,
#annotation-footer .footer-popover-panel .toolbar-button.footer-popover-action:hover,
#annotation-footer .footer-popover-panel .relation-filter-btn.footer-popover-action:hover,
#annotation-footer .footer-popover-panel .relation-arrows-toggle-btn.footer-popover-action:hover {
  background: var(--ann-btn-hover-bg, #f4f7fb);
  border-color: var(--ann-border, #d7dee8);
}

#annotation-footer .footer-popover-action.is-active,
#annotation-footer .footer-popover-panel .relation-filter-btn.footer-popover-action.is-active,
#annotation-footer .footer-popover-panel .relation-arrows-toggle-btn.footer-popover-action.is-active {
  background: var(--ann-btn-active-bg, #eaf3ff);
  border-color: var(--ann-chip-border-strong, #afc8e6);
  color: var(--ann-btn-active-text, #244b77);
}

#annotation-footer .footer-tools-panel .footer-popover-action + .footer-popover-action {
  margin-top: 2px;
}

#annotation-footer .footer-hidden-file-input {
  display: none !important;
}

#annotation-footer .footer-relation-filter {
  display: block;
  width: 100%;
}

/* Filtr relacji staje się częścią panelu „Relacje”, zamiast tworzyć kolejny
   niezależny popover nad stopką. */
#annotation-footer .footer-relations-panel .relation-filter-menu {
  position: static;
  width: 100%;
  min-width: 0;
  max-width: none !important;
  max-height: min(42vh, 360px);
  margin: 5px 0 8px;
  padding: 8px;
  border-radius: 10px;
  box-shadow: none;
  background: color-mix(in srgb, var(--ann-menu-bg, #fff) 92%, var(--ann-btn-hover-bg, #f4f7fb));
}

#annotation-footer .footer-relations-panel .relation-filter-menu::after {
  display: none;
}

#annotation-footer .footer-setting-block {
  display: block;
  width: 100%;
  margin-top: 2px;
}

#annotation-footer .footer-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  margin-top: 4px;
  padding: 7px 5px 2px;
  border-top: 1px solid color-mix(in srgb, var(--ann-menu-border, #dbe7f3) 72%, transparent);
}

#annotation-footer .footer-setting-label {
  color: var(--ann-muted, #64748b);
  font-size: 0.82rem;
  font-weight: 650;
}

#annotation-footer .footer-relations-panel .relation-display-toggle-wrap {
  min-height: 32px;
  border-radius: 9px;
  background: var(--ann-btn-bg, #fff);
  border-color: var(--ann-border, #d7dee8);
}

#annotation-footer .footer-relations-panel .relation-display-toggle-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.8rem;
}

#annotation-footer .footer-taxonomy-tools {
  display: none;
}

/* 1366px pozostaje pełnym, dwurzędowym paskiem. Na typowym mniejszym
   laptopie odzyskujemy miejsce bez dokładania trzeciego rzędu. */
@media (max-width: 1180px) {
  #annotation-footer .annotation-group.type-select {
    flex-basis: 260px;
    min-width: 260px;
    max-width: 260px;
  }

  #annotation-footer .annotation-group.custom-tag {
    flex-basis: 155px;
    max-width: 165px;
  }

  #annotation-footer .annotation-group.flex-grow {
    min-width: 220px;
  }

  #annotation-footer .tag-view-mode-label {
    display: none;
  }

  #annotation-footer .footer-taxonomy-primary {
    display: none !important;
  }

  #annotation-footer .footer-taxonomy-tools {
    display: flex;
  }
}

@media (max-width: 980px) {
  #annotation-footer {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  #annotation-footer .annotation-toolbar {
    gap: 0.34rem;
  }

  #annotation-footer .annotation-group.type-select {
    flex-basis: 220px;
    min-width: 220px;
    max-width: 220px;
  }

  #annotation-footer .annotation-group.custom-tag {
    flex-basis: 135px;
    max-width: 140px;
  }

  #annotation-footer .annotation-group.flex-grow {
    min-width: 190px;
  }

  #annotation-footer .footer-secondary-toolbar {
    gap: 0.3rem;
    overflow: visible;
  }

  #annotation-footer .footer-popover-toggle,
  #annotation-footer .tag-filter-btn,
  #annotation-footer .translations-menu-btn,
  #annotation-footer #mediaToolbarBtn,
  #annotation-footer #exportJsonBtn {
    min-height: 36px;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 0.84rem;
  }
}

/* Higher-specificity reset for legacy footer button rules inside Tools. */
#annotation-footer #downloadAutosaveBtn.footer-popover-action,
#annotation-footer #showTranscriptBtn.footer-popover-action,
#annotation-footer #showChangeHistoryBtn.footer-popover-action {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ann-text, #1f2937);
  box-shadow: none;
  justify-content: flex-start;
  font-size: 0.88rem;
}

#annotation-footer #downloadAutosaveBtn.footer-popover-action:hover,
#annotation-footer #showTranscriptBtn.footer-popover-action:hover,
#annotation-footer #showChangeHistoryBtn.footer-popover-action:hover {
  background: var(--ann-btn-hover-bg, #f4f7fb);
  border-color: var(--ann-border, #d7dee8);
}

#annotation-footer .footer-popover-toggle.has-active-state:not(.is-open) {
  border-color: var(--ann-chip-border-strong, #afc8e6);
  color: var(--ann-btn-active-text, #244b77);
}

/* =========================================================
   ANNOTATION UX 5.5a — Relation canvas resize / root background fix
   Prevents a stale relation SVG width from revealing the neutral html canvas
   after window resize, split-screen use or browser zoom changes.
   ========================================================= */

html.bg-white {
  background-color: #f9fbfe;
  background-image:
    radial-gradient(920px 560px at 10% -10%, rgba(255,255,255,.96), transparent 68%),
    radial-gradient(760px 520px at 96% 2%, rgba(219,234,254,.38), transparent 70%),
    repeating-linear-gradient(0deg, rgba(148,163,184,.10) 0, rgba(148,163,184,.10) 1px, transparent 1px, transparent 16px),
    repeating-linear-gradient(90deg, rgba(148,163,184,.10) 0, rgba(148,163,184,.10) 1px, transparent 1px, transparent 16px);
  background-attachment: fixed;
}

html.bg-paper {
  background-color: #efe6d6;
  background-image:
    repeating-linear-gradient(0deg, rgba(120,102,78,.04) 0, rgba(120,102,78,.04) 1px, transparent 1px, transparent 16px),
    repeating-linear-gradient(90deg, rgba(120,102,78,.04) 0, rgba(120,102,78,.04) 1px, transparent 1px, transparent 16px);
  background-attachment: fixed;
}

html.bg-mist {
  background-color: #e9eff1;
  background-image:
    radial-gradient(900px 520px at 10% -8%, rgba(255,255,255,.58), transparent 65%),
    radial-gradient(780px 520px at 94% 2%, rgba(191,215,220,.20), transparent 68%),
    linear-gradient(rgba(52,88,98,.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(52,88,98,.026) 1px, transparent 1px);
  background-size: auto, auto, 20px 20px, 20px 20px;
  background-attachment: fixed;
}

html.bg-sage {
  background-color: #edf1e9;
  background-image:
    radial-gradient(900px 520px at 8% -8%, rgba(255,255,255,.62), transparent 65%),
    radial-gradient(820px 520px at 96% 0%, rgba(189,207,184,.20), transparent 68%),
    repeating-linear-gradient(0deg, rgba(90,119,96,.075) 0, rgba(90,119,96,.075) 1px, transparent 1px, transparent 16px),
    repeating-linear-gradient(90deg, rgba(90,119,96,.075) 0, rgba(90,119,96,.075) 1px, transparent 1px, transparent 16px);
  background-attachment: fixed;
}

html.bg-stone {
  background-color: #ece8e1;
  background-image:
    radial-gradient(880px 520px at 10% -8%, rgba(255,255,255,.60), transparent 65%),
    radial-gradient(780px 520px at 95% 1%, rgba(211,202,188,.18), transparent 68%),
    repeating-linear-gradient(0deg, rgba(120,109,94,.075) 0, rgba(120,109,94,.075) 1px, transparent 1px, transparent 16px),
    repeating-linear-gradient(90deg, rgba(120,109,94,.075) 0, rgba(120,109,94,.075) 1px, transparent 1px, transparent 16px);
  background-attachment: fixed;
}

html.bg-lavender {
  background-color: #efedf5;
  background-image:
    radial-gradient(900px 520px at 9% -8%, rgba(255,255,255,.65), transparent 65%),
    radial-gradient(800px 520px at 95% 1%, rgba(204,197,222,.20), transparent 68%),
    repeating-linear-gradient(0deg, rgba(108,96,143,.070) 0, rgba(108,96,143,.070) 1px, transparent 1px, transparent 16px),
    repeating-linear-gradient(90deg, rgba(108,96,143,.070) 0, rgba(108,96,143,.070) 1px, transparent 1px, transparent 16px);
  background-attachment: fixed;
}


/* =========================================================
   TMM Tabular Import 2.0 — non-blocking import status
   ========================================================= */
.annotation-import-notice {
  position: fixed;
  right: 16px;
  bottom: calc(var(--annotation-footer-h, 96px) + 14px);
  z-index: 10050;
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 14px;
  border: 1px solid rgba(86, 104, 128, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  color: #233044;
  font-size: 13px;
  line-height: 1.45;
  backdrop-filter: blur(8px);
}

.annotation-import-notice[hidden] { display: none !important; }
.annotation-import-notice.is-success { border-color: rgba(22, 163, 74, 0.34); }
.annotation-import-notice.is-warning { border-color: rgba(217, 119, 6, 0.38); }
.annotation-import-notice.is-error { border-color: rgba(220, 38, 38, 0.42); }

/* ==========================================================
   MACROSTRUCTURES 5.8 — Annotation UI
   Subtle membership badges + opt-in selection/focus layers.
========================================================== */

#annotation-footer .footer-macrostructures-panel {
  width: 310px;
}

#annotation-footer .footer-macrostructures-wrap .footer-popover-toggle {
  gap: 7px;
}

.macrostructures-toolbar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ann-btn-active-bg, #eaf3ff);
  border: 1px solid var(--ann-chip-border-strong, #afc8e6);
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.macrostructure-panel-summary {
  padding: 3px 5px 8px;
  color: var(--ann-muted, #64748b);
  font-size: 0.82rem;
  line-height: 1.35;
}

.macrostructure-panel-divider {
  height: 1px;
  margin: 8px 4px 10px;
  background: color-mix(in srgb, var(--ann-menu-border, #dbe7f3) 76%, transparent);
}

.macrostructure-panel-subheading {
  padding: 0 5px 8px;
  color: var(--ann-muted, #64748b);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.macrostructure-panel-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#annotation-footer .macrostructure-shortcut-btn.footer-popover-action {
  min-height: 36px;
  padding: 8px 10px;
  justify-content: center;
  border-color: var(--ann-border, #d7dee8);
  border-radius: 11px;
  background: color-mix(in srgb, var(--ann-surface, #fff) 88%, var(--ann-btn-hover-bg, #f4f7fb));
  color: var(--ann-text, #1f2937);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  white-space: normal;
}

#annotation-footer .macrostructure-shortcut-btn.footer-popover-action:hover {
  background: var(--ann-btn-hover-bg, #f4f7fb);
  border-color: var(--ann-chip-border-strong, #afc8e6);
}

/* Membership markers are intentionally smaller and quieter than relation chips. */
.macrostructure-badges {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
}

.macrostructure-badge {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 29px;
  height: 21px;
  padding: 0 6px;
  border: 1px solid color-mix(in srgb, var(--ann-chip-border-strong, #afc8e6) 82%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ann-btn-active-bg, #eaf3ff) 68%, var(--ann-surface, #fff));
  color: var(--ann-btn-active-text, #244b77);
  font: inherit;
  font-size: 0.69rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.13s ease, border-color 0.13s ease, transform 0.13s ease, opacity 0.13s ease;
}

.macrostructure-badge:hover {
  background: var(--ann-btn-active-bg, #eaf3ff);
  border-color: var(--ann-chip-border-strong, #afc8e6);
  transform: translateY(-1px);
}

.macrostructure-badge.is-active {
  background: color-mix(in srgb, var(--ann-btn-active-bg, #eaf3ff) 72%, #cfe2ff);
  border-color: color-mix(in srgb, var(--ann-chip-border-strong, #afc8e6) 72%, #5e8ec5);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ann-chip-border-strong, #afc8e6) 28%, transparent);
}

.macrostructure-badge--more {
  min-width: 27px;
  color: var(--ann-muted, #64748b);
  background: color-mix(in srgb, var(--ann-surface, #fff) 82%, var(--ann-btn-hover-bg, #f4f7fb));
}

body.macrostructure-selection-mode .macrostructure-badge {
  pointer-events: none;
  opacity: 0.38;
}

/* Creation/editing mode. The whole annotation card is the selection target. */
body.macrostructure-selection-mode .qa-ann {
  cursor: pointer;
}

body.macrostructure-selection-mode .qa-ann:hover {
  background: color-mix(in srgb, var(--ann-btn-hover-bg, #f4f7fb) 72%, transparent);
  border-radius: 8px;
}

.qa-ann.macrostructure-selection-selected {
  border-radius: 9px;
  background: color-mix(in srgb, var(--ann-btn-active-bg, #eaf3ff) 74%, transparent);
  box-shadow: inset 3px 0 0 var(--ann-btn-active-text, #244b77), 0 0 0 1px color-mix(in srgb, var(--ann-chip-border-strong, #afc8e6) 55%, transparent);
}

.qa-ann.macrostructure-selection-selected::after {
  content: "✓";
  position: absolute;
  top: 2px;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--ann-btn-active-text, #244b77);
  color: #fff;
  font-size: 0.73rem;
  font-weight: 800;
  z-index: 3;
}

.macrostructure-selection-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--annotation-footer-h, 108px) + 13px);
  transform: translateX(-50%);
  z-index: 4100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  width: min(760px, calc(100vw - 28px));
  padding: 11px 12px 11px 15px;
  box-sizing: border-box;
  border: 1px solid var(--ann-chip-border-strong, #afc8e6);
  border-radius: 14px;
  background: color-mix(in srgb, var(--ann-menu-bg, #fff) 95%, transparent);
  color: var(--ann-text, #1f2937);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(10px);
}

.macrostructure-selection-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.macrostructure-selection-copy strong {
  font-size: 0.9rem;
}

.macrostructure-selection-copy span {
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.83rem;
  font-weight: 750;
}

.macrostructure-selection-copy small {
  color: var(--ann-muted, #64748b);
  font-size: 0.73rem;
  line-height: 1.3;
}

.macrostructure-selection-actions {
  display: inline-flex;
  gap: 7px;
  flex: 0 0 auto;
}

.macrostructure-selection-actions button,
.macrostructure-modal-footer button,
.macrostructure-inspector-actions button {
  appearance: none;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--ann-border, #d7dee8);
  border-radius: 9px;
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #1f2937);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.macrostructure-selection-actions button:hover,
.macrostructure-modal-footer button:hover,
.macrostructure-inspector-actions button:hover {
  background: var(--ann-btn-hover-bg, #f4f7fb);
}

.macrostructure-selection-actions button.is-primary,
.macrostructure-modal-footer button.is-primary {
  background: var(--ann-btn-active-text, #244b77);
  border-color: var(--ann-btn-active-text, #244b77);
  color: #fff;
}

.macrostructure-selection-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Focus mode dims only other annotation cards — never the transcript itself. */
body.macrostructure-focus-mode .qa-ann.macrostructure-focus-other {
  opacity: 0.34;
  filter: saturate(0.72);
  transition: opacity 0.16s ease, filter 0.16s ease;
}

body.macrostructure-focus-mode .qa-ann.macrostructure-focus-other:hover {
  opacity: 0.72;
}

.qa-ann.macrostructure-focus-member {
  border-radius: 8px;
  background: color-mix(in srgb, var(--ann-btn-active-bg, #eaf3ff) 63%, transparent);
  box-shadow: inset 3px 0 0 var(--ann-btn-active-text, #244b77);
}

.qa-segment-row.macrostructure-focus-row {
  position: relative;
}

.qa-segment-row.macrostructure-focus-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ann-btn-active-text, #244b77) 62%, transparent);
}

@keyframes macrostructure-jump-pulse {
  0%, 100% { box-shadow: inset 3px 0 0 var(--ann-btn-active-text, #244b77); }
  45% { box-shadow: inset 3px 0 0 var(--ann-btn-active-text, #244b77), 0 0 0 4px color-mix(in srgb, var(--ann-btn-active-bg, #eaf3ff) 85%, transparent); }
}

.qa-ann.macrostructure-jump-pulse {
  animation: macrostructure-jump-pulse 1.15s ease;
}

/* Inspector is opt-in: it exists only while a macrostructure is focused. */
.macrostructure-inspector {
  position: fixed;
  top: calc(var(--toolbar-h, 60px) + 14px);
  right: 14px;
  bottom: calc(var(--annotation-footer-h, 108px) + 14px);
  z-index: 3500;
  display: flex;
  flex-direction: column;
  width: min(370px, calc(100vw - 28px));
  padding: 13px;
  box-sizing: border-box;
  border: 1px solid var(--ann-menu-border, #dbe7f3);
  border-radius: 16px;
  background: color-mix(in srgb, var(--ann-menu-bg, #fff) 97%, transparent);
  color: var(--ann-text, #1f2937);
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(12px);
}

.macrostructure-inspector-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.macrostructure-inspector-id,
.macrostructure-modal-kicker {
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.macrostructure-inspector h3,
.macrostructure-modal h2 {
  margin: 3px 0 0;
  color: var(--ann-text, #1f2937);
  font-size: 1.08rem;
  line-height: 1.25;
}

.macrostructure-inspector-close,
.macrostructure-modal-close {
  appearance: none;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  border: 1px solid var(--ann-border, #d7dee8);
  border-radius: 9px;
  background: var(--ann-surface, #fff);
  color: var(--ann-muted, #64748b);
  font: inherit;
  cursor: pointer;
}

.macrostructure-inspector-type {
  display: inline-flex;
  align-self: flex-start;
  margin-top: 9px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--ann-btn-active-bg, #eaf3ff);
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.76rem;
  font-weight: 750;
}

.macrostructure-inspector-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 9px;
  color: var(--ann-muted, #64748b);
  font-size: 0.77rem;
}

.macrostructure-inspector-notes {
  margin-top: 10px;
  padding: 8px 9px;
  border: 1px solid color-mix(in srgb, var(--ann-border, #d7dee8) 72%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--ann-btn-hover-bg, #f4f7fb) 62%, transparent);
  color: var(--ann-text, #1f2937);
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.macrostructure-inspector-section-title {
  margin: 13px 1px 7px;
  color: var(--ann-muted, #64748b);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.macrostructure-inspector-members {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.macrostructure-inspector-member {
  appearance: none;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid color-mix(in srgb, var(--ann-border, #d7dee8) 78%, transparent);
  border-radius: 10px;
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #1f2937);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.macrostructure-inspector-member:hover {
  background: var(--ann-btn-hover-bg, #f4f7fb);
  border-color: var(--ann-chip-border-strong, #afc8e6);
}

.macrostructure-inspector-member-head {
  display: flex;
  gap: 7px;
  align-items: baseline;
  margin-bottom: 3px;
}

.macrostructure-inspector-member-head strong {
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.76rem;
}

.macrostructure-inspector-member-head span {
  overflow: hidden;
  color: var(--ann-muted, #64748b);
  font-size: 0.75rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.macrostructure-inspector-member-text {
  display: block;
  color: var(--ann-text, #1f2937);
  font-size: 0.77rem;
  line-height: 1.35;
}

.macrostructure-inspector-overflow,
.macrostructure-inspector-empty {
  padding: 7px 2px;
  color: var(--ann-muted, #64748b);
  font-size: 0.77rem;
}

.macrostructure-inspector-actions {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--ann-border, #d7dee8) 72%, transparent);
}

.macrostructure-inspector-actions .is-danger {
  color: #9b2c2c;
}


/* 5.8a: compact, movable inspector used while editing macrostructure members. */
.macrostructure-inspector.is-editing {
  bottom: auto;
  width: min(410px, calc(100vw - 28px));
  max-height: min(68vh, 620px);
  padding: 10px;
  overflow: hidden;
}

.macrostructure-inspector.is-editing.is-collapsed {
  max-height: none;
}

.macrostructure-inspector.is-editing.is-expanded {
  display: flex;
  flex-direction: column;
}

.macrostructure-inspector-edit-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.macrostructure-inspector.is-dragging .macrostructure-inspector-edit-header {
  cursor: grabbing;
}

.macrostructure-inspector-edit-title {
  min-width: 0;
}

.macrostructure-inspector-edit-title strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--ann-text, #1f2937);
  font-size: 0.92rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.macrostructure-inspector-compact-toggle {
  appearance: none;
  flex: 0 0 auto;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--ann-border, #d7dee8);
  border-radius: 8px;
  background: var(--ann-surface, #fff);
  color: var(--ann-muted, #64748b);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 750;
  cursor: pointer;
}

.macrostructure-inspector-compact-toggle:hover {
  background: var(--ann-btn-hover-bg, #f4f7fb);
}

.macrostructure-inspector-edit-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 9px;
  background: var(--ann-btn-hover-bg, #f4f7fb);
}

.macrostructure-inspector-edit-summary span {
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.8rem;
  font-weight: 800;
}

.macrostructure-inspector-edit-summary small {
  min-width: 0;
  overflow: hidden;
  color: var(--ann-muted, #64748b);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.macrostructure-inspector-edit-details {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.macrostructure-inspector-edit-details .macrostructure-inspector-members {
  max-height: min(38vh, 360px);
}

.macrostructure-inspector-edit-hint {
  margin-top: 7px;
  color: var(--ann-muted, #64748b);
  font-size: 0.71rem;
  line-height: 1.35;
}

.macrostructure-inspector-edit-actions {
  margin-top: 8px;
  padding-top: 8px;
}

.macrostructure-inspector-edit-actions button.is-primary {
  background: var(--ann-btn-active-text, #244b77);
  border-color: var(--ann-btn-active-text, #244b77);
  color: #fff;
}

.macrostructure-inspector-edit-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Small chooser used only for annotations belonging to 3+ macrostructures. */
.macrostructure-badge-chooser {
  position: fixed;
  z-index: 4300;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
  padding: 7px;
  box-sizing: border-box;
  border: 1px solid var(--ann-menu-border, #dbe7f3);
  border-radius: 12px;
  background: var(--ann-menu-bg, #fff);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
}

.macrostructure-badge-chooser button {
  appearance: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ann-text, #1f2937);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.macrostructure-badge-chooser button:hover {
  background: var(--ann-btn-hover-bg, #f4f7fb);
  border-color: var(--ann-border, #d7dee8);
}

.macrostructure-badge-chooser strong {
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.76rem;
}

.macrostructure-badge-chooser span {
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Metadata modal appears after selection. */
.macrostructure-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(2px);
}

.macrostructure-modal {
  width: min(570px, 100%);
  max-height: calc(100vh - 36px);
  overflow: hidden;
  border: 1px solid var(--ann-menu-border, #dbe7f3);
  border-radius: 16px;
  background: var(--ann-menu-bg, #fff);
  color: var(--ann-text, #1f2937);
  box-shadow: 0 22px 64px rgba(15, 23, 42, 0.25);
}

.macrostructure-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 15px 11px;
  border-bottom: 1px solid var(--ann-border, #d7dee8);
}

.macrostructure-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 15px;
  overflow-y: auto;
}

.macrostructure-modal-body label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.macrostructure-modal-body label > span {
  color: var(--ann-text, #1f2937);
  font-size: 0.8rem;
  font-weight: 750;
}

.macrostructure-modal-body label small {
  color: var(--ann-muted, #64748b);
  font-weight: 500;
}

.macrostructure-modal-body input,
.macrostructure-modal-body textarea {
  width: 100%;
  padding: 9px 10px;
  box-sizing: border-box;
  border: 1px solid var(--ann-border, #d7dee8);
  border-radius: 9px;
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #1f2937);
  font: inherit;
  font-size: 0.88rem;
}

.macrostructure-modal-body textarea {
  resize: vertical;
}

.macrostructure-modal-body input:focus,
.macrostructure-modal-body textarea:focus {
  outline: none;
  border-color: var(--ann-chip-border-strong, #afc8e6);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ann-btn-active-bg, #eaf3ff) 70%, transparent);
}

.macrostructure-modal-member-summary {
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--ann-btn-hover-bg, #f4f7fb);
  color: var(--ann-muted, #64748b);
  font-size: 0.78rem;
  font-weight: 650;
}

.macrostructure-modal-error {
  padding: 8px 10px;
  border: 1px solid #e7b2b2;
  border-radius: 9px;
  background: #fff5f5;
  color: #9b2c2c;
  font-size: 0.79rem;
  line-height: 1.35;
}

.macrostructure-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  padding: 10px 15px 14px;
  border-top: 1px solid var(--ann-border, #d7dee8);
}

@media (max-width: 1100px) {
  .macrostructure-inspector {
    top: calc(var(--toolbar-h, 60px) + 10px);
    right: 10px;
    bottom: calc(var(--annotation-footer-h, 108px) + 10px);
    width: min(340px, calc(100vw - 20px));
  }
}

@media (max-width: 760px) {
  .macrostructure-selection-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }
  .macrostructure-selection-actions {
    justify-content: flex-end;
  }
  .macrostructure-selection-copy small {
    display: none;
  }
  .macrostructure-inspector {
    left: 10px;
    width: auto;
  }
}

/* Keep the two-row footer stable on smaller laptops after adding Macrostructures. */
@media (max-width: 1180px) {
  #annotation-footer .macrostructures-toolbar-label {
    display: none;
  }
  #annotation-footer #footerMacrostructuresToggle {
    min-width: 42px;
    padding-left: 9px;
    padding-right: 9px;
  }
}

/* 5.9: macrostructure relation workflow. Relations stay inside the inspector
   and modal; Annotation does not gain a second permanent arrow layer. */
.macrostructure-inspector-relation-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.macrostructure-inspector-relation-title > span:last-child {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--ann-btn-hover-bg, #f4f7fb);
  color: var(--ann-btn-active-text, #244b77);
  text-align: center;
}

.macrostructure-inspector-relations {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 7px;
  max-height: 210px;
  overflow-y: auto;
  padding-right: 2px;
}

.macrostructure-relation-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.macrostructure-relation-group-title {
  padding: 1px 2px;
  color: var(--ann-muted, #64748b);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.macrostructure-relation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
  align-items: stretch;
}

.macrostructure-relation-target,
.macrostructure-relation-edit {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--ann-border, #d7dee8) 78%, transparent);
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #1f2937);
  font: inherit;
  cursor: pointer;
}

.macrostructure-relation-target {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 9px;
  text-align: left;
}

.macrostructure-relation-target:hover,
.macrostructure-relation-edit:hover {
  border-color: var(--ann-chip-border-strong, #afc8e6);
  background: var(--ann-btn-hover-bg, #f4f7fb);
}

.macrostructure-relation-target strong {
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.76rem;
}

.macrostructure-relation-target > span:last-child {
  overflow: hidden;
  color: var(--ann-text, #1f2937);
  font-size: 0.76rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.macrostructure-relation-arrow {
  color: var(--ann-muted, #64748b);
  font-size: 0.84rem;
  font-weight: 850;
}

.macrostructure-relation-edit {
  width: 32px;
  border-radius: 9px;
  color: var(--ann-muted, #64748b);
  font-size: 0.84rem;
}

body.macrostructure-relation-selection-mode .macrostructure-badge.is-relation-source {
  opacity: 0.56;
  cursor: not-allowed;
}

body.macrostructure-relation-selection-mode .macrostructure-badge.is-relation-target-option {
  border-color: var(--ann-btn-active-text, #244b77);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ann-btn-active-bg, #eaf3ff) 78%, transparent);
}

body.macrostructure-relation-selection-mode .qa-ann {
  cursor: default;
}

.macrostructure-badge-chooser button.is-disabled,
.macrostructure-badge-chooser button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.macrostructure-relation-pick-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--annotation-footer-h, 108px) + 14px);
  z-index: 4450;
  display: grid;
  grid-template-columns: minmax(180px, auto) minmax(250px, 410px) auto;
  gap: 10px;
  align-items: center;
  width: min(850px, calc(100vw - 28px));
  padding: 10px 11px;
  box-sizing: border-box;
  border: 1px solid var(--ann-menu-border, #dbe7f3);
  border-radius: 14px;
  background: color-mix(in srgb, var(--ann-menu-bg, #fff) 98%, transparent);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
}

.macrostructure-relation-pick-copy {
  min-width: 0;
}

.macrostructure-relation-pick-copy strong,
.macrostructure-relation-pick-copy span {
  display: block;
}

.macrostructure-relation-pick-copy strong {
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.82rem;
}

.macrostructure-relation-pick-copy span {
  margin-top: 2px;
  color: var(--ann-muted, #64748b);
  font-size: 0.72rem;
  line-height: 1.3;
}

.macrostructure-relation-search-wrap {
  position: relative;
  min-width: 0;
}

.macrostructure-relation-search-wrap input {
  width: 100%;
  padding: 8px 9px;
  box-sizing: border-box;
  border: 1px solid var(--ann-border, #d7dee8);
  border-radius: 9px;
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #1f2937);
  font: inherit;
  font-size: 0.82rem;
}

.macrostructure-relation-target-results {
  position: absolute;
  right: 0;
  bottom: calc(100% + 7px);
  left: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--ann-menu-border, #dbe7f3);
  border-radius: 11px;
  background: var(--ann-menu-bg, #fff);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.17);
}

.macrostructure-relation-target-results button {
  appearance: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 7px;
  align-items: baseline;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ann-text, #1f2937);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.macrostructure-relation-target-results button:hover {
  border-color: var(--ann-border, #d7dee8);
  background: var(--ann-btn-hover-bg, #f4f7fb);
}

.macrostructure-relation-target-results strong {
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.76rem;
}

.macrostructure-relation-target-results span {
  overflow: hidden;
  font-size: 0.77rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.macrostructure-relation-target-results small {
  color: var(--ann-muted, #64748b);
  font-size: 0.67rem;
  white-space: nowrap;
}

.macrostructure-relation-picker-empty {
  padding: 9px;
  color: var(--ann-muted, #64748b);
  font-size: 0.76rem;
  text-align: center;
}

.macrostructure-relation-cancel,
.macrostructure-relation-reverse {
  appearance: none;
  padding: 7px 9px;
  border: 1px solid var(--ann-border, #d7dee8);
  border-radius: 9px;
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #1f2937);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.macrostructure-relation-cancel:hover,
.macrostructure-relation-reverse:hover {
  background: var(--ann-btn-hover-bg, #f4f7fb);
}

.macrostructure-relation-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 11px;
  background: var(--ann-btn-hover-bg, #f4f7fb);
}

.macrostructure-relation-preview > div {
  min-width: 0;
}

.macrostructure-relation-preview strong,
.macrostructure-relation-preview span {
  display: block;
}

.macrostructure-relation-preview strong {
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.8rem;
}

.macrostructure-relation-preview span {
  margin-top: 2px;
  overflow: hidden;
  color: var(--ann-text, #1f2937);
  font-size: 0.77rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.macrostructure-relation-preview b {
  color: var(--ann-muted, #64748b);
  font-size: 1.1rem;
}

.macrostructure-relation-reverse {
  align-self: flex-start;
}

.macrostructure-modal-body select {
  width: 100%;
  padding: 9px 10px;
  box-sizing: border-box;
  border: 1px solid var(--ann-border, #d7dee8);
  border-radius: 9px;
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #1f2937);
  font: inherit;
  font-size: 0.88rem;
}

.macrostructure-modal-body select:focus {
  outline: none;
  border-color: var(--ann-chip-border-strong, #afc8e6);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ann-btn-active-bg, #eaf3ff) 70%, transparent);
}

.macrostructure-relation-modal-footer .is-danger {
  color: #9b2c2c;
}

.macrostructure-modal-footer-spacer {
  flex: 1 1 auto;
}

@media (max-width: 760px) {
  .macrostructure-relation-pick-bar {
    grid-template-columns: 1fr auto;
  }
  .macrostructure-relation-pick-copy {
    grid-column: 1 / -1;
  }
  .macrostructure-relation-search-wrap {
    min-width: 0;
  }
  .macrostructure-relation-target-results button {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .macrostructure-relation-target-results small {
    display: none;
  }
}


/* 5.9a: clearer macrostructure relation classes. */
.macrostructure-field-help {
  display: block;
  margin-top: 5px;
  color: var(--ann-muted, #64748b);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
}

#macrostructureRelationTypeInput[readonly] {
  background: color-mix(in srgb, var(--ann-btn-hover-bg, #f4f7fb) 82%, var(--ann-surface, #fff));
  color: var(--ann-muted, #64748b);
  cursor: default;
}

#macrostructureRelationDirectionalitySelect:disabled {
  opacity: 0.72;
  cursor: default;
}

/* =========================================================
   ANNOTATION UX 5.10b — Header 2.0
   One-row navigation, grouped visualizations, responsive disclosure
   ========================================================= */

body.annotation-page #toolbar.tmm-app-toolbar {
  height: var(--toolbar-h);
  min-height: var(--toolbar-h);
  box-sizing: border-box;
  padding: 6px 10px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  overflow: visible;
  border-bottom-color: color-mix(in srgb, var(--ann-border, #d7dee8) 82%, transparent);
  box-shadow: 0 3px 14px rgba(15, 23, 42, 0.055);
}

body.annotation-page #toolbar .nav-left,
body.annotation-page #toolbar .nav-right,
body.annotation-page #toolbar nav.tab-bar,
body.annotation-page #toolbar nav.tab-bar .tabs {
  min-width: 0;
}

body.annotation-page #toolbar .nav-left {
  gap: 0;
}

body.annotation-page #toolbar .tmm-brand {
  width: 112px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  text-decoration: none;
  flex: 0 0 auto;
}

body.annotation-page #toolbar .tmm-brand-full {
  width: 112px;
  height: 112px;
  object-fit: contain;
  display: block;
  margin: 0;
  flex: 0 0 112px;
}

body.annotation-page #toolbar .tmm-brand-mark {
  display: none;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

/* No wrapping and no native horizontal scrollbar in Annotation. */
body.annotation-page #toolbar nav.tab-bar {
  overflow: visible;
}

body.annotation-page #toolbar nav.tab-bar .tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 7px;
  padding: 2px 1px;
  overflow: visible;
  scrollbar-width: none;
  white-space: nowrap;
}

body.annotation-page #toolbar nav.tab-bar .tabs::-webkit-scrollbar {
  display: none;
}

body.annotation-page #toolbar .tab-bar .tab-button {
  min-height: 38px;
  box-sizing: border-box;
  padding: 0 13px;
  gap: 7px;
  flex: 0 0 auto;
  font-size: 0.92rem;
  border-color: color-mix(in srgb, var(--ann-border, #d7dee8) 92%, transparent);
  background: color-mix(in srgb, var(--ann-surface-elevated, #fff) 90%, transparent);
  color: var(--ann-text, #0f172a);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.035);
}

body.annotation-page #toolbar .tab-bar .tab-button:hover {
  background: var(--ann-btn-hover-bg, #f8fafc);
  border-color: var(--ann-border-strong, #c7d2e1);
}

body.annotation-page #toolbar .tab-bar .tab-button.active,
body.annotation-page #toolbar .tab-bar .tab-button[aria-current="page"] {
  background: var(--ann-surface-elevated, #fff);
  border-color: color-mix(in srgb, var(--ann-chip-border-strong, #afc8e6) 74%, white);
  color: var(--ann-text, #0b1220);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.075);
}

body.annotation-page #toolbar .tab-icon {
  line-height: 1;
  flex: 0 0 auto;
}

/* Dropdowns in the main navigation. */
body.annotation-page #toolbar details.nav-dropdown {
  position: relative;
  flex: 0 0 auto;
}

body.annotation-page #toolbar details.nav-dropdown > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

body.annotation-page #toolbar details.nav-dropdown > summary::-webkit-details-marker {
  display: none;
}

body.annotation-page #toolbar details.nav-dropdown[open] > summary.tab-button {
  background: var(--ann-btn-hover-bg, #f8fafc);
  border-color: var(--ann-border-strong, #c7d2e1);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.07);
}

body.annotation-page #toolbar .nav-dropdown-caret {
  margin-left: 1px;
  font-size: 0.72rem;
  color: var(--ann-muted, #64748b);
  transition: transform 0.14s ease;
}

body.annotation-page #toolbar details[open] .nav-dropdown-caret {
  transform: rotate(180deg);
}

body.annotation-page #toolbar .nav-dropdown-menu {
  position: absolute;
  z-index: 15050;
  top: calc(100% + 9px);
  left: 0;
  min-width: 178px;
  padding: 6px;
  border: 1px solid var(--ann-menu-border, var(--ann-border, #d7dee8));
  border-radius: 12px;
  background: var(--ann-menu-bg, var(--ann-surface-elevated, #fff));
  color: var(--ann-text, #0f172a);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
}

body.annotation-page #toolbar .nav-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  color: inherit;
  font-size: 0.88rem;
  font-weight: 680;
  text-decoration: none;
  white-space: nowrap;
}

body.annotation-page #toolbar .nav-dropdown-menu a:hover,
body.annotation-page #toolbar .nav-dropdown-menu a:focus-visible {
  background: var(--ann-btn-hover-bg, #f3f6fa);
  outline: none;
}

body.annotation-page #toolbar .nav-more {
  display: none;
}

body.annotation-page #toolbar .nav-more-presentation {
  display: none;
}

/* Right side: compact, visually grouped user identity. */
body.annotation-page #toolbar .nav-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
  white-space: nowrap;
}

body.annotation-page #toolbar .annotator-pill {
  height: 38px;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--ann-border, #d7dee8);
  border-radius: 999px;
  background: var(--ann-surface-elevated, #fff);
  box-shadow: var(--ann-shadow-soft, 0 2px 7px rgba(15, 23, 42, 0.05));
}

body.annotation-page #toolbar .annotator-pill-action {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  padding: 0;
  border: 0;
  border-right: 1px solid color-mix(in srgb, var(--ann-border, #d7dee8) 78%, transparent);
  background: transparent;
  color: var(--ann-text, #0f172a);
  cursor: pointer;
}

body.annotation-page #toolbar .annotator-pill-action:hover {
  background: var(--ann-btn-hover-bg, #f4f7fb);
}

body.annotation-page #toolbar #annotatorName.annotator-name-compact {
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  height: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ann-text, #0f172a);
  box-shadow: none;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 720;
}

body.annotation-page #toolbar #loadedFileName.file-indicator {
  height: 38px;
  box-sizing: border-box;
  max-width: 235px;
  margin-left: 0;
  padding: 0 11px;
  gap: 7px;
  border-radius: 10px;
}

body.annotation-page #toolbar .annotation-theme-btn {
  height: 38px;
  min-height: 38px;
  padding: 0 10px;
}

body.annotation-page #toolbar .lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

body.annotation-page #toolbar .lang-switcher .lang-btn {
  min-width: 38px;
  height: 36px;
  box-sizing: border-box;
  padding: 0 8px;
}

/* Medium desktop / browser zoom: condense, never wrap. */
@media (max-width: 1480px) {
  body.annotation-page #toolbar.tmm-app-toolbar {
    padding-left: 8px;
    padding-right: 8px;
    gap: 7px;
  }

  body.annotation-page #toolbar .tmm-brand {
    width: 92px;
  }

  body.annotation-page #toolbar .tmm-brand-full {
    width: 96px;
    height: 96px;
    flex-basis: 96px;
  }

  body.annotation-page #toolbar nav.tab-bar .tabs {
    gap: 5px;
  }

  body.annotation-page #toolbar .tab-bar .tab-button {
    padding-left: 10px;
    padding-right: 10px;
    gap: 6px;
    font-size: 0.88rem;
  }

  body.annotation-page #toolbar #loadedFileName.file-indicator {
    max-width: 165px;
  }
}

/* First disclosure step: compact brand/file/theme and move Guide to More. */
@media (max-width: 1160px) {
  body.annotation-page #toolbar .tmm-brand {
    width: 38px;
    height: 40px;
    justify-content: center;
  }

  body.annotation-page #toolbar .tmm-brand-full {
    display: none;
  }

  body.annotation-page #toolbar .tmm-brand-mark {
    display: block;
  }

  body.annotation-page #toolbar .guide-tab {
    display: none;
  }

  body.annotation-page #toolbar .nav-more {
    display: block;
  }

  body.annotation-page #toolbar #loadedFileName.file-indicator {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  body.annotation-page #toolbar #loadedFileName .file-indicator-text {
    display: none;
  }

  body.annotation-page #toolbar .annotation-theme-btn {
    width: 40px;
    min-width: 40px;
    padding: 0;
  }

  body.annotation-page #toolbar .annotation-theme-btn-label {
    display: none;
  }

  body.annotation-page #toolbar .nav-right {
    gap: 5px;
  }
}

/* Strong zoom / narrow laptop: keep core modules visible as icons, Presentation moves to More. */
@media (max-width: 920px) {
  body.annotation-page #toolbar .presentation-tab {
    display: none;
  }

  body.annotation-page #toolbar .nav-more-presentation {
    display: flex;
  }

  body.annotation-page #toolbar .tab-button--responsive .tab-label {
    display: none;
  }

  body.annotation-page #toolbar .tab-button--responsive {
    width: 40px;
    min-width: 40px;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    gap: 0;
  }

  body.annotation-page #toolbar .nav-dropdown-caret {
    display: none;
  }

  body.annotation-page #toolbar .tab-bar .tab-button.active {
    padding-left: 10px;
    padding-right: 10px;
  }

  body.annotation-page #toolbar .annotator-pill-action {
    width: 34px;
    flex-basis: 34px;
  }

  body.annotation-page #toolbar #annotatorName.annotator-name-compact {
    width: 46px;
    min-width: 46px;
    max-width: 46px;
    padding-left: 4px;
    padding-right: 4px;
  }

  body.annotation-page #toolbar .lang-switcher .lang-btn {
    min-width: 34px;
    width: 34px;
    padding: 0 4px;
    font-size: 0.8rem;
  }
}

/* Very narrow viewport: preserve a single line by reducing nonessential horizontal chrome. */
@media (max-width: 760px) {
  body.annotation-page #toolbar.tmm-app-toolbar {
    padding-left: 5px;
    padding-right: 5px;
    gap: 4px;
  }

  body.annotation-page #toolbar .nav-right {
    gap: 3px;
  }

  body.annotation-page #toolbar .annotator-pill {
    display: none;
  }

  body.annotation-page #toolbar .annotation-theme-control {
    display: none;
  }

  body.annotation-page #toolbar .tab-bar .tab-button.active .tab-label {
    display: none;
  }

  body.annotation-page #toolbar .tab-bar .tab-button.active {
    width: 40px;
    min-width: 40px;
    justify-content: center;
    padding: 0;
  }
}

body.annotation-page #toolbar .nav-more .nav-dropdown-menu {
  left: auto;
  right: 0;
}

/* =========================================================
   ANNOTATION UX 5.10c — Header 2.1
   Content-aware fitting for browser zoom / intermediate widths.
   The JS fitter applies data-header-fit=0..9 based on the actual
   available width instead of relying on viewport breakpoints alone.
   ========================================================= */

/* Reset the breakpoint-only disclosure from Header 2.0. The fitter below
   decides the active level; these rules intentionally come last. */
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .guide-tab,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .presentation-tab {
  display: inline-flex;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .nav-more {
  display: none;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .nav-more-presentation {
  display: none;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .tmm-brand-full {
  display: block;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .tmm-brand-mark {
  display: none;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] #loadedFileName.file-indicator {
  width: auto;
  min-width: 0;
  max-width: 235px;
  padding: 0 11px;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] #loadedFileName .file-indicator-text,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .annotation-theme-btn-label,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .tab-button--responsive .tab-label,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .tab-bar .tab-button.active .tab-label,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .nav-dropdown-caret,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .annotator-pill,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .annotation-theme-control {
  display: initial;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .annotator-pill {
  display: inline-flex;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .annotation-theme-control {
  display: block;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .tab-button--responsive,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .tab-bar .tab-button.active {
  width: auto;
  min-width: 0;
  padding-left: 13px;
  padding-right: 13px;
  gap: 7px;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .annotation-theme-btn {
  width: auto;
  min-width: 0;
  padding-left: 10px;
  padding-right: 10px;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] .lang-switcher .lang-btn {
  min-width: 38px;
  width: auto;
  padding-left: 8px;
  padding-right: 8px;
  font-size: 0.84rem;
}

/* State 1 — Guide is the first item to move into More. */
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="1"] .guide-tab,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="2"] .guide-tab,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="3"] .guide-tab,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="4"] .guide-tab,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="5"] .guide-tab,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="6"] .guide-tab,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="7"] .guide-tab,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="8"] .guide-tab,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="9"] .guide-tab {
  display: none;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="1"] .nav-more,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="2"] .nav-more,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="3"] .nav-more,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="4"] .nav-more,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="5"] .nav-more,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="6"] .nav-more,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="7"] .nav-more,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="8"] .nav-more,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="9"] .nav-more {
  display: block;
}

/* State 2 — switch to the real TMM mark (never the old emoji favicon). */
body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="2"],[data-header-fit="3"],[data-header-fit="4"],[data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .tmm-brand {
  width: 40px;
  height: 40px;
  justify-content: center;
}

body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="2"],[data-header-fit="3"],[data-header-fit="4"],[data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .tmm-brand-full {
  display: none;
}

body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="2"],[data-header-fit="3"],[data-header-fit="4"],[data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .tmm-brand-mark {
  display: block;
  width: 34px;
  height: 34px;
}

/* State 3 — file name becomes a folder icon; full name remains in title. */
body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="3"],[data-header-fit="4"],[data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) #loadedFileName.file-indicator {
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="3"],[data-header-fit="4"],[data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) #loadedFileName .file-indicator-text {
  display: none;
}

/* State 4 — theme becomes icon-only. */
body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="4"],[data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .annotation-theme-btn {
  width: 40px;
  min-width: 40px;
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
}

body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="4"],[data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .annotation-theme-btn-label {
  display: none;
}

/* State 5 — core secondary modules become icon pills. Annotation and
   Presentation deliberately keep their labels longer. */
body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .tab-button--responsive .tab-label,
body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .nav-dropdown-caret {
  display: none;
}

body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .tab-button--responsive {
  width: 40px;
  min-width: 40px;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
  gap: 0;
}

/* State 6 — Presentation finally moves to More. */
body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .presentation-tab {
  display: none;
}

body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .nav-more-presentation {
  display: flex;
}

/* State 7 — tighten the right side but keep the annotator visible. */
body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .nav-right {
  gap: 4px;
}

body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .annotator-pill-action {
  width: 32px;
  flex-basis: 32px;
}

body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) #annotatorName.annotator-name-compact {
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  padding-left: 3px;
  padding-right: 3px;
}

body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .lang-switcher {
  gap: 3px;
}

body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .lang-switcher .lang-btn {
  min-width: 34px;
  width: 34px;
  padding-left: 3px;
  padding-right: 3px;
  font-size: 0.78rem;
}

/* State 8 — only at extreme zoom does the active Annotation pill become an icon. */
body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="8"],[data-header-fit="9"]) .tab-bar .tab-button.active .tab-label {
  display: none;
}

body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="8"],[data-header-fit="9"]) .tab-bar .tab-button.active {
  width: 40px;
  min-width: 40px;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
  gap: 0;
}

/* State 9 — last-resort one-row safety: retain user switching but hide the
   displayed initials. This should only be reached on very narrow/zoomed views. */
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="9"] #annotatorName.annotator-name-compact {
  display: none;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit="9"] .annotator-pill-action {
  border-right: 0;
}

/* Make icon-only controls feel intentional and consistent. */
body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .tab-button--responsive,
body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="3"],[data-header-fit="4"],[data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) #loadedFileName.file-indicator,
body.annotation-page #toolbar.tmm-app-toolbar:is([data-header-fit="4"],[data-header-fit="5"],[data-header-fit="6"],[data-header-fit="7"],[data-header-fit="8"],[data-header-fit="9"]) .annotation-theme-btn {
  border-radius: 12px;
}

/* No native scrollbar; the fitter must resolve every intermediate state. */
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] nav.tab-bar,
body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] nav.tab-bar .tabs {
  overflow: visible;
  scrollbar-width: none;
}

body.annotation-page #toolbar.tmm-app-toolbar[data-header-fit] nav.tab-bar .tabs::-webkit-scrollbar {
  display: none;
}

/* =========================================================
   ANNOTATION UX 5.10d — Footer 2.0 polishing
   Primary row = annotation action; secondary row = compact configuration.
   ========================================================= */
#annotation-footer .footer-secondary-section {
  padding-top: 0.28rem;
  border-top-color: color-mix(in srgb, var(--ann-border, #d7dee8) 58%, transparent);
}

#annotation-footer .footer-secondary-toolbar,
#annotation-footer .data-import-tools.footer-secondary-toolbar {
  gap: 0.34rem;
}

#annotation-footer .footer-secondary-toolbar .footer-popover-toggle,
#annotation-footer .footer-secondary-toolbar .footer-secondary-action,
#annotation-footer .footer-secondary-toolbar #mediaToolbarBtn {
  min-height: 34px;
  height: 34px;
  padding: 0 11px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 650;
}

#annotation-footer .footer-secondary-action-wrap {
  display: inline-flex;
  align-items: center;
}

#annotation-footer .footer-tags-panel {
  width: 390px;
}

#annotation-footer .footer-tags-view-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 4px 9px;
  margin-bottom: 4px;
  border-bottom: 1px solid color-mix(in srgb, var(--ann-menu-border, #dbe7f3) 66%, transparent);
}

#annotation-footer .footer-tag-view-mode {
  margin: 0;
  min-height: 34px;
  box-shadow: none;
}

#annotation-footer .footer-tag-filter {
  display: block;
  width: 100%;
}

/* Tag filter lives inside the Tagi popover, just like relation filtering lives
   inside Relacje. It no longer behaves as a second floating panel. */
#annotation-footer .footer-tags-panel .tag-filter-menu {
  position: static;
  inset: auto;
  width: 100%;
  min-width: 0;
  max-width: none !important;
  max-height: min(43vh, 370px);
  margin: 5px 0 8px;
  padding: 8px;
  border-radius: 10px;
  box-shadow: none;
  background: color-mix(in srgb, var(--ann-menu-bg, #fff) 92%, var(--ann-btn-hover-bg, #f4f7fb));
}

#annotation-footer .footer-tags-panel .tag-filter-menu::after {
  display: none;
}

#annotation-footer .footer-taxonomy-action {
  justify-content: space-between;
  gap: 10px;
  margin-top: 3px;
  border-top-color: transparent;
}

#annotation-footer .footer-taxonomy-action.has-unclassified {
  border-color: #d6b46b;
  background: color-mix(in srgb, #fff1d6 42%, transparent);
}

#annotation-footer .footer-toolbar-status-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  z-index: 2;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ann-chip-border-strong, #afc8e6);
  background: var(--ann-btn-active-bg, #eaf3ff);
  color: var(--ann-btn-active-text, #244b77);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

#annotation-footer .footer-toolbar-status-badge[hidden] {
  display: none !important;
}

#annotation-footer .footer-tools-panel {
  width: 286px;
}
#annotation-footer .footer-import-panel {
  width: 248px;
}

#annotation-footer .footer-import-toggle {
  gap: 8px;
}

#annotation-footer .footer-import-toggle-icon {
  flex: 0 0 auto;
  font-size: 0.96rem;
}

#annotation-footer .footer-import-toggle-label {
  white-space: nowrap;
}


#annotation-footer .footer-tools-group-label {
  margin: 7px 5px 3px;
  padding-top: 7px;
  border-top: 1px solid color-mix(in srgb, var(--ann-menu-border, #dbe7f3) 62%, transparent);
  color: var(--ann-muted, #64748b);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

#annotation-footer .footer-popover-heading + .footer-tools-group-label {
  margin-top: 1px;
  padding-top: 0;
  border-top: 0;
}

/* The first row is deliberately a little stronger than the configuration row. */
#annotation-footer .annotation-toolbar input[type="text"],
#annotation-footer .annotation-toolbar select,
#annotation-footer .annotation-toolbar button:not(.annotation-edit-cancel-btn) {
  min-height: 40px;
}

#annotation-footer #addAnnotationToSegmentBtn:not(:disabled) {
  font-weight: 750;
}

/* Old responsive taxonomy proxies are obsolete: General Tags now always live
   inside the Tagi panel. */
#annotation-footer .footer-taxonomy-primary,
#annotation-footer .footer-taxonomy-tools {
  display: none !important;
}

@media (max-width: 980px) {
  #annotation-footer .footer-secondary-toolbar .footer-popover-toggle,
  #annotation-footer .footer-secondary-toolbar .footer-secondary-action,
  #annotation-footer .footer-secondary-toolbar #mediaToolbarBtn {
    min-height: 33px;
    height: 33px;
    padding-left: 9px;
    padding-right: 9px;
    font-size: 0.79rem;
  }

  #annotation-footer .footer-tags-panel {
    width: min(390px, calc(100vw - 18px));
  }
}

/* =========================================================
   ANNOTATION UX 5.10d.1 — Footer popover viewport safety + visible export
   Keep left-side popovers inside the viewport and restore Export JSON as a
   persistent primary action in the secondary toolbar.
   ========================================================= */
#annotation-footer .footer-popover-panel {
  transform: translateX(var(--footer-popover-shift-x, 0px));
}

/* Tagi and Relacje live at the left edge of the footer. Aligning their panels
   from the left prevents the default right alignment from pushing them off-screen. */
#annotation-footer .footer-tags-panel,
#annotation-footer .footer-relations-panel {
  left: 0;
  right: auto;
}

#annotation-footer .footer-secondary-toolbar #exportJsonBtn.footer-export-primary {
  flex: 0 0 auto;
  min-height: 34px !important;
  height: 34px !important;
  padding: 0 13px !important;
  border-radius: 10px !important;
  font-size: 0.82rem !important;
  line-height: 1 !important;
  white-space: nowrap;
}

#annotation-footer .footer-export-primary-icon {
  flex: 0 0 auto;
}

#annotation-footer .footer-export-primary-label {
  white-space: nowrap;
}

/* At very narrow effective widths keep the save/export action visible rather
   than moving it into a menu: only its text collapses. */
@media (max-width: 880px) {
  #annotation-footer .footer-secondary-toolbar #exportJsonBtn.footer-export-primary {
    width: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
  }

  #annotation-footer .footer-export-primary-label {
    display: none;
  }
}

/* ==============================================================
   UX 5.10g — Segment Actions + Segment Options Polish
   ============================================================== */

/* Kompaktowa belka akcji segmentu. Zastępuje luźne, absolutnie
   pozycjonowane emoji i zostawia tekst segmentu możliwie spokojny. */
.segment-action-bar {
  position: absolute;
  right: 10px;
  bottom: 8px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid color-mix(in srgb, var(--ann-border, #cbd5e1) 82%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--ann-surface, #fff) 88%, transparent);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .07);
  backdrop-filter: blur(3px);
  opacity: .72;
  transition: opacity .14s ease, box-shadow .14s ease, border-color .14s ease;
}

.qa-segment-content-column:hover .segment-action-bar,
.qa-segment-content-column:focus-within .segment-action-bar {
  opacity: 1;
  box-shadow: 0 2px 7px rgba(15, 23, 42, .10);
}

.segment-action-item,
.note-icon,
.tree-icon,
.expert-note-icon,
.expert-rationale-icon,
.expert-difficulty-icon,
.sentence-features-toggle-btn {
  position: relative;
  right: auto;
  bottom: auto;
  top: auto;
  left: auto;
  margin: 0;
  width: 27px;
  height: 27px;
  min-width: 27px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ann-muted, #64748b);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  opacity: .82;
  z-index: auto;
  vertical-align: middle;
  transform: none;
  box-shadow: none;
}

.segment-action-item.is-interactive {
  cursor: pointer;
}

.segment-action-item.is-interactive:hover,
.sentence-features-toggle-btn:hover,
.tree-icon:hover,
.expert-note-icon:hover {
  opacity: 1;
  background: var(--ann-btn-hover-bg, rgba(59,130,246,.08));
  border-color: var(--ann-border, #cbd5e1);
  transform: translateY(-1px);
}

.sentence-features-toggle-btn.is-active {
  opacity: 1;
  color: #1d4ed8;
  background: rgba(59,130,246,.10);
  border-color: rgba(59,130,246,.28);
}

body.bg-paper .sentence-features-toggle-btn.is-active {
  color: #76551f;
  background: rgba(167,109,8,.10);
  border-color: rgba(151,113,55,.34);
}

/* Krótki tooltip nazw akcji. Dłuższa notatka ma własny dymek. */
.segment-action-item[data-tooltip]:not(.note-icon)::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: 280px;
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid var(--ann-border, #cbd5e1);
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #243244);
  box-shadow: 0 5px 14px rgba(15,23,42,.13);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .12s ease, transform .12s ease;
  z-index: 20;
}

.segment-action-item[data-tooltip]:not(.note-icon):hover::after,
.segment-action-item[data-tooltip]:not(.note-icon):focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

/* Notatka segmentu: tooltip z treścią pozostaje pojemniejszy. */
.segment-action-bar .note-icon .custom-tooltip.segment-note-tooltip {
  top: auto;
  left: auto;
  right: 0;
  bottom: calc(100% + 8px);
  transform: translateY(3px);
  min-width: 220px;
  max-width: min(420px, 60vw);
  width: max-content;
  padding: 7px 9px;
  border: 1px solid var(--ann-border, #cbd5e1);
  border-radius: 8px;
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #243244);
  box-shadow: 0 5px 14px rgba(15,23,42,.13);
  font-size: 12px;
  line-height: 1.35;
  opacity: 0;
  white-space: normal;
  pointer-events: none;
  z-index: 21;
}

.segment-action-bar .note-icon:hover .custom-tooltip.segment-note-tooltip {
  opacity: 1;
  transform: translateY(0);
}

/* Stary placeholder w nagłówku nie jest już potrzebny — ustawienia
   segmentu są pierwszą akcją w dolnej mini-beli. */
.features-placeholder { display: none !important; }

/* Panel opcji segmentu: sekcyjny, spokojniejszy i spójny z resztą TMM. */
.features-panel {
  margin-top: 1rem;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ann-panel-border, #ccd6e0);
  border-radius: 13px;
  background: var(--ann-surface, #fff);
  box-shadow: 0 4px 14px rgba(15,23,42,.065);
  font-family: inherit;
  font-size: .94rem;
}

.features-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--ann-border, #dbe3ef);
  background: var(--ann-panel-soft, #f8fafc);
}

.features-panel-title {
  color: var(--ann-text, #253247);
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.2;
}

.features-panel-meta {
  margin-top: 2px;
  color: var(--ann-muted, #64748b);
  font-size: .78rem;
  font-weight: 600;
}

.features-section {
  margin: 0;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ann-border, #dbe3ef) 85%, transparent);
}

.features-section:last-of-type { border-bottom: 0; }

.features-section-title,
.expert-fields-header {
  margin: 0 0 10px;
  color: var(--ann-text, #253247);
  font-size: .88rem;
  font-weight: 750;
  letter-spacing: .01em;
}

.features-panel label {
  color: var(--ann-text, #334155);
  font-weight: 600;
}

.features-panel input[type="text"],
.features-panel textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--ann-border, #cbd5e1);
  border-radius: 8px;
  background: var(--ann-surface, #fff);
  color: var(--ann-text, #243244);
  font: inherit;
  box-sizing: border-box;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.features-panel input[type="text"]:focus,
.features-panel textarea:focus {
  outline: none;
  border-color: #93b9e8;
  box-shadow: 0 0 0 3px rgba(59,130,246,.10);
}

.features-panel textarea {
  min-height: 72px;
  resize: vertical;
}

.logic-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0;
}

.logic-row + .logic-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed color-mix(in srgb, var(--ann-border, #dbe3ef) 82%, transparent);
}

.logic-label {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  margin: 0 !important;
  padding: 6px 9px;
  border: 1px solid var(--ann-border, #d5dee9);
  border-radius: 8px;
  background: var(--ann-btn-bg, #fff);
  cursor: pointer;
  white-space: nowrap;
}

.logic-label:has(input:checked) {
  border-color: rgba(59,130,246,.34);
  background: rgba(59,130,246,.08);
  color: #174a86;
}

.logic-input-wrapper {
  flex: 1 1 230px;
  min-width: 180px;
  display: grid;
  grid-template-columns: auto minmax(90px, 1fr);
  align-items: center;
  gap: 8px;
}

.logic-input-wrapper label { margin: 0 !important; }
.logic-input-wrapper input[type="text"] { min-width: 90px; }

.argumentative-row {
  justify-content: flex-start;
}

.argumentative-row > .logic-label {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: default;
}

.argumentative-toggle-group {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border: 1px solid var(--ann-border, #cbd5e1);
  border-radius: 9px;
  background: var(--ann-panel-soft, #f8fafc);
}

.features-panel .argumentative-choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  margin: 0 !important;
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  color: var(--ann-muted, #64748b);
  cursor: pointer;
  user-select: none;
  transition: background .12s ease, color .12s ease, box-shadow .12s ease;
}

.features-panel .argumentative-choice input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.features-panel .argumentative-choice:has(input:checked) {
  background: var(--ann-surface, #fff);
  color: #174a86;
  box-shadow: 0 1px 4px rgba(15,23,42,.10);
}

body.bg-paper .features-panel .argumentative-choice:has(input:checked) {
  color: #76551f;
}

.features-panel .expert-fields {
  margin-top: 0;
  padding-top: 14px;
  border-top: 0;
}

.features-panel .difficulty-toggle-group {
  margin-top: 7px;
  gap: 7px;
}

.features-panel .difficulty-chip {
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--ann-btn-bg, #fff);
}

.features-panel .difficulty-clear-btn {
  display: inline-flex;
  margin: 8px 0 0;
  padding: 6px 10px;
  border: 1px solid var(--ann-border, #cbd5e1);
  border-radius: 8px;
  background: transparent;
  color: var(--ann-muted, #64748b);
  font-weight: 650;
}

.features-panel .difficulty-clear-btn:hover {
  background: var(--ann-btn-hover-bg, #f8fafc);
}

.features-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 11px 15px;
  border-top: 1px solid var(--ann-border, #dbe3ef);
  background: var(--ann-panel-soft, #f8fafc);
}

.features-panel .features-save-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  margin: 0;
  padding: 8px 15px;
  border: 1px solid #2563eb;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 750;
}

.features-panel .features-save-btn:hover {
  background: #1d4ed8;
}

body.bg-paper .segment-action-bar {
  background: rgba(248,240,225,.90);
  border-color: rgba(151,125,88,.28);
}

@media (max-width: 900px) {
  .segment-action-bar { right: 7px; bottom: 7px; }
  .segment-action-item,
  .note-icon,
  .tree-icon,
  .expert-note-icon,
  .expert-rationale-icon,
  .expert-difficulty-icon,
  .sentence-features-toggle-btn {
    width: 25px;
    height: 25px;
    min-width: 25px;
    font-size: 14px;
  }
  .logic-input-wrapper { flex-basis: 100%; }
}


/* ===============================
   UX 5.10h — Expert comment modal polish
================================ */

.expert-comment-modal {
  padding: clamp(14px, 2.2vw, 30px);
  background: rgba(25, 31, 40, 0.46);
  backdrop-filter: blur(4px);
}

.expert-comment-modal__dialog {
  width: min(1620px, 96vw);
  max-height: min(94vh, 1120px);
  border-radius: 18px;
  box-shadow: 0 28px 72px rgba(20, 24, 31, 0.26);
}

.expert-comment-modal__header {
  align-items: center;
  padding: 15px 20px 14px;
}

.expert-comment-modal__title {
  font-size: 1.08em;
  letter-spacing: -0.01em;
}

.expert-comment-modal__close {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 10px;
  font-size: 1.12em;
}

.expert-comment-modal__body {
  padding: clamp(14px, 1.8vw, 22px);
  background: color-mix(in srgb, var(--ann-panel-soft) 58%, var(--ann-surface));
}

.expert-context-box {
  margin-bottom: 14px;
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}

.expert-context-box--compact {
  gap: 0;
}

.expert-context-hero {
  padding: 14px 16px 13px;
  background: color-mix(in srgb, var(--ann-panel-soft) 78%, var(--ann-surface));
  border-bottom: 1px solid var(--ann-border);
}

.expert-context-headline {
  margin: 0 0 5px;
  gap: 0.45em;
  font-size: 1.01em;
}

.expert-context-segid {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid var(--ann-border);
  border-radius: 999px;
  background: var(--ann-surface);
  font-size: 0.84em;
  color: var(--ann-muted);
}

.expert-context-speaker {
  font-weight: 750;
  color: var(--ann-text, #263449);
}

.expert-context-text--compact {
  margin: 0;
  font-size: 1.03em;
  line-height: 1.48;
}

.expert-context-annotations {
  margin: 0;
  padding: 13px 14px 14px;
}

.expert-context-subtitle,
.expert-comment-label {
  font-size: 0.86em;
  letter-spacing: 0.01em;
  color: var(--ann-muted);
}

.expert-context-ann-list {
  gap: 8px;
}

.expert-context-ann {
  padding: 11px 12px;
  border-radius: 11px;
  box-shadow: none;
}

.expert-context-ann-head {
  margin-bottom: 5px;
}

.expert-context-ann-rationale {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--ann-border);
}

.expert-comment-section--analysis {
  display: grid;
  gap: 12px;
}

.expert-comment-row {
  margin: 0 !important;
  padding: 13px 14px 14px;
  border: 1px solid var(--ann-panel-border);
  border-radius: 14px;
  background: var(--ann-surface);
}

.expert-comment-row--primary {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.025);
}

.expert-comment-row--legacy {
  background: color-mix(in srgb, var(--ann-panel-soft) 66%, var(--ann-surface));
  opacity: 0.86;
}

.expert-comment-row--legacy .expert-comment-label {
  font-weight: 650;
}

.expert-comment-row--difficulty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 11px;
  padding-bottom: 11px;
}

.expert-comment-row--difficulty .expert-comment-label {
  margin: 0;
}

.expert-comment-lang-grid {
  gap: 10px;
}

.expert-comment-lang-card {
  min-width: 0;
  padding: 11px 12px 12px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--ann-panel-soft) 42%, var(--ann-surface));
}

.expert-comment-lang-card--pl,
.expert-comment-lang-card--en {
  background: color-mix(in srgb, var(--ann-panel-soft) 42%, var(--ann-surface));
}

.expert-comment-lang-head {
  margin-bottom: 6px;
}

.expert-comment-value {
  line-height: 1.52;
}

.expert-difficulty-summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  padding: 4px 10px;
  border: 1px solid var(--ann-border);
  border-radius: 999px;
  background: var(--ann-panel-soft);
  font-weight: 650;
  color: var(--ann-text, #263449);
}

.expert-difficulty-summary__icon {
  line-height: 1;
}

@media (max-width: 859px) {
  .expert-comment-modal {
    padding: 8px;
  }

  .expert-comment-modal__dialog {
    width: 100%;
    max-height: 97vh;
    border-radius: 14px;
  }

  .expert-comment-row--difficulty {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ==============================================================
   Macrostructure Relations Modal — Pack 1
   ============================================================== */
body.macro-relations-modal-open {
  overflow: hidden;
}

.macro-relations-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 14000;
  display: grid;
  place-items: center;
  padding: 3vh 3vw;
  background: rgba(19, 24, 32, .52);
  backdrop-filter: blur(3px);
}

.macro-relations-modal-overlay[hidden] { display: none !important; }

.macro-relations-modal {
  width: min(94vw, 1720px);
  height: min(92vh, 980px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ann-border, #d5c7ad) 88%, transparent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--ann-surface, #fffaf0) 96%, transparent);
  color: var(--ann-text, #342f27);
  box-shadow: 0 22px 70px rgba(15, 23, 42, .28);
}

.macro-relations-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 13px;
  border-bottom: 1px solid color-mix(in srgb, var(--ann-border, #d8c9af) 70%, transparent);
  background: color-mix(in srgb, var(--ann-surface-2, #f8efdf) 78%, transparent);
}

.macro-relations-modal-kicker {
  margin-bottom: 2px;
  color: var(--ann-accent-text, #785a2d);
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .08em;
}

.macro-relations-modal-head h2 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.25;
}

.macro-relations-modal-summary {
  margin-top: 4px;
  color: var(--ann-muted, #6f675d);
  font-size: .78rem;
}

.macro-relations-modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--ann-border, #d4c5ab);
  border-radius: 11px;
  background: color-mix(in srgb, var(--ann-surface, #fff) 78%, transparent);
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
}

.macro-relations-modal-controls {
  position: relative;
  z-index: 4;
  padding: 10px 14px 9px;
  border-bottom: 1px solid color-mix(in srgb, var(--ann-border, #d8c9af) 66%, transparent);
  background: color-mix(in srgb, var(--ann-surface, #fffaf0) 92%, transparent);
}

.macro-relations-layer-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  margin-bottom: 8px;
  border: 1px solid var(--ann-border, #d8c9af);
  border-radius: 12px;
  background: color-mix(in srgb, var(--ann-surface-2, #f4ead8) 72%, transparent);
}

.macro-relations-layer-switch button {
  min-height: 31px;
  padding: 0 13px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ann-muted, #675f55);
  font-weight: 720;
  cursor: pointer;
}

.macro-relations-layer-switch button.is-active {
  background: var(--ann-btn-active-bg, #fff);
  color: var(--ann-btn-active-text, #2d527c);
  box-shadow: 0 1px 4px rgba(15, 23, 42, .10);
}

.macro-relations-control-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

.macro-relations-control-row label {
  display: grid;
  gap: 3px;
  flex: 0 0 auto;
}

.macro-relations-control-row label > span {
  padding-left: 2px;
  color: var(--ann-muted, #6c655c);
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.macro-relations-control-row select,
.macro-relations-search-wrap input {
  height: 35px;
  border: 1px solid var(--ann-border, #d8c9af);
  border-radius: 9px;
  background: color-mix(in srgb, var(--ann-surface, #fff) 92%, transparent);
  color: inherit;
  font: inherit;
}

.macro-relations-control-row select { min-width: 116px; padding: 0 28px 0 9px; }

.macro-relations-search-wrap {
  position: relative;
  flex: 1 1 290px;
  min-width: 190px;
}

.macro-relations-search-wrap input {
  width: 100%;
  padding: 0 11px;
}

.macro-relations-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 5px);
  z-index: 20;
  max-height: 320px;
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--ann-border, #d8c9af);
  border-radius: 11px;
  background: var(--ann-menu-bg, #fffaf0);
  box-shadow: 0 14px 30px rgba(15,23,42,.18);
}

.macro-relations-search-results button {
  width: 100%;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.macro-relations-search-results button:hover { background: var(--ann-btn-hover-bg, #f3ead9); }
.macro-relations-search-results button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.macro-relations-search-results button small { color: var(--ann-muted, #756c62); }
.macro-relations-search-empty { padding: 12px; color: var(--ann-muted, #756c62); text-align: center; }

.macro-relations-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.macro-relations-zoom-controls button {
  height: 35px;
  min-width: 35px;
  padding: 0 9px;
  border: 1px solid var(--ann-border, #d8c9af);
  background: color-mix(in srgb, var(--ann-surface, #fff) 90%, transparent);
  color: inherit;
  cursor: pointer;
  font-weight: 700;
}
.macro-relations-zoom-controls button:first-child { border-radius: 9px 0 0 9px; }
.macro-relations-zoom-controls button:last-child { border-radius: 0 9px 9px 0; }

.macro-relations-focus-bar,
.macro-relations-warning {
  margin-top: 7px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 29px;
  padding: 5px 8px;
  border-radius: 9px;
  font-size: .76rem;
}
.macro-relations-focus-bar {
  border: 1px solid color-mix(in srgb, #4c84c5 40%, var(--ann-border, #ddd));
  background: color-mix(in srgb, #eaf4ff 55%, var(--ann-surface, #fff));
}
.macro-relations-focus-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.macro-relations-focus-bar button { margin-left: auto; border: 0; background: transparent; color: #315e91; font-weight: 750; cursor: pointer; }
.macro-relations-warning {
  border: 1px solid #d5aa58;
  background: color-mix(in srgb, #fff0c9 64%, var(--ann-surface, #fff));
  color: #76521b;
}

.macro-relations-modal-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
}

.macro-relations-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(color-mix(in srgb, var(--ann-grid, #ab9878) 10%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ann-grid, #ab9878) 10%, transparent) 1px, transparent 1px),
    color-mix(in srgb, var(--ann-canvas-bg, #f7eddb) 92%, #fff);
  background-size: 22px 22px;
}

.macro-relations-stage-sizer { position: relative; min-width: 100%; min-height: 100%; }
.macro-relations-stage {
  position: relative;
  min-width: 100%;
  min-height: 100%;
  padding: 24px;
  box-sizing: border-box;
}

.macro-relations-empty {
  min-height: 360px;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--ann-muted, #72695f);
  text-align: center;
}
.macro-relations-empty > div { font-size: 2rem; }

.macro-relations-details {
  min-width: 0;
  overflow: auto;
  padding: 14px;
  border-left: 1px solid color-mix(in srgb, var(--ann-border, #d8c9af) 70%, transparent);
  background: color-mix(in srgb, var(--ann-surface, #fffaf0) 96%, transparent);
}
.macro-relations-details-empty { padding: 20px 8px; color: var(--ann-muted, #746c62); font-size: .83rem; line-height: 1.5; }
.macro-detail-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.macro-detail-head h3 { margin: 1px 0 0; font-size: 1rem; line-height: 1.3; }
.macro-detail-head > button { border: 0; background: transparent; color: var(--ann-muted, #777); cursor: pointer; font-size: 1.1rem; }
.macro-detail-id { color: var(--ann-accent-text, #73572c); font-size: .72rem; font-weight: 850; letter-spacing: .04em; }
.macro-detail-type { display: inline-flex; margin-top: 8px; padding: 4px 8px; border-radius: 999px; background: var(--ann-chip-bg, #efe3ce); color: var(--ann-chip-text, #6a512c); font-size: .74rem; font-weight: 750; }
.macro-detail-meta { margin-top: 7px; color: var(--ann-muted, #70685f); font-size: .76rem; }
.macro-detail-warning { margin-top: 9px; padding: 7px 8px; border-radius: 8px; background: #fff0c9; color: #76521b; font-size: .73rem; }
.macro-detail-notes { margin-top: 10px; padding: 9px; border: 1px solid var(--ann-border, #d8c9af); border-radius: 9px; background: color-mix(in srgb, var(--ann-surface-2, #f7eddb) 62%, transparent); font-size: .8rem; line-height: 1.45; }
.macro-detail-section { margin-top: 14px; }
.macro-detail-section h4 { margin: 0 0 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .045em; color: var(--ann-muted, #6c655d); }
.macro-detail-relation { width: 100%; display: grid; grid-template-columns: 20px 44px minmax(0, 1fr); gap: 5px; align-items: center; padding: 7px 6px; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--ann-border, #ddd) 55%, transparent); background: transparent; color: inherit; text-align: left; cursor: pointer; }
.macro-detail-relation em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ann-muted, #70685f); font-style: normal; font-size: .75rem; }
.macro-detail-muted { color: var(--ann-muted, #777); font-size: .76rem; }
.macro-detail-actions { display: grid; grid-template-columns: 1fr 1.2fr; gap: 6px; margin-top: 15px; }
.macro-detail-actions button { min-height: 36px; border: 1px solid var(--ann-border, #d8c9af); border-radius: 9px; background: var(--ann-btn-bg, #fffaf0); color: inherit; font-weight: 720; cursor: pointer; }
.macro-detail-actions button.is-primary { background: #2f6fe4; border-color: #2f6fe4; color: white; }
.macro-detail-edge-route { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 5px; margin-top: 13px; }
.macro-detail-edge-route button { display: grid; gap: 2px; min-width: 0; padding: 8px; border: 1px solid var(--ann-border, #d8c9af); border-radius: 9px; background: var(--ann-btn-bg, #fffaf0); color: inherit; text-align: left; cursor: pointer; }
.macro-detail-edge-route button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ann-muted, #777); font-size: .7rem; }

.macro-relations-modal-foot {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 15px;
  border-top: 1px solid color-mix(in srgb, var(--ann-border, #d8c9af) 66%, transparent);
  color: var(--ann-muted, #6e675e);
  font-size: .68rem;
  background: color-mix(in srgb, var(--ann-surface-2, #f7eddb) 68%, transparent);
}
.macro-relations-modal-foot span { display: inline-flex; align-items: center; gap: 6px; }
.macro-legend-box { width: 16px; height: 10px; border: 1.5px solid #a89068; border-radius: 3px; background: #fff8ec; }
.macro-legend-containment { width: 16px; height: 10px; border: 2px double #a89068; border-radius: 3px; }
.macro-legend-discourse { width: 18px; height: 0; border-top: 2px solid #6886a8; position: relative; }
.macro-legend-discourse::after { content: ""; position: absolute; right: -1px; top: -4px; border-left: 5px solid #6886a8; border-top: 3px solid transparent; border-bottom: 3px solid transparent; }

/* Matryoshka renderer */
.macro-matryoshka-forest {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  align-items: start;
  gap: 18px;
  min-width: 780px;
}
.macro-matryoshka-card {
  position: relative;
  min-width: 0;
  padding: 9px;
  border: 1.5px solid color-mix(in srgb, #9f8357 72%, var(--ann-border, #d5c7ad));
  border-radius: 14px;
  background: color-mix(in srgb, var(--ann-surface, #fffaf0) 89%, transparent);
  box-shadow: 0 2px 8px rgba(66, 49, 25, .06);
}
.macro-matryoshka-card.has-children { padding-bottom: 11px; }
.macro-matryoshka-card.has-cycle { border-style: dashed; border-color: #c98b32; }
.macro-matryoshka-head {
  position: relative;
  z-index: 3;
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  background: color-mix(in srgb, var(--ann-surface-2, #f6ead5) 72%, transparent);
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.macro-matryoshka-head:hover { background: color-mix(in srgb, var(--ann-btn-hover-bg, #eaf2fb) 58%, var(--ann-surface-2, #f6ead5)); }
.macro-matryoshka-id { align-self: start; padding: 3px 6px; border-radius: 999px; background: var(--ann-chip-bg, #ecdfc7); color: var(--ann-chip-text, #6b512a); font-size: .69rem; font-weight: 850; }
.macro-matryoshka-copy { min-width: 0; display: grid; gap: 2px; }
.macro-matryoshka-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; }
.macro-matryoshka-copy small { color: var(--ann-muted, #70685f); font-size: .66rem; }
.macro-cycle-badge { font-size: .8rem; }
.macro-secondary-parents { display: flex; flex-wrap: wrap; gap: 4px; padding: 5px 3px 0; }
.macro-secondary-parents button { border: 0; border-radius: 999px; padding: 3px 6px; background: color-mix(in srgb, #e6eef8 60%, transparent); color: #4c6582; font-size: .62rem; cursor: pointer; }
.macro-matryoshka-children { display: grid; gap: 9px; padding: 10px 4px 2px 16px; }
.macro-matryoshka-children > .macro-matryoshka-card { background: color-mix(in srgb, var(--ann-surface, #fffaf0) 94%, #fff); }

/* Cytoscape network renderer */
.macro-relations-stage.layer-discourse { padding: 0; }
.macro-cy-container { position: absolute; inset: 0; min-height: 100%; }

/* Combined renderer */
.macro-combined-forest { position: relative; z-index: 2; }
.macro-combined-svg { position: absolute; inset: 0; z-index: 4; overflow: visible; pointer-events: none; }
.macro-combined-svg marker path { fill: #6d88a5; }
.macro-combined-edge { fill: none; stroke: #6d88a5; stroke-width: 1.9; opacity: .82; pointer-events: none; }
.macro-combined-edge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.macro-combined-edge-label { fill: #5f7185; font-size: 10px; font-weight: 700; text-anchor: middle; paint-order: stroke; stroke: color-mix(in srgb, var(--ann-surface, #fffaf0) 94%, transparent); stroke-width: 5px; stroke-linejoin: round; pointer-events: none; }

@media (max-width: 1050px) {
  .macro-relations-modal-overlay { padding: 1.5vh 1.5vw; }
  .macro-relations-modal { width: 97vw; height: 95vh; border-radius: 15px; }
  .macro-relations-modal-body { grid-template-columns: 1fr; }
  .macro-relations-details { position: absolute; right: 12px; bottom: 46px; z-index: 8; width: min(330px, calc(100% - 24px)); max-height: 55%; border: 1px solid var(--ann-border, #d8c9af); border-radius: 12px; box-shadow: 0 12px 28px rgba(15,23,42,.20); }
  .macro-relations-details:has(.macro-relations-details-empty) { display: none; }
  .macro-relations-control-row { flex-wrap: wrap; }
  .macro-relations-search-wrap { flex-basis: 100%; }
  .macro-relations-zoom-controls { margin-left: 0; }
}

@media (max-width: 680px) {
  .macro-relations-modal-head { padding: 12px; }
  .macro-relations-modal-controls { padding: 8px 9px; }
  .macro-relations-layer-switch { width: 100%; }
  .macro-relations-layer-switch button { flex: 1; padding-inline: 7px; }
  .macro-relations-control-row label { flex: 1 1 120px; }
  .macro-relations-control-row select { width: 100%; min-width: 0; }
  .macro-relations-zoom-controls { width: 100%; }
  .macro-relations-zoom-controls button { flex: 1; }
  .macro-relations-modal-foot { gap: 8px; flex-wrap: wrap; }
}

/* ==============================================================
   Macrostructure Relations Modal — Pack 2 renderer variants
   ============================================================== */
.macro-relations-variant-wrap {
  display: grid;
  gap: 3px;
  flex: 0 1 auto;
}
.macro-relations-variant-wrap > span {
  padding-left: 2px;
  color: var(--ann-muted, #6c655c);
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.macro-relations-variant-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 35px;
  padding: 3px;
  border: 1px solid var(--ann-border, #d8c9af);
  border-radius: 10px;
  background: color-mix(in srgb, var(--ann-surface-2, #f4ead8) 62%, transparent);
}
.macro-relations-variant-switch button {
  min-height: 27px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ann-muted, #675f55);
  font-size: .73rem;
  font-weight: 740;
  white-space: nowrap;
  cursor: pointer;
}
.macro-relations-variant-switch button:hover { background: color-mix(in srgb, var(--ann-btn-hover-bg, #eaf2fb) 58%, transparent); }
.macro-relations-variant-switch button.is-active {
  background: var(--ann-btn-active-bg, #fff);
  color: var(--ann-btn-active-text, #2d527c);
  box-shadow: 0 1px 3px rgba(15,23,42,.09);
}

/* Cytoscape is used by both the tree and combined hierarchy renderers. */
.macro-relations-stage.renderer-cy { padding: 0; }
.macro-legend-containment-line,
.macro-legend-story-tree,
.macro-legend-time-run {
  display: inline-block;
  width: 18px;
  height: 10px;
  position: relative;
}
.macro-legend-containment-line::before {
  content: "";
  position: absolute;
  left: 1px; right: 1px; top: 5px;
  border-top: 2px solid #ad9c80;
}
.macro-legend-story-tree::before {
  content: "";
  position: absolute;
  left: 3px; top: 0; bottom: 1px;
  border-left: 2px solid #ad9c80;
}
.macro-legend-story-tree::after {
  content: "";
  position: absolute;
  left: 3px; right: 1px; top: 6px;
  border-top: 2px solid #ad9c80;
}
.macro-legend-time-run::before {
  content: "";
  position: absolute;
  left: 1px; right: 1px; top: 4px;
  height: 4px;
  border-radius: 999px;
  background: #7f9ab7;
}

/* Local controls used only by individual renderers (currently Levels). */
.macro-renderer-localbar {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 9px;
  color: var(--ann-muted, #6d665d);
  font-size: .68rem;
  font-weight: 750;
}
.macro-renderer-localbar > div {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--ann-border, #d8c9af);
  border-radius: 9px;
  background: color-mix(in srgb, var(--ann-surface, #fffaf0) 86%, transparent);
}
.macro-renderer-localbar button {
  min-height: 27px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-size: .68rem;
  font-weight: 740;
  cursor: pointer;
}
.macro-renderer-localbar button.is-active { background: var(--ann-btn-active-bg, #fff); color: var(--ann-btn-active-text, #2d527c); box-shadow: 0 1px 3px rgba(15,23,42,.08); }

/* Containment / Levels */
.macro-levels-view {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  min-width: 850px;
  padding: 5px 5px 18px;
}
.macro-level-row {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 74px;
  padding: 8px 9px;
  border: 1px solid color-mix(in srgb, var(--ann-border, #d8c9af) 55%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--ann-surface, #fffaf0) 64%, transparent);
}
.macro-level-label {
  align-self: stretch;
  display: grid;
  place-items: center;
  border-right: 1px solid color-mix(in srgb, var(--ann-border, #d8c9af) 70%, transparent);
  color: var(--ann-muted, #70685e);
  font-size: .69rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.macro-level-nodes { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.macro-level-node {
  position: relative;
  z-index: 4;
  min-width: 150px;
  max-width: 230px;
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  gap: 2px 7px;
  align-items: center;
  padding: 8px 9px;
  border: 1.5px solid color-mix(in srgb, #a89068 70%, var(--ann-border, #d8c9af));
  border-radius: 10px;
  background: var(--ann-surface, #fffaf0);
  color: inherit;
  text-align: left;
  box-shadow: 0 1px 4px rgba(52,42,27,.06);
  cursor: pointer;
}
.macro-level-node strong { grid-row: 1 / span 2; align-self: start; padding: 3px 6px; border-radius: 999px; background: var(--ann-chip-bg, #ecdfc7); color: var(--ann-chip-text, #6b512a); font-size: .68rem; }
.macro-level-node span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .76rem; font-weight: 760; }
.macro-level-node small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ann-muted, #70685f); font-size: .62rem; }
.macro-level-node.is-focused { border-color: #2f6fe4; box-shadow: 0 0 0 3px rgba(47,111,228,.12); }
.macro-levels-view.is-compact .macro-level-row { min-height: 56px; }
.macro-levels-view.is-compact .macro-level-node { min-width: 56px; width: auto; padding: 6px; grid-template-columns: 1fr; place-items: center; }
.macro-levels-view.is-compact .macro-level-node strong { grid-row: auto; padding: 4px 7px; }
.macro-levels-svg { position: absolute; inset: 0; z-index: 1; overflow: visible; pointer-events: none; }
.macro-levels-edge { fill: none; stroke: #b2a184; stroke-width: 1.7; opacity: .78; pointer-events: none; }
.macro-levels-edge-hit { fill: none; stroke: transparent; stroke-width: 13; pointer-events: stroke; cursor: pointer; }

/* Discourse / Timeline and Combined / Storyline */
.macro-temporal-svg { display: block; overflow: visible; }
.macro-time-axis { stroke: #9b8d75; stroke-width: 1.3; }
.macro-time-gridline { stroke: color-mix(in srgb, #a79578 22%, transparent); stroke-width: 1; stroke-dasharray: 3 5; }
.macro-time-tick { fill: var(--ann-muted, #71695f); font-size: 10px; font-weight: 700; }
.macro-time-axis-label { fill: var(--ann-muted, #71695f); font-size: 10px; font-weight: 750; }
.macro-time-row { cursor: pointer; }
.macro-time-row-bg { fill: color-mix(in srgb, var(--ann-surface, #fffaf0) 34%, transparent); }
.macro-time-row:hover .macro-time-row-bg,
.macro-time-row.is-focused .macro-time-row-bg { fill: color-mix(in srgb, #e9f3ff 48%, var(--ann-surface, #fffaf0)); }
.macro-time-node-id { fill: var(--ann-accent-text, #73572c); font-size: 11px; font-weight: 850; }
.macro-time-node-name { fill: var(--ann-text, #342f27); font-size: 11px; font-weight: 760; }
.macro-time-node-type { fill: var(--ann-muted, #746c62); font-size: 8.5px; }
.macro-time-span-guide { stroke: #a8b6c4; stroke-width: 1.2; stroke-dasharray: 3 4; opacity: .68; }
.macro-time-run { stroke: #6888a8; stroke-width: 7; stroke-linecap: round; }
.macro-time-point { fill: #6888a8; stroke: color-mix(in srgb, var(--ann-surface, #fffaf0) 94%, transparent); stroke-width: 2; }
.macro-time-row.is-focused .macro-time-run { stroke: #2f6fe4; stroke-width: 8.5; }
.macro-time-row.is-focused .macro-time-point { fill: #2f6fe4; }
.macro-pack2-arrow-shape { fill: #6b86a4; }
.macro-time-discourse-edge { fill: none; stroke: #6b86a4; stroke-width: 1.8; opacity: .84; pointer-events: none; }
.macro-time-edge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.macro-time-edge-label { fill: #5b7187; font-size: 9px; font-weight: 760; paint-order: stroke; stroke: color-mix(in srgb, var(--ann-canvas-bg, #f7eddb) 94%, transparent); stroke-width: 5px; stroke-linejoin: round; pointer-events: none; }
.macro-story-containment { fill: none; stroke: #ad9b7d; stroke-width: 1.6; opacity: .84; pointer-events: none; }
.macro-story-containment-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }

/* Discourse / Matrix */
.macro-matrix-wrap { position: relative; min-width: max-content; padding: 2px 2px 18px; }
.macro-matrix-table { border-collapse: separate; border-spacing: 0; background: var(--ann-surface, #fffaf0); border: 1px solid var(--ann-border, #d8c9af); border-radius: 12px; overflow: hidden; font-size: .7rem; }
.macro-matrix-table th,
.macro-matrix-table td { min-width: 74px; height: 48px; padding: 4px; border-right: 1px solid color-mix(in srgb, var(--ann-border, #d8c9af) 55%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--ann-border, #d8c9af) 55%, transparent); vertical-align: middle; text-align: center; }
.macro-matrix-table thead th { position: sticky; top: 0; z-index: 5; background: var(--ann-surface-2, #f7eddb); }
.macro-matrix-table tbody th { position: sticky; left: 0; z-index: 4; min-width: 175px; max-width: 175px; background: var(--ann-surface-2, #f7eddb); text-align: left; }
.macro-matrix-table .macro-matrix-corner { left: 0; z-index: 7; min-width: 175px; }
.macro-matrix-table th > button { width: 100%; border: 0; background: transparent; color: inherit; cursor: pointer; font-weight: 800; }
.macro-matrix-table tbody th > button { display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 4px; align-items: center; text-align: left; }
.macro-matrix-table tbody th span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ann-muted, #71695f); font-weight: 650; }
.macro-matrix-table th.is-focused,
.macro-matrix-table tr.is-focused > th,
.macro-matrix-table td.is-focus-col { background: color-mix(in srgb, #e8f2ff 58%, var(--ann-surface-2, #f7eddb)); }
.macro-matrix-table td.is-diagonal { color: #b0a99f; background: color-mix(in srgb, var(--ann-surface-2, #f7eddb) 48%, transparent); }
.macro-matrix-edge { display: inline-flex; align-items: center; justify-content: center; max-width: 68px; margin: 1px; padding: 3px 5px; border: 1px solid color-mix(in srgb, #6886a8 45%, var(--ann-border, #ddd)); border-radius: 999px; background: color-mix(in srgb, #eaf3fc 55%, var(--ann-surface, #fff)); color: #4d6680; font-size: .62rem; font-weight: 780; cursor: pointer; }
.macro-matrix-edge:hover { border-color: #2f6fe4; color: #245ab2; }

@media (max-width: 900px) {
  .macro-relations-variant-wrap { flex: 1 1 100%; }
  .macro-relations-variant-switch { width: 100%; overflow-x: auto; scrollbar-width: none; }
  .macro-relations-variant-switch::-webkit-scrollbar { display: none; }
  .macro-relations-variant-switch button { flex: 1 0 auto; }
}

/* ==============================================================
   Macrostructure Relations Modal — Pack 2 polish (5.10l)
   Clearer scope semantics + Storyline 1.1
   ============================================================== */
.macro-relations-scope-control {
  position: relative;
}

.macro-relations-scope-control > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.macro-relations-scope-help {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 999px;
  color: var(--ann-muted, #6c655c);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  outline: none;
}

.macro-relations-scope-help:hover,
.macro-relations-scope-help:focus-visible {
  color: var(--ann-btn-active-text, #2d527c);
  background: color-mix(in srgb, var(--ann-btn-hover-bg, #eaf2fb) 68%, transparent);
}

.macro-relations-scope-help-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 7px);
  z-index: 40;
  width: min(330px, 72vw);
  padding: 9px 10px;
  border: 1px solid var(--ann-border, #d8c9af);
  border-radius: 9px;
  background: var(--ann-menu-bg, #fffaf0);
  color: var(--ann-text, #342f27);
  box-shadow: 0 10px 24px rgba(15,23,42,.16);
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity .12s ease, transform .12s ease, visibility .12s ease;
}

.macro-relations-scope-help:hover .macro-relations-scope-help-popover,
.macro-relations-scope-help:focus .macro-relations-scope-help-popover,
.macro-relations-scope-help:focus-within .macro-relations-scope-help-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.macro-relations-scope-note {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-height: 24px;
  margin-top: 5px;
  padding: 3px 2px 0;
  color: var(--ann-muted, #70685f);
  font-size: .7rem;
  line-height: 1.35;
}

.macro-relations-scope-note strong {
  flex: 0 0 auto;
  color: var(--ann-text, #342f27);
  font-size: .7rem;
}

.macro-relations-control-row select option:disabled {
  color: #9a9389;
}

/* Storyline: hierarchy is a real left-hand layer, timeline is a separate layer. */
.macro-story-label-gutter {
  fill: color-mix(in srgb, var(--ann-surface, #fffaf0) 66%, transparent);
}

.macro-story-label-divider {
  stroke: color-mix(in srgb, #a99270 48%, var(--ann-border, #d8c9af));
  stroke-width: 1.2;
}

.macro-story-root-separator {
  stroke: color-mix(in srgb, #a99270 22%, transparent);
  stroke-width: 1;
  stroke-dasharray: 2 5;
}

.macro-storyline-svg .macro-story-containment {
  stroke: #a28d6d;
  stroke-width: 2.05;
  opacity: .9;
}

.macro-storyline-svg .macro-time-row-bg {
  fill: color-mix(in srgb, var(--ann-surface, #fffaf0) 24%, transparent);
}

.macro-storyline-svg .macro-time-row:hover .macro-time-row-bg {
  fill: color-mix(in srgb, var(--ann-btn-hover-bg, #eaf2fb) 24%, var(--ann-surface, #fffaf0));
}

.macro-storyline-svg .macro-time-row.is-focused .macro-time-row-bg {
  fill: color-mix(in srgb, #e7f1ff 22%, var(--ann-surface, #fffaf0));
}

.macro-time-selection-mark {
  fill: #4b78aa;
  opacity: .8;
}

.macro-time-gap-guide {
  stroke: #8ea2b6;
  stroke-width: 1.35;
  stroke-dasharray: 2 5;
  opacity: .7;
}

.macro-storyline-svg .macro-time-run {
  stroke-width: 6.5;
}

.macro-storyline-svg .macro-time-row.is-focused .macro-time-run {
  stroke-width: 7.4;
}

.macro-storyline-svg .macro-time-discourse-edge {
  stroke-width: 1.65;
  opacity: .8;
}

.macro-time-edge-chip {
  pointer-events: none;
}

.macro-time-edge-chip-bg {
  fill: color-mix(in srgb, var(--ann-surface, #fffaf0) 94%, #edf4fb);
  stroke: color-mix(in srgb, #6b86a4 38%, var(--ann-border, #d8c9af));
  stroke-width: 1;
}

.macro-storyline-svg .macro-time-edge-label {
  fill: #536d87;
  stroke: none;
  font-size: 8.5px;
  font-weight: 780;
}

@media (max-width: 760px) {
  .macro-relations-scope-note {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
}

/* ==============================================================
   ANNOTATION UX 5.10m — Segment ID / speaker spacing
   The legacy segment-id badge uses a negative right margin. In the main
   Annotation segment header this made the speaker name touch the ID badge.
   Keep the legacy rule elsewhere, but restore a clear gap in segment headers.
   ============================================================== */
.qa-segment-content-column > .segment-id-tag {
  margin-right: 0.5em;
}

/* Statistics 5.10v — temporary highlight after "Pokaż w Annotation". */
.qa-segment-row.stats-jump-highlight {
  outline: 2px solid color-mix(in srgb, var(--ann-accent, #4f63e8) 70%, transparent);
  outline-offset: -2px;
  border-radius: 12px;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--ann-accent, #4f63e8) 10%, transparent);
  transition: outline-color .25s ease, box-shadow .25s ease;
}
.qa-ann.annotation-jump-highlight {
  border-radius: 10px;
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--tmm-theme-accent) 28%, transparent);
  background: color-mix(in oklab, var(--tmm-theme-accent-soft) 34%, transparent);
  transition: box-shadow .2s ease, background .2s ease;
}


/* =========================================================
   GENERAL TAGS 2.0B — mapping editor + bulk workflow
   ========================================================= */
.taxonomy-modal-content {
  width: min(1320px, calc(100vw - 44px));
  max-width: 1320px;
  height: min(90vh, 960px);
  max-height: 960px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
}

.taxonomy-modal-content .config-header {
  padding: 18px 20px 15px;
  background: linear-gradient(180deg, #fbfdff 0%, #f7faff 100%);
  border-bottom: 1px solid #e3e9f1;
}

.taxonomy-modal-content .config-header h2 {
  margin: 0;
  letter-spacing: -.015em;
}

.taxonomy-modal-subtitle {
  max-width: 940px;
  margin-top: 6px;
  color: #65748a;
  font-size: .9rem;
}

.taxonomy-modal-body {
  padding: 16px 18px 18px;
  background:
    linear-gradient(rgba(123,145,175,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(123,145,175,.035) 1px, transparent 1px),
    #f7f9fc;
  background-size: 24px 24px;
}

.taxonomy-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 12px;
}

.taxonomy-kpi {
  min-height: 78px;
  padding: 12px 14px;
  border-color: #dce5ef;
  border-radius: 13px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 1px 2px rgba(15,23,42,.025);
}

.taxonomy-kpi--accent {
  border-color: #cfd7ff;
  background: linear-gradient(145deg, #f6f6ff, #fbfbff);
}

.taxonomy-kpi--identity {
  border-color: #cfe3dc;
  background: #f6fbf9;
}

.taxonomy-kpi--warning {
  border-color: #ead3a6;
  background: #fffaf1;
}

.taxonomy-kpi--wide {
  grid-column: 1 / -1;
  min-height: auto;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-top: 9px;
  padding-bottom: 9px;
}

.taxonomy-kpi--wide .taxonomy-kpi-label { margin-top: 0; }
.taxonomy-kpi-value { font-size: 1.28rem; }

.taxonomy-controls {
  grid-template-columns: minmax(320px, 1fr) minmax(220px, 290px);
  gap: 9px;
  top: -16px;
  padding: 11px 0 9px;
  background: #f7f9fc;
}

.taxonomy-search-wrap {
  position: relative;
}

.taxonomy-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #93a1b3;
  font-size: 1.05rem;
  pointer-events: none;
}

.taxonomy-search-wrap input {
  padding-left: 34px;
}

.taxonomy-controls input,
.taxonomy-controls select,
.taxonomy-bulk input,
.taxonomy-bulk select,
.taxonomy-inline-editor input,
.taxonomy-inline-editor select {
  min-height: 39px;
  border: 1px solid #cfd9e5;
  border-radius: 10px;
  background: #fff;
  color: #243246;
  font: inherit;
  font-size: .84rem;
  box-sizing: border-box;
}

.taxonomy-controls input:focus,
.taxonomy-controls select:focus,
.taxonomy-bulk input:focus,
.taxonomy-bulk select:focus,
.taxonomy-inline-editor input:focus,
.taxonomy-inline-editor select:focus {
  outline: 0;
  border-color: #8fa8ff;
  box-shadow: 0 0 0 3px rgba(99,102,241,.11);
}

.taxonomy-bulk {
  position: sticky;
  top: 53px;
  z-index: 5;
  display: grid;
  grid-template-columns: auto auto minmax(175px, .8fr) minmax(210px, 1fr) minmax(205px, .95fr) auto;
  gap: 9px;
  align-items: end;
  margin: 0 0 12px;
  padding: 10px;
  border: 1px solid #d8e0eb;
  border-radius: 14px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 6px 20px rgba(15,23,42,.05);
  backdrop-filter: blur(10px);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.taxonomy-bulk.has-selection {
  border-color: #b9c2ff;
  background: rgba(249,249,255,.98);
  box-shadow: 0 8px 24px rgba(79,70,229,.08);
}

.taxonomy-select-visible {
  min-height: 39px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 5px;
  color: #42516a;
  font-size: .8rem;
  font-weight: 700;
  white-space: nowrap;
}

.taxonomy-select-visible input,
.taxonomy-row-check {
  width: 17px;
  height: 17px;
  accent-color: #5b5ce2;
}

.taxonomy-bulk-selection {
  min-width: 76px;
  min-height: 39px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 8px;
  border-left: 1px solid #e4e9f0;
  color: #79879a;
  font-size: .7rem;
  line-height: 1.05;
}

.taxonomy-bulk-selection strong {
  color: #3436ae;
  font-size: 1.05rem;
}

.taxonomy-bulk-field {
  min-width: 0;
}

.taxonomy-bulk-field > span,
.taxonomy-field > span {
  display: block;
  margin: 0 0 4px 2px;
  color: #7b8797;
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .035em;
  text-transform: uppercase;
}

.taxonomy-bulk-field input,
.taxonomy-bulk-field select { width: 100%; padding: 7px 9px; }

.taxonomy-bulk-actions {
  display: flex;
  gap: 7px;
}

.taxonomy-bulk-actions .toolbar-button {
  min-height: 39px;
  padding: 0 12px;
  white-space: nowrap;
}

.taxonomy-bulk-actions .btn-primary:disabled {
  opacity: .42;
  cursor: not-allowed;
  box-shadow: none;
}

.taxonomy-bulk-mapped-field.is-hidden,
.taxonomy-row-mapped-field.is-hidden {
  display: none !important;
}

.taxonomy-list {
  gap: 13px;
}

.taxonomy-group {
  border-color: #dbe3ed;
  border-radius: 14px;
  background: rgba(255,255,255,.95);
  box-shadow: 0 2px 8px rgba(15,23,42,.025);
}

.taxonomy-group--unclassified { border-color: #ead7b2; }
.taxonomy-group--identity { border-color: #d4e5df; }
.taxonomy-group--type-pending { border-color: #ddd9f3; }

.taxonomy-group-head {
  min-height: 62px;
  padding: 11px 14px;
  background: #fafbfd;
}

.taxonomy-group--unclassified .taxonomy-group-head { background: #fffbf4; }
.taxonomy-group--identity .taxonomy-group-head { background: #f7fbfa; }
.taxonomy-group--type-pending .taxonomy-group-head { background: #faf9ff; }

.taxonomy-group-title-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.taxonomy-general-tools--compact {
  flex: 0 1 420px;
  grid-template-columns: minmax(180px, 1fr) auto;
}

.taxonomy-tag-row {
  position: relative;
  grid-template-columns: 32px minmax(260px, 1fr) minmax(300px, 1.05fr) auto;
  gap: 12px;
  min-height: 58px;
  padding: 8px 12px 8px 10px;
  background: rgba(255,255,255,.94);
}

.taxonomy-tag-row:hover {
  background: #fbfcff;
}

.taxonomy-tag-row.is-editing {
  background: #fafaff;
  box-shadow: inset 3px 0 0 #7777e8;
}

.taxonomy-select-cell {
  display: grid;
  place-items: center;
  align-self: stretch;
  cursor: pointer;
}

.taxonomy-tag-main {
  display: grid;
  grid-template-columns: minmax(0, auto) auto;
  align-items: baseline;
  justify-content: start;
  column-gap: 9px;
  row-gap: 2px;
}

.taxonomy-tag-name {
  font-weight: 720;
  color: #26354a;
}

.taxonomy-tag-en {
  grid-column: 1 / -1;
  color: #8995a5;
  font-size: .74rem;
  line-height: 1.2;
}

.taxonomy-tag-count {
  font-size: .72rem;
}

.taxonomy-row-projection {
  min-width: 0;
  align-self: center;
}

.taxonomy-projection {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  color: #536176;
  font-size: .8rem;
}

.taxonomy-projection-arrow,
.taxonomy-equals {
  color: #6e6fdc;
  font-weight: 900;
}

.taxonomy-projection-target {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #2d3f59;
  font-weight: 750;
}

.taxonomy-type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid #d7d9f1;
  border-radius: 999px;
  background: #f5f5ff;
  color: #5f60a9;
  font-size: .68rem;
  font-weight: 750;
}

.taxonomy-type-pill.is-pending {
  border-color: #ead9ae;
  background: #fff9eb;
  color: #956b18;
}

.taxonomy-projection--identity {
  color: #4f7567;
}

.taxonomy-projection--unassigned {
  color: #8b6c37;
}

.taxonomy-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #d3a94f;
  box-shadow: 0 0 0 3px rgba(211,169,79,.13);
}

.taxonomy-row-edit.toolbar-button {
  min-height: 34px;
  height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  color: #4f5e73;
  font-size: .78rem;
}

.taxonomy-inline-editor {
  grid-column: 2 / -1;
  margin: 2px 0 5px;
  padding: 12px;
  border: 1px solid #d9ddf3;
  border-radius: 12px;
  background: linear-gradient(145deg, #fbfbff, #f8f9ff);
}

.taxonomy-inline-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.taxonomy-inline-editor-head strong {
  display: block;
  color: #30334b;
  font-size: .83rem;
}

.taxonomy-inline-editor-head span {
  display: block;
  margin-top: 2px;
  color: #7c8798;
  font-size: .72rem;
}

.taxonomy-inline-grid {
  display: grid;
  grid-template-columns: minmax(170px, .8fr) minmax(210px, 1fr) minmax(210px, 1fr) auto;
  gap: 9px;
  align-items: end;
}

.taxonomy-field select,
.taxonomy-field input {
  width: 100%;
  padding: 7px 9px;
}

.taxonomy-inline-actions {
  display: flex;
  gap: 7px;
}

.taxonomy-inline-actions .toolbar-button {
  min-height: 39px;
  white-space: nowrap;
}

/* Manage Tag — explicit coarse-grained state */
.manage-tag-taxonomy-section {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #dbe3ed;
  border-radius: 14px;
  background: linear-gradient(145deg, #fbfcff, #f7f9fd);
}

.manage-tag-taxonomy-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}

.manage-tag-taxonomy-title {
  color: #27364b;
  font-weight: 800;
}

.manage-tag-taxonomy-subtitle {
  margin-top: 3px;
  color: #738095;
  font-size: .78rem;
  line-height: 1.35;
}

.manage-tag-taxonomy-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid #d5d8f0;
  border-radius: 999px;
  background: #f3f3ff;
  color: #6667ac;
  font-size: .66rem;
  font-weight: 750;
}

.manage-tag-projection-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 8px;
}

.manage-tag-projection-choice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 66px;
  padding: 10px;
  border: 1px solid #d9e1eb;
  border-radius: 11px;
  background: #fff;
  cursor: pointer;
  transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}

.manage-tag-projection-choice:hover {
  border-color: #c3cbed;
  background: #fbfbff;
}

.manage-tag-projection-choice.is-active {
  border-color: #9798e9;
  background: #f7f7ff;
  box-shadow: 0 0 0 2px rgba(99,102,241,.08);
}

.manage-tag-projection-choice input {
  margin-top: 2px;
  accent-color: #5b5ce2;
}

.manage-tag-projection-choice strong,
.manage-tag-projection-choice small {
  display: block;
}

.manage-tag-projection-choice strong {
  color: #303d52;
  font-size: .8rem;
}

.manage-tag-projection-choice small {
  margin-top: 3px;
  color: #78869a;
  font-size: .7rem;
  line-height: 1.3;
}

.manage-tag-general-mapped-fields {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0, .9fr);
  gap: 9px;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid #e5eaf1;
}

.manage-tag-general-mapped-fields[hidden] { display: none !important; }

.manage-tag-taxonomy-field > span {
  display: block;
  margin: 0 0 5px 2px;
  color: #6f7c8f;
  font-size: .72rem;
  font-weight: 750;
}

.manage-tag-taxonomy-field input,
.manage-tag-taxonomy-field select {
  width: 100%;
  min-height: 40px;
  box-sizing: border-box;
  padding: 7px 9px;
  border: 1px solid #ccd7e4;
  border-radius: 9px;
  background: #fff;
  color: #26354a;
  font: inherit;
}

.manage-tag-generalization-help {
  grid-column: 1 / -1;
  margin-top: -1px;
  padding: 7px 9px;
  border-radius: 8px;
  background: #f2f4fb;
  color: #707d91;
  font-size: .72rem;
  line-height: 1.35;
}

@media (max-width: 1120px) {
  .taxonomy-bulk {
    grid-template-columns: auto auto minmax(180px, 1fr) minmax(200px, 1fr);
  }
  .taxonomy-bulk-field:nth-of-type(3) { grid-column: 1 / 3; }
  .taxonomy-bulk-actions { justify-content: flex-end; }
  .taxonomy-tag-row {
    grid-template-columns: 32px minmax(220px, 1fr) minmax(250px, 1fr) auto;
  }
  .taxonomy-inline-grid { grid-template-columns: 1fr 1fr; }
  .taxonomy-inline-actions { justify-content: flex-end; }
}

@media (max-width: 820px) {
  .taxonomy-modal-content {
    width: calc(100vw - 16px);
    height: calc(100vh - 16px);
  }
  .taxonomy-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .taxonomy-kpi--wide { grid-column: 1 / -1; }
  .taxonomy-controls { grid-template-columns: 1fr; top: -16px; }
  .taxonomy-bulk {
    position: static;
    grid-template-columns: 1fr 1fr;
  }
  .taxonomy-select-visible,
  .taxonomy-bulk-selection { border-left: 0; }
  .taxonomy-bulk-field { grid-column: 1 / -1; }
  .taxonomy-bulk-actions { grid-column: 1 / -1; }
  .taxonomy-tag-row {
    grid-template-columns: 30px minmax(0,1fr) auto;
  }
  .taxonomy-row-projection { grid-column: 2 / -1; }
  .taxonomy-inline-editor { grid-column: 2 / -1; }
  .taxonomy-inline-grid { grid-template-columns: 1fr; }
  .manage-tag-projection-choices { grid-template-columns: 1fr; }
  .manage-tag-general-mapped-fields { grid-template-columns: 1fr; }
  .manage-tag-generalization-help { grid-column: 1; }
}

/* =========================================================
   General Tags 2.0C — Projection UX
   ========================================================= */
.annotation-tag--general-fallback {
  position: relative;
  border: 1px dashed #d2a351 !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.34);
  filter: saturate(.82);
}

.annotation-tag--general-fallback::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(210,163,81,.10);
}

.tag-level-marker--pending {
  background: rgba(255,248,230,.86);
  border-color: rgba(183,125,27,.34);
  color: #8a5a08;
  min-width: 1.7em;
}

.annotation-tag--general-missing {
  gap: .2em;
  min-height: 1.95em;
  padding-right: .7em;
  font-size: .73rem;
  font-weight: 650;
}

/* =========================================================
   GENERAL TAGS 2.0D — Mapping Workflow Polish
   ========================================================= */
.taxonomy-kpi--filter {
  appearance: none;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.taxonomy-kpi--filter:hover {
  transform: translateY(-1px);
  border-color: #c5d0df;
  box-shadow: 0 5px 14px rgba(15,23,42,.055);
}
.taxonomy-kpi--filter:focus-visible {
  outline: 2px solid #7e8ff1;
  outline-offset: 2px;
}

/* The bulk editor stays quiet until there is an actual selection. */
.taxonomy-bulk:not(.has-selection) {
  grid-template-columns: auto auto 1fr;
  align-items: center;
  min-height: 54px;
  padding-top: 7px;
  padding-bottom: 7px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 2px 10px rgba(15,23,42,.035);
}
.taxonomy-bulk:not(.has-selection) .taxonomy-bulk-field,
.taxonomy-bulk:not(.has-selection) .taxonomy-bulk-actions {
  display: none !important;
}
.taxonomy-bulk:not(.has-selection) .taxonomy-bulk-selection {
  border-right: 0;
}
.taxonomy-bulk.has-selection .taxonomy-bulk-selection {
  padding-left: 10px;
}
.taxonomy-bulk.has-selection #tagTaxonomyBulkApply {
  min-width: 190px;
}

.taxonomy-type-pill--identity {
  border-color: #cfe3dc;
  background: #f3faf7;
  color: #4f7567;
}
.taxonomy-projection-source {
  max-width: 185px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #5d6b7e;
  font-weight: 650;
}
.taxonomy-projection--identity .taxonomy-projection-arrow {
  color: #6f9a89;
}

.taxonomy-identity-preview {
  min-height: 39px;
  padding: 7px 10px;
  border: 1px solid #cfe3dc;
  border-radius: 10px;
  background: #f6fbf9;
  color: #4f7567;
}
.taxonomy-identity-preview > span {
  display: block;
  margin-bottom: 2px;
  color: #7a8d85;
  font-size: .63rem;
  font-weight: 800;
  letter-spacing: .035em;
  text-transform: uppercase;
}
.taxonomy-identity-preview strong {
  font-size: .78rem;
}
.taxonomy-identity-preview b {
  padding: 0 4px;
  color: #769486;
}
.taxonomy-identity-preview.is-hidden { display: none !important; }

.taxonomy-required-note {
  display: block;
  margin: 4px 2px 0;
  color: #8a6a2c;
  font-size: .64rem;
  line-height: 1.25;
}

.taxonomy-toast {
  position: sticky;
  top: 118px;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: -3px 0 12px;
  padding: 10px 12px;
  border: 1px solid #bedccb;
  border-radius: 12px;
  background: rgba(244,251,247,.98);
  color: #355d4e;
  box-shadow: 0 8px 22px rgba(26,78,57,.09);
  font-size: .8rem;
  font-weight: 650;
  backdrop-filter: blur(8px);
}
.taxonomy-toast[hidden] { display: none !important; }
.taxonomy-toast-message { min-width: 0; }
.taxonomy-toast-undo {
  flex: 0 0 auto;
  padding: 5px 10px;
  border: 1px solid #aacfbf;
  border-radius: 999px;
  background: #fff;
  color: #376a57;
  font: inherit;
  font-size: .75rem;
  font-weight: 800;
  cursor: pointer;
}
.taxonomy-toast-undo:hover { background: #f0faf5; }

.taxonomy-row-edit.toolbar-button {
  min-width: 62px;
  font-weight: 750;
}
.taxonomy-projection--unassigned span:last-child {
  font-weight: 650;
}

@media (max-width: 1120px) {
  .taxonomy-bulk:not(.has-selection) {
    grid-template-columns: auto auto 1fr;
  }
  .taxonomy-bulk.has-selection #tagTaxonomyBulkApply { min-width: 0; }
  .taxonomy-identity-preview { grid-column: span 1; }
}

@media (max-width: 820px) {
  .taxonomy-bulk:not(.has-selection) {
    grid-template-columns: 1fr auto;
  }
  .taxonomy-bulk:not(.has-selection) .taxonomy-bulk-selection {
    justify-self: end;
  }
  .taxonomy-toast { top: 0; }
}

/* =========================================================
   GENERAL TAGS 2.0D1 — Sorting & Navigation Polish
   ========================================================= */
.taxonomy-controls {
  grid-template-columns: minmax(320px, 1fr) minmax(190px, 245px) minmax(210px, 270px);
  align-items: end;
}

.taxonomy-control-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.taxonomy-control-field > span {
  margin-left: 2px;
  color: #748196;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.taxonomy-search-wrap {
  align-self: end;
}

#tagTaxonomySort {
  font-weight: 650;
  color: #334155;
}

#tagTaxonomySort:focus {
  border-color: #8fa8ff;
  box-shadow: 0 0 0 3px rgba(99,102,241,.11);
}

@media (max-width: 1080px) {
  .taxonomy-controls {
    grid-template-columns: 1fr 1fr;
  }
  .taxonomy-search-wrap {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .taxonomy-controls {
    grid-template-columns: 1fr;
  }
  .taxonomy-search-wrap,
  .taxonomy-control-field {
    grid-column: 1;
  }
}

/* Transcript 1.0C — discreet per-segment transcript QA status */
.transcript-segment-status{display:inline-flex;align-items:center;justify-content:center;width:15px;height:15px;margin-left:4px;vertical-align:1px;border-radius:999px;font-size:9px;font-weight:900;line-height:1;border:1px solid transparent}.transcript-segment-status.is-done{background:#f0fdf4;color:#166534;border-color:#bbf7d0}.transcript-segment-status.is-warning{background:#fff7ed;color:#9a3412;border-color:#fed7aa}


/* =========================================================
   PERSISTENCE 1.0A — visible autosave state
   ========================================================= */
.autosave-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--ann-border);
  border-radius: 999px;
  background: var(--ann-btn-bg);
  color: var(--ann-muted);
  font-size: .72rem;
  font-weight: 750;
  white-space: nowrap;
  box-shadow: var(--ann-shadow-soft);
}
.autosave-status[hidden] { display: none !important; }
.autosave-status[data-state="saving"] {
  color: #475569;
  background: #f8fafc;
}
.autosave-status[data-state="saved"] {
  color: #166534;
  border-color: #bbf7d0;
  background: #f0fdf4;
}
.autosave-status[data-state="error"],
.autosave-status[data-state="blocked"] {
  color: #991b1b;
  border-color: #fecaca;
  background: #fef2f2;
}
@media (max-width: 900px) {
  .autosave-status {
    min-height: 28px;
    padding-inline: 8px;
    font-size: .68rem;
  }
}

/* === Audit 07: single-editor safety === */
.editor-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(3px);
}

.editor-lock-overlay[hidden] {
  display: none !important;
}

.editor-lock-card {
  width: min(560px, calc(100vw - 32px));
  border-radius: 18px;
  padding: 28px;
  background: var(--surface, #fff);
  color: var(--text, #172033);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  text-align: center;
}

.editor-lock-icon {
  font-size: 34px;
  line-height: 1;
  margin-bottom: 12px;
}

.editor-lock-card h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
}

.editor-lock-card p {
  margin: 0 auto 22px;
  max-width: 48ch;
  line-height: 1.55;
  color: var(--text-muted, #596579);
}

.editor-lock-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.editor-lock-reader {
  text-decoration: none;
}

.autosave-status[data-state="locked"] {
  border-color: rgba(148, 163, 184, 0.55);
  background: rgba(148, 163, 184, 0.14);
  color: inherit;
}

@media (max-width: 640px) {
  .editor-lock-card { padding: 22px 18px; }
  .editor-lock-actions { flex-direction: column; }
  .editor-lock-actions .toolbar-button { width: 100%; justify-content: center; }
}

/* =========================================================
   PERSISTENCE 1.0C — storage + performance diagnostics
   ========================================================= */
.storage-metrics-wrap { position: relative; }
.storage-metrics-toggle {
  min-width: 86px;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.storage-metrics-toggle[data-level="warning"] {
  border-color: #facc15;
  background: #fefce8;
  color: #854d0e;
}
.storage-metrics-toggle[data-level="high"] {
  border-color: #fdba74;
  background: #fff7ed;
  color: #9a3412;
}
.storage-metrics-toggle[data-level="critical"] {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}
.storage-metrics-panel {
  width: min(390px, calc(100vw - 24px));
  padding: 14px;
}
.storage-metrics-reference { margin: 4px 0 12px; }
.storage-metrics-reference-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: .78rem;
}
.storage-metrics-reference-head strong { font-variant-numeric: tabular-nums; }
.storage-metrics-progress {
  height: 7px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, .2);
}
.storage-metrics-progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #64748b;
  transition: width .18s ease;
}
.storage-metrics-progress > span[data-level="warning"] { background: #ca8a04; }
.storage-metrics-progress > span[data-level="high"] { background: #ea580c; }
.storage-metrics-progress > span[data-level="critical"] { background: #dc2626; }
.storage-metrics-hint {
  margin: 7px 0 0;
  color: var(--ann-muted);
  font-size: .68rem;
  line-height: 1.35;
}
.storage-metrics-warning {
  margin: 8px 0 12px;
  padding: 8px 10px;
  border: 1px solid #fed7aa;
  border-radius: 9px;
  background: #fff7ed;
  color: #9a3412;
  font-size: .72rem;
  line-height: 1.4;
}
.storage-metrics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 14px;
  margin: 0;
  font-size: .74rem;
}
.storage-metrics-grid dt { color: var(--ann-muted); min-width: 0; }
.storage-metrics-grid dd {
  margin: 0;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.storage-metrics-grid [hidden] { display: none !important; }
.storage-metrics-subheading {
  margin: 13px 0 8px;
  padding-top: 10px;
  border-top: 1px solid var(--ann-border);
  font-size: .7rem;
  font-weight: 800;
  color: var(--ann-muted);
  text-transform: uppercase;
  letter-spacing: .035em;
}
.storage-metrics-panel .footer-popover-action { margin-top: 12px; }
@media (max-width: 640px) {
  .storage-metrics-toggle { min-width: 74px; }
  .storage-metrics-panel { width: min(340px, calc(100vw - 16px)); }
}

/* =========================================================
   Annotation UX 4 — Hierarchy Arrow Editor
   Jedna kolumna; ↑↓ zmieniają kolejność, ←→ poziom hierarchii.
   ========================================================= */
.hierarchy-editor-arrow .hierarchy-editor-body {
  grid-template-columns: minmax(0, 1fr);
}

.hierarchy-editor-arrow .hierarchy-tree-node {
  margin-left: calc(var(--hierarchy-depth, 0) * 32px);
}

.hierarchy-editor-arrow .hierarchy-tree-node:not([style*="--hierarchy-depth: 0"])::before {
  left: -18px;
  width: 16px;
}

.hierarchy-editor-arrow .hierarchy-tree-row {
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.62rem;
  align-items: flex-start;
  cursor: default;
}

.hierarchy-arrow-controls {
  display: grid;
  grid-template-columns: repeat(4, 28px);
  gap: 3px;
  align-items: center;
  padding-top: 0.02rem;
  flex: 0 0 auto;
}

.hierarchy-arrow-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #52657d;
  font: inherit;
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.hierarchy-arrow-btn:hover:not(:disabled) {
  background: #eaf3ff;
  border-color: #9fbee1;
  color: #23598c;
}

.hierarchy-arrow-btn:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 2px;
}

.hierarchy-arrow-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

.hierarchy-node-select {
  appearance: none;
  min-width: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 0.45rem;
  align-items: flex-start;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.hierarchy-node-select:focus-visible {
  outline: 2px solid #60a5fa;
  outline-offset: 3px;
  border-radius: 6px;
}

body.bg-paper .hierarchy-arrow-btn {
  background: #fffaf0;
  border-color: #d9c7a7;
  color: #765b38;
}
body.bg-paper .hierarchy-arrow-btn:hover:not(:disabled) {
  background: #f2e5cb;
  border-color: #c6a878;
  color: #684719;
}

@media (max-width: 760px) {
  .hierarchy-editor-arrow .hierarchy-tree-node {
    margin-left: calc(var(--hierarchy-depth, 0) * 22px);
  }
  .hierarchy-editor-arrow .hierarchy-tree-row {
    grid-template-columns: 1fr;
  }
  .hierarchy-arrow-controls {
    grid-template-columns: repeat(4, 32px);
  }
  .hierarchy-arrow-btn {
    width: 32px;
    height: 32px;
  }
}


/* =========================================================
   Annotation UX 5.10h — Bottom Bar Cleanup
   Media and storage diagnostics live in Tools; only their entry points move.
   ========================================================= */
#annotation-footer .footer-tools-split-action {
  justify-content: space-between !important;
  gap: 12px;
}

#annotation-footer .footer-tools-action-label {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#annotation-footer .footer-tools-action-meta {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--ann-muted, #64748b);
  font-size: .76rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

#annotation-footer .footer-tools-panel #mediaToolbarBtn.media-toolbar-btn {
  display: flex !important;
}

#annotation-footer .storage-metrics-anchor {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
}

/* JSON import: auditable, non-destructive correction report (Oct 2026). */
.json-import-repair-dialog {
  width: min(700px, calc(100vw - 32px));
  max-height: min(80vh, 730px);
  overflow-y: auto;
  box-sizing: border-box;
  border: 1px solid var(--border-color, #b7b7b7);
  border-radius: 14px;
  padding: 24px;
  background: var(--surface-color, #fff);
  color: var(--text-color, #202124);
  box-shadow: 0 15px 45px rgba(0,0,0,.26);
  z-index: 10050;
}
.json-import-repair-dialog::backdrop { background: rgba(0,0,0,.53); }
.json-import-repair-dialog h2 { margin: 0 0 14px; font-size: 1.25rem; }
.json-import-repair-dialog p { margin: 10px 0; line-height: 1.55; }
.json-import-repair-lines {
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: min(40vh, 350px);
  overflow-y: auto;
  padding: 12px;
  font-size: 12px;
  line-height: 1.7;
  border: 1px solid #a2a2a2;
  border-radius: 8px;
  background: rgba(127,127,127,.08);
  color: inherit;
}
.json-import-repair-actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.json-import-repair-actions button { padding: 9px 15px; cursor: pointer; border-radius: 8px; border: 1px solid #929292; }
