:root {
  --font-size: 13px;
  --control-height: 30px;
  --radius: 4px;
  --btn-padding-x: 12px;
  --primary: hsl(215 28% 17%);
  --border-color: hsl(220 10% 60%);
  --input-bg: hsl(0 0% 100%);
  --danger: hsl(0 84% 60%);
  --accent: hsl(255 55% 45%);
  --header-color: hsl(215 14% 34%);
  --white: hsl(0 0% 100%);
  --text-strong: hsl(0 0% 7%);
  --text-muted: hsl(220 9% 46%);
  --text-soft: hsl(218 11% 65%);
  --text-emphasis: hsl(217 19% 27%);
  --panel-bg: hsl(210 20% 98%);
  --panel-bg-alt: hsl(220 14% 96%);
  --danger-bg: hsl(0 86% 97%);
  --accent-soft: hsl(255 55% 97%);
  --primary-dark: hsl(221 39% 11%);
  --note-text: hsl(32 95% 44%);
  --row-selected-bg: var(--accent);
  --border-color-soft: hsl(220 10% 85%);
}

[data-theme="dark"] {
  --primary: hsl(215 20% 80%);
  --border-color: hsl(220 10% 30%);
  --input-bg: hsl(220 15% 18%);
  --danger: hsl(0 70% 55%);
  --accent: hsl(255 55% 60%);
  --header-color: hsl(215 14% 65%);
  --white: hsl(220 15% 13%);
  --text-strong: hsl(0 0% 90%);
  --text-muted: hsl(220 9% 55%);
  --text-soft: hsl(218 11% 45%);
  --text-emphasis: hsl(217 15% 75%);
  --panel-bg: hsl(220 15% 15%);
  --panel-bg-alt: hsl(220 14% 20%);
  --danger-bg: hsl(0 40% 15%);
  --accent-soft: hsl(255 30% 18%);
  --primary-dark: hsl(221 20% 85%);
  --note-text: hsl(32 80% 55%);
  --row-selected-bg: var(--accent);
  --border-color-soft: hsl(220 10% 25%);
  color-scheme: dark;
}

[data-theme="dark"] select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

html {
  overflow-y: scroll;
}

* {
  box-sizing: border-box;
  transition: none !important;
}

body {
  background: var(--white);
  color: var(--primary);
  font-family: system-ui;
  font-size: var(--font-size);
  margin: 0;
  min-width: 800px;
}

b {
  font-weight: 500;
}

header {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 0;
}

.header-inner {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 900px;
  padding: 0 20px;
}

.header-left {
  align-items: center;
  display: flex;
  flex: 1;
  gap: 15px;
}

.header-right {
  align-items: center;
  display: flex;
  gap: 8px;
}

.header-logo {
  align-items: center;
  display: inline-flex;
  height: 24px;
  line-height: 0;
}

.header-logo svg {
  display: block;
  height: 24px;
  width: 108px;
}

.header-icon-button {
  align-items: center;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  height: 22px;
  justify-content: center;
  padding: 0;
  width: 22px;
}

.header-icon-button:disabled {
  cursor: default;
  opacity: 0.4;
}

.header-icon-button:hover {
  background: var(--panel-bg-alt);
}

.header-icon-button:disabled:hover {
  background: var(--white);
  border-color: var(--border-color);
}

.header-button-group {
  align-items: center;
  display: flex;
  gap: 6px;
}

.header-button-group .btn-accent svg {
  height: 14px;
  transform: translateY(-1px);
  width: 14px;
}

.btn-accent:disabled {
  cursor: default;
  opacity: 0.4;
}

.btn-accent:disabled:hover {
  background: var(--white);
}

.form-input {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-strong);
  font-family: system-ui;
  font-size: var(--font-size);
  height: var(--control-height);
  padding: 6px 8px;
}

/* Keep number inputs visually consistent with other form fields. */
.form-input[type="number"] {
  border-radius: var(--radius);
  height: var(--control-height);
  padding: 6px 8px;
}

.command-name-input {
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border-color);
  font-size: 13px;
  font-weight: 400;
}

.form-input::placeholder {
  color: var(--text-soft);
  font-style: italic;
}

select {
  appearance: none;
  background-color: var(--input-bg);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-position: right 6px center;
  background-repeat: no-repeat;
  background-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-strong);
  cursor: pointer;
  flex-shrink: 0;
  font-family: system-ui;
  font-size: var(--font-size);
  height: var(--control-height);
  padding: 5px 24px 5px 8px;
}

.form-input:focus,
select:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

button {
  align-items: center;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--primary);
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  font-family: system-ui;
  font-size: var(--font-size);
  font-weight: 500;
  gap: 6px;
  height: var(--control-height);
  padding: 6px var(--btn-padding-x);
}

