.lexres-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2vw, 24px);
  background: rgba(15, 23, 42, .58);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.lexres-dialog {
  --lexres-ink: #172033;
  --lexres-muted: #607086;
  --lexres-line: #d5e0e5;
  --lexres-soft: #f5f8f8;
  --lexres-teal: #176a70;
  --lexres-teal-dark: #0d5358;
  --lexres-attention: #a44825;
  width: min(1080px, 100%);
  max-height: calc(100vh - clamp(16px, 4vw, 48px));
  overflow: auto;
  color: var(--lexres-ink);
  background: #fff;
  border: 1px solid rgba(255, 255, 255, .66);
  border-radius: 22px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
  scrollbar-gutter: stable;
}

.lexres-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px 18px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--lexres-line);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.lexres-eyebrow {
  margin: 0 0 4px;
  color: var(--lexres-attention);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.lexres-title {
  margin: 0;
  color: var(--lexres-ink);
  font-size: clamp(27px, 4vw, 39px);
  line-height: 1.05;
}

.lexres-subtitle {
  margin: 8px 0 0;
  color: var(--lexres-muted);
  font-size: 15px;
}

.lexres-material {
  margin: 8px 0 0;
  color: var(--lexres-muted);
  font-size: 15px;
}

.lexres-close,
.lexres-btn,
.lexres-button,
.lexres-help,
.lexres-candidate {
  min-height: 44px;
  border: 1px solid #b9cbd2;
  border-radius: 12px;
  background: #fff;
  color: var(--lexres-ink);
  font: inherit;
  cursor: pointer;
}

.lexres-close {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  padding: 0;
  font-size: 23px;
}

.lexres-close:hover,
.lexres-btn:hover,
.lexres-button:hover,
.lexres-candidate:hover {
  border-color: var(--lexres-teal);
  background: #f1f8f8;
}

.lexres-dialog :focus-visible {
  outline: 3px solid #51b7c0;
  outline-offset: 3px;
}

.lexres-intro {
  padding: 22px 24px 20px;
  background: linear-gradient(135deg, #f7fbfa 0%, #f2f7f8 100%);
  border-bottom: 1px solid var(--lexres-line);
}

.lexres-intro > p {
  max-width: 820px;
  margin: 0;
  color: #33455a;
  line-height: 1.55;
}

.lexres-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: lexres-step;
}

.lexres-steps li {
  position: relative;
  min-height: 70px;
  padding-inline-start: 45px;
  counter-increment: lexres-step;
}

.lexres-steps li::before {
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #fff;
  background: var(--lexres-teal);
  border-radius: 50%;
  content: counter(lexres-step);
  font-weight: 800;
}

.lexres-steps strong,
.lexres-steps span {
  display: block;
}

.lexres-steps span {
  margin-top: 5px;
  color: var(--lexres-muted);
  font-size: 13px;
  line-height: 1.4;
}

.lexres-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  padding: 20px 24px;
  background: var(--lexres-soft);
  border-bottom: 1px solid var(--lexres-line);
}

.lexres-counts {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 22px;
}

.lexres-count {
  min-width: 96px;
  padding: 3px 0 3px 12px;
  border-inline-start: 3px solid #dc704b;
}

.lexres-count strong,
.lexres-count span {
  display: block;
}

.lexres-count strong {
  margin-bottom: 2px;
  font-size: 24px;
  line-height: 1;
}

.lexres-count span {
  color: #405268;
  font-size: 13px;
}

.lexres-export-box {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 390px;
}

.lexres-export-copy strong,
.lexres-export-copy span {
  display: block;
}

.lexres-export-copy span {
  margin-top: 3px;
  color: var(--lexres-muted);
  font-size: 12px;
  line-height: 1.35;
}

.lexres-body {
  padding: 22px 24px 28px;
}

.lexres-status {
  min-height: 22px;
  margin: 0 0 14px;
  color: var(--lexres-muted);
}

.lexres-status[data-kind="error"],
.lexres-status[data-state="error"] {
  color: #a12622;
}

.lexres-status[data-kind="success"],
.lexres-status[data-state="ready"] {
  color: #17643d;
}

.lexres-filters {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(210px, .55fr) auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--lexres-line);
}

.lexres-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.lexres-filter,
.lexres-form label {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  color: #42546a;
  font-size: 12px;
}

.lexres-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 25px;
}

.lexres-field > label,
.lexres-field-label {
  color: #42546a;
  font-size: 12px;
}

.lexres-field input,
.lexres-field select,
.lexres-filter input,
.lexres-filter select,
.lexres-form input,
.lexres-form select {
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 9px 11px;
  color: var(--lexres-ink);
  background: #fff;
  border: 1px solid #b8cad2;
  border-radius: 10px;
  font: inherit;
}

.lexres-field-help {
  color: var(--lexres-muted);
  font-size: 11px;
  line-height: 1.35;
}

