:root {
  --regex-purple: #7051bf;
  --regex-purple-soft: color-mix(
    in srgb,
    var(--regex-purple) 13%,
    var(--toolbox-surface)
  );
  --regex-mint: #41bda8;
  --regex-warning: #b66d08;
  --regex-success: #237b57;
  --capture-1: #7357c8;
  --capture-2: #087986;
  --capture-3: #b14d24;
  --capture-4: #b13775;
  --capture-5: #4e7c1f;
  --capture-6: #2766b5;
  --capture-7: #8a6411;
  --capture-8: #72544d;
}

[data-toolbox-theme="dark"] {
  --regex-success: #62d19e;
  --capture-1: #b7a2ff;
  --capture-2: #55d5e3;
  --capture-3: #ff9a70;
  --capture-4: #ff8fc6;
  --capture-5: #a8d96f;
  --capture-6: #82b7ff;
  --capture-7: #e6bd5c;
  --capture-8: #d5aaa0;
}

@media (prefers-color-scheme: dark) {
  [data-toolbox-theme="system"] {
    --regex-success: #62d19e;
    --capture-1: #b7a2ff;
    --capture-2: #55d5e3;
    --capture-3: #ff9a70;
    --capture-4: #ff8fc6;
    --capture-5: #a8d96f;
    --capture-6: #82b7ff;
    --capture-7: #e6bd5c;
    --capture-8: #d5aaa0;
  }
}

* {
  box-sizing: border-box;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="checkbox"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.cm-editor.cm-focused {
  outline: 3px solid color-mix(in srgb, var(--toolbox-focus) 62%, transparent);
  outline-offset: 2px;
}

.regex-application {
  position: relative;
  width: min(100%, 90rem);
  margin-inline: auto;
  padding: 1rem clamp(0.75rem, 2.5vw, 2rem) 3rem;
  color: var(--toolbox-text);
}

.workbench-loading {
  width: min(100%, 90rem);
  margin: 2rem auto;
  padding: 2rem;
  color: var(--toolbox-muted);
  text-align: center;
}

.panel {
  min-width: 0;
  border: 1px solid var(--toolbox-border);
  border-radius: var(--toolbox-radius);
  background: var(--toolbox-surface);
  box-shadow: 0 8px 28px rgb(20 30 60 / 5%);
}

.panel-heading {
  display: flex;
  min-height: 4rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--toolbox-border);
}

.editor-heading-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem 0.75rem;
  color: var(--toolbox-muted);
  font-size: 0.78rem;
}

.panel-heading.compact {
  min-height: 3rem;
}

.panel-heading h2,
.panel-heading p {
  margin: 0;
}

.panel-heading h2 {
  font-size: 1rem;
  line-height: 1.25;
}

.eyebrow {
  color: var(--toolbox-muted);
  font-size: 0.69rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.provenance-badge,
.status,
.token-chips span {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--toolbox-border);
  border-radius: 99rem;
  padding: 0.25rem 0.5rem;
  background: var(--toolbox-surface-soft);
  color: var(--toolbox-muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
}

.provenance-badge.is-engine {
  border-color: color-mix(
    in srgb,
    var(--regex-mint) 55%,
    var(--toolbox-border)
  );
  background: color-mix(in srgb, var(--regex-mint) 10%, var(--toolbox-surface));
  color: color-mix(in srgb, var(--regex-mint) 70%, var(--toolbox-text));
}

.primary-button,
.secondary-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: calc(var(--toolbox-radius) * 0.78);
  padding: 0.55rem 0.75rem;
  font-weight: 700;
}

.primary-button {
  border-color: var(--toolbox-accent);
  background: var(--toolbox-accent);
  color: var(--toolbox-accent-contrast);
}

.primary-button:hover:not(:disabled) {
  background: var(--toolbox-accent-hover);
}

.secondary-button,
.icon-button {
  border-color: var(--toolbox-border);
  background: var(--toolbox-surface);
  color: var(--toolbox-text);
}

.secondary-button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  border-color: color-mix(
    in srgb,
    var(--toolbox-accent) 55%,
    var(--toolbox-border)
  );
  background: var(--toolbox-accent-soft);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.icon-button {
  display: inline-grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  padding: 0;
  font-size: 1.15rem;
}

.command-bar {
  display: flex;
  position: sticky;
  z-index: 8;
  top: 0.5rem;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--toolbox-border);
  border-radius: var(--toolbox-radius);
  background: color-mix(in srgb, var(--toolbox-surface) 94%, transparent);
  box-shadow: var(--toolbox-shadow);
  backdrop-filter: blur(16px);
}