button:hover {
  background: var(--panel-bg-alt);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-dark);
}


.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  height: auto;
  padding: 0;
  text-decoration: none;
}

.btn-link:hover {
  background: transparent;
  text-decoration: underline;
}


main {
  padding: 20px 0;
}

.container {
  margin: 0 auto;
  max-width: 900px;
  padding: 0 20px 40px;
}

.field-row {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.preview-area {
  font-size: 13px;
  padding: 4px 0;
}

.preview-count {
  color: var(--text-emphasis);
  margin-bottom: 6px;
}

.preview-count b {
  font-weight: 500;
}

.preview-item {
  color: var(--text-emphasis);
  margin-left: 18px;
  overflow: hidden;
  padding: 3px 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-more {
  color: var(--text-muted);
  font-style: italic;
  margin-left: 18px;
  padding: 3px 0;
}

.item-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.item-row:last-child {
  margin-bottom: 0;
}

.item-row-wrap {
  flex-wrap: wrap;
}

.filter-row-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.filter-join-select {
  width: 72px;
}

.filter-join-spacer {
  width: 72px;
}

.limit-row {
  border-top: none;
  margin-bottom: 0;
  margin-top: 10px;
  padding-top: 10px;
}

.col-fill {
  flex: 1;
  min-width: 0;
}

.col-fill > .form-input {
  width: 100%;
}

.small-label {
  font-size: 13px;
}

.header-label {
  color: var(--text-emphasis);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
}

.inline-label {
  align-items: center;
  display: flex;
  font-size: 13px;
  gap: 4px;
  line-height: 22px;
  white-space: nowrap;
}

.chevron-sep {
  align-items: center;
  color: var(--text-muted);
  display: inline-flex;
}

.chevron-sep svg {
  height: 12px;
  width: 12px;
}

.logic-block {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 0;
  padding: 25px 15px 18px;
  position: relative;
}

.logic-block+.logic-block {
  margin-top: 50px;
}

.logic-block:last-child {
  margin-bottom: 35px;
}

.logic-label {
  background: var(--accent);
  border-radius: 4px;
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  height: 24px;
  left: 10px;
  letter-spacing: 0.05em;
  line-height: 24px;
  padding: 0 12px;
  position: absolute;
  text-transform: uppercase;
  top: -14px;
}

.action-select {
  min-width: 200px;
}

.action-row-main {
  flex-wrap: nowrap;
}

.action-row-main > .icon-button-group {
  margin-left: auto;
}

.command-section {
  margin: 20px 0;
}

.command-table-frame {
  position: relative;
}

.command-table {
  display: flex;
  flex-direction: column;
  position: relative;
}

.command-triggers-label {
  align-items: center;
  background: var(--accent);
  border: none;
  border-radius: 6px 6px 0 0;
  box-sizing: border-box;
  color: var(--white);
  display: flex;
  font-size: 13px;
  font-weight: 700;
  height: 24px;
  justify-content: center;
  letter-spacing: 0.05em;
  line-height: 24px;
  position: absolute;
  right: 121px;
  text-transform: uppercase;
  top: 0;
  width: 340px;
  z-index: 2;
}

.command-row {
  align-items: center;
  background: var(--panel-bg);
  display: grid;
  grid-template-columns: 80px 1fr 60px 80px 80px 120px 120px;
}

.command-header-row {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px 6px 0 0;
  margin-top: 24px;
}

.command-header-row .command-cell {
  color: var(--text-emphasis);
  font-size: 13px;
  font-weight: 500;
  height: 24px;
  letter-spacing: normal;
  padding: 0 12px;
  text-align: center;
  text-transform: none;
}

.command-header-row .command-cell-name {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.command-header-row .command-trigger-start,
.command-header-row .command-trigger-end,
.command-header-row .command-cell-trigger {
  border-top: none;
}

.command-body-row {
  border-bottom: 1px solid var(--border-color);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}

.command-body-row:last-child {
  border-radius: 0 0 6px 6px;
}

.command-body-row.is-editing {
  background: var(--row-selected-bg);
}

.command-body-row.is-editing .command-cell-editing {
  color: hsl(0 0% 100%);
  font-size: var(--font-size);
  font-weight: 500;
}

.command-body-row.is-editing .command-name-input {
  font-weight: 500;
}


.command-cell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100%;
  padding: 10px 12px;
}

.command-cell-name {
  justify-content: flex-start;
}

.command-cell-trigger {
  justify-content: center;
  position: relative;
}

.command-trigger-start {
  box-shadow: inset 1px 0 0 0 var(--border-color);
}

.command-trigger-end {
  box-shadow: inset -1px 0 0 0 var(--border-color);
}

.command-table input[type="text"],
.command-table input[type="number"],
.command-table select {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-family: system-ui;
  font-size: var(--font-size);
  height: var(--control-height);
  padding: 4px 6px;
  width: 100%;
}

.command-table input[type="text"]:focus,
.command-table select:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.omnibox-duplicate,
.input-invalid {
  background-color: var(--accent-soft) !important;
  border-color: var(--accent) !important;
}

.action-input-inline-label {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 0.5rem;
  margin-left: 12px;
  min-width: 0;
  white-space: nowrap;
}

.action-input-inline-label-select {
  flex: 0 0 auto;
}

.include-active-label {
  flex: 0 0 auto;
}

.action-input-inline-label input:not([type="checkbox"]),
.action-input-inline-label select {
  flex: 1;
  min-width: 80px;
}

.action-input-inline-label-select select {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
}

.action-row-textarea {
  width: 100%;
  margin-top: 0.5rem;
}

.action-textarea-label {
  display: block;
  margin-bottom: 0.25rem;
}

.action-textarea {
  width: 100%;
  min-height: 60px;
  resize: none;
  overflow: hidden;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.4;
}

.command-table .command-name-input {
  color: var(--primary-dark);
}


input[type="radio"],
input[type="checkbox"] {
  align-items: center;
  appearance: none;
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  height: 22px;
  justify-content: center;
  margin: 0;
  min-height: 22px;
  min-width: 22px;
  position: relative;
  width: 22px;
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="radio"]:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

input[type="checkbox"]:checked {
  background-color: var(--input-bg);
  border-color: var(--border-color);
}

input[type="checkbox"]:checked::after {
  content: '';
  display: block;
  height: 13px;
  width: 13px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 13' fill='none' stroke='%23253a47' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.75 7L5.5 9.75L10.25 4'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 13px 13px;
}

[data-theme="dark"] input[type="checkbox"]:checked::after {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 13' fill='none' stroke='%23bcc8d4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.75 7L5.5 9.75L10.25 4'/%3E%3C/svg%3E");
}

input[type="radio"]:checked::after {
  background-color: var(--white);
  border-radius: 50%;
  content: '';
  height: 10px;
  width: 10px;
}

input[type="radio"]:disabled,
input[type="checkbox"]:disabled {
  background-color: var(--panel-bg);
  border-color: var(--border-color);
  cursor: default;
  opacity: 1;
}

input.context-trigger-checkbox:disabled {
  border-color: var(--border-color-soft);
  cursor: help;
}

.icon-button-group {
  align-items: center;
  display: inline-flex;
  gap: 2px;
}

.move-delete-group {
  align-items: center;
  display: inline-flex;
  gap: 2px;
}

.icon-button {
  align-items: center;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  height: 22px;
  justify-content: center;
  min-height: 22px;
  min-width: 22px;
  padding: 0;
  width: 22px;
}

.icon-button:hover {
  background: var(--panel-bg-alt);
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.3;
}

.icon-button:disabled:hover {
  background: var(--white);
  border-color: var(--border-color);
}


.icon-button svg {
  height: 12px;
  width: 12px;
}

.icon-button[title="Run"] svg {
  height: 16px;
  width: 16px;
}

.command-controls {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  margin-top: 16px;
}

.header-menu {
  position: relative;
}

.header-menu-panel {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: none;
  min-width: 180px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: 34px;
  z-index: 10;
}

.header-menu-panel.open {
  display: block;
}

.header-menu-panel button {
  border: none;
  justify-content: flex-start;
  padding: 8px 10px;
  width: 100%;
}

.header-menu-panel button:hover {
  background: var(--panel-bg-alt);
}

.visually-hidden {
  height: 1px;
  left: -9999px;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

.command-editor .field-row:first-child {
  display: none;
}

.command-editor {
  margin-top: 50px;
}

.command-editor+.logic-block {
  margin-top: 50px;
}

#items-options {
  align-items: center;
  display: contents;
}

#refinement-wrap {
  align-items: center;
  display: flex;
  gap: 8px;
}

#items-options.hidden {
  display: none;
}