.lexres-pealim-open {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  color: var(--lexres-teal);
  font-size: 12px;
  font-weight: 750;
}

.lexres-field-note {
  color: var(--lexres-muted);
  font-size: 12px;
  line-height: 1.35;
}

.lexres-shown {
  padding-bottom: 11px;
  color: var(--lexres-muted);
  font-size: 13px;
  white-space: nowrap;
}

.lexres-clusters {
  display: grid;
  gap: 18px;
}

.lexres-cluster {
  border: 1px solid var(--lexres-line);
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(33, 53, 67, .06);
}

.lexres-cluster > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 11px;
  min-height: 64px;
  box-sizing: border-box;
  padding: 13px 16px;
  background: #f7f9f9;
  border-radius: 17px;
  cursor: pointer;
  list-style-position: inside;
}

.lexres-cluster[open] > summary {
  border-bottom: 1px solid var(--lexres-line);
  border-radius: 17px 17px 0 0;
}

.lexres-token,
.lexres-term {
  margin-inline-end: 4px;
  font-size: 25px;
  font-weight: 800;
}

.lexres-count-chip,
.lexres-badge,
.lexres-reason {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.25;
}

.lexres-count-chip,
.lexres-badge {
  color: #0f5960;
  background: #e8f4f2;
  font-weight: 800;
}

.lexres-reason {
  color: #65421f;
  background: #fff2dc;
  border: 1px solid #edd4a7;
}

.lexres-cluster-inner {
  padding: 18px;
}

.lexres-editor {
  padding: 0;
}

.lexres-editor h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.lexres-why {
  margin: 0 0 18px;
  padding: 14px 16px;
  color: #394c61;
  background: #fff9ed;
  border-inline-start: 4px solid #db8b3f;
  border-radius: 10px;
}

.lexres-why strong {
  display: block;
  margin-bottom: 7px;
}

.lexres-why h3 {
  margin: 0 0 7px;
  font-size: 15px;
}

.lexres-why ul {
  margin: 0;
  padding-inline-start: 20px;
}

.lexres-why li + li {
  margin-top: 5px;
}

.lexres-candidates {
  display: block;
  margin-bottom: 17px;
}

.lexres-candidates h4 {
  margin: 0;
  font-size: 15px;
}

.lexres-candidates .lexres-candidate {
  margin: 0 8px 8px 0;
}

.lexres-candidate {
  min-height: 38px;
  padding: 7px 11px;
}

.lexres-candidate.is-selected {
  color: #fff;
  background: var(--lexres-teal);
  border-color: var(--lexres-teal);
}

.lexres-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.lexres-batch {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  padding: 13px 14px;
  background: #fbf7f2;
  border-radius: 10px;
}

.lexres-batch input {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 1px 0 0;
}

.lexres-batch-copy strong,
.lexres-batch-copy span {
  display: block;
}

.lexres-batch-copy span {
  margin-top: 4px;
  color: var(--lexres-muted);
  font-size: 12px;
  line-height: 1.4;
}

.lexres-contexts {
  margin: 18px 0 0;
  padding: 16px 0 0;
  border: 0;
  border-top: 1px solid var(--lexres-line);
}

.lexres-contexts legend {
  padding: 0;
  font-size: 16px;
  font-weight: 800;
}

.lexres-selection-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin: 12px 0;
  padding: 11px 12px;
  background: #eef7f6;
  border: 1px solid #c8dfdd;
  border-radius: 10px;
}

.lexres-selected-count {
  color: var(--lexres-teal-dark);
  font-size: 13px;
}

.lexres-select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}

.lexres-select-all input {
  width: 24px;
  height: 24px;
  margin: 0;
}

.lexres-select-all:has(input:disabled) {
  color: var(--lexres-muted);
  cursor: not-allowed;
}

.lexres-manual-selection {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--lexres-muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline dotted;
  text-underline-offset: 4px;
  cursor: help;
}

.lexres-manual-selection:focus-visible {
  outline: 3px solid #51b7c0;
  outline-offset: 3px;
  border-radius: 5px;
}

.lexres-prior-analysis {
  margin: 0 0 15px;
  padding: 11px 13px;
  color: #174f53;
  background: #eef7f6;
  border-inline-start: 4px solid var(--lexres-teal);
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.45;
}

.lexres-context-help,
.lexres-editor-copy,
.lexres-candidates > p {
  margin: 6px 0 12px;
  color: var(--lexres-muted);
  font-size: 13px;
  line-height: 1.45;
}

.lexres-context-list {
  display: grid;
  gap: 9px;
  max-height: 330px;
  overflow: auto;
  overscroll-behavior: contain;
}

.lexres-context {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px 14px;
  background: #fff4f0;
  border-radius: 11px;
}

