.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  height: var(--control-height-md);
  padding: 0 var(--space-lg);
  font-size: var(--font-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-surface-active);
  border-color: var(--border-highlight);
}

.btn:active {
  transform: translateY(1px);
}

.btn.sm {
  height: var(--control-height-sm);
  padding: 0 var(--space-md);
  font-size: var(--font-xs);
  border-radius: var(--radius-sm);
}

.btn.lg {
  height: var(--control-height-lg);
  padding: 0 var(--space-2xl);
  font-size: var(--font-md);
}

.btn.block {
  width: 100%;
}

.btn.accent {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  font-weight: 700;
}

.btn.accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 0 12px var(--accent-glow);
}

.btn.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

.btn.danger:hover {
  background: var(--danger);
  color: var(--on-danger);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn.ghost:hover {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-icon {
  width: var(--control-height-md);
  height: var(--control-height-md);
  padding: 0;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

.btn-icon.sm {
  width: var(--control-height-sm);
  height: var(--control-height-sm);
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  color: var(--text-primary);
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.card-title {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.card-desc {
  font-size: var(--font-xs);
  color: var(--text-muted);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  height: var(--control-height-sm);
  padding: 0 var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-default);
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
  flex-shrink: 0;
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

.status-dot.warning {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
  height: 24px;
  border: none;
  padding: 0;
  margin: 0;
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--accent);
  border: 2px solid var(--bg-app);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  margin-top: -6px;
  transition: all var(--transition-fast);
}

input[type="range"]:hover::-webkit-slider-thumb {
  background: var(--accent-hover);
  box-shadow: 0 0 10px var(--accent-glow);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--accent);
  border: 2px solid var(--bg-app);
  cursor: pointer;
  transition: all var(--transition-fast);
}

input[type="number"],
input[type="text"],
select {
  height: var(--control-height-md);
  padding: 0 var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  color: var(--text-primary);
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
  outline: none;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa1b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.num-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 var(--space-sm);
  height: var(--control-height-md);
}

.num-input-wrap input {
  border: none;
  background: transparent;
  padding: 0;
  width: 64px;
  text-align: right;
  height: 100%;
  font-family: var(--font-mono);
  font-weight: 600;
}

.num-input-wrap .unit {
  font-size: var(--font-xs);
  color: var(--text-muted);
  font-weight: 600;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.switch-slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-muted);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.switch input:checked + .switch-slider {
  background-color: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
  background-color: var(--on-accent);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.setting-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.setting-row:first-child {
  padding-top: 0;
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.setting-label {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.setting-help {
  font-size: var(--font-xs);
  color: var(--text-muted);
  line-height: 1.4;
}

.segment-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3xs);
  gap: var(--space-3xs);
}

.segment-btn {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.segment-btn:hover {
  color: var(--text-primary);
}

.segment-btn.active {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}

.dpi-stage-row {
  display: grid;
  grid-template-columns: 36px 36px 1fr 110px 40px;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.dpi-stage-row.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.dpi-stage-number {
  font-size: var(--font-xs);
  font-weight: 700;
  color: var(--text-muted);
}

.dpi-color-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-default);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.dpi-color-btn input[type="color"] {
  position: absolute;
  inset: -10px;
  width: 50px;
  height: 50px;
  opacity: 0;
  cursor: pointer;
}

.macro-step-row {
  grid-template-columns: 24px 80px 1fr 90px 32px;
  padding: var(--space-xs) var(--space-md);
}

.notify-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 380px;
  width: 100%;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-sm);
  color: var(--text-primary);
  animation: toastSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all var(--transition-fast);
}

@keyframes toastSlide {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}

.toast.info {
  border-left: 4px solid var(--info);
}

.toast .toast-icon {
  flex-shrink: 0;
  margin-top: 2px;
}

.toast .toast-msg {
  flex: 1;
  line-height: 1.4;
}

.toast .toast-close {
  color: var(--text-muted);
  cursor: pointer;
}

.toast .toast-close:hover {
  color: var(--text-primary);
}

.firmware-drop {
  border: 1px dashed var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  transition: all var(--transition-fast);
}

.firmware-drop:hover,
.firmware-drop.dragging {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.firmware-drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--font-sm);
  text-align: center;
}

.firmware-drop-inner code,
.firmware-drop code {
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

.firmware-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.firmware-meta div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
}

.firmware-meta span {
  color: var(--text-muted);
}

.firmware-meta strong {
  font-family: var(--font-mono);
  font-weight: 600;
}

.firmware-errors {
  margin: var(--space-md) 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: var(--space-xs);
  color: var(--danger);
  font-size: var(--font-xs);
}

.firmware-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.firmware-badge.success {
  color: var(--success);
  border-color: var(--success-border);
}

.firmware-badge.warning {
  color: var(--warning);
  border-color: var(--warning-border);
}

.firmware-badge.danger {
  color: var(--danger);
  border-color: var(--danger-border);
}

.badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.scroll-list {
  max-height: 480px;
  overflow-y: auto;
}

.step-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  max-height: 280px;
  overflow-y: auto;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.flex-gap-xs {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.segment-wrap {
  display: flex;
  flex-wrap: wrap;
}

.clickable {
  cursor: pointer;
}

.icon-danger {
  color: var(--danger);
  padding: 0;
}

.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-muted);
}

.empty-state p {
  margin: 0 0 var(--space-md);
  font-size: var(--font-sm);
}

.empty-state--lg {
  padding: var(--space-4xl) 0;
}

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-xs);
  padding: var(--space-xl) 0;
}

.mt-md {
  margin-top: var(--space-md);
}

.self-start {
  align-self: flex-start;
}

.step-idx {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.step-value {
  font-size: var(--font-xs);
  color: var(--text-primary);
  font-weight: 600;
}

.step-delay-input {
  width: 52px;
  font-size: 11px;
}

.num-input-wrap.compact {
  height: 26px;
}

.select-sm {
  height: var(--control-height-sm);
  max-width: 130px;
}

.name-input {
  max-width: 220px;
}