.actions-controls {
  display: flex;
  justify-content: flex-start;
  margin-top: 30px;
}

#run-command-btn svg {
  height: 16px;
  transform: translateY(1px);
  width: 16px;
}

.btn-accent {
  background: var(--white);
  border: 1px solid var(--accent);
  color: var(--accent);
  height: var(--control-height);
}

.btn-accent:hover {
  background: var(--accent-soft);
}

.logic-block .btn-accent {
  margin-bottom: 0;
}

.indent-row {
  margin-left: 14px;
}

.action-confirm-row {
  margin-bottom: 0;
  margin-top: 10px;
  padding-top: 10px;
}


.action-confirm-label {
  align-items: center;
  display: flex;
  font-size: 13px;
  gap: 6px;
  line-height: 22px;
}


.preview-toggle-row {
  border-top: none;
  margin-top: 10px;
  padding-top: 10px;
}

.preview-content-inner {
  border-top: 1px solid var(--border-color);
  margin-left: -15px;
  margin-right: -15px;
  margin-top: 10px;
  padding: 12px 15px 0;
}

.preview-content-inner>*:last-child {
  margin-bottom: 0;
}

.action-context-label {
  color: var(--text-emphasis);
  font-size: 13px;
  margin-bottom: 12px;
}

.preview-toggle-btn-wrap {
  margin-left: 20px;
}