.lexres-context.is-selected {
  background: #edf7f6;
  box-shadow: inset 0 0 0 1px #9fcac7;
}

.lexres-context input {
  width: 24px;
  height: 24px;
  margin-top: 3px;
}

.lexres-context-he,
.lexres-context-translation,
.lexres-context bdi,
.lexres-context small {
  display: block;
}

.lexres-context-he,
.lexres-context bdi {
  font-size: 18px;
  line-height: 1.45;
}

.lexres-context-translation,
.lexres-context small {
  margin-top: 4px;
  color: #53647a;
  font-size: 13px;
}

.lexres-technical {
  margin-top: 8px;
  color: var(--lexres-muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.lexres-technical summary {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  color: #53647a;
  cursor: pointer;
}

.lexres-actions,
.lexres-impact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--lexres-line);
}

.lexres-btn,
.lexres-button {
  padding: 9px 15px;
  font-weight: 650;
}

.lexres-btn-primary,
.lexres-primary {
  color: #fff;
  background: var(--lexres-teal);
  border-color: var(--lexres-teal);
}

.lexres-btn-primary:hover,
.lexres-primary:hover {
  color: #fff;
  background: var(--lexres-teal-dark);
  border-color: var(--lexres-teal-dark);
}

.lexres-btn-danger {
  color: #8c2e25;
  border-color: #e2b8b1;
}

.lexres-btn[aria-disabled="true"],
.lexres-button[aria-disabled="true"] {
  color: #8995a2;
  background: #f3f5f6;
  border-color: #d9e0e4;
  cursor: not-allowed;
}

.lexres-tip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.lexres-tooltip {
  position: absolute;
  z-index: 60;
  inset-inline-start: 50%;
  bottom: calc(100% + 9px);
  width: max-content;
  max-width: min(330px, 76vw);
  padding: 9px 11px;
  color: #fff;
  background: #172033;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .25);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity .14s ease, transform .14s ease;
}

[dir="rtl"] .lexres-tooltip {
  transform: translate(50%, 4px);
}

.lexres-tip-wrap:hover > .lexres-tooltip,
.lexres-tip-wrap > :focus-visible + .lexres-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

[dir="rtl"] .lexres-tip-wrap:hover > .lexres-tooltip,
[dir="rtl"] .lexres-tip-wrap > :focus-visible + .lexres-tooltip {
  transform: translate(50%, 0);
}

.lexres-help {
  display: inline-grid;
  place-items: center;
  width: 24px;
  min-height: 24px;
  padding: 0;
  color: #3f5c70;
  background: #fff;
  border-color: #bccbd2;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.lexres-impact {
  padding: 4px 0;
}

.lexres-impact h2 {
  margin: 0 0 8px;
  font-size: 25px;
}

.lexres-impact > p {
  color: #405268;
}

.lexres-impact-list {
  max-height: 360px;
  overflow: auto;
  margin: 16px 0;
  padding: 0;
  list-style: none;
}

.lexres-impact-list li {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--lexres-line);
}

.lexres-empty {
  padding: 28px 18px;
  color: var(--lexres-muted);
  text-align: center;
  background: var(--lexres-soft);
  border-radius: 12px;
}

@media (max-width: 760px) {
  .lexres-steps,
  .lexres-form {
    grid-template-columns: 1fr;
  }

  .lexres-steps {
    gap: 8px;
  }

  .lexres-steps li {
    min-height: 48px;
  }

  .lexres-toolbar,
  .lexres-filters {
    grid-template-columns: 1fr;
  }

  .lexres-export-box {
    max-width: none;
    justify-content: space-between;
  }

  .lexres-shown {
    padding: 0;
  }
}

@media (max-width: 640px) {
  .lexres-overlay {
    padding: 0;
  }

  .lexres-dialog {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .lexres-head,
  .lexres-intro,
  .lexres-toolbar,
  .lexres-body {
    padding-inline: 16px;
  }

  .lexres-title {
    font-size: 29px;
  }

  .lexres-counts {
    gap: 14px;
  }

  .lexres-count {
    min-width: 84px;
  }

  .lexres-editor {
    padding: 0;
  }

  .lexres-cluster-inner {
    padding: 15px;
  }

  .lexres-actions > .lexres-tip-wrap,
  .lexres-impact-actions > .lexres-tip-wrap {
    width: 100%;
  }

  .lexres-actions .lexres-btn,
  .lexres-actions .lexres-button,
  .lexres-impact-actions .lexres-btn,
  .lexres-impact-actions .lexres-button {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .lexres-export-box {
    align-items: stretch;
    flex-direction: column;
  }

  .lexres-export-box .lexres-tip-wrap,
  .lexres-export-box .lexres-btn,
  .lexres-export-box .lexres-button {
    width: 100%;
  }

  .lexres-context {
    padding-inline: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lexres-tooltip {
    transition: none;
  }
}
