.comfyui-device-selector-section {
  display: grid;
  gap: 8px;
}

.comfyui-device-selector-section > h3 {
  margin: 0;
  color: #111827;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.comfyui-device-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 248px;
  overflow-y: auto;
  padding: 1px;
}

.comfyui-device-card {
  min-width: 0;
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px;
  border: 1px solid #e8edf5;
  border-radius: var(--rect-radius, 8px);
  color: #4b5563;
  background: #fff;
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.comfyui-device-card:not(:disabled):hover {
  border-color: #b8e8f8;
  background: #f6fcfe;
}

.comfyui-device-card:not(:disabled):active {
  transform: translateY(1px);
}

.comfyui-device-card.is-selected {
  border-color: #00afe9;
  background: #eefaff;
  box-shadow: 0 0 0 1px rgba(0, 175, 233, 0.12);
}

.comfyui-device-card:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.comfyui-device-card__topline {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #111827;
  font-size: 14px;
  line-height: 1.4;
}

.comfyui-device-card__topline strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comfyui-device-card__model,
.comfyui-device-card__helper,
.comfyui-device-selector__notice,
.comfyui-device-selector__loading,
.comfyui-device-selector__empty {
  margin: 0;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.5;
}

.comfyui-device-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  color: #6b7280;
  background: #f3f4f6;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.comfyui-device-status.is-idle {
  color: #027a35;
  background: #ecfdf3;
}

.comfyui-device-status.is-busy {
  color: #007ea8;
  background: #eaf9fe;
}

.comfyui-device-status.is-offline {
  color: #cd140f;
  background: #fff1f0;
}

.comfyui-device-selector__notice {
  margin-top: 8px;
}

.comfyui-device-selector__notice.is-warning {
  color: #cd140f;
}

.canvas-tool-device-dialog .comfyui-device-selector--compact-inline {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: none;
  overflow: visible;
  padding: 0;
}

.comfyui-device-option {
  min-width: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 8px;
  border: 1px solid #e8edf5;
  border-radius: var(--rect-radius, 8px);
  color: #344054;
  background: #fff;
  text-align: center;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.comfyui-device-option:not(:disabled):hover {
  border-color: #c7ecf8;
  background: #f7fcfe;
}

.comfyui-device-option:not(:disabled):active {
  transform: translateY(1px);
}

.comfyui-device-option.is-selected {
  border-color: #00afe9;
  background: #e7f8fe;
}

.comfyui-device-option:disabled {
  cursor: not-allowed;
  color: #98a2b3;
  background: #f8fafc;
  border-color: #eef2f6;
  opacity: 1;
}

.comfyui-device-option__radio {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: grid;
  place-items: center;
  border: 1.5px solid #98a2b3;
  border-radius: 50%;
  background: #fff;
}

.comfyui-device-option.is-selected .comfyui-device-option__radio {
  border-color: #00afe9;
}

.comfyui-device-option.is-selected .comfyui-device-option__radio::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00afe9;
}

.comfyui-device-option:disabled .comfyui-device-option__radio {
  border-color: #cfd6df;
  background: #f2f4f7;
}

.comfyui-device-option__label {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comfyui-device-option__state.is-online {
  color: #03b144;
}

.comfyui-device-option__state.is-busy,
.comfyui-device-option__state.is-offline {
  color: #98a2b3;
}

.canvas-tool-device-overlay {
  position: fixed;
  inset: 0;
  z-index: 1340;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.34);
}

.canvas-tool-device-overlay.is-open {
  display: grid;
}

.canvas-tool-device-dialog {
  width: min(560px, calc(100vw - 32px));
  display: grid;
  gap: 0;
  padding: 0;
  border: 1px solid #e8edf5;
  border-radius: var(--rect-radius, 8px);
  background: #fff;
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.16);
}

.canvas-tool-device-dialog__header,
.canvas-tool-device-dialog__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
}

.canvas-tool-device-dialog__header {
  min-height: 64px;
  border-bottom: 1px solid #e8edf5;
}

.canvas-tool-device-dialog__header h2 {
  margin: 0;
  color: #111827;
  font-size: 18px;
  font-weight: 600;
  line-height: 26px;
}

.canvas-tool-device-dialog > .comfyui-device-selector-section {
  padding: 16px 20px;
}

.canvas-tool-device-dialog__footer {
  min-height: 68px;
  justify-content: flex-end;
  border-top: 1px solid #e8edf5;
}

.canvas-tool-device-dialog__footer .ghost-button,
.canvas-tool-device-dialog__footer .primary-button {
  font-weight: 400;
}

@media (max-width: 680px) {
  .comfyui-device-selector {
    grid-template-columns: minmax(0, 1fr);
  }

  .canvas-tool-device-overlay {
    padding: 16px;
  }
}

@media (min-width: 1920px) {
  .comfyui-device-selector-section > h3,
  .comfyui-device-card__topline {
    font-size: 16px;
  }

  .comfyui-device-card__model,
  .comfyui-device-card__helper,
  .comfyui-device-selector__notice,
  .comfyui-device-selector__loading,
  .comfyui-device-selector__empty,
  .comfyui-device-status {
    font-size: 14px;
  }
}