.action-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.action-row + .action-row {
  margin-top: 12px;
}

#filters-container:not(:empty),
#actions-container:not(:empty) {
  margin-bottom: 16px;
}

.action-checkbox {
  align-items: center;
  cursor: pointer;
  display: flex;
  flex-direction: row-reverse;
  gap: 8px;
  justify-content: flex-end;
  line-height: 22px;
  margin: 0;
  padding: 0;
  user-select: none;
}

.action-checkbox-list .action-checkbox {
  flex-direction: row;
  justify-content: flex-start;
}

.action-checkbox-group {
  margin-bottom: 8px;
}

.action-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.action-input-label {
  color: var(--text-emphasis);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: normal;
  text-transform: none;
}

.help-panel {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 6px;
  margin-bottom: 30px;
  margin-top: 10px;
  padding: 20px 40px 20px 20px;
  position: relative;
}

.help-panel.hidden {
  display: none;
}

.help-panel h2 {
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: normal;
  margin: 0 0 12px;
  text-transform: none;
}

.help-panel h3 {
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: normal;
  margin: 20px 0 6px;
  text-transform: none;
}

.help-panel p {
  color: var(--text-emphasis);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 8px;
}

.help-panel p:last-child {
  margin-bottom: 0;
}

.help-panel-close {
  background: var(--white);
  border-color: var(--accent);
  color: var(--accent);
  position: absolute;
  right: 10px;
  top: 10px;
}

.help-panel-close:hover {
  background: var(--accent-soft);
}

.help-steps {
  margin: 12px 0 16px;
  padding-left: 20px;
}

.help-steps li {
  color: var(--text-emphasis);
  font-size: 13px;
  margin-bottom: 6px;
}

.help-panel b,
.help-steps b {
  color: inherit;
  font-weight: 700;
}

.help-hint {
  border-top: 1px solid var(--accent);
  font-style: italic;
  margin-top: 15px !important;
  padding-top: 10px;
}

.help-hint a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.help-hint a:hover {
  text-decoration: underline;
}

.help-examples {
  margin-top: 20px;
}

.help-examples h3 {
  color: var(--accent);
  font-size: 15px;
  margin: 0 0 10px;
}

.help-examples ul {
  margin: 0;
  padding-left: 20px;
}

.help-examples li {
  color: var(--text-emphasis);
  font-size: 13px;
  margin-bottom: 5px;
}

/* Initially hidden elements */
#command-editor,
#include-active-label,
#refinement-n-label,
#preview-content,
#import-file-input {
  display: none;
}

#refinement-n-label {
  margin-left: 1rem;
}

#refinement-n {
  width: 60px;
}


.action-row-main-stacked {
  align-items: flex-start;
  flex-wrap: wrap;
}

.action-row-main-stacked > .action-input-inline-label {
  flex: 1 1 100%;
}

.action-row-main-stacked > .icon-button-group {
  margin-left: 0;
}


.help-steps-tifa {
  list-style: none;
  margin: 12px 0 16px;
  padding-left: 0;
}

.help-steps-tifa li {
  align-items: center;
  display: flex;
  gap: 7px;
  margin-bottom: 8px;
}

.help-step-badge {
  display: inline-flex;
  line-height: 0;
}

.help-step-badge svg {
  display: block;
  height: 20px;
  width: 20px;
}

.help-pipeline {
  align-items: center;
  color: var(--text-emphasis);
  display: flex;
  flex-wrap: wrap;
  font-weight: 700;
  gap: 7px;
  margin: 10px 0 12px;
}

.help-pipeline-arrow {
  align-items: center;
  color: var(--text-muted);
  display: inline-flex;
  line-height: 0;
}

.help-pipeline-arrow svg {
  display: block;
  height: 12px;
  width: 12px;
}