.command-bar > label:not(.check-control),
.inline-controls label,
.table-tools label:not(.check-control) {
  display: grid;
  gap: 0.25rem;
}

.command-bar label > span,
.inline-controls label > span,
.table-tools label > span,
.stacked-control > span {
  color: var(--toolbox-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

select,
input[type="text"],
input[type="search"],
input[type="number"],
textarea,
.stacked-control input {
  min-height: 2.25rem;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.75);
  background: var(--toolbox-surface);
  color: var(--toolbox-text);
}

select,
input[type="text"],
input[type="search"],
input[type="number"],
.stacked-control input {
  padding: 0.35rem 0.55rem;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 0.65rem;
  font-family:
    ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.flag-selector {
  display: flex;
  min-inline-size: 0;
  max-width: 100%;
  align-items: center;
  gap: 0.18rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.flag-selector legend {
  margin-bottom: 0.25rem;
  color: var(--toolbox-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.flag-selector label {
  display: block;
  position: relative;
}

.flag-selector input {
  position: absolute;
  opacity: 0;
}

.flag-selector span {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 1px solid var(--toolbox-border);
  background: var(--toolbox-surface);
  color: var(--toolbox-muted);
  font-family: ui-monospace, monospace;
  font-weight: 800;
}

.flag-selector label:first-of-type span {
  border-radius: 0.45rem 0 0 0.45rem;
}

.flag-selector label:last-of-type span {
  border-radius: 0 0.45rem 0.45rem 0;
}

.flag-selector input:checked + span {
  position: relative;
  z-index: 1;
  border-color: var(--toolbox-accent);
  background: var(--toolbox-accent-soft);
  color: var(--toolbox-accent);
}

.flag-selector input:focus-visible + span,
.test-flag-selector input:focus-visible + span {
  position: relative;
  z-index: 2;
  outline: 3px solid color-mix(in srgb, var(--toolbox-focus) 62%, transparent);
  outline-offset: 2px;
}

.engine-option-selector {
  display: flex;
  min-inline-size: 0;
  align-items: end;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.engine-option-selector legend,
.engine-option-selector label > span {
  color: var(--toolbox-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.engine-option-selector label {
  display: grid;
  width: 7.5rem;
  gap: 0.25rem;
}

.engine-option-selector input,
.engine-option-selector select {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.35rem 0.55rem;
}

.test-flag-selector {
  display: flex;
  min-inline-size: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.18rem;
  margin: 0.75rem;
  padding: 0;
  border: 0;
}

.test-flag-selector legend {
  width: 100%;
  margin-bottom: 0.25rem;
  color: var(--toolbox-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.test-flag-selector label {
  display: block;
  position: relative;
}

.test-flag-selector input {
  position: absolute;
  opacity: 0;
}

.test-flag-selector span {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 1px solid var(--toolbox-border);
  border-radius: 0.45rem;
  background: var(--toolbox-surface);
  color: var(--toolbox-muted);
  font-family: ui-monospace, monospace;
  font-weight: 800;
}

.test-flag-selector input:checked + span {
  border-color: var(--toolbox-accent);
  background: var(--toolbox-accent-soft);
  color: var(--toolbox-accent);
}

.check-control {
  display: inline-flex;
  min-height: 2.25rem;
  align-items: center;
  gap: 0.45rem;
  color: var(--toolbox-text);
  font-size: 0.82rem;
  font-weight: 650;
}

.check-control input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--toolbox-accent);
}

.run-button {
  min-width: 5rem;
}

.limit-banner,
.scan-banner,
.privacy-warning {
  margin: 0.5rem 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid
    color-mix(in srgb, var(--regex-warning) 42%, var(--toolbox-border));
  border-radius: var(--toolbox-radius);
  background: color-mix(
    in srgb,
    var(--regex-warning) 9%,
    var(--toolbox-surface)
  );
  color: color-mix(in srgb, var(--regex-warning) 75%, var(--toolbox-text));
  font-size: 0.82rem;
}

.render-limit-banner {
  margin: 0.65rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid
    color-mix(in srgb, var(--regex-warning) 48%, var(--toolbox-border));
  border-radius: calc(var(--toolbox-radius) * 0.78);
  background: color-mix(
    in srgb,
    var(--regex-warning) 9%,
    var(--toolbox-surface)
  );
  color: var(--toolbox-text);
  font-size: 0.8rem;
  line-height: 1.45;
}

.workspace-toolbar {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.85rem 0 0.6rem;
}

.mode-tabs {
  display: flex;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
  padding: 0.25rem;
  border: 1px solid var(--toolbox-border);
  border-radius: var(--toolbox-radius);
  background: var(--toolbox-surface-soft);
}

.mode-tabs button {
  border: 0;
  border-radius: calc(var(--toolbox-radius) * 0.7);
  padding: 0.55rem 0.8rem;
  background: transparent;
  color: var(--toolbox-muted);
  font-weight: 700;
  white-space: nowrap;
}

.mode-tabs button[aria-current="page"] {
  background: var(--toolbox-surface);
  box-shadow: 0 2px 8px rgb(20 30 60 / 8%);
  color: var(--toolbox-accent);
}

.workspace-actions,
.project-actions,
.inline-controls,
.table-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.55rem;
}

.project-popover {
  position: absolute;
  z-index: 12;
  top: calc(100% + 0.4rem);
  right: 0;
  width: min(30rem, 100%);
  padding-bottom: 1rem;
  box-shadow: var(--toolbox-shadow);
}

.project-popover > p,
.project-popover > label,
.project-popover > .project-actions {
  margin-inline: 1rem;
}

.project-status {
  min-height: 1.4em;
  margin: 0.75rem 1rem 0;
  color: var(--toolbox-muted);
  font-size: 0.8rem;
}

.run-status {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.7rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--toolbox-border);
  border-radius: var(--toolbox-radius);
  background: var(--toolbox-surface);
  font-size: 0.8rem;
}

.run-status > span {
  border-radius: 99rem;
  padding: 0.2rem 0.45rem;
  background: var(--toolbox-surface-soft);
  color: var(--toolbox-muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.run-status > small {
  color: var(--toolbox-muted);
}

.run-status.status-ready > span {
  background: color-mix(
    in srgb,
    var(--regex-success) 12%,
    var(--toolbox-surface)
  );
  color: var(--regex-success);
}

.run-status.status-timeout > span,
.run-status.status-error > span {
  background: color-mix(
    in srgb,
    var(--toolbox-danger) 11%,
    var(--toolbox-surface)
  );
  color: var(--toolbox-danger);
}

.primary-workspace,
.result-workspace,
.mode-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(22rem, 0.75fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.mode-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(22rem, 1.1fr);
}

.mode-span {
  grid-column: 1 / -1;
}

.corpus-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(22rem, 0.95fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.corpus-input-panel,
.corpus-run-panel,
.corpus-results-panel {
  min-width: 0;
}

.corpus-input-panel > .panel-heading > span,
.corpus-results-panel > .panel-heading > span {
  color: var(--toolbox-muted);
  font-size: 0.74rem;
  text-align: right;
}

.corpus-add-controls,
.corpus-paste-footer,
.corpus-run-actions,
.corpus-export-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem;
}

.corpus-add-controls {
  border-bottom: 1px solid var(--toolbox-border);
}

.corpus-add-controls small,
.corpus-paste-footer span,
.corpus-export-controls small {
  color: var(--toolbox-muted);
  font-size: 0.74rem;
}

.corpus-paste-controls {
  display: grid;
  gap: 0.65rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--toolbox-border);
}

.corpus-paste-controls > label {
  display: grid;
  gap: 0.3rem;
}

.corpus-paste-controls > label > span {
  color: var(--toolbox-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.corpus-paste-footer {
  justify-content: space-between;
  padding: 0;
}

.corpus-document-list {
  display: grid;
  max-height: 20rem;
  gap: 0.35rem;
  overflow: auto;
  margin: 0;
  padding: 0.75rem;
  list-style: none;
}

.corpus-document-list li {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.72);
  background: var(--toolbox-surface-soft);
}

.corpus-document-list li > span,
.corpus-document-name {
  display: grid;
  min-width: 0;
}

.corpus-document-list strong,
.corpus-document-name {
  overflow: hidden;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.corpus-document-list small,
.corpus-results-panel tbody th small {
  color: var(--toolbox-muted);
  font-size: 0.68rem;
  font-weight: 400;
  line-height: 1.4;
}

.corpus-operation-selector {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem;
  border: 0;
}

.corpus-operation-selector legend {
  padding-top: 0.75rem;
  color: var(--toolbox-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.corpus-operation-selector label {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0.6rem;
  padding: 0.65rem;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.72);
  cursor: pointer;
}

.corpus-operation-selector label:has(input:checked) {
  border-color: var(--toolbox-accent);
  background: var(--toolbox-accent-soft);
}

.corpus-operation-selector input {
  margin-top: 0.18rem;
  accent-color: var(--toolbox-accent);
}

.corpus-operation-selector span {
  display: grid;
  gap: 0.2rem;
}

.corpus-operation-selector small,
.corpus-run-summary,
.corpus-message {
  color: var(--toolbox-muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.corpus-replacement-control {
  margin-top: 0;
}

.corpus-run-summary {
  padding: 0 0.75rem;
}

.corpus-run-summary p {
  margin: 0.45rem 0;
}

.corpus-message {
  min-height: 1.5rem;
  margin: 0;
  padding: 0 0.75rem 0.75rem;
}

.corpus-progress {
  display: grid;
  gap: 0.35rem;
  padding: 0 0.75rem 0.75rem;
  color: var(--toolbox-muted);
  font-size: 0.73rem;
}

.corpus-progress progress {
  width: 100%;
  height: 0.7rem;
  accent-color: var(--toolbox-accent);
}

.corpus-table-scroll {
  max-height: 28rem;
  overflow: auto;
}

.corpus-results-panel tbody tr {
  cursor: default;
}

.corpus-results-panel tbody th {
  min-width: 13rem;
  max-width: 24rem;
  text-transform: none;
}

.corpus-results-panel tbody th small {
  margin-top: 0.2rem;
  overflow-wrap: anywhere;
  white-space: normal;
}

.corpus-results-panel td {
  white-space: nowrap;
}

.corpus-status-complete {
  border-color: color-mix(
    in srgb,
    var(--regex-success) 45%,
    var(--toolbox-border)
  );
  color: var(--regex-success);
}

.corpus-status-partial,
.corpus-status-not-run {
  border-color: color-mix(
    in srgb,
    var(--regex-warning) 45%,
    var(--toolbox-border)
  );
  color: var(--regex-warning);
}

.corpus-status-error,
.corpus-status-cancelled {
  border-color: color-mix(
    in srgb,
    var(--toolbox-danger) 45%,
    var(--toolbox-border)
  );
  color: var(--toolbox-danger);
}

.corpus-row-download {
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
}

.corpus-row-actions {
  display: flex;
  gap: 0.35rem;
}

.corpus-inspector {
  border-top: 1px solid var(--toolbox-border);
  background: var(--toolbox-surface-soft);
}

.corpus-inspector > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
}

.corpus-inspector h3,
.corpus-inspector h4,
.corpus-inspector p {
  margin: 0;
}

.corpus-inspector h3 {
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.corpus-inspector > header > span,
.corpus-output-preview p {
  color: var(--toolbox-muted);
  font-size: 0.7rem;
}

.corpus-output-preview {
  display: grid;
  gap: 0.45rem;
  padding: 0 0.75rem 0.75rem;
}

.corpus-output-preview h4 {
  font-size: 0.78rem;
}

.corpus-output-preview pre {
  max-height: 12rem;
  overflow: auto;
  margin: 0;
  padding: 0.65rem;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.65);
  background: var(--toolbox-surface);
  color: var(--toolbox-text);
  font-size: 0.76rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.corpus-capture-scroll {
  max-height: 19rem;
  overflow: auto;
  border-top: 1px solid var(--toolbox-border);
}

.corpus-capture-scroll tbody tr {
  cursor: default;
}

.corpus-capture-scroll tbody th {
  min-width: 8rem;
  text-transform: none;
}

.corpus-capture-scroll ul {
  display: grid;
  gap: 0.2rem;
  max-width: 24rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.corpus-capture-scroll code {
  display: block;
  max-width: 24rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: pre;
}

.corpus-capture-scroll td small {
  display: block;
  margin-top: 0.25rem;
  color: var(--toolbox-muted);
  white-space: normal;
}

.corpus-export-controls {
  align-items: center;
  justify-content: flex-start;
  border-top: 1px solid var(--toolbox-border);
}

.corpus-export-controls > div {
  display: grid;
  grid-template-columns: auto auto;
  align-items: end;
  gap: 0.25rem;
  margin-right: auto;
}

.corpus-export-controls > div > label {
  display: grid;
  gap: 0.2rem;
}

.corpus-export-controls > div > label > span {
  color: var(--toolbox-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.corpus-export-controls > div > small {
  grid-column: 1 / -1;
}

.corpus-content-confirmation {
  max-width: 19rem;
}

.code-editor {
  min-height: 8rem;
  overflow: hidden;
  background: color-mix(
    in srgb,
    var(--toolbox-surface) 96%,
    var(--regex-purple)
  );
}

.code-editor-host {
  min-height: inherit;
}

.editor-limit-message {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--toolbox-danger);
  background: color-mix(
    in srgb,
    var(--toolbox-danger) 8%,
    var(--toolbox-surface)
  );
  color: var(--toolbox-danger);
  font-size: 0.78rem;
}

.pattern-editor {
  min-height: 11rem;
}

.subject-editor {
  min-height: 22rem;
}

.replacement-editor {
  min-height: 9rem;
}

.output-editor {
  min-height: 14rem;
}

.code-editor .cm-editor {
  height: 100%;
  min-height: inherit;
  color: var(--toolbox-text);
  font-family:
    ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
}

.code-editor .cm-scroller {
  min-height: inherit;
  overflow: auto;
}

.code-editor .cm-content {
  min-height: inherit;
  padding: 0.8rem 0;
  caret-color: var(--toolbox-accent);
}

.code-editor .cm-line {
  padding-inline: 0.75rem;
}

.code-editor .cm-gutters {
  border-right: 1px solid var(--toolbox-border);
  background: var(--toolbox-surface-soft);
  color: var(--toolbox-muted);
}

.code-editor .cm-activeLine,
.code-editor .cm-activeLineGutter {
  background: var(--toolbox-accent-soft);
}

.code-editor .cm-selectionBackground,
.code-editor .cm-content ::selection {
  background: color-mix(
    in srgb,
    var(--toolbox-focus) 38%,
    transparent
  ) !important;
}

.code-editor .cm-content[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--toolbox-muted);
  pointer-events: none;
}

.cm-syntax-token {
  border-radius: 0.15rem;
}

.cm-token-quantifier,
.cm-token-anchor,
.cm-token-word-boundary {
  color: color-mix(in srgb, var(--regex-purple) 80%, var(--toolbox-text));
  font-weight: 800;
}

.cm-token-character-class,
.cm-token-unicode-property {
  color: color-mix(in srgb, var(--regex-mint) 78%, var(--toolbox-text));
}

.cm-token-capture-group,
.cm-token-named-capture-group,
.cm-token-noncapture-group,
.cm-token-lookahead,
.cm-token-lookbehind,
.cm-token-negative-lookahead,
.cm-token-negative-lookbehind {
  border-bottom: 2px solid currentColor;
}

.cm-diagnostic-error {
  text-decoration: underline wavy var(--toolbox-danger) 1.5px;
  text-underline-offset: 0.22rem;
}

.cm-diagnostic-warning {
  text-decoration: underline wavy var(--regex-warning) 1.5px;
}

.cm-selected-range {
  outline: 2px solid var(--toolbox-focus);
  outline-offset: 1px;
  background: color-mix(in srgb, var(--toolbox-focus) 16%, transparent);
}

.cm-subject-match {
  border-radius: 0.18rem;
  background: color-mix(in srgb, var(--regex-purple) 15%, transparent);
  box-shadow: inset 0 -2px var(--regex-purple);
}

.cm-subject-capture {
  border-radius: 0.15rem;
  box-shadow: inset 0 -2px currentColor;
}

.cm-zero-width {
  position: relative;
  z-index: 2;
  color: var(--toolbox-danger);
  font-weight: 900;
}

.cm-capture-1 {
  color: var(--capture-1);
}
.cm-capture-2 {
  color: var(--capture-2);
}
.cm-capture-3 {
  color: var(--capture-3);
}
.cm-capture-4 {
  color: var(--capture-4);
}
.cm-capture-5 {
  color: var(--capture-5);
}
.cm-capture-6 {
  color: var(--capture-6);
}
.cm-capture-7 {
  color: var(--capture-7);
}
.cm-capture-8 {
  color: var(--capture-8);
}

.tree-panel {
  min-height: 0;
}

.tree {
  max-height: 30rem;
  overflow: auto;
  margin: 0;
  padding: 0.45rem;
  list-style: none;
}

.tree ul {
  margin: 0 0 0 1rem;
  padding: 0 0 0 0.55rem;
  border-left: 1px solid var(--toolbox-border);
  list-style: none;
}

.tree-row {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(5rem, auto) 1fr auto;
  align-items: start;
  gap: 0.6rem;
  border: 1px solid transparent;
  border-radius: calc(var(--toolbox-radius) * 0.65);
  padding: 0.48rem 0.55rem;
  background: transparent;
  color: var(--toolbox-text);
  text-align: left;
}

.tree-row:hover,
.tree-row.is-selected {
  border-color: var(--toolbox-border);
  background: var(--toolbox-accent-soft);
}

.tree-row.is-selected {
  box-shadow: inset 3px 0 var(--toolbox-focus);
}

.tree-token {
  overflow: hidden;
  color: var(--toolbox-accent);
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-explanation {
  font-size: 0.79rem;
  line-height: 1.35;
}

.tree-meta {
  color: var(--toolbox-muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.tree-details {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 0.25rem 0.65rem;
  color: var(--toolbox-muted);
  font-size: 0.65rem;
  line-height: 1.35;
}

.tree-details > span {
  overflow-wrap: anywhere;
}

.extraction-row {
  grid-template-columns: minmax(8rem, auto) 1fr auto;
}

.tree-note {
  margin: 0.1rem 0.5rem 0.4rem;
  color: var(--toolbox-muted);
  font-size: 0.7rem;
}

.status-did-not-participate {
  opacity: 0.72;
}

.status-matched-empty {
  color: var(--regex-warning);
}

.empty-state,
.success-state {
  margin: 0;
  padding: 1.2rem;
  color: var(--toolbox-muted);
  text-align: center;
}

.success-state {
  color: var(--regex-success);
}

.capture-panel,
.diagnostics-panel,
.reference-panel,
.capability-panel {
  margin-bottom: 0.75rem;
}

.table-tools {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--toolbox-border);
}

.capture-table-scroll {
  max-height: 24rem;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

th,
td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--toolbox-border);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  z-index: 2;
  top: 0;
  background: var(--toolbox-surface-soft);
  color: var(--toolbox-muted);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.is-selected {
  background: var(--toolbox-accent-soft);
}

.value-cell {
  max-width: 26rem;
  overflow: hidden;
  font-family: ui-monospace, monospace;
  text-overflow: ellipsis;
  white-space: pre;
}

.code-point-cell {
  max-width: 30rem;
  color: var(--toolbox-muted);
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.row-actions {
  display: inline-flex;
  gap: 0.3rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.65rem;
  color: var(--toolbox-muted);
  font-size: 0.75rem;
}

.diagnostic-list,
.token-list,
.reference-list,
.test-list,
.list-preview {
  margin: 0;
  padding: 0.5rem;
  list-style: none;
}

.diagnostic-list li + li,
.token-list li + li,
.test-list li + li {
  margin-top: 0.35rem;
}

.diagnostic,
.token-row {
  display: grid;
  width: 100%;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.72);
  padding: 0.6rem;
  background: var(--toolbox-surface);
  color: var(--toolbox-text);
  text-align: left;
}

.diagnostic > span {
  color: var(--toolbox-muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.diagnostic > strong {
  font-size: 0.8rem;
}

.diagnostic > small {
  color: var(--toolbox-muted);
}

.token-row:hover,
.token-row.is-selected {
  border-color: var(--toolbox-accent);
  background: var(--toolbox-accent-soft);
}

.diagnostic-error {
  border-left: 4px solid var(--toolbox-danger);
}

.diagnostic-warning {
  border-left: 4px solid var(--regex-warning);
}

.token-row code {
  color: var(--toolbox-accent);
  font-weight: 800;
}

.token-row small {
  color: var(--toolbox-muted);
}

.replacement-preview-list,
.replacement-contribution-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.replacement-preview-list {
  display: grid;
  max-height: 34rem;
  gap: 0.65rem;
  overflow: auto;
  padding: 0.7rem;
}

.replacement-match-preview {
  overflow: hidden;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.78);
  background: var(--toolbox-surface);
}

.replacement-match-preview > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--toolbox-border);
  background: var(--toolbox-surface-soft);
}

.replacement-match-preview > header small {
  color: var(--toolbox-muted);
}

.replacement-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  padding: 0.7rem;
}

.replacement-comparison > div {
  display: grid;
  min-width: 0;
  gap: 0.3rem;
}

.replacement-comparison span {
  color: var(--toolbox-muted);
  font-size: 0.7rem;
  font-weight: 750;
  text-transform: uppercase;
}

.replacement-comparison code,
.replacement-contribution-list span {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.replacement-contribution-list {
  display: grid;
  gap: 0.35rem;
  padding: 0 0.7rem 0.7rem;
}

.replacement-contribution-list button {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(4rem, auto) minmax(6rem, 1fr) minmax(12rem, 2fr);
  gap: 0.55rem;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.65);
  padding: 0.5rem;
  background: var(--toolbox-surface);
  color: var(--toolbox-text);
  text-align: left;
}

.replacement-contribution-list button:hover,
.replacement-contribution-list button.is-selected {
  border-color: var(--toolbox-accent);
  background: var(--toolbox-accent-soft);
}

.replacement-contribution-list code {
  color: var(--toolbox-accent);
  font-weight: 800;
}

.replacement-contribution-list small {
  color: var(--toolbox-muted);
}

.stacked-control {
  display: grid;
  gap: 0.3rem;
  margin: 0.75rem;
}

.field-help,
.capability-roadmap {
  margin: 0.75rem;
  color: var(--toolbox-muted);
  font-size: 0.78rem;
}

.token-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.75rem;
}

.list-preview {
  max-height: 18rem;
  overflow: auto;
  counter-reset: rows;
}

.list-preview li {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.5rem;
  padding: 0.42rem;
  border-bottom: 1px solid var(--toolbox-border);
  counter-increment: rows;
}

.list-preview li::before {
  content: counter(rows);
  color: var(--toolbox-muted);
  font-size: 0.68rem;
  text-align: right;
}

.export-panel {
  padding-bottom: 0.75rem;
}

.inline-controls {
  padding: 0.75rem;
}

.test-create-panel {
  padding-bottom: 0.8rem;
}

.test-form-actions,
.test-run-actions,
.test-suite-toolbar,
.test-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.test-form-actions,
.test-suite-toolbar {
  padding: 0.75rem;
}

.test-suite-toolbar {
  border-bottom: 1px solid var(--toolbox-border);
}

.tests-panel > .privacy-warning,
.tests-panel > [role="status"] {
  margin-inline: 0.75rem;
}

.test-list li {
  display: grid;
  grid-template-columns:
    auto minmax(12rem, 0.8fr) minmax(12rem, 1.2fr)
    auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.75);
}

.test-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.test-selection {
  display: grid;
  place-items: center;
}

.test-toggle > span {
  display: grid;
}

.test-toggle small {
  color: var(--toolbox-muted);
}

.test-result {
  color: var(--toolbox-muted);
  font-size: 0.77rem;
}

.test-result.is-pass {
  color: var(--regex-success);
}

.test-result.is-fail {
  color: var(--toolbox-danger);
}

.reference-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.55rem;
}

.reference-list li {
  display: grid;
  gap: 0.45rem;
  align-content: start;
  padding: 0.7rem;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.7);
}

.reference-list li > div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.reference-list p,
.reference-list small {
  margin: 0;
  color: var(--toolbox-muted);
  font-size: 0.78rem;
}

.reference-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0;
}

.reference-meta div {
  min-width: 0;
}

.reference-meta dt {
  color: var(--toolbox-muted);
  font-size: 0.65rem;
  font-weight: 750;
  text-transform: uppercase;
}

.reference-meta dd {
  margin: 0.15rem 0 0;
  overflow-wrap: anywhere;
  font-size: 0.75rem;
}

.reference-list button {
  justify-self: start;
}

.panel-heading-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--toolbox-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.capability-grid,
.help-limits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  margin: 0;
  padding: 0.65rem;
}

.capability-grid div,
.help-limits div {
  padding: 0.65rem;
  border-bottom: 1px solid var(--toolbox-border);
}

.capability-grid dt,
.help-limits dt {
  color: var(--toolbox-muted);
  font-size: 0.7rem;
  font-weight: 750;
  text-transform: uppercase;
}

.capability-grid dd,
.help-limits dd {
  margin: 0.2rem 0 0;
  font-size: 0.84rem;
}

.app-dialog {
  width: min(44rem, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--toolbox-border);
  border-radius: var(--toolbox-radius);
  background: var(--toolbox-surface);
  color: var(--toolbox-text);
  box-shadow: var(--toolbox-shadow);
}

.app-dialog::backdrop {
  background: rgb(8 12 24 / 64%);
  backdrop-filter: blur(4px);
}

.app-dialog > header,
.app-dialog > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--toolbox-border);
}

.app-dialog > footer {
  justify-content: flex-end;
  border-top: 1px solid var(--toolbox-border);
  border-bottom: 0;
}

.auxiliary-dialog {
  width: min(72rem, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
}

.auxiliary-dialog > .panel {
  max-height: calc(100vh - 2rem);
  overflow: auto;
  margin: 0;
  border: 0;
  box-shadow: none;
}

.auxiliary-dialog .panel-heading {
  position: sticky;
  z-index: 3;
  top: 0;
  background: var(--toolbox-surface);
}

.capabilities-dialog {
  width: min(60rem, calc(100% - 2rem));
}

.trace-dialog {
  width: min(90rem, calc(100% - 2rem));
}

.trace-panel {
  display: grid;
  gap: 0.85rem;
}

.trace-disclosure {
  padding: 0 1rem;
  color: var(--toolbox-muted);
  line-height: 1.5;
}

.trace-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.65rem;
  padding: 0 1rem;
}

.trace-controls label {
  display: grid;
  gap: 0.3rem;
  color: var(--toolbox-muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.trace-controls input {
  width: 12rem;
  min-height: 2.3rem;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.55);
  padding: 0.4rem 0.55rem;
  background: var(--toolbox-surface-soft);
  color: var(--toolbox-text);
}

.trace-status {
  display: grid;
  gap: 0.25rem;
  margin: 0 1rem;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.6);
  padding: 0.65rem 0.75rem;
  background: var(--toolbox-surface-soft);
}

.trace-status small,
.trace-table small {
  display: block;
  margin-top: 0.15rem;
  color: var(--toolbox-muted);
}

.trace-diagnostics {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0 1rem;
  list-style: none;
}

.trace-diagnostics li {
  border-left: 3px solid var(--toolbox-border);
  padding: 0.35rem 0.55rem;
  color: var(--toolbox-muted);
}

.trace-diagnostics .diagnostic-warning {
  border-color: var(--regex-warning);
}

.trace-table-scroll {
  overflow: auto;
  margin: 0 1rem 1rem;
  border: 1px solid var(--toolbox-border);
  border-radius: calc(var(--toolbox-radius) * 0.65);
}

.trace-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  white-space: nowrap;
}

.trace-table th,
.trace-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--toolbox-border);
  text-align: left;
  vertical-align: top;
}

.trace-table th {
  position: sticky;
  z-index: 1;
  top: 0;
  background: var(--toolbox-surface-soft);
}

.trace-event-select {
  min-width: 2.2rem;
  border: 1px solid var(--toolbox-border);
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  background: var(--toolbox-surface);
  color: var(--toolbox-accent-strong);
  font: inherit;
  font-weight: 800;
}

.trace-event-select:hover {
  border-color: var(--toolbox-accent);
  background: var(--toolbox-accent-soft);
}

.trace-movement {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  background: var(--toolbox-accent-soft);
  font-weight: 800;
}

.trace-apparent-backtrack {
  background: color-mix(in srgb, var(--regex-warning) 22%, transparent);
  color: color-mix(in srgb, var(--regex-warning) 75%, var(--toolbox-text));
}

.app-dialog h2,
.app-dialog p {
  margin: 0;
}

.dialog-content {
  display: grid;
  max-height: 65vh;
  gap: 1rem;
  overflow: auto;
  padding: 1rem;
}

.dialog-content section {
  display: grid;
  gap: 0.4rem;
}

.dialog-content h3 {
  margin: 0;
  font-size: 1rem;
}

.dialog-content p {
  color: var(--toolbox-muted);
  line-height: 1.55;
}

.fatal-error {
  width: min(100% - 2rem, 50rem);
  margin: 3rem auto;
  padding: 2rem;
  border: 1px solid var(--toolbox-danger);
  border-radius: var(--toolbox-radius);
  background: var(--toolbox-surface);
  color: var(--toolbox-text);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

@media (max-width: 64rem) {
  .command-bar {
    position: static;
  }

  .primary-workspace,
  .result-workspace,
  .mode-grid,
  .corpus-workspace {
    grid-template-columns: 1fr;
  }

  .mode-span {
    grid-column: auto;
  }

  .workspace-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-actions {
    justify-content: flex-end;
  }

  .project-popover {
    top: 100%;
  }

  .replacement-comparison,
  .replacement-contribution-list button {
    grid-template-columns: 1fr;
  }

  .tree {
    max-height: 24rem;
  }
}

@media (max-width: 40rem) {
  .regex-application {
    padding-inline: 0.5rem;
  }

  .command-bar > label:not(.check-control) {
    flex: 1 1 10rem;
    min-width: 0;
    max-width: 100%;
  }

  .command-bar > label:not(.check-control) > select {
    width: 100%;
    min-width: 0;
  }

  .flag-selector {
    flex-basis: 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
  }

  .engine-option-selector {
    flex-basis: 100%;
    width: 100%;
    overflow-x: auto;
  }

  .workspace-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .run-status {
    grid-template-columns: auto 1fr;
  }

  .run-status small {
    grid-column: 1 / -1;
  }

  .tree-row,
  .extraction-row {
    grid-template-columns: 1fr auto;
  }

  .tree-explanation {
    grid-column: 1 / -1;
  }

  .test-list li {
    grid-template-columns: auto 1fr;
  }

  .corpus-export-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .corpus-export-controls > div {
    grid-template-columns: 1fr;
    margin-right: 0;
  }

  .corpus-export-controls > div > small {
    grid-column: auto;
  }

  .corpus-content-confirmation {
    max-width: none;
  }

  .test-result {
    grid-column: 2 / -1;
  }

  .test-row-actions {
    grid-column: 2 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
